diff --git a/src/doc/testing.html b/src/doc/testing.html index 1c5a4ccdceb..4e48c15bdd1 100644 --- a/src/doc/testing.html +++ b/src/doc/testing.html @@ -35,6 +35,9 @@

Testing the JDK

  • JTReg keywords
  • Gtest keywords
  • +
  • Notes for Specific Tests
  • Using the run-test framework

    @@ -123,5 +126,11 @@

    REPEAT

    OPTIONS

    Additional options to the Gtest test framework.

    Use GTEST="OPTIONS=--help" to see all available Gtest options.

    +

    Notes for Specific Tests

    +

    Docker Tests

    +

    Docker tests with default parameters may fail on systems with glibc versions not compatible with the one used in the default docker image (e.g., Oracle Linux 7.6 for x86). For example, they pass on Ubuntu 16.04 but fail on Ubuntu 18.04 if run like this on x86:

    +
    $ make run-test TEST="jtreg:test/hotspot/jtreg/containers/docker"
    +

    To run these tests correctly, additional parameters for the correct docker image are required on Ubuntu 18.04 by using JAVA_OPTIONS.

    +
    $ make run-test TEST="jtreg:test/hotspot/jtreg/containers/docker" JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest"
    diff --git a/src/doc/testing.md b/src/doc/testing.md index 7aa40a6c42b..c4ab2801f14 100644 --- a/src/doc/testing.md +++ b/src/doc/testing.md @@ -230,6 +230,21 @@ Additional options to the Gtest test framework. Use `GTEST="OPTIONS=--help"` to see all available Gtest options. +## Notes for Specific Tests + +### Docker Tests + +Docker tests with default parameters may fail on systems with glibc versions not +compatible with the one used in the default docker image (e.g., Oracle Linux 7.6 for x86). +For example, they pass on Ubuntu 16.04 but fail on Ubuntu 18.04 if run like this on x86: + + $ make run-test TEST="jtreg:test/hotspot/jtreg/containers/docker" + +To run these tests correctly, additional parameters for the correct docker image are +required on Ubuntu 18.04 by using `JAVA_OPTIONS`. + + $ make run-test TEST="jtreg:test/hotspot/jtreg/containers/docker" JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest" + --- # Override some definitions in the global css file that are not optimal for # this document. diff --git a/src/make/CompileToolsJdk.gmk b/src/make/CompileToolsJdk.gmk index 14966405ed1..0856e72937e 100644 --- a/src/make/CompileToolsJdk.gmk +++ b/src/make/CompileToolsJdk.gmk @@ -40,6 +40,7 @@ $(eval $(call IncludeCustomExtension, CompileTools.gmk)) BUILD_TOOLS_SRC_DIRS += \ $(TOPDIR)/make/jdk/src/classes \ $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes \ + $(BUILDTOOLS_OUTPUTDIR)/interim_tzdb_classes \ # $(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \ diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/factory b/src/make/CopyInterimTZDB.gmk similarity index 56% rename from src/test/jdk/sun/util/calendar/zi/tzdata/factory rename to src/make/CopyInterimTZDB.gmk index 6ef6bca0b8c..6ce41865e2c 100644 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/factory +++ b/src/make/CopyInterimTZDB.gmk @@ -1,4 +1,5 @@ # +# Copyright (c) 2019, 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 @@ -21,15 +22,29 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# tzdb data for noncommittal factory settings -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. +default: all -# For distributors who don't want to specify a timezone in their -# installation procedures. Users who run 'date' will get the -# time zone abbreviation "-00", indicating that the actual time zone -# is unknown. +include $(SPEC) +include MakeBase.gmk -# Zone NAME GMTOFF RULES FORMAT -Zone Factory 0 - -00 +########################################################################################## + +### TZDB tool needs files from java.time.zone package + +define tzdb_copyfiles + $(call MakeTargetDir) + $(RM) '$@' + $(SED) -e "s/package java.time.zone/package build.tools.tzdb/" \ + < $(<) > $@ +endef + +$(eval $(call SetupCopyFiles,COPY_INTERIM_TZDB, \ + SRC := $(TOPDIR)/src/java.base/share/classes/java/time/zone, \ + DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_tzdb_classes/build/tools/tzdb, \ + FILES := ZoneRules.java ZoneOffsetTransition.java ZoneOffsetTransitionRule.java Ser.java, \ + MACRO := tzdb_copyfiles)) + +########################################################################################## + +all: $(COPY_INTERIM_TZDB) diff --git a/src/make/ExplodedImageOptimize.gmk b/src/make/ExplodedImageOptimize.gmk index dedac6db738..78d4189efd8 100644 --- a/src/make/ExplodedImageOptimize.gmk +++ b/src/make/ExplodedImageOptimize.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ ALL_MODULEINFO_CLASSES := $(wildcard $(JDK_OUTPUTDIR)/modules/*/module_info.clas $(PACKAGES_ATTRIBUTE_TARGET): $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES) $(call LogInfo, Optimizing the exploded image) - $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR) + $(call ExecuteWithLog, $@, $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR)) $(TOUCH) $@ TARGETS := $(PACKAGES_ATTRIBUTE_TARGET) diff --git a/src/make/InitSupport.gmk b/src/make/InitSupport.gmk index 8f2d2b92707..baefc8941b3 100644 --- a/src/make/InitSupport.gmk +++ b/src/make/InitSupport.gmk @@ -421,8 +421,8 @@ else # $(HAS_SPEC)=true $(if $(filter all, $(LOG_REPORT)), \ $(GREP) -v -e "^Note: including file:" < $(logfile) || true $(NEWLINE) \ , \ - ($(GREP) -v -e "^Note: including file:" < $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \ - if test `$(WC) -l < $(logfile)` -gt 12; then \ + ($(GREP) -v -e "^Note: including file:" < $(logfile) || true) | $(HEAD) -n 15 $(NEWLINE) \ + if test `$(WC) -l < $(logfile)` -gt 15; then \ $(ECHO) " ... (rest of output omitted)" ; \ fi $(NEWLINE) \ ) \ diff --git a/src/make/Main.gmk b/src/make/Main.gmk index 00097d19ff5..f4757f3a946 100644 --- a/src/make/Main.gmk +++ b/src/make/Main.gmk @@ -80,6 +80,10 @@ ifneq ($(CREATING_BUILDJDK), true) interim-cldrconverter: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk) + +interim-tzdb: + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimTZDB.gmk) + buildtools-jdk: +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileToolsJdk.gmk) @@ -92,7 +96,7 @@ ifneq ($(CREATING_BUILDJDK), true) endif ALL_TARGETS += buildtools-langtools interim-langtools \ - interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules \ + interim-rmic interim-cldrconverter interim-tzdb buildtools-jdk buildtools-modules \ buildtools-hotspot ################################################################################ @@ -610,7 +614,7 @@ else interim-langtools: $(INTERIM_LANGTOOLS_GENSRC_TARGETS) - buildtools-jdk: interim-langtools interim-cldrconverter + buildtools-jdk: interim-langtools interim-cldrconverter interim-tzdb buildtools-hotspot: interim-langtools diff --git a/src/make/RunTests.gmk b/src/make/RunTests.gmk index 1ffe735667b..af958831be7 100644 --- a/src/make/RunTests.gmk +++ b/src/make/RunTests.gmk @@ -44,11 +44,23 @@ TEST_JOBS_FACTOR_JDL ?= 1 TEST_JOBS_FACTOR_MACHINE ?= 1 ifeq ($(TEST_JOBS), 0) - # Concurrency based on min(cores / 2, 12) * TEST_JOBS_FACTOR + CORES_DIVIDER := 2 + ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + # For smaller SPARC machines we see reasonable scaling of throughput up to + # cpus/4 without affecting test reliability. On the bigger machines, cpus/4 + # causes intermittent timeouts. + ifeq ($(shell $(EXPR) $(NUM_CORES) \> 16), 1) + CORES_DIVIDER := 5 + else + CORES_DIVIDER := 4 + endif + endif + MEMORY_DIVIDER := 2048 TEST_JOBS := $(shell $(AWK) \ 'BEGIN { \ - c = $(NUM_CORES) / 2; \ - if (c > 12) c = 12; \ + c = $(NUM_CORES) / $(CORES_DIVIDER); \ + m = $(MEMORY_SIZE) / $(MEMORY_DIVIDER); \ + if (c > m) c = m; \ c = c * $(TEST_JOBS_FACTOR); \ c = c * $(TEST_JOBS_FACTOR_JDL); \ c = c * $(TEST_JOBS_FACTOR_MACHINE); \ @@ -501,7 +513,12 @@ define SetupRunJtregTestBody # we may end up with a lot of JVM's $1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $$(EXPR) 25 / $$($1_JTREG_JOBS)) - JTREG_TIMEOUT ?= 4 + # SPARC is in general slower per core so need to scale up timeouts a bit. + ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) + JTREG_TIMEOUT ?= 8 + else + JTREG_TIMEOUT ?= 4 + endif JTREG_VERBOSE ?= fail,error,summary JTREG_RETAIN ?= fail,error diff --git a/src/make/RunTestsPrebuilt.gmk b/src/make/RunTestsPrebuilt.gmk index 2660e766e25..888393a141b 100644 --- a/src/make/RunTestsPrebuilt.gmk +++ b/src/make/RunTestsPrebuilt.gmk @@ -87,12 +87,12 @@ endef # $1: The output file name # $2..$N: The lines to output to the file define CreateNewSpec - $(if $(strip $(26)), \ + $(if $(strip $(27)), \ $(error Internal makefile error: \ Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \ ) \ $(shell $(RM) $1) \ - $(foreach i, $(call sequence, 2, 25), \ + $(foreach i, $(call sequence, 2, 26), \ $(if $(strip $($i)), \ $(call AppendFile, $(strip $($i)), $1) \ ) \ @@ -212,17 +212,29 @@ else PATH_SEP:=: endif -# Check number of cores +# Check number of cores and memory in MB ifeq ($(OPENJDK_TARGET_OS), linux) NUM_CORES := $(shell $(CAT) /proc/cpuinfo | $(GREP) -c processor) + MEMORY_SIZE := $(shell \ + $(EXPR) `$(CAT) /proc/meminfo | $(GREP) MemTotal | $(AWK) '{print $$2}'` / 1024 \ + ) else ifeq ($(OPENJDK_TARGET_OS), macosx) NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu) + MEMORY_SIZE := $(shell $(EXPR) `/usr/sbin/sysctl -n hw.memsize` / 1024 / 1024) else ifeq ($(OPENJDK_TARGET_OS), solaris) NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | $(GREP) -c on-line) + MEMORY_SIZE := $(shell \ + /usr/sbin/prtconf 2> /dev/null | $(GREP) "^Memory [Ss]ize" | $(AWK) '{print $$3}' \ + ) else ifeq ($(OPENJDK_TARGET_OS), windows) NUM_CORES := $(NUMBER_OF_PROCESSORS) + MEMORY_SIZE := $(shell \ + $(EXPR) `wmic computersystem get totalphysicalmemory -value | $(GREP) = \ + | $(CUT) -d "=" -f 2-` / 1024 / 1024 \ + ) else NUM_CORES := 1 + MEMORY_SIZE := 1024 endif ################################################################################ @@ -260,6 +272,7 @@ $(call CreateNewSpec, $(NEW_SPEC), \ OPENJDK_TARGET_CPU_BITS := $(OPENJDK_TARGET_CPU_BITS), \ OPENJDK_TARGET_CPU_ENDIAN := $(OPENJDK_TARGET_CPU_ENDIAN), \ NUM_CORES := $(NUM_CORES), \ + MEMORY_SIZE := $(MEMORY_SIZE), \ include $(TOPDIR)/make/RunTestsPrebuiltSpec.gmk, \ $(CUSTOM_NEW_SPEC_LINE), \ ) diff --git a/src/make/autoconf/build-performance.m4 b/src/make/autoconf/build-performance.m4 index 72799148692..0731da2a230 100644 --- a/src/make/autoconf/build-performance.m4 +++ b/src/make/autoconf/build-performance.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2019, 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 @@ -42,8 +42,11 @@ AC_DEFUN([BPERF_CHECK_CORES], NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu` FOUND_CORES=yes elif test "x$OPENJDK_BUILD_OS" = xaix ; then - NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'` - FOUND_CORES=yes + NUM_LCPU=`lparstat -m 2> /dev/null | $GREP -o "lcpu=[[0-9]]*" | $CUT -d "=" -f 2` + if test -n "$NUM_LCPU"; then + NUM_CORES=$NUM_LCPU + FOUND_CORES=yes + fi elif test -n "$NUMBER_OF_PROCESSORS"; then # On windows, look in the env NUM_CORES=$NUMBER_OF_PROCESSORS diff --git a/src/make/autoconf/flags-other.m4 b/src/make/autoconf/flags-other.m4 index ffd093ee1bd..dbbeaf11cf4 100644 --- a/src/make/autoconf/flags-other.m4 +++ b/src/make/autoconf/flags-other.m4 @@ -31,9 +31,7 @@ AC_DEFUN([FLAGS_SETUP_ARFLAGS], [ # FIXME: figure out if we should select AR flags depending on OS or toolchain. - if test "x$OPENJDK_TARGET_OS" = xmacosx; then - ARFLAGS="-r -mmacosx-version-min=$MACOSX_VERSION_MIN" - elif test "x$OPENJDK_TARGET_OS" = xaix; then + if test "x$OPENJDK_TARGET_OS" = xaix; then ARFLAGS="-X64" elif test "x$OPENJDK_TARGET_OS" = xwindows; then # lib.exe is used as AR to create static libraries. diff --git a/src/make/autoconf/flags.m4 b/src/make/autoconf/flags.m4 index 472e7a638a2..1ffc437268e 100644 --- a/src/make/autoconf/flags.m4 +++ b/src/make/autoconf/flags.m4 @@ -335,8 +335,12 @@ AC_DEFUN([FLAGS_SETUP_TOOLCHAIN_CONTROL], CC_OUT_OPTION='-o$(SPACE)' # When linking, how to specify the output LD_OUT_OPTION='-o$(SPACE)' - # When archiving, how to specify the to be create static archive for object files. - AR_OUT_OPTION='rcs$(SPACE)' + # When archiving, how to specify the destination static archive. + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + AR_OUT_OPTION='-r -cs$(SPACE)' + else + AR_OUT_OPTION='-rcs$(SPACE)' + fi fi AC_SUBST(CC_OUT_OPTION) AC_SUBST(LD_OUT_OPTION) diff --git a/src/make/autoconf/lib-x11.m4 b/src/make/autoconf/lib-x11.m4 index df3eb0f1383..50a4d863a72 100644 --- a/src/make/autoconf/lib-x11.m4 +++ b/src/make/autoconf/lib-x11.m4 @@ -117,7 +117,7 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], if test "x$X11_HEADERS_OK" = xno; then HELP_MSG_MISSING_DEPENDENCY([x11]) - AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h Xrander.h XTest.h Intrinsic.h). $HELP_MSG]) + AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h Xrandr.h XTest.h Intrinsic.h). $HELP_MSG]) fi # If XLinearGradient isn't available in Xrender.h, signal that it needs to be diff --git a/src/make/autoconf/libraries.m4 b/src/make/autoconf/libraries.m4 index ab40c8bd22e..a73c0f38181 100644 --- a/src/make/autoconf/libraries.m4 +++ b/src/make/autoconf/libraries.m4 @@ -130,6 +130,11 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES], BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lthread" fi + # perfstat lib + if test "x$OPENJDK_TARGET_OS" = xaix; then + BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat" + fi + if test "x$OPENJDK_TARGET_OS" = xsolaris; then BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lsocket -lsched -ldoor -ldemangle -lnsl \ -lrt -lkstat" diff --git a/src/make/autoconf/version-numbers b/src/make/autoconf/version-numbers index 69e5e834bbf..fec9997e75a 100644 --- a/src/make/autoconf/version-numbers +++ b/src/make/autoconf/version-numbers @@ -27,12 +27,12 @@ DEFAULT_VERSION_FEATURE=11 DEFAULT_VERSION_INTERIM=0 -DEFAULT_VERSION_UPDATE=4 +DEFAULT_VERSION_UPDATE=5 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2019-07-16 +DEFAULT_VERSION_DATE=2019-10-15 DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11" diff --git a/src/make/data/lsrdata/language-subtag-registry.txt b/src/make/data/lsrdata/language-subtag-registry.txt index 67b3705749e..9fea9cecd11 100644 --- a/src/make/data/lsrdata/language-subtag-registry.txt +++ b/src/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2018-11-30 +File-Date: 2019-04-03 %% Type: language Subtag: aa @@ -43008,6 +43008,7 @@ Subtag: lsg Description: Lyons Sign Language Added: 2009-07-29 Deprecated: 2018-03-08 +Preferred-Value: lsg Prefix: sgn %% Type: extlang @@ -43406,6 +43407,7 @@ Subtag: rsi Description: Rennellese Sign Language Added: 2009-07-29 Deprecated: 2017-02-23 +Preferred-Value: rsi Prefix: sgn %% Type: extlang @@ -43760,6 +43762,7 @@ Subtag: yds Description: Yiddish Sign Language Added: 2009-07-29 Deprecated: 2015-02-12 +Preferred-Value: yds Prefix: sgn %% Type: extlang @@ -46537,16 +46540,16 @@ Subtag: arevela Description: Eastern Armenian Added: 2006-09-18 Deprecated: 2018-03-24 -Preferred-Value: hy Prefix: hy +Comments: Preferred tag is hy %% Type: variant Subtag: arevmda Description: Western Armenian Added: 2006-09-18 Deprecated: 2018-03-24 -Preferred-Value: hyw Prefix: hy +Comments: Preferred tag is hyw %% Type: variant Subtag: asante @@ -46642,6 +46645,12 @@ Prefix: en Comments: Jargon embedded in American English %% Type: variant +Subtag: bornholm +Description: Bornholmsk +Added: 2019-03-27 +Prefix: da +%% +Type: variant Subtag: cisaup Description: Cisalpine Added: 2018-04-22 diff --git a/src/make/data/tzdata/VERSION b/src/make/data/tzdata/VERSION index e3fa9222bcf..53851281fd5 100644 --- a/src/make/data/tzdata/VERSION +++ b/src/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2018g +tzdata2019b diff --git a/src/make/data/tzdata/africa b/src/make/data/tzdata/africa index e2ffac25ec1..cfce2ca8df9 100644 --- a/src/make/data/tzdata/africa +++ b/src/make/data/tzdata/africa @@ -112,7 +112,7 @@ Rule Algeria 1980 only - Apr 25 0:00 1:00 S Rule Algeria 1980 only - Oct 31 2:00 0 - # Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's # more precise 0:09:21. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Algiers 0:12:12 - LMT 1891 Mar 15 0:01 0:09:21 - PMT 1911 Mar 11 # Paris Mean Time 0:00 Algeria WE%sT 1940 Feb 25 2:00 @@ -147,7 +147,7 @@ Zone Africa/Algiers 0:12:12 - LMT 1891 Mar 15 0:01 # For now, ignore that and follow the 1911-05-26 Portuguese decree # (see Europe/Lisbon). # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Atlantic/Cape_Verde -1:34:04 - LMT 1912 Jan 01 2:00u # Praia -2:00 - -02 1942 Sep -2:00 1:00 -01 1945 Oct 15 @@ -158,7 +158,7 @@ Zone Atlantic/Cape_Verde -1:34:04 - LMT 1912 Jan 01 2:00u # Praia # See Africa/Lagos. # Chad -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Ndjamena 1:00:12 - LMT 1912 # N'Djamena 1:00 - WAT 1979 Oct 14 1:00 1:00 WAST 1980 Mar 8 @@ -174,7 +174,7 @@ Zone Africa/Ndjamena 1:00:12 - LMT 1912 # N'Djamena # See Africa/Lagos. # Côte d'Ivoire / Ivory Coast -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Abidjan -0:16:08 - LMT 1912 0:00 - GMT Link Africa/Abidjan Africa/Bamako # Mali @@ -379,7 +379,7 @@ Rule Egypt 2014 only - Jun 26 24:00 0 - Rule Egypt 2014 only - Jul 31 24:00 1:00 S Rule Egypt 2014 only - Sep lastThu 24:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Cairo 2:05:09 - LMT 1900 Oct 2:00 Egypt EE%sT @@ -387,6 +387,11 @@ Zone Africa/Cairo 2:05:09 - LMT 1900 Oct # See Africa/Lagos. # Eritrea +# See Africa/Nairobi. + +# Eswatini (formerly Swaziland) +# See Africa/Johannesburg. + # Ethiopia # See Africa/Nairobi. # @@ -432,7 +437,7 @@ Zone Africa/Cairo 2:05:09 - LMT 1900 Oct # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Ghana 1920 1942 - Sep 1 0:00 0:20 - Rule Ghana 1920 1942 - Dec 31 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Accra -0:00:52 - LMT 1918 0:00 Ghana GMT/+0020 @@ -446,13 +451,13 @@ Zone Africa/Accra -0:00:52 - LMT 1918 # evidently confusing the date of the Portuguese decree # (see Europe/Lisbon) with the date that it took effect. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Bissau -1:02:20 - LMT 1912 Jan 1 1:00u -1:00 - -01 1975 0:00 - GMT # Kenya -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Nairobi 2:27:16 - LMT 1928 Jul 3:00 - EAT 1930 2:30 - +0230 1940 @@ -487,7 +492,7 @@ Link Africa/Nairobi Indian/Mayotte # Use the abbreviation "MMT" before 1972, as the more-accurate numeric # abbreviation "-004430" would be one byte over the POSIX limit. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Monrovia -0:43:08 - LMT 1882 -0:43:08 - MMT 1919 Mar # Monrovia Mean Time -0:44:30 - MMT 1972 Jan 7 # approximately MMT @@ -537,7 +542,7 @@ Rule Libya 1997 only - Apr 4 0:00 1:00 S Rule Libya 1997 only - Oct 4 0:00 0 - Rule Libya 2013 only - Mar lastFri 1:00 1:00 S Rule Libya 2013 only - Oct lastFri 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Tripoli 0:52:44 - LMT 1920 1:00 Libya CE%sT 1959 2:00 - EET 1982 @@ -647,7 +652,7 @@ Rule Mauritius 1982 only - Oct 10 0:00 1:00 - Rule Mauritius 1983 only - Mar 21 0:00 0 - Rule Mauritius 2008 only - Oct lastSun 2:00 1:00 - Rule Mauritius 2009 only - Mar lastSun 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis 4:00 Mauritius +04/+05 # Agalega Is, Rodriguez @@ -870,8 +875,47 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # From Mohamed Essedik Najd (2018-10-26): # Today, a Moroccan government council approved the perpetual addition # of 60 minutes to the regular Moroccan timezone. -# From Brian Inglis (2018-10-26): -# http://www.maroc.ma/fr/actualites/le-conseil-de-gouvernement-adopte-un-projet-de-decret-relatif-lheure-legale-stipulant-le +# From Matt Johnson (2018-10-28): +# http://www.sgg.gov.ma/Portals/1/BO/2018/BO_6720-bis_Ar.pdf +# +# From Maamar Abdelkader (2018-11-01): +# We usually move clocks back the previous week end and come back to the +1 +# the week end after.... The government does not announce yet the decision +# about this temporary change. But it s 99% sure that it will be the case, +# as in previous years. An unofficial survey was done these days, showing +# that 64% of asked people are ok for moving from +1 to +0 during Ramadan. +# https://leconomiste.com/article/1035870-enquete-l-economiste-sunergia-64-des-marocains-plebiscitent-le-gmt-pendant-ramadan + +# From Naoufal Semlali (2019-04-16): +# Morocco will be on GMT starting from Sunday, May 5th 2019 at 3am. +# The switch to GMT+1 will occur on Sunday, June 9th 2019 at 2am.... +# http://fr.le360.ma/societe/voici-la-date-du-retour-a-lheure-legale-au-maroc-188222 +# +# From Paul Eggert (2019-05-20): +# This agrees with our 2018-11-01 guess that the Moroccan government +# would continue the practice of falling back at 03:00 the last Sunday +# before Ramadan, and of springing forward at 02:00 the first Sunday after +# Ramadan, as this has been the practice since 2012. To implement this, +# transition dates for 2019 through 2087 were determined by running the +# following program under GNU Emacs 26.2. +# (let ((islamic-year 1440)) +# (require 'cal-islam) +# (while (< islamic-year 1511) +# (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year))) +# (b (calendar-islamic-to-absolute (list 10 1 islamic-year))) +# (sunday 0)) +# (while (/= sunday (mod (setq a (1- a)) 7))) +# (while (/= sunday (mod b 7)) +# (setq b (1+ b))) +# (setq a (calendar-gregorian-from-absolute a)) +# (setq b (calendar-gregorian-from-absolute b)) +# (insert +# (format +# (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 3:00\t-1:00\t-\n" +# "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 2:00\t0\t-\n") +# (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a)) +# (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b))))) +# (setq islamic-year (+ 1 islamic-year)))) # RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Morocco 1939 only - Sep 12 0:00 1:00 - @@ -915,13 +959,159 @@ Rule Morocco 2017 only - May 21 3:00 0 - Rule Morocco 2017 only - Jul 2 2:00 1:00 - Rule Morocco 2018 only - May 13 3:00 0 - Rule Morocco 2018 only - Jun 17 2:00 1:00 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Rule Morocco 2019 only - May 5 3:00 -1:00 - +Rule Morocco 2019 only - Jun 9 2:00 0 - +Rule Morocco 2020 only - Apr 19 3:00 -1:00 - +Rule Morocco 2020 only - May 24 2:00 0 - +Rule Morocco 2021 only - Apr 11 3:00 -1:00 - +Rule Morocco 2021 only - May 16 2:00 0 - +Rule Morocco 2022 only - Mar 27 3:00 -1:00 - +Rule Morocco 2022 only - May 8 2:00 0 - +Rule Morocco 2023 only - Mar 19 3:00 -1:00 - +Rule Morocco 2023 only - Apr 23 2:00 0 - +Rule Morocco 2024 only - Mar 10 3:00 -1:00 - +Rule Morocco 2024 only - Apr 14 2:00 0 - +Rule Morocco 2025 only - Feb 23 3:00 -1:00 - +Rule Morocco 2025 only - Apr 6 2:00 0 - +Rule Morocco 2026 only - Feb 15 3:00 -1:00 - +Rule Morocco 2026 only - Mar 22 2:00 0 - +Rule Morocco 2027 only - Feb 7 3:00 -1:00 - +Rule Morocco 2027 only - Mar 14 2:00 0 - +Rule Morocco 2028 only - Jan 23 3:00 -1:00 - +Rule Morocco 2028 only - Feb 27 2:00 0 - +Rule Morocco 2029 only - Jan 14 3:00 -1:00 - +Rule Morocco 2029 only - Feb 18 2:00 0 - +Rule Morocco 2029 only - Dec 30 3:00 -1:00 - +Rule Morocco 2030 only - Feb 10 2:00 0 - +Rule Morocco 2030 only - Dec 22 3:00 -1:00 - +Rule Morocco 2031 only - Jan 26 2:00 0 - +Rule Morocco 2031 only - Dec 14 3:00 -1:00 - +Rule Morocco 2032 only - Jan 18 2:00 0 - +Rule Morocco 2032 only - Nov 28 3:00 -1:00 - +Rule Morocco 2033 only - Jan 9 2:00 0 - +Rule Morocco 2033 only - Nov 20 3:00 -1:00 - +Rule Morocco 2033 only - Dec 25 2:00 0 - +Rule Morocco 2034 only - Nov 5 3:00 -1:00 - +Rule Morocco 2034 only - Dec 17 2:00 0 - +Rule Morocco 2035 only - Oct 28 3:00 -1:00 - +Rule Morocco 2035 only - Dec 2 2:00 0 - +Rule Morocco 2036 only - Oct 19 3:00 -1:00 - +Rule Morocco 2036 only - Nov 23 2:00 0 - +Rule Morocco 2037 only - Oct 4 3:00 -1:00 - +Rule Morocco 2037 only - Nov 15 2:00 0 - +Rule Morocco 2038 only - Sep 26 3:00 -1:00 - +Rule Morocco 2038 only - Oct 31 2:00 0 - +Rule Morocco 2039 only - Sep 18 3:00 -1:00 - +Rule Morocco 2039 only - Oct 23 2:00 0 - +Rule Morocco 2040 only - Sep 2 3:00 -1:00 - +Rule Morocco 2040 only - Oct 14 2:00 0 - +Rule Morocco 2041 only - Aug 25 3:00 -1:00 - +Rule Morocco 2041 only - Sep 29 2:00 0 - +Rule Morocco 2042 only - Aug 10 3:00 -1:00 - +Rule Morocco 2042 only - Sep 21 2:00 0 - +Rule Morocco 2043 only - Aug 2 3:00 -1:00 - +Rule Morocco 2043 only - Sep 6 2:00 0 - +Rule Morocco 2044 only - Jul 24 3:00 -1:00 - +Rule Morocco 2044 only - Aug 28 2:00 0 - +Rule Morocco 2045 only - Jul 9 3:00 -1:00 - +Rule Morocco 2045 only - Aug 20 2:00 0 - +Rule Morocco 2046 only - Jul 1 3:00 -1:00 - +Rule Morocco 2046 only - Aug 5 2:00 0 - +Rule Morocco 2047 only - Jun 23 3:00 -1:00 - +Rule Morocco 2047 only - Jul 28 2:00 0 - +Rule Morocco 2048 only - Jun 7 3:00 -1:00 - +Rule Morocco 2048 only - Jul 19 2:00 0 - +Rule Morocco 2049 only - May 30 3:00 -1:00 - +Rule Morocco 2049 only - Jul 4 2:00 0 - +Rule Morocco 2050 only - May 15 3:00 -1:00 - +Rule Morocco 2050 only - Jun 26 2:00 0 - +Rule Morocco 2051 only - May 7 3:00 -1:00 - +Rule Morocco 2051 only - Jun 11 2:00 0 - +Rule Morocco 2052 only - Apr 28 3:00 -1:00 - +Rule Morocco 2052 only - Jun 2 2:00 0 - +Rule Morocco 2053 only - Apr 13 3:00 -1:00 - +Rule Morocco 2053 only - May 25 2:00 0 - +Rule Morocco 2054 only - Apr 5 3:00 -1:00 - +Rule Morocco 2054 only - May 10 2:00 0 - +Rule Morocco 2055 only - Mar 28 3:00 -1:00 - +Rule Morocco 2055 only - May 2 2:00 0 - +Rule Morocco 2056 only - Mar 12 3:00 -1:00 - +Rule Morocco 2056 only - Apr 23 2:00 0 - +Rule Morocco 2057 only - Mar 4 3:00 -1:00 - +Rule Morocco 2057 only - Apr 8 2:00 0 - +Rule Morocco 2058 only - Feb 17 3:00 -1:00 - +Rule Morocco 2058 only - Mar 31 2:00 0 - +Rule Morocco 2059 only - Feb 9 3:00 -1:00 - +Rule Morocco 2059 only - Mar 16 2:00 0 - +Rule Morocco 2060 only - Feb 1 3:00 -1:00 - +Rule Morocco 2060 only - Mar 7 2:00 0 - +Rule Morocco 2061 only - Jan 16 3:00 -1:00 - +Rule Morocco 2061 only - Feb 27 2:00 0 - +Rule Morocco 2062 only - Jan 8 3:00 -1:00 - +Rule Morocco 2062 only - Feb 12 2:00 0 - +Rule Morocco 2062 only - Dec 31 3:00 -1:00 - +Rule Morocco 2063 only - Feb 4 2:00 0 - +Rule Morocco 2063 only - Dec 16 3:00 -1:00 - +Rule Morocco 2064 only - Jan 20 2:00 0 - +Rule Morocco 2064 only - Dec 7 3:00 -1:00 - +Rule Morocco 2065 only - Jan 11 2:00 0 - +Rule Morocco 2065 only - Nov 22 3:00 -1:00 - +Rule Morocco 2066 only - Jan 3 2:00 0 - +Rule Morocco 2066 only - Nov 14 3:00 -1:00 - +Rule Morocco 2066 only - Dec 19 2:00 0 - +Rule Morocco 2067 only - Nov 6 3:00 -1:00 - +Rule Morocco 2067 only - Dec 11 2:00 0 - +Rule Morocco 2068 only - Oct 21 3:00 -1:00 - +Rule Morocco 2068 only - Dec 2 2:00 0 - +Rule Morocco 2069 only - Oct 13 3:00 -1:00 - +Rule Morocco 2069 only - Nov 17 2:00 0 - +Rule Morocco 2070 only - Oct 5 3:00 -1:00 - +Rule Morocco 2070 only - Nov 9 2:00 0 - +Rule Morocco 2071 only - Sep 20 3:00 -1:00 - +Rule Morocco 2071 only - Oct 25 2:00 0 - +Rule Morocco 2072 only - Sep 11 3:00 -1:00 - +Rule Morocco 2072 only - Oct 16 2:00 0 - +Rule Morocco 2073 only - Aug 27 3:00 -1:00 - +Rule Morocco 2073 only - Oct 8 2:00 0 - +Rule Morocco 2074 only - Aug 19 3:00 -1:00 - +Rule Morocco 2074 only - Sep 23 2:00 0 - +Rule Morocco 2075 only - Aug 11 3:00 -1:00 - +Rule Morocco 2075 only - Sep 15 2:00 0 - +Rule Morocco 2076 only - Jul 26 3:00 -1:00 - +Rule Morocco 2076 only - Sep 6 2:00 0 - +Rule Morocco 2077 only - Jul 18 3:00 -1:00 - +Rule Morocco 2077 only - Aug 22 2:00 0 - +Rule Morocco 2078 only - Jul 10 3:00 -1:00 - +Rule Morocco 2078 only - Aug 14 2:00 0 - +Rule Morocco 2079 only - Jun 25 3:00 -1:00 - +Rule Morocco 2079 only - Jul 30 2:00 0 - +Rule Morocco 2080 only - Jun 16 3:00 -1:00 - +Rule Morocco 2080 only - Jul 21 2:00 0 - +Rule Morocco 2081 only - Jun 1 3:00 -1:00 - +Rule Morocco 2081 only - Jul 13 2:00 0 - +Rule Morocco 2082 only - May 24 3:00 -1:00 - +Rule Morocco 2082 only - Jun 28 2:00 0 - +Rule Morocco 2083 only - May 16 3:00 -1:00 - +Rule Morocco 2083 only - Jun 20 2:00 0 - +Rule Morocco 2084 only - Apr 30 3:00 -1:00 - +Rule Morocco 2084 only - Jun 11 2:00 0 - +Rule Morocco 2085 only - Apr 22 3:00 -1:00 - +Rule Morocco 2085 only - May 27 2:00 0 - +Rule Morocco 2086 only - Apr 14 3:00 -1:00 - +Rule Morocco 2086 only - May 19 2:00 0 - +Rule Morocco 2087 only - Mar 30 3:00 -1:00 - +Rule Morocco 2087 only - May 4 2:00 0 - +# For dates after the somewhat-arbitrary cutoff of 2087, assume that +# Morocco will no longer observe DST. At some point this table will +# need to be extended, though quite possibly Morocco will change the +# rules first. + +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26 0:00 Morocco +00/+01 1984 Mar 16 1:00 - +01 1986 - 0:00 Morocco +00/+01 2018 Oct 27 - 1:00 - +01 + 0:00 Morocco +00/+01 2018 Oct 28 3:00 + 1:00 Morocco +01/+00 # Western Sahara # @@ -936,8 +1126,8 @@ Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26 Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan # El Aaiún -1:00 - -01 1976 Apr 14 - 0:00 Morocco +00/+01 2018 Oct 27 - 1:00 - +01 + 0:00 Morocco +00/+01 2018 Oct 28 3:00 + 1:00 Morocco +01/+00 # Mozambique # @@ -946,7 +1136,7 @@ Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan # El Aaiún # https://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf # merely made it official? # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Maputo 2:10:20 - LMT 1903 Mar 2:00 - CAT Link Africa/Maputo Africa/Blantyre # Malawi @@ -1009,37 +1199,37 @@ Link Africa/Maputo Africa/Lusaka # Zambia # RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Vanguard section, for zic and other parsers that support negative DST. -#Rule Namibia 1994 only - Mar 21 0:00 -1:00 WAT -#Rule Namibia 1994 2017 - Sep Sun>=1 2:00 0 CAT -#Rule Namibia 1995 2017 - Apr Sun>=1 2:00 -1:00 WAT +Rule Namibia 1994 only - Mar 21 0:00 -1:00 WAT +Rule Namibia 1994 2017 - Sep Sun>=1 2:00 0 CAT +Rule Namibia 1995 2017 - Apr Sun>=1 2:00 -1:00 WAT # Rearguard section, for parsers that do not support negative DST. -Rule Namibia 1994 only - Mar 21 0:00 0 WAT -Rule Namibia 1994 2017 - Sep Sun>=1 2:00 1:00 CAT -Rule Namibia 1995 2017 - Apr Sun>=1 2:00 0 WAT +#Rule Namibia 1994 only - Mar 21 0:00 0 WAT +#Rule Namibia 1994 2017 - Sep Sun>=1 2:00 1:00 CAT +#Rule Namibia 1995 2017 - Apr Sun>=1 2:00 0 WAT # End of rearguard section. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Windhoek 1:08:24 - LMT 1892 Feb 8 1:30 - +0130 1903 Mar 2:00 - SAST 1942 Sep 20 2:00 2:00 1:00 SAST 1943 Mar 21 2:00 2:00 - SAST 1990 Mar 21 # independence # Vanguard section, for zic and other parsers that support negative DST. -# 2:00 Namibia %s + 2:00 Namibia %s # Rearguard section, for parsers that do not support negative DST. - 2:00 - CAT 1994 Mar 21 0:00 +# 2:00 - CAT 1994 Mar 21 0:00 # From Paul Eggert (2017-04-07): # The official date of the 2017 rule change was 2017-10-24. See: # http://www.lac.org.na/laws/annoSTAT/Namibian%20Time%20Act%209%20of%202017.pdf - 1:00 Namibia %s 2017 Oct 24 - 2:00 - CAT +# 1:00 Namibia %s 2017 Oct 24 +# 2:00 - CAT # End of rearguard section. # Niger # See Africa/Lagos. # Nigeria -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Lagos 0:13:36 - LMT 1919 Sep 1:00 - WAT Link Africa/Lagos Africa/Bangui # Central African Republic @@ -1053,7 +1243,7 @@ Link Africa/Lagos Africa/Niamey # Niger Link Africa/Lagos Africa/Porto-Novo # Benin # Réunion -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Reunion 3:41:52 - LMT 1911 Jun # Saint-Denis 4:00 - +04 # @@ -1094,16 +1284,26 @@ Zone Indian/Reunion 3:41:52 - LMT 1911 Jun # Saint-Denis # the switch is from 01:00 to 02:00 ... [Decree No. 25/2017] # http://www.mnec.gov.st/index.php/publicacoes/documentos/file/90-decreto-lei-n-25-2017 +# From Vadim Nasardinov (2018-12-29): +# São Tomé and Príncipe is about to do the following on Jan 1, 2019: +# https://www.stp-press.st/2018/12/05/governo-jesus-ja-decidiu-repor-hora-legal-sao-tomense/ +# +# From Michael Deckers (2018-12-30): +# https://www.legis-palop.org/download.jsp?idFile=102818 +# ... [The legal time of the country, which coincides with universal +# coordinated time, will be restituted at 2 o'clock on day 1 of January, 2019.] + Zone Africa/Sao_Tome 0:26:56 - LMT 1884 -0:36:45 - LMT 1912 Jan 1 00:00u # Lisbon MT 0:00 - GMT 2018 Jan 1 01:00 - 1:00 - WAT + 1:00 - WAT 2019 Jan 1 02:00 + 0:00 - GMT # Senegal # See Africa/Abidjan. # Seychelles -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Mahe 3:41:48 - LMT 1906 Jun # Victoria 4:00 - +04 # From Paul Eggert (2001-05-30): @@ -1123,12 +1323,12 @@ Zone Indian/Mahe 3:41:48 - LMT 1906 Jun # Victoria # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule SA 1942 1943 - Sep Sun>=15 2:00 1:00 - Rule SA 1943 1944 - Mar Sun>=15 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Johannesburg 1:52:00 - LMT 1892 Feb 8 1:30 - SAST 1903 Mar 2:00 SA SAST Link Africa/Johannesburg Africa/Maseru # Lesotho -Link Africa/Johannesburg Africa/Mbabane # Swaziland +Link Africa/Johannesburg Africa/Mbabane # Eswatini # # Marion and Prince Edward Is # scientific station since 1947 @@ -1158,21 +1358,18 @@ Rule Sudan 1970 only - May 1 0:00 1:00 S Rule Sudan 1970 1985 - Oct 15 0:00 0 - Rule Sudan 1971 only - Apr 30 0:00 1:00 S Rule Sudan 1972 1985 - Apr lastSun 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Khartoum 2:10:08 - LMT 1931 2:00 Sudan CA%sT 2000 Jan 15 12:00 3:00 - EAT 2017 Nov 1 2:00 - CAT # South Sudan -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Juba 2:06:28 - LMT 1931 2:00 Sudan CA%sT 2000 Jan 15 12:00 3:00 - EAT -# Swaziland -# See Africa/Johannesburg. - # Tanzania # See Africa/Nairobi. @@ -1274,7 +1471,7 @@ Rule Tunisia 2006 2008 - Oct lastSun 2:00s 0 - # Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's # more precise 0:09:21. # Shanks & Pottenger say the 1911 switch was on Mar 9; go with Howse's Mar 11. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Tunis 0:40:44 - LMT 1881 May 12 0:09:21 - PMT 1911 Mar 11 # Paris Mean Time 1:00 Tunisia CE%sT diff --git a/src/make/data/tzdata/antarctica b/src/make/data/tzdata/antarctica index d98afed9b85..6239f837e9f 100644 --- a/src/make/data/tzdata/antarctica +++ b/src/make/data/tzdata/antarctica @@ -36,7 +36,7 @@ # for information. # Unless otherwise specified, we have no time zone information. -# FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited. +# FORMAT is '-00' and STDOFF is 0 for locations while uninhabited. # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 @@ -93,7 +93,7 @@ # Australian Antarctica Division informed us that Casey changed time # zone to UTC+11 in "the morning of 22nd October 2016". -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Antarctica/Casey 0 - -00 1969 8:00 - +08 2009 Oct 18 2:00 11:00 - +11 2010 Mar 5 2:00 @@ -165,7 +165,7 @@ Zone Antarctica/Mawson 0 - -00 1954 Feb 13 # St Paul Island - near Amsterdam, uninhabited # fishing stations operated variously 1819/1931 # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français 5:00 - +05 # @@ -176,7 +176,7 @@ Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français # Another base at Port-Martin, 50km east, began operation in 1947. # It was destroyed by fire on 1952-01-14. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Antarctica/DumontDUrville 0 - -00 1947 10:00 - +10 1952 Jan 14 0 - -00 1956 Nov @@ -204,7 +204,7 @@ Zone Antarctica/DumontDUrville 0 - -00 1947 # Syowa station, which is the first antarctic station of Japan, # was established on 1957-01-29. Since Syowa station is still the main # station of Japan, it's appropriate for the principal location. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Antarctica/Syowa 0 - -00 1957 Jan 29 3:00 - +03 # See: @@ -254,7 +254,7 @@ Rule Troll 2005 max - Mar lastSun 1:00u 2:00 +02 #Rule Troll 2004 max - Nov 7 1:00u 0:00 +00 # Remove the following line when uncommenting the above '#Rule' lines. Rule Troll 2004 max - Oct lastSun 1:00u 0:00 +00 -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Antarctica/Troll 0 - -00 2005 Feb 12 0:00 Troll %s @@ -328,7 +328,7 @@ Zone Antarctica/Vostok 0 - -00 1957 Dec 16 # From Paul Eggert (2002-10-22) # says Rothera is -03 all year. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Antarctica/Rothera 0 - -00 1976 Dec 1 -3:00 - -03 diff --git a/src/make/data/tzdata/asia b/src/make/data/tzdata/asia index 57255f2b6b8..a339bc9b165 100644 --- a/src/make/data/tzdata/asia +++ b/src/make/data/tzdata/asia @@ -107,7 +107,7 @@ Rule RussiaAsia 1985 2010 - Mar lastSun 2:00s 1:00 - Rule RussiaAsia 1996 2010 - Oct lastSun 2:00s 0 - # Afghanistan -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kabul 4:36:48 - LMT 1890 4:00 - +04 1945 4:30 - +0430 @@ -140,7 +140,7 @@ Zone Asia/Kabul 4:36:48 - LMT 1890 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Armenia 2011 only - Mar lastSun 2:00s 1:00 - Rule Armenia 2011 only - Oct lastSun 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 3:00 - +03 1957 Mar 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s @@ -166,7 +166,7 @@ Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Azer 1997 2015 - Mar lastSun 4:00 1:00 - Rule Azer 1997 2015 - Oct lastSun 5:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Baku 3:19:24 - LMT 1924 May 2 3:00 - +03 1957 Mar 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s @@ -254,7 +254,7 @@ Zone Asia/Baku 3:19:24 - LMT 1924 May 2 Rule Dhaka 2009 only - Jun 19 23:00 1:00 - Rule Dhaka 2009 only - Dec 31 24:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Dhaka 6:01:40 - LMT 1890 5:53:20 - HMT 1941 Oct # Howrah Mean Time? 6:30 - +0630 1942 May 15 @@ -264,7 +264,7 @@ Zone Asia/Dhaka 6:01:40 - LMT 1890 6:00 Dhaka +06/+07 # Bhutan -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Thimphu 5:58:36 - LMT 1947 Aug 15 # or Thimbu 5:30 - +0530 1987 Oct 6:00 - +06 @@ -275,13 +275,13 @@ Zone Asia/Thimphu 5:58:36 - LMT 1947 Aug 15 # or Thimbu # We have no information as to when standard time was introduced; # assume it occurred in 1907, the same year as Mauritius (which # then contained the Chagos Archipelago). -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Chagos 4:49:40 - LMT 1907 5:00 - +05 1996 6:00 - +06 # Brunei -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Bandar Seri Begawan 7:30 - +0730 1933 8:00 - +08 @@ -296,7 +296,7 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Bandar Seri Begawan # of Greenwich." This refers to the period before Burma's transition to +0630, # a transition for which Shanks is the only source. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Yangon 6:24:47 - LMT 1880 # or Rangoon 6:24:47 - RMT 1920 # Rangoon local time 6:30 - +0630 1942 May @@ -584,7 +584,7 @@ Rule PRC 1987 1991 - Apr Sun>=11 2:00 1:00 D # that the sort of users who prefer Asia/Urumqi now typically ignored the # +08 mandate back then. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # Beijing time, used throughout China; represented by Shanghai. Zone Asia/Shanghai 8:05:43 - LMT 1901 8:00 Shang C%sT 1949 May 28 @@ -609,23 +609,123 @@ Zone Asia/Urumqi 5:50:20 - LMT 1928 # obtained from # http://www.hko.gov.hk/gts/time/Summertime.htm -# From Arthur David Olson (2009-10-28): +# From Phake Nick (2018-10-27): +# According to Singaporean newspaper +# http://eresources.nlb.gov.sg/newspapers/Digitised/Article/singfreepresswk19041102-1.2.37 +# the day that Hong Kong start using GMT+8 should be Oct 30, 1904. +# +# From Paul Eggert (2018-11-17): +# Hong Kong had a time ball near the Marine Police Station, Tsim Sha Tsui. +# "The ball was raised manually each day and dropped at exactly 1pm +# (except on Sundays and Government holidays)." +# Dyson AD. From Time Ball to Atomic Clock. Hong Kong Government. 1983. +# +# "From 1904 October 30 the time-ball at Hong Kong has been dropped by order +# of the Governor of the Colony at 17h 0m 0s G.M.T., which is 23m 18s.14 in +# advance of 1h 0m 0s of Hong Kong mean time." +# Hollis HP. Universal Time, Longitudes, and Geodesy. Mon Not R Astron Soc. +# 1905-02-10;65(4):405-6. https://doi.org/10.1093/mnras/65.4.382 +# +# From Joseph Myers (2018-11-18): +# An astronomer before 1925 referring to GMT would have been using the old +# astronomical convention where the day started at noon, not midnight. +# +# From Steve Allen (2018-11-17): +# Meteorological Observations made at the Hongkong Observatory in the year 1904 +# page 4 +# ... the log of drop times in Table II shows that on Sunday 1904-10-30 the +# ball was dropped. So that looks like a special case drop for the sake +# of broadcasting the new local time. +# +# From Phake Nick (2018-11-18): +# According to The Hong Kong Weekly Press, 1904-10-29, p.324, the +# governor of Hong Kong at the time stated that "We are further desired to +# make it known that the change will be effected by firing the gun and by the +# dropping of the Ball at 23min. 18sec. before one." +# From Paul Eggert (2018-11-18): +# See for this; unfortunately Flash is required. + +# From Phake Nick (2018-10-26): +# I went to check microfilm records stored at Hong Kong Public Library.... +# on September 30 1941, according to Ta Kung Pao (Hong Kong edition), it was +# stated that fallback would occur on the next day (the 1st)'s "03:00 am (Hong +# Kong Time 04:00 am)" and the clock will fall back for a half hour. (03:00 +# probably refer to the time commonly used in mainland China at the time given +# the paper's background) ... the sunrise/sunset time given by South China +# Morning Post for October 1st was indeed moved by half an hour compares to +# before. After that, in December, the battle to capture Hong Kong started and +# the library doesn't seems to have any record stored about press during that +# period of time. Some media resumed publication soon after that within the +# same month, but there were not much information about time there. Later they +# started including a radio program guide when they restored radio service, +# explicitly mentioning it use Tokyo standard time, and later added a note +# saying it's half an hour ahead of the old Hong Kong standard time, and it +# also seems to indicate that Hong Kong was not using GMT+8 when it was +# captured by Japan. +# +# Image of related sections on newspaper: +# * 1941-09-30, Ta Kung Pao (Hong Kong), "Winter Time start tomorrow". +# https://i.imgur.com/6waY51Z.jpg (Chinese) +# * 1941-09-29, South China Morning Post, Information on sunrise/sunset +# time and other things for September 30 and October 1. +# https://i.imgur.com/kCiUR78.jpg +# * 1942-02-05. The Hong Kong News, Radio Program Guide. +# https://i.imgur.com/eVvDMzS.jpg +# * 1941-06-14. Hong Kong Daily Press, Daylight Saving from 3am Tomorrow. +# https://i.imgur.com/05KkvtC.png +# * 1941-09-30, Hong Kong Daily Press, Winter Time Warning. +# https://i.imgur.com/dge4kFJ.png + +# From P Chan (2018-12-31): +# * According to the Hong Kong Daylight-Saving Regulations, 1941, the +# 1941 spring-forward transition was at 03:00. +# http://sunzi.lib.hku.hk/hkgro/view/g1941/304271.pdf +# http://sunzi.lib.hku.hk/hkgro/view/g1941/305516.pdf +# * According to some articles from South China Morning Post, +08 was +# resumed on 1945-11-18 at 02:00. +# https://i.imgur.com/M2IsZ3c.png +# https://i.imgur.com/iOPqrVo.png +# https://i.imgur.com/fffcGDs.png +# * Some newspapers ... said the 1946 spring-forward transition was on +# 04-21 at 00:00. The Kung Sheung Evening News 1946-04-20 (Chinese) +# https://i.imgur.com/ZSzent0.png +# https://mmis.hkpl.gov.hk///c/portal/cover?c=QF757YsWv5%2FH7zGe%2FKF%2BFLYsuqGhRBfe p.4 +# The Kung Sheung Daily News 1946-04-21 (Chinese) +# https://i.imgur.com/7ecmRlcm.png +# https://mmis.hkpl.gov.hk///c/portal/cover?c=QF757YsWv5%2BQBGt1%2BwUj5qG2GqtwR3Wh p.4 +# * According to the Summer Time Ordinance (1946), the fallback +# transitions between 1946 and 1952 were at 03:30 Standard Time (+08) +# http://oelawhk.lib.hku.hk/archive/files/bb74b06a74d5294620a15de560ab33c6.pdf +# * Some other laws and regulations related to DST from 1953 to 1979 +# Summer Time Ordinance 1953 +# https://i.imgur.com/IOlJMav.jpg +# Summer Time (Amendment) Ordinance 1965 +# https://i.imgur.com/8rofeLa.jpg +# Interpretation and General Clauses Ordinance (1966) +# https://i.imgur.com/joy3msj.jpg +# Emergency (Summer Time) Regulation 1973 +# Interpretation and General Clauses (Amendment) Ordinance 1977 +# https://i.imgur.com/RaNqnc4.jpg +# Resolution of the Legislative Council passed on 9 May 1979 +# https://www.legco.gov.hk/yr78-79/english/lc_sitg/hansard/h790509.pdf#page=39 + +# From Paul Eggert (2019-05-31): # Here are the dates given at -# http://www.hko.gov.hk/gts/time/Summertime.htm -# as of 2009-10-28: +# https://www.hko.gov.hk/gts/time/Summertime.htm +# as of 2014-06-19: # Year Period -# 1941 1 Apr to 30 Sep +# 1941 15 Jun to 30 Sep # 1942 Whole year # 1943 Whole year # 1944 Whole year # 1945 Whole year # 1946 20 Apr to 1 Dec -# 1947 13 Apr to 30 Dec +# 1947 13 Apr to 30 Nov # 1948 2 May to 31 Oct # 1949 3 Apr to 30 Oct # 1950 2 Apr to 29 Oct # 1951 1 Apr to 28 Oct -# 1952 6 Apr to 25 Oct +# 1952 6 Apr to 2 Nov # 1953 5 Apr to 1 Nov # 1954 21 Mar to 31 Oct # 1955 20 Mar to 6 Nov @@ -654,37 +754,31 @@ Zone Asia/Urumqi 5:50:20 - LMT 1928 # 1978 Nil # 1979 13 May to 21 Oct # 1980 to Now Nil -# The page does not give start or end times of day. -# The page does not give a start date for 1942. -# The page does not givw an end date for 1945. -# The Japanese occupation of Hong Kong began on 1941-12-25. -# The Japanese surrender of Hong Kong was signed 1945-09-15. -# For lack of anything better, use start of those days as the transition times. +# The page does not give times of day for transitions, +# or dates for the 1942 and 1945 transitions. +# The Japanese occupation of Hong Kong began 1941-12-25. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule HK 1941 only - Apr 1 3:30 1:00 S -Rule HK 1941 only - Sep 30 3:30 0 - -Rule HK 1946 only - Apr 20 3:30 1:00 S -Rule HK 1946 only - Dec 1 3:30 0 - -Rule HK 1947 only - Apr 13 3:30 1:00 S -Rule HK 1947 only - Dec 30 3:30 0 - -Rule HK 1948 only - May 2 3:30 1:00 S -Rule HK 1948 1951 - Oct lastSun 3:30 0 - -Rule HK 1952 only - Oct 25 3:30 0 - +Rule HK 1946 only - Apr 21 0:00 1:00 S +Rule HK 1946 only - Dec 1 3:30s 0 - +Rule HK 1947 only - Apr 13 3:30s 1:00 S +Rule HK 1947 only - Nov 30 3:30s 0 - +Rule HK 1948 only - May 2 3:30s 1:00 S +Rule HK 1948 1952 - Oct Sun>=28 3:30s 0 - Rule HK 1949 1953 - Apr Sun>=1 3:30 1:00 S -Rule HK 1953 only - Nov 1 3:30 0 - +Rule HK 1953 1964 - Oct Sun>=31 3:30 0 - Rule HK 1954 1964 - Mar Sun>=18 3:30 1:00 S -Rule HK 1954 only - Oct 31 3:30 0 - -Rule HK 1955 1964 - Nov Sun>=1 3:30 0 - Rule HK 1965 1976 - Apr Sun>=16 3:30 1:00 S Rule HK 1965 1976 - Oct Sun>=16 3:30 0 - Rule HK 1973 only - Dec 30 3:30 1:00 S -Rule HK 1979 only - May Sun>=8 3:30 1:00 S -Rule HK 1979 only - Oct Sun>=16 3:30 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30 - 8:00 HK HK%sT 1941 Dec 25 - 9:00 - JST 1945 Sep 15 +Rule HK 1979 only - May 13 3:30 1:00 S +Rule HK 1979 only - Oct 21 3:30 0 - +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30 0:36:42 + 8:00 - HKT 1941 Jun 15 3:00 + 8:00 1:00 HKST 1941 Oct 1 4:00 + 8:30 - HKT 1941 Dec 25 + 9:00 - JST 1945 Nov 18 2:00 8:00 HK HK%sT ############################################################################### @@ -808,7 +902,7 @@ Rule Taiwan 1974 1975 - Oct 1 0:00 0 S Rule Taiwan 1979 only - Jul 1 0:00 1:00 D Rule Taiwan 1979 only - Oct 1 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # Taipei or Taibei or T'ai-pei Zone Asia/Taipei 8:06:00 - LMT 1896 Jan 1 8:00 - CST 1937 Oct 1 @@ -946,7 +1040,7 @@ Rule Macau 1975 1976 - Apr Sun>=16 03:30 1:00 D Rule Macau 1979 only - May 13 03:30 1:00 D Rule Macau 1979 only - Oct Sun>=16 03:30 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Macau 7:34:10 - LMT 1904 Oct 30 8:00 - CST 1941 Dec 21 23:00 9:00 Macau +09/+10 1945 Sep 30 24:00 @@ -985,7 +1079,7 @@ Rule Cyprus 1977 only - Sep 25 0:00 0 - Rule Cyprus 1978 only - Oct 2 0:00 0 - Rule Cyprus 1979 1997 - Sep lastSun 0:00 0 - Rule Cyprus 1981 1998 - Mar lastSun 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Nicosia 2:13:28 - LMT 1921 Nov 14 2:00 Cyprus EE%sT 1998 Sep 2:00 EUAsia EE%sT @@ -1034,7 +1128,7 @@ Link Asia/Nicosia Europe/Nicosia # Byalokoz 1919 says Georgia was 2:59:11. # Go with Byalokoz. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Tbilisi 2:59:11 - LMT 1880 2:59:11 - TBMT 1924 May 2 # Tbilisi Mean Time 3:00 - +03 1957 Mar @@ -1071,7 +1165,7 @@ Zone Asia/Tbilisi 2:59:11 - LMT 1880 # which will be permanent, with no seasonal adjustment, will happen at # midnight on Saturday, September 16. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 8:00 - +08 1942 Feb 21 23:00 9:00 - +09 1976 May 3 @@ -1080,6 +1174,16 @@ Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 # India +# British astronomer Henry Park Hollis disliked India Standard Time's offset: +# "A new time system has been proposed for India, Further India, and Burmah. +# The scheme suggested is that the times of the meridians 5½ and 6½ hours +# east of Greenwich should be adopted in these territories. No reason is +# given why hourly meridians five hours and six hours east should not be +# chosen; a plan which would bring the time of India into harmony with +# that of almost the whole of the civilised world." +# Hollis HP. Universal Time, Longitudes, and Geodesy. Mon Not R Astron Soc. +# 1905-02-10;65(4):405-6. https://doi.org/10.1093/mnras/65.4.382 + # From Ian P. Beacock, in "A brief history of (modern) time", The Atlantic # https://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ # (2015-12-22): @@ -1127,7 +1231,7 @@ Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 # time for 1870-1941. Shanks is our only (and dubious) source for the # 1941-1945 data. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kolkata 5:53:28 - LMT 1854 Jun 28 # Kolkata 5:53:20 - HMT 1870 # Howrah Mean Time? 5:21:10 - MMT 1906 Jan 1 # Madras local time @@ -1179,7 +1283,7 @@ Zone Asia/Kolkata 5:53:28 - LMT 1854 Jun 28 # Kolkata # WITA - +08 - Waktu Indonesia Tengah (Indonesia central time) # WIT - +09 - Waktu Indonesia Timur (Indonesia eastern time) # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # Java, Sumatra Zone Asia/Jakarta 7:07:12 - LMT 1867 Aug 10 # Shanks & Pottenger say the next transition was at 1924 Jan 1 0:13, @@ -1250,12 +1354,65 @@ Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov # leap year calculation involved. There has never been any serious # plan to change that law.... # -# From Paul Eggert (2006-03-22): +# From Paul Eggert (2018-11-30): # Go with Shanks & Pottenger before Sept. 1991, and with Pournader thereafter. -# I used Ed Reingold's cal-persia in GNU Emacs 21.2 to check Persian dates, -# stopping after 2037 when 32-bit time_t's overflow. -# That cal-persia used Birashk's approximation, which disagrees with the solar -# calendar predictions for the year 2025, so I corrected those dates by hand. +# I used the following code in GNU Emacs 26.1 to generate the "Rule Iran" +# lines from 2008 through 2087. Emacs 26.1 uses Ed Reingold's +# cal-persia implementation of Birashk's approximation, which in the +# 2008-2087 range disagrees with the astronomical Persian calendar +# for Persian years 1404 (Gregorian 2025) and 1437 (Gregorian 2058), so +# the following code special-cases those years. See Table 15.1, page 264, of: +# Edward M. Reingold and Nachum Dershowitz, Calendrical Calculations: +# The Ultimate Edition, Cambridge University Press (2018). +# https://www.cambridge.org/fr/academic/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition +# Page 258, footnote 2, of this book says there is some dispute over what will +# happen in 2091 (and some other years after that), so this code +# stops in 2087, as 2088 and 2089 agree with the "max" rule below. +# (cl-loop +# initially (require 'cal-persia) +# with first-persian-year = 1387 +# with last-persian-year = 1466 +# ;; Exceptional years in the above range, +# ;; from Reingold & Dershowitz Table 15.1, page 264: +# with exceptional-persian-years = '(1404 1437) +# with range-start = nil +# for persian-year from first-persian-year to last-persian-year +# do +# (let* +# ((exceptional-year-offset +# (if (member persian-year exceptional-persian-years) 1 0)) +# (beg-dst-absolute +# (+ (calendar-persian-to-absolute (list 1 1 persian-year)) +# exceptional-year-offset)) +# (end-dst-absolute +# (+ (calendar-persian-to-absolute (list 6 30 persian-year)) +# exceptional-year-offset)) +# (next-year-beg-dst-absolute +# (+ (calendar-persian-to-absolute (list 1 1 (1+ persian-year))) +# (if (member (1+ persian-year) exceptional-persian-years) 1 0))) +# (beg-dst (calendar-gregorian-from-absolute beg-dst-absolute)) +# (end-dst (calendar-gregorian-from-absolute end-dst-absolute)) +# (next-year-beg-dst (calendar-gregorian-from-absolute +# next-year-beg-dst-absolute)) +# (year (calendar-extract-year beg-dst)) +# (range-end (if range-start year "only"))) +# (setq range-start (or range-start year)) +# (when (or (/= (calendar-extract-day beg-dst) +# (calendar-extract-day next-year-beg-dst)) +# (= persian-year last-persian-year)) +# (insert +# (format +# "Rule\tIran\t%d\t%s\t-\t%s\t%2d\t24:00\t1:00\t-\n" +# range-start range-end +# (calendar-month-name (calendar-extract-month beg-dst) t) +# (calendar-extract-day beg-dst))) +# (insert +# (format +# "Rule\tIran\t%d\t%s\t-\t%s\t%2d\t24:00\t0\t-\n" +# range-start range-end +# (calendar-month-name (calendar-extract-month end-dst) t) +# (calendar-extract-day end-dst))) +# (setq range-start nil)))) # # From Oscar van Vlijmen (2005-03-30), writing about future # discrepancies between cal-persia and the Iranian calendar: @@ -1290,63 +1447,115 @@ Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov # thirtieth day of Shahrivar. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iran 1978 1980 - Mar 21 0:00 1:00 - -Rule Iran 1978 only - Oct 21 0:00 0 - -Rule Iran 1979 only - Sep 19 0:00 0 - -Rule Iran 1980 only - Sep 23 0:00 0 - -Rule Iran 1991 only - May 3 0:00 1:00 - -Rule Iran 1992 1995 - Mar 22 0:00 1:00 - -Rule Iran 1991 1995 - Sep 22 0:00 0 - -Rule Iran 1996 only - Mar 21 0:00 1:00 - -Rule Iran 1996 only - Sep 21 0:00 0 - -Rule Iran 1997 1999 - Mar 22 0:00 1:00 - -Rule Iran 1997 1999 - Sep 22 0:00 0 - -Rule Iran 2000 only - Mar 21 0:00 1:00 - -Rule Iran 2000 only - Sep 21 0:00 0 - -Rule Iran 2001 2003 - Mar 22 0:00 1:00 - -Rule Iran 2001 2003 - Sep 22 0:00 0 - -Rule Iran 2004 only - Mar 21 0:00 1:00 - -Rule Iran 2004 only - Sep 21 0:00 0 - -Rule Iran 2005 only - Mar 22 0:00 1:00 - -Rule Iran 2005 only - Sep 22 0:00 0 - -Rule Iran 2008 only - Mar 21 0:00 1:00 - -Rule Iran 2008 only - Sep 21 0:00 0 - -Rule Iran 2009 2011 - Mar 22 0:00 1:00 - -Rule Iran 2009 2011 - Sep 22 0:00 0 - -Rule Iran 2012 only - Mar 21 0:00 1:00 - -Rule Iran 2012 only - Sep 21 0:00 0 - -Rule Iran 2013 2015 - Mar 22 0:00 1:00 - -Rule Iran 2013 2015 - Sep 22 0:00 0 - -Rule Iran 2016 only - Mar 21 0:00 1:00 - -Rule Iran 2016 only - Sep 21 0:00 0 - -Rule Iran 2017 2019 - Mar 22 0:00 1:00 - -Rule Iran 2017 2019 - Sep 22 0:00 0 - -Rule Iran 2020 only - Mar 21 0:00 1:00 - -Rule Iran 2020 only - Sep 21 0:00 0 - -Rule Iran 2021 2023 - Mar 22 0:00 1:00 - -Rule Iran 2021 2023 - Sep 22 0:00 0 - -Rule Iran 2024 only - Mar 21 0:00 1:00 - -Rule Iran 2024 only - Sep 21 0:00 0 - -Rule Iran 2025 2027 - Mar 22 0:00 1:00 - -Rule Iran 2025 2027 - Sep 22 0:00 0 - -Rule Iran 2028 2029 - Mar 21 0:00 1:00 - -Rule Iran 2028 2029 - Sep 21 0:00 0 - -Rule Iran 2030 2031 - Mar 22 0:00 1:00 - -Rule Iran 2030 2031 - Sep 22 0:00 0 - -Rule Iran 2032 2033 - Mar 21 0:00 1:00 - -Rule Iran 2032 2033 - Sep 21 0:00 0 - -Rule Iran 2034 2035 - Mar 22 0:00 1:00 - -Rule Iran 2034 2035 - Sep 22 0:00 0 - -# -# The following rules are approximations starting in the year 2038. -# These are the best post-2037 approximations available, given the -# restrictions of a single rule using a Gregorian-based data format. +Rule Iran 1978 1980 - Mar 20 24:00 1:00 - +Rule Iran 1978 only - Oct 20 24:00 0 - +Rule Iran 1979 only - Sep 18 24:00 0 - +Rule Iran 1980 only - Sep 22 24:00 0 - +Rule Iran 1991 only - May 2 24:00 1:00 - +Rule Iran 1992 1995 - Mar 21 24:00 1:00 - +Rule Iran 1991 1995 - Sep 21 24:00 0 - +Rule Iran 1996 only - Mar 20 24:00 1:00 - +Rule Iran 1996 only - Sep 20 24:00 0 - +Rule Iran 1997 1999 - Mar 21 24:00 1:00 - +Rule Iran 1997 1999 - Sep 21 24:00 0 - +Rule Iran 2000 only - Mar 20 24:00 1:00 - +Rule Iran 2000 only - Sep 20 24:00 0 - +Rule Iran 2001 2003 - Mar 21 24:00 1:00 - +Rule Iran 2001 2003 - Sep 21 24:00 0 - +Rule Iran 2004 only - Mar 20 24:00 1:00 - +Rule Iran 2004 only - Sep 20 24:00 0 - +Rule Iran 2005 only - Mar 21 24:00 1:00 - +Rule Iran 2005 only - Sep 21 24:00 0 - +Rule Iran 2008 only - Mar 20 24:00 1:00 - +Rule Iran 2008 only - Sep 20 24:00 0 - +Rule Iran 2009 2011 - Mar 21 24:00 1:00 - +Rule Iran 2009 2011 - Sep 21 24:00 0 - +Rule Iran 2012 only - Mar 20 24:00 1:00 - +Rule Iran 2012 only - Sep 20 24:00 0 - +Rule Iran 2013 2015 - Mar 21 24:00 1:00 - +Rule Iran 2013 2015 - Sep 21 24:00 0 - +Rule Iran 2016 only - Mar 20 24:00 1:00 - +Rule Iran 2016 only - Sep 20 24:00 0 - +Rule Iran 2017 2019 - Mar 21 24:00 1:00 - +Rule Iran 2017 2019 - Sep 21 24:00 0 - +Rule Iran 2020 only - Mar 20 24:00 1:00 - +Rule Iran 2020 only - Sep 20 24:00 0 - +Rule Iran 2021 2023 - Mar 21 24:00 1:00 - +Rule Iran 2021 2023 - Sep 21 24:00 0 - +Rule Iran 2024 only - Mar 20 24:00 1:00 - +Rule Iran 2024 only - Sep 20 24:00 0 - +Rule Iran 2025 2027 - Mar 21 24:00 1:00 - +Rule Iran 2025 2027 - Sep 21 24:00 0 - +Rule Iran 2028 2029 - Mar 20 24:00 1:00 - +Rule Iran 2028 2029 - Sep 20 24:00 0 - +Rule Iran 2030 2031 - Mar 21 24:00 1:00 - +Rule Iran 2030 2031 - Sep 21 24:00 0 - +Rule Iran 2032 2033 - Mar 20 24:00 1:00 - +Rule Iran 2032 2033 - Sep 20 24:00 0 - +Rule Iran 2034 2035 - Mar 21 24:00 1:00 - +Rule Iran 2034 2035 - Sep 21 24:00 0 - +Rule Iran 2036 2037 - Mar 20 24:00 1:00 - +Rule Iran 2036 2037 - Sep 20 24:00 0 - +Rule Iran 2038 2039 - Mar 21 24:00 1:00 - +Rule Iran 2038 2039 - Sep 21 24:00 0 - +Rule Iran 2040 2041 - Mar 20 24:00 1:00 - +Rule Iran 2040 2041 - Sep 20 24:00 0 - +Rule Iran 2042 2043 - Mar 21 24:00 1:00 - +Rule Iran 2042 2043 - Sep 21 24:00 0 - +Rule Iran 2044 2045 - Mar 20 24:00 1:00 - +Rule Iran 2044 2045 - Sep 20 24:00 0 - +Rule Iran 2046 2047 - Mar 21 24:00 1:00 - +Rule Iran 2046 2047 - Sep 21 24:00 0 - +Rule Iran 2048 2049 - Mar 20 24:00 1:00 - +Rule Iran 2048 2049 - Sep 20 24:00 0 - +Rule Iran 2050 2051 - Mar 21 24:00 1:00 - +Rule Iran 2050 2051 - Sep 21 24:00 0 - +Rule Iran 2052 2053 - Mar 20 24:00 1:00 - +Rule Iran 2052 2053 - Sep 20 24:00 0 - +Rule Iran 2054 2055 - Mar 21 24:00 1:00 - +Rule Iran 2054 2055 - Sep 21 24:00 0 - +Rule Iran 2056 2057 - Mar 20 24:00 1:00 - +Rule Iran 2056 2057 - Sep 20 24:00 0 - +Rule Iran 2058 2059 - Mar 21 24:00 1:00 - +Rule Iran 2058 2059 - Sep 21 24:00 0 - +Rule Iran 2060 2062 - Mar 20 24:00 1:00 - +Rule Iran 2060 2062 - Sep 20 24:00 0 - +Rule Iran 2063 only - Mar 21 24:00 1:00 - +Rule Iran 2063 only - Sep 21 24:00 0 - +Rule Iran 2064 2066 - Mar 20 24:00 1:00 - +Rule Iran 2064 2066 - Sep 20 24:00 0 - +Rule Iran 2067 only - Mar 21 24:00 1:00 - +Rule Iran 2067 only - Sep 21 24:00 0 - +Rule Iran 2068 2070 - Mar 20 24:00 1:00 - +Rule Iran 2068 2070 - Sep 20 24:00 0 - +Rule Iran 2071 only - Mar 21 24:00 1:00 - +Rule Iran 2071 only - Sep 21 24:00 0 - +Rule Iran 2072 2074 - Mar 20 24:00 1:00 - +Rule Iran 2072 2074 - Sep 20 24:00 0 - +Rule Iran 2075 only - Mar 21 24:00 1:00 - +Rule Iran 2075 only - Sep 21 24:00 0 - +Rule Iran 2076 2078 - Mar 20 24:00 1:00 - +Rule Iran 2076 2078 - Sep 20 24:00 0 - +Rule Iran 2079 only - Mar 21 24:00 1:00 - +Rule Iran 2079 only - Sep 21 24:00 0 - +Rule Iran 2080 2082 - Mar 20 24:00 1:00 - +Rule Iran 2080 2082 - Sep 20 24:00 0 - +Rule Iran 2083 only - Mar 21 24:00 1:00 - +Rule Iran 2083 only - Sep 21 24:00 0 - +Rule Iran 2084 2086 - Mar 20 24:00 1:00 - +Rule Iran 2084 2086 - Sep 20 24:00 0 - +Rule Iran 2087 only - Mar 21 24:00 1:00 - +Rule Iran 2087 only - Sep 21 24:00 0 - +# +# The following rules are approximations starting in the year 2088. +# These are the best post-2088 approximations available, given the +# restrictions of a single rule using ordinary Gregorian dates. # At some point this table will need to be extended, though quite # possibly Iran will change the rules first. -Rule Iran 2036 max - Mar 21 0:00 1:00 - -Rule Iran 2036 max - Sep 21 0:00 0 - +Rule Iran 2088 max - Mar 20 24:00 1:00 - +Rule Iran 2088 max - Sep 20 24:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Tehran 3:25:44 - LMT 1916 3:25:44 - TMT 1946 # Tehran Mean Time 3:30 - +0330 1977 Nov @@ -1391,7 +1600,7 @@ Rule Iraq 1986 1990 - Mar lastSun 1:00s 1:00 - # Rule Iraq 1991 2007 - Apr 1 3:00s 1:00 - Rule Iraq 1991 2007 - Oct 1 3:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Baghdad 2:57:40 - LMT 1890 2:57:36 - BMT 1918 # Baghdad Mean Time? 3:00 - +03 1982 May @@ -1456,6 +1665,24 @@ Rule Zion 1974 only - Jul 7 0:00 1:00 D Rule Zion 1974 only - Oct 13 0:00 0 S Rule Zion 1975 only - Apr 20 0:00 1:00 D Rule Zion 1975 only - Aug 31 0:00 0 S + +# From Alois Treindl (2019-03-06): +# http://www.moin.gov.il/Documents/שעון%20קיץ/clock-50-years-7-2014.pdf +# From Isaac Starkman (2019-03-06): +# Summer time was in that period in 1980 and 1984, see +# https://www.ynet.co.il/articles/0,7340,L-3951073,00.html +# You can of course read it in translation. +# I checked the local newspapers for that years. +# It started on midnight and end at 01.00 am. +# From Paul Eggert (2019-03-06): +# Also see this thread about the moin.gov.il URL: +# https://mm.icann.org/pipermail/tz/2018-November/027194.html +Rule Zion 1980 only - Aug 2 0:00 1:00 D +Rule Zion 1980 only - Sep 13 1:00 0 S +Rule Zion 1984 only - May 5 0:00 1:00 D +Rule Zion 1984 only - Aug 25 1:00 0 S + +# From Shanks & Pottenger: Rule Zion 1985 only - Apr 14 0:00 1:00 D Rule Zion 1985 only - Sep 15 0:00 0 S Rule Zion 1986 only - May 18 0:00 1:00 D @@ -1578,32 +1805,15 @@ Rule Zion 2004 only - Sep 22 1:00 0 S # # ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2005+beyond.ps -# From Paul Eggert (2012-10-26): -# I used Ephraim Silverberg's dst-israel.el program -# (2005-02-20) -# along with Ed Reingold's cal-hebrew in GNU Emacs 21.4, -# to generate the transitions from 2005 through 2012. -# (I replaced "lastFri" with "Fri>=26" by hand.) -# The spring transitions all correspond to the following Rule: -# -# Rule Zion 2005 2012 - Mar Fri>=26 2:00 1:00 D -# -# but older zic implementations (e.g., Solaris 8) do not support -# "Fri>=26" to mean April 1 in years like 2005, so for now we list the -# springtime transitions explicitly. - # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 2005 only - Apr 1 2:00 1:00 D +Rule Zion 2005 2012 - Apr Fri<=1 2:00 1:00 D Rule Zion 2005 only - Oct 9 2:00 0 S -Rule Zion 2006 2010 - Mar Fri>=26 2:00 1:00 D Rule Zion 2006 only - Oct 1 2:00 0 S Rule Zion 2007 only - Sep 16 2:00 0 S Rule Zion 2008 only - Oct 5 2:00 0 S Rule Zion 2009 only - Sep 27 2:00 0 S Rule Zion 2010 only - Sep 12 2:00 0 S -Rule Zion 2011 only - Apr 1 2:00 1:00 D Rule Zion 2011 only - Oct 2 2:00 0 S -Rule Zion 2012 only - Mar Fri>=26 2:00 1:00 D Rule Zion 2012 only - Sep 23 2:00 0 S # From Ephraim Silverberg (2013-06-27): @@ -1619,7 +1829,7 @@ Rule Zion 2012 only - Sep 23 2:00 0 S Rule Zion 2013 max - Mar Fri>=23 2:00 1:00 D Rule Zion 2013 max - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Jerusalem 2:20:54 - LMT 1880 2:20:40 - JMT 1918 # Jerusalem Mean Time? 2:00 Zion I%sT @@ -1676,7 +1886,7 @@ Zone Asia/Jerusalem 2:20:54 - LMT 1880 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Japan 1948 only - May Sat>=1 24:00 1:00 D -Rule Japan 1948 1951 - Sep Sun>=9 1:00 0 S +Rule Japan 1948 1951 - Sep Sat>=8 25:00 0 S Rule Japan 1949 only - Apr Sat>=1 24:00 1:00 D Rule Japan 1950 1951 - May Sat>=1 24:00 1:00 D @@ -1711,10 +1921,12 @@ Rule Japan 1950 1951 - May Sat>=1 24:00 1:00 D # Central Time (UT+9). The adoption began on Oct 1, 1937. # https://ja.wikisource.org/wiki/明治二十八年勅令第百六十七號標準時ニ關スル件中改正ノ件 -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u 9:00 Japan J%sT -# Since 1938, all Japanese possessions have been like Asia/Tokyo. +# Since 1938, all Japanese possessions have been like Asia/Tokyo, +# except that Truk (Chuuk), Ponape (Pohnpei), and Jaluit (Kosrae) did not +# switch from +10 to +09 until 1941-04-01; see the 'australasia' file. # Jordan # @@ -1812,7 +2024,7 @@ Rule Jordan 2006 2011 - Oct lastFri 0:00s 0 - Rule Jordan 2013 only - Dec 20 0:00 0 - Rule Jordan 2014 max - Mar lastThu 24:00 1:00 S Rule Jordan 2014 max - Oct lastFri 0:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Amman 2:23:44 - LMT 1931 2:00 Jordan EE%sT @@ -1853,8 +2065,8 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # text. # # According to Izvestia newspaper No. 68 (23334) from 1991-03-20 -# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via -# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during +# -- page 6; available at http://libinfo.org/newsr/newsr2574.djvu via +# http://libinfo.org/index.php?id=58564 -- on 1991-03-31 at 2:00 during # transition to "summer" time: # Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova, # Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug @@ -1870,7 +2082,7 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # Apparently there were last minute changes. Apparently Kazakh act No. 170 # was one of such changes. # -# https://ru.wikipedia.org/wiki/Декретное время +# https://ru.wikipedia.org/wiki/Декретное_время # claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that # Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast) # were to not move clocks and Uralsk oblast was to move clocks @@ -2004,10 +2216,12 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # and in Byalokoz) lists Ural river (plus 10 versts on its left bank) in # the third time belt (before 1930 this means +03). -# From Paul Eggert (2016-12-06): -# The tables below reflect Golosunov's remarks, with exceptions as noted. +# From Alexander Konzurovski (2018-12-20): +# Qyzyolrda Region (Asia/Qyzylorda) is changing its time zone from +# UTC+6 to UTC+5 effective December 21st, 2018. The legal document is +# located here: http://adilet.zan.kz/rus/docs/P1800000817 (russian language). -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan # This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA, @@ -2019,8 +2233,6 @@ Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 # or Alma-Ata 6:00 RussiaAsia +06/+07 2004 Oct 31 2:00s 6:00 - +06 # Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY) -# This currently includes Qostanay (aka Kostanay, Kustanay) (KZ-KUS); -# see comments below. Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 4:00 - +04 1930 Jun 21 5:00 - +05 1981 Apr 1 @@ -2031,21 +2243,22 @@ Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s 6:00 RussiaAsia +06/+07 1992 Mar 29 2:00s 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s - 6:00 - +06 -# The following zone is like Asia/Qyzylorda except for being one -# hour earlier from 1991-09-29 to 1992-03-29. The 1991/2 rules for -# Qostanay are unclear partly because of the 1997 Turgai -# reorganization, so this zone is commented out for now. -#Zone Asia/Qostanay 4:14:20 - LMT 1924 May 2 -# 4:00 - +04 1930 Jun 21 -# 5:00 - +05 1981 Apr 1 -# 5:00 1:00 +06 1981 Oct 1 -# 6:00 - +06 1982 Apr 1 -# 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s -# 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s -# 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s -# 6:00 - +06 + 6:00 - +06 2018 Dec 21 0:00 + 5:00 - +05 # +# Qostanay (aka Kostanay, Kustanay) (KZ-KUS) +# The 1991/2 rules are unclear partly because of the 1997 Turgai +# reorganization. +Zone Asia/Qostanay 4:14:28 - LMT 1924 May 2 + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 6:00 - +06 + # Aqtöbe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT) Zone Asia/Aqtobe 3:48:40 - LMT 1924 May 2 4:00 - +04 1930 Jun 21 @@ -2110,7 +2323,7 @@ Rule Kyrgyz 1992 1996 - Apr Sun>=7 0:00s 1:00 - Rule Kyrgyz 1992 1996 - Sep lastSun 0:00 0 - Rule Kyrgyz 1997 2005 - Mar lastSun 2:30 1:00 - Rule Kyrgyz 1997 2004 - Oct lastSun 2:30 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 5:00 - +05 1930 Jun 21 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s @@ -2139,21 +2352,43 @@ Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 # started at June 1 in that year. For another example, the article in # 1988 said that DST started at 2:00 AM in that year. +# From Phake Nick (2018-10-27): +# 1. According to official announcement from Korean government, the DST end +# date in South Korea should be +# 1955-09-08 without specifying time +# http://theme.archives.go.kr/next/common/viewEbook.do?singleData=N&archiveEventId=0027977557 +# 1956-09-29 without specifying time +# http://theme.archives.go.kr/next/common/viewEbook.do?singleData=N&archiveEventId=0027978341 +# 1957-09-21 24 o'clock +# http://theme.archives.go.kr/next/common/viewEbook.do?singleData=N&archiveEventId=0027979690#3 +# 1958-09-20 24 o'clock +# http://theme.archives.go.kr/next/common/viewEbook.do?singleData=N&archiveEventId=0027981189 +# 1959-09-19 24 o'clock +# http://theme.archives.go.kr/next/common/viewEbook.do?singleData=N&archiveEventId=0027982974#2 +# 1960-09-17 24 o'clock +# http://theme.archives.go.kr/next/common/viewEbook.do?singleData=N&archiveEventId=0028044104 +# ... +# 2.... https://namu.wiki/w/대한민국%20표준시 ... [says] +# when Korea was using GMT+8:30 as standard time, the international +# aviation/marine/meteorological industry in the country refused to +# follow and continued to use GMT+9:00 for interoperability. + + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule ROK 1948 only - Jun 1 0:00 1:00 D -Rule ROK 1948 only - Sep 13 0:00 0 S -Rule ROK 1949 only - Apr 3 0:00 1:00 D -Rule ROK 1949 1951 - Sep Sun>=8 0:00 0 S -Rule ROK 1950 only - Apr 1 0:00 1:00 D -Rule ROK 1951 only - May 6 0:00 1:00 D -Rule ROK 1955 only - May 5 0:00 1:00 D -Rule ROK 1955 only - Sep 9 0:00 0 S -Rule ROK 1956 only - May 20 0:00 1:00 D -Rule ROK 1956 only - Sep 30 0:00 0 S -Rule ROK 1957 1960 - May Sun>=1 0:00 1:00 D -Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 S -Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D -Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S +Rule ROK 1948 only - Jun 1 0:00 1:00 D +Rule ROK 1948 only - Sep 12 24:00 0 S +Rule ROK 1949 only - Apr 3 0:00 1:00 D +Rule ROK 1949 1951 - Sep Sat>=7 24:00 0 S +Rule ROK 1950 only - Apr 1 0:00 1:00 D +Rule ROK 1951 only - May 6 0:00 1:00 D +Rule ROK 1955 only - May 5 0:00 1:00 D +Rule ROK 1955 only - Sep 8 24:00 0 S +Rule ROK 1956 only - May 20 0:00 1:00 D +Rule ROK 1956 only - Sep 29 24:00 0 S +Rule ROK 1957 1960 - May Sun>=1 0:00 1:00 D +Rule ROK 1957 1960 - Sep Sat>=17 24:00 0 S +Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D +Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S # From Paul Eggert (2016-08-23): # The Korean Wikipedia entry gives the following sources for UT offsets: @@ -2203,7 +2438,7 @@ Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S # The BBC reported that the transition was from 23:30 to 24:00 today. # https://www.bbc.com/news/world-asia-44010705 -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1 8:30 - KST 1912 Jan 1 9:00 - JST 1945 Sep 8 @@ -2252,7 +2487,7 @@ Rule Lebanon 1992 only - Oct 4 0:00 0 - Rule Lebanon 1993 max - Mar lastSun 0:00 1:00 S Rule Lebanon 1993 1998 - Sep lastSun 0:00 0 - Rule Lebanon 1999 max - Oct lastSun 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Beirut 2:22:00 - LMT 1880 2:00 Lebanon EE%sT @@ -2264,7 +2499,7 @@ Rule NBorneo 1935 1941 - Dec 14 0:00 0 - # peninsular Malaysia # taken from Mok Ly Yng (2003-10-30) # http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kuala_Lumpur 6:46:46 - LMT 1901 Jan 1 6:55:25 - SMT 1905 Jun 1 # Singapore M.T. 7:00 - +07 1933 Jan 1 @@ -2278,7 +2513,7 @@ Zone Asia/Kuala_Lumpur 6:46:46 - LMT 1901 Jan 1 # From Paul Eggert (2014-08-12): # The data entries here are mostly from Shanks & Pottenger, but the 1942, 1945 # and 1982 transition dates are from Mok Ly Yng. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kuching 7:21:20 - LMT 1926 Mar 7:30 - +0730 1933 8:00 NBorneo +08/+0820 1942 Feb 16 @@ -2286,7 +2521,7 @@ Zone Asia/Kuching 7:21:20 - LMT 1926 Mar 8:00 - +08 # Maldives -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Maldives 4:54:00 - LMT 1880 # Malé 4:54:00 - MMT 1960 # Malé Mean Time 5:00 - +05 @@ -2429,7 +2664,7 @@ Rule Mongol 2002 2006 - Mar lastSat 2:00 1:00 - Rule Mongol 2015 2016 - Mar lastSat 2:00 1:00 - Rule Mongol 2015 2016 - Sep lastSat 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta Zone Asia/Hovd 6:06:36 - LMT 1905 Aug 6:00 - +06 1978 @@ -2447,7 +2682,7 @@ Zone Asia/Choibalsan 7:38:00 - LMT 1905 Aug 8:00 Mongol +08/+09 # Nepal -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Kathmandu 5:41:16 - LMT 1920 5:30 - +0530 1986 5:45 - +0545 @@ -2597,7 +2832,7 @@ Rule Pakistan 2008 only - Jun 1 0:00 1:00 S Rule Pakistan 2008 2009 - Nov 1 0:00 0 - Rule Pakistan 2009 only - Apr 15 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Karachi 4:28:12 - LMT 1907 5:30 - +0530 1942 Sep 5:30 1:00 +0630 1945 Oct 15 @@ -2882,9 +3117,23 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # the official website, though the decree did not specify the exact # time of the time shift. # http://www.palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e7a42ab7-ee23-435a-b9c8-a4f7e81f3817 + +# From Even Scharning (2019-03-23): +# http://pnn.ps/news/401130 +# http://palweather.ps/ar/node/50136.html +# +# From Sharif Mustafa (2019-03-26): +# The Palestinian cabinet announced today that the switch to DST will +# be on Fri Mar 29th 2019 by advancing the clock by 60 minutes. +# The decree signing date is Mar 12th but it was not published till today. +# The decree does not specify the exact time of switch. +# http://palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e54e9ea1-50ee-4137-84df-0d6c78da259b # -# From Paul Eggert (2018-03-16): -# For 2016 on, predict spring transitions on March's fourth Saturday at 01:00. +# From Even Scharning (2019-04-10): +# Our source in Palestine said it happened Friday 29 at 00:00 local time.... +# +# From Paul Eggert (2019-04-10): +# For now, guess spring-ahead transitions are March's last Friday at 00:00. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S @@ -2915,10 +3164,11 @@ Rule Palestine 2012 only - Sep 21 1:00 0 - Rule Palestine 2013 only - Sep Fri>=21 0:00 0 - Rule Palestine 2014 2015 - Oct Fri>=21 0:00 0 - Rule Palestine 2015 only - Mar lastFri 24:00 1:00 S -Rule Palestine 2016 max - Mar Sat>=22 1:00 1:00 S +Rule Palestine 2016 2018 - Mar Sat>=24 1:00 1:00 S Rule Palestine 2016 max - Oct lastSat 1:00 0 - +Rule Palestine 2019 max - Mar lastFri 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct 2:00 Zion EET/EEST 1948 May 15 2:00 EgyptAsia EE%sT 1967 Jun 5 @@ -2943,6 +3193,11 @@ Zone Asia/Hebron 2:20:23 - LMT 1900 Oct # no information # Philippines + +# From Paul Eggert (2018-11-18): +# The Spanish initially used American (west-of-Greenwich) time. +# It is unknown what time Manila kept when the British occupied it from +# 1762-10-06 through 1764-04; for now assume it kept American time. # On 1844-08-16, Narciso Clavería, governor-general of the # Philippines, issued a proclamation announcing that 1844-12-30 was to # be immediately followed by 1845-01-01; see R.H. van Gent's @@ -2987,7 +3242,7 @@ Rule Phil 1954 only - Apr 12 0:00 1:00 D Rule Phil 1954 only - Jul 1 0:00 0 S Rule Phil 1978 only - Mar 22 0:00 1:00 D Rule Phil 1978 only - Sep 21 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Manila -15:56:00 - LMT 1844 Dec 31 8:04:00 - LMT 1899 May 11 8:00 Phil P%sT 1942 May @@ -2995,7 +3250,7 @@ Zone Asia/Manila -15:56:00 - LMT 1844 Dec 31 8:00 Phil P%sT # Qatar -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha 4:00 - +04 1972 Jun 3:00 - +03 @@ -3028,8 +3283,8 @@ Link Asia/Qatar Asia/Bahrain # going to run on Higgins Time.' And so, until last year, it did." See: # Antar E. Dinner at When? Saudi Aramco World, 1969 March/April. 2-3. # http://archive.aramcoworld.com/issue/196902/dinner.at.when.htm -# newspapers.com says a similar story about Higgins was published in the Port -# Angeles (WA) Evening News, 1965-03-10, page 5, but I lack access to the text. +# Also see: Antar EN. Arabian flying is confusing. +# Port Angeles (WA) Evening News. 1965-03-10. page 3. # # The TZ database cannot represent quasi-solar time; airline time is the best # we can do. The 1946 foreign air news digest of the U.S. Civil Aeronautics @@ -3043,7 +3298,7 @@ Link Asia/Qatar Asia/Bahrain # the country. Presumably this is documenting airline time. Ignore this, # as it's before our 1970 cutoff. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14 3:00 - +03 Link Asia/Riyadh Asia/Aden # Yemen @@ -3052,7 +3307,7 @@ Link Asia/Riyadh Asia/Kuwait # Singapore # taken from Mok Ly Yng (2003-10-30) # http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Singapore 6:55:25 - LMT 1901 Jan 1 6:55:25 - SMT 1905 Jun 1 # Singapore M.T. 7:00 - +07 1933 Jan 1 @@ -3116,7 +3371,7 @@ Zone Asia/Singapore 6:55:25 - LMT 1901 Jan 1 # even worse. For now, let's use a numeric abbreviation; we can # switch to "SLST" if it catches on. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Colombo 5:19:24 - LMT 1880 5:19:32 - MMT 1906 # Moratuwa Mean Time 5:30 - +0530 1942 Jan 5 @@ -3286,13 +3541,13 @@ Rule Syria 2010 2011 - Apr Fri>=1 0:00 1:00 S Rule Syria 2012 max - Mar lastFri 0:00 1:00 S Rule Syria 2009 max - Oct lastFri 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Damascus 2:25:12 - LMT 1920 # Dimashq 2:00 Syria EE%sT # Tajikistan # From Shanks & Pottenger. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 5:00 - +05 1930 Jun 21 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s @@ -3300,7 +3555,7 @@ Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 5:00 - +05 # Thailand -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Bangkok 6:42:04 - LMT 1880 6:42:04 - BMT 1920 Apr # Bangkok Mean Time 7:00 - +07 @@ -3309,7 +3564,7 @@ Link Asia/Bangkok Asia/Vientiane # Laos # Turkmenistan # From Shanks & Pottenger. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad 4:00 - +04 1930 Jun 21 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00 @@ -3317,14 +3572,14 @@ Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad 5:00 - +05 # United Arab Emirates -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Dubai 3:41:12 - LMT 1920 4:00 - +04 Link Asia/Dubai Asia/Muscat # Oman # Uzbekistan # Byalokoz 1919 says Uzbekistan was 4:27:53. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Samarkand 4:27:53 - LMT 1924 May 2 4:00 - +04 1930 Jun 21 5:00 - +05 1981 Apr 1 @@ -3390,7 +3645,7 @@ Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 # Lê Thành Lân: "Lịch hai thế kỷ (1802-2010) và các lịch vĩnh cửu", # NXB Thuận Hoá, Huế, 1995. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 7:06:30 - PLMT 1911 May 1 # Phù Liễn MT 7:00 - +07 1942 Dec 31 23:00 @@ -3402,5 +3657,17 @@ Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 8:00 - +08 1975 Jun 13 7:00 - +07 +# From Paul Eggert (2019-02-19): +# +# The Ho Chi Minh entry suffices for most purposes as it agrees with all of +# Vietnam since 1975-06-13. Presumably clocks often changed in south Vietnam +# in the early 1970s as locations changed hands during the war; however the +# details are unknown and would likely be too voluminous for this database. +# +# For timestamps in north Vietnam back to 1970 (the tzdb cutoff), +# use Asia/Bangkok; see the VN entries in the file zone1970.tab. +# For timestamps before 1970, see Asia/Hanoi in the file 'backzone'. + + # Yemen # See Asia/Riyadh. diff --git a/src/make/data/tzdata/australasia b/src/make/data/tzdata/australasia index 82e88c51e91..7d7c54b9615 100644 --- a/src/make/data/tzdata/australasia +++ b/src/make/data/tzdata/australasia @@ -48,7 +48,7 @@ Rule Aus 1943 only - Oct 3 2:00 1:00 D # says W Australia didn't use DST in 1943/1944. Ignore Whitman's claim that # 1944/1945 was just like 1943/1944. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # Northern Territory Zone Australia/Darwin 8:43:20 - LMT 1895 Feb 9:00 - ACST 1899 May @@ -125,7 +125,7 @@ Rule AS 2006 only - Apr 2 2:00s 0 S Rule AS 2007 only - Mar lastSun 2:00s 0 S Rule AS 2008 max - Apr Sun>=1 2:00s 0 S Rule AS 2008 max - Oct Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Australia/Adelaide 9:14:20 - LMT 1895 Feb 9:00 - ACST 1899 May 9:30 Aus AC%sT 1971 @@ -157,7 +157,7 @@ Rule AT 2001 max - Oct Sun>=1 2:00s 1:00 D Rule AT 2006 only - Apr Sun>=1 2:00s 0 S Rule AT 2007 only - Mar lastSun 2:00s 0 S Rule AT 2008 max - Apr Sun>=1 2:00s 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Australia/Hobart 9:49:16 - LMT 1895 Sep 10:00 - AEST 1916 Oct 1 2:00 10:00 1:00 AEDT 1917 Feb @@ -185,7 +185,7 @@ Rule AV 2006 only - Apr Sun>=1 2:00s 0 S Rule AV 2007 only - Mar lastSun 2:00s 0 S Rule AV 2008 max - Apr Sun>=1 2:00s 0 S Rule AV 2008 max - Oct Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Australia/Melbourne 9:39:52 - LMT 1895 Feb 10:00 Aus AE%sT 1971 10:00 AV AE%sT @@ -208,7 +208,7 @@ Rule AN 2006 only - Apr Sun>=1 2:00s 0 S Rule AN 2007 only - Mar lastSun 2:00s 0 S Rule AN 2008 max - Apr Sun>=1 2:00s 0 S Rule AN 2008 max - Oct Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Australia/Sydney 10:04:52 - LMT 1895 Feb 10:00 Aus AE%sT 1971 10:00 AN AE%sT @@ -279,14 +279,14 @@ Zone Antarctica/Macquarie 0 - -00 1899 Nov 11:00 - +11 # Christmas -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Christmas 7:02:52 - LMT 1895 Feb 7:00 - +07 # Cocos (Keeling) Is # These islands were ruled by the Ross family from about 1830 to 1978. # We don't know when standard time was introduced; for now, we guess 1900. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Indian/Cocos 6:27:40 - LMT 1900 6:30 - +0630 @@ -409,12 +409,12 @@ Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 - Rule Fiji 2015 max - Jan Sun>=13 3:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji +12/+13 # French Polynesia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Gambier -8:59:48 - LMT 1912 Oct # Rikitea -9:00 - -09 Zone Pacific/Marquesas -9:18:00 - LMT 1912 Oct @@ -425,15 +425,49 @@ Zone Pacific/Tahiti -9:58:16 - LMT 1912 Oct # Papeete # it is uninhabited. # Guam -# Zone NAME GMTOFF RULES FORMAT [UNTIL] + +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +# http://guamlegislature.com/Public_Laws_5th/PL05-025.pdf +# http://documents.guam.gov/wp-content/uploads/E.O.-59-7-Guam-Daylight-Savings-Time-May-6-1959.pdf +Rule Guam 1959 only - Jun 27 2:00 1:00 D +# http://documents.guam.gov/wp-content/uploads/E.O.-61-5-Revocation-of-Daylight-Saving-Time-and-Restoratio.pdf +Rule Guam 1961 only - Jan 29 2:00 0 S +# http://documents.guam.gov/wp-content/uploads/E.O.-67-13-Guam-Daylight-Savings-Time.pdf +Rule Guam 1967 only - Sep 1 2:00 1:00 D +# http://documents.guam.gov/wp-content/uploads/E.O.-69-2-Repeal-of-Guam-Daylight-Saving-Time.pdf +Rule Guam 1969 only - Jan 26 0:01 0 S +# http://documents.guam.gov/wp-content/uploads/E.O.-69-10-Guam-Daylight-Saving-Time.pdf +Rule Guam 1969 only - Jun 22 2:00 1:00 D +Rule Guam 1969 only - Aug 31 2:00 0 S +# http://documents.guam.gov/wp-content/uploads/E.O.-70-10-Guam-Daylight-Saving-Time.pdf +# http://documents.guam.gov/wp-content/uploads/E.O.-70-30-End-of-Guam-Daylight-Saving-Time.pdf +# http://documents.guam.gov/wp-content/uploads/E.O.-71-5-Guam-Daylight-Savings-Time.pdf +Rule Guam 1970 1971 - Apr lastSun 2:00 1:00 D +Rule Guam 1970 1971 - Sep Sun>=1 2:00 0 S +# http://documents.guam.gov/wp-content/uploads/E.O.-73-28.-Guam-Day-light-Saving-Time.pdf +Rule Guam 1973 only - Dec 16 2:00 1:00 D +# http://documents.guam.gov/wp-content/uploads/E.O.-74-7-Guam-Daylight-Savings-Time-Rescinded.pdf +Rule Guam 1974 only - Feb 24 2:00 0 S +# http://documents.guam.gov/wp-content/uploads/E.O.-76-13-Daylight-Savings-Time.pdf +Rule Guam 1976 only - May 26 2:00 1:00 D +# http://documents.guam.gov/wp-content/uploads/E.O.-76-25-Revocation-of-E.O.-76-13.pdf +Rule Guam 1976 only - Aug 22 2:01 0 S +# http://documents.guam.gov/wp-content/uploads/E.O.-77-4-Daylight-Savings-Time.pdf +Rule Guam 1977 only - Apr 24 2:00 1:00 D +# http://documents.guam.gov/wp-content/uploads/E.O.-77-18-Guam-Standard-Time.pdf +Rule Guam 1977 only - Aug 28 2:00 0 S + +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Guam -14:21:00 - LMT 1844 Dec 31 9:39:00 - LMT 1901 # Agana - 10:00 - GST 2000 Dec 23 # Guam + 10:00 - GST 1941 Dec 10 # Guam + 9:00 - +09 1944 Jul 31 + 10:00 Guam G%sT 2000 Dec 23 10:00 - ChST # Chamorro Standard Time Link Pacific/Guam Pacific/Saipan # N Mariana Is # Kiribati -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Tarawa 11:32:04 - LMT 1901 # Bairiki 12:00 - +12 Zone Pacific/Enderbury -11:24:20 - LMT 1901 @@ -449,32 +483,57 @@ Zone Pacific/Kiritimati -10:29:20 - LMT 1901 # See Pacific/Guam. # Marshall Is -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Majuro 11:24:48 - LMT 1901 - 11:00 - +11 1969 Oct - 12:00 - +12 -Zone Pacific/Kwajalein 11:09:20 - LMT 1901 - 11:00 - +11 1969 Oct - -12:00 - -12 1993 Aug 20 - 12:00 - +12 +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Pacific/Majuro 11:24:48 - LMT 1901 + 11:00 - +11 1914 Oct + 9:00 - +09 1919 Feb 1 + 11:00 - +11 1937 + 10:00 - +10 1941 Apr 1 + 9:00 - +09 1944 Jan 30 + 11:00 - +11 1969 Oct + 12:00 - +12 +Zone Pacific/Kwajalein 11:09:20 - LMT 1901 + 11:00 - +11 1937 + 10:00 - +10 1941 Apr 1 + 9:00 - +09 1944 Feb 6 + 11:00 - +11 1969 Oct + -12:00 - -12 1993 Aug 20 24:00 + 12:00 - +12 # Micronesia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Chuuk 10:07:08 - LMT 1901 - 10:00 - +10 -Zone Pacific/Pohnpei 10:32:52 - LMT 1901 # Kolonia - 11:00 - +11 -Zone Pacific/Kosrae 10:51:56 - LMT 1901 - 11:00 - +11 1969 Oct - 12:00 - +12 1999 - 11:00 - +11 +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Pacific/Chuuk -13:52:52 - LMT 1844 Dec 31 + 10:07:08 - LMT 1901 + 10:00 - +10 1914 Oct + 9:00 - +09 1919 Feb 1 + 10:00 - +10 1941 Apr 1 + 9:00 - +09 1945 Aug + 10:00 - +10 +Zone Pacific/Pohnpei -13:27:08 - LMT 1844 Dec 31 # Kolonia + 10:32:52 - LMT 1901 + 11:00 - +11 1914 Oct + 9:00 - +09 1919 Feb 1 + 11:00 - +11 1937 + 10:00 - +10 1941 Apr 1 + 9:00 - +09 1945 Aug + 11:00 - +11 +Zone Pacific/Kosrae -13:08:04 - LMT 1844 Dec 31 + 10:51:56 - LMT 1901 + 11:00 - +11 1914 Oct + 9:00 - +09 1919 Feb 1 + 11:00 - +11 1937 + 10:00 - +10 1941 Apr 1 + 9:00 - +09 1945 Aug + 11:00 - +11 1969 Oct + 12:00 - +12 1999 + 11:00 - +11 # Nauru -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Nauru 11:07:40 - LMT 1921 Jan 15 # Uaobe - 11:30 - +1130 1942 Mar 15 - 9:00 - +09 1944 Aug 15 - 11:30 - +1130 1979 May + 11:30 - +1130 1942 Aug 29 + 9:00 - +09 1945 Sep 8 + 11:30 - +1130 1979 Feb 10 2:00 12:00 - +12 # New Caledonia @@ -484,7 +543,7 @@ Rule NC 1978 1979 - Feb 27 0:00 0 - Rule NC 1996 only - Dec 1 2:00s 1:00 - # Shanks & Pottenger say the following was at 2:00; go with IATA. Rule NC 1997 only - Mar 2 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Noumea 11:05:48 - LMT 1912 Jan 13 # Nouméa 11:00 NC +11/+12 @@ -523,7 +582,7 @@ Rule NZ 2007 max - Sep lastSun 2:00s 1:00 D Rule Chatham 2007 max - Sep lastSun 2:45s 1:00 - Rule NZ 2008 max - Apr Sun>=1 2:00s 0 S Rule Chatham 2008 max - Apr Sun>=1 2:45s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Auckland 11:39:04 - LMT 1868 Nov 2 11:30 NZ NZ%sT 1946 Jan 1 12:00 NZ NZ%sT @@ -549,7 +608,7 @@ Link Pacific/Auckland Antarctica/McMurdo Rule Cook 1978 only - Nov 12 0:00 0:30 - Rule Cook 1979 1991 - Mar Sun>=1 0:00 0 - Rule Cook 1979 1990 - Oct lastSun 0:00 0:30 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Rarotonga -10:39:04 - LMT 1901 # Avarua -10:30 - -1030 1978 Nov 12 -10:00 Cook -10/-0930 @@ -558,14 +617,14 @@ Zone Pacific/Rarotonga -10:39:04 - LMT 1901 # Avarua # Niue -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Niue -11:19:40 - LMT 1901 # Alofi -11:20 - -1120 1951 -11:30 - -1130 1978 Oct 1 -11:00 - -11 # Norfolk -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Norfolk 11:11:52 - LMT 1901 # Kingston 11:12 - +1112 1951 11:30 - +1130 1974 Oct 27 02:00 @@ -574,12 +633,13 @@ Zone Pacific/Norfolk 11:11:52 - LMT 1901 # Kingston 11:00 - +11 # Palau (Belau) -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Palau 8:57:56 - LMT 1901 # Koror - 9:00 - +09 +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Pacific/Palau -15:02:04 - LMT 1844 Dec 31 # Koror + 8:57:56 - LMT 1901 + 9:00 - +09 # Papua New Guinea -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Port_Moresby 9:48:40 - LMT 1880 9:48:32 - PMMT 1895 # Port Moresby Mean Time 10:00 - +10 @@ -609,7 +669,7 @@ Zone Pacific/Bougainville 10:22:16 - LMT 1880 11:00 - +11 # Pitcairn -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Pitcairn -8:40:20 - LMT 1901 # Adamstown -8:30 - -0830 1998 Apr 27 0:00 -8:00 - -08 @@ -694,7 +754,7 @@ Rule WS 2011 only - Apr Sat>=1 4:00 0 - Rule WS 2011 only - Sep lastSat 3:00 1 - Rule WS 2012 max - Apr Sun>=1 4:00 0 - Rule WS 2012 max - Sep lastSun 3:00 1 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Apia 12:33:04 - LMT 1892 Jul 5 -11:26:56 - LMT 1911 -11:30 - -1130 1950 @@ -703,7 +763,7 @@ Zone Pacific/Apia 12:33:04 - LMT 1892 Jul 5 # Solomon Is # excludes Bougainville, for which see Papua New Guinea -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Guadalcanal 10:39:48 - LMT 1912 Oct # Honiara 11:00 - +11 @@ -726,7 +786,7 @@ Zone Pacific/Guadalcanal 10:39:48 - LMT 1912 Oct # Honiara # was "11 hours slow on G.M.T." Go with Thorsen and assume Shanks & Pottenger # are off by an hour starting in 1901. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Fakaofo -11:24:56 - LMT 1901 -11:00 - -11 2011 Dec 30 13:00 - +13 @@ -739,14 +799,14 @@ Rule Tonga 2000 2001 - Nov Sun>=1 2:00 1:00 - Rule Tonga 2001 2002 - Jan lastSun 2:00 0 - Rule Tonga 2016 only - Nov Sun>=1 2:00 1:00 - Rule Tonga 2017 only - Jan Sun>=15 3:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Tongatapu 12:19:20 - LMT 1901 12:20 - +1220 1941 13:00 - +13 1999 13:00 Tonga +13/+14 # Tuvalu -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Funafuti 11:56:52 - LMT 1901 12:00 - +12 @@ -807,7 +867,7 @@ Zone Pacific/Funafuti 11:56:52 - LMT 1901 # uninhabited since World War II; was probably like Pacific/Kiritimati # Wake -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Wake 11:06:28 - LMT 1901 12:00 - +12 @@ -820,12 +880,12 @@ Rule Vanuatu 1984 only - Oct 23 0:00 1:00 - Rule Vanuatu 1985 1991 - Sep Sun>=23 0:00 1:00 - Rule Vanuatu 1992 1993 - Jan Sun>=23 0:00 0 - Rule Vanuatu 1992 only - Oct Sun>=23 0:00 1:00 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Efate 11:13:16 - LMT 1912 Jan 13 # Vila 11:00 Vanuatu +11/+12 # Wallis and Futuna -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Wallis 12:15:20 - LMT 1901 12:00 - +12 @@ -838,7 +898,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2017-02-10): +# From Paul Eggert (2018-11-18): # # Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), @@ -863,6 +923,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # A reliable and entertaining source about time zones is # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). # +# I invented the abbreviation marked "*". # The following abbreviations are from other sources. # Corrections are welcome! # std dst @@ -870,7 +931,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # 8:00 AWST AWDT Western Australia # 9:30 ACST ACDT Central Australia # 10:00 AEST AEDT Eastern Australia -# 10:00 GST Guam through 2000 +# 10:00 GST GDT* Guam through 2000 # 10:00 ChST Chamorro # 11:30 NZMT NZST New Zealand through 1945 # 12:00 NZST NZDT New Zealand 1946-present @@ -1210,6 +1271,22 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # in WA or its introduction in SA had anything to do with the genesis # of this time zone. My hunch is that it's been around since well # before 1975. I remember seeing it noted on road maps decades ago. +# +# From Gilmore Davidson (2019-04-08): +# https://www.abc.net.au/news/2019-04-08/this-remote-stretch-of-desert-has-its-own-custom-time-zone/10981000 +# ... include[s] a rough description of the geographical boundaries... +# "The time zone exists for about 340 kilometres and takes in the tiny +# roadhouse communities of Cocklebiddy, Madura, Eucla and Border Village." +# ... and an indication that the zone has definitely been in existence +# since before the 1970 cut-off of the database ... +# From Paul Eggert (2019-05-17): +# That ABC Esperance story by Christien de Garis also says: +# Although the Central Western Time Zone is not officially recognised (your +# phones won't automatically change), there is a sign instructing you which +# way to wind your clocks 45 minutes and scrawled underneath one of them in +# Texta is the word: 'Why'? +# "Good question," Mr Pike said. +# "I don't even know that, and it's been going for over 50 years." # From Paul Eggert (2006-12-15): # For lack of better info, assume the tradition dates back to the @@ -1528,6 +1605,42 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 ############################################################################### +# Bonin (Ogasawara) Islands and Marcus Island (Minami-Tori-shima) + +# From Wakaba (2019-01-28) via Phake Nick: +# National Diet Library of Japan has several reports by Japanese Government +# officers that describe the time used in islands when they visited there. +# According to them (and other sources such as newspapers), standard time UTC +# + 10 (JST + 1) and DST UTC + 11 (JST + 2) was used until its return to Japan +# at 1968-06-26 00:00 JST. The exact periods of DST are still unknown. +# I guessed Guam, Mariana, and Bonin and Marcus districts might have +# synchronized their DST periods, but reports imply they had their own +# decisions, i.e. there were three or more different time zones.... +# +# https://wiki.suikawiki.org/n/小笠原諸島の標準時 + +# From Phake Nick (2019-02-12): +# Because their last time change to return to Japanese time when they returned +# to Japanese rule was right before 1970, ... per the current tz database +# rule, the information doesn't warrant creation of a new timezone for Bonin +# Islands itself and is thus as an anecdotal note for interest purpose only. +# ... [The abovementioned link] described some special timekeeping phenomenon +# regarding Marcus island, another remote island currently owned by Japanese +# in the same administrative unit as Bonin Islands. Many reports claim that +# the American coastal guard on the American quarter of the island use its own +# coastal guard time, and most sources describe the time as UTC+11, being two +# hours faster than JST used by some Japanese personnel on the island. Some +# sites describe it as same as Wake Island/Guam time although it would be +# incorrect to be same as Guam. And then in a few Japanese governmental +# report from 1980s (from National Institute of Information and Communications +# Technology) regarding the construction of VLBI facility on the Marcus +# Island, it claimed that there are three time standards being used on the +# island at the time which include not just JST (UTC+9) or [US]CG time +# (UTC+11) but also a JMSDF time (UTC+10) (Japan Maritime Self-Defense +# Force). Unfortunately there are no other sources that mentioned such time +# and there are also no information on things like how the time was used. + + # Fiji # Howse writes (p 153) that in 1879 the British governor of Fiji @@ -1569,28 +1682,70 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Kwajalein -# In comp.risks 14.87 (26 August 1993), Peter Neumann writes: -# I wonder what happened in Kwajalein, where there was NO Friday, -# 1993-08-20. Thursday night at midnight Kwajalein switched sides with -# respect to the International Date Line, to rejoin its fellow islands, -# going from 11:59 p.m. Thursday to 12:00 m. Saturday in a blink. +# From an AP article (1993-08-22): +# "The nearly 3,000 Americans living on this remote Pacific atoll have a good +# excuse for not remembering Saturday night: there wasn't one. Residents were +# going to bed Friday night and waking up Sunday morning because at midnight +# -- 8 A.M. Eastern daylight time on Saturday -- Kwajalein was jumping from +# one side of the international date line to the other." +# "In Marshall Islands, Friday is followed by Sunday", NY Times. 1993-08-22. +# https://www.nytimes.com/1993/08/22/world/in-marshall-islands-friday-is-followed-by-sunday.html + +# From Phake Nick (2018-10-27): +# ... pointed out that +# currently tzdata say Pacific/Kwajalein switched from GMT+11 to GMT-12 in +# 1969 October without explanation, however an 1993 article from NYT say it +# synchorized its day with US mainland about 40 years ago and thus the switch +# should occur at around 1950s instead. +# +# From Paul Eggert (2018-11-18): +# The NYT (actually, AP) article is vague and possibly wrong about this. +# The article says the earlier switch was "40 years ago when the United States +# Army established a missile test range here". However, the Kwajalein Test +# Center was established on 1960-10-01 and was run by the US Navy. It was +# transferred to the US Army on 1964-07-01. See "Seize the High Ground" +# . +# Given that Shanks was right on the money about the 1993 change, I'm inclined +# to take Shanks's word for the 1969 change unless we find better evidence. # N Mariana Is, Guam +# From Phake Nick (2018-10-27): +# Guam Island was briefly annexed by Japan during ... year 1941-1944 ... +# however there are no detailed information about what time it use during that +# period. It would probably be reasonable to assume Guam use GMT+9 during +# that period of time like the surrounding area. + +# From Paul Eggert (2018-11-18): # Howse writes (p 153) "The Spaniards, on the other hand, reached the # Philippines and the Ladrones from America," and implies that the Ladrones # (now called the Marianas) kept American date for quite some time. # For now, we assume the Ladrones switched at the same time as the Philippines; # see Asia/Manila. - +# +# Use 1941-12-10 and 1944-07-31 for Guam WWII transitions, as the rough start +# and end of Japanese control of Agana. We don't know whether the Northern +# Marianas followed Guam's DST rules from 1959 through 1977; for now, assume +# they did as that avoids the need for a separate zone due to our 1970 cutoff. +# # US Public Law 106-564 (2000-12-23) made UT +10 the official standard time, # under the name "Chamorro Standard Time". There is no official abbreviation, # but Congressman Robert A. Underwood, author of the bill that became law, # wrote in a press release (2000-12-27) that he will seek the use of "ChST". +# See also the commentary for Micronesia. + + +# Marshall Is +# See the commentary for Micronesia. -# Micronesia + +# Micronesia (and nearby) + +# From Paul Eggert (2018-11-18): +# Like the Ladrones (see Guam commentary), assume the Spanish East Indies +# kept American time until the Philippines switched at the end of 1844. # Alan Eugene Davis writes (1996-03-16), # "I am certain, having lived there for the past decade, that 'Truk' @@ -1606,6 +1761,95 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # that Truk and Yap are UT +10, and Ponape and Kosrae are +11. # We don't know when Kosrae switched from +12; assume January 1 for now. +# From Phake Nick (2018-10-27): +# +# From a Japanese wiki site https://wiki.suikawiki.org/n/南洋群島の標準時 +# ... +# For "Southern Islands" (modern region of Mariana + Palau + Federation of +# Micronesia + Marshall Islands): +# +# A 1906 Japanese magazine shown the Caroline Islands and Mariana Islands +# who was occupied by Germany at the time as GMT+10, together with the like +# of German New Guinea. However there is a marking saying it have not been +# implemented (yet). No further information after that were found. +# +# Japan invaded those islands in 1914, and records shows that they were +# instructed to use JST at the time. +# +# 1915 January telecommunication record on the Jaluit Atoll shows they use +# the meridian of 170E as standard time (GMT+11:20), which is similar to the +# longitude of the atoll. +# 1915 February record say the 170E standard time is to be used until +# February 9 noon, and after February 9 noon they are to use JST. +# However these are time used within the Japanese Military at the time and +# probably does not reflect the time used by local resident at the time (that +# is if they keep their own time back then) +# +# In January 1919 the occupying force issued a command that split the area +# into three different timezone with meridian of 135E, 150E, 165E (JST+0, +1, +# +2), and the command was to become effective from February 1 of the same +# year. Despite the target of the command is still only for the occupying +# force itself, further publication have described the time as the standard +# time for the occupied area and thus it can probably be seen as such. +# * Area that use meridian of 135E: Palau and Yap civil administration area +# (Southern Islands Western Standard Time) +# * Area that use meridian of 150E: Truk (Chuuk) and Saipan civil +# administration area (Southern Islands Central Standard Time) +# * Area that use meridian of 165E: Ponape (Pohnpei) and Jaluit civil +# administration area (Southern Islands Eastern Standard Time). +# * In the next few years Japanese occupation of those islands have been +# formalized via League of Nation Mandate (South Pacific Mandate) and formal +# governance structure have been established, these district [become +# subprefectures] and timezone classification have been inherited as standard +# time of the area. +# * Saipan subprefecture include Mariana islands (exclude Guam which was +# occupied by America at the time), Palau and Yap subprefecture rule the +# Western Caroline Islands with 137E longitude as border, Truk and Ponape +# subprefecture rule the Eastern Caroline Islands with 154E as border, Ponape +# subprefecture also rule part of Marshall Islands to the west of 164E +# starting from (1918?) and Jaluit subprefecture rule the rest of the +# Marshall Islands. +# +# And then in year 1937, an announcement was made to change the time in the +# area into 2 timezones: +# * Area that use meridian of 135E: area administered by Palau, Yap and +# Saipan subprefecture (Southern Islands Western Standard Time) +# * Area that use meridian of 150E: area administered by Truk (Chuuk), +# Ponape (Pohnpei) and Jaluit subprefecture (Southern Islands Eastern +# Standard Time) +# +# Another announcement issued in 1941 say that on April 1 that year, +# standard time of the Southern Islands would be changed to use the meridian +# of 135E (GMT+9), and thus abolishing timezone different within the area. +# +# Then Pacific theater of WWII started and Japan slowly lose control on the +# island. The webpage I linked above contain no information during this +# period of time.... +# +# After the end of WWII, in 1946 February, a document written by the +# (former?) Japanese military personnel describe there are 3 hours time +# different between Caroline islands time/Wake island time and the Chungking +# time, which would mean the time being used there at the time was GMT+10. +# +# After that, the area become Trust Territories of the Pacific Islands +# under American administration from year 1947. The site listed some +# American/International books/maps/publications about time used in those +# area during this period of time but they doesn't seems to be reliable +# information so it would be the best if someone know where can more reliable +# information can be found. +# +# +# From Paul Eggert (2018-11-18): +# +# For the above, use vague dates like "1914" and "1945" for transitions that +# plausibly exist but for which the details are not known. The information +# for Wake is too sketchy to act on. +# +# The 1906 GMT+10 info about German-controlled islands might not have been +# done, so omit it from the data for now. +# +# The Jaluit info governs Kwajalein. + # Midway @@ -1623,6 +1867,29 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # started DST on June 3. Possibly DST was observed other years # in Midway, but we have no record of it. +# Nauru + +# From Phake Nick (2018-10-31): +# Currently, the tz database say Nauru use LMT until 1921, and then +# switched to GMT+11:30 for the next two decades. +# However, a number of timezone map published in America/Japan back then +# showed its timezone as GMT+11 per https://wiki.suikawiki.org/n/ナウルの標準時 +# And it would also be nice if the 1921 transition date could be sourced. +# ... +# The "Nauru Standard Time Act 1978 Time Change" +# http://ronlaw.gov.nr/nauru_lpms/files/gazettes/4b23a17d2030150404db7a5fa5872f52.pdf#page=3 +# based on "Nauru Standard Time Act 1978 Time Change" +# http://www.paclii.org/nr/legis/num_act/nsta1978207/ defined that "Nauru +# Alternative Time" (GMT+12) should be in effect from 1979 Feb. +# +# From Paul Eggert (2018-11-19): +# The 1921-01-15 introduction of standard time is in Shanks; it is also in +# "Standard Time Throughout the World", US National Bureau of Standards (1935), +# page 3, which does not give the UT offset. In response to a comment by +# Phake Nick I set the Nauru time of occupation by Japan to +# 1942-08-29/1945-09-08 by using dates from: +# https://en.wikipedia.org/wiki/Japanese_occupation_of_Nauru + # Norfolk # From Alexander Krivenyshev (2015-09-23): @@ -1638,6 +1905,9 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # other than in 1974/5. See: # https://www.timeanddate.com/time/australia/norfolk-island.html +# Palau +# See commentary for Micronesia. + # Pitcairn # From Rives McDow (1999-11-08): @@ -1802,6 +2072,9 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # From Paul Eggert (2003-03-23): # We have no other report of DST in Wake Island, so omit this info for now. +# See also the commentary for Micronesia. + + ############################################################################### # The International Date Line diff --git a/src/make/data/tzdata/backward b/src/make/data/tzdata/backward index f30f30e511b..2a41a98010e 100644 --- a/src/make/data/tzdata/backward +++ b/src/make/data/tzdata/backward @@ -100,6 +100,7 @@ Link Pacific/Easter Chile/EasterIsland Link America/Havana Cuba Link Africa/Cairo Egypt Link Europe/Dublin Eire +Link Etc/UTC Etc/UCT Link Europe/London Europe/Belfast Link Europe/Chisinau Europe/Tiraspol Link Europe/London GB @@ -134,7 +135,7 @@ Link Asia/Taipei ROC Link Asia/Seoul ROK Link Asia/Singapore Singapore Link Europe/Istanbul Turkey -Link Etc/UCT UCT +Link Etc/UTC UCT Link America/Anchorage US/Alaska Link America/Adak US/Aleutian Link America/Phoenix US/Arizona diff --git a/src/make/data/tzdata/etcetera b/src/make/data/tzdata/etcetera index db5937879e0..7c7eab1f6a1 100644 --- a/src/make/data/tzdata/etcetera +++ b/src/make/data/tzdata/etcetera @@ -42,7 +42,6 @@ Zone Etc/GMT 0 - GMT Zone Etc/UTC 0 - UTC -Zone Etc/UCT 0 - UCT # The following link uses older naming conventions, # but it belongs here, not in the file 'backward', diff --git a/src/make/data/tzdata/europe b/src/make/data/tzdata/europe index e434b7e9fc4..46c57457c47 100644 --- a/src/make/data/tzdata/europe +++ b/src/make/data/tzdata/europe @@ -145,7 +145,7 @@ # position is 51° 28' 30" N, 0° 18' 45" W. The longitude should # be within about ±2". The Ordnance Survey grid reference is TQ172761. # -# [This yields GMTOFF = -0:01:15 for London LMT in the 18th century.] +# [This yields STDOFF = -0:01:15 for London LMT in the 18th century.] # From Paul Eggert (1993-11-18): # @@ -523,7 +523,7 @@ Rule GB-Eire 1990 1995 - Oct Sun>=22 1:00u 0 GMT # # Use Europe/London for Jersey, Guernsey, and the Isle of Man. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/London -0:01:15 - LMT 1847 Dec 1 0:00s 0:00 GB-Eire %s 1968 Oct 27 1:00 - BST 1971 Oct 31 2:00u @@ -553,15 +553,15 @@ Link Europe/London Europe/Isle_of_Man # summer and negative daylight saving time in winter. It is for when # negative SAVE values are used. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Eire 1971 only - Oct 31 2:00u -1:00 - -#Rule Eire 1972 1980 - Mar Sun>=16 2:00u 0 - -#Rule Eire 1972 1980 - Oct Sun>=23 2:00u -1:00 - -#Rule Eire 1981 max - Mar lastSun 1:00u 0 - -#Rule Eire 1981 1989 - Oct Sun>=23 1:00u -1:00 - -#Rule Eire 1990 1995 - Oct Sun>=22 1:00u -1:00 - -#Rule Eire 1996 max - Oct lastSun 1:00u -1:00 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Rule Eire 1971 only - Oct 31 2:00u -1:00 - +Rule Eire 1972 1980 - Mar Sun>=16 2:00u 0 - +Rule Eire 1972 1980 - Oct Sun>=23 2:00u -1:00 - +Rule Eire 1981 max - Mar lastSun 1:00u 0 - +Rule Eire 1981 1989 - Oct Sun>=23 1:00u -1:00 - +Rule Eire 1990 1995 - Oct Sun>=22 1:00u -1:00 - +Rule Eire 1996 max - Oct lastSun 1:00u -1:00 - + +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 -0:25:21 - DMT 1916 May 21 2:00s -0:25:21 1:00 IST 1916 Oct 1 2:00s @@ -573,11 +573,11 @@ Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 0:00 - GMT 1948 Apr 18 2:00s 0:00 GB-Eire GMT/IST 1968 Oct 27 # The next line is for when negative SAVE values are used. -# 1:00 Eire IST/GMT + 1:00 Eire IST/GMT # These three lines are for when SAVE values are always nonnegative. - 1:00 - IST 1971 Oct 31 2:00u - 0:00 GB-Eire GMT/IST 1996 - 0:00 EU GMT/IST +# 1:00 - IST 1971 Oct 31 2:00u +# 0:00 GB-Eire GMT/IST 1996 +# 0:00 EU GMT/IST ############################################################################### @@ -760,7 +760,7 @@ Rule Russia 1996 2010 - Oct lastSun 2:00s 0 - # These are for backward compatibility with older versions. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone WET 0:00 EU WE%sT Zone CET 1:00 C-Eur CE%sT Zone MET 1:00 C-Eur ME%sT @@ -820,14 +820,14 @@ Rule Albania 1982 only - Oct 3 0:00 0 - Rule Albania 1983 only - Apr 18 0:00 1:00 S Rule Albania 1983 only - Oct 1 0:00 0 - Rule Albania 1984 only - Apr 1 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Tirane 1:19:20 - LMT 1914 1:00 - CET 1940 Jun 16 1:00 Albania CE%sT 1984 Jul 1:00 EU CE%sT # Andorra -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Andorra 0:06:04 - LMT 1901 0:00 - WET 1946 Sep 30 1:00 - CET 1985 Mar 31 2:00 @@ -853,7 +853,7 @@ Rule Austria 1947 only - Apr 6 2:00s 1:00 S Rule Austria 1948 only - Apr 18 2:00s 1:00 S Rule Austria 1980 only - Apr 6 0:00 1:00 S Rule Austria 1980 only - Sep 28 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Vienna 1:05:21 - LMT 1893 Apr 1:00 C-Eur CE%sT 1920 1:00 Austria CE%sT 1940 Apr 1 2:00s @@ -885,7 +885,7 @@ Zone Europe/Vienna 1:05:21 - LMT 1893 Apr # Belarussian government decided against changing to winter time.... # http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Minsk 1:50:16 - LMT 1880 1:50 - MMT 1924 May 2 # Minsk Mean Time 2:00 - EET 1930 Jun 21 @@ -949,7 +949,7 @@ Rule Belgium 1945 only - Apr 2 2:00s 1:00 S Rule Belgium 1945 only - Sep 16 2:00s 0 - Rule Belgium 1946 only - May 19 2:00s 1:00 S Rule Belgium 1946 only - Oct 7 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Brussels 0:17:30 - LMT 1880 0:17:30 - BMT 1892 May 1 12:00 # Brussels MT 0:00 - WET 1914 Nov 8 @@ -976,7 +976,7 @@ Rule Bulg 1979 only - Oct 1 1:00 0 - Rule Bulg 1980 1982 - Apr Sat>=1 23:00 1:00 S Rule Bulg 1980 only - Sep 29 1:00 0 - Rule Bulg 1981 only - Sep 27 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Sofia 1:33:16 - LMT 1880 1:56:56 - IMT 1894 Nov 30 # Istanbul MT? 2:00 - EET 1942 Nov 2 3:00 @@ -1009,15 +1009,15 @@ Rule Czech 1946 only - May 6 2:00s 1:00 S Rule Czech 1946 1949 - Oct Sun>=1 2:00s 0 - Rule Czech 1947 1948 - Apr Sun>=15 2:00s 1:00 S Rule Czech 1949 only - Apr 9 2:00s 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Prague 0:57:44 - LMT 1850 0:57:44 - PMT 1891 Oct # Prague Mean Time 1:00 C-Eur CE%sT 1945 May 9 1:00 Czech CE%sT 1946 Dec 1 3:00 # Vanguard section, for zic and other parsers that support negative DST. -# 1:00 -1:00 GMT 1947 Feb 23 2:00 + 1:00 -1:00 GMT 1947 Feb 23 2:00 # Rearguard section, for parsers that do not support negative DST. - 0:00 - GMT 1947 Feb 23 2:00 +# 0:00 - GMT 1947 Feb 23 2:00 # End of rearguard section. 1:00 Czech CE%sT 1979 1:00 EU CE%sT @@ -1071,7 +1071,7 @@ Rule Denmark 1947 only - Aug 10 2:00s 0 - Rule Denmark 1948 only - May 9 2:00s 1:00 S Rule Denmark 1948 only - Aug 8 2:00s 0 - # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Copenhagen 0:50:20 - LMT 1890 0:50:20 - CMT 1894 Jan 1 # Copenhagen MT 1:00 Denmark CE%sT 1942 Nov 2 2:00s @@ -1168,7 +1168,7 @@ Rule Thule 1993 2006 - Oct lastSun 2:00 0 S Rule Thule 2007 max - Mar Sun>=8 2:00 1:00 D Rule Thule 2007 max - Nov Sun>=1 2:00 0 S # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Danmarkshavn -1:14:40 - LMT 1916 Jul 28 -3:00 - -03 1980 Apr 6 2:00 -3:00 EU -03/-02 1996 @@ -1234,7 +1234,7 @@ Zone America/Thule -4:35:08 - LMT 1916 Jul 28 # Pituffik air base # From Urmet Jänes (2002-03-28): # The legislative reference is Government decree No. 84 on 2002-02-21. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Tallinn 1:39:00 - LMT 1880 1:39:00 - TMT 1918 Feb # Tallinn Mean Time 1:00 C-Eur CE%sT 1919 Jul @@ -1297,7 +1297,7 @@ Rule Finland 1981 1982 - Sep lastSun 3:00 0 - # Milne says Helsinki (Helsingfors) time was 1:39:49.2 (official document); # round to nearest. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Helsinki 1:39:49 - LMT 1878 May 31 1:39:49 - HMT 1921 May # Helsinki Mean Time 2:00 Finland EE%sT 1983 @@ -1387,7 +1387,7 @@ Rule France 1976 only - Sep 26 1:00 0 - # but Howse quotes the actual French legislation as saying 0:09:21. # Go with Howse. Howse writes that the time in France was officially based # on PMT-0:09:21 until 1978-08-09, when the time base finally switched to UTC. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 0:09:21 - PMT 1911 Mar 11 0:01 # Paris MT # Shanks & Pottenger give 1940 Jun 14 0:00; go with Excoffier and Le Corre. @@ -1435,7 +1435,7 @@ Rule SovietZone 1945 only - May 24 2:00 2:00 M # Midsummer Rule SovietZone 1945 only - Sep 24 3:00 1:00 S Rule SovietZone 1945 only - Nov 18 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Berlin 0:53:28 - LMT 1893 Apr 1:00 C-Eur CE%sT 1945 May 24 2:00 1:00 SovietZone CE%sT 1946 @@ -1463,7 +1463,7 @@ Link Europe/Zurich Europe/Busingen # is in Europe. Our reference location Tbilisi is in the Asian part. # Gibraltar -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Gibraltar -0:21:24 - LMT 1880 Aug 2 0:00s 0:00 GB-Eire %s 1957 Apr 14 2:00 1:00 - CET 1982 @@ -1494,7 +1494,7 @@ Rule Greece 1979 only - Apr 1 9:00 1:00 S Rule Greece 1979 only - Sep 29 2:00 0 - Rule Greece 1980 only - Apr 1 0:00 1:00 S Rule Greece 1980 only - Sep 28 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Athens 1:34:52 - LMT 1895 Sep 14 1:34:52 - AMT 1916 Jul 28 0:01 # Athens MT 2:00 Greece EE%sT 1941 Apr 30 @@ -1531,7 +1531,7 @@ Rule Hungary 1956 only - Sep lastSun 0:00 0 - Rule Hungary 1957 only - Jun Sun>=1 1:00 1:00 S Rule Hungary 1957 only - Sep lastSun 3:00 0 - Rule Hungary 1980 only - Apr 6 1:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Budapest 1:16:20 - LMT 1890 Oct 1:00 C-Eur CE%sT 1918 1:00 Hungary CE%sT 1941 Apr 8 @@ -1592,7 +1592,7 @@ Rule Iceland 1947 1967 - Apr Sun>=1 1:00s 1:00 - Rule Iceland 1949 only - Oct 30 1:00s 0 - Rule Iceland 1950 1966 - Oct Sun>=22 1:00s 0 - Rule Iceland 1967 only - Oct 29 1:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Atlantic/Reykjavik -1:28 - LMT 1908 -1:00 Iceland -01/+00 1968 Apr 7 1:00s 0:00 - GMT @@ -1606,6 +1606,25 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # But these events all occurred before the 1970 cutoff, # so record only the time in Rome. # +# From Stephen Trainor (2019-05-06): +# http://www.ac-ilsestante.it/MERIDIANE/ora_legale/ORA_LEGALE_ESTIVA_IN_ITALIA.htm +# ... the [1866] law went into effect on 12 December 1866, rather than +# the date of the decree (22 Sep 1866) +# https://web.archive.org/web/20070824155341/http://www.iav.it/planetario/didastro/didastro/english.htm +# ... "In Italy in 1866 there were 6 railway times (Torino, Verona, Firenze, +# Roma, Napoli, Palermo). On that year it was decided to unify them, adopting +# the average time of Rome (even if this city was not yet part of the +# kingdom). On the 12th December 1866, on the starting of the winter time +# table, it took effect in the railways, the post office and the telegraph, +# not only for the internal service but also for the public.... Milano set +# the public watches on the Rome time on the same day (12th December 1866), +# Torino and Bologna on the 1st January 1867, Venezia the 1st May 1880 and the +# last city was Cagliari in 1886." +# +# From Luigi Rosa (2019-05-07): +# this is the scan of the decree: +# http://www.radiomarconi.com/marconi/filopanti/1866c.jpg +# # From Michael Deckers (2016-10-24): # http://www.ac-ilsestante.it/MERIDIANE/ora_legale quotes a law of 1893-08-10 # ... [translated as] "The preceding dispositions will enter into @@ -1616,6 +1635,7 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # The authoritative source for time in Italy is the national metrological # institute, which has a summary page of historical DST data at # http://www.inrim.it/res/tf/ora_legale_i.shtml +# [now at http://oldsite.inrim.it/res/tf/ora_legale_i.shtml as of 2017] # (2016-10-24): # http://www.renzobaldini.it/le-ore-legali-in-italia/ # has still different data for 1944. It divides Italy in two, as @@ -1679,8 +1699,8 @@ Rule Italy 1976 only - May 30 0:00s 1:00 S Rule Italy 1977 1979 - May Sun>=22 0:00s 1:00 S Rule Italy 1978 only - Oct 1 0:00s 0 - Rule Italy 1979 only - Sep 30 0:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Rome 0:49:56 - LMT 1866 Sep 22 +# Zone NAME STDOFF RULES FORMAT [UNTIL] +Zone Europe/Rome 0:49:56 - LMT 1866 Dec 12 0:49:56 - RMT 1893 Oct 31 23:49:56 # Rome Mean 1:00 Italy CE%sT 1943 Sep 10 1:00 C-Eur CE%sT 1944 Jun 4 @@ -1755,7 +1775,7 @@ Rule Latvia 1989 1996 - Sep lastSun 2:00s 0 - # Byalokoz 1919 says Latvia was 1:36:34. # Go with Byalokoz. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Riga 1:36:34 - LMT 1880 1:36:34 - RMT 1918 Apr 15 2:00 # Riga MT 1:36:34 1:00 LST 1918 Sep 16 3:00 # Latvian ST @@ -1825,7 +1845,7 @@ Link Europe/Zurich Europe/Vaduz # http://www.lrvk.lt/nut/11/n1749.htm -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Vilnius 1:41:16 - LMT 1880 1:24:00 - WMT 1917 # Warsaw Mean Time 1:35:36 - KMT 1919 Oct 10 # Kaunas Mean Time @@ -1869,7 +1889,7 @@ Rule Lux 1926 only - Apr 17 23:00 1:00 S Rule Lux 1927 only - Apr 9 23:00 1:00 S Rule Lux 1928 only - Apr 14 23:00 1:00 S Rule Lux 1929 only - Apr 20 23:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Luxembourg 0:24:36 - LMT 1904 Jun 1:00 Lux CE%sT 1918 Nov 25 0:00 Lux WE%sT 1929 Oct 6 2:00s @@ -1878,7 +1898,7 @@ Zone Europe/Luxembourg 0:24:36 - LMT 1904 Jun 1:00 Belgium CE%sT 1977 1:00 EU CE%sT -# Macedonia +# North Macedonia # See Europe/Belgrade. # Malta @@ -1894,7 +1914,7 @@ Rule Malta 1974 only - Sep 16 0:00s 0 - Rule Malta 1975 1979 - Apr Sun>=15 2:00 1:00 S Rule Malta 1975 1980 - Sep Sun>=15 2:00 0 - Rule Malta 1980 only - Mar 31 2:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 0:00s # Valletta 1:00 Italy CE%sT 1973 Mar 31 1:00 Malta CE%sT 1981 @@ -1963,7 +1983,7 @@ Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 0:00s # Valletta Rule Moldova 1997 max - Mar lastSun 2:00 1:00 S Rule Moldova 1997 max - Oct lastSun 3:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Chisinau 1:55:20 - LMT 1880 1:55 - CMT 1918 Feb 15 # Chisinau MT 1:44:24 - BMT 1931 Jul 24 # Bucharest MT @@ -1979,7 +1999,7 @@ Zone Europe/Chisinau 1:55:20 - LMT 1880 # Monaco # Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's # more precise 0:09:21. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15 0:09:21 - PMT 1911 Mar 11 # Paris Mean Time 0:00 France WE%sT 1945 Sep 16 3:00 @@ -2054,8 +2074,8 @@ Rule Neth 1945 only - Apr 2 2:00s 1:00 S Rule Neth 1945 only - Sep 16 2:00s 0 - # # Amsterdam Mean Time was +00:19:32.13, but the .13 is omitted -# below because the current format requires GMTOFF to be an integer. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# below because the current format requires STDOFF to be an integer. +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Amsterdam 0:19:32 - LMT 1835 0:19:32 Neth %s 1937 Jul 1 0:20 Neth +0020/+0120 1940 May 16 0:00 @@ -2074,7 +2094,7 @@ Rule Norway 1945 only - Oct 1 2:00s 0 - Rule Norway 1959 1964 - Mar Sun>=15 2:00s 1:00 S Rule Norway 1959 1965 - Sep Sun>=15 2:00s 0 - Rule Norway 1965 only - Apr 25 2:00s 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 1:00 Norway CE%sT 1940 Aug 10 23:00 1:00 C-Eur CE%sT 1945 Apr 2 2:00 @@ -2165,7 +2185,7 @@ Rule Poland 1959 1961 - Oct Sun>=1 1:00s 0 - Rule Poland 1960 only - Apr 3 1:00s 1:00 S Rule Poland 1961 1964 - May lastSun 1:00s 1:00 S Rule Poland 1962 1964 - Sep lastSun 1:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Warsaw 1:24:00 - LMT 1880 1:24:00 - WMT 1915 Aug 5 # Warsaw Mean Time 1:00 C-Eur CE%sT 1918 Sep 16 3:00 @@ -2270,7 +2290,7 @@ Rule Port 1980 only - Mar lastSun 0:00s 1:00 S Rule Port 1981 1982 - Mar lastSun 1:00s 1:00 S Rule Port 1983 only - Mar lastSun 2:00s 1:00 S # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Lisbon -0:36:45 - LMT 1884 -0:36:45 - LMT 1912 Jan 1 0:00u # Lisbon MT 0:00 Port WE%sT 1966 Apr 3 2:00 @@ -2329,7 +2349,7 @@ Rule Romania 1980 only - Apr 5 23:00 1:00 S Rule Romania 1980 only - Sep lastSun 1:00 0 - Rule Romania 1991 1993 - Mar lastSun 0:00s 1:00 S Rule Romania 1991 1993 - Sep lastSun 0:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct 1:44:24 - BMT 1931 Jul 24 # Bucharest MT 2:00 Romania EE%sT 1981 Mar 29 2:00s @@ -3368,7 +3388,7 @@ Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2 # See Europe/Rome. # Serbia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Belgrade 1:22:00 - LMT 1884 1:00 - CET 1941 Apr 18 23:00 1:00 C-Eur CE%sT 1945 @@ -3382,7 +3402,7 @@ Zone Europe/Belgrade 1:22:00 - LMT 1884 Link Europe/Belgrade Europe/Ljubljana # Slovenia Link Europe/Belgrade Europe/Podgorica # Montenegro Link Europe/Belgrade Europe/Sarajevo # Bosnia and Herzegovina -Link Europe/Belgrade Europe/Skopje # Macedonia +Link Europe/Belgrade Europe/Skopje # North Macedonia Link Europe/Belgrade Europe/Zagreb # Croatia # Slovakia @@ -3474,7 +3494,7 @@ Rule SpainAfrica 1976 only - Aug 1 0:00 0 - Rule SpainAfrica 1977 only - Sep 28 0:00 0 - Rule SpainAfrica 1978 only - Jun 1 0:00 1:00 S Rule SpainAfrica 1978 only - Aug 4 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Madrid -0:14:44 - LMT 1900 Dec 31 23:45:16 0:00 Spain WE%sT 1940 Mar 16 23:00 1:00 Spain CE%sT 1979 @@ -3542,7 +3562,7 @@ Zone Atlantic/Canary -1:01:36 - LMT 1922 Mar # Las Palmas de Gran C. # # Source: The newspaper "Dagens Nyheter", 1916-10-01, page 7 upper left. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 1:00:14 - SET 1900 Jan 1 # Swedish Time 1:00 - CET 1916 May 14 23:00 @@ -3645,7 +3665,7 @@ Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Swiss 1941 1942 - May Mon>=1 1:00 1:00 S Rule Swiss 1941 1942 - Oct Mon>=1 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment. 0:29:46 - BMT 1894 Jun # Bern Mean Time 1:00 Swiss CE%sT 1981 @@ -3795,7 +3815,7 @@ Rule Turkey 1986 1995 - Sep lastSun 1:00s 0 - Rule Turkey 1994 only - Mar 20 1:00s 1:00 S Rule Turkey 1995 2006 - Mar lastSun 1:00s 1:00 S Rule Turkey 1996 2006 - Oct lastSun 1:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Europe/Istanbul 1:55:52 - LMT 1880 1:56:56 - IMT 1910 Oct # Istanbul Mean Time? 2:00 Turkey EE%sT 1978 Oct 15 @@ -3892,16 +3912,8 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # controversial, and some day "Kyiv" may become substantially more popular in # English; in the meantime, stick with the traditional English "Kiev" as that # means less disruption for our users. -# -# Anyway, none of the common English-language spellings (Kiev, Kyiv, Kieff, -# Kijeff, Kijev, Kiyef, Kiyeff) do justice to the common pronunciation in -# Ukrainian, namely [ˈkɪjiu̯] (IPA). This pronunciation has nothing like an -# English "v" or "f", and instead trails off with what an English-speaker -# would call a demure "oo" sound, and it would would be better anglicized as -# "Kuiyu". Here's a sound file, if you would like to do as the Kuiyuvians do: -# https://commons.wikimedia.org/wiki/File:Uk-Київ.ogg -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # This represents most of Ukraine. See above for the spelling of "Kiev". Zone Europe/Kiev 2:02:04 - LMT 1880 2:02:04 - KMT 1924 May 2 # Kiev Mean Time diff --git a/src/make/data/tzdata/factory b/src/make/data/tzdata/factory index 6ef6bca0b8c..a05346a301d 100644 --- a/src/make/data/tzdata/factory +++ b/src/make/data/tzdata/factory @@ -31,5 +31,5 @@ # time zone abbreviation "-00", indicating that the actual time zone # is unknown. -# Zone NAME GMTOFF RULES FORMAT +# Zone NAME STDOFF RULES FORMAT Zone Factory 0 - -00 diff --git a/src/make/data/tzdata/iso3166.tab b/src/make/data/tzdata/iso3166.tab index 38a3a1ed52b..544b3034c17 100644 --- a/src/make/data/tzdata/iso3166.tab +++ b/src/make/data/tzdata/iso3166.tab @@ -32,8 +32,8 @@ # All text uses UTF-8 encoding. The columns of the table are as follows: # # 1. ISO 3166-1 alpha-2 country code, current as of -# ISO 3166-1 N905 (2016-11-15). See: Updates on ISO 3166-1 -# http://isotc.iso.org/livelink/livelink/Open/16944257 +# ISO 3166-1 N976 (2018-11-06). See: Updates on ISO 3166-1 +# https://isotc.iso.org/livelink/livelink/Open/16944257 # 2. The usual English name for the coded region, # chosen so that alphabetic sorting of subsets produces helpful lists. # This is not the same as the English name in the ISO 3166 tables. @@ -189,7 +189,7 @@ ME Montenegro MF St Martin (French) MG Madagascar MH Marshall Islands -MK Macedonia +MK North Macedonia ML Mali MM Myanmar (Burma) MN Mongolia @@ -258,7 +258,7 @@ ST Sao Tome & Principe SV El Salvador SX St Maarten (Dutch) SY Syria -SZ Swaziland +SZ Eswatini (Swaziland) TC Turks & Caicos Is TD Chad TF French Southern & Antarctic Lands diff --git a/src/make/data/tzdata/leapseconds b/src/make/data/tzdata/leapseconds index 8b539e6ef4b..2d05e87c637 100644 --- a/src/make/data/tzdata/leapseconds +++ b/src/make/data/tzdata/leapseconds @@ -42,9 +42,12 @@ # See: Levine J. Coordinated Universal Time and the leap second. # URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995 # . + # There were no leap seconds before 1972, because the official mechanism # accounting for the discrepancy between atomic time and the earth's rotation -# did not exist. +# did not exist. The first ("1 Jan 1972") data line in leap-seconds.list +# does not denote a leap second; it denotes the start of the current definition +# of UTC. # The correction (+ or -) is made at the given time, so lines # will typically look like: @@ -83,7 +86,7 @@ Leap 2016 Dec 31 23:59:60 + S # POSIX timestamps for the data in this file: #updated 1467936000 -#expires 1561680000 +#expires 1577491200 -# Updated through IERS Bulletin C56 -# File expires on: 28 June 2019 +# Updated through IERS Bulletin C57 +# File expires on: 28 December 2019 diff --git a/src/make/data/tzdata/northamerica b/src/make/data/tzdata/northamerica index 297a10a3849..718f4e6e31f 100644 --- a/src/make/data/tzdata/northamerica +++ b/src/make/data/tzdata/northamerica @@ -116,10 +116,33 @@ # was the first nationwide legal time standard, and apparently # time was just called "Standard Time" or "Daylight Saving Time". -# From Arthur David Olson: -# US Daylight Saving Time ended on the last Sunday of *October* in 1974. -# See, for example, the front page of the Saturday, 1974-10-26 -# and Sunday, 1974-10-27 editions of the Washington Post. +# From Paul Eggert (2019-06-04): +# Here is the legal basis for the US federal rules. +# * Public Law 65-106 (1918-03-19) implemented standard and daylight saving +# time for the first time across the US, springing forward on March's last +# Sunday and falling back on October's last Sunday. +# https://www.loc.gov/law/help/statutes-at-large/65th-congress/session-2/c65s2ch24.pdf +# * Public Law 66-40 (1919-08-20) repealed DST on October 1919's last Sunday. +# https://www.loc.gov/law/help/statutes-at-large/66th-congress/session-1/c66s1ch51.pdf +# * Public Law 77-403 (1942-01-20) started wartime DST on 1942-02-09. +# https://www.loc.gov/law/help/statutes-at-large/77th-congress/session-2/c77s2ch7.pdf +# * Public Law 79-187 (1945-09-25) ended wartime DST on 1945-09-30. +# https://www.loc.gov/law/help/statutes-at-large/79th-congress/session-1/c79s1ch388.pdf +# * Public Law 89-387 (1966-04-13) reinstituted a national standard for DST, +# from April's last Sunday to October's last Sunday, effective 1967. +# https://www.govinfo.gov/content/pkg/STATUTE-80/pdf/STATUTE-80-Pg107.pdf +# * Public Law 93-182 (1973-12-15) moved the 1974 spring-forward to 01-06. +# https://www.govinfo.gov/content/pkg/STATUTE-87/pdf/STATUTE-87-Pg707.pdf +# * Public Law 93-434 (1974-10-05) moved the 1975 spring-forward to +# February's last Sunday. +# https://www.govinfo.gov/content/pkg/STATUTE-88/pdf/STATUTE-88-Pg1209.pdf +# * Public Law 99-359 (1986-07-08) moved the spring-forward to April's first +# Sunday. +# https://www.govinfo.gov/content/pkg/STATUTE-100/pdf/STATUTE-100-Pg764.pdf +# * Public Law 109-58 (2005-08-08), effective 2007, moved the spring-forward +# to March's second Sunday and the fall-back to November's first Sunday. +# https://www.govinfo.gov/content/pkg/PLAW-109publ58/pdf/PLAW-109publ58.pdf +# All transitions are at 02:00 local time. # From Arthur David Olson: # Before the Uniform Time Act of 1966 took effect in 1967, observance of @@ -175,11 +198,11 @@ Rule US 1918 1919 - Mar lastSun 2:00 1:00 D Rule US 1918 1919 - Oct lastSun 2:00 0 S Rule US 1942 only - Feb 9 2:00 1:00 W # War Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule US 1945 only - Sep lastSun 2:00 0 S +Rule US 1945 only - Sep 30 2:00 0 S Rule US 1967 2006 - Oct lastSun 2:00 0 S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D Rule US 1974 only - Jan 6 2:00 1:00 D -Rule US 1975 only - Feb 23 2:00 1:00 D +Rule US 1975 only - Feb lastSun 2:00 1:00 D Rule US 1976 1986 - Apr lastSun 2:00 1:00 D Rule US 1987 2006 - Apr Sun>=1 2:00 1:00 D Rule US 2007 max - Mar Sun>=8 2:00 1:00 D @@ -196,7 +219,7 @@ Rule US 2007 max - Nov Sun>=1 2:00 0 S # increase the chances that they'll actually get compiled and to # avoid the need to duplicate the US rules in another file. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone EST -5:00 - EST Zone MST -7:00 - MST Zone HST -10:00 - HST @@ -353,7 +376,7 @@ Rule NYC 1920 only - Oct lastSun 2:00 0 S Rule NYC 1921 1966 - Apr lastSun 2:00 1:00 D Rule NYC 1921 1954 - Sep lastSun 2:00 0 S Rule NYC 1955 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:03:58 -5:00 US E%sT 1920 -5:00 NYC E%sT 1942 @@ -413,7 +436,7 @@ Rule Chicago 1921 only - Mar lastSun 2:00 1:00 D Rule Chicago 1922 1966 - Apr lastSun 2:00 1:00 D Rule Chicago 1922 1954 - Sep lastSun 2:00 0 S Rule Chicago 1955 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Chicago -5:50:36 - LMT 1883 Nov 18 12:09:24 -6:00 US C%sT 1920 -6:00 Chicago C%sT 1936 Mar 1 2:00 @@ -481,7 +504,7 @@ Rule Denver 1920 only - Oct lastSun 2:00 0 S Rule Denver 1921 only - May 22 2:00 0 S Rule Denver 1965 1966 - Apr lastSun 2:00 1:00 D Rule Denver 1965 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00:04 -7:00 US M%sT 1920 -7:00 Denver M%sT 1942 @@ -534,7 +557,7 @@ Rule CA 1949 only - Jan 1 2:00 0 S Rule CA 1950 1966 - Apr lastSun 1:00 1:00 D Rule CA 1950 1961 - Sep lastSun 2:00 0 S Rule CA 1962 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 -8:00 US P%sT 1946 -8:00 CA P%sT 1967 @@ -622,7 +645,27 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 # between AKST and AKDT from now on.... # https://www.krbd.org/2015/10/30/annette-island-times-they-are-a-changing/ -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# From Ryan Stanley (2018-11-06): +# The Metlakatla community in Alaska has decided not to change its +# clock back an hour starting on November 4th, 2018 (day before yesterday). +# They will be gmtoff=-28800 year-round. +# https://www.facebook.com/141055983004923/photos/pb.141055983004923.-2207520000.1541465673./569081370202380/ + +# From Paul Eggert (2018-12-16): +# In a 2018-12-11 special election, Metlakatla voted to go back to +# Alaska time (including daylight saving time) starting next year. +# https://www.krbd.org/2018/12/12/metlakatla-to-follow-alaska-standard-time-allow-liquor-sales/ +# +# From Ryan Stanley (2019-01-11): +# The community will be changing back on the 20th of this month... +# From Tim Parenti (2019-01-11): +# Per an announcement on the Metlakatla community's official Facebook page, the +# "fall back" will be on Sunday 2019-01-20 at 02:00: +# https://www.facebook.com/141055983004923/photos/607150969728753/ +# So they won't be waiting for Alaska to join them on 2019-03-10, but will +# rather change their clocks twice in seven weeks. + +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Juneau 15:02:19 - LMT 1867 Oct 19 15:33:32 -8:57:41 - LMT 1900 Aug 20 12:00 -8:00 - PST 1942 @@ -648,6 +691,8 @@ Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 19 15:44:55 -8:00 - PST 1969 -8:00 US P%sT 1983 Oct 30 2:00 -8:00 - PST 2015 Nov 1 2:00 + -9:00 US AK%sT 2018 Nov 4 2:00 + -8:00 - PST 2019 Jan 20 2:00 -9:00 US AK%sT Zone America/Yakutat 14:41:05 - LMT 1867 Oct 19 15:12:18 -9:18:55 - LMT 1900 Aug 20 12:00 @@ -740,7 +785,7 @@ Zone America/Adak 12:13:22 - LMT 1867 Oct 19 12:44:35 # Note that 1933-05-21 was a Sunday. # We're left to guess the time of day when Act 163 was approved; guess noon. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Pacific/Honolulu -10:31:26 - LMT 1896 Jan 13 12:00 -10:30 - HST 1933 Apr 30 2:00 -10:30 1:00 HDT 1933 May 21 12:00 @@ -770,7 +815,7 @@ Zone Pacific/Honolulu -10:31:26 - LMT 1896 Jan 13 12:00 # Shanks says the 1944 experiment came to an end on 1944-03-17. # Go with the Arizona State Library instead. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Phoenix -7:28:18 - LMT 1883 Nov 18 11:31:42 -7:00 US M%sT 1944 Jan 1 0:01 -7:00 - MST 1944 Apr 1 0:01 @@ -796,7 +841,7 @@ Zone America/Phoenix -7:28:18 - LMT 1883 Nov 18 11:31:42 # quarter of Idaho county) and eastern Oregon (most of Malheur County) # switched four weeks late in 1974. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:15:11 -8:00 US P%sT 1923 May 13 2:00 -7:00 US M%sT 1974 @@ -808,6 +853,22 @@ Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:15:11 # For a map of Indiana's time zone regions, see: # https://en.wikipedia.org/wiki/Time_in_Indiana # +# From Paul Eggert (2018-11-30): +# A brief but entertaining history of time in Indiana describes a 1949 debate +# in the Indiana House where city legislators (who favored "fast time") +# tussled with farm legislators (who didn't) over a bill to outlaw DST: +# "Lacking enough votes, the city faction tries to filibuster until time runs +# out on the session at midnight, but rural champion Rep. Herbert Copeland, +# R-Madison, leans over the gallery railing and forces the official clock +# back to 9 p.m., breaking it in the process. The clock sticks on 9 as the +# debate rages on into the night. The filibuster finally dies out and the +# bill passes, while outside the chamber, clocks read 3:30 a.m. In the end, +# it doesn't matter which side won. The law has no enforcement powers and +# is simply ignored by fast-time communities." +# How Indiana went from 'God's time' to split zones and daylight-saving. +# Indianapolis Star. 2018-11-27 14:58 -05. +# https://www.indystar.com/story/news/politics/2018/11/27/indianapolis-indiana-time-zone-history-central-eastern-daylight-savings-time/2126300002/ +# # From Paul Eggert (2007-08-17): # Since 1970, most of Indiana has been like America/Indiana/Indianapolis, # with the following exceptions: @@ -852,7 +913,7 @@ Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:15:11 Rule Indianapolis 1941 only - Jun 22 2:00 1:00 D Rule Indianapolis 1941 1954 - Sep lastSun 2:00 0 S Rule Indianapolis 1946 1954 - Apr lastSun 2:00 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Indianapolis -5:44:38 - LMT 1883 Nov 18 12:15:22 -6:00 US C%sT 1920 -6:00 Indianapolis C%sT 1942 @@ -872,7 +933,7 @@ Rule Marengo 1951 only - Apr lastSun 2:00 1:00 D Rule Marengo 1951 only - Sep lastSun 2:00 0 S Rule Marengo 1954 1960 - Apr lastSun 2:00 1:00 D Rule Marengo 1954 1960 - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Marengo -5:45:23 - LMT 1883 Nov 18 12:14:37 -6:00 US C%sT 1951 -6:00 Marengo C%sT 1961 Apr 30 2:00 @@ -896,7 +957,7 @@ Rule Vincennes 1956 1963 - Apr lastSun 2:00 1:00 D Rule Vincennes 1960 only - Oct lastSun 2:00 0 S Rule Vincennes 1961 only - Sep lastSun 2:00 0 S Rule Vincennes 1962 1963 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Vincennes -5:50:07 - LMT 1883 Nov 18 12:09:53 -6:00 US C%sT 1946 -6:00 Vincennes C%sT 1964 Apr 26 2:00 @@ -917,7 +978,7 @@ Rule Perry 1956 1963 - Apr lastSun 2:00 1:00 D Rule Perry 1960 only - Oct lastSun 2:00 0 S Rule Perry 1961 only - Sep lastSun 2:00 0 S Rule Perry 1962 1963 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Tell_City -5:47:03 - LMT 1883 Nov 18 12:12:57 -6:00 US C%sT 1946 -6:00 Perry C%sT 1964 Apr 26 2:00 @@ -933,7 +994,7 @@ Rule Pike 1955 only - May 1 0:00 1:00 D Rule Pike 1955 1960 - Sep lastSun 2:00 0 S Rule Pike 1956 1964 - Apr lastSun 2:00 1:00 D Rule Pike 1961 1964 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Petersburg -5:49:07 - LMT 1883 Nov 18 12:10:53 -6:00 US C%sT 1955 -6:00 Pike C%sT 1965 Apr 25 2:00 @@ -955,7 +1016,7 @@ Rule Starke 1947 1954 - Sep lastSun 2:00 0 S Rule Starke 1955 1956 - Oct lastSun 2:00 0 S Rule Starke 1957 1958 - Sep lastSun 2:00 0 S Rule Starke 1959 1961 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Knox -5:46:30 - LMT 1883 Nov 18 12:13:30 -6:00 US C%sT 1947 -6:00 Starke C%sT 1962 Apr 29 2:00 @@ -971,7 +1032,7 @@ Rule Pulaski 1946 1960 - Apr lastSun 2:00 1:00 D Rule Pulaski 1946 1954 - Sep lastSun 2:00 0 S Rule Pulaski 1955 1956 - Oct lastSun 2:00 0 S Rule Pulaski 1957 1960 - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Winamac -5:46:25 - LMT 1883 Nov 18 12:13:35 -6:00 US C%sT 1946 -6:00 Pulaski C%sT 1961 Apr 30 2:00 @@ -982,7 +1043,7 @@ Zone America/Indiana/Winamac -5:46:25 - LMT 1883 Nov 18 12:13:35 -5:00 US E%sT # # Switzerland County, Indiana, did not observe DST from 1973 through 2005. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Indiana/Vevay -5:40:16 - LMT 1883 Nov 18 12:19:44 -6:00 US C%sT 1954 Apr 25 2:00 -5:00 - EST 1969 @@ -1007,7 +1068,7 @@ Rule Louisville 1941 only - Sep lastSun 2:00 0 S Rule Louisville 1946 only - Jun 2 2:00 0 S Rule Louisville 1950 1955 - Sep lastSun 2:00 0 S Rule Louisville 1956 1960 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Kentucky/Louisville -5:43:02 - LMT 1883 Nov 18 12:16:58 -6:00 US C%sT 1921 -6:00 Louisville C%sT 1942 @@ -1113,7 +1174,7 @@ Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:20:36 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule Detroit 1948 only - Apr lastSun 2:00 1:00 D Rule Detroit 1948 only - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Detroit -5:32:11 - LMT 1905 -6:00 - CST 1915 May 15 2:00 -5:00 - EST 1942 @@ -1130,7 +1191,7 @@ Rule Menominee 1946 only - Apr lastSun 2:00 1:00 D Rule Menominee 1946 only - Sep lastSun 2:00 0 S Rule Menominee 1966 only - Apr lastSun 2:00 1:00 D Rule Menominee 1966 only - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 -6:00 US C%sT 1946 -6:00 Menominee C%sT 1969 Apr 27 2:00 @@ -1364,7 +1425,7 @@ Rule StJohns 2007 2011 - Mar Sun>=8 0:01 1:00 D Rule StJohns 2007 2010 - Nov Sun>=1 0:01 0 S # # St John's has an apostrophe, but Posix file names can't have apostrophes. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/St_Johns -3:30:52 - LMT 1884 -3:30:52 StJohns N%sT 1918 -3:30:52 Canada N%sT 1919 @@ -1377,7 +1438,7 @@ Zone America/St_Johns -3:30:52 - LMT 1884 # most of east Labrador # The name 'Happy Valley-Goose Bay' is too long; use 'Goose Bay'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Goose_Bay -4:01:40 - LMT 1884 # Happy Valley-Goose Bay -3:30:52 - NST 1918 -3:30:52 Canada N%sT 1919 @@ -1451,7 +1512,7 @@ Rule Halifax 1956 1959 - Apr lastSun 2:00 1:00 D Rule Halifax 1956 1959 - Sep lastSun 2:00 0 S Rule Halifax 1962 1973 - Apr lastSun 2:00 1:00 D Rule Halifax 1962 1973 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Halifax -4:14:24 - LMT 1902 Jun 15 -4:00 Halifax A%sT 1918 -4:00 Canada A%sT 1919 @@ -1489,7 +1550,7 @@ Rule Moncton 1946 1956 - Sep lastSun 2:00 0 S Rule Moncton 1957 1972 - Oct lastSun 2:00 0 S Rule Moncton 1993 2006 - Apr Sun>=1 0:01 1:00 D Rule Moncton 1993 2006 - Oct lastSun 0:01 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Moncton -4:19:08 - LMT 1883 Dec 9 -5:00 - EST 1902 Jun 15 -4:00 Canada A%sT 1933 @@ -1518,7 +1579,7 @@ Zone America/Moncton -4:19:08 - LMT 1883 Dec 9 # For lack of better info, guess this practice began around 1970, contra to # Shanks & Pottenger who have this region observing AST/ADT. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Blanc-Sablon -3:48:28 - LMT 1884 -4:00 Canada A%sT 1970 -4:00 - AST @@ -1686,19 +1747,10 @@ Rule Toronto 1922 1923 - May Sun>=8 2:00 1:00 D # was meant. Rule Toronto 1922 1926 - Sep Sun>=15 2:00 0 S Rule Toronto 1924 1927 - May Sun>=1 2:00 1:00 D -# The 1927-to-1939 rules can be expressed more simply as -# Rule Toronto 1927 1937 - Sep Sun>=25 2:00 0 S -# Rule Toronto 1928 1937 - Apr Sun>=25 2:00 1:00 D -# Rule Toronto 1938 1940 - Apr lastSun 2:00 1:00 D -# Rule Toronto 1938 1939 - Sep lastSun 2:00 0 S -# The rules below avoid use of Sun>=25 -# (which pre-2004 versions of zic cannot handle). -Rule Toronto 1927 1932 - Sep lastSun 2:00 0 S -Rule Toronto 1928 1931 - Apr lastSun 2:00 1:00 D -Rule Toronto 1932 only - May 1 2:00 1:00 D -Rule Toronto 1933 1940 - Apr lastSun 2:00 1:00 D -Rule Toronto 1933 only - Oct 1 2:00 0 S -Rule Toronto 1934 1939 - Sep lastSun 2:00 0 S +Rule Toronto 1927 1937 - Sep Sun>=25 2:00 0 S +Rule Toronto 1928 1937 - Apr Sun>=25 2:00 1:00 D +Rule Toronto 1938 1940 - Apr lastSun 2:00 1:00 D +Rule Toronto 1938 1939 - Sep lastSun 2:00 0 S Rule Toronto 1945 1946 - Sep lastSun 2:00 0 S Rule Toronto 1946 only - Apr lastSun 2:00 1:00 D Rule Toronto 1947 1949 - Apr lastSun 0:00 1:00 D @@ -1731,7 +1783,7 @@ Rule Toronto 1957 1973 - Oct lastSun 2:00 0 S # War,... [t]he cities agreed to implement DST during the summer # months for the remainder of the war years. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Toronto -5:17:32 - LMT 1895 -5:00 Canada E%sT 1919 -5:00 Toronto E%sT 1942 Feb 9 2:00s @@ -1806,7 +1858,7 @@ Rule Winn 1963 only - Sep 22 2:00 0 S Rule Winn 1966 1986 - Apr lastSun 2:00s 1:00 D Rule Winn 1966 2005 - Oct lastSun 2:00s 0 S Rule Winn 1987 2005 - Apr Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Winnipeg -6:28:36 - LMT 1887 Jul 16 -6:00 Winn C%sT 2006 -6:00 Canada C%sT @@ -1828,6 +1880,13 @@ Zone America/Winnipeg -6:28:36 - LMT 1887 Jul 16 # Willett (1914-03) notes that DST "has been in operation ... in the # City of Moose Jaw, Saskatchewan, for one year." +# From Paul Eggert (2019-04-26): +# Chris Pearce's book "The Great Daylight Saving Time Controversy" (2017) +# says that Regina observed DST in 1914-1917. No dates and times, +# unfortunately. It also says that in 1914 Saskatoon observed DST +# from 1 June to 6 July, and that DST was also tried out in Davidson, +# Melfort, and Prince Albert. + # From Paul Eggert (2006-03-22): # Shanks & Pottenger say that since 1970 this region has mostly been as Regina. # Some western towns (e.g. Swift Current) switched from MST/MDT to CST in 1972. @@ -1890,7 +1949,7 @@ Rule Swift 1957 only - Oct lastSun 2:00 0 S Rule Swift 1959 1961 - Apr lastSun 2:00 1:00 D Rule Swift 1959 only - Oct lastSun 2:00 0 S Rule Swift 1960 1961 - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Regina -6:58:36 - LMT 1905 Sep -7:00 Regina M%sT 1960 Apr lastSun 2:00 -6:00 - CST @@ -1921,7 +1980,7 @@ Rule Edm 1969 only - Apr lastSun 2:00 1:00 D Rule Edm 1969 only - Oct lastSun 2:00 0 S Rule Edm 1972 1986 - Apr lastSun 2:00 1:00 D Rule Edm 1972 2006 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Edmonton -7:33:52 - LMT 1906 Sep -7:00 Edm M%sT 1987 -7:00 Canada M%sT @@ -2014,7 +2073,7 @@ Rule Vanc 1946 1986 - Apr lastSun 2:00 1:00 D Rule Vanc 1946 only - Oct 13 2:00 0 S Rule Vanc 1947 1961 - Sep lastSun 2:00 0 S Rule Vanc 1962 2006 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Vancouver -8:12:28 - LMT 1884 -8:00 Vanc P%sT 1987 -8:00 Canada P%sT @@ -2085,7 +2144,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # varying the manner of reckoning standard time. # # * Yukon Territory Commissioner's Order 1966-20 Interpretation Ordinance -# http://? - no online source found +# [no online source found] # # * Standard Time and Time Zones in Canada; Thomson, Malcolm M.; JRASC, # Vol. 64, pp.129-162; June 1970; SAO/NASA Astrophysics Data System (ADS) @@ -2118,7 +2177,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # to say eight hours behind Greenwich Time. # # * O.I.C. 1980/02 INTERPRETATION ACT -# http://? - no online source found +# [no online source found] # # * Yukon Daylight Saving Time, YOIC 1987/56 # https://www.canlii.org/en/yk/laws/regu/yoic-1987-56/latest/yoic-1987-56.html @@ -2334,7 +2393,7 @@ Rule NT_YK 1965 only - Oct lastSun 2:00 0 S Rule NT_YK 1980 1986 - Apr lastSun 2:00 1:00 D Rule NT_YK 1980 2006 - Oct lastSun 2:00 0 S Rule NT_YK 1987 2006 - Apr Sun>=1 2:00 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # aka Panniqtuuq Zone America/Pangnirtung 0 - -00 1921 # trading post est. -4:00 NT_YK A%sT 1995 Apr Sun>=1 2:00 @@ -2481,7 +2540,7 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # From Paul Eggert (2001-03-03): # -# http://www.latimes.com/news/nation/20010303/t000018766.html +# https://www.latimes.com/archives/la-xpm-2001-mar-03-mn-32561-story.html # James F. Smith writes in today's LA Times # * Sonora will continue to observe standard time. # * Last week Mexico City's mayor Andrés Manuel López Obrador decreed that @@ -2608,7 +2667,7 @@ Rule Mexico 2001 only - May Sun>=1 2:00 1:00 D Rule Mexico 2001 only - Sep lastSun 2:00 0 S Rule Mexico 2002 max - Apr Sun>=1 2:00 1:00 D Rule Mexico 2002 max - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # Quintana Roo; represented by Cancún Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56 -6:00 - CST 1981 Dec 23 @@ -2801,7 +2860,7 @@ Zone America/Tijuana -7:48:04 - LMT 1922 Jan 1 0:11:56 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Bahamas 1964 1975 - Oct lastSun 2:00 0 S Rule Bahamas 1964 1975 - Apr lastSun 2:00 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Nassau -5:09:30 - LMT 1912 Mar 2 -5:00 Bahamas E%sT 1976 -5:00 US E%sT @@ -2816,7 +2875,7 @@ Rule Barb 1977 1978 - Oct Sun>=1 2:00 0 S Rule Barb 1978 1980 - Apr Sun>=15 2:00 1:00 D Rule Barb 1979 only - Sep 30 2:00 0 S Rule Barb 1980 only - Sep 25 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Barbados -3:58:29 - LMT 1924 # Bridgetown -3:58:29 - BMT 1932 # Bridgetown Mean Time -4:00 Barb A%sT @@ -2830,7 +2889,7 @@ Rule Belize 1973 only - Dec 5 0:00 1:00 CDT Rule Belize 1974 only - Feb 9 0:00 0 CST Rule Belize 1982 only - Dec 18 0:00 1:00 CDT Rule Belize 1983 only - Feb 12 0:00 0 CST -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Belize -5:52:48 - LMT 1912 Apr -6:00 Belize %s @@ -2847,7 +2906,7 @@ Zone America/Belize -5:52:48 - LMT 1912 Apr # Friday, the same thing will happen in Bermuda. # http://www.theroyalgazette.com/apps/pbcs.dll/article?AID=/20060529/NEWS/105290135 -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Atlantic/Bermuda -4:19:18 - LMT 1930 Jan 1 2:00 # Hamilton -4:00 - AST 1974 Apr 28 2:00 -4:00 Canada A%sT 1976 @@ -2869,7 +2928,7 @@ Rule CR 1991 1992 - Jan Sat>=15 0:00 1:00 D Rule CR 1991 only - Jul 1 0:00 0 S Rule CR 1992 only - Mar 15 0:00 0 S # There are too many San Josés elsewhere, so we'll use 'Costa Rica'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Costa_Rica -5:36:13 - LMT 1890 # San José -5:36:13 - SJMT 1921 Jan 15 # San José Mean Time -6:00 CR C%sT @@ -3075,7 +3134,7 @@ Rule Cuba 2012 only - Apr 1 0:00s 1:00 D Rule Cuba 2012 max - Nov Sun>=1 0:00s 0 S Rule Cuba 2013 max - Mar Sun>=8 0:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Havana -5:29:28 - LMT 1890 -5:29:36 - HMT 1925 Jul 19 12:00 # Havana MT -5:00 Cuba C%sT @@ -3110,7 +3169,7 @@ Rule DR 1969 1973 - Oct lastSun 0:00 0:30 -0430 Rule DR 1970 only - Feb 21 0:00 0 EST Rule DR 1971 only - Jan 20 0:00 0 EST Rule DR 1972 1974 - Jan 21 0:00 0 EST -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Santo_Domingo -4:39:36 - LMT 1890 -4:40 - SDMT 1933 Apr 1 12:00 # S. Dom. MT -5:00 DR %s 1974 Oct 27 @@ -3125,7 +3184,7 @@ Rule Salv 1987 1988 - May Sun>=1 0:00 1:00 D Rule Salv 1987 1988 - Sep lastSun 0:00 0 S # There are too many San Salvadors elsewhere, so use America/El_Salvador # instead of America/San_Salvador. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/El_Salvador -5:56:48 - LMT 1921 # San Salvador -6:00 Salv C%sT @@ -3158,7 +3217,7 @@ Rule Guat 1991 only - Mar 23 0:00 1:00 D Rule Guat 1991 only - Sep 7 0:00 0 S Rule Guat 2006 only - Apr 30 0:00 1:00 D Rule Guat 2006 only - Oct 1 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Guatemala -6:02:04 - LMT 1918 Oct 5 -6:00 Guat C%sT @@ -3244,7 +3303,7 @@ Rule Haiti 2012 2015 - Mar Sun>=8 2:00 1:00 D Rule Haiti 2012 2015 - Nov Sun>=1 2:00 0 S Rule Haiti 2017 max - Mar Sun>=8 2:00 1:00 D Rule Haiti 2017 max - Nov Sun>=1 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Port-au-Prince -4:49:20 - LMT 1890 -4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT -5:00 Haiti E%sT @@ -3283,7 +3342,7 @@ Rule Hond 1987 1988 - May Sun>=1 0:00 1:00 D Rule Hond 1987 1988 - Sep lastSun 0:00 0 S Rule Hond 2006 only - May Sun>=1 0:00 1:00 D Rule Hond 2006 only - Aug Mon>=1 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Tegucigalpa -5:48:52 - LMT 1921 Apr -6:00 Hond C%sT # @@ -3304,7 +3363,7 @@ Zone America/Tegucigalpa -5:48:52 - LMT 1921 Apr # Neita L. The politician in all of us. Jamaica Observer 2014-09-20 # http://www.jamaicaobserver.com/columns/The-politician-in-all-of-us_17573647 # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Jamaica -5:07:10 - LMT 1890 # Kingston -5:07:10 - KMT 1912 Feb # Kingston Mean Time -5:00 - EST 1974 @@ -3312,7 +3371,7 @@ Zone America/Jamaica -5:07:10 - LMT 1890 # Kingston -5:00 - EST # Martinique -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Martinique -4:04:20 - LMT 1890 # Fort-de-France -4:04:20 - FFMT 1911 May # Fort-de-France MT -4:00 - AST 1980 Apr 6 @@ -3376,7 +3435,7 @@ Rule Nic 2005 only - Apr 10 0:00 1:00 D Rule Nic 2005 only - Oct Sun>=1 0:00 0 S Rule Nic 2006 only - Apr 30 2:00 1:00 D Rule Nic 2006 only - Oct Sun>=1 1:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Managua -5:45:08 - LMT 1890 -5:45:12 - MMT 1934 Jun 23 # Managua Mean Time? -6:00 - CST 1973 May @@ -3388,7 +3447,7 @@ Zone America/Managua -5:45:08 - LMT 1890 -6:00 Nic C%sT # Panama -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Panama -5:18:08 - LMT 1890 -5:19:36 - CMT 1908 Apr 22 # Colón Mean Time -5:00 - EST @@ -3396,7 +3455,7 @@ Link America/Panama America/Cayman # Puerto Rico # There are too many San Juans elsewhere, so we'll use 'Puerto_Rico'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Puerto_Rico -4:24:25 - LMT 1899 Mar 28 12:00 # San Juan -4:00 - AST 1942 May 3 -4:00 US A%sT 1946 @@ -3408,7 +3467,7 @@ Zone America/Puerto_Rico -4:24:25 - LMT 1899 Mar 28 12:00 # San Juan # St Pierre and Miquelon # There are too many St Pierres elsewhere, so we'll use 'Miquelon'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre -4:00 - AST 1980 May -3:00 - -03 1987 @@ -3454,7 +3513,7 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre # by March 2018 for TCI. Magnetic Media. 2017-08-25. # http://magneticmediatv.com/2017/08/time-change-back-by-march-2018-for-tci/ # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Grand_Turk -4:44:32 - LMT 1890 -5:07:10 - KMT 1912 Feb # Kingston Mean Time -5:00 - EST 1979 diff --git a/src/make/data/tzdata/pacificnew b/src/make/data/tzdata/pacificnew index 020b599bf00..f19a876372c 100644 --- a/src/make/data/tzdata/pacificnew +++ b/src/make/data/tzdata/pacificnew @@ -44,7 +44,7 @@ ## Rule Twilite XXXX max uspres Nov Sun>=7 2:00 0 S ## Rule Twilite XXXX max nonpres Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] +# Zone NAME STDOFF RULES/SAVE FORMAT [UNTIL] ## Zone America/Los_Angeles-PET -8:00 US P%sT XXXX ## -8:00 Twilite P%sT diff --git a/src/make/data/tzdata/southamerica b/src/make/data/tzdata/southamerica index 3f016479a75..6452c6c2bea 100644 --- a/src/make/data/tzdata/southamerica +++ b/src/make/data/tzdata/southamerica @@ -419,7 +419,7 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 - # plus is that this silences a zic complaint that there's no POSIX TZ # setting for timestamps past 2038. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # # Buenos Aires (BA), Capital Federal (CF), Zone America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 Oct 31 @@ -600,7 +600,7 @@ Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31 Link America/Curacao America/Aruba # Bolivia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/La_Paz -4:32:36 - LMT 1890 -4:32:36 - CMT 1931 Oct 15 # Calamarca MT -4:32:36 1:00 BST 1932 Mar 21 # Bolivia ST @@ -943,14 +943,13 @@ Rule Brazil 2012 only - Feb Sun>=22 0:00 0 - # removed Tocantins. Rule Brazil 2013 2014 - Feb Sun>=15 0:00 0 - Rule Brazil 2015 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2016 2022 - Feb Sun>=15 0:00 0 - +Rule Brazil 2016 2019 - Feb Sun>=15 0:00 0 - # From Steffen Thorsen (2017-12-18): # According to many media sources, next year's DST start in Brazil will move to -# the first Sunday of November, and it will stay like that for the years after. +# the first Sunday of November # ... https://www.timeanddate.com/news/time/brazil-delays-dst-2018.html # From Steffen Thorsen (2017-12-20): # http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2017/decreto/D9242.htm -# # From Fábio Gomes (2018-10-04): # The Brazilian president just announced a new change on this year DST. # It was scheduled to start on November 4th and it was changed to November 18th. @@ -958,22 +957,21 @@ Rule Brazil 2016 2022 - Feb Sun>=15 0:00 0 - # The Brazilian government just announced that the change in DST was # canceled.... Maybe the president Michel Temer also woke up one hour # earlier today. :) -Rule Brazil 2018 max - Nov Sun>=1 0:00 1:00 - -Rule Brazil 2023 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2024 2025 - Feb Sun>=15 0:00 0 - -Rule Brazil 2026 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2027 2033 - Feb Sun>=15 0:00 0 - -Rule Brazil 2034 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2035 2036 - Feb Sun>=15 0:00 0 - -Rule Brazil 2037 only - Feb Sun>=22 0:00 0 - -# From Arthur David Olson (2008-09-29): -# The next is wrong in some years but is better than nothing. -Rule Brazil 2038 max - Feb Sun>=15 0:00 0 - - -# The latest ruleset listed above says that the following states observe DST: +Rule Brazil 2018 only - Nov Sun>=1 0:00 1:00 - +# The last ruleset listed above says that the following states observed DST: # DF, ES, GO, MG, MS, MT, PR, RJ, RS, SC, SP. +# +# From Steffen Thorsen (2019-04-05): +# According to multiple sources the Brazilian president wants to get rid of DST. +# https://gmconline.com.br/noticias/politica/bolsonaro-horario-de-verao-deve-acabar-este-ano +# https://g1.globo.com/economia/noticia/2019/04/05/governo-anuncia-fim-do-horario-de-verao.ghtml +# From Marcus Diniz (2019-04-25): +# Brazil no longer has DST changes - decree signed today +# https://g1.globo.com/politica/noticia/2019/04/25/bolsonaro-assina-decreto-que-acaba-com-o-horario-de-verao.ghtml +# From Daniel Soares de Oliveira (2019-04-26): +# http://www.planalto.gov.br/ccivil_03/_Ato2019-2022/2019/Decreto/D9772.htm -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] # # Fernando de Noronha (administratively part of PE) Zone America/Noronha -2:09:40 - LMT 1914 @@ -1281,6 +1279,8 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # https://twitter.com/MinEnergia/status/1029009354001973248 # "We will keep the new time policy unchanged for at least the next 4 years." # So we extend the new rules on Saturdays at 24:00 mainland time indefinitely. +# From Juan Correa (2019-02-04): +# http://www.diariooficial.interior.gob.cl/publicaciones/2018/11/23/42212/01/1498738.pdf # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Chile 1927 1931 - Sep 1 0:00 1:00 - @@ -1321,7 +1321,7 @@ Rule Chile 2019 max - Apr Sun>=2 3:00u 0 - Rule Chile 2019 max - Sep Sun>=2 4:00u 1:00 - # IATA SSIM anomalies: (1992-02) says 1992-03-14; # (1996-09) says 1998-03-08. Ignore these. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Santiago -4:42:46 - LMT 1890 -4:42:46 - SMT 1910 Jan 10 # Santiago Mean Time -5:00 - -05 1916 Jul 1 @@ -1370,7 +1370,7 @@ Zone Pacific/Easter -7:17:28 - LMT 1890 # Palmer has followed Chile. Prior to that, before the Falklands War, # Palmer used to be supplied from Argentina. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Antarctica/Palmer 0 - -00 1965 -4:00 Arg -04/-03 1969 Oct 5 -3:00 Arg -03/-02 1982 May @@ -1385,7 +1385,7 @@ Zone Antarctica/Palmer 0 - -00 1965 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule CO 1992 only - May 3 0:00 1:00 - Rule CO 1993 only - Apr 4 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Bogota -4:56:16 - LMT 1884 Mar 13 -4:56:16 - BMT 1914 Nov 23 # Bogotá Mean Time -5:00 CO -05/-04 @@ -1410,7 +1410,7 @@ Zone America/Bogota -4:56:16 - LMT 1884 Mar 13 # Netherlands as Kingdom Islands. This won't affect their time zones # though, as far as we know. # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Curacao -4:35:47 - LMT 1912 Feb 12 # Willemstad -4:30 - -0430 1965 -4:00 - AST @@ -1446,7 +1446,7 @@ Link America/Curacao America/Kralendijk # Caribbean Netherlands Rule Ecuador 1992 only - Nov 28 0:00 1:00 - Rule Ecuador 1993 only - Feb 5 0:00 0 - # -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Guayaquil -5:19:20 - LMT 1890 -5:14:00 - QMT 1931 # Quito Mean Time -5:00 Ecuador -05/-04 @@ -1549,7 +1549,7 @@ Rule Falk 1985 2000 - Sep Sun>=9 0:00 1:00 - Rule Falk 1986 2000 - Apr Sun>=16 0:00 0 - Rule Falk 2001 2010 - Apr Sun>=15 2:00 0 - Rule Falk 2001 2010 - Sep Sun>=1 2:00 1:00 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Atlantic/Stanley -3:51:24 - LMT 1890 -3:51:24 - SMT 1912 Mar 12 # Stanley Mean Time -4:00 Falk -04/-03 1983 May @@ -1558,13 +1558,13 @@ Zone Atlantic/Stanley -3:51:24 - LMT 1890 -3:00 - -03 # French Guiana -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Cayenne -3:29:20 - LMT 1911 Jul -4:00 - -04 1967 Oct -3:00 - -03 # Guyana -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Guyana -3:52:40 - LMT 1915 Mar # Georgetown -3:45 - -0345 1975 Jul 31 -3:00 - -03 1991 @@ -1658,7 +1658,7 @@ Rule Para 2010 2012 - Apr Sun>=8 0:00 0 - # http://www.presidencia.gov.py/archivos/documentos/DECRETO1264_ey9r8zai.pdf Rule Para 2013 max - Mar Sun>=22 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Asuncion -3:50:40 - LMT 1890 -3:50:40 - AMT 1931 Oct 10 # Asunción Mean Time -4:00 - -04 1972 Oct @@ -1687,13 +1687,13 @@ Rule Peru 1990 only - Apr 1 0:00 0 - # IATA is ambiguous for 1993/1995; go with Shanks & Pottenger. Rule Peru 1994 only - Jan 1 0:00 1:00 - Rule Peru 1994 only - Apr 1 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Lima -5:08:12 - LMT 1890 -5:08:36 - LMT 1908 Jul 28 # Lima Mean Time? -5:00 Peru -05/-04 # South Georgia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Atlantic/South_Georgia -2:26:08 - LMT 1890 # Grytviken -2:00 - -02 @@ -1701,7 +1701,7 @@ Zone Atlantic/South_Georgia -2:26:08 - LMT 1890 # Grytviken # uninhabited; scientific personnel have wintered # Suriname -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Paramaribo -3:40:40 - LMT 1911 -3:40:52 - PMT 1935 # Paramaribo Mean Time -3:40:36 - PMT 1945 Oct # The capital moved? @@ -1709,7 +1709,7 @@ Zone America/Paramaribo -3:40:40 - LMT 1911 -3:00 - -03 # Trinidad and Tobago -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Port_of_Spain -4:06:04 - LMT 1912 Mar 2 -4:00 - AST @@ -1980,7 +1980,7 @@ Zone America/Montevideo -3:44:51 - LMT 1908 Jun 10 # ... published in the official Gazette [2016-04-18], here: # http://historico.tsj.gob.ve/gaceta_ext/abril/1842016/E-1842016-4551.pdf -# Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Zone NAME STDOFF RULES FORMAT [UNTIL] Zone America/Caracas -4:27:44 - LMT 1890 -4:27:40 - CMT 1912 Feb 12 # Caracas Mean Time? -4:30 - -0430 1965 Jan 1 0:00 diff --git a/src/make/data/tzdata/systemv b/src/make/data/tzdata/systemv index 63a48e8c3e0..9525ec47171 100644 --- a/src/make/data/tzdata/systemv +++ b/src/make/data/tzdata/systemv @@ -46,7 +46,7 @@ Rule SystemV 1975 only - Oct lastSun 2:00 0 S Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D Rule SystemV 1976 max - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] +# Zone NAME STDOFF RULES/SAVE FORMAT [UNTIL] ## Zone SystemV/AST4ADT -4:00 SystemV A%sT ## Zone SystemV/EST5EDT -5:00 SystemV E%sT ## Zone SystemV/CST6CDT -6:00 SystemV C%sT diff --git a/src/make/data/tzdata/zone.tab b/src/make/data/tzdata/zone.tab index 2a985868d28..8020ca04251 100644 --- a/src/make/data/tzdata/zone.tab +++ b/src/make/data/tzdata/zone.tab @@ -262,6 +262,7 @@ KW +2920+04759 Asia/Kuwait KY +1918-08123 America/Cayman KZ +4315+07657 Asia/Almaty Kazakhstan (most areas) KZ +4448+06528 Asia/Qyzylorda Qyzylorda/Kyzylorda/Kzyl-Orda +KZ +5312+06337 Asia/Qostanay Qostanay/Kostanay/Kustanay KZ +5017+05710 Asia/Aqtobe Aqtobe/Aktobe KZ +4431+05016 Asia/Aqtau Mangghystau/Mankistau KZ +4707+05156 Asia/Atyrau Atyrau/Atirau/Gur'yev @@ -354,10 +355,13 @@ RO +4426+02606 Europe/Bucharest RS +4450+02030 Europe/Belgrade RU +5443+02030 Europe/Kaliningrad MSK-01 - Kaliningrad RU +554521+0373704 Europe/Moscow MSK+00 - Moscow area -RU +4457+03406 Europe/Simferopol MSK+00 - Crimea -RU +4844+04425 Europe/Volgograd MSK+00 - Volgograd +# The obsolescent zone.tab format cannot represent Europe/Simferopol well. +# Put it in RU section and list as UA. See "territorial claims" above. +# Programs should use zone1970.tab instead; see above. +UA +4457+03406 Europe/Simferopol MSK+00 - Crimea RU +5836+04939 Europe/Kirov MSK+00 - Kirov RU +4621+04803 Europe/Astrakhan MSK+01 - Astrakhan +RU +4844+04425 Europe/Volgograd MSK+01 - Volgograd RU +5134+04602 Europe/Saratov MSK+01 - Saratov RU +5420+04824 Europe/Ulyanovsk MSK+01 - Ulyanovsk RU +5312+05009 Europe/Samara MSK+01 - Samara, Udmurtia diff --git a/src/make/hotspot/lib/CompileGtest.gmk b/src/make/hotspot/lib/CompileGtest.gmk index e288482b115..c4c842925c5 100644 --- a/src/make/hotspot/lib/CompileGtest.gmk +++ b/src/make/hotspot/lib/CompileGtest.gmk @@ -55,6 +55,7 @@ endif # Disabling undef, switch, format-nonliteral and tautological-undefined-compare # warnings for clang because of test source. +# Solaris: Disable inlining (+d) to workaround Assertion: (../lnk/vardescr.h, line 109) $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \ NAME := jvm, \ TOOLCHAIN := TOOLCHAIN_LINK_CXX, \ @@ -71,13 +72,12 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \ -I$(GTEST_FRAMEWORK_SRC)/include \ $(addprefix -I,$(GTEST_TEST_SRC)), \ CFLAGS_windows := -EHsc, \ - CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4, \ + CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4 +d, \ CFLAGS_macosx := -DGTEST_OS_MAC=1, \ DISABLED_WARNINGS_gcc := undef, \ DISABLED_WARNINGS_clang := undef switch format-nonliteral \ tautological-undefined-compare $(BUILD_LIBJVM_DISABLED_WARNINGS_clang), \ DISABLED_WARNINGS_solstudio := identexpected, \ - DISABLED_WARNINGS_CXX_microsoft := 4996, \ LDFLAGS := $(JVM_LDFLAGS), \ LDFLAGS_solaris := -library=stlport4 $(call SET_SHARED_LIBRARY_ORIGIN), \ LIBS := $(JVM_LIBS), \ diff --git a/src/make/hotspot/lib/JvmFeatures.gmk b/src/make/hotspot/lib/JvmFeatures.gmk index d4f0891532e..c42b1e930aa 100644 --- a/src/make/hotspot/lib/JvmFeatures.gmk +++ b/src/make/hotspot/lib/JvmFeatures.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2018, 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 @@ -109,6 +109,7 @@ ifneq ($(call check-jvm-feature, cds), true) classListParser.cpp \ classLoaderExt.cpp \ filemap.cpp \ + heapShared.cpp \ metaspaceShared.cpp \ metaspaceShared_$(HOTSPOT_TARGET_CPU).cpp \ metaspaceShared_$(HOTSPOT_TARGET_CPU_ARCH).cpp \ diff --git a/src/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp b/src/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp index 259b881ef2c..cdf66f93f1d 100644 --- a/src/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp +++ b/src/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp @@ -40,6 +40,7 @@ #include #include "gc/shared/collectedHeap.hpp" +#include "memory/heap.hpp" #include "runtime/vmStructs.hpp" typedef enum GEN_variant { diff --git a/src/make/hotspot/symbols/symbols-unix b/src/make/hotspot/symbols/symbols-unix index b3d09ba8415..b1017923a78 100644 --- a/src/make/hotspot/symbols/symbols-unix +++ b/src/make/hotspot/symbols/symbols-unix @@ -136,6 +136,7 @@ JVM_InitClassName JVM_InitProperties JVM_InitStackTraceElement JVM_InitStackTraceElementArray +JVM_InitializeFromArchive JVM_InternString JVM_Interrupt JVM_InvokeMethod diff --git a/src/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java b/src/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java index e32b8d77766..b9613200c48 100644 --- a/src/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java +++ b/src/make/jdk/src/classes/build/tools/classlist/HelloClasslist.java @@ -32,6 +32,7 @@ package build.tools.classlist; import java.net.InetAddress; +import java.nio.file.FileSystems; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -56,6 +57,8 @@ public class HelloClasslist { public static void main(String ... args) { + FileSystems.getDefault(); + List strings = Arrays.asList("Hello", "World!", "From: ", InetAddress.getLoopbackAddress().toString()); diff --git a/src/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/src/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index bc406881d00..bbfe419ca1d 100644 --- a/src/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/src/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -106,7 +106,7 @@ public class CLDRConverter { private static final ResourceBundle.Control defCon = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT); - private static final String[] AVAILABLE_TZIDS = TimeZone.getAvailableIDs(); + private static Set AVAILABLE_TZIDS; private static String zoneNameTempFile; private static String tzDataDir; private static final Map canonicalTZMap = new HashMap<>(); @@ -340,17 +340,26 @@ private static List readBundleList() throws Exception { if (sb.indexOf("root") == -1) { sb.append("root"); } - Bundle b = new Bundle(id, sb.toString(), null, null); - // Insert the bundle for root at the top so that it will get - // processed first. - if ("root".equals(id)) { - retList.add(0, b); - } else { - retList.add(b); - } + retList.add(new Bundle(id, sb.toString(), null, null)); } } } + + // Sort the bundles based on id. This will make sure all the parent bundles are + // processed first, e.g., for en_GB bundle, en_001, and "root" comes before + // en_GB. In order for "root" to come at the beginning, "root" is replaced with + // empty string on comparison. + retList.sort((o1, o2) -> { + String id1 = o1.getID(); + String id2 = o2.getID(); + if(id1.equals("root")) { + id1 = ""; + } + if(id2.equals("root")) { + id2 = ""; + } + return id1.compareTo(id2); + }); return retList; } @@ -711,7 +720,7 @@ private static Map extractZoneNames(Map map, Str }); } - Arrays.stream(AVAILABLE_TZIDS).forEach(tzid -> { + getAvailableZoneIds().stream().forEach(tzid -> { // If the tzid is deprecated, get the data for the replacement id String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid)) .orElse(tzid); @@ -1053,8 +1062,20 @@ private static void generateZoneName() throws Exception { StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } + // This method assumes handlerMetaZones is already initialized + private static Set getAvailableZoneIds() { + assert handlerMetaZones != null; + if (AVAILABLE_TZIDS == null) { + AVAILABLE_TZIDS = new HashSet<>(ZoneId.getAvailableZoneIds()); + AVAILABLE_TZIDS.addAll(handlerMetaZones.keySet()); + AVAILABLE_TZIDS.remove(MetaZonesParseHandler.NO_METAZONE_KEY); + } + + return AVAILABLE_TZIDS; + } + private static Stream zidMapEntry() { - return ZoneId.getAvailableZoneIds().stream() + return getAvailableZoneIds().stream() .map(id -> { String canonId = canonicalTZMap.getOrDefault(id, id); String meta = handlerMetaZones.get(canonId); diff --git a/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java b/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java index 8cbdd0d44ff..148cdbc3eca 100644 --- a/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java +++ b/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -263,7 +263,7 @@ private void outputFile(Path dstFile, String version, for (ZoneRules rules : rulesList) { baos.reset(); DataOutputStream dataos = new DataOutputStream(baos); - rules.writeExternal(dataos); + Ser.write(rules, dataos); dataos.close(); byte[] bytes = baos.toByteArray(); out.writeShort(bytes.length); diff --git a/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java index 488a1add46d..2622a8f9267 100644 --- a/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java +++ b/src/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.NavigableMap; -import java.util.Objects; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.time.*; import java.time.Year; import java.time.chrono.IsoChronology; import java.time.temporal.TemporalAdjusters; -import java.time.zone.ZoneOffsetTransition; -import java.time.zone.ZoneOffsetTransitionRule; -import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; +import build.tools.tzdb.ZoneOffsetTransitionRule.TimeDefinition; import java.time.zone.ZoneRulesException; /** @@ -274,8 +262,8 @@ private static abstract class MonthDayTime { /** Whether this is midnight end of day. */ boolean endOfDay; - /** The time of the cutover. */ + /** The time definition of the cutover. */ TimeDefinition timeDefinition = TimeDefinition.WALL; void adjustToForwards(int year) { @@ -345,6 +333,20 @@ private void parse(String[] tokens, int off) { // time must be midnight when end of day flag is true endOfDay = true; secsOfDay = 0; + } else if (secsOfDay < 0 || secsOfDay > 86400) { + // beyond 0:00-24:00 range. Adjust the cutover date. + int beyondDays = secsOfDay / 86400; + secsOfDay %= 86400; + if (secsOfDay < 0) { + secsOfDay = 86400 + secsOfDay; + beyondDays -= 1; + } + LocalDate date = LocalDate.of(2004, month, dayOfMonth).plusDays(beyondDays); // leap-year + month = date.getMonth(); + dayOfMonth = date.getDayOfMonth(); + if (dayOfWeek != null) { + dayOfWeek = dayOfWeek.plus(beyondDays); + } } timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1)); } @@ -499,9 +501,11 @@ private static class RuleLine extends MonthDayTime { * * @param standardOffset the active standard offset, not null * @param savingsBeforeSecs the active savings before the transition in seconds + * @param negativeSavings minimum savings in the rule, usually zero, but negative if negative DST is + * in effect. * @return the transition, not null */ - ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefore) { + ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefore, int negativeSavings) { // rule shared by different zones, so don't change it Month month = this.month; int dayOfMonth = this.dayOfMonth; @@ -524,6 +528,7 @@ ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefor } endOfDay = false; } + // build rule return ZoneOffsetTransitionRule.of( //month, dayOfMonth, dayOfWeek, time, endOfDay, timeDefinition, @@ -531,7 +536,7 @@ ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefor LocalTime.ofSecondOfDay(secsOfDay), endOfDay, timeDefinition, stdOffset, ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsBefore), - ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsAmount)); + ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsAmount - negativeSavings)); } RuleLine parse(String[] tokens) { @@ -645,12 +650,12 @@ private static class TransRule implements Comparable this.ldtSecs = ldt.toEpochSecond(ZoneOffset.UTC); } - ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { + ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs, int negativeSavings) { // copy of code in ZoneOffsetTransitionRule to avoid infinite loop ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds( standardOffset.getTotalSeconds() + savingsBeforeSecs); ZoneOffset offsetAfter = ZoneOffset.ofTotalSeconds( - standardOffset.getTotalSeconds() + rule.savingsAmount); + standardOffset.getTotalSeconds() + rule.savingsAmount - negativeSavings); LocalDateTime dt = rule.timeDefinition .createDateTime(ldt, standardOffset, wallOffset); return ZoneOffsetTransition.of(dt, wallOffset, offsetAfter); @@ -668,10 +673,12 @@ long toEpochSecond(ZoneOffset stdOffset, int savingsBeforeSecs) { * Tests if this a real transition with the active savings in seconds * * @param savingsBefore the active savings in seconds + * @param negativeSavings minimum savings in the rule, usually zero, but negative if negative DST is + * in effect. * @return true, if savings changes */ - boolean isTransition(int savingsBefore) { - return rule.savingsAmount != savingsBefore; + boolean isTransition(int savingsBefore, int negativeSavings) { + return rule.savingsAmount - negativeSavings != savingsBefore; } public int compareTo(TransRule other) { @@ -699,12 +706,22 @@ private ZoneRules buildRules(String zoneId, List zones) { // start ldt of each zone window LocalDateTime zoneStart = LocalDateTime.MIN; - // first stanard offset + // first standard offset ZoneOffset firstStdOffset = stdOffset; // first wall offset ZoneOffset firstWallOffset = wallOffset; for (ZoneLine zone : zones) { + // Adjust stdOffset, if negative DST is observed. It should be either + // fixed amount, or expressed in the named Rules. + int negativeSavings = Math.min(zone.fixedSavingsSecs, findNegativeSavings(zoneStart, zone)); + if (negativeSavings < 0) { + zone.stdOffsetSecs += negativeSavings; + if (zone.fixedSavingsSecs < 0) { + zone.fixedSavingsSecs = 0; + } + } + // check if standard offset changed, update it if yes ZoneOffset stdOffsetPrev = stdOffset; // for effectiveSavings check if (zone.stdOffsetSecs != stdOffset.getTotalSeconds()) { @@ -793,7 +810,7 @@ private ZoneRules buildRules(String zoneId, List zones) { // sort the merged rules Collections.sort(trules); - effectiveSavings = 0; + effectiveSavings = -negativeSavings; for (TransRule rule : trules) { if (rule.toEpochSecond(stdOffsetPrev, savings) > zoneStart.toEpochSecond(wallOffset)) { @@ -802,7 +819,7 @@ private ZoneRules buildRules(String zoneId, List zones) { // (hence isAfter) break; } - effectiveSavings = rule.rule.savingsAmount; + effectiveSavings = rule.rule.savingsAmount - negativeSavings; } } // check if the start of the window represents a transition @@ -819,21 +836,21 @@ private ZoneRules buildRules(String zoneId, List zones) { if (trules != null) { long zoneStartEpochSecs = zoneStart.toEpochSecond(wallOffset); for (TransRule trule : trules) { - if (trule.isTransition(savings)) { + if (trule.isTransition(savings, negativeSavings)) { long epochSecs = trule.toEpochSecond(stdOffset, savings); if (epochSecs < zoneStartEpochSecs || epochSecs >= zone.toDateTimeEpochSecond(savings)) { continue; } - transitionList.add(trule.toTransition(stdOffset, savings)); - savings = trule.rule.savingsAmount; + transitionList.add(trule.toTransition(stdOffset, savings, negativeSavings)); + savings = trule.rule.savingsAmount - negativeSavings; } } } if (lastRules != null) { for (TransRule trule : lastRules) { - lastTransitionRuleList.add(trule.rule.toTransitionRule(stdOffset, savings)); - savings = trule.rule.savingsAmount; + lastTransitionRuleList.add(trule.rule.toTransitionRule(stdOffset, savings, negativeSavings)); + savings = trule.rule.savingsAmount - negativeSavings; } } @@ -850,4 +867,38 @@ private ZoneRules buildRules(String zoneId, List zones) { lastTransitionRuleList); } + /** + * Find the minimum negative savings in named Rules for a Zone. Savings are only + * looked at for the period of the subject Zone. + * + * @param zoneStart start LDT of the zone + * @param zl ZoneLine to look at + */ + private int findNegativeSavings(LocalDateTime zoneStart, ZoneLine zl) { + int negativeSavings = 0; + LocalDateTime zoneEnd = zl.toDateTime(); + + if (zl.savingsRule != null) { + List rlines = rules.get(zl.savingsRule); + if (rlines == null) { + throw new IllegalArgumentException(" not found: " + + zl.savingsRule); + } + + negativeSavings = Math.min(0, rlines.stream() + .filter(l -> windowOverlap(l, zoneStart.getYear(), zoneEnd.getYear())) + .map(l -> l.savingsAmount) + .min(Comparator.naturalOrder()) + .orElse(0)); + } + + return negativeSavings; + } + + private boolean windowOverlap(RuleLine ruleLine, int zoneStartYear, int zoneEndYear) { + boolean overlap = zoneStartYear <= ruleLine.startYear && zoneEndYear >= ruleLine.startYear || + zoneStartYear <= ruleLine.endYear && zoneEndYear >= ruleLine.endYear; + + return overlap; + } } diff --git a/src/make/jdk/src/classes/build/tools/tzdb/ZoneRules.java b/src/make/jdk/src/classes/build/tools/tzdb/ZoneRules.java deleted file mode 100644 index 25d7cb7ac09..00000000000 --- a/src/make/jdk/src/classes/build/tools/tzdb/ZoneRules.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. 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) 2011-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.io.DataOutput; -import java.io.IOException; -import java.io.ObjectOutput; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneOffset; -import java.time.zone.ZoneOffsetTransition; -import java.time.zone.ZoneOffsetTransitionRule; -import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; -import java.util.Arrays; -import java.util.ArrayList; -import java.util.List; - -/** - * Duplicated code of javax.time.zone.ZoneRules, ZoneOffsetTransitionRule - * and Ser to generate the serialization form output of ZoneRules for - * tzdb.jar. - * - * Implementation here is the copy/paste of ZoneRules, ZoneOffsetTransitionRule - * and Ser in javax.time.zone package. Make sure the code here is synchrionozed - * with the serialization implementation there. - * - * @since 1.8 - */ - -final class ZoneRules { - - /** - * The transitions between standard offsets (epoch seconds), sorted. - */ - private final long[] standardTransitions; - /** - * The standard offsets. - */ - private final ZoneOffset[] standardOffsets; - /** - * The transitions between instants (epoch seconds), sorted. - */ - private final long[] savingsInstantTransitions; - - /** - * The wall offsets. - */ - private final ZoneOffset[] wallOffsets; - /** - * The last rule. - */ - private final ZoneOffsetTransitionRule[] lastRules; - - /** - * Creates an instance. - * - * @param baseStandardOffset the standard offset to use before legal rules were set, not null - * @param baseWallOffset the wall offset to use before legal rules were set, not null - * @param standardOffsetTransitionList the list of changes to the standard offset, not null - * @param transitionList the list of transitions, not null - * @param lastRules the recurring last rules, size 16 or less, not null - */ - ZoneRules(ZoneOffset baseStandardOffset, - ZoneOffset baseWallOffset, - List standardOffsetTransitionList, - List transitionList, - List lastRules) { - - this.standardTransitions = new long[standardOffsetTransitionList.size()]; - - this.standardOffsets = new ZoneOffset[standardOffsetTransitionList.size() + 1]; - this.standardOffsets[0] = baseStandardOffset; - for (int i = 0; i < standardOffsetTransitionList.size(); i++) { - this.standardTransitions[i] = standardOffsetTransitionList.get(i).toEpochSecond(); - this.standardOffsets[i + 1] = standardOffsetTransitionList.get(i).getOffsetAfter(); - } - - // convert savings transitions to locals - List localTransitionOffsetList = new ArrayList<>(); - localTransitionOffsetList.add(baseWallOffset); - for (ZoneOffsetTransition trans : transitionList) { - localTransitionOffsetList.add(trans.getOffsetAfter()); - } - - this.wallOffsets = localTransitionOffsetList.toArray(new ZoneOffset[localTransitionOffsetList.size()]); - - // convert savings transitions to instants - this.savingsInstantTransitions = new long[transitionList.size()]; - for (int i = 0; i < transitionList.size(); i++) { - this.savingsInstantTransitions[i] = transitionList.get(i).toEpochSecond(); - } - - // last rules - if (lastRules.size() > 16) { - throw new IllegalArgumentException("Too many transition rules"); - } - this.lastRules = lastRules.toArray(new ZoneOffsetTransitionRule[lastRules.size()]); - } - - /** Type for ZoneRules. */ - static final byte ZRULES = 1; - - /** - * Writes the state to the stream. - * - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - void writeExternal(DataOutput out) throws IOException { - out.writeByte(ZRULES); - out.writeInt(standardTransitions.length); - for (long trans : standardTransitions) { - writeEpochSec(trans, out); - } - for (ZoneOffset offset : standardOffsets) { - writeOffset(offset, out); - } - out.writeInt(savingsInstantTransitions.length); - for (long trans : savingsInstantTransitions) { - writeEpochSec(trans, out); - } - for (ZoneOffset offset : wallOffsets) { - writeOffset(offset, out); - } - out.writeByte(lastRules.length); - for (ZoneOffsetTransitionRule rule : lastRules) { - writeRule(rule, out); - } - } - - /** - * Writes the state the ZoneOffset to the stream. - * - * @param offset the offset, not null - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - static void writeOffset(ZoneOffset offset, DataOutput out) throws IOException { - final int offsetSecs = offset.getTotalSeconds(); - int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72 - out.writeByte(offsetByte); - if (offsetByte == 127) { - out.writeInt(offsetSecs); - } - } - - /** - * Writes the epoch seconds to the stream. - * - * @param epochSec the epoch seconds, not null - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - static void writeEpochSec(long epochSec, DataOutput out) throws IOException { - if (epochSec >= -4575744000L && epochSec < 10413792000L && epochSec % 900 == 0) { // quarter hours between 1825 and 2300 - int store = (int) ((epochSec + 4575744000L) / 900); - out.writeByte((store >>> 16) & 255); - out.writeByte((store >>> 8) & 255); - out.writeByte(store & 255); - } else { - out.writeByte(255); - out.writeLong(epochSec); - } - } - - /** - * Writes the state of the transition rule to the stream. - * - * @param rule the transition rule, not null - * @param out the output stream, not null - * @throws IOException if an error occurs - */ - static void writeRule(ZoneOffsetTransitionRule rule, DataOutput out) throws IOException { - int month = rule.getMonth().getValue(); - byte dom = (byte)rule.getDayOfMonthIndicator(); - int dow = (rule.getDayOfWeek() == null ? -1 : rule.getDayOfWeek().getValue()); - LocalTime time = rule.getLocalTime(); - boolean timeEndOfDay = rule.isMidnightEndOfDay(); - TimeDefinition timeDefinition = rule.getTimeDefinition(); - ZoneOffset standardOffset = rule.getStandardOffset(); - ZoneOffset offsetBefore = rule.getOffsetBefore(); - ZoneOffset offsetAfter = rule.getOffsetAfter(); - - int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay()); - int stdOffset = standardOffset.getTotalSeconds(); - int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset; - int afterDiff = offsetAfter.getTotalSeconds() - stdOffset; - int timeByte = (timeSecs % 3600 == 0 ? (timeEndOfDay ? 24 : time.getHour()) : 31); - int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255); - int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3); - int afterByte = (afterDiff == 0 || afterDiff == 1800 || afterDiff == 3600 ? afterDiff / 1800 : 3); - int dowByte = (dow == -1 ? 0 : dow); - int b = (month << 28) + // 4 bytes - ((dom + 32) << 22) + // 6 bytes - (dowByte << 19) + // 3 bytes - (timeByte << 14) + // 5 bytes - (timeDefinition.ordinal() << 12) + // 2 bytes - (stdOffsetByte << 4) + // 8 bytes - (beforeByte << 2) + // 2 bytes - afterByte; // 2 bytes - out.writeInt(b); - if (timeByte == 31) { - out.writeInt(timeSecs); - } - if (stdOffsetByte == 255) { - out.writeInt(stdOffset); - } - if (beforeByte == 3) { - out.writeInt(offsetBefore.getTotalSeconds()); - } - if (afterByte == 3) { - out.writeInt(offsetAfter.getTotalSeconds()); - } - } - - /** - * Checks if this set of rules equals another. - *

    - * Two rule sets are equal if they will always result in the same output - * for any given input instant or local date-time. - * Rules from two different groups may return false even if they are in fact the same. - *

    - * This definition should result in implementations comparing their entire state. - * - * @param otherRules the other rules, null returns false - * @return true if this rules is the same as that specified - */ - @Override - public boolean equals(Object otherRules) { - if (this == otherRules) { - return true; - } - if (otherRules instanceof ZoneRules) { - ZoneRules other = (ZoneRules) otherRules; - return Arrays.equals(standardTransitions, other.standardTransitions) && - Arrays.equals(standardOffsets, other.standardOffsets) && - Arrays.equals(savingsInstantTransitions, other.savingsInstantTransitions) && - Arrays.equals(wallOffsets, other.wallOffsets) && - Arrays.equals(lastRules, other.lastRules); - } - return false; - } - - /** - * Returns a suitable hash code given the definition of {@code #equals}. - * - * @return the hash code - */ - @Override - public int hashCode() { - return Arrays.hashCode(standardTransitions) ^ - Arrays.hashCode(standardOffsets) ^ - Arrays.hashCode(savingsInstantTransitions) ^ - Arrays.hashCode(wallOffsets) ^ - Arrays.hashCode(lastRules); - } - -} diff --git a/src/make/launcher/Launcher-java.base.gmk b/src/make/launcher/Launcher-java.base.gmk index e62e96b4bb0..5ee4530004b 100644 --- a/src/make/launcher/Launcher-java.base.gmk +++ b/src/make/launcher/Launcher-java.base.gmk @@ -43,8 +43,6 @@ $(eval $(call SetupBuildLauncher, java, \ VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/java_objs, \ OPTIMIZATION := HIGH, \ - WINDOWS_STATIC_LINK := true, \ - NO_JAVA_MS := true, \ )) $(SUPPORT_OUTPUTDIR)/modules_cmds/java.base/java$(EXE_SUFFIX): $(BUILD_LAUNCHER_java) @@ -60,8 +58,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBS_windows := user32.lib comctl32.lib, \ EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \ VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \ - WINDOWS_STATIC_LINK := true, \ - NO_JAVA_MS := true, \ )) endif diff --git a/src/make/launcher/LauncherCommon.gmk b/src/make/launcher/LauncherCommon.gmk index 8736d8f007c..ac355a44a87 100644 --- a/src/make/launcher/LauncherCommon.gmk +++ b/src/make/launcher/LauncherCommon.gmk @@ -25,19 +25,13 @@ include JdkNativeCompilation.gmk -ifeq ($(OPENJDK_TARGET_OS), macosx) - ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN) -else - ifeq ($(OPENJDK_TARGET_OS), windows) - endif - ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/jli) +ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN,/../lib/jli) - # Applications expect to be able to link against libjawt without invoking - # System.loadLibrary("jawt") first. This was the behaviour described in the - # devloper documentation of JAWT and what worked with OpenJDK6. - ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) - ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib) - endif +# Applications expect to be able to link against libjawt without invoking +# System.loadLibrary("jawt") first. This was the behaviour described in the +# devloper documentation of JAWT and what worked with OpenJDK6. +ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), ) + ORIGIN_ARG += $(call SET_EXECUTABLE_ORIGIN,/../lib) endif # Tell the compiler not to export any functions unless declared so in @@ -93,11 +87,9 @@ JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest # LDFLAGS_solaris Additional LDFLAGS_solaris # RC_FLAGS Additional RC_FLAGS # MACOSX_SIGNED On macosx, sign this binary -# WINDOWS_STATIC_LINK On windows, link statically with C runtime and libjli. # OPTIMIZATION Override default optimization level (LOW) # OUTPUT_DIR Override default output directory # VERSION_INFO_RESOURCE Override default Windows resource file -# NO_JAVA_MS Do not add -ms8m to JAVA_ARGS. SetupBuildLauncher = $(NamedParamsMacroTemplate) define SetupBuildLauncherBody # Setup default values (unless overridden) @@ -105,26 +97,24 @@ define SetupBuildLauncherBody $1_OPTIMIZATION := LOW endif - ifneq ($$($1_NO_JAVA_MS), true) - # The norm is to append -ms8m, unless otherwise instructed. - $1_JAVA_ARGS += -ms8m - endif - ifeq ($$($1_MAIN_MODULE), ) $1_MAIN_MODULE := $(MODULE) endif - ifneq ($$($1_JAVA_ARGS), ) - ifneq ($$($1_EXTRA_JAVA_ARGS), ) - $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ - $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }' - $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR) - endif - $1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ - $$(addprefix -J, $$($1_JAVA_ARGS)) -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS), "$$a"$(COMMA) )) }' - $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR) + $1_JAVA_ARGS += -ms8m + ifneq ($$($1_MAIN_CLASS), ) + $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS) endif + ifneq ($$($1_EXTRA_JAVA_ARGS), ) + $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ + $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }' + $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR) + endif + $1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \ + $$(addprefix -J, $$($1_JAVA_ARGS)) $$($1_LAUNCHER_CLASS), "$$a"$(COMMA) )) }' + $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR) + $1_LIBS := ifeq ($(OPENJDK_TARGET_OS), macosx) ifeq ($$($1_MACOSX_SIGNED), true) @@ -149,8 +139,6 @@ define SetupBuildLauncherBody -framework Foundation \ -framework SystemConfiguration \ -lstdc++ -liconv - else - $1_LIBS += $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a endif $1_LIBS += -framework Cocoa -framework Security \ -framework ApplicationServices @@ -165,19 +153,13 @@ define SetupBuildLauncherBody $1_LIBS += -lz endif - ifeq ($$($1_WINDOWS_STATIC_LINK), true) - $1_CFLAGS += $(filter-out -MD, $(CFLAGS_JDKEXE)) - $1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib - else - $1_CFLAGS += $(CFLAGS_JDKEXE) - $1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib - endif + $1_WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \ NAME := $1, \ EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \ OPTIMIZATION := $$($1_OPTIMIZATION), \ - CFLAGS := $$($1_CFLAGS) \ + CFLAGS := $$(CFLAGS_JDKEXE) $$($1_CFLAGS) \ $(LAUNCHER_CFLAGS) \ $(VERSION_CFLAGS) \ -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \ @@ -190,12 +172,15 @@ define SetupBuildLauncherBody $$(ORIGIN_ARG) \ $$($1_LDFLAGS), \ LDFLAGS_linux := \ - -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ + -L$(call FindLibDirForModule, java.base)/jli, \ + LDFLAGS_macosx := \ + -L$(call FindLibDirForModule, java.base)/jli, \ LDFLAGS_solaris := $$($1_LDFLAGS_solaris) \ - -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli, \ + -L$(call FindLibDirForModule, java.base)/jli, \ LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \ LIBS_unix := $$($1_LIBS_unix), \ LIBS_linux := -lpthread -ljli $(LIBDL), \ + LIBS_macosx := -ljli, \ LIBS_solaris := -ljli -lthread $(LIBDL), \ LIBS_windows := $$($1_WINDOWS_JLI_LIB) \ $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \ @@ -211,7 +196,7 @@ define SetupBuildLauncherBody $1 += $$(BUILD_LAUNCHER_$1) TARGETS += $$($1) - ifneq (,$(filter $(OPENJDK_TARGET_OS), macosx aix)) + ifeq ($(OPENJDK_TARGET_OS), aix) $$(BUILD_LAUNCHER_$1): $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a endif diff --git a/src/make/lib/Awt2dLibraries.gmk b/src/make/lib/Awt2dLibraries.gmk index aaf0244f1a2..18a90473a7f 100644 --- a/src/make/lib/Awt2dLibraries.gmk +++ b/src/make/lib/Awt2dLibraries.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2019, 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 @@ -503,6 +503,8 @@ else LIBFREETYPE_CFLAGS := -I$(BUILD_LIBFREETYPE_HEADER_DIRS) ifeq ($(OPENJDK_TARGET_OS), windows) LIBFREETYPE_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfreetype/freetype.lib + # freetype now requires you to manually define this (see ftconfig.h) + BUILD_LIBFREETYPE_CFLAGS += -DDLL_EXPORT else LIBFREETYPE_LIBS := -lfreetype endif @@ -516,8 +518,8 @@ else DISABLED_WARNINGS_solstudio := \ E_STATEMENT_NOT_REACHED \ E_END_OF_LOOP_CODE_NOT_REACHED, \ - DISABLED_WARNINGS_microsoft := 4267 4244 4312, \ - DISABLED_WARNINGS_gcc := implicit-fallthrough, \ + DISABLED_WARNINGS_microsoft := 4018 4267 4244 4312 4819, \ + DISABLED_WARNINGS_gcc := implicit-fallthrough cast-function-type bad-function-cast, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ )) @@ -795,7 +797,8 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_EXCLUDE_SRC_PATTERNS := unix endif - LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0 + LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE \ + -DPNG_ARM_NEON_OPT=0 -DPNG_ARM_NEON_IMPLEMENTATION=0 ifeq ($(OPENJDK_TARGET_OS), macosx) LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX diff --git a/src/make/lib/CoreLibraries.gmk b/src/make/lib/CoreLibraries.gmk index b7c49866514..ee52f93991a 100644 --- a/src/make/lib/CoreLibraries.gmk +++ b/src/make/lib/CoreLibraries.gmk @@ -49,40 +49,20 @@ endif LIBFDLIBM_SRC := $(TOPDIR)/src/java.base/share/native/libfdlibm LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC) $(FDLIBM_CFLAGS) -ifneq ($(OPENJDK_TARGET_OS), macosx) - $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \ - NAME := fdlibm, \ - TYPE := STATIC_LIBRARY, \ - OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \ - SRC := $(LIBFDLIBM_SRC), \ - OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \ - CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \ - CFLAGS_windows_debug := -DLOGGING, \ - CFLAGS_aix := -qfloat=nomaf, \ - DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \ - DISABLED_WARNINGS_microsoft := 4146 4244 4018, \ - ARFLAGS := $(ARFLAGS), \ - OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ - )) - -else - - # On macosx the old build does partial (incremental) linking of fdlibm instead of - # a plain static library. - $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM_MAC, \ - NAME := fdlibm, \ - OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ - SRC := $(LIBFDLIBM_SRC), \ - CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \ - LDFLAGS := -nostdlib $(ARFLAGS), \ - OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ - )) - - BUILD_LIBFDLIBM := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) - $(BUILD_LIBFDLIBM): $(BUILD_LIBFDLIBM_MAC) - $(call install-file) - -endif +$(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \ + NAME := fdlibm, \ + TYPE := STATIC_LIBRARY, \ + OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \ + SRC := $(LIBFDLIBM_SRC), \ + OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \ + CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \ + CFLAGS_windows_debug := -DLOGGING, \ + CFLAGS_aix := -qfloat=nomaf, \ + DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \ + DISABLED_WARNINGS_microsoft := 4146 4244 4018, \ + ARFLAGS := $(ARFLAGS), \ + OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \ +)) ########################################################################################## @@ -131,15 +111,15 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \ LDFLAGS_windows := -delayload:shell32.dll, \ + LIBS := $(BUILD_LIBFDLIBM_TARGET), \ LIBS_unix := -ljvm -lverify, \ - LIBS_linux := $(LIBDL) $(BUILD_LIBFDLIBM), \ - LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM), \ - LIBS_aix := $(LIBDL) $(BUILD_LIBFDLIBM) $(LIBM),\ - LIBS_macosx := -lfdlibm \ - -framework CoreFoundation \ + LIBS_linux := $(LIBDL), \ + LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL), \ + LIBS_aix := $(LIBDL) $(LIBM),\ + LIBS_macosx := -framework CoreFoundation \ -framework Foundation \ -framework Security -framework SystemConfiguration, \ - LIBS_windows := jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \ + LIBS_windows := jvm.lib $(WIN_VERIFY_LIB) \ shell32.lib delayimp.lib \ advapi32.lib version.lib, \ )) @@ -227,8 +207,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) endif ifeq ($(OPENJDK_TARGET_OS), windows) - # Staticically link with c runtime on windows. - LIBJLI_CFLAGS_JDKLIB := $(filter-out -MD, $(CFLAGS_JDKLIB)) LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE) # Supply the name of the C runtime lib. LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"' @@ -236,7 +214,6 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"' endif else - LIBJLI_CFLAGS_JDKLIB := $(CFLAGS_JDKLIB) LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)/jli endif @@ -260,7 +237,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \ EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \ EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \ OPTIMIZATION := HIGH, \ - CFLAGS := $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \ + CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \ DISABLED_WARNINGS_solstudio := \ E_ASM_DISABLES_OPTIMIZATION \ E_STATEMENT_NOT_REACHED, \ @@ -280,54 +257,7 @@ TARGETS += $(BUILD_LIBJLI) LIBJLI_SRC_DIRS := $(call FindSrcDirsForComponent, java.base, libjli) -# On windows, the static library has the same suffix as the import library created by -# with the shared library, so the static library is given a different name. No harm -# in doing it for all platform to reduce complexity. -ifeq ($(OPENJDK_TARGET_OS), windows) - $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \ - NAME := jli_static, \ - TYPE := STATIC_LIBRARY, \ - OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \ - SRC := $(LIBJLI_SRC_DIRS), \ - EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \ - EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \ - OPTIMIZATION := HIGH, \ - CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \ - $(addprefix -I, $(LIBJLI_SRC_DIRS)), \ - ARFLAGS := $(ARFLAGS), \ - OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \ - )) - - TARGETS += $(BUILD_LIBJLI_STATIC) - -else ifeq ($(OPENJDK_TARGET_OS), macosx) - # - # On macosx they do partial (incremental) linking of libjli_static.a - # code it here...rather than add support to NativeCompilation - # as this is first time I see it - $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \ - NAME := jli_static, \ - OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \ - SRC := $(LIBJLI_SRC_DIRS), \ - EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \ - EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \ - OPTIMIZATION := HIGH, \ - CFLAGS := $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \ - $(addprefix -I, $(LIBJLI_SRC_DIRS)), \ - LDFLAGS := -nostdlib $(ARFLAGS), \ - OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \ - )) - - ifeq ($(STATIC_BUILD), true) - TARGETS += $(BUILD_LIBJLI_STATIC) - else - $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static.a: $(BUILD_LIBJLI_STATIC) - $(call install-file) - - TARGETS += $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static.a - endif - -else ifeq ($(OPENJDK_TARGET_OS), aix) +ifeq ($(OPENJDK_TARGET_OS), aix) # AIX also requires a static libjli because the compiler doesn't support '-rpath' $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \ NAME := jli_static, \ @@ -337,7 +267,7 @@ else ifeq ($(OPENJDK_TARGET_OS), aix) EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \ EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \ OPTIMIZATION := HIGH, \ - CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \ + CFLAGS := $(STATIC_LIBRARY_FLAGS) $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \ $(addprefix -I, $(LIBJLI_SRC_DIRS)), \ ARFLAGS := $(ARFLAGS), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static)) diff --git a/src/make/lib/Lib-java.base.gmk b/src/make/lib/Lib-java.base.gmk index db95e758599..6e8712a0311 100644 --- a/src/make/lib/Lib-java.base.gmk +++ b/src/make/lib/Lib-java.base.gmk @@ -55,7 +55,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBNET, \ LIBS_solaris := -lnsl -lsocket $(LIBDL), \ LIBS_aix := $(LIBDL),\ LIBS_windows := ws2_32.lib jvm.lib secur32.lib iphlpapi.lib winhttp.lib \ - urlmon.lib delayimp.lib $(WIN_JAVA_LIB) advapi32.lib, \ + delayimp.lib $(WIN_JAVA_LIB) advapi32.lib, \ LIBS_macosx := -framework CoreFoundation -framework CoreServices, \ )) diff --git a/src/make/lib/Lib-java.instrument.gmk b/src/make/lib/Lib-java.instrument.gmk index 7e625e3a036..9acde85ffd3 100644 --- a/src/make/lib/Lib-java.instrument.gmk +++ b/src/make/lib/Lib-java.instrument.gmk @@ -31,20 +31,15 @@ $(eval $(call IncludeCustomExtension, lib/Lib-java.instrument.gmk)) ################################################################################ ifeq ($(OPENJDK_TARGET_OS), windows) - # Statically link the C runtime so that there are not dependencies on modules - # not on the search patch when invoked from the Windows system directory - # (or elsewhere). - LIBINSTRUMENT_CFLAGS_JDKLIB := $(filter-out -MD, $(CFLAGS_JDKLIB)) # equivalent of strcasecmp is stricmp on Windows LIBINSTRUMENT_CFLAGS := -Dstrcasecmp=stricmp -else - LIBINSTRUMENT_CFLAGS_JDKLIB := $(CFLAGS_JDKLIB) + WINDOWS_JLI_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib endif $(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \ NAME := instrument, \ OPTIMIZATION := LOW, \ - CFLAGS := $(LIBINSTRUMENT_CFLAGS_JDKLIB) $(LIBINSTRUMENT_CFLAGS), \ + CFLAGS := $(CFLAGS_JDKLIB) $(LIBINSTRUMENT_CFLAGS), \ CFLAGS_debug := -DJPLIS_LOGGING, \ CFLAGS_release := -DNO_JPLIS_LOGGING, \ EXTRA_HEADER_DIRS := java.base:libjli, \ @@ -55,22 +50,24 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \ -L$(call FindLibDirForModule, java.base)/jli, \ LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/jli) \ -L$(call FindLibDirForModule, java.base)/jli, \ - LDFLAGS_macosx := -Wl$(COMMA)-all_load, \ + LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN,/jli) \ + -L$(call FindLibDirForModule, java.base)/jli, \ LDFLAGS_aix := -L$(SUPPORT_OUTPUTDIR)/native/java.base, \ LIBS := $(JDKLIB_LIBS), \ LIBS_unix := -ljava -ljvm $(LIBZ_LIBS), \ LIBS_linux := -ljli $(LIBDL), \ LIBS_solaris := -ljli $(LIBDL), \ LIBS_aix := -liconv -ljli_static $(LIBDL), \ - LIBS_macosx := -liconv -framework Cocoa -framework Security \ - -framework ApplicationServices \ - $(call FindStaticLib, java.base, jli_static), \ + LIBS_macosx := -ljli -liconv -framework Cocoa -framework Security \ + -framework ApplicationServices, \ LIBS_windows := jvm.lib $(WIN_JAVA_LIB) advapi32.lib \ - $(call FindStaticLib, java.base, jli_static), \ + $(WINDOWS_JLI_LIB), \ )) -ifneq ($(filter $(OPENJDK_TARGET_OS), macosx windows aix), ) +ifeq ($(OPENJDK_TARGET_OS), aix) $(BUILD_LIBINSTRUMENT): $(call FindStaticLib, java.base, jli_static) +else ifeq ($(OPENJDK_TARGET_OS), windows) + $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli) else $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, jli, /jli) endif diff --git a/src/src/hotspot/cpu/aarch64/aarch64.ad b/src/src/hotspot/cpu/aarch64/aarch64.ad index 98ffd6702fe..e29a1dc45f1 100644 --- a/src/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/src/hotspot/cpu/aarch64/aarch64.ad @@ -1036,21 +1036,8 @@ class HandlerImpl { } }; - // graph traversal helpers - - MemBarNode *parent_membar(const Node *n); - MemBarNode *child_membar(const MemBarNode *n); - bool leading_membar(const MemBarNode *barrier); - - bool is_card_mark_membar(const MemBarNode *barrier); bool is_CAS(int opcode); - MemBarNode *leading_to_normal(MemBarNode *leading); - MemBarNode *normal_to_leading(const MemBarNode *barrier); - MemBarNode *card_mark_to_trailing(const MemBarNode *barrier); - MemBarNode *trailing_to_card_mark(const MemBarNode *trailing); - MemBarNode *trailing_to_leading(const MemBarNode *trailing); - // predicates controlling emit of ldr/ldar and associated dmb bool unnecessary_acquire(const Node *barrier); @@ -1272,605 +1259,6 @@ source %{ // relevant dmb instructions. // - // graph traversal helpers used for volatile put/get and CAS - // optimization - - // 1) general purpose helpers - - // if node n is linked to a parent MemBarNode by an intervening - // Control and Memory ProjNode return the MemBarNode otherwise return - // NULL. - // - // n may only be a Load or a MemBar. - - MemBarNode *parent_membar(const Node *n) - { - Node *ctl = NULL; - Node *mem = NULL; - Node *membar = NULL; - - if (n->is_Load()) { - ctl = n->lookup(LoadNode::Control); - mem = n->lookup(LoadNode::Memory); - } else if (n->is_MemBar()) { - ctl = n->lookup(TypeFunc::Control); - mem = n->lookup(TypeFunc::Memory); - } else { - return NULL; - } - - if (!ctl || !mem || !ctl->is_Proj() || !mem->is_Proj()) { - return NULL; - } - - membar = ctl->lookup(0); - - if (!membar || !membar->is_MemBar()) { - return NULL; - } - - if (mem->lookup(0) != membar) { - return NULL; - } - - return membar->as_MemBar(); - } - - // if n is linked to a child MemBarNode by intervening Control and - // Memory ProjNodes return the MemBarNode otherwise return NULL. - - MemBarNode *child_membar(const MemBarNode *n) - { - ProjNode *ctl = n->proj_out_or_null(TypeFunc::Control); - ProjNode *mem = n->proj_out_or_null(TypeFunc::Memory); - - // MemBar needs to have both a Ctl and Mem projection - if (! ctl || ! mem) - return NULL; - - MemBarNode *child = NULL; - Node *x; - - for (DUIterator_Fast imax, i = ctl->fast_outs(imax); i < imax; i++) { - x = ctl->fast_out(i); - // if we see a membar we keep hold of it. we may also see a new - // arena copy of the original but it will appear later - if (x->is_MemBar()) { - child = x->as_MemBar(); - break; - } - } - - if (child == NULL) { - return NULL; - } - - for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { - x = mem->fast_out(i); - // if we see a membar we keep hold of it. we may also see a new - // arena copy of the original but it will appear later - if (x == child) { - return child; - } - } - return NULL; - } - - // helper predicate use to filter candidates for a leading memory - // barrier - // - // returns true if barrier is a MemBarRelease or a MemBarCPUOrder - // whose Ctl and Mem feeds come from a MemBarRelease otherwise false - - bool leading_membar(const MemBarNode *barrier) - { - int opcode = barrier->Opcode(); - // if this is a release membar we are ok - if (opcode == Op_MemBarRelease) { - return true; - } - // if its a cpuorder membar . . . - if (opcode != Op_MemBarCPUOrder) { - return false; - } - // then the parent has to be a release membar - MemBarNode *parent = parent_membar(barrier); - if (!parent) { - return false; - } - opcode = parent->Opcode(); - return opcode == Op_MemBarRelease; - } - - // 2) card mark detection helper - - // helper predicate which can be used to detect a volatile membar - // introduced as part of a conditional card mark sequence either by - // G1 or by CMS when UseCondCardMark is true. - // - // membar can be definitively determined to be part of a card mark - // sequence if and only if all the following hold - // - // i) it is a MemBarVolatile - // - // ii) either UseG1GC or (UseConcMarkSweepGC && UseCondCardMark) is - // true - // - // iii) the node's Mem projection feeds a StoreCM node. - - bool is_card_mark_membar(const MemBarNode *barrier) - { - if (!UseG1GC && !(UseConcMarkSweepGC && UseCondCardMark)) { - return false; - } - - if (barrier->Opcode() != Op_MemBarVolatile) { - return false; - } - - ProjNode *mem = barrier->proj_out(TypeFunc::Memory); - - for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax ; i++) { - Node *y = mem->fast_out(i); - if (y->Opcode() == Op_StoreCM) { - return true; - } - } - - return false; - } - - - // 3) helper predicates to traverse volatile put or CAS graphs which - // may contain GC barrier subgraphs - - // Preamble - // -------- - // - // for volatile writes we can omit generating barriers and employ a - // releasing store when we see a node sequence sequence with a - // leading MemBarRelease and a trailing MemBarVolatile as follows - // - // MemBarRelease - // { || } -- optional - // {MemBarCPUOrder} - // || \\ - // || StoreX[mo_release] - // | \ / - // | MergeMem - // | / - // {MemBarCPUOrder} -- optional - // { || } - // MemBarVolatile - // - // where - // || and \\ represent Ctl and Mem feeds via Proj nodes - // | \ and / indicate further routing of the Ctl and Mem feeds - // - // this is the graph we see for non-object stores. however, for a - // volatile Object store (StoreN/P) we may see other nodes below the - // leading membar because of the need for a GC pre- or post-write - // barrier. - // - // with most GC configurations we with see this simple variant which - // includes a post-write barrier card mark. - // - // MemBarRelease______________________________ - // || \\ Ctl \ \\ - // || StoreN/P[mo_release] CastP2X StoreB/CM - // | \ / . . . / - // | MergeMem - // | / - // || / - // {MemBarCPUOrder} -- optional - // { || } - // MemBarVolatile - // - // i.e. the leading membar feeds Ctl to a CastP2X (which converts - // the object address to an int used to compute the card offset) and - // Ctl+Mem to a StoreB node (which does the actual card mark). - // - // n.b. a StoreCM node will only appear in this configuration when - // using CMS or G1. StoreCM differs from a normal card mark write (StoreB) - // because it implies a requirement to order visibility of the card - // mark (StoreCM) relative to the object put (StoreP/N) using a - // StoreStore memory barrier (arguably this ought to be represented - // explicitly in the ideal graph but that is not how it works). This - // ordering is required for both non-volatile and volatile - // puts. Normally that means we need to translate a StoreCM using - // the sequence - // - // dmb ishst - // strb - // - // However, when using G1 or CMS with conditional card marking (as - // we shall see) we don't need to insert the dmb when translating - // StoreCM because there is already an intervening StoreLoad barrier - // between it and the StoreP/N. - // - // It is also possible to perform the card mark conditionally on it - // currently being unmarked in which case the volatile put graph - // will look slightly different - // - // MemBarRelease____________________________________________ - // || \\ Ctl \ Ctl \ \\ Mem \ - // || StoreN/P[mo_release] CastP2X If LoadB | - // | \ / \ | - // | MergeMem . . . StoreB - // | / / - // || / - // MemBarVolatile - // - // It is worth noting at this stage that both the above - // configurations can be uniquely identified by checking that the - // memory flow includes the following subgraph: - // - // MemBarRelease - // {MemBarCPUOrder} - // | \ . . . - // | StoreX[mo_release] . . . - // | / - // MergeMem - // | - // {MemBarCPUOrder} - // MemBarVolatile - // - // This is referred to as a *normal* subgraph. It can easily be - // detected starting from any candidate MemBarRelease, - // StoreX[mo_release] or MemBarVolatile. - // - // A simple variation on this normal case occurs for an unsafe CAS - // operation. The basic graph for a non-object CAS is - // - // MemBarRelease - // || - // MemBarCPUOrder - // || \\ . . . - // || CompareAndSwapX - // || | - // || SCMemProj - // | \ / - // | MergeMem - // | / - // MemBarCPUOrder - // || - // MemBarAcquire - // - // The same basic variations on this arrangement (mutatis mutandis) - // occur when a card mark is introduced. i.e. we se the same basic - // shape but the StoreP/N is replaced with CompareAndSawpP/N and the - // tail of the graph is a pair comprising a MemBarCPUOrder + - // MemBarAcquire. - // - // So, in the case of a CAS the normal graph has the variant form - // - // MemBarRelease - // MemBarCPUOrder - // | \ . . . - // | CompareAndSwapX . . . - // | | - // | SCMemProj - // | / . . . - // MergeMem - // | - // MemBarCPUOrder - // MemBarAcquire - // - // This graph can also easily be detected starting from any - // candidate MemBarRelease, CompareAndSwapX or MemBarAcquire. - // - // the code below uses two helper predicates, leading_to_normal and - // normal_to_leading to identify these normal graphs, one validating - // the layout starting from the top membar and searching down and - // the other validating the layout starting from the lower membar - // and searching up. - // - // There are two special case GC configurations when a normal graph - // may not be generated: when using G1 (which always employs a - // conditional card mark); and when using CMS with conditional card - // marking configured. These GCs are both concurrent rather than - // stop-the world GCs. So they introduce extra Ctl+Mem flow into the - // graph between the leading and trailing membar nodes, in - // particular enforcing stronger memory serialisation beween the - // object put and the corresponding conditional card mark. CMS - // employs a post-write GC barrier while G1 employs both a pre- and - // post-write GC barrier. Of course the extra nodes may be absent -- - // they are only inserted for object puts/swaps. This significantly - // complicates the task of identifying whether a MemBarRelease, - // StoreX[mo_release] or MemBarVolatile forms part of a volatile put - // when using these GC configurations (see below). It adds similar - // complexity to the task of identifying whether a MemBarRelease, - // CompareAndSwapX or MemBarAcquire forms part of a CAS. - // - // In both cases the post-write subtree includes an auxiliary - // MemBarVolatile (StoreLoad barrier) separating the object put/swap - // and the read of the corresponding card. This poses two additional - // problems. - // - // Firstly, a card mark MemBarVolatile needs to be distinguished - // from a normal trailing MemBarVolatile. Resolving this first - // problem is straightforward: a card mark MemBarVolatile always - // projects a Mem feed to a StoreCM node and that is a unique marker - // - // MemBarVolatile (card mark) - // C | \ . . . - // | StoreCM . . . - // . . . - // - // The second problem is how the code generator is to translate the - // card mark barrier? It always needs to be translated to a "dmb - // ish" instruction whether or not it occurs as part of a volatile - // put. A StoreLoad barrier is needed after the object put to ensure - // i) visibility to GC threads of the object put and ii) visibility - // to the mutator thread of any card clearing write by a GC - // thread. Clearly a normal store (str) will not guarantee this - // ordering but neither will a releasing store (stlr). The latter - // guarantees that the object put is visible but does not guarantee - // that writes by other threads have also been observed. - // - // So, returning to the task of translating the object put and the - // leading/trailing membar nodes: what do the non-normal node graph - // look like for these 2 special cases? and how can we determine the - // status of a MemBarRelease, StoreX[mo_release] or MemBarVolatile - // in both normal and non-normal cases? - // - // A CMS GC post-barrier wraps its card write (StoreCM) inside an If - // which selects conditonal execution based on the value loaded - // (LoadB) from the card. Ctl and Mem are fed to the If via an - // intervening StoreLoad barrier (MemBarVolatile). - // - // So, with CMS we may see a node graph for a volatile object store - // which looks like this - // - // MemBarRelease - // {MemBarCPUOrder}_(leading)_________________ - // C | M \ \\ C \ - // | \ StoreN/P[mo_release] CastP2X - // | Bot \ / - // | MergeMem - // | / - // MemBarVolatile (card mark) - // C | || M | - // | LoadB | - // | | | - // | Cmp |\ - // | / | \ - // If | \ - // | \ | \ - // IfFalse IfTrue | \ - // \ / \ | \ - // \ / StoreCM | - // \ / | | - // Region . . . | - // | \ / - // | . . . \ / Bot - // | MergeMem - // | | - // {MemBarCPUOrder} - // MemBarVolatile (trailing) - // - // The first MergeMem merges the AliasIdxBot Mem slice from the - // leading membar and the oopptr Mem slice from the Store into the - // card mark membar. The trailing MergeMem merges the AliasIdxBot - // Mem slice from the card mark membar and the AliasIdxRaw slice - // from the StoreCM into the trailing membar (n.b. the latter - // proceeds via a Phi associated with the If region). - // - // The graph for a CAS varies slightly, the difference being - // that the StoreN/P node is replaced by a CompareAndSwapP/N node - // and the trailing MemBarVolatile by a MemBarCPUOrder + - // MemBarAcquire pair (also the MemBarCPUOrder nodes are not optional). - // - // MemBarRelease - // MemBarCPUOrder_(leading)_______________ - // C | M \ \\ C \ - // | \ CompareAndSwapN/P CastP2X - // | \ | - // | \ SCMemProj - // | Bot \ / - // | MergeMem - // | / - // MemBarVolatile (card mark) - // C | || M | - // | LoadB | - // | | | - // | Cmp |\ - // | / | \ - // If | \ - // | \ | \ - // IfFalse IfTrue | \ - // \ / \ | \ - // \ / StoreCM | - // \ / | | - // Region . . . | - // | \ / - // | . . . \ / Bot - // | MergeMem - // | | - // MemBarCPUOrder - // MemBarVolatile (trailing) - // - // - // G1 is quite a lot more complicated. The nodes inserted on behalf - // of G1 may comprise: a pre-write graph which adds the old value to - // the SATB queue; the releasing store itself; and, finally, a - // post-write graph which performs a card mark. - // - // The pre-write graph may be omitted, but only when the put is - // writing to a newly allocated (young gen) object and then only if - // there is a direct memory chain to the Initialize node for the - // object allocation. This will not happen for a volatile put since - // any memory chain passes through the leading membar. - // - // The pre-write graph includes a series of 3 If tests. The outermost - // If tests whether SATB is enabled (no else case). The next If tests - // whether the old value is non-NULL (no else case). The third tests - // whether the SATB queue index is > 0, if so updating the queue. The - // else case for this third If calls out to the runtime to allocate a - // new queue buffer. - // - // So with G1 the pre-write and releasing store subgraph looks like - // this (the nested Ifs are omitted). - // - // MemBarRelease - // {MemBarCPUOrder}_(leading)___________ - // C | || M \ M \ M \ M \ . . . - // | LoadB \ LoadL LoadN \ - // | / \ \ - // If |\ \ - // | \ | \ \ - // IfFalse IfTrue | \ \ - // | | | \ | - // | If | /\ | - // | | \ | - // | \ | - // | . . . \ | - // | / | / | | - // Region Phi[M] | | - // | \ | | | - // | \_____ | ___ | | - // C | C \ | C \ M | | - // | CastP2X | StoreN/P[mo_release] | - // | | | | - // C | M | M | M | - // \ | | / - // . . . - // (post write subtree elided) - // . . . - // C \ M / - // \ / - // {MemBarCPUOrder} - // MemBarVolatile (trailing) - // - // n.b. the LoadB in this subgraph is not the card read -- it's a - // read of the SATB queue active flag. - // - // The G1 post-write subtree is also optional, this time when the - // new value being written is either null or can be identified as a - // newly allocated (young gen) object with no intervening control - // flow. The latter cannot happen but the former may, in which case - // the card mark membar is omitted and the memory feeds form the - // leading membar and the SToreN/P are merged direct into the - // trailing membar as per the normal subgraph. So, the only special - // case which arises is when the post-write subgraph is generated. - // - // The kernel of the post-write G1 subgraph is the card mark itself - // which includes a card mark memory barrier (MemBarVolatile), a - // card test (LoadB), and a conditional update (If feeding a - // StoreCM). These nodes are surrounded by a series of nested Ifs - // which try to avoid doing the card mark. The top level If skips if - // the object reference does not cross regions (i.e. it tests if - // (adr ^ val) >> log2(regsize) != 0) -- intra-region references - // need not be recorded. The next If, which skips on a NULL value, - // may be absent (it is not generated if the type of value is >= - // OopPtr::NotNull). The 3rd If skips writes to young regions (by - // checking if card_val != young). n.b. although this test requires - // a pre-read of the card it can safely be done before the StoreLoad - // barrier. However that does not bypass the need to reread the card - // after the barrier. A final, 4th If tests if the card is already - // marked. - // - // (pre-write subtree elided) - // . . . . . . . . . . . . - // C | M | M | M | - // Region Phi[M] StoreN | - // | / \ | | - // / \_______ / \ | | - // C / C \ . . . \ | | - // If CastP2X . . . | | | - // / \ | | | - // / \ | | | - // IfFalse IfTrue | | | - // | | | | /| - // | If | | / | - // | / \ | | / | - // | / \ \ | / | - // | IfFalse IfTrue MergeMem | - // | . . . / \ / | - // | / \ / | - // | IfFalse IfTrue / | - // | . . . | / | - // | If / | - // | / \ / | - // | / \ / | - // | IfFalse IfTrue / | - // | . . . | / | - // | \ / | - // | \ / | - // | MemBarVolatile__(card mark) | - // | || C | M \ M \ | - // | LoadB If | | | - // | / \ | | | - // | . . . | | | - // | \ | | / - // | StoreCM | / - // | . . . | / - // | _________/ / - // | / _____________/ - // | . . . . . . | / / - // | | | / _________/ - // | | Phi[M] / / - // | | | / / - // | | | / / - // | Region . . . Phi[M] _____/ - // | / | / - // | | / - // | . . . . . . | / - // | / | / - // Region | | Phi[M] - // | | | / Bot - // \ MergeMem - // \ / - // {MemBarCPUOrder} - // MemBarVolatile - // - // As with CMS the initial MergeMem merges the AliasIdxBot Mem slice - // from the leading membar and the oopptr Mem slice from the Store - // into the card mark membar i.e. the memory flow to the card mark - // membar still looks like a normal graph. - // - // The trailing MergeMem merges an AliasIdxBot Mem slice with other - // Mem slices (from the StoreCM and other card mark queue stores). - // However in this case the AliasIdxBot Mem slice does not come - // direct from the card mark membar. It is merged through a series - // of Phi nodes. These are needed to merge the AliasIdxBot Mem flow - // from the leading membar with the Mem feed from the card mark - // membar. Each Phi corresponds to one of the Ifs which may skip - // around the card mark membar. So when the If implementing the NULL - // value check has been elided the total number of Phis is 2 - // otherwise it is 3. - // - // The CAS graph when using G1GC also includes a pre-write subgraph - // and an optional post-write subgraph. The same variations are - // introduced as for CMS with conditional card marking i.e. the - // StoreP/N is swapped for a CompareAndSwapP/N with a following - // SCMemProj, the trailing MemBarVolatile for a MemBarCPUOrder + - // MemBarAcquire pair. There may be an extra If test introduced in - // the CAS case, when the boolean result of the CAS is tested by the - // caller. In that case an extra Region and AliasIdxBot Phi may be - // introduced before the MergeMem - // - // So, the upshot is that in all cases the subgraph will include a - // *normal* memory subgraph betwen the leading membar and its child - // membar: either a normal volatile put graph including a releasing - // StoreX and terminating with a trailing volatile membar or card - // mark volatile membar; or a normal CAS graph including a - // CompareAndSwapX + SCMemProj pair and terminating with a card mark - // volatile membar or a trailing cpu order and acquire membar - // pair. If the child membar is not a (volatile) card mark membar - // then it marks the end of the volatile put or CAS subgraph. If the - // child is a card mark membar then the normal subgraph will form - // part of a larger volatile put or CAS subgraph if and only if the - // child feeds an AliasIdxBot Mem feed to a trailing barrier via a - // MergeMem. That feed is either direct (for CMS) or via 2, 3 or 4 - // Phi nodes merging the leading barrier memory flow (for G1). - // - // The predicates controlling generation of instructions for store - // and barrier nodes employ a few simple helper functions (described - // below) which identify the presence or absence of all these - // subgraph configurations and provide a means of traversing from - // one node in the subgraph to another. - // is_CAS(int opcode) // // return true if opcode is one of the possible CompareAndSwapX @@ -1893,691 +1281,24 @@ source %{ case Op_WeakCompareAndSwapI: case Op_WeakCompareAndSwapL: case Op_WeakCompareAndSwapP: - case Op_WeakCompareAndSwapN: - case Op_CompareAndExchangeB: - case Op_CompareAndExchangeS: - case Op_CompareAndExchangeI: - case Op_CompareAndExchangeL: - case Op_CompareAndExchangeP: - case Op_CompareAndExchangeN: - return false; - default: - return false; - } - } - - // helper to determine the maximum number of Phi nodes we may need to - // traverse when searching from a card mark membar for the merge mem - // feeding a trailing membar or vice versa - - int max_phis() - { - if (UseG1GC) { - return 4; - } else if (UseConcMarkSweepGC && UseCondCardMark) { - return 1; - } else { - return 0; - } - } - - // leading_to_normal - // - // graph traversal helper which detects the normal case Mem feed - // from a release membar (or, optionally, its cpuorder child) to a - // dependent volatile or acquire membar i.e. it ensures that one of - // the following 3 Mem flow subgraphs is present. - // - // MemBarRelease - // {MemBarCPUOrder} {leading} - // | \ . . . - // | StoreN/P[mo_release] . . . - // | / - // MergeMem - // | - // {MemBarCPUOrder} - // MemBarVolatile {trailing or card mark} - // - // MemBarRelease - // MemBarCPUOrder {leading} - // | \ . . . - // | CompareAndSwapX . . . - // | / - // MergeMem - // | - // MemBarVolatile {card mark} - // - // MemBarRelease - // MemBarCPUOrder {leading} - // | \ . . . - // | CompareAndSwapX . . . - // | / - // MergeMem - // | - // MemBarCPUOrder - // MemBarAcquire {trailing} - // - // if the correct configuration is present returns the trailing - // or cardmark membar otherwise NULL. - // - // the input membar is expected to be either a cpuorder membar or a - // release membar. in the latter case it should not have a cpu membar - // child. - // - // the returned value may be a card mark or trailing membar - // - - MemBarNode *leading_to_normal(MemBarNode *leading) - { - assert((leading->Opcode() == Op_MemBarRelease || - leading->Opcode() == Op_MemBarCPUOrder), - "expecting a volatile or cpuroder membar!"); - - // check the mem flow - ProjNode *mem = leading->proj_out(TypeFunc::Memory); - - if (!mem) { - return NULL; - } - - Node *x = NULL; - StoreNode * st = NULL; - LoadStoreNode *cas = NULL; - MergeMemNode *mm = NULL; - - for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { - x = mem->fast_out(i); - if (x->is_MergeMem()) { - if (mm != NULL) { - return NULL; - } - // two merge mems is one too many - mm = x->as_MergeMem(); - } else if (x->is_Store() && x->as_Store()->is_release() && x->Opcode() != Op_StoreCM) { - // two releasing stores/CAS nodes is one too many - if (st != NULL || cas != NULL) { - return NULL; - } - st = x->as_Store(); - } else if (is_CAS(x->Opcode())) { - if (st != NULL || cas != NULL) { - return NULL; - } - cas = x->as_LoadStore(); - } - } - - // must have a store or a cas - if (!st && !cas) { - return NULL; - } - - // must have a merge - if (!mm) { - return NULL; - } - - Node *feed = NULL; - if (cas) { - // look for an SCMemProj - for (DUIterator_Fast imax, i = cas->fast_outs(imax); i < imax; i++) { - x = cas->fast_out(i); - if (x->Opcode() == Op_SCMemProj) { - feed = x; - break; - } - } - if (feed == NULL) { - return NULL; - } - } else { - feed = st; - } - // ensure the feed node feeds the existing mergemem; - for (DUIterator_Fast imax, i = feed->fast_outs(imax); i < imax; i++) { - x = feed->fast_out(i); - if (x == mm) { - break; - } - } - if (x != mm) { - return NULL; - } - - MemBarNode *mbar = NULL; - // ensure the merge feeds to the expected type of membar - for (DUIterator_Fast imax, i = mm->fast_outs(imax); i < imax; i++) { - x = mm->fast_out(i); - if (x->is_MemBar()) { - if (x->Opcode() == Op_MemBarCPUOrder) { - // with a store any cpu order membar should precede a - // trailing volatile membar. with a cas it should precede a - // trailing acquire membar. in either case try to skip to - // that next membar - MemBarNode *y = x->as_MemBar(); - y = child_membar(y); - if (y != NULL) { - // skip to this new membar to do the check - x = y; - } - - } - if (x->Opcode() == Op_MemBarVolatile) { - mbar = x->as_MemBar(); - // for a volatile store this can be either a trailing membar - // or a card mark membar. for a cas it must be a card mark - // membar - guarantee(cas == NULL || is_card_mark_membar(mbar), - "in CAS graph volatile membar must be a card mark"); - } else if (cas != NULL && x->Opcode() == Op_MemBarAcquire) { - mbar = x->as_MemBar(); - } - break; - } - } - - return mbar; - } - - // normal_to_leading - // - // graph traversal helper which detects the normal case Mem feed - // from either a card mark or a trailing membar to a preceding - // release membar (optionally its cpuorder child) i.e. it ensures - // that one of the following 3 Mem flow subgraphs is present. - // - // MemBarRelease - // {MemBarCPUOrder} {leading} - // | \ . . . - // | StoreN/P[mo_release] . . . - // | / - // MergeMem - // | - // {MemBarCPUOrder} - // MemBarVolatile {trailing or card mark} - // - // MemBarRelease - // MemBarCPUOrder {leading} - // | \ . . . - // | CompareAndSwapX . . . - // | / - // MergeMem - // | - // MemBarVolatile {card mark} - // - // MemBarRelease - // MemBarCPUOrder {leading} - // | \ . . . - // | CompareAndSwapX . . . - // | / - // MergeMem - // | - // MemBarCPUOrder - // MemBarAcquire {trailing} - // - // this predicate checks for the same flow as the previous predicate - // but starting from the bottom rather than the top. - // - // if the configuration is present returns the cpuorder member for - // preference or when absent the release membar otherwise NULL. - // - // n.b. the input membar is expected to be a MemBarVolatile but - // need not be a card mark membar. - - MemBarNode *normal_to_leading(const MemBarNode *barrier) - { - // input must be a volatile membar - assert((barrier->Opcode() == Op_MemBarVolatile || - barrier->Opcode() == Op_MemBarAcquire), - "expecting a volatile or an acquire membar"); - bool barrier_is_acquire = barrier->Opcode() == Op_MemBarAcquire; - - // if we have an intervening cpu order membar then start the - // search from it - - Node *x = parent_membar(barrier); - - if (x == NULL) { - // stick with the original barrier - x = (Node *)barrier; - } else if (x->Opcode() != Op_MemBarCPUOrder) { - // any other barrier means this is not the graph we want - return NULL; - } - - // the Mem feed to the membar should be a merge - x = x ->in(TypeFunc::Memory); - if (!x->is_MergeMem()) - return NULL; - - MergeMemNode *mm = x->as_MergeMem(); - - // the merge should get its Bottom mem feed from the leading membar - x = mm->in(Compile::AliasIdxBot); - - // ensure this is a non control projection - if (!x->is_Proj() || x->is_CFG()) { - return NULL; - } - // if it is fed by a membar that's the one we want - x = x->in(0); - - if (!x->is_MemBar()) { - return NULL; - } - - MemBarNode *leading = x->as_MemBar(); - // reject invalid candidates - if (!leading_membar(leading)) { - return NULL; - } - - // ok, we have a leading membar, now for the sanity clauses - - // the leading membar must feed Mem to a releasing store or CAS - ProjNode *mem = leading->proj_out(TypeFunc::Memory); - StoreNode *st = NULL; - LoadStoreNode *cas = NULL; - for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { - x = mem->fast_out(i); - if (x->is_Store() && x->as_Store()->is_release() && x->Opcode() != Op_StoreCM) { - // two stores or CASes is one too many - if (st != NULL || cas != NULL) { - return NULL; - } - st = x->as_Store(); - } else if (is_CAS(x->Opcode())) { - if (st != NULL || cas != NULL) { - return NULL; - } - cas = x->as_LoadStore(); - } - } - - // we cannot have both a store and a cas - if (st == NULL && cas == NULL) { - // we have neither -- this is not a normal graph - return NULL; - } - if (st == NULL) { - // if we started from a volatile membar and found a CAS then the - // original membar ought to be for a card mark - guarantee((barrier_is_acquire || is_card_mark_membar(barrier)), - "unexpected volatile barrier (i.e. not card mark) in CAS graph"); - // check that the CAS feeds the merge we used to get here via an - // intermediary SCMemProj - Node *scmemproj = NULL; - for (DUIterator_Fast imax, i = cas->fast_outs(imax); i < imax; i++) { - x = cas->fast_out(i); - if (x->Opcode() == Op_SCMemProj) { - scmemproj = x; - break; - } - } - if (scmemproj == NULL) { - return NULL; - } - for (DUIterator_Fast imax, i = scmemproj->fast_outs(imax); i < imax; i++) { - x = scmemproj->fast_out(i); - if (x == mm) { - return leading; - } - } - } else { - // we should not have found a store if we started from an acquire - guarantee(!barrier_is_acquire, - "unexpected trailing acquire barrier in volatile store graph"); - - // the store should feed the merge we used to get here - for (DUIterator_Fast imax, i = st->fast_outs(imax); i < imax; i++) { - if (st->fast_out(i) == mm) { - return leading; - } - } - } - - return NULL; - } - - // card_mark_to_trailing - // - // graph traversal helper which detects extra, non-normal Mem feed - // from a card mark volatile membar to a trailing membar i.e. it - // ensures that one of the following three GC post-write Mem flow - // subgraphs is present. - // - // 1) - // . . . - // | - // MemBarVolatile (card mark) - // | | - // | StoreCM - // | | - // | . . . - // Bot | / - // MergeMem - // | - // {MemBarCPUOrder} OR MemBarCPUOrder - // MemBarVolatile {trailing} MemBarAcquire {trailing} - // - // - // 2) - // MemBarRelease/CPUOrder (leading) - // | - // | - // |\ . . . - // | \ | - // | \ MemBarVolatile (card mark) - // | \ | | - // \ \ | StoreCM . . . - // \ \ | - // \ Phi - // \ / - // Phi . . . - // Bot | / - // MergeMem - // | - // {MemBarCPUOrder} OR MemBarCPUOrder - // MemBarVolatile {trailing} MemBarAcquire {trailing} - // - // 3) - // MemBarRelease/CPUOrder (leading) - // | - // |\ - // | \ - // | \ . . . - // | \ | - // |\ \ MemBarVolatile (card mark) - // | \ \ | | - // | \ \ | StoreCM . . . - // | \ \ | - // \ \ Phi - // \ \ / - // \ Phi - // \ / - // Phi . . . - // Bot | / - // MergeMem - // | - // | - // {MemBarCPUOrder} OR MemBarCPUOrder - // MemBarVolatile {trailing} MemBarAcquire {trailing} - // - // 4) - // MemBarRelease/CPUOrder (leading) - // | - // |\ - // | \ - // | \ - // | \ - // |\ \ - // | \ \ - // | \ \ . . . - // | \ \ | - // |\ \ \ MemBarVolatile (card mark) - // | \ \ \ / | - // | \ \ \ / StoreCM . . . - // | \ \ Phi - // \ \ \ / - // \ \ Phi - // \ \ / - // \ Phi - // \ / - // Phi . . . - // Bot | / - // MergeMem - // | - // | - // MemBarCPUOrder - // MemBarAcquire {trailing} - // - // configuration 1 is only valid if UseConcMarkSweepGC && - // UseCondCardMark - // - // configuration 2, is only valid if UseConcMarkSweepGC && - // UseCondCardMark or if UseG1GC - // - // configurations 3 and 4 are only valid if UseG1GC. - // - // if a valid configuration is present returns the trailing membar - // otherwise NULL. - // - // n.b. the supplied membar is expected to be a card mark - // MemBarVolatile i.e. the caller must ensure the input node has the - // correct operand and feeds Mem to a StoreCM node - - MemBarNode *card_mark_to_trailing(const MemBarNode *barrier) - { - // input must be a card mark volatile membar - assert(is_card_mark_membar(barrier), "expecting a card mark membar"); - - Node *feed = barrier->proj_out(TypeFunc::Memory); - Node *x; - MergeMemNode *mm = NULL; - - const int MAX_PHIS = max_phis(); // max phis we will search through - int phicount = 0; // current search count - - bool retry_feed = true; - while (retry_feed) { - // see if we have a direct MergeMem feed - for (DUIterator_Fast imax, i = feed->fast_outs(imax); i < imax; i++) { - x = feed->fast_out(i); - // the correct Phi will be merging a Bot memory slice - if (x->is_MergeMem()) { - mm = x->as_MergeMem(); - break; - } - } - if (mm) { - retry_feed = false; - } else if (phicount++ < MAX_PHIS) { - // the barrier may feed indirectly via one or two Phi nodes - PhiNode *phi = NULL; - for (DUIterator_Fast imax, i = feed->fast_outs(imax); i < imax; i++) { - x = feed->fast_out(i); - // the correct Phi will be merging a Bot memory slice - if (x->is_Phi() && x->adr_type() == TypePtr::BOTTOM) { - phi = x->as_Phi(); - break; - } - } - if (!phi) { - return NULL; - } - // look for another merge below this phi - feed = phi; - } else { - // couldn't find a merge - return NULL; - } - } - - // sanity check this feed turns up as the expected slice - guarantee(mm->as_MergeMem()->in(Compile::AliasIdxBot) == feed, "expecting membar to feed AliasIdxBot slice to Merge"); - - MemBarNode *trailing = NULL; - // be sure we have a trailing membar fed by the merge - for (DUIterator_Fast imax, i = mm->fast_outs(imax); i < imax; i++) { - x = mm->fast_out(i); - if (x->is_MemBar()) { - // if this is an intervening cpu order membar skip to the - // following membar - if (x->Opcode() == Op_MemBarCPUOrder) { - MemBarNode *y = x->as_MemBar(); - y = child_membar(y); - if (y != NULL) { - x = y; - } - } - if (x->Opcode() == Op_MemBarVolatile || - x->Opcode() == Op_MemBarAcquire) { - trailing = x->as_MemBar(); - } - break; - } - } - - return trailing; - } - - // trailing_to_card_mark - // - // graph traversal helper which detects extra, non-normal Mem feed - // from a trailing volatile membar to a preceding card mark volatile - // membar i.e. it identifies whether one of the three possible extra - // GC post-write Mem flow subgraphs is present - // - // this predicate checks for the same flow as the previous predicate - // but starting from the bottom rather than the top. - // - // if the configuration is present returns the card mark membar - // otherwise NULL - // - // n.b. the supplied membar is expected to be a trailing - // MemBarVolatile or MemBarAcquire i.e. the caller must ensure the - // input node has the correct opcode - - MemBarNode *trailing_to_card_mark(const MemBarNode *trailing) - { - assert(trailing->Opcode() == Op_MemBarVolatile || - trailing->Opcode() == Op_MemBarAcquire, - "expecting a volatile or acquire membar"); - assert(!is_card_mark_membar(trailing), - "not expecting a card mark membar"); - - Node *x = (Node *)trailing; - - // look for a preceding cpu order membar - MemBarNode *y = parent_membar(x->as_MemBar()); - if (y != NULL) { - // make sure it is a cpu order membar - if (y->Opcode() != Op_MemBarCPUOrder) { - // this is nto the graph we were looking for - return NULL; - } - // start the search from here - x = y; - } - - // the Mem feed to the membar should be a merge - x = x->in(TypeFunc::Memory); - if (!x->is_MergeMem()) { - return NULL; - } - - MergeMemNode *mm = x->as_MergeMem(); - - x = mm->in(Compile::AliasIdxBot); - // with G1 we may possibly see a Phi or two before we see a Memory - // Proj from the card mark membar - - const int MAX_PHIS = max_phis(); // max phis we will search through - int phicount = 0; // current search count - - bool retry_feed = !x->is_Proj(); - - while (retry_feed) { - if (x->is_Phi() && phicount++ < MAX_PHIS) { - PhiNode *phi = x->as_Phi(); - ProjNode *proj = NULL; - PhiNode *nextphi = NULL; - bool found_leading = false; - for (uint i = 1; i < phi->req(); i++) { - x = phi->in(i); - if (x->is_Phi() && x->adr_type() == TypePtr::BOTTOM) { - nextphi = x->as_Phi(); - } else if (x->is_Proj()) { - int opcode = x->in(0)->Opcode(); - if (opcode == Op_MemBarVolatile) { - proj = x->as_Proj(); - } else if (opcode == Op_MemBarRelease || - opcode == Op_MemBarCPUOrder) { - // probably a leading membar - found_leading = true; - } - } - } - // if we found a correct looking proj then retry from there - // otherwise we must see a leading and a phi or this the - // wrong config - if (proj != NULL) { - x = proj; - retry_feed = false; - } else if (found_leading && nextphi != NULL) { - // retry from this phi to check phi2 - x = nextphi; - } else { - // not what we were looking for - return NULL; - } - } else { - return NULL; - } - } - // the proj has to come from the card mark membar - x = x->in(0); - if (!x->is_MemBar()) { - return NULL; - } - - MemBarNode *card_mark_membar = x->as_MemBar(); - - if (!is_card_mark_membar(card_mark_membar)) { - return NULL; - } - - return card_mark_membar; - } - - // trailing_to_leading - // - // graph traversal helper which checks the Mem flow up the graph - // from a (non-card mark) trailing membar attempting to locate and - // return an associated leading membar. it first looks for a - // subgraph in the normal configuration (relying on helper - // normal_to_leading). failing that it then looks for one of the - // possible post-write card mark subgraphs linking the trailing node - // to a the card mark membar (relying on helper - // trailing_to_card_mark), and then checks that the card mark membar - // is fed by a leading membar (once again relying on auxiliary - // predicate normal_to_leading). - // - // if the configuration is valid returns the cpuorder member for - // preference or when absent the release membar otherwise NULL. - // - // n.b. the input membar is expected to be either a volatile or - // acquire membar but in the former case must *not* be a card mark - // membar. - - MemBarNode *trailing_to_leading(const MemBarNode *trailing) - { - assert((trailing->Opcode() == Op_MemBarAcquire || - trailing->Opcode() == Op_MemBarVolatile), - "expecting an acquire or volatile membar"); - assert((trailing->Opcode() != Op_MemBarVolatile || - !is_card_mark_membar(trailing)), - "not expecting a card mark membar"); - - MemBarNode *leading = normal_to_leading(trailing); - - if (leading) { - return leading; - } - - // there is no normal path from trailing to leading membar. see if - // we can arrive via a card mark membar - - MemBarNode *card_mark_membar = trailing_to_card_mark(trailing); - - if (!card_mark_membar) { - return NULL; + case Op_WeakCompareAndSwapN: + case Op_CompareAndExchangeB: + case Op_CompareAndExchangeS: + case Op_CompareAndExchangeI: + case Op_CompareAndExchangeL: + case Op_CompareAndExchangeP: + case Op_CompareAndExchangeN: + return false; + default: + return false; } - - return normal_to_leading(card_mark_membar); } - // predicates controlling emit of ldr/ldar and associated dmb + // helper to determine the maximum number of Phi nodes we may need to + // traverse when searching from a card mark membar for the merge mem + // feeding a trailing membar or vice versa + +// predicates controlling emit of ldr/ldar and associated dmb bool unnecessary_acquire(const Node *barrier) { @@ -2588,40 +1309,19 @@ bool unnecessary_acquire(const Node *barrier) return false; } - // a volatile read derived from bytecode (or also from an inlined - // SHA field read via LibraryCallKit::load_field_from_object) - // manifests as a LoadX[mo_acquire] followed by an acquire membar - // with a bogus read dependency on it's preceding load. so in those - // cases we will find the load node at the PARMS offset of the - // acquire membar. n.b. there may be an intervening DecodeN node. - - Node *x = barrier->lookup(TypeFunc::Parms); - if (x) { - // we are starting from an acquire and it has a fake dependency - // - // need to check for - // - // LoadX[mo_acquire] - // { |1 } - // {DecodeN} - // |Parms - // MemBarAcquire* - // - // where * tags node we were passed - // and |k means input k - if (x->is_DecodeNarrowPtr()) { - x = x->in(1); - } + MemBarNode* mb = barrier->as_MemBar(); - return (x->is_Load() && x->as_Load()->is_acquire()); + if (mb->trailing_load()) { + return true; } - // other option for unnecessary membar is that it is a trailing node - // belonging to a CAS - - MemBarNode *leading = trailing_to_leading(barrier->as_MemBar()); + if (mb->trailing_load_store()) { + Node* load_store = mb->in(MemBarNode::Precedent); + assert(load_store->is_LoadStore(), "unexpected graph shape"); + return is_CAS(load_store->Opcode()); + } - return leading != NULL; + return false; } bool needs_acquiring_load(const Node *n) @@ -2634,45 +1334,7 @@ bool needs_acquiring_load(const Node *n) LoadNode *ld = n->as_Load(); - if (!ld->is_acquire()) { - return false; - } - - // check if this load is feeding an acquire membar - // - // LoadX[mo_acquire] - // { |1 } - // {DecodeN} - // |Parms - // MemBarAcquire* - // - // where * tags node we were passed - // and |k means input k - - Node *start = ld; - Node *mbacq = NULL; - - // if we hit a DecodeNarrowPtr we reset the start node and restart - // the search through the outputs - restart: - - for (DUIterator_Fast imax, i = start->fast_outs(imax); i < imax; i++) { - Node *x = start->fast_out(i); - if (x->is_MemBar() && x->Opcode() == Op_MemBarAcquire) { - mbacq = x; - } else if (!mbacq && - (x->is_DecodeNarrowPtr() || - (x->is_Mach() && x->Opcode() == Op_DecodeN))) { - start = x; - goto restart; - } - } - - if (mbacq) { - return true; - } - - return false; + return ld->is_acquire(); } bool unnecessary_release(const Node *n) @@ -2686,32 +1348,27 @@ bool unnecessary_release(const Node *n) return false; } - // if there is a dependent CPUOrder barrier then use that as the - // leading - MemBarNode *barrier = n->as_MemBar(); - // check for an intervening cpuorder membar - MemBarNode *b = child_membar(barrier); - if (b && b->Opcode() == Op_MemBarCPUOrder) { - // ok, so start the check from the dependent cpuorder barrier - barrier = b; - } - - // must start with a normal feed - MemBarNode *child_barrier = leading_to_normal(barrier); - - if (!child_barrier) { + if (!barrier->leading()) { return false; + } else { + Node* trailing = barrier->trailing_membar(); + MemBarNode* trailing_mb = trailing->as_MemBar(); + assert(trailing_mb->trailing(), "Not a trailing membar?"); + assert(trailing_mb->leading_membar() == n, "inconsistent leading/trailing membars"); + + Node* mem = trailing_mb->in(MemBarNode::Precedent); + if (mem->is_Store()) { + assert(mem->as_Store()->is_release(), ""); + assert(trailing_mb->Opcode() == Op_MemBarVolatile, ""); + return true; + } else { + assert(mem->is_LoadStore(), ""); + assert(trailing_mb->Opcode() == Op_MemBarAcquire, ""); + return is_CAS(mem->Opcode()); + } } - - if (!is_card_mark_membar(child_barrier)) { - // this is the trailing membar and we are done - return true; - } - - // must be sure this card mark feeds a trailing membar - MemBarNode *trailing = card_mark_to_trailing(child_barrier); - return (trailing != NULL); + return false; } bool unnecessary_volatile(const Node *n) @@ -2724,17 +1381,18 @@ bool unnecessary_volatile(const Node *n) MemBarNode *mbvol = n->as_MemBar(); - // first we check if this is part of a card mark. if so then we have - // to generate a StoreLoad barrier - - if (is_card_mark_membar(mbvol)) { - return false; + bool release = mbvol->trailing_store(); + assert(!release || (mbvol->in(MemBarNode::Precedent)->is_Store() && mbvol->in(MemBarNode::Precedent)->as_Store()->is_release()), ""); +#ifdef ASSERT + if (release) { + Node* leading = mbvol->leading_membar(); + assert(leading->Opcode() == Op_MemBarRelease, ""); + assert(leading->as_MemBar()->leading_store(), ""); + assert(leading->as_MemBar()->trailing_membar() == mbvol, ""); } +#endif - // ok, if it's not a card mark then we still need to check if it is - // a trailing membar of a volatile put graph. - - return (trailing_to_leading(mbvol) != NULL); + return release; } // predicates controlling emit of str/stlr and associated dmbs @@ -2749,53 +1407,7 @@ bool needs_releasing_store(const Node *n) StoreNode *st = n->as_Store(); - // the store must be marked as releasing - if (!st->is_release()) { - return false; - } - - // the store must be fed by a membar - - Node *x = st->lookup(StoreNode::Memory); - - if (! x || !x->is_Proj()) { - return false; - } - - ProjNode *proj = x->as_Proj(); - - x = proj->lookup(0); - - if (!x || !x->is_MemBar()) { - return false; - } - - MemBarNode *barrier = x->as_MemBar(); - - // if the barrier is a release membar or a cpuorder mmebar fed by a - // release membar then we need to check whether that forms part of a - // volatile put graph. - - // reject invalid candidates - if (!leading_membar(barrier)) { - return false; - } - - // does this lead a normal subgraph? - MemBarNode *mbvol = leading_to_normal(barrier); - - if (!mbvol) { - return false; - } - - // all done unless this is a card mark - if (!is_card_mark_membar(mbvol)) { - return true; - } - - // we found a card mark -- just make sure we have a trailing barrier - - return (card_mark_to_trailing(mbvol) != NULL); + return st->trailing_membar() != NULL; } // predicate controlling translation of CAS @@ -2809,48 +1421,9 @@ bool needs_acquiring_load_exclusive(const Node *n) return false; } - // CAS nodes only ought to turn up in inlined unsafe CAS operations -#ifdef ASSERT - LoadStoreNode *st = n->as_LoadStore(); - - // the store must be fed by a membar - - Node *x = st->lookup(StoreNode::Memory); - - assert (x && x->is_Proj(), "CAS not fed by memory proj!"); - - ProjNode *proj = x->as_Proj(); - - x = proj->lookup(0); - - assert (x && x->is_MemBar(), "CAS not fed by membar!"); - - MemBarNode *barrier = x->as_MemBar(); - - // the barrier must be a cpuorder mmebar fed by a release membar - - guarantee(barrier->Opcode() == Op_MemBarCPUOrder, - "CAS not fed by cpuorder membar!"); - - MemBarNode *b = parent_membar(barrier); - assert ((b != NULL && b->Opcode() == Op_MemBarRelease), - "CAS not fed by cpuorder+release membar pair!"); - - // does this lead a normal subgraph? - MemBarNode *mbar = leading_to_normal(barrier); - - guarantee(mbar != NULL, "CAS not embedded in normal graph!"); - - // if this is a card mark membar check we have a trailing acquire - - if (is_card_mark_membar(mbar)) { - mbar = card_mark_to_trailing(mbar); - } - - guarantee(mbar != NULL, "card mark membar for CAS not embedded in normal graph!"); + LoadStoreNode* ldst = n->as_LoadStore(); + assert(ldst->trailing_membar() != NULL, "expected trailing membar"); - guarantee(mbar->Opcode() == Op_MemBarAcquire, "trailing membar should be an acquire"); -#endif // ASSERT // so we can just return true here return true; } @@ -2914,7 +1487,7 @@ int MachCallRuntimeNode::ret_addr_offset() { // adr(rscratch2, retaddr) // lea(rscratch1, RuntimeAddress(addr) // stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize))) - // blrt rscratch1 + // blr(rscratch1) CodeBlob *cb = CodeCache::find_blob(_entry_point); if (cb) { return MacroAssembler::far_branch_size(); @@ -3039,10 +1612,6 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { __ build_frame(framesize); - if (NotifySimulator) { - __ notify(Assembler::method_entry); - } - if (VerifyStackAtCalls) { Unimplemented(); } @@ -3103,10 +1672,6 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { __ remove_frame(framesize); - if (NotifySimulator) { - __ notify(Assembler::method_reentry); - } - if (StackReservedPages > 0 && C->has_reserved_stack_access()) { __ reserved_stack_check(); } @@ -3545,7 +2110,12 @@ const uint Matcher::vector_ideal_reg(int len) { } const uint Matcher::vector_shift_count_ideal_reg(int size) { - return Op_VecX; + switch(size) { + case 8: return Op_VecD; + case 16: return Op_VecX; + } + ShouldNotReachHere(); + return 0; } // AES support not yet implemented @@ -3553,9 +2123,9 @@ const bool Matcher::pass_original_key_for_aes() { return false; } -// x86 supports misaligned vectors store/load. +// aarch64 supports misaligned vectors store/load. const bool Matcher::misaligned_vectors_ok() { - return !AlignVector; // can be changed by flag + return true; } // false => size gets scaled to BytesPerLong, ok. @@ -3763,47 +2333,6 @@ bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, Ve void Compile::reshape_address(AddPNode* addp) { } -// helper for encoding java_to_runtime calls on sim -// -// this is needed to compute the extra arguments required when -// planting a call to the simulator blrt instruction. the TypeFunc -// can be queried to identify the counts for integral, and floating -// arguments and the return type - -static void getCallInfo(const TypeFunc *tf, int &gpcnt, int &fpcnt, int &rtype) -{ - int gps = 0; - int fps = 0; - const TypeTuple *domain = tf->domain(); - int max = domain->cnt(); - for (int i = TypeFunc::Parms; i < max; i++) { - const Type *t = domain->field_at(i); - switch(t->basic_type()) { - case T_FLOAT: - case T_DOUBLE: - fps++; - default: - gps++; - } - } - gpcnt = gps; - fpcnt = fps; - BasicType rt = tf->return_type(); - switch (rt) { - case T_VOID: - rtype = MacroAssembler::ret_type_void; - break; - default: - rtype = MacroAssembler::ret_type_integral; - break; - case T_FLOAT: - rtype = MacroAssembler::ret_type_float; - break; - case T_DOUBLE: - rtype = MacroAssembler::ret_type_double; - break; - } -} #define MOV_VOLATILE(REG, BASE, INDEX, SCALE, DISP, SCRATCH, INSN) \ MacroAssembler _masm(&cbuf); \ @@ -4738,7 +3267,7 @@ encode %{ // some calls to generated routines (arraycopy code) are scheduled // by C2 as runtime calls. if so we can call them using a br (they - // will be in a reachable segment) otherwise we have to use a blrt + // will be in a reachable segment) otherwise we have to use a blr // which loads the absolute address into a register. address entry = (address)$meth$$method; CodeBlob *cb = CodeCache::find_blob(entry); @@ -4749,16 +3278,12 @@ encode %{ return; } } else { - int gpcnt; - int fpcnt; - int rtype; - getCallInfo(tf(), gpcnt, fpcnt, rtype); Label retaddr; __ adr(rscratch2, retaddr); __ lea(rscratch1, RuntimeAddress(entry)); // Leave a breadcrumb for JavaFrameAnchor::capture_last_Java_pc() __ stp(zr, rscratch2, Address(__ pre(sp, -2 * wordSize))); - __ blrt(rscratch1, gpcnt, fpcnt, rtype); + __ blr(rscratch1); __ bind(retaddr); __ add(sp, sp, 2 * wordSize); } @@ -4815,39 +3340,23 @@ encode %{ __ biased_locking_enter(box, oop, disp_hdr, tmp, true, cont); } - // Handle existing monitor + // Check for existing monitor if ((EmitSync & 0x02) == 0) { __ tbnz(disp_hdr, exact_log2(markOopDesc::monitor_value), object_has_monitor); } - // Set displaced_header to be (markOop of object | UNLOCK_VALUE). - __ orr(disp_hdr, disp_hdr, markOopDesc::unlocked_value); - - // Load Compare Value application register. + // Set tmp to be (markOop of object | UNLOCK_VALUE). + __ orr(tmp, disp_hdr, markOopDesc::unlocked_value); // Initialize the box. (Must happen before we update the object mark!) - __ str(disp_hdr, Address(box, BasicLock::displaced_header_offset_in_bytes())); - - // Compare object markOop with mark and if equal exchange scratch1 - // with object markOop. - if (UseLSE) { - __ mov(tmp, disp_hdr); - __ casal(Assembler::xword, tmp, box, oop); - __ cmp(tmp, disp_hdr); - __ br(Assembler::EQ, cont); - } else { - Label retry_load; - if ((VM_Version::features() & VM_Version::CPU_STXR_PREFETCH)) - __ prfm(Address(oop), PSTL1STRM); - __ bind(retry_load); - __ ldaxr(tmp, oop); - __ cmp(tmp, disp_hdr); - __ br(Assembler::NE, cas_failed); - // use stlxr to ensure update is immediately visible - __ stlxr(tmp, box, oop); - __ cbzw(tmp, cont); - __ b(retry_load); - } + __ str(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes())); + + // Compare object markOop with an unlocked value (tmp) and if + // equal exchange the stack address of our box with object markOop. + // On failure disp_hdr contains the possibly locked markOop. + __ cmpxchg(oop, tmp, box, Assembler::xword, /*acquire*/ true, + /*release*/ true, /*weak*/ false, disp_hdr); + __ br(Assembler::EQ, cont); assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); @@ -4861,41 +3370,24 @@ encode %{ // markOop of object (disp_hdr) with the stack pointer. __ mov(rscratch1, sp); __ sub(disp_hdr, disp_hdr, rscratch1); - __ mov(tmp, (address) (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place)); + __ mov(tmp, (address) (~(os::vm_page_size()-1) | (uintptr_t)markOopDesc::lock_mask_in_place)); // If condition is true we are cont and hence we can store 0 as the // displaced header in the box, which indicates that it is a recursive lock. - __ ands(tmp/*==0?*/, disp_hdr, tmp); + __ ands(tmp/*==0?*/, disp_hdr, tmp); // Sets flags for result __ str(tmp/*==0, perhaps*/, Address(box, BasicLock::displaced_header_offset_in_bytes())); - // Handle existing monitor. if ((EmitSync & 0x02) == 0) { __ b(cont); + // Handle existing monitor. __ bind(object_has_monitor); // The object's monitor m is unlocked iff m->owner == NULL, // otherwise m->owner may contain a thread or a stack address. // // Try to CAS m->owner from NULL to current thread. __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value)); - __ mov(disp_hdr, zr); - - if (UseLSE) { - __ mov(rscratch1, disp_hdr); - __ casal(Assembler::xword, rscratch1, rthread, tmp); - __ cmp(rscratch1, disp_hdr); - } else { - Label retry_load, fail; - if ((VM_Version::features() & VM_Version::CPU_STXR_PREFETCH)) - __ prfm(Address(tmp), PSTL1STRM); - __ bind(retry_load); - __ ldaxr(rscratch1, tmp); - __ cmp(disp_hdr, rscratch1); - __ br(Assembler::NE, fail); - // use stlxr to ensure update is immediately visible - __ stlxr(rscratch1, rthread, tmp); - __ cbnzw(rscratch1, retry_load); - __ bind(fail); - } + __ cmpxchg(tmp, zr, rthread, Assembler::xword, /*acquire*/ true, + /*release*/ true, /*weak*/ false, noreg); // Sets flags for result // Store a non-null value into the box to avoid looking like a re-entrant // lock. The fast-path monitor unlock code checks for @@ -4948,24 +3440,9 @@ encode %{ // see the stack address of the basicLock in the markOop of the // object. - if (UseLSE) { - __ mov(tmp, box); - __ casl(Assembler::xword, tmp, disp_hdr, oop); - __ cmp(tmp, box); - __ b(cont); - } else { - Label retry_load; - if ((VM_Version::features() & VM_Version::CPU_STXR_PREFETCH)) - __ prfm(Address(oop), PSTL1STRM); - __ bind(retry_load); - __ ldxr(tmp, oop); - __ cmp(box, tmp); - __ br(Assembler::NE, cont); - // use stlxr to ensure update is immediately visible - __ stlxr(tmp, disp_hdr, oop); - __ cbzw(tmp, cont); - __ b(retry_load); - } + __ cmpxchg(oop, box, disp_hdr, Assembler::xword, /*acquire*/ false, + /*release*/ true, /*weak*/ false, tmp); + __ b(cont); assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); @@ -4977,13 +3454,13 @@ encode %{ __ ldr(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes())); __ eor(rscratch1, rscratch1, rthread); // Will be 0 if we are the owner. __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if there are 0 recursions - __ cmp(rscratch1, zr); + __ cmp(rscratch1, zr); // Sets flags for result __ br(Assembler::NE, cont); __ ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset_in_bytes())); __ ldr(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset_in_bytes())); __ orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if both are 0. - __ cmp(rscratch1, zr); + __ cmp(rscratch1, zr); // Sets flags for result __ cbnz(rscratch1, cont); // need a release store here __ lea(tmp, Address(tmp, ObjectMonitor::owner_offset_in_bytes())); @@ -17474,32 +15951,32 @@ instruct vxor16B(vecX dst, vecX src1, vecX src2) %} // ------------------------------ Shift --------------------------------------- - -instruct vshiftcntL(vecX dst, iRegIorL2I cnt) %{ +instruct vshiftcnt8B(vecD dst, iRegIorL2I cnt) %{ + predicate(n->as_Vector()->length_in_bytes() == 8); match(Set dst (LShiftCntV cnt)); - format %{ "dup $dst, $cnt\t# shift count (vecX)" %} + match(Set dst (RShiftCntV cnt)); + format %{ "dup $dst, $cnt\t# shift count vector (8B)" %} ins_encode %{ - __ dup(as_FloatRegister($dst$$reg), __ T16B, as_Register($cnt$$reg)); + __ dup(as_FloatRegister($dst$$reg), __ T8B, as_Register($cnt$$reg)); %} - ins_pipe(vdup_reg_reg128); + ins_pipe(vdup_reg_reg64); %} -// Right shifts on aarch64 SIMD are implemented as left shift by -ve amount -instruct vshiftcntR(vecX dst, iRegIorL2I cnt) %{ +instruct vshiftcnt16B(vecX dst, iRegIorL2I cnt) %{ + predicate(n->as_Vector()->length_in_bytes() == 16); + match(Set dst (LShiftCntV cnt)); match(Set dst (RShiftCntV cnt)); - format %{ "dup $dst, $cnt\t# shift count (vecX)\n\tneg $dst, $dst\t T16B" %} + format %{ "dup $dst, $cnt\t# shift count vector (16B)" %} ins_encode %{ __ dup(as_FloatRegister($dst$$reg), __ T16B, as_Register($cnt$$reg)); - __ negr(as_FloatRegister($dst$$reg), __ T16B, as_FloatRegister($dst$$reg)); %} ins_pipe(vdup_reg_reg128); %} -instruct vsll8B(vecD dst, vecD src, vecX shift) %{ +instruct vsll8B(vecD dst, vecD src, vecD shift) %{ predicate(n->as_Vector()->length() == 4 || n->as_Vector()->length() == 8); match(Set dst (LShiftVB src shift)); - match(Set dst (RShiftVB src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (8B)" %} ins_encode %{ @@ -17513,7 +15990,6 @@ instruct vsll8B(vecD dst, vecD src, vecX shift) %{ instruct vsll16B(vecX dst, vecX src, vecX shift) %{ predicate(n->as_Vector()->length() == 16); match(Set dst (LShiftVB src shift)); - match(Set dst (RShiftVB src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (16B)" %} ins_encode %{ @@ -17524,29 +16000,93 @@ instruct vsll16B(vecX dst, vecX src, vecX shift) %{ ins_pipe(vshift128); %} -instruct vsrl8B(vecD dst, vecD src, vecX shift) %{ +// Right shifts with vector shift count on aarch64 SIMD are implemented +// as left shift by negative shift count. +// There are two cases for vector shift count. +// +// Case 1: The vector shift count is from replication. +// | | +// LoadVector RShiftCntV +// | / +// RShiftVI +// Note: In inner loop, multiple neg instructions are used, which can be +// moved to outer loop and merge into one neg instruction. +// +// Case 2: The vector shift count is from loading. +// This case isn't supported by middle-end now. But it's supported by +// panama/vectorIntrinsics(JEP 338: Vector API). +// | | +// LoadVector LoadVector +// | / +// RShiftVI +// + +instruct vsra8B(vecD dst, vecD src, vecD shift, vecD tmp) %{ + predicate(n->as_Vector()->length() == 4 || + n->as_Vector()->length() == 8); + match(Set dst (RShiftVB src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (8B)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T8B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T8B, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift64); +%} + +instruct vsra16B(vecX dst, vecX src, vecX shift, vecX tmp) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (RShiftVB src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (16B)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T16B, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift128); +%} + +instruct vsrl8B(vecD dst, vecD src, vecD shift, vecD tmp) %{ predicate(n->as_Vector()->length() == 4 || n->as_Vector()->length() == 8); match(Set dst (URShiftVB src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (8B)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (8B)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T8B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T8B, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift64); %} -instruct vsrl16B(vecX dst, vecX src, vecX shift) %{ +instruct vsrl16B(vecX dst, vecX src, vecX shift, vecX tmp) %{ predicate(n->as_Vector()->length() == 16); match(Set dst (URShiftVB src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (16B)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (16B)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T16B, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift128); %} @@ -17658,11 +16198,10 @@ instruct vsrl16B_imm(vecX dst, vecX src, immI shift) %{ ins_pipe(vshift128_imm); %} -instruct vsll4S(vecD dst, vecD src, vecX shift) %{ +instruct vsll4S(vecD dst, vecD src, vecD shift) %{ predicate(n->as_Vector()->length() == 2 || n->as_Vector()->length() == 4); match(Set dst (LShiftVS src shift)); - match(Set dst (RShiftVS src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (4H)" %} ins_encode %{ @@ -17676,7 +16215,6 @@ instruct vsll4S(vecD dst, vecD src, vecX shift) %{ instruct vsll8S(vecX dst, vecX src, vecX shift) %{ predicate(n->as_Vector()->length() == 8); match(Set dst (LShiftVS src shift)); - match(Set dst (RShiftVS src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (8H)" %} ins_encode %{ @@ -17687,29 +16225,72 @@ instruct vsll8S(vecX dst, vecX src, vecX shift) %{ ins_pipe(vshift128); %} -instruct vsrl4S(vecD dst, vecD src, vecX shift) %{ +instruct vsra4S(vecD dst, vecD src, vecD shift, vecD tmp) %{ + predicate(n->as_Vector()->length() == 2 || + n->as_Vector()->length() == 4); + match(Set dst (RShiftVS src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (4H)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T8B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T4H, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift64); +%} + +instruct vsra8S(vecX dst, vecX src, vecX shift, vecX tmp) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (RShiftVS src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (8H)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T8H, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift128); +%} + +instruct vsrl4S(vecD dst, vecD src, vecD shift, vecD tmp) %{ predicate(n->as_Vector()->length() == 2 || n->as_Vector()->length() == 4); match(Set dst (URShiftVS src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (4H)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (4H)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T8B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T4H, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift64); %} -instruct vsrl8S(vecX dst, vecX src, vecX shift) %{ +instruct vsrl8S(vecX dst, vecX src, vecX shift, vecX tmp) %{ predicate(n->as_Vector()->length() == 8); match(Set dst (URShiftVS src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (8H)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (8H)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T8H, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift128); %} @@ -17821,10 +16402,9 @@ instruct vsrl8S_imm(vecX dst, vecX src, immI shift) %{ ins_pipe(vshift128_imm); %} -instruct vsll2I(vecD dst, vecD src, vecX shift) %{ +instruct vsll2I(vecD dst, vecD src, vecD shift) %{ predicate(n->as_Vector()->length() == 2); match(Set dst (LShiftVI src shift)); - match(Set dst (RShiftVI src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (2S)" %} ins_encode %{ @@ -17838,7 +16418,6 @@ instruct vsll2I(vecD dst, vecD src, vecX shift) %{ instruct vsll4I(vecX dst, vecX src, vecX shift) %{ predicate(n->as_Vector()->length() == 4); match(Set dst (LShiftVI src shift)); - match(Set dst (RShiftVI src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (4S)" %} ins_encode %{ @@ -17849,28 +16428,70 @@ instruct vsll4I(vecX dst, vecX src, vecX shift) %{ ins_pipe(vshift128); %} -instruct vsrl2I(vecD dst, vecD src, vecX shift) %{ +instruct vsra2I(vecD dst, vecD src, vecD shift, vecD tmp) %{ + predicate(n->as_Vector()->length() == 2); + match(Set dst (RShiftVI src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (2S)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T8B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T2S, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift64); +%} + +instruct vsra4I(vecX dst, vecX src, vecX shift, vecX tmp) %{ + predicate(n->as_Vector()->length() == 4); + match(Set dst (RShiftVI src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (4S)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T4S, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift128); +%} + +instruct vsrl2I(vecD dst, vecD src, vecD shift, vecD tmp) %{ predicate(n->as_Vector()->length() == 2); match(Set dst (URShiftVI src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (2S)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (2S)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T8B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T2S, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift64); %} -instruct vsrl4I(vecX dst, vecX src, vecX shift) %{ +instruct vsrl4I(vecX dst, vecX src, vecX shift, vecX tmp) %{ predicate(n->as_Vector()->length() == 4); match(Set dst (URShiftVI src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (4S)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (4S)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T4S, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift128); %} @@ -17956,7 +16577,6 @@ instruct vsrl4I_imm(vecX dst, vecX src, immI shift) %{ instruct vsll2L(vecX dst, vecX src, vecX shift) %{ predicate(n->as_Vector()->length() == 2); match(Set dst (LShiftVL src shift)); - match(Set dst (RShiftVL src shift)); ins_cost(INSN_COST); format %{ "sshl $dst,$src,$shift\t# vector (2D)" %} ins_encode %{ @@ -17967,15 +16587,36 @@ instruct vsll2L(vecX dst, vecX src, vecX shift) %{ ins_pipe(vshift128); %} -instruct vsrl2L(vecX dst, vecX src, vecX shift) %{ +instruct vsra2L(vecX dst, vecX src, vecX shift, vecX tmp) %{ + predicate(n->as_Vector()->length() == 2); + match(Set dst (RShiftVL src shift)); + ins_cost(INSN_COST); + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "sshl $dst,$src,$tmp\t# vector (2D)" %} + ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); + __ sshl(as_FloatRegister($dst$$reg), __ T2D, + as_FloatRegister($src$$reg), + as_FloatRegister($tmp$$reg)); + %} + ins_pipe(vshift128); +%} + +instruct vsrl2L(vecX dst, vecX src, vecX shift, vecX tmp) %{ predicate(n->as_Vector()->length() == 2); match(Set dst (URShiftVL src shift)); ins_cost(INSN_COST); - format %{ "ushl $dst,$src,$shift\t# vector (2D)" %} + effect(TEMP tmp); + format %{ "negr $tmp,$shift\t" + "ushl $dst,$src,$tmp\t# vector (2D)" %} ins_encode %{ + __ negr(as_FloatRegister($tmp$$reg), __ T16B, + as_FloatRegister($shift$$reg)); __ ushl(as_FloatRegister($dst$$reg), __ T2D, as_FloatRegister($src$$reg), - as_FloatRegister($shift$$reg)); + as_FloatRegister($tmp$$reg)); %} ins_pipe(vshift128); %} diff --git a/src/src/hotspot/cpu/aarch64/aarch64_call.cpp b/src/src/hotspot/cpu/aarch64/aarch64_call.cpp deleted file mode 100644 index 844dd9e7327..00000000000 --- a/src/src/hotspot/cpu/aarch64/aarch64_call.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2014, Red Hat Inc. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifdef BUILTIN_SIM - -#include -#include -#include "asm/macroAssembler.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "runtime/sharedRuntime.hpp" -#include "../../../../../../simulator/cpustate.hpp" -#include "../../../../../../simulator/simulator.hpp" - -/* - * a routine to initialise and enter ARM simulator execution when - * calling into ARM code from x86 code. - * - * we maintain a simulator per-thread and provide it with 8 Mb of - * stack space - */ -#define SIM_STACK_SIZE (1024 * 1024) // in units of u_int64_t - -extern "C" u_int64_t get_alt_stack() -{ - return AArch64Simulator::altStack(); -} - -extern "C" void setup_arm_sim(void *sp, u_int64_t calltype) -{ - // n.b. this function runs on the simulator stack so as to avoid - // simulator frames appearing in between VM x86 and ARM frames. note - // that arfgument sp points to the old (VM) stack from which the - // call into the sim was made. The stack switch and entry into this - // routine is handled by x86 prolog code planted in the head of the - // ARM code buffer which the sim is about to start executing (see - // aarch64_linkage.S). - // - // The first ARM instruction in the buffer is identified by fnptr - // stored at the top of the old stack. x86 register contents precede - // fnptr. preceding that are the fp and return address of the VM - // caller into ARM code. any extra, non-register arguments passed to - // the linkage routine precede the fp (this is as per any normal x86 - // call wirth extra args). - // - // note that the sim creates Java frames on the Java stack just - // above sp (i.e. directly above fnptr). it sets the sim FP register - // to the pushed fp for the caller effectively eliding the register - // data saved by the linkage routine. - // - // x86 register call arguments are loaded from the stack into ARM - // call registers. if extra arguments occur preceding the x86 - // caller's fp then they are copied either into extra ARM registers - // (ARM has 8 rather than 6 gp call registers) or up the stack - // beyond the saved x86 registers so that they immediately precede - // the ARM frame where the ARM calling convention expects them to - // be. - // - // n.b. the number of register/stack values passed to the ARM code - // is determined by calltype - // - // +--------+ - // | fnptr | <--- argument sp points here - // +--------+ | - // | rax | | return slot if we need to return a value - // +--------+ | - // | rdi | increasing - // +--------+ address - // | rsi | | - // +--------+ V - // | rdx | - // +--------+ - // | rcx | - // +--------+ - // | r8 | - // +--------+ - // | r9 | - // +--------+ - // | xmm0 | - // +--------+ - // | xmm1 | - // +--------+ - // | xmm2 | - // +--------+ - // | xmm3 | - // +--------+ - // | xmm4 | - // +--------+ - // | xmm5 | - // +--------+ - // | xmm6 | - // +--------+ - // | xmm7 | - // +--------+ - // | fp | - // +--------+ - // | caller | - // | ret ip | - // +--------+ - // | arg0 | <-- any extra call args start here - // +--------+ offset = 18 * wordSize - // | . . . | (i.e. 1 * calladdr + 1 * rax + 6 * gp call regs - // + 8 * fp call regs + 2 * frame words) - // - // we use a unique sim/stack per thread - const int cursor2_offset = 18; - const int fp_offset = 16; - u_int64_t *cursor = (u_int64_t *)sp; - u_int64_t *cursor2 = ((u_int64_t *)sp) + cursor2_offset; - u_int64_t *fp = ((u_int64_t *)sp) + fp_offset; - int gp_arg_count = calltype & 0xf; - int fp_arg_count = (calltype >> 4) & 0xf; - int return_type = (calltype >> 8) & 0x3; - AArch64Simulator *sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - // save previous cpu state in case this is a recursive entry - CPUState saveState = sim->getCPUState(); - // set up initial sim pc, sp and fp registers - sim->init(*cursor++, (u_int64_t)sp, (u_int64_t)fp); - u_int64_t *return_slot = cursor++; - - // if we need to pass the sim extra args on the stack then bump - // the stack pointer now - u_int64_t *cursor3 = (u_int64_t *)sim->getCPUState().xreg(SP, 1); - if (gp_arg_count > 8) { - cursor3 -= gp_arg_count - 8; - } - if (fp_arg_count > 8) { - cursor3 -= fp_arg_count - 8; - } - sim->getCPUState().xreg(SP, 1) = (u_int64_t)(cursor3++); - - for (int i = 0; i < gp_arg_count; i++) { - if (i < 6) { - // copy saved register to sim register - GReg reg = (GReg)i; - sim->getCPUState().xreg(reg, 0) = *cursor++; - } else if (i < 8) { - // copy extra int arg to sim register - GReg reg = (GReg)i; - sim->getCPUState().xreg(reg, 0) = *cursor2++; - } else { - // copy extra fp arg to sim stack - *cursor3++ = *cursor2++; - } - } - for (int i = 0; i < fp_arg_count; i++) { - if (i < 8) { - // copy saved register to sim register - GReg reg = (GReg)i; - sim->getCPUState().xreg(reg, 0) = *cursor++; - } else { - // copy extra arg to sim stack - *cursor3++ = *cursor2++; - } - } - AArch64Simulator::status_t return_status = sim->run(); - if (return_status != AArch64Simulator::STATUS_RETURN){ - sim->simPrint0(); - fatal("invalid status returned from simulator.run()\n"); - } - switch (return_type) { - case MacroAssembler::ret_type_void: - default: - break; - case MacroAssembler::ret_type_integral: - // this overwrites the saved r0 - *return_slot = sim->getCPUState().xreg(R0, 0); - break; - case MacroAssembler::ret_type_float: - *(float *)return_slot = sim->getCPUState().sreg(V0); - break; - case MacroAssembler::ret_type_double: - *(double *)return_slot = sim->getCPUState().dreg(V0); - break; - } - // restore incoimng cpu state - sim->getCPUState() = saveState; -} - -#endif diff --git a/src/src/hotspot/cpu/aarch64/aarch64_linkage.S b/src/src/hotspot/cpu/aarch64/aarch64_linkage.S deleted file mode 100644 index 1370c6abced..00000000000 --- a/src/src/hotspot/cpu/aarch64/aarch64_linkage.S +++ /dev/null @@ -1,167 +0,0 @@ -# -# Copyright (c) 2012, Red Hat. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. - -# Routines used to enable x86 VM C++ code to invoke JIT-compiled ARM code -# -- either Java methods or generated stub -- and to allow JIT-compiled -# ARM code to invoke x86 VM C++ code -# -# the code for aarch64_stub_prolog below can be copied into the start -# of the ARM code buffer and patched with a link to the -# C++ routine which starts execution on the simulator. the ARM -# code can be generated immediately following the copied code. - -#ifdef BUILTIN_SIM - - .data - .globl setup_arm_sim, - .type setup_arm_sim,@function - .globl get_alt_stack, - .type get_alt_stack,@function - .globl aarch64_stub_prolog - .p2align 4 -aarch64_stub_prolog: - // entry point -4: lea 1f(%rip), %r11 - mov (%r11), %r10 - mov (%r10), %r10 - jmp *%r10 - .p2align 4 -1: - .set entry_offset, . - 1b - .quad aarch64_prolog_ptr - // 64 bit int used to idenitfy called fn arg/return types - .set calltype_offset, . - 1b - .quad 0 - // arm JIT code follows the stub - .set arm_code_offset, . - 1b - .size aarch64_stub_prolog, .-aarch64_stub_prolog -aarch64_stub_prolog_end: - - .text -aarch64_prolog_ptr: - .quad aarch64_prolog - - .globl aarch64_prolog -aarch64_prolog: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - // save all registers used to pass args - sub $8, %rsp - movd %xmm7, (%rsp) - sub $8, %rsp - movd %xmm6, (%rsp) - sub $8, %rsp - movd %xmm5, (%rsp) - sub $8, %rsp - movd %xmm4, (%rsp) - sub $8, %rsp - movd %xmm3, (%rsp) - sub $8, %rsp - movd %xmm2, (%rsp) - sub $8, %rsp - movd %xmm1, (%rsp) - sub $8, %rsp - movd %xmm0, (%rsp) - push %r9 - push %r8 - push %rcx - push %rdx - push %rsi - push %rdi - // save rax -- this stack slot will be rewritten with a - // return value if needed - push %rax - // temporarily save r11 while we find the other stack - push %r11 - // retrieve alt stack - call get_alt_stack@PLT - pop %r11 - // push start of arm code - lea (arm_code_offset)(%r11), %rsi - push %rsi - // load call type code in arg reg 1 - mov (calltype_offset)(%r11), %rsi - // load current stack pointer in arg reg 0 - mov %rsp, %rdi - // switch to alt stack - mov %rax, %rsp - // save previous stack pointer on new stack - push %rdi - // 16-align the new stack pointer - push %rdi - // call sim setup routine - call setup_arm_sim@PLT - // switch back to old stack - pop %rsp - // pop start of arm code - pop %rdi - // pop rax -- either restores old value or installs return value - pop %rax - // pop arg registers - pop %rdi - pop %rsi - pop %rdx - pop %rcx - pop %r8 - pop %r9 - movd (%rsp), %xmm0 - add $8, %rsp - movd (%rsp), %xmm1 - add $8, %rsp - movd (%rsp), %xmm2 - add $8, %rsp - movd (%rsp), %xmm3 - add $8, %rsp - movd (%rsp), %xmm4 - add $8, %rsp - movd (%rsp), %xmm5 - add $8, %rsp - movd (%rsp), %xmm6 - add $8, %rsp - movd (%rsp), %xmm7 - add $8, %rsp - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc - - - .p2align 4 -get_pc: - // get return pc in rdi and then push it back - pop %rdi - push %rdi - ret - - .p2align 4 - .long - .globl aarch64_stub_prolog_size - .type aarch64_stub_prolog_size,@function -aarch64_stub_prolog_size: - leaq aarch64_stub_prolog_end - aarch64_stub_prolog, %rax - ret - -#endif diff --git a/src/src/hotspot/cpu/aarch64/assembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/assembler_aarch64.cpp index b6c08775751..586743eb967 100644 --- a/src/src/hotspot/cpu/aarch64/assembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/assembler_aarch64.cpp @@ -38,11 +38,6 @@ const unsigned long Assembler::asm_bp = 0x00007fffee09ac88; #include "memory/resourceArea.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/sharedRuntime.hpp" - -// for the moment we reuse the logical/floating point immediate encode -// and decode functiosn provided by the simulator. when we move to -// real hardware we will need to pull taht code into here - #include "immediate_aarch64.hpp" extern "C" void entry(CodeBuffer *cb); @@ -1485,21 +1480,6 @@ int AbstractAssembler::code_fill_byte() { void Assembler::bang_stack_with_offset(int offset) { Unimplemented(); } -// these are the functions provided by the simulator which are used to -// encode and decode logical immediates and floating point immediates -// -// u_int64_t logical_immediate_for_encoding(u_int32_t encoding); -// -// u_int32_t encoding_for_logical_immediate(u_int64_t immediate); -// -// u_int64_t fp_immediate_for_encoding(u_int32_t imm8, int is_dp); -// -// u_int32_t encoding_for_fp_immediate(float immediate); -// -// we currently import these from the simulator librray but the -// definitions will need to be moved to here when we switch to real -// hardware. - // and now the routines called by the assembler which encapsulate the // above encode and decode functions diff --git a/src/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/src/hotspot/cpu/aarch64/assembler_aarch64.hpp index 56c33815105..c5f24b01d6b 100644 --- a/src/src/hotspot/cpu/aarch64/assembler_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/assembler_aarch64.hpp @@ -2598,137 +2598,6 @@ void ext(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, FloatRegister V f(0, 10), rf(Vn, 5), rf(Vd, 0); } -/* Simulator extensions to the ISA - - haltsim - - takes no arguments, causes the sim to enter a debug break and then - return from the simulator run() call with STATUS_HALT? The linking - code will call fatal() when it sees STATUS_HALT. - - blrt Xn, Wm - blrt Xn, #gpargs, #fpargs, #type - Xn holds the 64 bit x86 branch_address - call format is encoded either as immediate data in the call - or in register Wm. In the latter case - Wm[13..6] = #gpargs, - Wm[5..2] = #fpargs, - Wm[1,0] = #type - - calls the x86 code address 'branch_address' supplied in Xn passing - arguments taken from the general and floating point registers according - to the supplied counts 'gpargs' and 'fpargs'. may return a result in r0 - or v0 according to the the return type #type' where - - address branch_address; - uimm4 gpargs; - uimm4 fpargs; - enum ReturnType type; - - enum ReturnType - { - void_ret = 0, - int_ret = 1, - long_ret = 1, - obj_ret = 1, // i.e. same as long - float_ret = 2, - double_ret = 3 - } - - notify - - notifies the simulator of a transfer of control. instr[14:0] - identifies the type of change of control. - - 0 ==> initial entry to a method. - - 1 ==> return into a method from a submethod call. - - 2 ==> exit out of Java method code. - - 3 ==> start execution for a new bytecode. - - in cases 1 and 2 the simulator is expected to use a JVM callback to - identify the name of the specific method being executed. in case 4 - the simulator is expected to use a JVM callback to identify the - bytecode index. - - Instruction encodings - --------------------- - - These are encoded in the space with instr[28:25] = 00 which is - unallocated. Encodings are - - 10987654321098765432109876543210 - PSEUDO_HALT = 0x11100000000000000000000000000000 - PSEUDO_BLRT = 0x11000000000000000_______________ - PSEUDO_BLRTR = 0x1100000000000000100000__________ - PSEUDO_NOTIFY = 0x10100000000000000_______________ - - instr[31,29] = op1 : 111 ==> HALT, 110 ==> BLRT/BLRTR, 101 ==> NOTIFY - - for BLRT - instr[14,11] = #gpargs, instr[10,7] = #fpargs - instr[6,5] = #type, instr[4,0] = Rn - for BLRTR - instr[9,5] = Rm, instr[4,0] = Rn - for NOTIFY - instr[14:0] = type : 0 ==> entry, 1 ==> reentry, 2 ==> exit, 3 ==> bcstart -*/ - - enum NotifyType { method_entry, method_reentry, method_exit, bytecode_start }; - - virtual void notify(int type) { - if (UseBuiltinSim) { - starti; - // 109 - f(0b101, 31, 29); - // 87654321098765 - f(0b00000000000000, 28, 15); - f(type, 14, 0); - } - } - - void blrt(Register Rn, int gpargs, int fpargs, int type) { - if (UseBuiltinSim) { - starti; - f(0b110, 31 ,29); - f(0b00, 28, 25); - // 4321098765 - f(0b0000000000, 24, 15); - f(gpargs, 14, 11); - f(fpargs, 10, 7); - f(type, 6, 5); - rf(Rn, 0); - } else { - blr(Rn); - } - } - - void blrt(Register Rn, Register Rm) { - if (UseBuiltinSim) { - starti; - f(0b110, 31 ,29); - f(0b00, 28, 25); - // 4321098765 - f(0b0000000001, 24, 15); - // 43210 - f(0b00000, 14, 10); - rf(Rm, 5); - rf(Rn, 0); - } else { - blr(Rn); - } - } - - void haltsim() { - starti; - f(0b111, 31 ,29); - f(0b00, 28, 27); - // 654321098765432109876543210 - f(0b000000000000000000000000000, 26, 0); - } - Assembler(CodeBuffer* code) : AbstractAssembler(code) { } diff --git a/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp index c4a8288507d..ac91e87d273 100644 --- a/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp @@ -34,6 +34,7 @@ #include "c1/c1_ValueStack.hpp" #include "ci/ciArrayKlass.hpp" #include "ci/ciInstance.hpp" +#include "code/compiledIC.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/collectedHeap.hpp" @@ -2012,11 +2013,10 @@ void LIR_Assembler::emit_static_call_stub() { int start = __ offset(); __ relocate(static_stub_Relocation::spec(call_pc)); - __ mov_metadata(rmethod, (Metadata*)NULL); - __ movptr(rscratch1, 0); - __ br(rscratch1); + __ emit_static_call_stub(); - assert(__ offset() - start <= call_stub_size(), "stub too big"); + assert(__ offset() - start + CompiledStaticCall::to_trampoline_stub_size() + <= call_stub_size(), "stub too big"); __ end_a_stub(); } @@ -2824,40 +2824,7 @@ void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* arg __ far_call(RuntimeAddress(dest)); } else { __ mov(rscratch1, RuntimeAddress(dest)); - int len = args->length(); - int type = 0; - if (! result->is_illegal()) { - switch (result->type()) { - case T_VOID: - type = 0; - break; - case T_INT: - case T_LONG: - case T_OBJECT: - type = 1; - break; - case T_FLOAT: - type = 2; - break; - case T_DOUBLE: - type = 3; - break; - default: - ShouldNotReachHere(); - break; - } - } - int num_gpargs = 0; - int num_fpargs = 0; - for (int i = 0; i < args->length(); i++) { - LIR_Opr arg = args->at(i); - if (arg->type() == T_FLOAT || arg->type() == T_DOUBLE) { - num_fpargs++; - } else { - num_gpargs++; - } - } - __ blrt(rscratch1, num_gpargs, num_fpargs, type); + __ blr(rscratch1); } if (info != NULL) { diff --git a/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp b/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp index 95b89dd3fc5..6374a33e656 100644 --- a/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp @@ -69,7 +69,9 @@ friend class ArrayCopyStub; void deoptimize_trap(CodeEmitInfo *info); enum { - _call_stub_size = 12 * NativeInstruction::instruction_size, + // call stub: CompiledStaticCall::to_interp_stub_size() + + // CompiledStaticCall::to_trampoline_stub_size() + _call_stub_size = 13 * NativeInstruction::instruction_size, _call_aot_stub_size = 0, _exception_handler_size = DEBUG_ONLY(1*K) NOT_DEBUG(175), _deopt_handler_size = 7 * NativeInstruction::instruction_size diff --git a/src/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp index ccc7050b92c..218113b7811 100644 --- a/src/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp @@ -341,16 +341,10 @@ void C1_MacroAssembler::build_frame(int framesize, int bang_size_in_bytes) { // Note that we do this before doing an enter(). generate_stack_overflow_check(bang_size_in_bytes); MacroAssembler::build_frame(framesize + 2 * wordSize); - if (NotifySimulator) { - notify(Assembler::method_entry); - } } void C1_MacroAssembler::remove_frame(int framesize) { MacroAssembler::remove_frame(framesize + 2 * wordSize); - if (NotifySimulator) { - notify(Assembler::method_reentry); - } } diff --git a/src/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp b/src/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp index 3fd2bd9e27d..84b98995289 100644 --- a/src/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp @@ -62,7 +62,7 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre // do the call lea(rscratch1, RuntimeAddress(entry)); - blrt(rscratch1, args_size + 1, 8, 1); + blr(rscratch1); bind(retaddr); int call_offset = offset(); // verify callee-saved register @@ -537,7 +537,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { __ set_last_Java_frame(sp, rfp, retaddr, rscratch1); // do the call __ lea(rscratch1, RuntimeAddress(target)); - __ blrt(rscratch1, 1, 0, 1); + __ blr(rscratch1); __ bind(retaddr); OopMapSet* oop_maps = new OopMapSet(); oop_maps->add_gc_map(__ offset(), oop_map); diff --git a/src/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp b/src/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp index 3177a8980b9..44608fea201 100644 --- a/src/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp @@ -41,13 +41,7 @@ define_pd_global(bool, PreferInterpreterNativeStubs, false); define_pd_global(bool, ProfileTraps, false); define_pd_global(bool, UseOnStackReplacement, true ); define_pd_global(bool, TieredCompilation, false); -#ifdef BUILTIN_SIM -// We compile very aggressively with the builtin simulator because -// doing so greatly reduces run times and tests more code. -define_pd_global(intx, CompileThreshold, 150 ); -#else define_pd_global(intx, CompileThreshold, 1500 ); -#endif define_pd_global(intx, OnStackReplacePercentage, 933 ); define_pd_global(intx, FreqInlineSize, 325 ); diff --git a/src/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp b/src/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp index cc4d7d4a8ca..3f511db0a8f 100644 --- a/src/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp @@ -61,14 +61,14 @@ address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) // Don't create a Metadata reloc if we're generating immutable PIC. if (cbuf.immutable_PIC()) { __ movptr(rmethod, 0); - } else { - __ mov_metadata(rmethod, (Metadata*)NULL); - } -#else - __ mov_metadata(rmethod, (Metadata*)NULL); + __ movptr(rscratch1, 0); + __ br(rscratch1); + + } else #endif - __ movptr(rscratch1, 0); - __ br(rscratch1); + { + __ emit_static_call_stub(); + } assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big"); __ end_a_stub(); @@ -77,7 +77,8 @@ address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) #undef __ int CompiledStaticCall::to_interp_stub_size() { - return 7 * NativeInstruction::instruction_size; + // isb; movk; movz; movz; movk; movz; movz; br + return 8 * NativeInstruction::instruction_size; } int CompiledStaticCall::to_trampoline_stub_size() { @@ -159,7 +160,8 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad } // Creation also verifies the object. - NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); + NativeMovConstReg* method_holder + = nativeMovConstReg_at(stub + NativeInstruction::instruction_size); #ifndef PRODUCT NativeGeneralJump* jump = nativeGeneralJump_at(method_holder->next_instruction_address()); @@ -184,7 +186,8 @@ void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_ address stub = static_stub->addr(); assert(stub != NULL, "stub not found"); // Creation also verifies the object. - NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); + NativeMovConstReg* method_holder + = nativeMovConstReg_at(stub + NativeInstruction::instruction_size); method_holder->set_data(0); } @@ -203,8 +206,9 @@ void CompiledDirectStaticCall::verify() { address stub = find_stub(false /* is_aot */); assert(stub != NULL, "no stub found for static call"); // Creation also verifies the object. - NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); - NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); + NativeMovConstReg* method_holder + = nativeMovConstReg_at(stub + NativeInstruction::instruction_size); + NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); // Verify state. assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check"); diff --git a/src/src/hotspot/cpu/aarch64/cpustate_aarch64.hpp b/src/src/hotspot/cpu/aarch64/cpustate_aarch64.hpp deleted file mode 100644 index ce996e38df2..00000000000 --- a/src/src/hotspot/cpu/aarch64/cpustate_aarch64.hpp +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (c) 2014, Red Hat Inc. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef _CPU_STATE_H -#define _CPU_STATE_H - -#include - -/* - * symbolic names used to identify general registers which also match - * the registers indices in machine code - * - * We have 32 general registers which can be read/written as 32 bit or - * 64 bit sources/sinks and are appropriately referred to as Wn or Xn - * in the assembly code. Some instructions mix these access modes - * (e.g. ADD X0, X1, W2) so the implementation of the instruction - * needs to *know* which type of read or write access is required. - */ -enum GReg { - R0, - R1, - R2, - R3, - R4, - R5, - R6, - R7, - R8, - R9, - R10, - R11, - R12, - R13, - R14, - R15, - R16, - R17, - R18, - R19, - R20, - R21, - R22, - R23, - R24, - R25, - R26, - R27, - R28, - R29, - R30, - R31, - // and now the aliases - RSCRATCH1=R8, - RSCRATCH2=R9, - RMETHOD=R12, - RESP=R20, - RDISPATCH=R21, - RBCP=R22, - RLOCALS=R24, - RMONITORS=R25, - RCPOOL=R26, - RHEAPBASE=R27, - RTHREAD=R28, - FP = R29, - LR = R30, - SP = R31, - ZR = R31 -}; - -/* - * symbolic names used to refer to floating point registers which also - * match the registers indices in machine code - * - * We have 32 FP registers which can be read/written as 8, 16, 32, 64 - * and 128 bit sources/sinks and are appropriately referred to as Bn, - * Hn, Sn, Dn and Qn in the assembly code. Some instructions mix these - * access modes (e.g. FCVT S0, D0) so the implementation of the - * instruction needs to *know* which type of read or write access is - * required. - */ - -enum VReg { - V0, - V1, - V2, - V3, - V4, - V5, - V6, - V7, - V8, - V9, - V10, - V11, - V12, - V13, - V14, - V15, - V16, - V17, - V18, - V19, - V20, - V21, - V22, - V23, - V24, - V25, - V26, - V27, - V28, - V29, - V30, - V31, -}; - -/** - * all the different integer bit patterns for the components of a - * general register are overlaid here using a union so as to allow all - * reading and writing of the desired bits. - * - * n.b. the ARM spec says that when you write a 32 bit register you - * are supposed to write the low 32 bits and zero the high 32 - * bits. But we don't actually have to care about this because Java - * will only ever consume the 32 bits value as a 64 bit quantity after - * an explicit extend. - */ -union GRegisterValue -{ - int8_t s8; - int16_t s16; - int32_t s32; - int64_t s64; - u_int8_t u8; - u_int16_t u16; - u_int32_t u32; - u_int64_t u64; -}; - -class GRegister -{ -public: - GRegisterValue value; -}; - -/* - * float registers provide for storage of a single, double or quad - * word format float in the same register. single floats are not - * paired within each double register as per 32 bit arm. instead each - * 128 bit register Vn embeds the bits for Sn, and Dn in the lower - * quarter and half, respectively, of the bits for Qn. - * - * The upper bits can also be accessed as single or double floats by - * the float vector operations using indexing e.g. V1.D[1], V1.S[3] - * etc and, for SIMD operations using a horrible index range notation. - * - * The spec also talks about accessing float registers as half words - * and bytes with Hn and Bn providing access to the low 16 and 8 bits - * of Vn but it is not really clear what these bits represent. We can - * probably ignore this for Java anyway. However, we do need to access - * the raw bits at 32 and 64 bit resolution to load to/from integer - * registers. - */ - -union FRegisterValue -{ - float s; - double d; - long double q; - // eventually we will need to be able to access the data as a vector - // the integral array elements allow us to access the bits in s, d, - // q, vs and vd at an appropriate level of granularity - u_int8_t vb[16]; - u_int16_t vh[8]; - u_int32_t vw[4]; - u_int64_t vx[2]; - float vs[4]; - double vd[2]; -}; - -class FRegister -{ -public: - FRegisterValue value; -}; - -/* - * CPSR register -- this does not exist as a directly accessible - * register but we need to store the flags so we can implement - * flag-seting and flag testing operations - * - * we can possibly use injected x86 asm to report the outcome of flag - * setting operations. if so we will need to grab the flags - * immediately after the operation in order to ensure we don't lose - * them because of the actions of the simulator. so we still need - * somewhere to store the condition codes. - */ - -class CPSRRegister -{ -public: - u_int32_t value; - -/* - * condition register bit select values - * - * the order of bits here is important because some of - * the flag setting conditional instructions employ a - * bit field to populate the flags when a false condition - * bypasses execution of the operation and we want to - * be able to assign the flags register using the - * supplied value. - */ - - enum CPSRIdx { - V_IDX, - C_IDX, - Z_IDX, - N_IDX - }; - - enum CPSRMask { - V = 1 << V_IDX, - C = 1 << C_IDX, - Z = 1 << Z_IDX, - N = 1 << N_IDX - }; - - static const int CPSR_ALL_FLAGS = (V | C | Z | N); -}; - -// auxiliary function to assemble the relevant bits from -// the x86 EFLAGS register into an ARM CPSR value - -#define X86_V_IDX 11 -#define X86_C_IDX 0 -#define X86_Z_IDX 6 -#define X86_N_IDX 7 - -#define X86_V (1 << X86_V_IDX) -#define X86_C (1 << X86_C_IDX) -#define X86_Z (1 << X86_Z_IDX) -#define X86_N (1 << X86_N_IDX) - -inline u_int32_t convertX86Flags(u_int32_t x86flags) -{ - u_int32_t flags; - // set N flag - flags = ((x86flags & X86_N) >> X86_N_IDX); - // shift then or in Z flag - flags <<= 1; - flags |= ((x86flags & X86_Z) >> X86_Z_IDX); - // shift then or in C flag - flags <<= 1; - flags |= ((x86flags & X86_C) >> X86_C_IDX); - // shift then or in V flag - flags <<= 1; - flags |= ((x86flags & X86_V) >> X86_V_IDX); - - return flags; -} - -inline u_int32_t convertX86FlagsFP(u_int32_t x86flags) -{ - // x86 flags set by fcomi(x,y) are ZF:PF:CF - // (yes, that's PF for parity, WTF?) - // where - // 0) 0:0:0 means x > y - // 1) 0:0:1 means x < y - // 2) 1:0:0 means x = y - // 3) 1:1:1 means x and y are unordered - // note that we don't have to check PF so - // we really have a simple 2-bit case switch - // the corresponding ARM64 flags settings - // in hi->lo bit order are - // 0) --C- - // 1) N--- - // 2) -ZC- - // 3) --CV - - static u_int32_t armFlags[] = { - 0b0010, - 0b1000, - 0b0110, - 0b0011 - }; - // pick out the ZF and CF bits - u_int32_t zc = ((x86flags & X86_Z) >> X86_Z_IDX); - zc <<= 1; - zc |= ((x86flags & X86_C) >> X86_C_IDX); - - return armFlags[zc]; -} - -/* - * FPSR register -- floating point status register - - * this register includes IDC, IXC, UFC, OFC, DZC, IOC and QC bits, - * and the floating point N, Z, C, V bits but the latter are unused in - * aarch64 mode. the sim ignores QC for now. - * - * bit positions are as per the ARMv7 FPSCR register - * - * IDC : 7 ==> Input Denormal (cumulative exception bit) - * IXC : 4 ==> Inexact - * UFC : 3 ==> Underflow - * OFC : 2 ==> Overflow - * DZC : 1 ==> Division by Zero - * IOC : 0 ==> Invalid Operation - */ - -class FPSRRegister -{ -public: - u_int32_t value; - // indices for bits in the FPSR register value - enum FPSRIdx { - IO_IDX = 0, - DZ_IDX = 1, - OF_IDX = 2, - UF_IDX = 3, - IX_IDX = 4, - ID_IDX = 7 - }; - // corresponding bits as numeric values - enum FPSRMask { - IO = (1 << IO_IDX), - DZ = (1 << DZ_IDX), - OF = (1 << OF_IDX), - UF = (1 << UF_IDX), - IX = (1 << IX_IDX), - ID = (1 << ID_IDX) - }; - static const int FPSR_ALL_FPSRS = (IO | DZ | OF | UF | IX | ID); -}; - -// debugger support - -enum PrintFormat -{ - FMT_DECIMAL, - FMT_HEX, - FMT_SINGLE, - FMT_DOUBLE, - FMT_QUAD, - FMT_MULTI -}; - -/* - * model of the registers and other state associated with the cpu - */ -class CPUState -{ - friend class AArch64Simulator; -private: - // this is the PC of the instruction being executed - u_int64_t pc; - // this is the PC of the instruction to be executed next - // it is defaulted to pc + 4 at instruction decode but - // execute may reset it - - u_int64_t nextpc; - GRegister gr[33]; // extra register at index 32 is used - // to hold zero value - FRegister fr[32]; - CPSRRegister cpsr; - FPSRRegister fpsr; - -public: - - CPUState() { - gr[20].value.u64 = 0; // establish initial condition for - // checkAssertions() - trace_counter = 0; - } - - // General Register access macros - - // only xreg or xregs can be used as an lvalue in order to update a - // register. this ensures that the top part of a register is always - // assigned when it is written by the sim. - - inline u_int64_t &xreg(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.u64; - } else { - return gr[reg].value.u64; - } - } - - inline int64_t &xregs(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.s64; - } else { - return gr[reg].value.s64; - } - } - - inline u_int32_t wreg(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.u32; - } else { - return gr[reg].value.u32; - } - } - - inline int32_t wregs(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.s32; - } else { - return gr[reg].value.s32; - } - } - - inline u_int32_t hreg(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.u16; - } else { - return gr[reg].value.u16; - } - } - - inline int32_t hregs(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.s16; - } else { - return gr[reg].value.s16; - } - } - - inline u_int32_t breg(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.u8; - } else { - return gr[reg].value.u8; - } - } - - inline int32_t bregs(GReg reg, int r31_is_sp) { - if (reg == R31 && !r31_is_sp) { - return gr[32].value.s8; - } else { - return gr[reg].value.s8; - } - } - - // FP Register access macros - - // all non-vector accessors return a reference so we can both read - // and assign - - inline float &sreg(VReg reg) { - return fr[reg].value.s; - } - - inline double &dreg(VReg reg) { - return fr[reg].value.d; - } - - inline long double &qreg(VReg reg) { - return fr[reg].value.q; - } - - // all vector register accessors return a pointer - - inline float *vsreg(VReg reg) { - return &fr[reg].value.vs[0]; - } - - inline double *vdreg(VReg reg) { - return &fr[reg].value.vd[0]; - } - - inline u_int8_t *vbreg(VReg reg) { - return &fr[reg].value.vb[0]; - } - - inline u_int16_t *vhreg(VReg reg) { - return &fr[reg].value.vh[0]; - } - - inline u_int32_t *vwreg(VReg reg) { - return &fr[reg].value.vw[0]; - } - - inline u_int64_t *vxreg(VReg reg) { - return &fr[reg].value.vx[0]; - } - - union GRegisterValue prev_sp, prev_fp; - - static const int trace_size = 256; - u_int64_t trace_buffer[trace_size]; - int trace_counter; - - bool checkAssertions() - { - // Make sure that SP is 16-aligned - // Also make sure that ESP is above SP. - // We don't care about checking ESP if it is null, i.e. it hasn't - // been used yet. - if (gr[31].value.u64 & 0x0f) { - asm volatile("nop"); - return false; - } - return true; - } - - // pc register accessors - - // this instruction can be used to fetch the current PC - u_int64_t getPC(); - // instead of setting the current PC directly you can - // first set the next PC (either absolute or PC-relative) - // and later copy the next PC into the current PC - // this supports a default increment by 4 at instruction - // fetch with an optional reset by control instructions - u_int64_t getNextPC(); - void setNextPC(u_int64_t next); - void offsetNextPC(int64_t offset); - // install nextpc as current pc - void updatePC(); - - // this instruction can be used to save the next PC to LR - // just before installing a branch PC - inline void saveLR() { gr[LR].value.u64 = nextpc; } - - // cpsr register accessors - u_int32_t getCPSRRegister(); - void setCPSRRegister(u_int32_t flags); - // read a specific subset of the flags as a bit pattern - // mask should be composed using elements of enum FlagMask - u_int32_t getCPSRBits(u_int32_t mask); - // assign a specific subset of the flags as a bit pattern - // mask and value should be composed using elements of enum FlagMask - void setCPSRBits(u_int32_t mask, u_int32_t value); - // test the value of a single flag returned as 1 or 0 - u_int32_t testCPSR(CPSRRegister::CPSRIdx idx); - // set a single flag - void setCPSR(CPSRRegister::CPSRIdx idx); - // clear a single flag - void clearCPSR(CPSRRegister::CPSRIdx idx); - // utility method to set ARM CSPR flags from an x86 bit mask generated by integer arithmetic - void setCPSRRegisterFromX86(u_int64_t x86Flags); - // utility method to set ARM CSPR flags from an x86 bit mask generated by floating compare - void setCPSRRegisterFromX86FP(u_int64_t x86Flags); - - // fpsr register accessors - u_int32_t getFPSRRegister(); - void setFPSRRegister(u_int32_t flags); - // read a specific subset of the fprs bits as a bit pattern - // mask should be composed using elements of enum FPSRRegister::FlagMask - u_int32_t getFPSRBits(u_int32_t mask); - // assign a specific subset of the flags as a bit pattern - // mask and value should be composed using elements of enum FPSRRegister::FlagMask - void setFPSRBits(u_int32_t mask, u_int32_t value); - // test the value of a single flag returned as 1 or 0 - u_int32_t testFPSR(FPSRRegister::FPSRIdx idx); - // set a single flag - void setFPSR(FPSRRegister::FPSRIdx idx); - // clear a single flag - void clearFPSR(FPSRRegister::FPSRIdx idx); - - // debugger support - void printPC(int pending, const char *trailing = "\n"); - void printInstr(u_int32_t instr, void (*dasm)(u_int64_t), const char *trailing = "\n"); - void printGReg(GReg reg, PrintFormat format = FMT_HEX, const char *trailing = "\n"); - void printVReg(VReg reg, PrintFormat format = FMT_HEX, const char *trailing = "\n"); - void printCPSR(const char *trailing = "\n"); - void printFPSR(const char *trailing = "\n"); - void dumpState(); -}; - -#endif // ifndef _CPU_STATE_H diff --git a/src/src/hotspot/cpu/aarch64/decode_aarch64.hpp b/src/src/hotspot/cpu/aarch64/decode_aarch64.hpp deleted file mode 100644 index e93924d3493..00000000000 --- a/src/src/hotspot/cpu/aarch64/decode_aarch64.hpp +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright (c) 2014, Red Hat Inc. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef _DECODE_H -#define _DECODE_H - -#include -#include "cpustate_aarch64.hpp" - -// bitfield immediate expansion helper - -extern int expandLogicalImmediate(u_int32_t immN, u_int32_t immr, - u_int32_t imms, u_int64_t &bimm); - - -/* - * codes used in conditional instructions - * - * these are passed to conditional operations to identify which - * condition to test for - */ -enum CondCode { - EQ = 0b0000, // meaning Z == 1 - NE = 0b0001, // meaning Z == 0 - HS = 0b0010, // meaning C == 1 - CS = HS, - LO = 0b0011, // meaning C == 0 - CC = LO, - MI = 0b0100, // meaning N == 1 - PL = 0b0101, // meaning N == 0 - VS = 0b0110, // meaning V == 1 - VC = 0b0111, // meaning V == 0 - HI = 0b1000, // meaning C == 1 && Z == 0 - LS = 0b1001, // meaning !(C == 1 && Z == 0) - GE = 0b1010, // meaning N == V - LT = 0b1011, // meaning N != V - GT = 0b1100, // meaning Z == 0 && N == V - LE = 0b1101, // meaning !(Z == 0 && N == V) - AL = 0b1110, // meaning ANY - NV = 0b1111 // ditto -}; - -/* - * certain addressing modes for load require pre or post writeback of - * the computed address to a base register - */ -enum WriteBack { - Post = 0, - Pre = 1 -}; - -/* - * certain addressing modes for load require an offset to - * be optionally scaled so the decode needs to pass that - * through to the execute routine - */ -enum Scaling { - Unscaled = 0, - Scaled = 1 -}; - -/* - * when we do have to scale we do so by shifting using - * log(bytes in data element - 1) as the shift count. - * so we don't have to scale offsets when loading - * bytes. - */ -enum ScaleShift { - ScaleShift16 = 1, - ScaleShift32 = 2, - ScaleShift64 = 3, - ScaleShift128 = 4 -}; - -/* - * one of the addressing modes for load requires a 32-bit register - * value to be either zero- or sign-extended for these instructions - * UXTW or SXTW should be passed - * - * arithmetic register data processing operations can optionally - * extend a portion of the second register value for these - * instructions the value supplied must identify the portion of the - * register which is to be zero- or sign-exended - */ -enum Extension { - UXTB = 0, - UXTH = 1, - UXTW = 2, - UXTX = 3, - SXTB = 4, - SXTH = 5, - SXTW = 6, - SXTX = 7 -}; - -/* - * arithmetic and logical register data processing operations - * optionally perform a shift on the second register value - */ -enum Shift { - LSL = 0, - LSR = 1, - ASR = 2, - ROR = 3 -}; - -/* - * bit twiddling helpers for instruction decode - */ - -// 32 bit mask with bits [hi,...,lo] set - -static inline u_int32_t mask32(int hi = 31, int lo = 0) -{ - int nbits = (hi + 1) - lo; - return ((1 << nbits) - 1) << lo; -} - -static inline u_int64_t mask64(int hi = 63, int lo = 0) -{ - int nbits = (hi + 1) - lo; - return ((1L << nbits) - 1) << lo; -} - -// pick bits [hi,...,lo] from val -static inline u_int32_t pick32(u_int32_t val, int hi = 31, int lo = 0) -{ - return (val & mask32(hi, lo)); -} - -// pick bits [hi,...,lo] from val -static inline u_int64_t pick64(u_int64_t val, int hi = 31, int lo = 0) -{ - return (val & mask64(hi, lo)); -} - -// pick bits [hi,...,lo] from val and shift to [(hi-(newlo - lo)),newlo] -static inline u_int32_t pickshift32(u_int32_t val, int hi = 31, - int lo = 0, int newlo = 0) -{ - u_int32_t bits = pick32(val, hi, lo); - if (lo < newlo) { - return (bits << (newlo - lo)); - } else { - return (bits >> (lo - newlo)); - } -} -// mask [hi,lo] and shift down to start at bit 0 -static inline u_int32_t pickbits32(u_int32_t val, int hi = 31, int lo = 0) -{ - return (pick32(val, hi, lo) >> lo); -} - -// mask [hi,lo] and shift down to start at bit 0 -static inline u_int64_t pickbits64(u_int64_t val, int hi = 63, int lo = 0) -{ - return (pick64(val, hi, lo) >> lo); -} - -/* - * decode registers, immediates and constants of various types - */ - -static inline GReg greg(u_int32_t val, int lo) -{ - return (GReg)pickbits32(val, lo + 4, lo); -} - -static inline VReg vreg(u_int32_t val, int lo) -{ - return (VReg)pickbits32(val, lo + 4, lo); -} - -static inline u_int32_t uimm(u_int32_t val, int hi, int lo) -{ - return pickbits32(val, hi, lo); -} - -static inline int32_t simm(u_int32_t val, int hi = 31, int lo = 0) { - union { - u_int32_t u; - int32_t n; - }; - - u = val << (31 - hi); - n = n >> (31 - hi + lo); - return n; -} - -static inline int64_t simm(u_int64_t val, int hi = 63, int lo = 0) { - union { - u_int64_t u; - int64_t n; - }; - - u = val << (63 - hi); - n = n >> (63 - hi + lo); - return n; -} - -static inline Shift shift(u_int32_t val, int lo) -{ - return (Shift)pickbits32(val, lo+1, lo); -} - -static inline Extension extension(u_int32_t val, int lo) -{ - return (Extension)pickbits32(val, lo+2, lo); -} - -static inline Scaling scaling(u_int32_t val, int lo) -{ - return (Scaling)pickbits32(val, lo, lo); -} - -static inline WriteBack writeback(u_int32_t val, int lo) -{ - return (WriteBack)pickbits32(val, lo, lo); -} - -static inline CondCode condcode(u_int32_t val, int lo) -{ - return (CondCode)pickbits32(val, lo+3, lo); -} - -/* - * operation decode - */ -// bits [28,25] are the primary dispatch vector - -static inline u_int32_t dispatchGroup(u_int32_t val) -{ - return pickshift32(val, 28, 25, 0); -} - -/* - * the 16 possible values for bits [28,25] identified by tags which - * map them to the 5 main instruction groups LDST, DPREG, ADVSIMD, - * BREXSYS and DPIMM. - * - * An extra group PSEUDO is included in one of the unallocated ranges - * for simulator-specific pseudo-instructions. - */ -enum DispatchGroup { - GROUP_PSEUDO_0000, - GROUP_UNALLOC_0001, - GROUP_UNALLOC_0010, - GROUP_UNALLOC_0011, - GROUP_LDST_0100, - GROUP_DPREG_0101, - GROUP_LDST_0110, - GROUP_ADVSIMD_0111, - GROUP_DPIMM_1000, - GROUP_DPIMM_1001, - GROUP_BREXSYS_1010, - GROUP_BREXSYS_1011, - GROUP_LDST_1100, - GROUP_DPREG_1101, - GROUP_LDST_1110, - GROUP_ADVSIMD_1111 -}; - -// bits [31, 29] of a Pseudo are the secondary dispatch vector - -static inline u_int32_t dispatchPseudo(u_int32_t val) -{ - return pickshift32(val, 31, 29, 0); -} - -/* - * the 8 possible values for bits [31,29] in a Pseudo Instruction. - * Bits [28,25] are always 0000. - */ - -enum DispatchPseudo { - PSEUDO_UNALLOC_000, // unallocated - PSEUDO_UNALLOC_001, // ditto - PSEUDO_UNALLOC_010, // ditto - PSEUDO_UNALLOC_011, // ditto - PSEUDO_UNALLOC_100, // ditto - PSEUDO_UNALLOC_101, // ditto - PSEUDO_CALLOUT_110, // CALLOUT -- bits [24,0] identify call/ret sig - PSEUDO_HALT_111 // HALT -- bits [24, 0] identify halt code -}; - -// bits [25, 23] of a DPImm are the secondary dispatch vector - -static inline u_int32_t dispatchDPImm(u_int32_t instr) -{ - return pickshift32(instr, 25, 23, 0); -} - -/* - * the 8 possible values for bits [25,23] in a Data Processing Immediate - * Instruction. Bits [28,25] are always 100_. - */ - -enum DispatchDPImm { - DPIMM_PCADR_000, // PC-rel-addressing - DPIMM_PCADR_001, // ditto - DPIMM_ADDSUB_010, // Add/Subtract (immediate) - DPIMM_ADDSUB_011, // ditto - DPIMM_LOG_100, // Logical (immediate) - DPIMM_MOV_101, // Move Wide (immediate) - DPIMM_BITF_110, // Bitfield - DPIMM_EXTR_111 // Extract -}; - -// bits [29,28:26] of a LS are the secondary dispatch vector - -static inline u_int32_t dispatchLS(u_int32_t instr) -{ - return (pickshift32(instr, 29, 28, 1) | - pickshift32(instr, 26, 26, 0)); -} - -/* - * the 8 possible values for bits [29,28:26] in a Load/Store - * Instruction. Bits [28,25] are always _1_0 - */ - -enum DispatchLS { - LS_EXCL_000, // Load/store exclusive (includes some unallocated) - LS_ADVSIMD_001, // AdvSIMD load/store (various -- includes some unallocated) - LS_LIT_010, // Load register literal (includes some unallocated) - LS_LIT_011, // ditto - LS_PAIR_100, // Load/store register pair (various) - LS_PAIR_101, // ditto - LS_OTHER_110, // other load/store formats - LS_OTHER_111 // ditto -}; - -// bits [28:24:21] of a DPReg are the secondary dispatch vector - -static inline u_int32_t dispatchDPReg(u_int32_t instr) -{ - return (pickshift32(instr, 28, 28, 2) | - pickshift32(instr, 24, 24, 1) | - pickshift32(instr, 21, 21, 0)); -} - -/* - * the 8 possible values for bits [28:24:21] in a Data Processing - * Register Instruction. Bits [28,25] are always _101 - */ - -enum DispatchDPReg { - DPREG_LOG_000, // Logical (shifted register) - DPREG_LOG_001, // ditto - DPREG_ADDSHF_010, // Add/subtract (shifted register) - DPREG_ADDEXT_011, // Add/subtract (extended register) - DPREG_ADDCOND_100, // Add/subtract (with carry) AND - // Cond compare/select AND - // Data Processing (1/2 source) - DPREG_UNALLOC_101, // Unallocated - DPREG_3SRC_110, // Data Processing (3 source) - DPREG_3SRC_111 // Data Processing (3 source) -}; - -// bits [31,29] of a BrExSys are the secondary dispatch vector - -static inline u_int32_t dispatchBrExSys(u_int32_t instr) -{ - return pickbits32(instr, 31, 29); -} - -/* - * the 8 possible values for bits [31,29] in a Branch/Exception/System - * Instruction. Bits [28,25] are always 101_ - */ - -enum DispatchBr { - BR_IMM_000, // Unconditional branch (immediate) - BR_IMMCMP_001, // Compare & branch (immediate) AND - // Test & branch (immediate) - BR_IMMCOND_010, // Conditional branch (immediate) AND Unallocated - BR_UNALLOC_011, // Unallocated - BR_IMM_100, // Unconditional branch (immediate) - BR_IMMCMP_101, // Compare & branch (immediate) AND - // Test & branch (immediate) - BR_REG_110, // Unconditional branch (register) AND System AND - // Excn gen AND Unallocated - BR_UNALLOC_111 // Unallocated -}; - -/* - * TODO still need to provide secondary decode and dispatch for - * AdvSIMD Insructions with instr[28,25] = 0111 or 1111 - */ - -#endif // ifndef DECODE_H diff --git a/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp index c9e8135390e..53922ed400f 100644 --- a/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp @@ -72,15 +72,12 @@ void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm } void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, - Register start, Register end, Register scratch, RegSet saved_regs) { + Register start, Register count, Register scratch, RegSet saved_regs) { __ push(saved_regs, sp); - // must compute element count unless barrier set interface is changed (other platforms supply count) - assert_different_registers(start, end, scratch); - __ lea(scratch, Address(end, BytesPerHeapOop)); - __ sub(scratch, scratch, start); // subtract start to get #bytes - __ lsr(scratch, scratch, LogBytesPerHeapOop); // convert to element count + assert_different_registers(start, count, scratch); + assert_different_registers(c_rarg0, count); __ mov(c_rarg0, start); - __ mov(c_rarg1, scratch); + __ mov(c_rarg1, count); __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry), 2); __ pop(saved_regs, sp); } diff --git a/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp b/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp index 965fd06b517..e38746f4f9e 100644 --- a/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp @@ -39,7 +39,7 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, RegSet saved_regs); void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, - Register start, Register end, Register tmp, RegSet saved_regs); + Register start, Register count, Register tmp, RegSet saved_regs); void g1_write_barrier_pre(MacroAssembler* masm, Register obj, diff --git a/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp index ad8c8c9d49a..2d3ebb7833a 100644 --- a/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp @@ -64,19 +64,22 @@ void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register ob } void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, - Register start, Register end, Register scratch, RegSet saved_regs) { + Register start, Register count, Register scratch, RegSet saved_regs) { BarrierSet* bs = BarrierSet::barrier_set(); CardTableBarrierSet* ctbs = barrier_set_cast(bs); CardTable* ct = ctbs->card_table(); - assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code"); - Label L_loop; + Label L_loop, L_done; + const Register end = count; + + __ cbz(count, L_done); // zero count - nothing to do + __ lea(end, Address(start, count, Address::lsl(LogBytesPerHeapOop))); // end = start + count << LogBytesPerHeapOop + __ sub(end, end, BytesPerHeapOop); // last element address to make inclusive __ lsr(start, start, CardTable::card_shift); __ lsr(end, end, CardTable::card_shift); - __ sub(end, end, start); // number of bytes to copy + __ sub(count, end, start); // number of bytes to copy - const Register count = end; // 'end' register contains bytes count now __ load_byte_map_base(scratch); __ add(start, start, scratch); if (ct->scanned_concurrently()) { @@ -86,6 +89,7 @@ void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembl __ strb(zr, Address(start, count)); __ subs(count, count, 1); __ br(Assembler::GE, L_loop); + __ bind(L_done); } void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, diff --git a/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.hpp b/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.hpp index d613c6d67cf..1be48f4c2a3 100644 --- a/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.hpp @@ -33,7 +33,7 @@ class CardTableBarrierSetAssembler: public ModRefBarrierSetAssembler { void store_check(MacroAssembler* masm, Register obj, Address dst); virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, - Register start, Register end, Register tmp, RegSet saved_regs); + Register start, Register count, Register tmp, RegSet saved_regs); virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Address dst, Register val, Register tmp1, Register tmp2); diff --git a/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.cpp index 7693e0b4bf3..a28c50169d8 100644 --- a/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.cpp @@ -37,10 +37,10 @@ void ModRefBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Decorat } void ModRefBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop, - Register start, Register end, Register tmp, + Register start, Register count, Register tmp, RegSet saved_regs) { if (is_oop) { - gen_write_ref_array_post_barrier(masm, decorators, start, end, tmp, saved_regs); + gen_write_ref_array_post_barrier(masm, decorators, start, count, tmp, saved_regs); } } diff --git a/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.hpp b/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.hpp index f0de0957047..e145b5d74f1 100644 --- a/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/gc/shared/modRefBarrierSetAssembler_aarch64.hpp @@ -37,7 +37,7 @@ class ModRefBarrierSetAssembler: public BarrierSetAssembler { virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, RegSet saved_regs) {} virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, - Register start, Register end, Register tmp, RegSet saved_regs) {} + Register start, Register count, Register tmp, RegSet saved_regs) {} virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Address dst, Register val, Register tmp1, Register tmp2) = 0; @@ -46,7 +46,7 @@ class ModRefBarrierSetAssembler: public BarrierSetAssembler { virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop, Register addr, Register count, RegSet saved_regs); virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop, - Register start, Register end, Register tmp, RegSet saved_regs); + Register start, Register count, Register tmp, RegSet saved_regs); virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Address dst, Register val, Register tmp1, Register tmp2); }; diff --git a/src/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/src/hotspot/cpu/aarch64/globals_aarch64.hpp index a8b1efb65f2..e28d4408629 100644 --- a/src/src/hotspot/cpu/aarch64/globals_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/globals_aarch64.hpp @@ -85,48 +85,6 @@ define_pd_global(bool, ThreadLocalHandshakes, true); define_pd_global(intx, InlineSmallCode, 1000); #endif -#ifdef BUILTIN_SIM -#define UseBuiltinSim true -#define ARCH_FLAGS(develop, \ - product, \ - diagnostic, \ - experimental, \ - notproduct, \ - range, \ - constraint, \ - writeable) \ - \ - product(bool, NotifySimulator, UseBuiltinSim, \ - "tell the AArch64 sim where we are in method code") \ - \ - product(bool, UseSimulatorCache, false, \ - "tell sim to cache memory updates until exclusive op occurs") \ - \ - product(bool, DisableBCCheck, true, \ - "tell sim not to invoke bccheck callback") \ - \ - product(bool, NearCpool, true, \ - "constant pool is close to instructions") \ - \ - product(bool, UseBarriersForVolatile, false, \ - "Use memory barriers to implement volatile accesses") \ - \ - product(bool, UseCRC32, false, \ - "Use CRC32 instructions for CRC32 computation") \ - \ - product(bool, UseLSE, false, \ - "Use LSE instructions") \ - -// Don't attempt to use Neon on builtin sim until builtin sim supports it -#define UseCRC32 false -#define UseSIMDForMemoryOps false -#define AvoidUnalignedAcesses false - -#else -#define UseBuiltinSim false -#define NotifySimulator false -#define UseSimulatorCache false -#define DisableBCCheck true #define ARCH_FLAGS(develop, \ product, \ diagnostic, \ @@ -165,7 +123,5 @@ define_pd_global(intx, InlineSmallCode, 1000); "Use prfm hint with specified distance in compiled code." \ "Value -1 means off.") \ range(-1, 4096) -#endif - #endif // CPU_AARCH64_VM_GLOBALS_AARCH64_HPP diff --git a/src/src/hotspot/cpu/aarch64/immediate_aarch64.cpp b/src/src/hotspot/cpu/aarch64/immediate_aarch64.cpp index 7410c0749e0..81a799587b9 100644 --- a/src/src/hotspot/cpu/aarch64/immediate_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/immediate_aarch64.cpp @@ -23,7 +23,6 @@ */ #include -#include "decode_aarch64.hpp" #include "immediate_aarch64.hpp" // there are at most 2^13 possible logical immediate encodings @@ -69,12 +68,57 @@ static inline u_int64_t ones(int N) return (N == 64 ? (u_int64_t)-1UL : ((1UL << N) - 1)); } +/* + * bit twiddling helpers for instruction decode + */ + +// 32 bit mask with bits [hi,...,lo] set +static inline u_int32_t mask32(int hi = 31, int lo = 0) +{ + int nbits = (hi + 1) - lo; + return ((1 << nbits) - 1) << lo; +} + +static inline u_int64_t mask64(int hi = 63, int lo = 0) +{ + int nbits = (hi + 1) - lo; + return ((1L << nbits) - 1) << lo; +} + +// pick bits [hi,...,lo] from val +static inline u_int32_t pick32(u_int32_t val, int hi = 31, int lo = 0) +{ + return (val & mask32(hi, lo)); +} + +// pick bits [hi,...,lo] from val +static inline u_int64_t pick64(u_int64_t val, int hi = 31, int lo = 0) +{ + return (val & mask64(hi, lo)); +} + +// mask [hi,lo] and shift down to start at bit 0 +static inline u_int32_t pickbits32(u_int32_t val, int hi = 31, int lo = 0) +{ + return (pick32(val, hi, lo) >> lo); +} + +// mask [hi,lo] and shift down to start at bit 0 +static inline u_int64_t pickbits64(u_int64_t val, int hi = 63, int lo = 0) +{ + return (pick64(val, hi, lo) >> lo); +} + // result<0> to val static inline u_int64_t pickbit(u_int64_t val, int N) { return pickbits64(val, N, N); } +static inline u_int32_t uimm(u_int32_t val, int hi, int lo) +{ + return pickbits32(val, hi, lo); +} // SPEC bits(M*N) Replicate(bits(M) x, integer N); // this is just an educated guess diff --git a/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp b/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp index 86a74782278..ae2e9a8835e 100644 --- a/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp @@ -260,29 +260,6 @@ void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprin // generate code to handle arguments iterate(fingerprint); - // set the call format - // n.b. allow extra 1 for the JNI_Env in c_rarg0 - unsigned int call_format = ((_num_int_args + 1) << 6) | (_num_fp_args << 2); - - switch (method()->result_type()) { - case T_VOID: - call_format |= MacroAssembler::ret_type_void; - break; - case T_FLOAT: - call_format |= MacroAssembler::ret_type_float; - break; - case T_DOUBLE: - call_format |= MacroAssembler::ret_type_double; - break; - default: - call_format |= MacroAssembler::ret_type_integral; - break; - } - - // // store the call format in the method - // __ movw(r0, call_format); - // __ str(r0, Address(rmethod, Method::call_format_offset())); - // return result handler __ lea(r0, ExternalAddress(Interpreter::result_handler(method()->result_type()))); __ ret(lr); @@ -393,28 +370,6 @@ class SlowSignatureHandler _num_fp_args = 0; } - // n.b. allow extra 1 for the JNI_Env in c_rarg0 - unsigned int get_call_format() - { - unsigned int call_format = ((_num_int_args + 1) << 6) | (_num_fp_args << 2); - - switch (method()->result_type()) { - case T_VOID: - call_format |= MacroAssembler::ret_type_void; - break; - case T_FLOAT: - call_format |= MacroAssembler::ret_type_float; - break; - case T_DOUBLE: - call_format |= MacroAssembler::ret_type_double; - break; - default: - call_format |= MacroAssembler::ret_type_integral; - break; - } - - return call_format; - } }; @@ -430,9 +385,6 @@ IRT_ENTRY(address, SlowSignatureHandler ssh(m, (address)from, to); ssh.iterate(UCONST64(-1)); - // // set the call format - // method->set_call_format(ssh.get_call_format()); - // return result handler return Interpreter::result_handler(m->result_type()); IRT_END diff --git a/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.hpp b/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.hpp index 70dd029e067..a403bf48c03 100644 --- a/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/interpreterRT_aarch64.hpp @@ -34,7 +34,6 @@ class SignatureHandlerGenerator: public NativeSignatureIterator { private: MacroAssembler* _masm; - unsigned int _call_format; unsigned int _num_fp_args; unsigned int _num_int_args; int _stack_offset; diff --git a/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 1895fde5fcb..508c13c274f 100644 --- a/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Red Hat Inc. 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 @@ -372,15 +372,9 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp, Register last_java_fp, address last_java_pc, Register scratch) { - if (last_java_pc != NULL) { - adr(scratch, last_java_pc); - } else { - // FIXME: This is almost never correct. We should delete all - // cases of set_last_Java_frame with last_java_pc=NULL and use the - // correct return address instead. - adr(scratch, pc()); - } + assert(last_java_pc != NULL, "must provide a valid PC"); + adr(scratch, last_java_pc); str(scratch, Address(rthread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset())); @@ -397,7 +391,7 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp, } else { InstructionMark im(this); L.add_patch_at(code(), locator()); - set_last_Java_frame(last_java_sp, last_java_fp, (address)NULL, scratch); + set_last_Java_frame(last_java_sp, last_java_fp, pc() /* Patched later */, scratch); } } @@ -812,6 +806,18 @@ address MacroAssembler::emit_trampoline_stub(int insts_call_instruction_offset, return stub_start_addr; } +void MacroAssembler::emit_static_call_stub() { + // CompiledDirectStaticCall::set_to_interpreted knows the + // exact layout of this stub. + + isb(); + mov_metadata(rmethod, (Metadata*)NULL); + + // Jump to the entry point of the i2c stub. + movptr(rscratch1, 0); + br(rscratch1); +} + void MacroAssembler::c2bool(Register x) { // implements x == 0 ? 0 : 1 // note: must only look at least-significant byte of x @@ -959,17 +965,6 @@ RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_ad return RegisterOrConstant(tmp); } - -void MacroAssembler:: notify(int type) { - if (type == bytecode_start) { - // set_last_Java_frame(esp, rfp, (address)NULL); - Assembler:: notify(type); - // reset_last_Java_frame(true); - } - else - Assembler:: notify(type); -} - // Look up the method for a megamorphic invokeinterface call. // The target method is determined by . // The receiver klass is in recv_klass. @@ -1383,22 +1378,12 @@ Address MacroAssembler::argument_address(RegisterOrConstant arg_slot, void MacroAssembler::call_VM_leaf_base(address entry_point, int number_of_arguments, Label *retaddr) { - call_VM_leaf_base1(entry_point, number_of_arguments, 0, ret_type_integral, retaddr); -} - -void MacroAssembler::call_VM_leaf_base1(address entry_point, - int number_of_gp_arguments, - int number_of_fp_arguments, - ret_type type, - Label *retaddr) { Label E, L; stp(rscratch1, rmethod, Address(pre(sp, -2 * wordSize))); - // We add 1 to number_of_arguments because the thread in arg0 is - // not counted mov(rscratch1, entry_point); - blrt(rscratch1, number_of_gp_arguments + 1, number_of_fp_arguments, type); + blr(rscratch1); if (retaddr) bind(*retaddr); @@ -2156,8 +2141,7 @@ void MacroAssembler::stop(const char* msg) { mov(c_rarg1, (address)ip); mov(c_rarg2, sp); mov(c_rarg3, CAST_FROM_FN_PTR(address, MacroAssembler::debug64)); - // call(c_rarg3); - blrt(c_rarg3, 3, 0, 1); + blr(c_rarg3); hlt(0); } @@ -2165,7 +2149,7 @@ void MacroAssembler::warn(const char* msg) { pusha(); mov(c_rarg0, (address)msg); mov(lr, CAST_FROM_FN_PTR(address, warning)); - blrt(lr, 1, 0, MacroAssembler::ret_type_void); + blr(lr); popa(); } @@ -2546,50 +2530,6 @@ void MacroAssembler::debug64(char* msg, int64_t pc, int64_t regs[]) } } -#ifdef BUILTIN_SIM -// routine to generate an x86 prolog for a stub function which -// bootstraps into the generated ARM code which directly follows the -// stub -// -// the argument encodes the number of general and fp registers -// passed by the caller and the callng convention (currently just -// the number of general registers and assumes C argument passing) - -extern "C" { -int aarch64_stub_prolog_size(); -void aarch64_stub_prolog(); -void aarch64_prolog(); -} - -void MacroAssembler::c_stub_prolog(int gp_arg_count, int fp_arg_count, int ret_type, - address *prolog_ptr) -{ - int calltype = (((ret_type & 0x3) << 8) | - ((fp_arg_count & 0xf) << 4) | - (gp_arg_count & 0xf)); - - // the addresses for the x86 to ARM entry code we need to use - address start = pc(); - // printf("start = %lx\n", start); - int byteCount = aarch64_stub_prolog_size(); - // printf("byteCount = %x\n", byteCount); - int instructionCount = (byteCount + 3)/ 4; - // printf("instructionCount = %x\n", instructionCount); - for (int i = 0; i < instructionCount; i++) { - nop(); - } - - memcpy(start, (void*)aarch64_stub_prolog, byteCount); - - // write the address of the setup routine and the call format at the - // end of into the copied code - u_int64_t *patch_end = (u_int64_t *)(start + byteCount); - if (prolog_ptr) - patch_end[-2] = (u_int64_t)prolog_ptr; - patch_end[-1] = calltype; -} -#endif - void MacroAssembler::push_call_clobbered_registers() { int step = 4 * wordSize; push(RegSet::range(r0, r18) - RegSet::of(rscratch1, rscratch2), sp); @@ -5619,7 +5559,6 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, mov(result, len); // Save initial len -#ifndef BUILTIN_SIM cmp(len, 8); // handle shortest strings first br(LT, LOOP_1); cmp(len, 32); @@ -5695,7 +5634,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, br(GE, NEXT_8); BIND(LOOP_1); -#endif + cbz(len, DONE); BIND(NEXT_1); ldrh(tmp1, Address(post(src, 2))); @@ -5834,7 +5773,7 @@ void MacroAssembler::get_thread(Register dst) { push(saved_regs, sp); mov(lr, CAST_FROM_FN_PTR(address, JavaThread::aarch64_get_thread_helper)); - blrt(lr, 1, 0, 1); + blr(lr); if (dst != c_rarg0) { mov(dst, c_rarg0); } diff --git a/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index 918cda7f4c5..af8056be094 100644 --- a/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -169,13 +169,10 @@ class MacroAssembler: public Assembler { virtual void _call_Unimplemented(address call_site) { mov(rscratch2, call_site); - haltsim(); } #define call_Unimplemented() _call_Unimplemented((address)__PRETTY_FUNCTION__) - virtual void notify(int type); - // aliases defined in AARCH64 spec template @@ -605,6 +602,7 @@ class MacroAssembler: public Assembler { static int patch_narrow_klass(address insn_addr, narrowKlass n); address emit_trampoline_stub(int insts_call_instruction_offset, address target); + void emit_static_call_stub(); // The following 4 methods return the offset of the appropriate move instruction @@ -1173,28 +1171,6 @@ class MacroAssembler: public Assembler { // public: - // enum used for aarch64--x86 linkage to define return type of x86 function - enum ret_type { ret_type_void, ret_type_integral, ret_type_float, ret_type_double}; - -#ifdef BUILTIN_SIM - void c_stub_prolog(int gp_arg_count, int fp_arg_count, int ret_type, address *prolog_ptr = NULL); -#else - void c_stub_prolog(int gp_arg_count, int fp_arg_count, int ret_type) { } -#endif - - // special version of call_VM_leaf_base needed for aarch64 simulator - // where we need to specify both the gp and fp arg counts and the - // return type so that the linkage routine from aarch64 to x86 and - // back knows which aarch64 registers to copy to x86 registers and - // which x86 result register to copy back to an aarch64 register - - void call_VM_leaf_base1( - address entry_point, // the entry point - int number_of_gp_arguments, // the number of gp reg arguments to pass - int number_of_fp_arguments, // the number of fp reg arguments to pass - ret_type type, // the return type for the call - Label* retaddr = NULL - ); void ldr_constant(Register dest, const Address &const_addr) { if (NearCpool) { diff --git a/src/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp b/src/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp index 4e99ddaf76f..74de7712b14 100644 --- a/src/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp @@ -230,7 +230,11 @@ void NativeCall::insert(address code_pos, address entry) { Unimplemented(); } //------------------------------------------------------------------- void NativeMovConstReg::verify() { - // make sure code pattern is actually mov reg64, imm64 instructions + if (! (nativeInstruction_at(instruction_address())->is_movz() || + is_adrp_at(instruction_address()) || + is_ldr_literal_at(instruction_address())) ) { + fatal("should be MOVZ or ADRP or LDR (literal)"); + } } diff --git a/src/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 3db6b914d4d..5dd4718ea62 100644 --- a/src/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Red Hat Inc. 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 @@ -50,10 +50,6 @@ #include "jvmci/jvmciJavaClasses.hpp" #endif -#ifdef BUILTIN_SIM -#include "../../../../../../simulator/simulator.hpp" -#endif - #define __ masm-> const int StackAlignmentInSlots = StackAlignmentInBytes / VMRegImpl::stack_slot_size; @@ -342,7 +338,7 @@ static void patch_callers_callsite(MacroAssembler *masm) { __ mov(c_rarg0, rmethod); __ mov(c_rarg1, lr); __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::fixup_callers_callsite))); - __ blrt(rscratch1, 2, 0, 0); + __ blr(rscratch1); __ maybe_isb(); __ pop_CPU_state(); @@ -662,71 +658,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm, __ br(rscratch1); } -#ifdef BUILTIN_SIM -static void generate_i2c_adapter_name(char *result, int total_args_passed, const BasicType *sig_bt) -{ - strcpy(result, "i2c("); - int idx = 4; - for (int i = 0; i < total_args_passed; i++) { - switch(sig_bt[i]) { - case T_BOOLEAN: - result[idx++] = 'Z'; - break; - case T_CHAR: - result[idx++] = 'C'; - break; - case T_FLOAT: - result[idx++] = 'F'; - break; - case T_DOUBLE: - assert((i < (total_args_passed - 1)) && (sig_bt[i+1] == T_VOID), - "double must be followed by void"); - i++; - result[idx++] = 'D'; - break; - case T_BYTE: - result[idx++] = 'B'; - break; - case T_SHORT: - result[idx++] = 'S'; - break; - case T_INT: - result[idx++] = 'I'; - break; - case T_LONG: - assert((i < (total_args_passed - 1)) && (sig_bt[i+1] == T_VOID), - "long must be followed by void"); - i++; - result[idx++] = 'L'; - break; - case T_OBJECT: - result[idx++] = 'O'; - break; - case T_ARRAY: - result[idx++] = '['; - break; - case T_ADDRESS: - result[idx++] = 'P'; - break; - case T_NARROWOOP: - result[idx++] = 'N'; - break; - case T_METADATA: - result[idx++] = 'M'; - break; - case T_NARROWKLASS: - result[idx++] = 'K'; - break; - default: - result[idx++] = '?'; - break; - } - } - result[idx++] = ')'; - result[idx] = '\0'; -} -#endif - // --------------------------------------------------------------- AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm, int total_args_passed, @@ -735,20 +666,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm const VMRegPair *regs, AdapterFingerPrint* fingerprint) { address i2c_entry = __ pc(); -#ifdef BUILTIN_SIM - char *name = NULL; - AArch64Simulator *sim = NULL; - size_t len = 65536; - if (NotifySimulator) { - name = NEW_C_HEAP_ARRAY(char, len, mtInternal); - } - if (name) { - generate_i2c_adapter_name(name, total_args_passed, sig_bt); - sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - sim->notifyCompile(name, i2c_entry); - } -#endif gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs); address c2i_unverified_entry = __ pc(); @@ -790,15 +708,6 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm address c2i_entry = __ pc(); -#ifdef BUILTIN_SIM - if (name) { - name[0] = 'c'; - name[2] = 'i'; - sim->notifyCompile(name, c2i_entry); - FREE_C_HEAP_ARRAY(char, name, mtInternal); - } -#endif - gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup); __ flush(); @@ -1200,8 +1109,7 @@ static void rt_call(MacroAssembler* masm, address dest, int gpargs, int fpargs, assert((unsigned)gpargs < 256, "eek!"); assert((unsigned)fpargs < 32, "eek!"); __ lea(rscratch1, RuntimeAddress(dest)); - if (UseBuiltinSim) __ mov(rscratch2, (gpargs << 6) | (fpargs << 2) | type); - __ blrt(rscratch1, rscratch2); + __ blr(rscratch1); __ maybe_isb(); } } @@ -1322,24 +1230,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, BasicType* in_sig_bt, VMRegPair* in_regs, BasicType ret_type) { -#ifdef BUILTIN_SIM - if (NotifySimulator) { - // Names are up to 65536 chars long. UTF8-coded strings are up to - // 3 bytes per character. We concatenate three such strings. - // Yes, I know this is ridiculous, but it's debug code and glibc - // allocates large arrays very efficiently. - size_t len = (65536 * 3) * 3; - char *name = new char[len]; - - strncpy(name, method()->method_holder()->name()->as_utf8(), len); - strncat(name, ".", len); - strncat(name, method()->name()->as_utf8(), len); - strncat(name, method()->signature()->as_utf8(), len); - AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck)->notifyCompile(name, __ pc()); - delete[] name; - } -#endif - if (method->is_method_handle_intrinsic()) { vmIntrinsics::ID iid = method->intrinsic_id(); intptr_t start = (intptr_t)__ pc(); @@ -1596,11 +1486,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, // Frame is now completed as far as size and linkage. int frame_complete = ((intptr_t)__ pc()) - start; - // record entry into native wrapper code - if (NotifySimulator) { - __ notify(Assembler::method_entry); - } - // We use r20 as the oop handle for the receiver/klass // It is callee save so it survives the call to native @@ -1781,14 +1666,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, } // Change state to native (we save the return address in the thread, since it might not - // be pushed on the stack when we do a a stack traversal). It is enough that the pc() - // points into the right code segment. It does not have to be the correct return pc. + // be pushed on the stack when we do a stack traversal). // We use the same pc/oopMap repeatedly when we call out - intptr_t the_pc = (intptr_t) __ pc(); - oop_maps->add_gc_map(the_pc - start, map); - - __ set_last_Java_frame(sp, noreg, (address)the_pc, rscratch1); + Label native_return; + __ set_last_Java_frame(sp, noreg, native_return, rscratch1); Label dtrace_method_entry, dtrace_method_entry_done; { @@ -1919,6 +1801,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, return_type); } + __ bind(native_return); + + intptr_t return_pc = (intptr_t) __ pc(); + oop_maps->add_gc_map(return_pc - start, map); + // Unpack native results. switch (ret_type) { case T_BOOLEAN: __ c2bool(r0); break; @@ -2071,11 +1958,6 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ cbnz(rscratch1, exception_pending); } - // record exit from native wrapper code - if (NotifySimulator) { - __ notify(Assembler::method_reentry); - } - // We're done __ ret(lr); @@ -2190,7 +2072,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, } else { __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition))); } - __ blrt(rscratch1, 1, 0, 1); + __ blr(rscratch1); __ maybe_isb(); // Restore any method result value restore_native_result(masm, ret_type, stack_slots); @@ -2287,14 +2169,6 @@ void SharedRuntime::generate_deopt_blob() { OopMap* map = NULL; OopMapSet *oop_maps = new OopMapSet(); -#ifdef BUILTIN_SIM - AArch64Simulator *simulator; - if (NotifySimulator) { - simulator = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - simulator->notifyCompile(const_cast("SharedRuntime::deopt_blob"), __ pc()); - } -#endif - // ------------- // This code enters when returning to a de-optimized nmethod. A return // address has been pushed on the the stack, and return values are in @@ -2383,7 +2257,7 @@ void SharedRuntime::generate_deopt_blob() { __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); - __ blrt(rscratch1, 2, 0, MacroAssembler::ret_type_integral); + __ blr(rscratch1); __ bind(retaddr); oop_maps->add_gc_map( __ pc()-start, map->deep_copy()); @@ -2475,7 +2349,7 @@ void SharedRuntime::generate_deopt_blob() { __ mov(c_rarg0, rthread); __ mov(c_rarg1, rcpool); __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::fetch_unroll_info))); - __ blrt(rscratch1, 1, 0, 1); + __ blr(rscratch1); __ bind(retaddr); // Need to have an oopmap that tells fetch_unroll_info where to @@ -2615,7 +2489,7 @@ void SharedRuntime::generate_deopt_blob() { __ mov(c_rarg0, rthread); __ movw(c_rarg1, rcpool); // second arg: exec_mode __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames))); - __ blrt(rscratch1, 2, 0, 0); + __ blr(rscratch1); // Set an oopmap for the call site // Use the same PC we used for the last java frame @@ -2648,12 +2522,6 @@ void SharedRuntime::generate_deopt_blob() { _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); } #endif -#ifdef BUILTIN_SIM - if (NotifySimulator) { - unsigned char *base = _deopt_blob->code_begin(); - simulator->notifyRelocate(start, base - start); - } -#endif } uint SharedRuntime::out_preserve_stack_slots() { @@ -2669,14 +2537,6 @@ void SharedRuntime::generate_uncommon_trap_blob() { CodeBuffer buffer("uncommon_trap_blob", 2048, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); -#ifdef BUILTIN_SIM - AArch64Simulator *simulator; - if (NotifySimulator) { - simulator = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - simulator->notifyCompile(const_cast("SharedRuntime:uncommon_trap_blob"), __ pc()); - } -#endif - assert(SimpleRuntimeFrame::framesize % 4 == 0, "sp not 16-byte aligned"); address start = __ pc(); @@ -2715,7 +2575,7 @@ void SharedRuntime::generate_uncommon_trap_blob() { __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); - __ blrt(rscratch1, 2, 0, MacroAssembler::ret_type_integral); + __ blr(rscratch1); __ bind(retaddr); // Set an oopmap for the call site @@ -2838,7 +2698,7 @@ void SharedRuntime::generate_uncommon_trap_blob() { __ mov(c_rarg0, rthread); __ movw(c_rarg1, (unsigned)Deoptimization::Unpack_uncommon_trap); __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames))); - __ blrt(rscratch1, 2, 0, MacroAssembler::ret_type_integral); + __ blr(rscratch1); // Set an oopmap for the call site // Use the same PC we used for the last java frame @@ -2858,13 +2718,6 @@ void SharedRuntime::generate_uncommon_trap_blob() { _uncommon_trap_blob = UncommonTrapBlob::create(&buffer, oop_maps, SimpleRuntimeFrame::framesize >> 1); - -#ifdef BUILTIN_SIM - if (NotifySimulator) { - unsigned char *base = _deopt_blob->code_begin(); - simulator->notifyRelocate(start, base - start); - } -#endif } #endif // COMPILER2_OR_JVMCI @@ -2914,7 +2767,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // Do the call __ mov(c_rarg0, rthread); __ lea(rscratch1, RuntimeAddress(call_ptr)); - __ blrt(rscratch1, 1, 0, 1); + __ blr(rscratch1); __ bind(retaddr); // Set an oopmap for the call site. This oopmap will map all @@ -3019,7 +2872,7 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha __ mov(c_rarg0, rthread); __ lea(rscratch1, RuntimeAddress(destination)); - __ blrt(rscratch1, 1, 0, 1); + __ blr(rscratch1); __ bind(retaddr); } @@ -3151,7 +3004,7 @@ void OptoRuntime::generate_exception_blob() { __ set_last_Java_frame(sp, noreg, the_pc, rscratch1); __ mov(c_rarg0, rthread); __ lea(rscratch1, RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C))); - __ blrt(rscratch1, 1, 0, MacroAssembler::ret_type_integral); + __ blr(rscratch1); __ maybe_isb(); // Set an oopmap for the call site. This oopmap will only be used if we diff --git a/src/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index 9824625051f..eff23b6ba54 100644 --- a/src/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,10 +46,6 @@ #include "opto/runtime.hpp" #endif -#ifdef BUILTIN_SIM -#include "../../../../../../simulator/simulator.hpp" -#endif - // Declaration and definition of StubGenerator (no .hpp file). // For a more detailed description of the stub routine structure // see the comment in stubRoutines.hpp @@ -217,16 +213,8 @@ class StubGenerator: public StubCodeGenerator { // stub code - // we need a C prolog to bootstrap the x86 caller into the sim - __ c_stub_prolog(8, 0, MacroAssembler::ret_type_void); - address aarch64_entry = __ pc(); -#ifdef BUILTIN_SIM - // Save sender's SP for stack traces. - __ mov(rscratch1, sp); - __ str(rscratch1, Address(__ pre(sp, -2 * wordSize))); -#endif // set up frame and move sp to end of save area __ enter(); __ sub(sp, rfp, -sp_after_call_off * wordSize); @@ -297,8 +285,6 @@ class StubGenerator: public StubCodeGenerator { __ mov(r13, sp); __ blr(c_rarg4); - // tell the simulator we have returned to the stub - // we do this here because the notify will already have been done // if we get to the next instruction via an exception // @@ -308,9 +294,6 @@ class StubGenerator: public StubCodeGenerator { // pc against the address saved below. so we may need to allow for // this extra instruction in the check. - if (NotifySimulator) { - __ notify(Assembler::method_reentry); - } // save current address for use by exception handling code return_address = __ pc(); @@ -373,12 +356,6 @@ class StubGenerator: public StubCodeGenerator { __ ldp(c_rarg4, c_rarg5, entry_point); __ ldp(c_rarg6, c_rarg7, parameter_size); -#ifndef PRODUCT - // tell the simulator we are about to end Java execution - if (NotifySimulator) { - __ notify(Assembler::method_exit); - } -#endif // leave frame and return to caller __ leave(); __ ret(lr); @@ -412,13 +389,6 @@ class StubGenerator: public StubCodeGenerator { // // r0: exception oop - // NOTE: this is used as a target from the signal handler so it - // needs an x86 prolog which returns into the current simulator - // executing the generated catch_exception code. so the prolog - // needs to install rax in a sim register and adjust the sim's - // restart pc to enter the generated code at the start position - // then return from native to simulated execution. - address generate_catch_exception() { StubCodeMark mark(this, "StubRoutines", "catch_exception"); address start = __ pc(); @@ -613,7 +583,7 @@ class StubGenerator: public StubCodeGenerator { #endif BLOCK_COMMENT("call MacroAssembler::debug"); __ mov(rscratch1, CAST_FROM_FN_PTR(address, MacroAssembler::debug64)); - __ blrt(rscratch1, 3, 0, 1); + __ blr(rscratch1); return start; } @@ -725,8 +695,11 @@ class StubGenerator: public StubCodeGenerator { stub_name = "forward_copy_longs"; else stub_name = "backward_copy_longs"; - StubCodeMark mark(this, "StubRoutines", stub_name); + __ align(CodeEntryAlignment); + + StubCodeMark mark(this, "StubRoutines", stub_name); + __ bind(start); Label unaligned_copy_long; @@ -1372,8 +1345,6 @@ class StubGenerator: public StubCodeGenerator { __ pop(RegSet::of(d, count), sp); if (VerifyOops) verify_oop_array(size, d, count, r16); - __ sub(count, count, 1); // make an inclusive end pointer - __ lea(count, Address(d, count, Address::lsl(exact_log2(size)))); } bs->arraycopy_epilogue(_masm, decorators, is_oop, d, count, rscratch1, RegSet()); @@ -1381,12 +1352,6 @@ class StubGenerator: public StubCodeGenerator { __ leave(); __ mov(r0, zr); // return 0 __ ret(lr); -#ifdef BUILTIN_SIM - { - AArch64Simulator *sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - sim->notifyCompile(const_cast(name), start); - } -#endif return start; } @@ -1445,19 +1410,11 @@ class StubGenerator: public StubCodeGenerator { __ pop(RegSet::of(d, count), sp); if (VerifyOops) verify_oop_array(size, d, count, r16); - __ sub(count, count, 1); // make an inclusive end pointer - __ lea(count, Address(d, count, Address::lsl(exact_log2(size)))); } bs->arraycopy_epilogue(_masm, decorators, is_oop, d, count, rscratch1, RegSet()); __ leave(); __ mov(r0, zr); // return 0 __ ret(lr); -#ifdef BUILTIN_SIM - { - AArch64Simulator *sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - sim->notifyCompile(const_cast(name), start); - } -#endif return start; } @@ -1789,7 +1746,7 @@ class StubGenerator: public StubCodeGenerator { } #endif //ASSERT - DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_CHECKCAST; + DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT; bool is_oop = true; if (dest_uninitialized) { decorators |= IS_DEST_UNINITIALIZED; @@ -1839,8 +1796,7 @@ class StubGenerator: public StubCodeGenerator { __ br(Assembler::EQ, L_done_pop); __ BIND(L_do_card_marks); - __ add(to, to, -heapOopSize); // make an inclusive end pointer - bs->arraycopy_epilogue(_masm, decorators, is_oop, start_to, to, rscratch1, wb_post_saved_regs); + bs->arraycopy_epilogue(_masm, decorators, is_oop, start_to, count_save, rscratch1, wb_post_saved_regs); __ bind(L_done_pop); __ pop(RegSet::of(r18, r19, r20, r21), sp); @@ -1976,13 +1932,13 @@ class StubGenerator: public StubCodeGenerator { const Register dst_pos = c_rarg3; // destination position const Register length = c_rarg4; - StubCodeMark mark(this, "StubRoutines", name); + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); // Registers used as temps const Register dst_klass = c_rarg5; - __ align(CodeEntryAlignment); address start = __ pc(); __ enter(); // required for proper stackwalking of RuntimeStub frame @@ -3105,7 +3061,6 @@ class StubGenerator: public StubCodeGenerator { return start; } -#ifndef BUILTIN_SIM // Safefetch stubs. void generate_safefetch(const char* name, int size, address* entry, address* fault_pc, address* continuation_pc) { @@ -3145,7 +3100,6 @@ class StubGenerator: public StubCodeGenerator { __ mov(r0, c_rarg1); __ ret(lr); } -#endif /** * Arguments: @@ -3657,7 +3611,6 @@ class StubGenerator: public StubCodeGenerator { } address generate_has_negatives(address &has_negatives_long) { - StubCodeMark mark(this, "StubRoutines", "has_negatives"); const int large_loop_size = 64; const uint64_t UPPER_BIT_MASK=0x8080808080808080; int dcache_line = VM_Version::dcache_line_size(); @@ -3665,6 +3618,9 @@ class StubGenerator: public StubCodeGenerator { Register ary1 = r1, len = r2, result = r0; __ align(CodeEntryAlignment); + + StubCodeMark mark(this, "StubRoutines", "has_negatives"); + address entry = __ pc(); __ enter(); @@ -3904,7 +3860,6 @@ class StubGenerator: public StubCodeGenerator { // cnt1 = r10 - amount of elements left to check, reduced by wordSize // r3-r5 are reserved temporary registers address generate_large_array_equals() { - StubCodeMark mark(this, "StubRoutines", "large_array_equals"); Register a1 = r1, a2 = r2, result = r0, cnt1 = r10, tmp1 = rscratch1, tmp2 = rscratch2, tmp3 = r3, tmp4 = r4, tmp5 = r5, tmp6 = r11, tmp7 = r12, tmp8 = r13; @@ -3919,6 +3874,9 @@ class StubGenerator: public StubCodeGenerator { tmp5, tmp6, tmp7, tmp8); __ align(CodeEntryAlignment); + + StubCodeMark mark(this, "StubRoutines", "large_array_equals"); + address entry = __ pc(); __ enter(); __ sub(cnt1, cnt1, wordSize); // first 8 bytes were loaded outside of stub @@ -4077,14 +4035,14 @@ class StubGenerator: public StubCodeGenerator { : "compare_long_string_different_encoding UL"); address entry = __ pc(); Label SMALL_LOOP, TAIL, TAIL_LOAD_16, LOAD_LAST, DIFF1, DIFF2, - DONE, CALCULATE_DIFFERENCE, LARGE_LOOP_PREFETCH, SMALL_LOOP_ENTER, + DONE, CALCULATE_DIFFERENCE, LARGE_LOOP_PREFETCH, NO_PREFETCH, LARGE_LOOP_PREFETCH_REPEAT1, LARGE_LOOP_PREFETCH_REPEAT2; Register result = r0, str1 = r1, cnt1 = r2, str2 = r3, cnt2 = r4, tmp1 = r10, tmp2 = r11, tmp3 = r12, tmp4 = r14; FloatRegister vtmpZ = v0, vtmp = v1, vtmp3 = v2; RegSet spilled_regs = RegSet::of(tmp3, tmp4); - int prefetchLoopExitCondition = MAX(32, SoftwarePrefetchHintDistance/2); + int prefetchLoopExitCondition = MAX(64, SoftwarePrefetchHintDistance/2); __ eor(vtmpZ, __ T16B, vtmpZ, vtmpZ); // cnt2 == amount of characters left to compare @@ -4111,7 +4069,7 @@ class StubGenerator: public StubCodeGenerator { if (SoftwarePrefetchHintDistance >= 0) { __ cmp(cnt2, prefetchLoopExitCondition); - __ br(__ LT, SMALL_LOOP); + __ br(__ LT, NO_PREFETCH); __ bind(LARGE_LOOP_PREFETCH); __ prfm(Address(tmp2, SoftwarePrefetchHintDistance)); __ mov(tmp4, 2); @@ -4131,51 +4089,20 @@ class StubGenerator: public StubCodeGenerator { __ br(__ GE, LARGE_LOOP_PREFETCH); } __ cbz(cnt2, LOAD_LAST); // no characters left except last load + __ bind(NO_PREFETCH); __ subs(cnt2, cnt2, 16); __ br(__ LT, TAIL); - __ b(SMALL_LOOP_ENTER); __ bind(SMALL_LOOP); // smaller loop __ subs(cnt2, cnt2, 16); - __ bind(SMALL_LOOP_ENTER); compare_string_16_x_LU(tmpL, tmpU, DIFF1, DIFF2); __ br(__ GE, SMALL_LOOP); - __ cbz(cnt2, LOAD_LAST); - __ bind(TAIL); // 1..15 characters left - __ cmp(cnt2, -8); - __ br(__ GT, TAIL_LOAD_16); - __ ldrd(vtmp, Address(tmp2)); - __ zip1(vtmp3, __ T8B, vtmp, vtmpZ); - - __ ldr(tmpU, Address(__ post(cnt1, 8))); - __ fmovd(tmpL, vtmp3); - __ eor(rscratch2, tmp3, tmpL); - __ cbnz(rscratch2, DIFF2); - __ umov(tmpL, vtmp3, __ D, 1); - __ eor(rscratch2, tmpU, tmpL); - __ cbnz(rscratch2, DIFF1); - __ b(LOAD_LAST); - __ bind(TAIL_LOAD_16); - __ ldrq(vtmp, Address(tmp2)); - __ ldr(tmpU, Address(__ post(cnt1, 8))); - __ zip1(vtmp3, __ T16B, vtmp, vtmpZ); - __ zip2(vtmp, __ T16B, vtmp, vtmpZ); - __ fmovd(tmpL, vtmp3); - __ eor(rscratch2, tmp3, tmpL); - __ cbnz(rscratch2, DIFF2); - - __ ldr(tmp3, Address(__ post(cnt1, 8))); - __ umov(tmpL, vtmp3, __ D, 1); - __ eor(rscratch2, tmpU, tmpL); - __ cbnz(rscratch2, DIFF1); - - __ ldr(tmpU, Address(__ post(cnt1, 8))); - __ fmovd(tmpL, vtmp); - __ eor(rscratch2, tmp3, tmpL); - __ cbnz(rscratch2, DIFF2); - - __ umov(tmpL, vtmp, __ D, 1); - __ eor(rscratch2, tmpU, tmpL); - __ cbnz(rscratch2, DIFF1); + __ cmn(cnt2, (u1)16); + __ br(__ EQ, LOAD_LAST); + __ bind(TAIL); // 1..15 characters left until last load (last 4 characters) + __ add(cnt1, cnt1, cnt2, __ LSL, 1); // Address of 8 bytes before last 4 characters in UTF-16 string + __ add(tmp2, tmp2, cnt2); // Address of 16 bytes before last 4 characters in Latin1 string + __ ldr(tmp3, Address(cnt1, -8)); + compare_string_16_x_LU(tmpL, tmpU, DIFF1, DIFF2); // last 16 characters before last load __ b(LOAD_LAST); __ bind(DIFF2); __ mov(tmpU, tmp3); @@ -4183,10 +4110,12 @@ class StubGenerator: public StubCodeGenerator { __ pop(spilled_regs, sp); __ b(CALCULATE_DIFFERENCE); __ bind(LOAD_LAST); + // Last 4 UTF-16 characters are already pre-loaded into tmp3 by compare_string_16_x_LU. + // No need to load it again + __ mov(tmpU, tmp3); __ pop(spilled_regs, sp); __ ldrs(vtmp, Address(strL)); - __ ldr(tmpU, Address(strU)); __ zip1(vtmp, __ T8B, vtmp, vtmpZ); __ fmovd(tmpL, vtmp); @@ -4248,10 +4177,10 @@ class StubGenerator: public StubCodeGenerator { compare_string_16_bytes_same(DIFF, DIFF2); __ br(__ GT, LARGE_LOOP_PREFETCH); __ cbz(cnt2, LAST_CHECK_AND_LENGTH_DIFF); // no more chars left? - // less than 16 bytes left? - __ subs(cnt2, cnt2, isLL ? 16 : 8); - __ br(__ LT, TAIL); } + // less than 16 bytes left? + __ subs(cnt2, cnt2, isLL ? 16 : 8); + __ br(__ LT, TAIL); __ bind(SMALL_LOOP); compare_string_16_bytes_same(DIFF, DIFF2); __ subs(cnt2, cnt2, isLL ? 16 : 8); @@ -4380,6 +4309,7 @@ class StubGenerator: public StubCodeGenerator { __ ldr(ch1, Address(str1)); // Read whole register from str2. It is safe, because length >=8 here __ ldr(ch2, Address(str2)); + __ sub(cnt2, cnt2, cnt1); __ andr(first, ch1, str1_isL ? 0xFF : 0xFFFF); if (str1_isL != str2_isL) { __ eor(v0, __ T16B, v0, v0); @@ -4838,7 +4768,7 @@ class StubGenerator: public StubCodeGenerator { // Set up last_Java_sp and last_Java_fp address the_pc = __ pc(); - __ set_last_Java_frame(sp, rfp, (address)NULL, rscratch1); + __ set_last_Java_frame(sp, rfp, the_pc, rscratch1); // Call runtime if (arg1 != noreg) { @@ -4851,7 +4781,7 @@ class StubGenerator: public StubCodeGenerator { __ mov(c_rarg0, rthread); BLOCK_COMMENT("call runtime_entry"); __ mov(rscratch1, runtime_entry); - __ blrt(rscratch1, 3 /* number_of_arguments */, 0, 1); + __ blr(rscratch1); // Generate oop map OopMap* map = new OopMap(framesize, 0); @@ -5825,7 +5755,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_montgomerySquare = g.generate_multiply(); } -#ifndef BUILTIN_SIM // generate GHASH intrinsics code if (UseGHASHIntrinsics) { StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks(); @@ -5859,7 +5788,6 @@ class StubGenerator: public StubCodeGenerator { generate_safefetch("SafeFetchN", sizeof(intptr_t), &StubRoutines::_safefetchN_entry, &StubRoutines::_safefetchN_fault_pc, &StubRoutines::_safefetchN_continuation_pc); -#endif StubRoutines::aarch64::set_completed(); } diff --git a/src/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp b/src/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp index 4315b5194c4..3e7d42dbe0a 100644 --- a/src/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp +++ b/src/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp @@ -30,13 +30,8 @@ // definition. See stubRoutines.hpp for a description on how to // extend it. -// n.b. if we are notifying entry/exit to the simulator then the call -// stub does a notify at normal return placing -// call_stub_return_address one instruction beyond the notify. the -// latter address is sued by the stack unwind code when doign an -// exception return. static bool returns_to_call_stub(address return_pc) { - return return_pc == _call_stub_return_address + (NotifySimulator ? -4 : 0); + return return_pc == _call_stub_return_address; } enum platform_dependent_constants { diff --git a/src/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp b/src/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp index e19fb924af5..45e47f19e59 100644 --- a/src/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Red Hat Inc. 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 @@ -55,10 +55,6 @@ #include "oops/method.hpp" #endif // !PRODUCT -#ifdef BUILTIN_SIM -#include "../../../../../../simulator/simulator.hpp" -#endif - // Size of interpreter code. Increase if too small. Interpreter will // fail with a guarantee ("not enough space for interpreter generation"); // if too small. @@ -300,9 +296,8 @@ void TemplateInterpreterGenerator::generate_transcendental_entry(AbstractInterpr ShouldNotReachHere(); fn = NULL; // unreachable } - const int gpargs = 0, rtype = 3; __ mov(rscratch1, fn); - __ blrt(rscratch1, gpargs, fpargs, rtype); + __ blr(rscratch1); } // Abstract method entry @@ -469,13 +464,6 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, __ sub(rscratch1, rscratch2, rscratch1, ext::uxtw, 3); __ andr(sp, rscratch1, -16); -#ifndef PRODUCT - // tell the simulator that the method has been reentered - if (NotifySimulator) { - __ notify(Assembler::method_reentry); - } -#endif - __ check_and_handle_popframe(rthread); __ check_and_handle_earlyret(rthread); @@ -514,7 +502,7 @@ address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, // only occur on method entry so emit it only for vtos with step 0. if ((EnableJVMCI || UseAOT) && state == vtos && step == 0) { Label L; - __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset())); + __ ldrb(rscratch1, Address(rthread, JavaThread::pending_monitorenter_offset())); __ cbz(rscratch1, L); // Clear flag. __ strb(zr, Address(rthread, JavaThread::pending_monitorenter_offset())); @@ -525,7 +513,7 @@ address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, #ifdef ASSERT if (EnableJVMCI) { Label L; - __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset())); + __ ldrb(rscratch1, Address(rthread, JavaThread::pending_monitorenter_offset())); __ cbz(rscratch1, L); __ stop("unexpected pending monitor in deopt entry"); __ bind(L); @@ -1180,12 +1168,6 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // initialize fixed part of activation frame generate_fixed_frame(true); -#ifndef PRODUCT - // tell the simulator that a method has been entered - if (NotifySimulator) { - __ notify(Assembler::method_entry); - } -#endif // make sure method is native & not abstract #ifdef ASSERT @@ -1346,9 +1328,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // pass JNIEnv __ add(c_rarg0, rthread, in_bytes(JavaThread::jni_environment_offset())); - // It is enough that the pc() points into the right code - // segment. It does not have to be the correct return pc. - __ set_last_Java_frame(esp, rfp, (address)NULL, rscratch1); + // Set the last Java PC in the frame anchor to be the return address from + // the call to the native method: this will allow the debugger to + // generate an accurate stack trace. + Label native_return; + __ set_last_Java_frame(esp, rfp, native_return, rscratch1); // change thread state #ifdef ASSERT @@ -1368,7 +1352,8 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { __ stlrw(rscratch1, rscratch2); // Call the native method. - __ blrt(r10, rscratch1); + __ blr(r10); + __ bind(native_return); __ maybe_isb(); __ get_method(rmethod); // result potentially in r0 or v0 @@ -1417,7 +1402,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // __ mov(c_rarg0, rthread); __ mov(rscratch2, CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)); - __ blrt(rscratch2, 1, 0, 0); + __ blr(rscratch2); __ maybe_isb(); __ get_method(rmethod); __ reinit_heapbase(); @@ -1468,7 +1453,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { __ pusha(); // XXX only save smashed registers __ mov(c_rarg0, rthread); __ mov(rscratch2, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages)); - __ blrt(rscratch2, 0, 0, 0); + __ blr(rscratch2); __ popa(); // XXX only restore smashed registers __ bind(no_reguard); } @@ -1623,12 +1608,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { // initialize fixed part of activation frame generate_fixed_frame(false); -#ifndef PRODUCT - // tell the simulator that a method has been entered - if (NotifySimulator) { - __ notify(Assembler::method_entry); - } -#endif + // make sure method is not native & not abstract #ifdef ASSERT __ ldrw(r0, access_flags); @@ -1764,13 +1744,6 @@ void TemplateInterpreterGenerator::generate_throw_exception() { __ reinit_heapbase(); // restore rheapbase as heapbase. __ get_dispatch(); -#ifndef PRODUCT - // tell the simulator that the caller method has been reentered - if (NotifySimulator) { - __ get_method(rmethod); - __ notify(Assembler::method_reentry); - } -#endif // Entry point for exceptions thrown within interpreter code Interpreter::_throw_exception_entry = __ pc(); // If we came here via a NullPointerException on the receiver of a @@ -2088,121 +2061,4 @@ void TemplateInterpreterGenerator::stop_interpreter_at() { __ pop(rscratch1); } -#ifdef BUILTIN_SIM - -#include -#include - -extern "C" { - static int PAGESIZE = getpagesize(); - int is_mapped_address(u_int64_t address) - { - address = (address & ~((u_int64_t)PAGESIZE - 1)); - if (msync((void *)address, PAGESIZE, MS_ASYNC) == 0) { - return true; - } - if (errno != ENOMEM) { - return true; - } - return false; - } - - void bccheck1(u_int64_t pc, u_int64_t fp, char *method, int *bcidx, int *framesize, char *decode) - { - if (method != 0) { - method[0] = '\0'; - } - if (bcidx != 0) { - *bcidx = -2; - } - if (decode != 0) { - decode[0] = 0; - } - - if (framesize != 0) { - *framesize = -1; - } - - if (Interpreter::contains((address)pc)) { - AArch64Simulator *sim = AArch64Simulator::get_current(UseSimulatorCache, DisableBCCheck); - Method* meth; - address bcp; - if (fp) { -#define FRAME_SLOT_METHOD 3 -#define FRAME_SLOT_BCP 7 - meth = (Method*)sim->getMemory()->loadU64(fp - (FRAME_SLOT_METHOD << 3)); - bcp = (address)sim->getMemory()->loadU64(fp - (FRAME_SLOT_BCP << 3)); -#undef FRAME_SLOT_METHOD -#undef FRAME_SLOT_BCP - } else { - meth = (Method*)sim->getCPUState().xreg(RMETHOD, 0); - bcp = (address)sim->getCPUState().xreg(RBCP, 0); - } - if (meth->is_native()) { - return; - } - if(method && meth->is_method()) { - ResourceMark rm; - method[0] = 'I'; - method[1] = ' '; - meth->name_and_sig_as_C_string(method + 2, 398); - } - if (bcidx) { - if (meth->contains(bcp)) { - *bcidx = meth->bci_from(bcp); - } else { - *bcidx = -2; - } - } - if (decode) { - if (!BytecodeTracer::closure()) { - BytecodeTracer::set_closure(BytecodeTracer::std_closure()); - } - stringStream str(decode, 400); - BytecodeTracer::trace(meth, bcp, &str); - } - } else { - if (method) { - CodeBlob *cb = CodeCache::find_blob((address)pc); - if (cb != NULL) { - if (cb->is_nmethod()) { - ResourceMark rm; - nmethod* nm = (nmethod*)cb; - method[0] = 'C'; - method[1] = ' '; - nm->method()->name_and_sig_as_C_string(method + 2, 398); - } else if (cb->is_adapter_blob()) { - strcpy(method, "B adapter blob"); - } else if (cb->is_runtime_stub()) { - strcpy(method, "B runtime stub"); - } else if (cb->is_exception_stub()) { - strcpy(method, "B exception stub"); - } else if (cb->is_deoptimization_stub()) { - strcpy(method, "B deoptimization stub"); - } else if (cb->is_safepoint_stub()) { - strcpy(method, "B safepoint stub"); - } else if (cb->is_uncommon_trap_stub()) { - strcpy(method, "B uncommon trap stub"); - } else if (cb->contains((address)StubRoutines::call_stub())) { - strcpy(method, "B call stub"); - } else { - strcpy(method, "B unknown blob : "); - strcat(method, cb->name()); - } - if (framesize != NULL) { - *framesize = cb->frame_size(); - } - } - } - } - } - - - JNIEXPORT void bccheck(u_int64_t pc, u_int64_t fp, char *method, int *bcidx, int *framesize, char *decode) - { - bccheck1(pc, fp, method, bcidx, framesize, decode); - } -} - -#endif // BUILTIN_SIM #endif // !PRODUCT diff --git a/src/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index c9a3d927200..b8a9a46a827 100644 --- a/src/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -1478,8 +1478,7 @@ void TemplateTable::fop2(Operation op) case rem: __ fmovs(v1, v0); __ pop_f(v0); - __ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::frem), - 0, 2, MacroAssembler::ret_type_float); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::frem)); break; default: ShouldNotReachHere(); @@ -1511,8 +1510,7 @@ void TemplateTable::dop2(Operation op) case rem: __ fmovd(v1, v0); __ pop_d(v0); - __ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::drem), - 0, 2, MacroAssembler::ret_type_double); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::drem)); break; default: ShouldNotReachHere(); @@ -1653,8 +1651,7 @@ void TemplateTable::convert() __ fcvtzsw(r0, v0); __ get_fpsr(r1); __ cbzw(r1, L_Okay); - __ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::f2i), - 0, 1, MacroAssembler::ret_type_integral); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2i)); __ bind(L_Okay); } break; @@ -1665,8 +1662,7 @@ void TemplateTable::convert() __ fcvtzs(r0, v0); __ get_fpsr(r1); __ cbzw(r1, L_Okay); - __ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::f2l), - 0, 1, MacroAssembler::ret_type_integral); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2l)); __ bind(L_Okay); } break; @@ -1680,8 +1676,7 @@ void TemplateTable::convert() __ fcvtzdw(r0, v0); __ get_fpsr(r1); __ cbzw(r1, L_Okay); - __ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::d2i), - 0, 1, MacroAssembler::ret_type_integral); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2i)); __ bind(L_Okay); } break; @@ -1692,8 +1687,7 @@ void TemplateTable::convert() __ fcvtzd(r0, v0); __ get_fpsr(r1); __ cbzw(r1, L_Okay); - __ call_VM_leaf_base1(CAST_FROM_FN_PTR(address, SharedRuntime::d2l), - 0, 1, MacroAssembler::ret_type_integral); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); __ bind(L_Okay); } break; @@ -2719,7 +2713,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr { Label notVolatile; __ tbz(r5, ConstantPoolCacheEntry::is_volatile_shift, notVolatile); - __ membar(MacroAssembler::StoreStore); + __ membar(MacroAssembler::StoreStore | MacroAssembler::LoadStore); __ bind(notVolatile); } @@ -2884,7 +2878,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr { Label notVolatile; __ tbz(r5, ConstantPoolCacheEntry::is_volatile_shift, notVolatile); - __ membar(MacroAssembler::StoreLoad); + __ membar(MacroAssembler::StoreLoad | MacroAssembler::StoreStore); __ bind(notVolatile); } } @@ -2979,7 +2973,7 @@ void TemplateTable::fast_storefield(TosState state) { Label notVolatile; __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile); - __ membar(MacroAssembler::StoreStore); + __ membar(MacroAssembler::StoreStore | MacroAssembler::LoadStore); __ bind(notVolatile); } @@ -3027,7 +3021,7 @@ void TemplateTable::fast_storefield(TosState state) { Label notVolatile; __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile); - __ membar(MacroAssembler::StoreLoad); + __ membar(MacroAssembler::StoreLoad | MacroAssembler::StoreStore); __ bind(notVolatile); } } diff --git a/src/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index c5d7a61e385..b2e85fc924c 100644 --- a/src/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -34,12 +34,8 @@ #include OS_HEADER_INLINE(os) -#ifndef BUILTIN_SIM #include #include -#else -#define getauxval(hwcap) 0 -#endif #ifndef HWCAP_AES #define HWCAP_AES (1<<3) @@ -92,10 +88,6 @@ class VM_Version_StubGenerator: public StubCodeGenerator { # define __ _masm-> address start = __ pc(); -#ifdef BUILTIN_SIM - __ c_stub_prolog(1, 0, MacroAssembler::ret_type_void); -#endif - // void getPsrInfo(VM_Version::PsrInfo* psr_info); address entry = __ pc(); diff --git a/src/src/hotspot/cpu/aarch64/vm_version_ext_aarch64.cpp b/src/src/hotspot/cpu/aarch64/vm_version_ext_aarch64.cpp index 6444a9b3568..ebabc3723c2 100644 --- a/src/src/hotspot/cpu/aarch64/vm_version_ext_aarch64.cpp +++ b/src/src/hotspot/cpu/aarch64/vm_version_ext_aarch64.cpp @@ -50,7 +50,7 @@ void VM_Version_Ext::initialize_cpu_information(void) { _no_of_threads = _no_of_cores; _no_of_sockets = _no_of_cores; snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE - 1, "AArch64"); - snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "%s", _features_string); + snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "AArch64 %s", _features_string); _initialized = true; } diff --git a/src/src/hotspot/cpu/arm/templateTable_arm.cpp b/src/src/hotspot/cpu/arm/templateTable_arm.cpp index 13726c30c5b..ac757f5b750 100644 --- a/src/src/hotspot/cpu/arm/templateTable_arm.cpp +++ b/src/src/hotspot/cpu/arm/templateTable_arm.cpp @@ -527,19 +527,20 @@ void TemplateTable::ldc2_w() { __ add(Rbase, Rcpool, AsmOperand(Rindex, lsl, LogBytesPerWord)); - Label Condy, exit; -#ifdef __ABI_HARD__ - Label Long; // get type from tags __ add(Rtemp, Rtags, tags_offset); __ ldrb(Rtemp, Address(Rtemp, Rindex)); + + Label Condy, exit; +#ifdef __ABI_HARD__ + Label NotDouble; __ cmp(Rtemp, JVM_CONSTANT_Double); - __ b(Long, ne); + __ b(NotDouble, ne); __ ldr_double(D0_tos, Address(Rbase, base_offset)); __ push(dtos); __ b(exit); - __ bind(Long); + __ bind(NotDouble); #endif __ cmp(Rtemp, JVM_CONSTANT_Long); diff --git a/src/src/hotspot/cpu/ppc/frame_ppc.hpp b/src/src/hotspot/cpu/ppc/frame_ppc.hpp index 6a0c4bfd136..50111279ca7 100644 --- a/src/src/hotspot/cpu/ppc/frame_ppc.hpp +++ b/src/src/hotspot/cpu/ppc/frame_ppc.hpp @@ -250,9 +250,6 @@ (offset_of(frame::top_ijava_frame_abi, _component)) struct ijava_state { -#ifdef ASSERT - uint64_t ijava_reserved; // Used for assertion. -#endif uint64_t method; uint64_t mirror; uint64_t locals; @@ -409,12 +406,6 @@ // The size of a cInterpreter object. static inline int interpreter_frame_cinterpreterstate_size_in_bytes(); - private: - - ConstantPoolCache** interpreter_frame_cpoolcache_addr() const; - - public: - // Additional interface for entry frames: inline entry_frame_locals* get_entry_frame_locals() const { return (entry_frame_locals*) (((address) fp()) - entry_frame_locals_size); diff --git a/src/src/hotspot/cpu/ppc/frame_ppc.inline.hpp b/src/src/hotspot/cpu/ppc/frame_ppc.inline.hpp index a1a660041be..a9949984059 100644 --- a/src/src/hotspot/cpu/ppc/frame_ppc.inline.hpp +++ b/src/src/hotspot/cpu/ppc/frame_ppc.inline.hpp @@ -130,19 +130,22 @@ inline frame::ijava_state* frame::get_ijava_state() const { inline intptr_t** frame::interpreter_frame_locals_addr() const { return (intptr_t**) &(get_ijava_state()->locals); } + inline intptr_t* frame::interpreter_frame_bcp_addr() const { return (intptr_t*) &(get_ijava_state()->bcp); } + inline intptr_t* frame::interpreter_frame_mdp_addr() const { return (intptr_t*) &(get_ijava_state()->mdx); } + // Pointer beyond the "oldest/deepest" BasicObjectLock on stack. inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { - return (BasicObjectLock *) get_ijava_state()->monitors; + return (BasicObjectLock*) get_ijava_state()->monitors; } inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { - return (BasicObjectLock *) get_ijava_state(); + return (BasicObjectLock*) get_ijava_state(); } // Return register stack slot addr at which currently interpreted method is found. @@ -154,23 +157,21 @@ inline oop* frame::interpreter_frame_mirror_addr() const { return (oop*) &(get_ijava_state()->mirror); } -inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const { - return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache); -} inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache); } inline oop* frame::interpreter_frame_temp_oop_addr() const { - return (oop *) &(get_ijava_state()->oop_tmp); + return (oop*) &(get_ijava_state()->oop_tmp); } + inline intptr_t* frame::interpreter_frame_esp() const { return (intptr_t*) get_ijava_state()->esp; } // Convenient setters inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* end) { get_ijava_state()->monitors = (intptr_t) end;} -inline void frame::interpreter_frame_set_cpcache(ConstantPoolCache* cp) { *frame::interpreter_frame_cpoolcache_addr() = cp; } +inline void frame::interpreter_frame_set_cpcache(ConstantPoolCache* cp) { *interpreter_frame_cache_addr() = cp; } inline void frame::interpreter_frame_set_esp(intptr_t* esp) { get_ijava_state()->esp = (intptr_t) esp; } inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) { get_ijava_state()->top_frame_sp = (intptr_t) top_frame_sp; } inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp) { get_ijava_state()->sender_sp = (intptr_t) sender_sp; } diff --git a/src/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index a8d719a7836..e800e7d014b 100644 --- a/src/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -756,16 +756,6 @@ void InterpreterMacroAssembler::merge_frames(Register Rsender_sp, Register retur ld(Rscratch1, 0, R1_SP); // *SP ld(Rsender_sp, _ijava_state_neg(sender_sp), Rscratch1); // top_frame_sp ld(Rscratch2, 0, Rscratch1); // **SP -#ifdef ASSERT - { - Label Lok; - ld(R0, _ijava_state_neg(ijava_reserved), Rscratch1); - cmpdi(CCR0, R0, 0x5afe); - beq(CCR0, Lok); - stop("frame corrupted (remove activation)", 0x5afe); - bind(Lok); - } -#endif if (return_pc!=noreg) { ld(return_pc, _abi(lr), Rscratch1); // LR } @@ -2251,14 +2241,6 @@ void InterpreterMacroAssembler::restore_interpreter_state(Register scratch, bool stop("frame too small (restore istate)", 0x5432); bind(Lok); } - { - Label Lok; - ld(R0, _ijava_state_neg(ijava_reserved), scratch); - cmpdi(CCR0, R0, 0x5afe); - beq(CCR0, Lok); - stop("frame corrupted (restore istate)", 0x5afe); - bind(Lok); - } #endif } @@ -2271,7 +2253,7 @@ void InterpreterMacroAssembler::get_method_counters(Register method, cmpdi(CCR0, Rcounters, 0); bne(CCR0, has_counters); call_VM(noreg, CAST_FROM_FN_PTR(address, - InterpreterRuntime::build_method_counters), method, false); + InterpreterRuntime::build_method_counters), method); ld(Rcounters, in_bytes(Method::method_counters_offset()), method); cmpdi(CCR0, Rcounters, 0); beq(CCR0, skip); // No MethodCounters, OutOfMemory. diff --git a/src/src/hotspot/cpu/ppc/ppc.ad b/src/src/hotspot/cpu/ppc/ppc.ad index 6cc8875f090..ed3785b2fd4 100644 --- a/src/src/hotspot/cpu/ppc/ppc.ad +++ b/src/src/hotspot/cpu/ppc/ppc.ad @@ -1,6 +1,6 @@ // -// Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. -// Copyright (c) 2012, 2018 SAP SE. All rights reserved. +// Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2012, 2019 SAP SE. 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 @@ -2310,9 +2310,10 @@ const int Matcher::min_vector_size(const BasicType bt) { return max_vector_size(bt); // Same as max. } -// PPC doesn't support misaligned vectors store/load. +// PPC implementation uses VSX load/store instructions (if +// SuperwordUseVSX) which support 4 byte but not arbitrary alignment const bool Matcher::misaligned_vectors_ok() { - return !AlignVector; // can be changed by flag + return false; } // PPC AES support not yet implemented @@ -4602,6 +4603,16 @@ operand immD() %{ interface(CONST_INTER); %} +// Double Immediate: +0.0d. +operand immD_0() %{ + predicate(jlong_cast(n->getd()) == 0); + match(ConD); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + // Integer Register Operands // Integer Destination Register // See definition of reg_class bits32_reg_rw. @@ -13967,7 +13978,7 @@ instruct repl4S_reg_Ex(iRegLdst dst, iRegIsrc src) %{ instruct repl4S_immI0(iRegLdst dst, immI_0 zero) %{ match(Set dst (ReplicateS zero)); predicate(n->as_Vector()->length() == 4); - format %{ "LI $dst, #0 \t// replicate4C" %} + format %{ "LI $dst, #0 \t// replicate4S" %} size(4); ins_encode %{ // TODO: PPC port $archOpcode(ppc64Opcode_addi); @@ -13979,7 +13990,7 @@ instruct repl4S_immI0(iRegLdst dst, immI_0 zero) %{ instruct repl4S_immIminus1(iRegLdst dst, immI_minus1 src) %{ match(Set dst (ReplicateS src)); predicate(n->as_Vector()->length() == 4); - format %{ "LI $dst, -1 \t// replicate4C" %} + format %{ "LI $dst, -1 \t// replicate4S" %} size(4); ins_encode %{ // TODO: PPC port $archOpcode(ppc64Opcode_addi); @@ -14020,7 +14031,7 @@ instruct repl8S_immIminus1(vecX dst, immI_minus1 src) %{ match(Set dst (ReplicateS src)); predicate(n->as_Vector()->length() == 8); - format %{ "XXLEQV $dst, $src \t// replicate16B" %} + format %{ "XXLEQV $dst, $src \t// replicate8S" %} size(4); ins_encode %{ __ xxleqv($dst$$VectorSRegister, $dst$$VectorSRegister, $dst$$VectorSRegister); @@ -14041,7 +14052,7 @@ instruct repl2I_reg_Ex(iRegLdst dst, iRegIsrc src) %{ instruct repl2I_immI0(iRegLdst dst, immI_0 zero) %{ match(Set dst (ReplicateI zero)); predicate(n->as_Vector()->length() == 2); - format %{ "LI $dst, #0 \t// replicate4C" %} + format %{ "LI $dst, #0 \t// replicate2I" %} size(4); ins_encode %{ // TODO: PPC port $archOpcode(ppc64Opcode_addi); @@ -14053,7 +14064,7 @@ instruct repl2I_immI0(iRegLdst dst, immI_0 zero) %{ instruct repl2I_immIminus1(iRegLdst dst, immI_minus1 src) %{ match(Set dst (ReplicateI src)); predicate(n->as_Vector()->length() == 2); - format %{ "LI $dst, -1 \t// replicate4C" %} + format %{ "LI $dst, -1 \t// replicate2I" %} size(4); ins_encode %{ // TODO: PPC port $archOpcode(ppc64Opcode_addi); @@ -14256,7 +14267,7 @@ instruct repl2D_reg_Ex(vecX dst, regD src) %{ %} %} -instruct repl2D_immI0(vecX dst, immI_0 zero) %{ +instruct repl2D_immD0(vecX dst, immD_0 zero) %{ match(Set dst (ReplicateD zero)); predicate(n->as_Vector()->length() == 2); @@ -14268,18 +14279,6 @@ instruct repl2D_immI0(vecX dst, immI_0 zero) %{ ins_pipe(pipe_class_default); %} -instruct repl2D_immIminus1(vecX dst, immI_minus1 src) %{ - match(Set dst (ReplicateD src)); - predicate(n->as_Vector()->length() == 2); - - format %{ "XXLEQV $dst, $src \t// replicate16B" %} - size(4); - ins_encode %{ - __ xxleqv($dst$$VectorSRegister, $dst$$VectorSRegister, $dst$$VectorSRegister); - %} - ins_pipe(pipe_class_default); -%} - instruct mtvsrd(vecX dst, iRegLsrc src) %{ predicate(false); effect(DEF dst, USE src); @@ -14341,7 +14340,7 @@ instruct repl2L_immIminus1(vecX dst, immI_minus1 src) %{ match(Set dst (ReplicateL src)); predicate(n->as_Vector()->length() == 2); - format %{ "XXLEQV $dst, $src \t// replicate16B" %} + format %{ "XXLEQV $dst, $src \t// replicate2L" %} size(4); ins_encode %{ __ xxleqv($dst$$VectorSRegister, $dst$$VectorSRegister, $dst$$VectorSRegister); diff --git a/src/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index 3fdeb23e55b..03e92cde349 100644 --- a/src/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -2690,10 +2690,6 @@ static void push_skeleton_frame(MacroAssembler* masm, bool deopt, __ ld(frame_size_reg, 0, frame_sizes_reg); __ std(pc_reg, _abi(lr), R1_SP); __ push_frame(frame_size_reg, R0/*tmp*/); -#ifdef ASSERT - __ load_const_optimized(pc_reg, 0x5afe); - __ std(pc_reg, _ijava_state_neg(ijava_reserved), R1_SP); -#endif __ std(R1_SP, _ijava_state_neg(sender_sp), R1_SP); __ addi(number_of_frames_reg, number_of_frames_reg, -1); __ addi(frame_sizes_reg, frame_sizes_reg, wordSize); @@ -2766,10 +2762,6 @@ static void push_skeleton_frames(MacroAssembler* masm, bool deopt, __ std(R12_scratch2, _abi(lr), R1_SP); // Initialize initial_caller_sp. -#ifdef ASSERT - __ load_const_optimized(pc_reg, 0x5afe); - __ std(pc_reg, _ijava_state_neg(ijava_reserved), R1_SP); -#endif __ std(frame_size_reg, _ijava_state_neg(sender_sp), R1_SP); #ifdef ASSERT diff --git a/src/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index 133ca712c59..2e7837c0cbb 100644 --- a/src/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -1050,17 +1050,14 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist // Get mirror and store it in the frame as GC root for this Method*. __ load_mirror_from_const_method(R12_scratch2, Rconst_method); - __ addi(R26_monitor, R1_SP, - frame::ijava_state_size); - __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize); + __ addi(R26_monitor, R1_SP, -frame::ijava_state_size); + __ addi(R15_esp, R26_monitor, -Interpreter::stackElementSize); // Store values. - // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls - // in InterpreterMacroAssembler::call_from_interpreter. __ std(R19_method, _ijava_state_neg(method), R1_SP); __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP); - __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP); - __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP); __ std(R18_locals, _ijava_state_neg(locals), R1_SP); + __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP); // Note: esp, bcp, monitor, mdx live in registers. Hence, the correct version can only // be found in the frame after save_interpreter_state is done. This is always true @@ -1068,31 +1065,20 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist // because e.g. frame::interpreter_frame_bcp() will not access the correct value // (Enhanced Stack Trace). // The signal handler does not save the interpreter state into the frame. + + // We have to initialize some of these frame slots for native calls (accessed by GC). + // Also initialize them for non-native calls for better tool support (even though + // you may not get the most recent version as described above). __ li(R0, 0); -#ifdef ASSERT - // Fill remaining slots with constants. - __ load_const_optimized(R11_scratch1, 0x5afe); - __ load_const_optimized(R12_scratch2, 0xdead); -#endif - // We have to initialize some frame slots for native calls (accessed by GC). - if (native_call) { - __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP); - __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP); - if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); } - } -#ifdef ASSERT - else { - __ std(R12_scratch2, _ijava_state_neg(monitors), R1_SP); - __ std(R12_scratch2, _ijava_state_neg(bcp), R1_SP); - __ std(R12_scratch2, _ijava_state_neg(mdx), R1_SP); - } - __ std(R11_scratch1, _ijava_state_neg(ijava_reserved), R1_SP); - __ std(R12_scratch2, _ijava_state_neg(esp), R1_SP); - __ std(R12_scratch2, _ijava_state_neg(lresult), R1_SP); - __ std(R12_scratch2, _ijava_state_neg(fresult), R1_SP); -#endif + __ std(R26_monitor, _ijava_state_neg(monitors), R1_SP); + __ std(R14_bcp, _ijava_state_neg(bcp), R1_SP); + if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); } + __ std(R15_esp, _ijava_state_neg(esp), R1_SP); + __ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call + + // Store sender's SP and this frame's top SP. __ subf(R12_scratch2, top_frame_size, R1_SP); - __ std(R0, _ijava_state_neg(oop_tmp), R1_SP); + __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP); __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP); // Push top frame. diff --git a/src/src/hotspot/cpu/ppc/vm_version_ppc.cpp b/src/src/hotspot/cpu/ppc/vm_version_ppc.cpp index e5a62383801..447c93f3eae 100644 --- a/src/src/hotspot/cpu/ppc/vm_version_ppc.cpp +++ b/src/src/hotspot/cpu/ppc/vm_version_ppc.cpp @@ -38,6 +38,9 @@ #include "vm_version_ppc.hpp" #include +#if defined(_AIX) +#include +#endif #if defined(LINUX) && defined(VM_LITTLE_ENDIAN) #include @@ -381,6 +384,80 @@ void VM_Version::initialize() { } } +void VM_Version::print_platform_virtualization_info(outputStream* st) { +#if defined(_AIX) + // more info about perfstat API see + // https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.prftools/idprftools_perfstat_glob_partition.htm + int rc = 0; + perfstat_partition_total_t pinfo; + memset(&pinfo, 0, sizeof(perfstat_partition_total_t)); + rc = perfstat_partition_total(NULL, &pinfo, sizeof(perfstat_partition_total_t), 1); + if (rc != 1) { + return; + } else { + st->print_cr("Virtualization type : PowerVM"); + } + // CPU information + perfstat_cpu_total_t cpuinfo; + memset(&cpuinfo, 0, sizeof(perfstat_cpu_total_t)); + rc = perfstat_cpu_total(NULL, &cpuinfo, sizeof(perfstat_cpu_total_t), 1); + if (rc != 1) { + return; + } + + st->print_cr("Processor description : %s", cpuinfo.description); + st->print_cr("Processor speed : %llu Hz", cpuinfo.processorHZ); + + st->print_cr("LPAR partition name : %s", pinfo.name); + st->print_cr("LPAR partition number : %u", pinfo.lpar_id); + st->print_cr("LPAR partition type : %s", pinfo.type.b.shared_enabled ? "shared" : "dedicated"); + st->print_cr("LPAR mode : %s", pinfo.type.b.donate_enabled ? "donating" : pinfo.type.b.capped ? "capped" : "uncapped"); + st->print_cr("LPAR partition group ID : %u", pinfo.group_id); + st->print_cr("LPAR shared pool ID : %u", pinfo.pool_id); + + st->print_cr("AMS (active memory sharing) : %s", pinfo.type.b.ams_capable ? "capable" : "not capable"); + st->print_cr("AMS (active memory sharing) : %s", pinfo.type.b.ams_enabled ? "on" : "off"); + st->print_cr("AME (active memory expansion) : %s", pinfo.type.b.ame_enabled ? "on" : "off"); + + if (pinfo.type.b.ame_enabled) { + st->print_cr("AME true memory in bytes : %llu", pinfo.true_memory); + st->print_cr("AME expanded memory in bytes : %llu", pinfo.expanded_memory); + } + + st->print_cr("SMT : %s", pinfo.type.b.smt_capable ? "capable" : "not capable"); + st->print_cr("SMT : %s", pinfo.type.b.smt_enabled ? "on" : "off"); + int ocpus = pinfo.online_cpus > 0 ? pinfo.online_cpus : 1; + st->print_cr("LPAR threads : %d", cpuinfo.ncpus/ocpus); + st->print_cr("LPAR online virtual cpus : %d", pinfo.online_cpus); + st->print_cr("LPAR logical cpus : %d", cpuinfo.ncpus); + st->print_cr("LPAR maximum virtual cpus : %u", pinfo.max_cpus); + st->print_cr("LPAR minimum virtual cpus : %u", pinfo.min_cpus); + st->print_cr("LPAR entitled capacity : %4.2f", (double) (pinfo.entitled_proc_capacity/100.0)); + st->print_cr("LPAR online memory : %llu MB", pinfo.online_memory); + st->print_cr("LPAR maximum memory : %llu MB", pinfo.max_memory); + st->print_cr("LPAR minimum memory : %llu MB", pinfo.min_memory); +#else + const char* info_file = "/proc/ppc64/lparcfg"; + const char* kw[] = { "system_type=", // qemu indicates PowerKVM + "partition_entitled_capacity=", // entitled processor capacity percentage + "partition_max_entitled_capacity=", + "capacity_weight=", // partition CPU weight + "partition_active_processors=", + "partition_potential_processors=", + "entitled_proc_capacity_available=", + "capped=", // 0 - uncapped, 1 - vcpus capped at entitled processor capacity percentage + "shared_processor_mode=", // (non)dedicated partition + "system_potential_processors=", + "pool=", // CPU-pool number + "pool_capacity=", + "NumLpars=", // on non-KVM machines, NumLpars is not found for full partition mode machines + NULL }; + if (!print_matching_lines_from_file(info_file, st, kw)) { + st->print_cr(" <%s Not Available>", info_file); + } +#endif +} + bool VM_Version::use_biased_locking() { #if INCLUDE_RTM_OPT // RTM locking is most useful when there is high lock contention and diff --git a/src/src/hotspot/cpu/ppc/vm_version_ppc.hpp b/src/src/hotspot/cpu/ppc/vm_version_ppc.hpp index 22ce3701aae..9bed5c25b01 100644 --- a/src/src/hotspot/cpu/ppc/vm_version_ppc.hpp +++ b/src/src/hotspot/cpu/ppc/vm_version_ppc.hpp @@ -88,6 +88,9 @@ class VM_Version: public Abstract_VM_Version { // Initialization static void initialize(); + // Override Abstract_VM_Version implementation + static void print_platform_virtualization_info(outputStream*); + // Override Abstract_VM_Version implementation static bool use_biased_locking(); diff --git a/src/src/hotspot/cpu/s390/compiledIC_s390.cpp b/src/src/hotspot/cpu/s390/compiledIC_s390.cpp index 32b8b5ce6f6..1a1340beb7b 100644 --- a/src/src/hotspot/cpu/s390/compiledIC_s390.cpp +++ b/src/src/hotspot/cpu/s390/compiledIC_s390.cpp @@ -119,7 +119,7 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad #endif // Update stub. - method_holder->set_data((intptr_t)callee()); + method_holder->set_data((intptr_t)callee(), relocInfo::metadata_type); jump->set_jump_destination(entry); // Update jump to call. @@ -134,7 +134,7 @@ void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_ // Creation also verifies the object. NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub()); NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); - method_holder->set_data(0); + method_holder->set_data(0, relocInfo::metadata_type); jump->set_jump_destination((address)-1); } diff --git a/src/src/hotspot/cpu/s390/globals_s390.hpp b/src/src/hotspot/cpu/s390/globals_s390.hpp index 2354e5ab045..7704ddbe6bf 100644 --- a/src/src/hotspot/cpu/s390/globals_s390.hpp +++ b/src/src/hotspot/cpu/s390/globals_s390.hpp @@ -55,7 +55,7 @@ define_pd_global(intx, InlineSmallCode, 2000); #define DEFAULT_STACK_RED_PAGES (1) // Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the // stack. To pass stack overflow tests we need 20 shadow pages. -#define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+2)) +#define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+4)) #define DEFAULT_STACK_RESERVED_PAGES (1) #define MIN_STACK_YELLOW_PAGES DEFAULT_STACK_YELLOW_PAGES diff --git a/src/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/src/hotspot/cpu/s390/interp_masm_s390.cpp index 957fd0d3315..907e0af8450 100644 --- a/src/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -1901,7 +1901,7 @@ void InterpreterMacroAssembler::get_method_counters(Register Rmethod, load_and_test_long(Rcounters, Address(Rmethod, Method::method_counters_offset())); z_brnz(has_counters); - call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters), Rmethod, false); + call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters), Rmethod); z_ltgr(Rcounters, Z_RET); // Runtime call returns MethodCounters object. z_brz(skip); // No MethodCounters, out of memory. diff --git a/src/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 001ebe55ea8..c72116f73eb 100644 --- a/src/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -5899,7 +5899,7 @@ bool MacroAssembler::load_const_from_toc(Register dst, AddressLiteral& a, Regist if (tocOffset == -1) return false; address tocPos = tocOffset + code()->consts()->start(); assert((address)code()->consts()->start() != NULL, "Please add CP address"); - + relocate(a.rspec()); load_long_pcrelative(dst, tocPos); return true; } diff --git a/src/src/hotspot/cpu/s390/nativeInst_s390.cpp b/src/src/hotspot/cpu/s390/nativeInst_s390.cpp index 6d3eccd5aab..c351e69edaa 100644 --- a/src/src/hotspot/cpu/s390/nativeInst_s390.cpp +++ b/src/src/hotspot/cpu/s390/nativeInst_s390.cpp @@ -475,12 +475,42 @@ address NativeMovConstReg::set_data_plain(intptr_t src, CodeBlob *cb) { // Divided up in set_data_plain() which patches the instruction in the // code stream and set_data() which additionally patches the oop pool // if necessary. -void NativeMovConstReg::set_data(intptr_t src) { +void NativeMovConstReg::set_data(intptr_t data, relocInfo::relocType expected_type) { // Also store the value into an oop_Relocation cell, if any. CodeBlob *cb = CodeCache::find_blob(instruction_address()); - address next_address = set_data_plain(src, cb); - - relocInfo::update_oop_pool(instruction_address(), next_address, (address)src, cb); + address next_address = set_data_plain(data, cb); + + // 'RelocIterator' requires an nmethod + nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; + if (nm != NULL) { + RelocIterator iter(nm, instruction_address(), next_address); + oop* oop_addr = NULL; + Metadata** metadata_addr = NULL; + while (iter.next()) { + if (iter.type() == relocInfo::oop_type) { + oop_Relocation *r = iter.oop_reloc(); + if (oop_addr == NULL) { + oop_addr = r->oop_addr(); + *oop_addr = cast_to_oop(data); + } else { + assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); + } + } + if (iter.type() == relocInfo::metadata_type) { + metadata_Relocation *r = iter.metadata_reloc(); + if (metadata_addr == NULL) { + metadata_addr = r->metadata_addr(); + *metadata_addr = (Metadata*)data; + } else { + assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); + } + } + } + assert(expected_type == relocInfo::none || + (expected_type == relocInfo::metadata_type && metadata_addr != NULL) || + (expected_type == relocInfo::oop_type && oop_addr != NULL), + "%s relocation not found", expected_type == relocInfo::oop_type ? "oop" : "metadata"); + } } void NativeMovConstReg::set_narrow_oop(intptr_t data) { @@ -510,7 +540,7 @@ void NativeMovConstReg::set_narrow_klass(intptr_t data) { ICache::invalidate_range(start, range); } -void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passed_nm /* = NULL */, bool copy_back_to_oop_pool) { +void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passed_nm /* = NULL */) { address next_address; address loc = addr_at(0); @@ -533,20 +563,9 @@ void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passe assert(false, "Not a NativeMovConstReg site for set_pcrel_addr"); next_address = next_instruction_address(); // Failure should be handled in next_instruction_address(). } - - if (copy_back_to_oop_pool) { - if (relocInfo::update_oop_pool(instruction_address(), next_address, (address)newTarget, NULL)) { - ((NativeMovConstReg*)instruction_address())->dump(64, "NativeMovConstReg::set_pcrel_addr(): found oop reloc for pcrel_addr"); -#ifdef LUCY_DBG - VM_Version::z_SIGSEGV(); -#else - assert(false, "Ooooops: found oop reloc for pcrel_addr"); -#endif - } - } } -void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_nm /* = NULL */, bool copy_back_to_oop_pool) { +void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_nm /* = NULL */) { address next_address; address loc = addr_at(0); @@ -573,17 +592,6 @@ void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_ assert(false, "Not a NativeMovConstReg site for set_pcrel_data"); next_address = next_instruction_address(); // Failure should be handled in next_instruction_address(). } - - if (copy_back_to_oop_pool) { - if (relocInfo::update_oop_pool(instruction_address(), next_address, (address)newData, NULL)) { - ((NativeMovConstReg*)instruction_address())->dump(64, "NativeMovConstReg::set_pcrel_data(): found oop reloc for pcrel_data"); -#ifdef LUCY_DBG - VM_Version::z_SIGSEGV(); -#else - assert(false, "Ooooops: found oop reloc for pcrel_data"); -#endif - } - } } #ifdef COMPILER1 diff --git a/src/src/hotspot/cpu/s390/nativeInst_s390.hpp b/src/src/hotspot/cpu/s390/nativeInst_s390.hpp index 5a7a8a27145..8c895c2c95b 100644 --- a/src/src/hotspot/cpu/s390/nativeInst_s390.hpp +++ b/src/src/hotspot/cpu/s390/nativeInst_s390.hpp @@ -496,13 +496,13 @@ class NativeMovConstReg: public NativeInstruction { // Patch data in code stream. address set_data_plain(intptr_t x, CodeBlob *code); // Patch data in code stream and oop pool if necessary. - void set_data(intptr_t x); + void set_data(intptr_t x, relocInfo::relocType expected_type = relocInfo::none); // Patch narrow oop constant in code stream. void set_narrow_oop(intptr_t data); void set_narrow_klass(intptr_t data); - void set_pcrel_addr(intptr_t addr, CompiledMethod *nm = NULL, bool copy_back_to_oop_pool=false); - void set_pcrel_data(intptr_t data, CompiledMethod *nm = NULL, bool copy_back_to_oop_pool=false); + void set_pcrel_addr(intptr_t addr, CompiledMethod *nm = NULL); + void set_pcrel_data(intptr_t data, CompiledMethod *nm = NULL); void verify(); diff --git a/src/src/hotspot/cpu/s390/relocInfo_s390.cpp b/src/src/hotspot/cpu/s390/relocInfo_s390.cpp index fd1437c1d69..9fcefd77962 100644 --- a/src/src/hotspot/cpu/s390/relocInfo_s390.cpp +++ b/src/src/hotspot/cpu/s390/relocInfo_s390.cpp @@ -164,49 +164,6 @@ void Relocation::pd_set_call_destination(address x) { } -// store the new target address into an oop_Relocation cell, if any -// return indication if update happened. -bool relocInfo::update_oop_pool(address begin, address end, address newTarget, CodeBlob* cb) { - - // Try to find the CodeBlob, if not given by caller - if (cb == NULL) cb = CodeCache::find_blob(begin); -#ifdef ASSERT - else - assert(cb == CodeCache::find_blob(begin), "consistency"); -#endif - - // 'RelocIterator' requires an nmethod - nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; - if (nm != NULL) { - RelocIterator iter(nm, begin, end); - oop* oop_addr = NULL; - Metadata** metadata_addr = NULL; - while (iter.next()) { - if (iter.type() == relocInfo::oop_type) { - oop_Relocation *r = iter.oop_reloc(); - if (oop_addr == NULL) { - oop_addr = r->oop_addr(); - *oop_addr = (oop)newTarget; - } else { - assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); - } - } - if (iter.type() == relocInfo::metadata_type) { - metadata_Relocation *r = iter.metadata_reloc(); - if (metadata_addr == NULL) { - metadata_addr = r->metadata_addr(); - *metadata_addr = (Metadata*)newTarget; - } else { - assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); - } - } - } - return oop_addr || metadata_addr; - } - return false; -} - - address* Relocation::pd_address_in_code() { ShouldNotReachHere(); return 0; diff --git a/src/src/hotspot/cpu/s390/relocInfo_s390.hpp b/src/src/hotspot/cpu/s390/relocInfo_s390.hpp index ba9d40bbdfc..529f2b6d62a 100644 --- a/src/src/hotspot/cpu/s390/relocInfo_s390.hpp +++ b/src/src/hotspot/cpu/s390/relocInfo_s390.hpp @@ -114,8 +114,4 @@ // listed in the oop section. static bool mustIterateImmediateOopsInCode() { return false; } - // Store the new target address into an oop_Relocation cell, if any. - // Return indication if update happened. - static bool update_oop_pool(address begin, address end, address newTarget, CodeBlob* cb); - #endif // CPU_S390_VM_RELOCINFO_S390_HPP diff --git a/src/src/hotspot/cpu/s390/vm_version_ext_s390.cpp b/src/src/hotspot/cpu/s390/vm_version_ext_s390.cpp index dd4a721a35e..2be9d1c5ede 100644 --- a/src/src/hotspot/cpu/s390/vm_version_ext_s390.cpp +++ b/src/src/hotspot/cpu/s390/vm_version_ext_s390.cpp @@ -46,7 +46,7 @@ void VM_Version_Ext::initialize_cpu_information(void) { _no_of_threads = _no_of_cores; _no_of_sockets = _no_of_cores; snprintf(_cpu_name, CPU_TYPE_DESC_BUF_SIZE, "s390 %s", VM_Version::get_model_string()); - snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "zArch %s", features_string()); + snprintf(_cpu_desc, CPU_DETAILED_DESC_BUF_SIZE, "s390 %s", features_string()); _initialized = true; } diff --git a/src/src/hotspot/cpu/s390/vm_version_s390.cpp b/src/src/hotspot/cpu/s390/vm_version_s390.cpp index 5fd2392fc45..2aacd8d33fb 100644 --- a/src/src/hotspot/cpu/s390/vm_version_s390.cpp +++ b/src/src/hotspot/cpu/s390/vm_version_s390.cpp @@ -516,6 +516,19 @@ void VM_Version::print_features_internal(const char* text, bool print_anyway) { } } +void VM_Version::print_platform_virtualization_info(outputStream* st) { + // /proc/sysinfo contains interesting information about + // - LPAR + // - whole "Box" (CPUs ) + // - z/VM / KVM (VM); this is not available in an LPAR-only setup + const char* kw[] = { "LPAR", "CPUs", "VM", NULL }; + const char* info_file = "/proc/sysinfo"; + + if (!print_matching_lines_from_file(info_file, st, kw)) { + st->print_cr(" <%s Not Available>", info_file); + } +} + void VM_Version::print_features() { print_features_internal("Version:"); } diff --git a/src/src/hotspot/cpu/s390/vm_version_s390.hpp b/src/src/hotspot/cpu/s390/vm_version_s390.hpp index 210ed1768c3..c42c549d88c 100644 --- a/src/src/hotspot/cpu/s390/vm_version_s390.hpp +++ b/src/src/hotspot/cpu/s390/vm_version_s390.hpp @@ -346,6 +346,9 @@ class VM_Version: public Abstract_VM_Version { static void print_features(); static bool is_determine_features_test_running() { return _is_determine_features_test_running; } + // Override Abstract_VM_Version implementation + static void print_platform_virtualization_info(outputStream*); + // CPU feature query functions static const char* get_model_string() { return _model_string; } static bool has_StoreFacilityListExtended() { return (_features[0] & StoreFacilityListExtendedMask) == StoreFacilityListExtendedMask; } diff --git a/src/src/hotspot/cpu/x86/gc/shared/modRefBarrierSetAssembler_x86.cpp b/src/src/hotspot/cpu/x86/gc/shared/modRefBarrierSetAssembler_x86.cpp index 19b7eec8acc..888ca1329d8 100644 --- a/src/src/hotspot/cpu/x86/gc/shared/modRefBarrierSetAssembler_x86.cpp +++ b/src/src/hotspot/cpu/x86/gc/shared/modRefBarrierSetAssembler_x86.cpp @@ -36,12 +36,14 @@ void ModRefBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Decorat if (type == T_OBJECT || type == T_ARRAY) { #ifdef _LP64 - if (!checkcast && !obj_int) { - // Save count for barrier - __ movptr(r11, count); - } else if (disjoint && obj_int) { - // Save dst in r11 in the disjoint case - __ movq(r11, dst); + if (!checkcast) { + if (!obj_int) { + // Save count for barrier + __ movptr(r11, count); + } else if (disjoint) { + // Save dst in r11 in the disjoint case + __ movq(r11, dst); + } } #else if (disjoint) { @@ -61,13 +63,15 @@ void ModRefBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, Decorat if (type == T_OBJECT || type == T_ARRAY) { #ifdef _LP64 - if (!checkcast && !obj_int) { - // Save count for barrier - count = r11; - } else if (disjoint && obj_int) { - // Use the saved dst in the disjoint case - dst = r11; - } else if (checkcast) { + if (!checkcast) { + if (!obj_int) { + // Save count for barrier + count = r11; + } else if (disjoint) { + // Use the saved dst in the disjoint case + dst = r11; + } + } else { tmp = rscratch1; } #else diff --git a/src/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 537bfcfffa5..6c48416403a 100644 --- a/src/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -6353,7 +6353,7 @@ void MacroAssembler::string_indexof_char(Register str1, Register cnt1, Register movptr(result, str1); if (UseAVX >= 2) { cmpl(cnt1, stride); - jcc(Assembler::less, SCAN_TO_CHAR_LOOP); + jcc(Assembler::less, SCAN_TO_CHAR); cmpl(cnt1, 2*stride); jcc(Assembler::less, SCAN_TO_8_CHAR_INIT); movdl(vec1, ch); @@ -6380,10 +6380,8 @@ void MacroAssembler::string_indexof_char(Register str1, Register cnt1, Register } bind(SCAN_TO_8_CHAR); cmpl(cnt1, stride); - if (UseAVX >= 2) { - jcc(Assembler::less, SCAN_TO_CHAR); - } else { - jcc(Assembler::less, SCAN_TO_CHAR_LOOP); + jcc(Assembler::less, SCAN_TO_CHAR); + if (UseAVX < 2) { movdl(vec1, ch); pshuflw(vec1, vec1, 0x00); pshufd(vec1, vec1, 0); diff --git a/src/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp index 07a5cde9be8..e9d75263e20 100644 --- a/src/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp +++ b/src/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp @@ -2112,7 +2112,7 @@ class StubGenerator: public StubCodeGenerator { // r9 and r10 may be used to save non-volatile registers // 'from', 'to' and 'qword_count' are now valid - DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_DISJOINT; + DecoratorSet decorators = IN_HEAP | IS_ARRAY; if (dest_uninitialized) { decorators |= IS_DEST_UNINITIALIZED; } @@ -2295,7 +2295,7 @@ class StubGenerator: public StubCodeGenerator { Address from_element_addr(end_from, count, TIMES_OOP, 0); Address to_element_addr(end_to, count, TIMES_OOP, 0); - DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_CHECKCAST; + DecoratorSet decorators = IN_HEAP | IS_ARRAY | ARRAYCOPY_CHECKCAST | ARRAYCOPY_DISJOINT; if (dest_uninitialized) { decorators |= IS_DEST_UNINITIALIZED; } diff --git a/src/src/hotspot/cpu/x86/vm_version_ext_x86.cpp b/src/src/hotspot/cpu/x86/vm_version_ext_x86.cpp index 3cc775d7ec1..968428db598 100644 --- a/src/src/hotspot/cpu/x86/vm_version_ext_x86.cpp +++ b/src/src/hotspot/cpu/x86/vm_version_ext_x86.cpp @@ -43,10 +43,10 @@ typedef enum { CPU_FAMILY_PENTIUM_4 = 0xF } FamilyFlag; - typedef enum { - RDTSCP_FLAG = 0x08000000, // bit 27 - INTEL64_FLAG = 0x20000000 // bit 29 - } _featureExtendedEdxFlag; +typedef enum { + RDTSCP_FLAG = 0x08000000, // bit 27 + INTEL64_FLAG = 0x20000000 // bit 29 +} _featureExtendedEdxFlag; #define CPUID_STANDARD_FN 0x0 #define CPUID_STANDARD_FN_1 0x1 @@ -399,13 +399,17 @@ int VM_Version_Ext::number_of_sockets(void) { const char* VM_Version_Ext::cpu_family_description(void) { int cpu_family_id = extended_cpu_family(); if (is_amd()) { - return _family_id_amd[cpu_family_id]; + if (cpu_family_id < ExtendedFamilyIdLength_AMD) { + return _family_id_amd[cpu_family_id]; + } } if (is_intel()) { if (cpu_family_id == CPU_FAMILY_PENTIUMPRO) { return cpu_model_description(); } - return _family_id_intel[cpu_family_id]; + if (cpu_family_id < ExtendedFamilyIdLength_INTEL) { + return _family_id_intel[cpu_family_id]; + } } return "Unknown x86"; } @@ -694,7 +698,7 @@ jlong VM_Version_Ext::maximum_qualified_cpu_frequency(void) { return _max_qualified_cpu_frequency; } -const char* const VM_Version_Ext::_family_id_intel[] = { +const char* const VM_Version_Ext::_family_id_intel[ExtendedFamilyIdLength_INTEL] = { "8086/8088", "", "286", @@ -713,7 +717,7 @@ const char* const VM_Version_Ext::_family_id_intel[] = { "Pentium 4" }; -const char* const VM_Version_Ext::_family_id_amd[] = { +const char* const VM_Version_Ext::_family_id_amd[ExtendedFamilyIdLength_AMD] = { "", "", "", @@ -731,6 +735,13 @@ const char* const VM_Version_Ext::_family_id_amd[] = { "", "Opteron/Athlon64", "Opteron QC/Phenom" // Barcelona et.al. + "", + "", + "", + "", + "", + "", + "Zen" }; // Partially from Intel 64 and IA-32 Architecture Software Developer's Manual, // September 2013, Vol 3C Table 35-1 diff --git a/src/src/hotspot/cpu/x86/vm_version_ext_x86.hpp b/src/src/hotspot/cpu/x86/vm_version_ext_x86.hpp index 78fb001cb39..71d37f8bc7c 100644 --- a/src/src/hotspot/cpu/x86/vm_version_ext_x86.hpp +++ b/src/src/hotspot/cpu/x86/vm_version_ext_x86.hpp @@ -29,14 +29,20 @@ #include "vm_version_x86.hpp" class VM_Version_Ext : public VM_Version { + + enum { + ExtendedFamilyIdLength_INTEL = 16, + ExtendedFamilyIdLength_AMD = 24 + }; + private: static const size_t VENDOR_LENGTH; static const size_t CPU_EBS_MAX_LENGTH; static const size_t CPU_TYPE_DESC_BUF_SIZE; static const size_t CPU_DETAILED_DESC_BUF_SIZE; - static const char* const _family_id_intel[]; - static const char* const _family_id_amd[]; + static const char* const _family_id_intel[ExtendedFamilyIdLength_INTEL]; + static const char* const _family_id_amd[ExtendedFamilyIdLength_AMD]; static const char* const _brand_id[]; static const char* const _model_id_pentium_pro[]; diff --git a/src/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/src/hotspot/cpu/x86/vm_version_x86.cpp index b074fd8fd60..e55d1b3026d 100644 --- a/src/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ #include "runtime/java.hpp" #include "runtime/os.hpp" #include "runtime/stubCodeGenerator.hpp" +#include "utilities/virtualizationSupport.hpp" #include "vm_version_x86.hpp" @@ -1569,6 +1570,66 @@ void VM_Version::get_processor_features() { #endif // !PRODUCT } +void VM_Version::print_platform_virtualization_info(outputStream* st) { + VirtualizationType vrt = VM_Version::get_detected_virtualization(); + if (vrt == XenHVM) { + st->print_cr("Xen hardware-assisted virtualization detected"); + } else if (vrt == KVM) { + st->print_cr("KVM virtualization detected"); + } else if (vrt == VMWare) { + st->print_cr("VMWare virtualization detected"); + VirtualizationSupport::print_virtualization_info(st); + } else if (vrt == HyperV) { + st->print_cr("HyperV virtualization detected"); + } +} + +void VM_Version::check_virt_cpuid(uint32_t idx, uint32_t *regs) { +// TODO support 32 bit +#if defined(_LP64) +#if defined(_MSC_VER) + // Allocate space for the code + const int code_size = 100; + ResourceMark rm; + CodeBuffer cb("detect_virt", code_size, 0); + MacroAssembler* a = new MacroAssembler(&cb); + address code = a->pc(); + void (*test)(uint32_t idx, uint32_t *regs) = (void(*)(uint32_t idx, uint32_t *regs))code; + + a->movq(r9, rbx); // save nonvolatile register + + // next line would not work on 32-bit + a->movq(rax, c_rarg0 /* rcx */); + a->movq(r8, c_rarg1 /* rdx */); + a->cpuid(); + a->movl(Address(r8, 0), rax); + a->movl(Address(r8, 4), rbx); + a->movl(Address(r8, 8), rcx); + a->movl(Address(r8, 12), rdx); + + a->movq(rbx, r9); // restore nonvolatile register + a->ret(0); + + uint32_t *code_end = (uint32_t *)a->pc(); + a->flush(); + + // execute code + (*test)(idx, regs); +#elif defined(__GNUC__) + __asm__ volatile ( + " cpuid;" + " mov %%eax,(%1);" + " mov %%ebx,4(%1);" + " mov %%ecx,8(%1);" + " mov %%edx,12(%1);" + : "+a" (idx) + : "S" (regs) + : "ebx", "ecx", "edx", "memory" ); +#endif +#endif +} + + bool VM_Version::use_biased_locking() { #if INCLUDE_RTM_OPT // RTM locking is most useful when there is high lock contention and @@ -1590,6 +1651,56 @@ bool VM_Version::use_biased_locking() { return UseBiasedLocking; } +// On Xen, the cpuid instruction returns +// eax / registers[0]: Version of Xen +// ebx / registers[1]: chars 'XenV' +// ecx / registers[2]: chars 'MMXe' +// edx / registers[3]: chars 'nVMM' +// +// On KVM / VMWare / MS Hyper-V, the cpuid instruction returns +// ebx / registers[1]: chars 'KVMK' / 'VMwa' / 'Micr' +// ecx / registers[2]: chars 'VMKV' / 'reVM' / 'osof' +// edx / registers[3]: chars 'M' / 'ware' / 't Hv' +// +// more information : +// https://kb.vmware.com/s/article/1009458 +// +void VM_Version::check_virtualizations() { +#if defined(_LP64) + uint32_t registers[4]; + char signature[13]; + uint32_t base; + signature[12] = '\0'; + memset((void*)registers, 0, 4*sizeof(uint32_t)); + + for (base = 0x40000000; base < 0x40010000; base += 0x100) { + check_virt_cpuid(base, registers); + + *(uint32_t *)(signature + 0) = registers[1]; + *(uint32_t *)(signature + 4) = registers[2]; + *(uint32_t *)(signature + 8) = registers[3]; + + if (strncmp("VMwareVMware", signature, 12) == 0) { + Abstract_VM_Version::_detected_virtualization = VMWare; + // check for extended metrics from guestlib + VirtualizationSupport::initialize(); + } + + if (strncmp("Microsoft Hv", signature, 12) == 0) { + Abstract_VM_Version::_detected_virtualization = HyperV; + } + + if (strncmp("KVMKVMKVM", signature, 9) == 0) { + Abstract_VM_Version::_detected_virtualization = KVM; + } + + if (strncmp("XenVMMXenVMM", signature, 12) == 0) { + Abstract_VM_Version::_detected_virtualization = XenHVM; + } + } +#endif +} + void VM_Version::initialize() { ResourceMark rm; // Making this stub must be FIRST use of assembler @@ -1604,4 +1715,7 @@ void VM_Version::initialize() { g.generate_get_cpu_info()); get_processor_features(); + if (cpu_family() > 4) { // it supports CPUID + check_virtualizations(); + } } diff --git a/src/src/hotspot/cpu/x86/vm_version_x86.hpp b/src/src/hotspot/cpu/x86/vm_version_x86.hpp index e3b986a36bc..5894e7f08f8 100644 --- a/src/src/hotspot/cpu/x86/vm_version_x86.hpp +++ b/src/src/hotspot/cpu/x86/vm_version_x86.hpp @@ -684,6 +684,9 @@ class VM_Version : public Abstract_VM_Version { // Initialization static void initialize(); + // Override Abstract_VM_Version implementation + static void print_platform_virtualization_info(outputStream*); + // Override Abstract_VM_Version implementation static bool use_biased_locking(); @@ -928,6 +931,11 @@ class VM_Version : public Abstract_VM_Version { // that can be used for efficient implementation of // the intrinsic for java.lang.Thread.onSpinWait() static bool supports_on_spin_wait() { return supports_sse2(); } + + // support functions for virtualization detection + private: + static void check_virt_cpuid(uint32_t idx, uint32_t *regs); + static void check_virtualizations(); }; #endif // CPU_X86_VM_VM_VERSION_X86_HPP diff --git a/src/src/hotspot/cpu/x86/x86.ad b/src/src/hotspot/cpu/x86/x86.ad index f27bc90e63e..e0e67d65638 100644 --- a/src/src/hotspot/cpu/x86/x86.ad +++ b/src/src/hotspot/cpu/x86/x86.ad @@ -1581,7 +1581,7 @@ const uint Matcher::vector_shift_count_ideal_reg(int size) { // x86 supports misaligned vectors store/load. const bool Matcher::misaligned_vectors_ok() { - return !AlignVector; // can be changed by flag + return true; } // x86 AES instructions are compatible with SunJCE expanded @@ -1634,6 +1634,7 @@ bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, Ve // Cheap to find it by looking for screwy base. if (adr->is_AddP() && !adr->in(AddPNode::Base)->is_top() && + LP64_ONLY( off->get_long() == (int) (off->get_long()) && ) // immL32 // Are there other uses besides address expressions? !is_visited(adr)) { address_visited.set(adr->_idx); // Flag as address_visited @@ -1680,26 +1681,24 @@ static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo case Op_VecS: // copy whole register case Op_VecD: case Op_VecX: -#ifndef LP64 +#ifndef _LP64 __ movdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo])); #else if ((UseAVX < 3) || VM_Version::supports_avx512vl()) { __ movdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo])); } else { - __ vpxor(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[dst_lo]), 2); - __ vinserti32x4(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 0x0); + __ vextractf32x4(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 0x0); } #endif break; case Op_VecY: -#ifndef LP64 +#ifndef _LP64 __ vmovdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo])); #else if ((UseAVX < 3) || VM_Version::supports_avx512vl()) { __ vmovdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo])); } else { - __ vpxor(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[dst_lo]), 2); - __ vinserti64x4(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 0x0); + __ vextractf64x4(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 0x0); } #endif break; @@ -1753,26 +1752,26 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, __ movq(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); break; case Op_VecX: -#ifndef LP64 +#ifndef _LP64 __ movdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); #else if ((UseAVX < 3) || VM_Version::supports_avx512vl()) { __ movdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); } else { - __ vpxor(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), 2); - __ vinserti32x4(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset),0x0); + __ vpxor(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), 2); + __ vinsertf32x4(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset),0x0); } #endif break; case Op_VecY: -#ifndef LP64 +#ifndef _LP64 __ vmovdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); #else if ((UseAVX < 3) || VM_Version::supports_avx512vl()) { __ vmovdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); } else { - __ vpxor(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), 2); - __ vinserti64x4(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset),0x0); + __ vpxor(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), 2); + __ vinsertf64x4(as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset),0x0); } #endif break; @@ -1791,26 +1790,26 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, __ movq(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); break; case Op_VecX: -#ifndef LP64 +#ifndef _LP64 __ movdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); #else if ((UseAVX < 3) || VM_Version::supports_avx512vl()) { __ movdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); } else { - __ vextracti32x4(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), 0x0); + __ vextractf32x4(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 0x0); } #endif break; case Op_VecY: -#ifndef LP64 +#ifndef _LP64 __ vmovdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); #else if ((UseAVX < 3) || VM_Version::supports_avx512vl()) { __ vmovdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); } else { - __ vextracti64x4(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), as_XMMRegister(Matcher::_regEncode[reg]), 0x0); + __ vextractf64x4(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 0x0); } #endif break; @@ -3108,30 +3107,6 @@ instruct storeV64_qword(memory mem, vecZ src) %{ // ====================LEGACY REPLICATE======================================= -instruct Repl4B_mem(vecS dst, memory mem) %{ - predicate(n->as_Vector()->length() == 4 && UseAVX > 0 && !VM_Version::supports_avx512vlbw()); - match(Set dst (ReplicateB (LoadB mem))); - format %{ "punpcklbw $dst,$mem\n\t" - "pshuflw $dst,$dst,0x00\t! replicate4B" %} - ins_encode %{ - __ punpcklbw($dst$$XMMRegister, $mem$$Address); - __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); - %} - ins_pipe( pipe_slow ); -%} - -instruct Repl8B_mem(vecD dst, memory mem) %{ - predicate(n->as_Vector()->length() == 8 && UseAVX > 0 && !VM_Version::supports_avx512vlbw()); - match(Set dst (ReplicateB (LoadB mem))); - format %{ "punpcklbw $dst,$mem\n\t" - "pshuflw $dst,$dst,0x00\t! replicate8B" %} - ins_encode %{ - __ punpcklbw($dst$$XMMRegister, $mem$$Address); - __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); - %} - ins_pipe( pipe_slow ); -%} - instruct Repl16B(vecX dst, rRegI src) %{ predicate(n->as_Vector()->length() == 16 && !VM_Version::supports_avx512vlbw()); match(Set dst (ReplicateB src)); @@ -3148,20 +3123,6 @@ instruct Repl16B(vecX dst, rRegI src) %{ ins_pipe( pipe_slow ); %} -instruct Repl16B_mem(vecX dst, memory mem) %{ - predicate(n->as_Vector()->length() == 16 && UseAVX > 0 && !VM_Version::supports_avx512vlbw()); - match(Set dst (ReplicateB (LoadB mem))); - format %{ "punpcklbw $dst,$mem\n\t" - "pshuflw $dst,$dst,0x00\n\t" - "punpcklqdq $dst,$dst\t! replicate16B" %} - ins_encode %{ - __ punpcklbw($dst$$XMMRegister, $mem$$Address); - __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); - __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); - %} - ins_pipe( pipe_slow ); -%} - instruct Repl32B(vecY dst, rRegI src) %{ predicate(n->as_Vector()->length() == 32 && !VM_Version::supports_avx512vlbw()); match(Set dst (ReplicateB src)); @@ -3180,22 +3141,6 @@ instruct Repl32B(vecY dst, rRegI src) %{ ins_pipe( pipe_slow ); %} -instruct Repl32B_mem(vecY dst, memory mem) %{ - predicate(n->as_Vector()->length() == 32 && !VM_Version::supports_avx512vlbw()); - match(Set dst (ReplicateB (LoadB mem))); - format %{ "punpcklbw $dst,$mem\n\t" - "pshuflw $dst,$dst,0x00\n\t" - "punpcklqdq $dst,$dst\n\t" - "vinserti128_high $dst,$dst\t! replicate32B" %} - ins_encode %{ - __ punpcklbw($dst$$XMMRegister, $mem$$Address); - __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); - __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); - __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister); - %} - ins_pipe( pipe_slow ); -%} - instruct Repl64B(legVecZ dst, rRegI src) %{ predicate(n->as_Vector()->length() == 64 && !VM_Version::supports_avx512vlbw()); match(Set dst (ReplicateB src)); @@ -3216,24 +3161,6 @@ instruct Repl64B(legVecZ dst, rRegI src) %{ ins_pipe( pipe_slow ); %} -instruct Repl64B_mem(legVecZ dst, memory mem) %{ - predicate(n->as_Vector()->length() == 64 && !VM_Version::supports_avx512vlbw()); - match(Set dst (ReplicateB (LoadB mem))); - format %{ "punpcklbw $dst,$mem\n\t" - "pshuflw $dst,$dst,0x00\n\t" - "punpcklqdq $dst,$dst\n\t" - "vinserti128_high $dst,$dst\t" - "vinserti64x4 $dst,$dst,$dst,0x1\t! replicate64B" %} - ins_encode %{ - __ punpcklbw($dst$$XMMRegister, $mem$$Address); - __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); - __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); - __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister); - __ vinserti64x4($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, 0x1); - %} - ins_pipe( pipe_slow ); -%} - instruct Repl16B_imm(vecX dst, immI con) %{ predicate(n->as_Vector()->length() == 16 && !VM_Version::supports_avx512vlbw()); match(Set dst (ReplicateB con)); diff --git a/src/src/hotspot/os/aix/loadlib_aix.cpp b/src/src/hotspot/os/aix/loadlib_aix.cpp index d6e58217d24..9ac761f6212 100644 --- a/src/src/hotspot/os/aix/loadlib_aix.cpp +++ b/src/src/hotspot/os/aix/loadlib_aix.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 SAP SE. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019 SAP SE. 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 @@ -207,7 +207,7 @@ static bool reload_table() { } } - trcVerbose("loadquery buffer size is %llu.", buflen); + trcVerbose("loadquery buffer size is " SIZE_FORMAT ".", buflen); // Iterate over the loadquery result. For details see sys/ldr.h on AIX. ldi = (struct ld_info*) buffer; @@ -264,7 +264,7 @@ static bool reload_table() { e->info.is_in_vm = true; } - trcVerbose("entry: %p %llu, %p %llu, %s %s %s, %d", + trcVerbose("entry: %p " SIZE_FORMAT ", %p " SIZE_FORMAT ", %s %s %s, %d", e->info.text, e->info.text_len, e->info.data, e->info.data_len, e->info.path, e->info.shortname, diff --git a/src/src/hotspot/os/aix/os_aix.cpp b/src/src/hotspot/os/aix/os_aix.cpp index e0c8b7fe14b..502980bf1bc 100644 --- a/src/src/hotspot/os/aix/os_aix.cpp +++ b/src/src/hotspot/os/aix/os_aix.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2018 SAP SE. All rights reserved. + * Copyright (c) 2012, 2019 SAP SE. 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 @@ -37,6 +37,7 @@ #include "compiler/compileBroker.hpp" #include "interpreter/interpreter.hpp" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "libo4.hpp" #include "libperfstat_aix.hpp" #include "libodm_aix.hpp" @@ -486,8 +487,7 @@ static void query_multipage_support() { if (::shmctl(shmid, SHM_PAGESIZE, &shm_buf) != 0) { const int en = errno; ::shmctl(shmid, IPC_RMID, NULL); // As early as possible! - trcVerbose("shmctl(SHM_PAGESIZE) failed with errno=%n", - errno); + trcVerbose("shmctl(SHM_PAGESIZE) failed with errno=%d", errno); } else { // Attach and double check pageisze. void* p = ::shmat(shmid, NULL, 0); @@ -495,7 +495,7 @@ static void query_multipage_support() { guarantee0(p != (void*) -1); // Should always work. const size_t real_pagesize = os::Aix::query_pagesize(p); if (real_pagesize != pagesize) { - trcVerbose("real page size (0x%llX) differs.", real_pagesize); + trcVerbose("real page size (" SIZE_FORMAT_HEX ") differs.", real_pagesize); } else { can_use = true; } @@ -917,6 +917,11 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, char buf[64]; log_warning(os, thread)("Failed to start thread - pthread_create failed (%d=%s) for attributes: %s.", ret, os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); + // Log some OS information which might explain why creating the thread failed. + log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); + LogStream st(Log(os, thread)::info()); + os::Posix::print_rlimit_info(&st); + os::print_memory_info(&st); } pthread_attr_destroy(&attr); @@ -1393,12 +1398,15 @@ void os::print_os_info(outputStream* st) { os::Posix::print_rlimit_info(st); + // _SC_THREAD_THREADS_MAX is the maximum number of threads within a process. + long tmax = sysconf(_SC_THREAD_THREADS_MAX); + st->print_cr("maximum #threads within a process:%ld", tmax); + // load average st->print("load average:"); double loadavg[3] = {-1.L, -1.L, -1.L}; os::loadavg(loadavg, 3); - st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); - st->cr(); + st->print_cr("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); // print wpar info libperfstat::wparinfo_t wi; @@ -1409,13 +1417,7 @@ void os::print_os_info(outputStream* st) { st->print_cr("type: %s", (wi.app_wpar ? "application" : "system")); } - // print partition info - libperfstat::partitioninfo_t pi; - if (libperfstat::get_partitioninfo(&pi)) { - st->print_cr("partition info"); - st->print_cr(" name: %s", pi.name); - } - + VM_Version::print_platform_virtualization_info(st); } void os::print_memory_info(outputStream* st) { @@ -1883,12 +1885,12 @@ struct vmembk_t { if (!contains_range(p, s)) { trcVerbose("[" PTR_FORMAT " - " PTR_FORMAT "] is not a sub " "range of [" PTR_FORMAT " - " PTR_FORMAT "].", - p, p + s, addr, addr + size); + p2i(p), p2i(p + s), p2i(addr), p2i(addr + size)); guarantee0(false); } if (!is_aligned_to(p, pagesize) || !is_aligned_to(p + s, pagesize)) { trcVerbose("range [" PTR_FORMAT " - " PTR_FORMAT "] is not" - " aligned to pagesize (%lu)", p, p + s, (unsigned long) pagesize); + " aligned to pagesize (%lu)", p2i(p), p2i(p + s), (unsigned long) pagesize); guarantee0(false); } } @@ -1959,7 +1961,7 @@ static char* reserve_shmated_memory ( trcVerbose("reserve_shmated_memory " UINTX_FORMAT " bytes, wishaddress " PTR_FORMAT ", alignment_hint " UINTX_FORMAT "...", - bytes, requested_addr, alignment_hint); + bytes, p2i(requested_addr), alignment_hint); // Either give me wish address or wish alignment but not both. assert0(!(requested_addr != NULL && alignment_hint != 0)); @@ -1968,7 +1970,7 @@ static char* reserve_shmated_memory ( // BRK because that may cause malloc OOM. if (requested_addr != NULL && is_close_to_brk((address)requested_addr)) { trcVerbose("Wish address " PTR_FORMAT " is too close to the BRK segment. " - "Will attach anywhere.", requested_addr); + "Will attach anywhere.", p2i(requested_addr)); // Act like the OS refused to attach there. requested_addr = NULL; } @@ -2020,7 +2022,7 @@ static char* reserve_shmated_memory ( // Handle shmat error. If we failed to attach, just return. if (addr == (char*)-1) { - trcVerbose("Failed to attach segment at " PTR_FORMAT " (%d).", requested_addr, errno_shmat); + trcVerbose("Failed to attach segment at " PTR_FORMAT " (%d).", p2i(requested_addr), errno_shmat); return NULL; } @@ -2028,15 +2030,15 @@ static char* reserve_shmated_memory ( // work (see above), the system may have given us something other then 4K (LDR_CNTRL). const size_t real_pagesize = os::Aix::query_pagesize(addr); if (real_pagesize != shmbuf.shm_pagesize) { - trcVerbose("pagesize is, surprisingly, %h.", real_pagesize); + trcVerbose("pagesize is, surprisingly, " SIZE_FORMAT, real_pagesize); } if (addr) { trcVerbose("shm-allocated " PTR_FORMAT " .. " PTR_FORMAT " (" UINTX_FORMAT " bytes, " UINTX_FORMAT " %s pages)", - addr, addr + size - 1, size, size/real_pagesize, describe_pagesize(real_pagesize)); + p2i(addr), p2i(addr + size - 1), size, size/real_pagesize, describe_pagesize(real_pagesize)); } else { if (requested_addr != NULL) { - trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at with address " PTR_FORMAT ".", size, requested_addr); + trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at with address " PTR_FORMAT ".", size, p2i(requested_addr)); } else { trcVerbose("failed to shm-allocate " UINTX_FORMAT " bytes at any address.", size); } @@ -2052,7 +2054,7 @@ static char* reserve_shmated_memory ( static bool release_shmated_memory(char* addr, size_t size) { trcVerbose("release_shmated_memory [" PTR_FORMAT " - " PTR_FORMAT "].", - addr, addr + size - 1); + p2i(addr), p2i(addr + size - 1)); bool rc = false; @@ -2068,12 +2070,12 @@ static bool release_shmated_memory(char* addr, size_t size) { static bool uncommit_shmated_memory(char* addr, size_t size) { trcVerbose("uncommit_shmated_memory [" PTR_FORMAT " - " PTR_FORMAT "].", - addr, addr + size - 1); + p2i(addr), p2i(addr + size - 1)); const bool rc = my_disclaim64(addr, size); if (!rc) { - trcVerbose("my_disclaim64(" PTR_FORMAT ", " UINTX_FORMAT ") failed.\n", addr, size); + trcVerbose("my_disclaim64(" PTR_FORMAT ", " UINTX_FORMAT ") failed.\n", p2i(addr), size); return false; } return true; @@ -2090,11 +2092,11 @@ static bool uncommit_shmated_memory(char* addr, size_t size) { static char* reserve_mmaped_memory(size_t bytes, char* requested_addr, size_t alignment_hint) { trcVerbose("reserve_mmaped_memory " UINTX_FORMAT " bytes, wishaddress " PTR_FORMAT ", " "alignment_hint " UINTX_FORMAT "...", - bytes, requested_addr, alignment_hint); + bytes, p2i(requested_addr), alignment_hint); // If a wish address is given, but not aligned to 4K page boundary, mmap will fail. if (requested_addr && !is_aligned_to(requested_addr, os::vm_page_size()) != 0) { - trcVerbose("Wish address " PTR_FORMAT " not aligned to page boundary.", requested_addr); + trcVerbose("Wish address " PTR_FORMAT " not aligned to page boundary.", p2i(requested_addr)); return NULL; } @@ -2102,7 +2104,7 @@ static char* reserve_mmaped_memory(size_t bytes, char* requested_addr, size_t al // BRK because that may cause malloc OOM. if (requested_addr != NULL && is_close_to_brk((address)requested_addr)) { trcVerbose("Wish address " PTR_FORMAT " is too close to the BRK segment. " - "Will attach anywhere.", requested_addr); + "Will attach anywhere.", p2i(requested_addr)); // Act like the OS refused to attach there. requested_addr = NULL; } @@ -2149,7 +2151,7 @@ static char* reserve_mmaped_memory(size_t bytes, char* requested_addr, size_t al PROT_READ|PROT_WRITE|PROT_EXEC, flags, -1, 0); if (addr == MAP_FAILED) { - trcVerbose("mmap(" PTR_FORMAT ", " UINTX_FORMAT ", ..) failed (%d)", requested_addr, size, errno); + trcVerbose("mmap(" PTR_FORMAT ", " UINTX_FORMAT ", ..) failed (%d)", p2i(requested_addr), size, errno); return NULL; } @@ -2168,10 +2170,10 @@ static char* reserve_mmaped_memory(size_t bytes, char* requested_addr, size_t al if (addr) { trcVerbose("mmap-allocated " PTR_FORMAT " .. " PTR_FORMAT " (" UINTX_FORMAT " bytes)", - addr, addr + bytes, bytes); + p2i(addr), p2i(addr + bytes), bytes); } else { if (requested_addr != NULL) { - trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at wish address " PTR_FORMAT ".", bytes, requested_addr); + trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at wish address " PTR_FORMAT ".", bytes, p2i(requested_addr)); } else { trcVerbose("failed to mmap-allocate " UINTX_FORMAT " bytes at any address.", bytes); } @@ -2191,7 +2193,7 @@ static bool release_mmaped_memory(char* addr, size_t size) { assert0(is_aligned_to(size, os::vm_page_size())); trcVerbose("release_mmaped_memory [" PTR_FORMAT " - " PTR_FORMAT "].", - addr, addr + size - 1); + p2i(addr), p2i(addr + size - 1)); bool rc = false; if (::munmap(addr, size) != 0) { @@ -2211,7 +2213,7 @@ static bool uncommit_mmaped_memory(char* addr, size_t size) { assert0(is_aligned_to(size, os::vm_page_size())); trcVerbose("uncommit_mmaped_memory [" PTR_FORMAT " - " PTR_FORMAT "].", - addr, addr + size - 1); + p2i(addr), p2i(addr + size - 1)); bool rc = false; // Uncommit mmap memory with msync MS_INVALIDATE. @@ -2242,7 +2244,7 @@ int os::vm_allocation_granularity() { static void warn_fail_commit_memory(char* addr, size_t size, bool exec, int err) { warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT - ", %d) failed; error='%s' (errno=%d)", addr, size, exec, + ", %d) failed; error='%s' (errno=%d)", p2i(addr), size, exec, os::errno_name(err), err); } #endif @@ -2270,7 +2272,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) { guarantee0(vmi); vmi->assert_is_valid_subrange(addr, size); - trcVerbose("commit_memory [" PTR_FORMAT " - " PTR_FORMAT "].", addr, addr + size - 1); + trcVerbose("commit_memory [" PTR_FORMAT " - " PTR_FORMAT "].", p2i(addr), p2i(addr + size - 1)); if (UseExplicitCommit) { // AIX commits memory on touch. So, touch all pages to be committed. @@ -2449,6 +2451,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) { // // See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); bool rc = ::mprotect(addr, size, prot) == 0 ? true : false; if (!rc) { @@ -2489,6 +2492,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) { // A valid strategy is just to try again. This usually works. :-/ ::usleep(1000); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); if (::mprotect(addr, size, prot) == 0) { const bool read_protected_2 = (SafeFetch32((int*)addr, 0x12345678) == 0x12345678 && @@ -3035,8 +3039,6 @@ static void javaSignalHandler(int sig, siginfo_t* info, void* uc) { bool os::Aix::signal_handlers_are_installed = false; // For signal-chaining -struct sigaction sigact[NSIG]; -sigset_t sigs; bool os::Aix::libjsig_is_loaded = false; typedef struct sigaction *(*get_signal_t)(int); get_signal_t os::Aix::get_signal_action = NULL; @@ -3050,7 +3052,7 @@ struct sigaction* os::Aix::get_chained_signal_action(int sig) { } if (actp == NULL) { // Retrieve the preinstalled signal handler from jvm - actp = get_preinstalled_handler(sig); + actp = os::Posix::get_preinstalled_handler(sig); } return actp; @@ -3113,19 +3115,6 @@ bool os::Aix::chained_handler(int sig, siginfo_t* siginfo, void* context) { return chained; } -struct sigaction* os::Aix::get_preinstalled_handler(int sig) { - if (sigismember(&sigs, sig)) { - return &sigact[sig]; - } - return NULL; -} - -void os::Aix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { - assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); - sigact[sig] = oldAct; - sigaddset(&sigs, sig); -} - // for diagnostic int sigflags[NSIG]; @@ -3157,7 +3146,7 @@ void os::Aix::set_signal_handler(int sig, bool set_installed) { return; } else if (UseSignalChaining) { // save the old handler in jvm - save_preinstalled_handler(sig, oldAct); + os::Posix::save_preinstalled_handler(sig, oldAct); // libjsig also interposes the sigaction() call below and saves the // old sigaction on it own. } else { @@ -3213,7 +3202,6 @@ void os::Aix::install_signal_handlers() { (*begin_signal_setting)(); } - ::sigemptyset(&sigs); set_signal_handler(SIGSEGV, true); set_signal_handler(SIGPIPE, true); set_signal_handler(SIGBUS, true); diff --git a/src/src/hotspot/os/aix/os_aix.hpp b/src/src/hotspot/os/aix/os_aix.hpp index 515edfd0b07..f00036fec47 100644 --- a/src/src/hotspot/os/aix/os_aix.hpp +++ b/src/src/hotspot/os/aix/os_aix.hpp @@ -37,8 +37,6 @@ class Aix { static bool libjsig_is_loaded; // libjsig that interposes sigaction(), // __sigaction(), signal() is loaded static struct sigaction *(*get_signal_action)(int); - static struct sigaction *get_preinstalled_handler(int); - static void save_preinstalled_handler(int, struct sigaction&); static void check_signal_handler(int sig); diff --git a/src/src/hotspot/os/aix/os_perf_aix.cpp b/src/src/hotspot/os/aix/os_perf_aix.cpp index f754e4a4d2d..7c4a945c52c 100644 --- a/src/src/hotspot/os/aix/os_perf_aix.cpp +++ b/src/src/hotspot/os/aix/os_perf_aix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -720,11 +720,7 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() { char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const { if (str != NULL) { - size_t len = strlen(str); - char* tmp = NEW_C_HEAP_ARRAY(char, len+1, mtInternal); - strncpy(tmp, str, len); - tmp[len] = '\0'; - return tmp; + return os::strdup_check_oom(str, mtInternal); } return NULL; } diff --git a/src/src/hotspot/os/aix/safepointMechanism_aix.cpp b/src/src/hotspot/os/aix/safepointMechanism_aix.cpp index a6b33c0beb6..7fd5ba2c3fc 100644 --- a/src/src/hotspot/os/aix/safepointMechanism_aix.cpp +++ b/src/src/hotspot/os/aix/safepointMechanism_aix.cpp @@ -27,6 +27,7 @@ #include "runtime/globals.hpp" #include "runtime/os.hpp" #include "runtime/safepointMechanism.hpp" +#include "services/memTracker.hpp" #include void SafepointMechanism::pd_initialize() { @@ -95,6 +96,9 @@ void SafepointMechanism::pd_initialize() { log_info(os)("SafePoint Polling address: " INTPTR_FORMAT, p2i(map_address)); os::set_polling_page((address)(map_address)); + // Register polling page with NMT. + MemTracker::record_virtual_memory_reserve_and_commit(map_address, map_size, CALLER_PC, mtSafepoint); + // Use same page for ThreadLocalHandshakes without SIGTRAP if (ThreadLocalHandshakes) { set_uses_thread_local_poll(); diff --git a/src/src/hotspot/os/bsd/os_bsd.cpp b/src/src/hotspot/os/bsd/os_bsd.cpp index 6b3b3c8d87f..d5e8696c5ea 100644 --- a/src/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/src/hotspot/os/bsd/os_bsd.cpp @@ -33,6 +33,7 @@ #include "compiler/disassembler.hpp" #include "interpreter/interpreter.hpp" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "oops/oop.inline.hpp" @@ -750,6 +751,11 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } else { log_warning(os, thread)("Failed to start thread - pthread_create failed (%s) for attributes: %s.", os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); + // Log some OS information which might explain why creating the thread failed. + log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); + LogStream st(Log(os, thread)::info()); + os::Posix::print_rlimit_info(&st); + os::print_memory_info(&st); } pthread_attr_destroy(&attr); @@ -1615,6 +1621,8 @@ void os::get_summary_cpu_info(char* buf, size_t buflen) { } void os::print_memory_info(outputStream* st) { + xsw_usage swap_usage; + size_t size = sizeof(swap_usage); st->print("Memory:"); st->print(" %dk page", os::vm_page_size()>>10); @@ -1623,6 +1631,16 @@ void os::print_memory_info(outputStream* st) { os::physical_memory() >> 10); st->print("(" UINT64_FORMAT "k free)", os::available_memory() >> 10); + + if((sysctlbyname("vm.swapusage", &swap_usage, &size, NULL, 0) == 0) || (errno == ENOMEM)) { + if (size >= offset_of(xsw_usage, xsu_used)) { + st->print(", swap " UINT64_FORMAT "k", + ((julong) swap_usage.xsu_total) >> 10); + st->print("(" UINT64_FORMAT "k free)", + ((julong) swap_usage.xsu_avail) >> 10); + } + } + st->cr(); } @@ -1938,6 +1956,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) { int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; #ifdef __OpenBSD__ // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot); if (::mprotect(addr, size, prot) == 0) { return true; } @@ -2022,6 +2041,7 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info bool os::pd_uncommit_memory(char* addr, size_t size) { #ifdef __OpenBSD__ // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size)); return ::mprotect(addr, size, PROT_NONE) == 0; #else uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE, @@ -2090,6 +2110,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) { assert(addr == bottom, "sanity check"); size = align_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size()); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot); return ::mprotect(bottom, size, prot) == 0; } @@ -2777,11 +2798,6 @@ static void signalHandler(int sig, siginfo_t* info, void* uc) { bool os::Bsd::signal_handlers_are_installed = false; // For signal-chaining -struct sigaction sigact[NSIG]; -uint32_t sigs = 0; -#if (32 < NSIG-1) -#error "Not all signals can be encoded in sigs. Adapt its type!" -#endif bool os::Bsd::libjsig_is_loaded = false; typedef struct sigaction *(*get_signal_t)(int); get_signal_t os::Bsd::get_signal_action = NULL; @@ -2795,7 +2811,7 @@ struct sigaction* os::Bsd::get_chained_signal_action(int sig) { } if (actp == NULL) { // Retrieve the preinstalled signal handler from jvm - actp = get_preinstalled_handler(sig); + actp = os::Posix::get_preinstalled_handler(sig); } return actp; @@ -2858,19 +2874,6 @@ bool os::Bsd::chained_handler(int sig, siginfo_t* siginfo, void* context) { return chained; } -struct sigaction* os::Bsd::get_preinstalled_handler(int sig) { - if ((((uint32_t)1 << (sig-1)) & sigs) != 0) { - return &sigact[sig]; - } - return NULL; -} - -void os::Bsd::save_preinstalled_handler(int sig, struct sigaction& oldAct) { - assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); - sigact[sig] = oldAct; - sigs |= (uint32_t)1 << (sig-1); -} - // for diagnostic int sigflags[NSIG]; @@ -2902,7 +2905,7 @@ void os::Bsd::set_signal_handler(int sig, bool set_installed) { return; } else if (UseSignalChaining) { // save the old handler in jvm - save_preinstalled_handler(sig, oldAct); + os::Posix::save_preinstalled_handler(sig, oldAct); // libjsig also interposes the sigaction() call below and saves the // old sigaction on it own. } else { diff --git a/src/src/hotspot/os/bsd/os_bsd.hpp b/src/src/hotspot/os/bsd/os_bsd.hpp index b04da8cbc5c..e2fb5b18c2d 100644 --- a/src/src/hotspot/os/bsd/os_bsd.hpp +++ b/src/src/hotspot/os/bsd/os_bsd.hpp @@ -37,8 +37,6 @@ class Bsd { static bool libjsig_is_loaded; // libjsig that interposes sigaction(), // __sigaction(), signal() is loaded static struct sigaction *(*get_signal_action)(int); - static struct sigaction *get_preinstalled_handler(int); - static void save_preinstalled_handler(int, struct sigaction&); static void check_signal_handler(int sig); diff --git a/src/src/hotspot/os/linux/osContainer_linux.cpp b/src/src/hotspot/os/linux/osContainer_linux.cpp index 0b35bb32c5d..ca936270063 100644 --- a/src/src/hotspot/os/linux/osContainer_linux.cpp +++ b/src/src/hotspot/os/linux/osContainer_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -81,14 +81,14 @@ class CgroupSubsystem: CHeapObj { buf[MAXPATHLEN-1] = '\0'; _path = os::strdup(buf); } else { - char *p = strstr(_root, cgroup_path); + char *p = strstr(cgroup_path, _root); if (p != NULL && p == _root) { if (strlen(cgroup_path) > strlen(_root)) { int buflen; strncpy(buf, _mount_point, MAXPATHLEN); buf[MAXPATHLEN-1] = '\0'; buflen = strlen(buf); - if ((buflen + strlen(cgroup_path)) > (MAXPATHLEN-1)) { + if ((buflen + strlen(cgroup_path) - strlen(_root)) > (MAXPATHLEN-1)) { return; } strncat(buf, cgroup_path + strlen(_root), MAXPATHLEN-buflen); @@ -199,16 +199,11 @@ PRAGMA_DIAG_POP * we are running under cgroup control. */ void OSContainer::init() { - int mountid; - int parentid; - int major; - int minor; FILE *mntinfo = NULL; FILE *cgroup = NULL; char buf[MAXPATHLEN+1]; char tmproot[MAXPATHLEN+1]; char tmpmount[MAXPATHLEN+1]; - char tmpbase[MAXPATHLEN+1]; char *p; jlong mem_limit; @@ -242,85 +237,24 @@ void OSContainer::init() { return; } - while ( (p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) { - // Look for the filesystem type and see if it's cgroup - char fstype[MAXPATHLEN+1]; - fstype[0] = '\0'; - char *s = strstr(p, " - "); - if (s != NULL && - sscanf(s, " - %s", fstype) == 1 && - strcmp(fstype, "cgroup") == 0) { - - if (strstr(p, "memory") != NULL) { - int matched = sscanf(p, "%d %d %d:%d %s %s", - &mountid, - &parentid, - &major, - &minor, - tmproot, - tmpmount); - if (matched == 6) { - memory = new CgroupSubsystem(tmproot, tmpmount); - } - else - log_debug(os, container)("Incompatible str containing cgroup and memory: %s", p); - } else if (strstr(p, "cpuset") != NULL) { - int matched = sscanf(p, "%d %d %d:%d %s %s", - &mountid, - &parentid, - &major, - &minor, - tmproot, - tmpmount); - if (matched == 6) { - cpuset = new CgroupSubsystem(tmproot, tmpmount); - } - else { - log_debug(os, container)("Incompatible str containing cgroup and cpuset: %s", p); - } - } else if (strstr(p, "cpu,cpuacct") != NULL || strstr(p, "cpuacct,cpu") != NULL) { - int matched = sscanf(p, "%d %d %d:%d %s %s", - &mountid, - &parentid, - &major, - &minor, - tmproot, - tmpmount); - if (matched == 6) { - cpu = new CgroupSubsystem(tmproot, tmpmount); - cpuacct = new CgroupSubsystem(tmproot, tmpmount); - } - else { - log_debug(os, container)("Incompatible str containing cgroup and cpu,cpuacct: %s", p); - } - } else if (strstr(p, "cpuacct") != NULL) { - int matched = sscanf(p, "%d %d %d:%d %s %s", - &mountid, - &parentid, - &major, - &minor, - tmproot, - tmpmount); - if (matched == 6) { - cpuacct = new CgroupSubsystem(tmproot, tmpmount); - } - else { - log_debug(os, container)("Incompatible str containing cgroup and cpuacct: %s", p); - } - } else if (strstr(p, "cpu") != NULL) { - int matched = sscanf(p, "%d %d %d:%d %s %s", - &mountid, - &parentid, - &major, - &minor, - tmproot, - tmpmount); - if (matched == 6) { - cpu = new CgroupSubsystem(tmproot, tmpmount); - } - else { - log_debug(os, container)("Incompatible str containing cgroup and cpu: %s", p); - } + while ((p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) { + char tmpcgroups[MAXPATHLEN+1]; + char *cptr = tmpcgroups; + char *token; + + // mountinfo format is documented at https://www.kernel.org/doc/Documentation/filesystems/proc.txt + if (sscanf(p, "%*d %*d %*d:%*d %s %s %*[^-]- cgroup %*s %s", tmproot, tmpmount, tmpcgroups) != 3) { + continue; + } + while ((token = strsep(&cptr, ",")) != NULL) { + if (strcmp(token, "memory") == 0) { + memory = new CgroupSubsystem(tmproot, tmpmount); + } else if (strcmp(token, "cpuset") == 0) { + cpuset = new CgroupSubsystem(tmproot, tmpmount); + } else if (strcmp(token, "cpu") == 0) { + cpu = new CgroupSubsystem(tmproot, tmpmount); + } else if (strcmp(token, "cpuacct") == 0) { + cpuacct= new CgroupSubsystem(tmproot, tmpmount); } } } @@ -374,30 +308,30 @@ void OSContainer::init() { return; } - while ( (p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) { - int cgno; - int matched; - char *controller; + while ((p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) { + char *controllers; + char *token; char *base; /* Skip cgroup number */ strsep(&p, ":"); - /* Get controller and base */ - controller = strsep(&p, ":"); + /* Get controllers and base */ + controllers = strsep(&p, ":"); base = strsep(&p, "\n"); - if (controller != NULL) { - if (strstr(controller, "memory") != NULL) { + if (controllers == NULL) { + continue; + } + + while ((token = strsep(&controllers, ",")) != NULL) { + if (strcmp(token, "memory") == 0) { memory->set_subsystem_path(base); - } else if (strstr(controller, "cpuset") != NULL) { + } else if (strcmp(token, "cpuset") == 0) { cpuset->set_subsystem_path(base); - } else if (strstr(controller, "cpu,cpuacct") != NULL || strstr(controller, "cpuacct,cpu") != NULL) { + } else if (strcmp(token, "cpu") == 0) { cpu->set_subsystem_path(base); + } else if (strcmp(token, "cpuacct") == 0) { cpuacct->set_subsystem_path(base); - } else if (strstr(controller, "cpuacct") != NULL) { - cpuacct->set_subsystem_path(base); - } else if (strstr(controller, "cpu") != NULL) { - cpu->set_subsystem_path(base); } } } diff --git a/src/src/hotspot/os/linux/os_linux.cpp b/src/src/hotspot/os/linux/os_linux.cpp index 4a7986e46c9..2cccc9767ad 100644 --- a/src/src/hotspot/os/linux/os_linux.cpp +++ b/src/src/hotspot/os/linux/os_linux.cpp @@ -33,6 +33,7 @@ #include "compiler/disassembler.hpp" #include "interpreter/interpreter.hpp" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "oops/oop.inline.hpp" @@ -61,6 +62,7 @@ #include "runtime/threadCritical.hpp" #include "runtime/threadSMR.hpp" #include "runtime/timer.hpp" +#include "runtime/vm_version.hpp" #include "semaphore_posix.hpp" #include "services/attachListener.hpp" #include "services/memTracker.hpp" @@ -848,6 +850,13 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } else { log_warning(os, thread)("Failed to start thread - pthread_create failed (%s) for attributes: %s.", os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); + // Log some OS information which might explain why creating the thread failed. + log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); + LogStream st(Log(os, thread)::info()); + os::Posix::print_rlimit_info(&st); + os::print_memory_info(&st); + os::Linux::print_proc_sys_info(&st); + os::Linux::print_container_info(&st); } pthread_attr_destroy(&attr); @@ -1993,35 +2002,6 @@ static bool _print_ascii_file(const char* filename, outputStream* st, const char return true; } -#if defined(S390) || defined(PPC64) -// keywords_to_match - NULL terminated array of keywords -static bool print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) { - char* line = NULL; - size_t length = 0; - FILE* fp = fopen(filename, "r"); - if (fp == NULL) { - return false; - } - - st->print_cr("Virtualization information:"); - while (getline(&line, &length, fp) != -1) { - int i = 0; - while (keywords_to_match[i] != NULL) { - if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) { - st->print("%s", line); - break; - } - i++; - } - } - - free(line); - fclose(fp); - - return true; -} -#endif - void os::print_dll_info(outputStream *st) { st->print_cr("Dynamic libraries:"); @@ -2106,7 +2086,7 @@ void os::print_os_info(outputStream* st) { os::Linux::print_container_info(st); - os::Linux::print_virtualization_info(st); + VM_Version::print_platform_virtualization_info(st); os::Linux::print_steal_info(st); } @@ -2322,40 +2302,6 @@ void os::Linux::print_container_info(outputStream* st) { st->cr(); } -void os::Linux::print_virtualization_info(outputStream* st) { -#if defined(S390) - // /proc/sysinfo contains interesting information about - // - LPAR - // - whole "Box" (CPUs ) - // - z/VM / KVM (VM); this is not available in an LPAR-only setup - const char* kw[] = { "LPAR", "CPUs", "VM", NULL }; - const char* info_file = "/proc/sysinfo"; - - if (!print_matching_lines_from_file(info_file, st, kw)) { - st->print_cr(" <%s Not Available>", info_file); - } -#elif defined(PPC64) - const char* info_file = "/proc/ppc64/lparcfg"; - const char* kw[] = { "system_type=", // qemu indicates PowerKVM - "partition_entitled_capacity=", // entitled processor capacity percentage - "partition_max_entitled_capacity=", - "capacity_weight=", // partition CPU weight - "partition_active_processors=", - "partition_potential_processors=", - "entitled_proc_capacity_available=", - "capped=", // 0 - uncapped, 1 - vcpus capped at entitled processor capacity percentage - "shared_processor_mode=", // (non)dedicated partition - "system_potential_processors=", - "pool=", // CPU-pool number - "pool_capacity=", - "NumLpars=", // on non-KVM machines, NumLpars is not found for full partition mode machines - NULL }; - if (!print_matching_lines_from_file(info_file, st, kw)) { - st->print_cr(" <%s Not Available>", info_file); - } -#endif -} - void os::Linux::print_steal_info(outputStream* st) { if (has_initial_tick_info) { CPUPerfTicks pticks; @@ -3537,6 +3483,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) { assert(addr == bottom, "sanity check"); size = align_up(pointer_delta(addr, bottom, 1) + size, os::Linux::page_size()); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot); return ::mprotect(bottom, size, prot) == 0; } @@ -4661,11 +4608,6 @@ static void signalHandler(int sig, siginfo_t* info, void* uc) { bool os::Linux::signal_handlers_are_installed = false; // For signal-chaining -struct sigaction sigact[NSIG]; -uint64_t sigs = 0; -#if (64 < NSIG-1) -#error "Not all signals can be encoded in sigs. Adapt its type!" -#endif bool os::Linux::libjsig_is_loaded = false; typedef struct sigaction *(*get_signal_t)(int); get_signal_t os::Linux::get_signal_action = NULL; @@ -4679,7 +4621,7 @@ struct sigaction* os::Linux::get_chained_signal_action(int sig) { } if (actp == NULL) { // Retrieve the preinstalled signal handler from jvm - actp = get_preinstalled_handler(sig); + actp = os::Posix::get_preinstalled_handler(sig); } return actp; @@ -4743,19 +4685,6 @@ bool os::Linux::chained_handler(int sig, siginfo_t* siginfo, void* context) { return chained; } -struct sigaction* os::Linux::get_preinstalled_handler(int sig) { - if ((((uint64_t)1 << (sig-1)) & sigs) != 0) { - return &sigact[sig]; - } - return NULL; -} - -void os::Linux::save_preinstalled_handler(int sig, struct sigaction& oldAct) { - assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); - sigact[sig] = oldAct; - sigs |= (uint64_t)1 << (sig-1); -} - // for diagnostic int sigflags[NSIG]; @@ -4787,7 +4716,7 @@ void os::Linux::set_signal_handler(int sig, bool set_installed) { return; } else if (UseSignalChaining) { // save the old handler in jvm - save_preinstalled_handler(sig, oldAct); + os::Posix::save_preinstalled_handler(sig, oldAct); // libjsig also interposes the sigaction() call below and saves the // old sigaction on it own. } else { diff --git a/src/src/hotspot/os/linux/os_linux.hpp b/src/src/hotspot/os/linux/os_linux.hpp index 75eb8821253..56fc9a7fcfc 100644 --- a/src/src/hotspot/os/linux/os_linux.hpp +++ b/src/src/hotspot/os/linux/os_linux.hpp @@ -38,8 +38,6 @@ class Linux { static bool libjsig_is_loaded; // libjsig that interposes sigaction(), // __sigaction(), signal() is loaded static struct sigaction *(*get_signal_action)(int); - static struct sigaction *get_preinstalled_handler(int); - static void save_preinstalled_handler(int, struct sigaction&); static void check_signal_handler(int sig); @@ -111,7 +109,6 @@ class Linux { static void print_full_memory_info(outputStream* st); static void print_container_info(outputStream* st); - static void print_virtualization_info(outputStream* st); static void print_steal_info(outputStream* st); static void print_distro_info(outputStream* st); static void print_libversion_info(outputStream* st); diff --git a/src/src/hotspot/os/linux/os_perf_linux.cpp b/src/src/hotspot/os/linux/os_perf_linux.cpp index 6c144863453..2b35dab9cf0 100644 --- a/src/src/hotspot/os/linux/os_perf_linux.cpp +++ b/src/src/hotspot/os/linux/os_perf_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -780,11 +780,7 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() { char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const { if (str != NULL) { - size_t len = strlen(str); - char* tmp = NEW_C_HEAP_ARRAY(char, len+1, mtInternal); - strncpy(tmp, str, len); - tmp[len] = '\0'; - return tmp; + return os::strdup_check_oom(str, mtInternal); } return NULL; } diff --git a/src/src/hotspot/os/posix/os_posix.cpp b/src/src/hotspot/os/posix/os_posix.cpp index 8b8328913db..708041f0498 100644 --- a/src/src/hotspot/os/posix/os_posix.cpp +++ b/src/src/hotspot/os/posix/os_posix.cpp @@ -168,13 +168,14 @@ int os::create_file_for_heap(const char* dir) { const char name_template[] = "/jvmheap.XXXXXX"; - char *fullname = (char*)os::malloc((strlen(dir) + strlen(name_template) + 1), mtInternal); + size_t fullname_len = strlen(dir) + strlen(name_template); + char *fullname = (char*)os::malloc(fullname_len + 1, mtInternal); if (fullname == NULL) { vm_exit_during_initialization(err_msg("Malloc failed during creation of backing file for heap (%s)", os::strerror(errno))); return -1; } - (void)strncpy(fullname, dir, strlen(dir)+1); - (void)strncat(fullname, name_template, strlen(name_template)); + int n = snprintf(fullname, fullname_len + 1, "%s%s", dir, name_template); + assert((size_t)n == fullname_len, "Unexpected number of characters in string"); os::native_path(fullname); @@ -1646,6 +1647,24 @@ static void pthread_init_common(void) { } } +#ifndef SOLARIS +sigset_t sigs; +struct sigaction sigact[NSIG]; + +struct sigaction* os::Posix::get_preinstalled_handler(int sig) { + if (sigismember(&sigs, sig)) { + return &sigact[sig]; + } + return NULL; +} + +void os::Posix::save_preinstalled_handler(int sig, struct sigaction& oldAct) { + assert(sig > 0 && sig < NSIG, "vm signal out of expected range"); + sigact[sig] = oldAct; + sigaddset(&sigs, sig); +} +#endif + // Not all POSIX types and API's are available on all notionally "posix" // platforms. If we have build-time support then we will check for actual // runtime support via dlopen/dlsym lookup. This allows for running on an @@ -1757,6 +1776,9 @@ void os::Posix::init_2(void) { (_pthread_condattr_setclock != NULL ? "" : " not")); log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with %s", _use_clock_monotonic_condattr ? "CLOCK_MONOTONIC" : "the default clock"); +#ifndef SOLARIS + sigemptyset(&sigs); +#endif } #else // !SUPPORTS_CLOCK_MONOTONIC @@ -1769,6 +1791,9 @@ void os::Posix::init_2(void) { log_info(os)("Use of CLOCK_MONOTONIC is not supported"); log_info(os)("Use of pthread_condattr_setclock is not supported"); log_info(os)("Relative timed-wait using pthread_cond_timedwait is associated with the default clock"); +#ifndef SOLARIS + sigemptyset(&sigs); +#endif } #endif // SUPPORTS_CLOCK_MONOTONIC diff --git a/src/src/hotspot/os/posix/os_posix.hpp b/src/src/hotspot/os/posix/os_posix.hpp index 9f133ebbb21..8ed86979493 100644 --- a/src/src/hotspot/os/posix/os_posix.hpp +++ b/src/src/hotspot/os/posix/os_posix.hpp @@ -117,6 +117,9 @@ class Posix { // effective gid, or if given uid is root. static bool matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid); + static struct sigaction *get_preinstalled_handler(int); + static void save_preinstalled_handler(int, struct sigaction&); + static void print_umask(outputStream* st, mode_t umsk); static void print_user_info(outputStream* st); @@ -163,7 +166,7 @@ class ThreadCrashProtection : public StackObj { * These event objects are type-stable and immortal - we never delete them. * Events are associated with a thread for the lifetime of the thread. */ -class PlatformEvent : public CHeapObj { +class PlatformEvent : public CHeapObj { private: double cachePad[4]; // Increase odds that _mutex is sole occupant of cache line volatile int _event; // Event count/permit: -1, 0 or 1 @@ -198,7 +201,7 @@ class PlatformEvent : public CHeapObj { // API updates of course). But Parker methods use fastpaths that break that // level of encapsulation - so combining the two remains a future project. -class PlatformParker : public CHeapObj { +class PlatformParker : public CHeapObj { protected: enum { REL_INDEX = 0, diff --git a/src/src/hotspot/os/solaris/os_perf_solaris.cpp b/src/src/hotspot/os/solaris/os_perf_solaris.cpp index 789b34e2727..772fd8b755e 100644 --- a/src/src/hotspot/os/solaris/os_perf_solaris.cpp +++ b/src/src/hotspot/os/solaris/os_perf_solaris.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -544,11 +544,7 @@ bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_valid_entry(st char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const { if (str != NULL) { - size_t len = strlen(str); - char* tmp = NEW_C_HEAP_ARRAY(char, len+1, mtInternal); - strncpy(tmp, str, len); - tmp[len] = '\0'; - return tmp; + return os::strdup_check_oom(str, mtInternal); } return NULL; } diff --git a/src/src/hotspot/os/solaris/os_solaris.cpp b/src/src/hotspot/os/solaris/os_solaris.cpp index b3c78620ca4..a8816b5af7c 100644 --- a/src/src/hotspot/os/solaris/os_solaris.cpp +++ b/src/src/hotspot/os/solaris/os_solaris.cpp @@ -33,6 +33,7 @@ #include "compiler/disassembler.hpp" #include "interpreter/interpreter.hpp" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "oops/oop.inline.hpp" @@ -1006,6 +1007,11 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } else { log_warning(os, thread)("Failed to start thread - thr_create failed (%s) for attributes: %s.", os::errno_name(status), describe_thr_create_attributes(buf, sizeof(buf), stack_size, flags)); + // Log some OS information which might explain why creating the thread failed. + log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); + LogStream st(Log(os, thread)::info()); + os::Posix::print_rlimit_info(&st); + os::print_memory_info(&st); } if (status != 0) { @@ -2058,6 +2064,7 @@ void* os::signal(int signal_number, void* handler) { struct sigaction sigAct, oldSigAct; sigfillset(&(sigAct.sa_mask)); sigAct.sa_flags = SA_RESTART & ~SA_RESETHAND; + sigAct.sa_flags |= SA_SIGINFO; sigAct.sa_handler = CAST_TO_FN_PTR(sa_handler_t, handler); if (sigaction(signal_number, &sigAct, &oldSigAct)) { @@ -2697,6 +2704,7 @@ bool os::pd_release_memory(char* addr, size_t bytes) { static bool solaris_mprotect(char* addr, size_t bytes, int prot) { assert(addr == (char*)align_down((uintptr_t)addr, os::vm_page_size()), "addr must be page aligned"); + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+bytes), prot); int retVal = mprotect(addr, bytes, prot); return retVal == 0; } @@ -4297,6 +4305,7 @@ jint os::init_2(void) { // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { + Events::log(NULL, "Protecting polling page " INTPTR_FORMAT " with PROT_NONE", p2i(_polling_page)); if (mprotect((char *)_polling_page, page_size, PROT_NONE) != 0) { fatal("Could not disable polling page"); } @@ -4304,6 +4313,7 @@ void os::make_polling_page_unreadable(void) { // Mark the polling page as readable void os::make_polling_page_readable(void) { + Events::log(NULL, "Protecting polling page " INTPTR_FORMAT " with PROT_READ", p2i(_polling_page)); if (mprotect((char *)_polling_page, page_size, PROT_READ) != 0) { fatal("Could not enable polling page"); } diff --git a/src/src/hotspot/os/solaris/os_solaris.hpp b/src/src/hotspot/os/solaris/os_solaris.hpp index fa86bc9cd14..c522713001c 100644 --- a/src/src/hotspot/os/solaris/os_solaris.hpp +++ b/src/src/hotspot/os/solaris/os_solaris.hpp @@ -281,7 +281,7 @@ class Solaris { }; -class PlatformEvent : public CHeapObj { +class PlatformEvent : public CHeapObj { private: double CachePad[4]; // increase odds that _mutex is sole occupant of cache line volatile int _Event; @@ -317,7 +317,7 @@ class PlatformEvent : public CHeapObj { void unpark(); }; -class PlatformParker : public CHeapObj { +class PlatformParker : public CHeapObj { protected: mutex_t _mutex[1]; cond_t _cond[1]; diff --git a/src/src/hotspot/os/windows/os_perf_windows.cpp b/src/src/hotspot/os/windows/os_perf_windows.cpp index cdffca9ff48..7af7e0924f0 100644 --- a/src/src/hotspot/os/windows/os_perf_windows.cpp +++ b/src/src/hotspot/os/windows/os_perf_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -1253,14 +1253,7 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProc char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const { if (str != NULL) { - size_t len = strlen(str); - char* tmp = NEW_C_HEAP_ARRAY(char, len+1, mtInternal); - if (NULL == tmp) { - return NULL; - } - strncpy(tmp, str, len); - tmp[len] = '\0'; - return tmp; + return os::strdup_check_oom(str, mtInternal); } return NULL; } diff --git a/src/src/hotspot/os/windows/os_windows.cpp b/src/src/hotspot/os/windows/os_windows.cpp index a3650298931..f352bde6db7 100644 --- a/src/src/hotspot/os/windows/os_windows.cpp +++ b/src/src/hotspot/os/windows/os_windows.cpp @@ -36,6 +36,7 @@ #include "compiler/disassembler.hpp" #include "interpreter/interpreter.hpp" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "oops/oop.inline.hpp" @@ -658,6 +659,10 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } else { log_warning(os, thread)("Failed to start thread - _beginthreadex failed (%s) for attributes: %s.", os::errno_name(errno), describe_beginthreadex_attributes(buf, sizeof(buf), stack_size, initflag)); + // Log some OS information which might explain why creating the thread failed. + log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads()); + LogStream st(Log(os, thread)::info()); + os::print_memory_info(&st); } if (thread_handle == NULL) { @@ -1589,6 +1594,10 @@ void os::print_os_info(outputStream* st) { #endif st->print("OS:"); os::win32::print_windows_version(st); + +#ifdef _LP64 + VM_Version::print_platform_virtualization_info(st); +#endif } void os::win32::print_windows_version(outputStream* st) { @@ -2967,14 +2976,15 @@ void os::large_page_init() { int os::create_file_for_heap(const char* dir) { const char name_template[] = "/jvmheap.XXXXXX"; - char *fullname = (char*)os::malloc((strlen(dir) + strlen(name_template) + 1), mtInternal); + + size_t fullname_len = strlen(dir) + strlen(name_template); + char *fullname = (char*)os::malloc(fullname_len + 1, mtInternal); if (fullname == NULL) { vm_exit_during_initialization(err_msg("Malloc failed during creation of backing file for heap (%s)", os::strerror(errno))); return -1; } - - (void)strncpy(fullname, dir, strlen(dir)+1); - (void)strncat(fullname, name_template, strlen(name_template)); + int n = snprintf(fullname, fullname_len + 1, "%s%s", dir, name_template); + assert((size_t)n == fullname_len, "Unexpected number of characters in string"); os::native_path(fullname); @@ -4869,6 +4879,9 @@ char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset, return NULL; } + // Record virtual memory allocation + MemTracker::record_virtual_memory_reserve_and_commit((address)addr, bytes, CALLER_PC); + DWORD bytes_read; OVERLAPPED overlapped; overlapped.Offset = (DWORD)file_offset; diff --git a/src/src/hotspot/os/windows/os_windows.hpp b/src/src/hotspot/os/windows/os_windows.hpp index b056c81b584..165f4513aa4 100644 --- a/src/src/hotspot/os/windows/os_windows.hpp +++ b/src/src/hotspot/os/windows/os_windows.hpp @@ -160,7 +160,7 @@ class ThreadCrashProtection : public StackObj { static volatile intptr_t _crash_mux; }; -class PlatformEvent : public CHeapObj { +class PlatformEvent : public CHeapObj { private: double CachePad [4] ; // increase odds that _Event is sole occupant of cache line volatile int _Event ; @@ -186,7 +186,7 @@ class PlatformEvent : public CHeapObj { -class PlatformParker : public CHeapObj { +class PlatformParker : public CHeapObj { protected: HANDLE _ParkEvent ; diff --git a/src/src/hotspot/os_cpu/linux_aarch64/linux_aarch64.S b/src/src/hotspot/os_cpu/linux_aarch64/linux_aarch64.S deleted file mode 100644 index 3c863ad1d2c..00000000000 --- a/src/src/hotspot/os_cpu/linux_aarch64/linux_aarch64.S +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. -// Copyright (c) 2014, Red Hat Inc. All rights reserved. -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -// -// This code is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License version 2 only, as -// published by the Free Software Foundation. -// -// This code is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// version 2 for more details (a copy is included in the LICENSE file that -// accompanied this code). -// -// You should have received a copy of the GNU General Public License version -// 2 along with this work; if not, write to the Free Software Foundation, -// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -// or visit www.oracle.com if you need additional information or have any -// questions. - -#ifdef BUILTIN_SIM - - .globl SafeFetch32, Fetch32PFI, Fetch32Resume - .align 16 - .type SafeFetch32,@function - // Prototype: int SafeFetch32 (int * Adr, int ErrValue) -SafeFetch32: - movl %esi, %eax -Fetch32PFI: - movl (%rdi), %eax -Fetch32Resume: - ret - - .globl SafeFetchN, FetchNPFI, FetchNResume - .align 16 - .type SafeFetchN,@function - // Prototype: intptr_t SafeFetchN (intptr_t * Adr, intptr_t ErrValue) -SafeFetchN: - movq %rsi, %rax -FetchNPFI: - movq (%rdi), %rax -FetchNResume: - ret - -#endif diff --git a/src/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp index 1900af5a72c..50d894b8e8a 100644 --- a/src/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp +++ b/src/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp @@ -53,9 +53,6 @@ #include "utilities/debug.hpp" #include "utilities/events.hpp" #include "utilities/vmError.hpp" -#ifdef BUILTIN_SIM -#include "../../../../../../simulator/simulator.hpp" -#endif // put OS-includes here # include @@ -79,19 +76,11 @@ # include # include -#ifdef BUILTIN_SIM -#define REG_SP REG_RSP -#define REG_PC REG_RIP -#define REG_FP REG_RBP -#define SPELL_REG_SP "rsp" -#define SPELL_REG_FP "rbp" -#else #define REG_FP 29 #define REG_LR 30 #define SPELL_REG_SP "sp" #define SPELL_REG_FP "x29" -#endif address os::current_stack_pointer() { register void *esp __asm__ (SPELL_REG_SP); @@ -107,35 +96,19 @@ char* os::non_memory_address_word() { } address os::Linux::ucontext_get_pc(const ucontext_t * uc) { -#ifdef BUILTIN_SIM - return (address)uc->uc_mcontext.gregs[REG_PC]; -#else return (address)uc->uc_mcontext.pc; -#endif } void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { -#ifdef BUILTIN_SIM - uc->uc_mcontext.gregs[REG_PC] = (intptr_t)pc; -#else uc->uc_mcontext.pc = (intptr_t)pc; -#endif } intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { -#ifdef BUILTIN_SIM - return (intptr_t*)uc->uc_mcontext.gregs[REG_SP]; -#else return (intptr_t*)uc->uc_mcontext.sp; -#endif } intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { -#ifdef BUILTIN_SIM - return (intptr_t*)uc->uc_mcontext.gregs[REG_FP]; -#else return (intptr_t*)uc->uc_mcontext.regs[REG_FP]; -#endif } // For Forte Analyzer AsyncGetCallTrace profiling support - thread @@ -223,11 +196,7 @@ bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* // By default, gcc always saves frame pointer rfp on this stack. This // may get turned off by -fomit-frame-pointer. frame os::get_sender_for_C_frame(frame* fr) { -#ifdef BUILTIN_SIM - return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); -#else return frame(fr->link(), fr->link(), fr->sender_pc()); -#endif } intptr_t* _get_previous_fp() { @@ -265,13 +234,6 @@ enum { trap_page_fault = 0xE }; -#ifdef BUILTIN_SIM -extern "C" void Fetch32PFI () ; -extern "C" void Fetch32Resume () ; -extern "C" void FetchNPFI () ; -extern "C" void FetchNResume () ; -#endif - extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, @@ -341,21 +303,10 @@ JVM_handle_linux_signal(int sig, if (info != NULL && uc != NULL && thread != NULL) { pc = (address) os::Linux::ucontext_get_pc(uc); -#ifdef BUILTIN_SIM - if (pc == (address) Fetch32PFI) { - uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ; - return 1 ; - } - if (pc == (address) FetchNPFI) { - uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ; - return 1 ; - } -#else if (StubRoutines::is_safefetch_fault(pc)) { os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); return 1; } -#endif // Handle ALL stack overflow variations here if (sig == SIGSEGV) { @@ -365,7 +316,6 @@ JVM_handle_linux_signal(int sig, if (thread->on_local_stack(addr)) { // stack overflow if (thread->in_stack_yellow_reserved_zone(addr)) { - thread->disable_stack_yellow_reserved_zone(); if (thread->thread_state() == _thread_in_Java) { if (thread->in_stack_reserved_zone(addr)) { frame fr; @@ -387,9 +337,11 @@ JVM_handle_linux_signal(int sig, } // Throw a stack overflow exception. Guard pages will be reenabled // while unwinding the stack. + thread->disable_stack_yellow_reserved_zone(); stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); } else { // Thread was in the vm or native code. Return and try to finish. + thread->disable_stack_yellow_reserved_zone(); return 1; } } else if (thread->in_stack_red_zone(addr)) { @@ -566,40 +518,10 @@ void os::print_context(outputStream *st, const void *context) { const ucontext_t *uc = (const ucontext_t*)context; st->print_cr("Registers:"); -#ifdef BUILTIN_SIM - st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]); - st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]); - st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]); - st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]); - st->cr(); - st->print( "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]); - st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]); - st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]); - st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]); - st->cr(); - st->print( "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]); - st->print(", R9 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R9]); - st->print(", R10=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R10]); - st->print(", R11=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R11]); - st->cr(); - st->print( "R12=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R12]); - st->print(", R13=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R13]); - st->print(", R14=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R14]); - st->print(", R15=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R15]); - st->cr(); - st->print( "RIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RIP]); - st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]); - st->print(", CSGSFS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_CSGSFS]); - st->print(", ERR=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_ERR]); - st->cr(); - st->print(" TRAPNO=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_TRAPNO]); - st->cr(); -#else for (int r = 0; r < 31; r++) { st->print("R%-2d=", r); print_location(st, uc->uc_mcontext.regs[r]); } -#endif st->cr(); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); @@ -629,27 +551,8 @@ void os::print_register_info(outputStream *st, const void *context) { // this is only for the "general purpose" registers -#ifdef BUILTIN_SIM - st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]); - st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]); - st->print("RCX="); print_location(st, uc->uc_mcontext.gregs[REG_RCX]); - st->print("RDX="); print_location(st, uc->uc_mcontext.gregs[REG_RDX]); - st->print("RSP="); print_location(st, uc->uc_mcontext.gregs[REG_RSP]); - st->print("RBP="); print_location(st, uc->uc_mcontext.gregs[REG_RBP]); - st->print("RSI="); print_location(st, uc->uc_mcontext.gregs[REG_RSI]); - st->print("RDI="); print_location(st, uc->uc_mcontext.gregs[REG_RDI]); - st->print("R8 ="); print_location(st, uc->uc_mcontext.gregs[REG_R8]); - st->print("R9 ="); print_location(st, uc->uc_mcontext.gregs[REG_R9]); - st->print("R10="); print_location(st, uc->uc_mcontext.gregs[REG_R10]); - st->print("R11="); print_location(st, uc->uc_mcontext.gregs[REG_R11]); - st->print("R12="); print_location(st, uc->uc_mcontext.gregs[REG_R12]); - st->print("R13="); print_location(st, uc->uc_mcontext.gregs[REG_R13]); - st->print("R14="); print_location(st, uc->uc_mcontext.gregs[REG_R14]); - st->print("R15="); print_location(st, uc->uc_mcontext.gregs[REG_R15]); -#else for (int r = 0; r < 31; r++) st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); -#endif st->cr(); } diff --git a/src/src/hotspot/os_cpu/linux_aarch64/prefetch_linux_aarch64.inline.hpp b/src/src/hotspot/os_cpu/linux_aarch64/prefetch_linux_aarch64.inline.hpp index 687eb50babe..7535441ae05 100644 --- a/src/src/hotspot/os_cpu/linux_aarch64/prefetch_linux_aarch64.inline.hpp +++ b/src/src/hotspot/os_cpu/linux_aarch64/prefetch_linux_aarch64.inline.hpp @@ -30,17 +30,13 @@ inline void Prefetch::read (void *loc, intx interval) { -#ifndef BUILTIN_SIM if (interval >= 0) asm("prfm PLDL1KEEP, [%0, %1]" : : "r"(loc), "r"(interval)); -#endif } inline void Prefetch::write(void *loc, intx interval) { -#ifndef BUILTIN_SIM if (interval >= 0) asm("prfm PSTL1KEEP, [%0, %1]" : : "r"(loc), "r"(interval)); -#endif } #endif // OS_CPU_LINUX_AARCH64_VM_PREFETCH_LINUX_AARCH64_INLINE_HPP diff --git a/src/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp b/src/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp index 9213c8772da..6e569c7decb 100644 --- a/src/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp +++ b/src/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 SAP SE. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019 SAP SE. 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 @@ -92,9 +92,8 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, return false; } -// Forte Analyzer AsyncGetCallTrace profiling support is not implemented on Linux/PPC. +// Forte Analyzer AsyncGetCallTrace profiling support. bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava) { - assert(this->is_Java_thread(), "must be JavaThread"); return pd_get_top_frame_for_profiling(fr_addr, ucontext, isInJava); } diff --git a/src/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp b/src/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp index c3379f5049e..d686a3e0c3c 100644 --- a/src/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp +++ b/src/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp @@ -89,10 +89,9 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, return false; } -// Forte Analyzer AsyncGetCallTrace profiling support is not implemented on Linux/S390x. +// Forte Analyzer AsyncGetCallTrace profiling support. bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava) { - Unimplemented(); - return false; + return pd_get_top_frame_for_profiling(fr_addr, ucontext, isInJava); } void JavaThread::cache_global_variables() { } diff --git a/src/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index 07d2ff2b971..8f283f14f4a 100644 --- a/src/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -465,6 +465,8 @@ frame os::get_sender_for_C_frame(frame* fr) { } #ifndef AMD64 +// Ignore "C4172: returning address of local variable or temporary" on 32bit +#pragma warning( disable : 4172 ) // Returns an estimate of the current stack pointer. Result must be guaranteed // to point into the calling threads stack, and be no lower than the current // stack pointer. @@ -473,6 +475,7 @@ address os::current_stack_pointer() { address sp = (address)&dummy; return sp; } +#pragma warning( default : 4172 ) #else // Returns the current stack pointer. Accurate value needed for // os::verify_stack_alignment(). diff --git a/src/src/hotspot/share/aot/aotCodeHeap.cpp b/src/src/hotspot/share/aot/aotCodeHeap.cpp index 4fe7917acee..dc270307bf9 100644 --- a/src/src/hotspot/share/aot/aotCodeHeap.cpp +++ b/src/src/hotspot/share/aot/aotCodeHeap.cpp @@ -714,7 +714,7 @@ void AOTCodeHeap::sweep_dependent_methods(InstanceKlass* ik) { void AOTCodeHeap::sweep_method(AOTCompiledMethod *aot) { int indexes[] = {aot->method_index()}; sweep_dependent_methods(indexes, 1); - vmassert(aot->method()->code() != aot && aot->method()->aot_code() == NULL, "method still active"); + vmassert(aot->method()->code() != aot TIERED_ONLY( && aot->method()->aot_code() == NULL), "method still active"); } diff --git a/src/src/hotspot/share/aot/aotCompiledMethod.cpp b/src/src/hotspot/share/aot/aotCompiledMethod.cpp index 725b09816d8..30c5e6adc03 100644 --- a/src/src/hotspot/share/aot/aotCompiledMethod.cpp +++ b/src/src/hotspot/share/aot/aotCompiledMethod.cpp @@ -206,6 +206,7 @@ bool AOTCompiledMethod::make_not_entrant_helper(int new_state) { return true; } +#ifdef TIERED bool AOTCompiledMethod::make_entrant() { assert(!method()->is_old(), "reviving evolved method!"); assert(*_state_adr != not_entrant, "%s", method()->has_aot_code() ? "has_aot_code() not cleared" : "caller didn't check has_aot_code()"); @@ -240,6 +241,7 @@ bool AOTCompiledMethod::make_entrant() { return true; } +#endif // TIERED // We don't have full dependencies for AOT methods, so flushing is // more conservative than for nmethods. diff --git a/src/src/hotspot/share/aot/aotCompiledMethod.hpp b/src/src/hotspot/share/aot/aotCompiledMethod.hpp index aff03e5db7c..6f9e0327514 100644 --- a/src/src/hotspot/share/aot/aotCompiledMethod.hpp +++ b/src/src/hotspot/share/aot/aotCompiledMethod.hpp @@ -194,7 +194,7 @@ class AOTCompiledMethod : public CompiledMethod, public CHeapObj { virtual address verified_entry_point() const { return _code + _meta->verified_entry_offset(); } virtual void log_identity(xmlStream* stream) const; virtual void log_state_change() const; - virtual bool make_entrant(); + virtual bool make_entrant() NOT_TIERED({ ShouldNotReachHere(); return false; }); virtual bool make_not_entrant() { return make_not_entrant_helper(not_entrant); } virtual bool make_not_used() { return make_not_entrant_helper(not_used); } virtual address entry_point() const { return _code + _meta->entry_offset(); } diff --git a/src/src/hotspot/share/c1/c1_Compiler.cpp b/src/src/hotspot/share/c1/c1_Compiler.cpp index 6ed4a29a48e..aff12954b38 100644 --- a/src/src/hotspot/share/c1/c1_Compiler.cpp +++ b/src/src/hotspot/share/c1/c1_Compiler.cpp @@ -79,7 +79,6 @@ void Compiler::initialize() { } int Compiler::code_buffer_size() { - assert(SegmentedCodeCache, "Should be only used with a segmented code cache"); return Compilation::desired_max_code_buffer_size() + Compilation::desired_max_constant_size(); } @@ -90,10 +89,7 @@ BufferBlob* Compiler::init_buffer_blob() { // setup CodeBuffer. Preallocate a BufferBlob of size // NMethodSizeLimit plus some extra space for constants. - int code_buffer_size = Compilation::desired_max_code_buffer_size() + - Compilation::desired_max_constant_size(); - - BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size); + BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size()); if (buffer_blob != NULL) { CompilerThread::current()->set_buffer_blob(buffer_blob); } diff --git a/src/src/hotspot/share/c1/c1_Decorators.hpp b/src/src/hotspot/share/c1/c1_Decorators.hpp index a1020690e01..14db0d8cb0a 100644 --- a/src/src/hotspot/share/c1/c1_Decorators.hpp +++ b/src/src/hotspot/share/c1/c1_Decorators.hpp @@ -38,5 +38,7 @@ const DecoratorSet C1_MASK_BOOLEAN = DECORATOR_LAST << 2; const DecoratorSet C1_WRITE_ACCESS = DECORATOR_LAST << 3; // The C1_READ_ACCESS decorator is used to mark reading accesses. const DecoratorSet C1_READ_ACCESS = DECORATOR_LAST << 4; +// Use the C1_UNSAFE_ACCESS decorator to mark unsafe accesses. +const DecoratorSet C1_UNSAFE_ACCESS = DECORATOR_LAST << 5; #endif // SHARE_VM_C1_C1_DECORATORS_HPP diff --git a/src/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/src/hotspot/share/c1/c1_GraphBuilder.cpp index 360e965aad3..471cb7cd952 100644 --- a/src/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -1451,9 +1451,6 @@ void GraphBuilder::call_register_finalizer() { } if (needs_check) { - // Not a trivial method because C2 can do better with inlined check. - compilation()->set_would_profile(true); - // Perform the registration of finalizable objects. ValueStack* state_before = copy_state_for_exception(); load_local(objectType, 0); @@ -3569,9 +3566,6 @@ void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee, bool ignore_retur } bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) { - // Not a trivial method because C2 may do intrinsics better. - compilation()->set_would_profile(true); - // For calling is_intrinsic_available we need to transition to // the '_thread_in_vm' state because is_intrinsic_available() // accesses critical VM-internal data. diff --git a/src/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/src/hotspot/share/c1/c1_LIRGenerator.cpp index 0e5fb3e95f3..f8d6f8750d8 100644 --- a/src/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -1640,7 +1640,7 @@ LIR_Opr LIRGenerator::access_atomic_cmpxchg_at(DecoratorSet decorators, BasicTyp // Atomic operations are SEQ_CST by default decorators |= C1_READ_ACCESS; decorators |= C1_WRITE_ACCESS; - decorators |= ((decorators & MO_DECORATOR_MASK) != 0) ? MO_SEQ_CST : 0; + decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0; LIRAccess access(this, decorators, base, offset, type); if (access.is_raw()) { return _barrier_set->BarrierSetC1::atomic_cmpxchg_at(access, cmp_value, new_value); @@ -1654,7 +1654,7 @@ LIR_Opr LIRGenerator::access_atomic_xchg_at(DecoratorSet decorators, BasicType t // Atomic operations are SEQ_CST by default decorators |= C1_READ_ACCESS; decorators |= C1_WRITE_ACCESS; - decorators |= ((decorators & MO_DECORATOR_MASK) != 0) ? MO_SEQ_CST : 0; + decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0; LIRAccess access(this, decorators, base, offset, type); if (access.is_raw()) { return _barrier_set->BarrierSetC1::atomic_xchg_at(access, value); @@ -1668,7 +1668,7 @@ LIR_Opr LIRGenerator::access_atomic_add_at(DecoratorSet decorators, BasicType ty // Atomic operations are SEQ_CST by default decorators |= C1_READ_ACCESS; decorators |= C1_WRITE_ACCESS; - decorators |= ((decorators & MO_DECORATOR_MASK) != 0) ? MO_SEQ_CST : 0; + decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0; LIRAccess access(this, decorators, base, offset, type); if (access.is_raw()) { return _barrier_set->BarrierSetC1::atomic_add_at(access, value); @@ -2138,7 +2138,7 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) { off.load_item(); src.load_item(); - DecoratorSet decorators = IN_HEAP; + DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS; if (x->is_volatile()) { decorators |= MO_SEQ_CST; @@ -2172,7 +2172,7 @@ void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) { set_no_result(x); - DecoratorSet decorators = IN_HEAP; + DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS; if (type == T_ARRAY || type == T_OBJECT) { decorators |= ON_UNKNOWN_OOP_REF; } @@ -2188,7 +2188,7 @@ void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { LIRItem off(x->offset(), this); LIRItem value(x->value(), this); - DecoratorSet decorators = IN_HEAP | MO_SEQ_CST; + DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS | MO_SEQ_CST; if (type == T_ARRAY || type == T_OBJECT) { decorators |= ON_UNKNOWN_OOP_REF; diff --git a/src/src/hotspot/share/c1/c1_Optimizer.cpp b/src/src/hotspot/share/c1/c1_Optimizer.cpp index c5c21430fbf..b5606a96967 100644 --- a/src/src/hotspot/share/c1/c1_Optimizer.cpp +++ b/src/src/hotspot/share/c1/c1_Optimizer.cpp @@ -174,6 +174,12 @@ void CE_Eliminator::block_do(BlockBegin* block) { for_each_phi_fun(t_block, phi, return; ); for_each_phi_fun(f_block, phi, return; ); + // Only replace safepoint gotos if state_before information is available (if is a safepoint) + bool is_safepoint = if_->is_safepoint(); + if (!is_safepoint && (t_goto->is_safepoint() || f_goto->is_safepoint())) { + return; + } + // 2) substitute conditional expression // with an IfOp followed by a Goto // cut if_ away and get node before @@ -202,7 +208,7 @@ void CE_Eliminator::block_do(BlockBegin* block) { // append Goto to successor ValueStack* state_before = if_->state_before(); - Goto* goto_ = new Goto(sux, state_before, if_->is_safepoint() || t_goto->is_safepoint() || f_goto->is_safepoint()); + Goto* goto_ = new Goto(sux, state_before, is_safepoint); // prepare state for Goto ValueStack* goto_state = if_state; diff --git a/src/src/hotspot/share/c1/c1_Runtime1.cpp b/src/src/hotspot/share/c1/c1_Runtime1.cpp index 1627849bcd2..25ff06290e4 100644 --- a/src/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/src/hotspot/share/c1/c1_Runtime1.cpp @@ -571,7 +571,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t tempst.print("compiled method <%s>\n" " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT, nm->method()->print_value_string(), p2i(pc), p2i(thread)); - Exceptions::log_exception(exception, tempst); + Exceptions::log_exception(exception, tempst.as_string()); } // for AbortVMOnException flag Exceptions::debug_check_abort(exception); diff --git a/src/src/hotspot/share/ci/bcEscapeAnalyzer.cpp b/src/src/hotspot/share/ci/bcEscapeAnalyzer.cpp index 5610cc47fe8..0e667b7081f 100644 --- a/src/src/hotspot/share/ci/bcEscapeAnalyzer.cpp +++ b/src/src/hotspot/share/ci/bcEscapeAnalyzer.cpp @@ -1198,40 +1198,36 @@ void BCEscapeAnalyzer::iterate_blocks(Arena *arena) { } } -bool BCEscapeAnalyzer::do_analysis() { +void BCEscapeAnalyzer::do_analysis() { Arena* arena = CURRENT_ENV->arena(); // identify basic blocks _methodBlocks = _method->get_method_blocks(); iterate_blocks(arena); - // TEMPORARY - return true; } vmIntrinsics::ID BCEscapeAnalyzer::known_intrinsic() { vmIntrinsics::ID iid = method()->intrinsic_id(); - if (iid == vmIntrinsics::_getClass || - iid == vmIntrinsics::_hashCode) + iid == vmIntrinsics::_hashCode) { return iid; - else + } else { return vmIntrinsics::_none; + } } -bool BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) { - ArgumentMap arg; - arg.clear(); +void BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) { switch (iid) { - case vmIntrinsics::_getClass: - _return_local = false; - break; - case vmIntrinsics::_hashCode: - // initialized state is correct - break; + case vmIntrinsics::_getClass: + _return_local = false; + _return_allocated = false; + break; + case vmIntrinsics::_hashCode: + // initialized state is correct + break; default: assert(false, "unexpected intrinsic"); } - return true; } void BCEscapeAnalyzer::initialize() { @@ -1302,7 +1298,7 @@ void BCEscapeAnalyzer::compute_escape_info() { vmIntrinsics::ID iid = known_intrinsic(); // check if method can be analyzed - if (iid == vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized() + if (iid == vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized() || _level > MaxBCEAEstimateLevel || method()->code_size() > MaxBCEAEstimateSize)) { if (BCEATraceLevel >= 1) { @@ -1335,8 +1331,6 @@ void BCEscapeAnalyzer::compute_escape_info() { tty->print_cr(" (%d bytes)", method()->code_size()); } - bool success; - initialize(); // Do not scan method if it has no object parameters and @@ -1352,9 +1346,9 @@ void BCEscapeAnalyzer::compute_escape_info() { } if (iid != vmIntrinsics::_none) - success = compute_escape_for_intrinsic(iid); + compute_escape_for_intrinsic(iid); else { - success = do_analysis(); + do_analysis(); } // don't store interprocedural escape information if it introduces diff --git a/src/src/hotspot/share/ci/bcEscapeAnalyzer.hpp b/src/src/hotspot/share/ci/bcEscapeAnalyzer.hpp index 74a0d3106b7..acca5a21032 100644 --- a/src/src/hotspot/share/ci/bcEscapeAnalyzer.hpp +++ b/src/src/hotspot/share/ci/bcEscapeAnalyzer.hpp @@ -101,8 +101,8 @@ class BCEscapeAnalyzer : public ResourceObj { void clear_escape_info(); void compute_escape_info(); vmIntrinsics::ID known_intrinsic(); - bool compute_escape_for_intrinsic(vmIntrinsics::ID iid); - bool do_analysis(); + void compute_escape_for_intrinsic(vmIntrinsics::ID iid); + void do_analysis(); void read_escape_info(); diff --git a/src/src/hotspot/share/ci/ciEnv.cpp b/src/src/hotspot/share/ci/ciEnv.cpp index fd8ba63dea1..92337b8094e 100644 --- a/src/src/hotspot/share/ci/ciEnv.cpp +++ b/src/src/hotspot/share/ci/ciEnv.cpp @@ -118,6 +118,9 @@ ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) _system_dictionary_modification_counter = system_dictionary_modification_counter; _num_inlined_bytecodes = 0; assert(task == NULL || thread->task() == task, "sanity"); + if (task != NULL) { + task->mark_started(os::elapsed_counter()); + } _task = task; _log = NULL; diff --git a/src/src/hotspot/share/ci/ciMethodData.cpp b/src/src/hotspot/share/ci/ciMethodData.cpp index 2a571d32951..99a7f6ecba7 100644 --- a/src/src/hotspot/share/ci/ciMethodData.cpp +++ b/src/src/hotspot/share/ci/ciMethodData.cpp @@ -97,9 +97,12 @@ void ciMethodData::load_extra_data() { // in the translate_from call below) as we translate the copy: // update the copy as we go. int tag = dp_src->tag(); - if (tag != DataLayout::arg_info_data_tag) { - memcpy(dp_dst, dp_src, ((intptr_t)MethodData::next_extra(dp_src)) - ((intptr_t)dp_src)); + size_t entry_size = DataLayout::header_size_in_bytes(); + if (tag != DataLayout::no_tag) { + ProfileData* src_data = dp_src->data_in(); + entry_size = src_data->size_in_bytes(); } + memcpy(dp_dst, dp_src, entry_size); switch(tag) { case DataLayout::speculative_trap_data_tag: { @@ -138,15 +141,17 @@ void ciMethodData::load_data() { // Snapshot the data -- actually, take an approximate snapshot of // the data. Any concurrently executing threads may be changing the // data as we copy it. - Copy::disjoint_words((HeapWord*) mdo, - (HeapWord*) &_orig, - sizeof(_orig) / HeapWordSize); + Copy::disjoint_words_atomic((HeapWord*) mdo, + (HeapWord*) &_orig, + sizeof(_orig) / HeapWordSize); Arena* arena = CURRENT_ENV->arena(); _data_size = mdo->data_size(); _extra_data_size = mdo->extra_data_size(); int total_size = _data_size + _extra_data_size; _data = (intptr_t *) arena->Amalloc(total_size); - Copy::disjoint_words((HeapWord*) mdo->data_base(), (HeapWord*) _data, total_size / HeapWordSize); + Copy::disjoint_words_atomic((HeapWord*) mdo->data_base(), + (HeapWord*) _data, + total_size / HeapWordSize); // Traverse the profile data, translating any oops into their // ci equivalents. diff --git a/src/src/hotspot/share/classfile/classFileParser.cpp b/src/src/hotspot/share/classfile/classFileParser.cpp index 8eb41673c3b..0d4862dd449 100644 --- a/src/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/src/hotspot/share/classfile/classFileParser.cpp @@ -60,6 +60,7 @@ #include "runtime/arguments.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/os.hpp" #include "runtime/perfData.hpp" #include "runtime/reflection.hpp" #include "runtime/safepointVerifiers.hpp" @@ -307,7 +308,7 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s const char* const str = java_lang_String::as_utf8_string(patch()); // (could use java_lang_String::as_symbol instead, but might as well batch them) utf8_buffer = (const u1*) str; - utf8_length = (int) strlen(str); + utf8_length = (u2) strlen(str); } unsigned int hash; @@ -5739,21 +5740,16 @@ void ClassFileParser::prepend_host_package_name(const InstanceKlass* host_klass, ClassLoader::package_from_name(host_klass->name()->as_C_string(), NULL); if (host_pkg_name != NULL) { - size_t host_pkg_len = strlen(host_pkg_name); + int host_pkg_len = (int)strlen(host_pkg_name); int class_name_len = _class_name->utf8_length(); - char* new_anon_name = - NEW_RESOURCE_ARRAY(char, host_pkg_len + 1 + class_name_len); - // Copy host package name and trailing /. - strncpy(new_anon_name, host_pkg_name, host_pkg_len); - new_anon_name[host_pkg_len] = '/'; - // Append anonymous class name. The anonymous class name can contain odd - // characters. So, do a strncpy instead of using sprintf("%s..."). - strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len); + int symbol_len = host_pkg_len + 1 + class_name_len; + char* new_anon_name = NEW_RESOURCE_ARRAY(char, symbol_len + 1); + int n = os::snprintf(new_anon_name, symbol_len + 1, "%s/%.*s", + host_pkg_name, class_name_len, _class_name->base()); + assert(n == symbol_len, "Unexpected number of characters in string"); // Create a symbol and update the anonymous class name. - _class_name = SymbolTable::new_symbol(new_anon_name, - (int)host_pkg_len + 1 + class_name_len, - CHECK); + _class_name = SymbolTable::new_symbol(new_anon_name, symbol_len, CHECK); } } diff --git a/src/src/hotspot/share/classfile/classLoaderData.cpp b/src/src/hotspot/share/classfile/classLoaderData.cpp index c8539997c7a..75f71452d73 100644 --- a/src/src/hotspot/share/classfile/classLoaderData.cpp +++ b/src/src/hotspot/share/classfile/classLoaderData.cpp @@ -346,6 +346,11 @@ void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { // Do not filter ArrayKlass oops here... if (k->is_array_klass() || (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded())) { +#ifdef ASSERT + oop m = k->java_mirror(); + assert(m != NULL, "NULL mirror"); + assert(m->is_a(SystemDictionary::Class_klass()), "invalid mirror"); +#endif klass_closure->do_klass(k); } } @@ -1415,6 +1420,13 @@ bool ClassLoaderDataGraph::do_unloading(bool clean_previous_versions) { if (data->modules_defined()) { data->modules()->purge_all_module_reads(); } + // Clean cached pd lists + // It's unlikely, but some loaded classes in a dictionary might + // point to a protection_domain that has been unloaded. + // The dictionary pd_set points at entries in the ProtectionDomainCacheTable. + if (data->dictionary() != NULL) { + data->dictionary()->clean_cached_protection_domains(); + } data = data->next(); } JFR_ONLY(post_class_unload_events();) diff --git a/src/src/hotspot/share/classfile/classLoaderExt.cpp b/src/src/hotspot/share/classfile/classLoaderExt.cpp index 31544c6437b..e649ddbf471 100644 --- a/src/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/src/hotspot/share/classfile/classLoaderExt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -206,13 +206,13 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry, file_end = end; } - int name_len = (int)strlen(file_start); + size_t name_len = strlen(file_start); if (name_len > 0) { ResourceMark rm(THREAD); - char* libname = NEW_RESOURCE_ARRAY(char, dir_len + name_len + 1); - *libname = 0; - strncat(libname, dir_name, dir_len); - strncat(libname, file_start, name_len); + size_t libname_len = dir_len + name_len; + char* libname = NEW_RESOURCE_ARRAY(char, libname_len + 1); + int n = os::snprintf(libname, libname_len + 1, "%.*s%s", dir_len, dir_name, file_start); + assert((size_t)n == libname_len, "Unexpected number of characters in string"); trace_class_path("library = ", libname); ClassLoader::update_class_path_entry_list(libname, true, false); } diff --git a/src/src/hotspot/share/classfile/dictionary.cpp b/src/src/hotspot/share/classfile/dictionary.cpp index aeebb4b709e..3ac1ca69ae5 100644 --- a/src/src/hotspot/share/classfile/dictionary.cpp +++ b/src/src/hotspot/share/classfile/dictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -211,41 +211,6 @@ void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_ } } -// During class loading we may have cached a protection domain that has -// since been unreferenced, so this entry should be cleared. -void Dictionary::clean_cached_protection_domains(DictionaryEntry* probe) { - assert_locked_or_safepoint(SystemDictionary_lock); - - ProtectionDomainEntry* current = probe->pd_set(); - ProtectionDomainEntry* prev = NULL; - while (current != NULL) { - if (current->object_no_keepalive() == NULL) { - LogTarget(Debug, protectiondomain) lt; - if (lt.is_enabled()) { - ResourceMark rm; - // Print out trace information - LogStream ls(lt); - ls.print_cr("PD in set is not alive:"); - ls.print("class loader: "); loader_data()->class_loader()->print_value_on(&ls); - ls.print(" loading: "); probe->instance_klass()->print_value_on(&ls); - ls.cr(); - } - if (probe->pd_set() == current) { - probe->set_pd_set(current->next()); - } else { - assert(prev != NULL, "should be set by alive entry"); - prev->set_next(current->next()); - } - ProtectionDomainEntry* to_delete = current; - current = current->next(); - delete to_delete; - } else { - prev = current; - current = current->next(); - } - } -} - void Dictionary::remove_classes_in_error_state() { assert(DumpSharedSpaces, "supported only when dumping"); DictionaryEntry* probe = NULL; @@ -431,10 +396,58 @@ bool Dictionary::is_valid_protection_domain(unsigned int hash, return entry->is_valid_protection_domain(protection_domain); } +// During class loading we may have cached a protection domain that has +// since been unreferenced, so this entry should be cleared. +void Dictionary::clean_cached_protection_domains() { + assert_locked_or_safepoint(SystemDictionary_lock); + + if (loader_data()->is_the_null_class_loader_data()) { + // Classes in the boot loader are not loaded with protection domains + return; + } + + for (int index = 0; index < table_size(); index++) { + for (DictionaryEntry* probe = bucket(index); + probe != NULL; + probe = probe->next()) { + Klass* e = probe->instance_klass(); + + ProtectionDomainEntry* current = probe->pd_set(); + ProtectionDomainEntry* prev = NULL; + while (current != NULL) { + if (current->object_no_keepalive() == NULL) { + LogTarget(Debug, protectiondomain) lt; + if (lt.is_enabled()) { + ResourceMark rm; + // Print out trace information + LogStream ls(lt); + ls.print_cr("PD in set is not alive:"); + ls.print("class loader: "); loader_data()->class_loader()->print_value_on(&ls); + ls.print(" loading: "); probe->instance_klass()->print_value_on(&ls); + ls.cr(); + } + if (probe->pd_set() == current) { + probe->set_pd_set(current->next()); + } else { + assert(prev != NULL, "should be set by alive entry"); + prev->set_next(current->next()); + } + ProtectionDomainEntry* to_delete = current; + current = current->next(); + delete to_delete; + } else { + prev = current; + current = current->next(); + } + } + } + } +} + #if INCLUDE_CDS static bool is_jfr_event_class(Klass *k) { while (k) { - if (k->name()->equals("jdk/jfr/Event")) { + if (k->name()->equals("jdk/internal/event/Event")) { return true; } k = k->super(); diff --git a/src/src/hotspot/share/classfile/dictionary.hpp b/src/src/hotspot/share/classfile/dictionary.hpp index 3906fb11efb..d26f1f11fb4 100644 --- a/src/src/hotspot/share/classfile/dictionary.hpp +++ b/src/src/hotspot/share/classfile/dictionary.hpp @@ -52,8 +52,6 @@ class Dictionary : public Hashtable { DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name); - void clean_cached_protection_domains(DictionaryEntry* probe); - protected: static size_t entry_size(); public: @@ -80,6 +78,8 @@ class Dictionary : public Hashtable { void unlink(); void remove_classes_in_error_state(); + void clean_cached_protection_domains(); + // Protection domains InstanceKlass* find(unsigned int hash, Symbol* name, Handle protection_domain); bool is_valid_protection_domain(unsigned int hash, diff --git a/src/src/hotspot/share/classfile/javaClasses.cpp b/src/src/hotspot/share/classfile/javaClasses.cpp index 2db344db2c8..e8579990fcd 100644 --- a/src/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/src/hotspot/share/classfile/javaClasses.cpp @@ -1051,8 +1051,9 @@ void java_lang_Class::archive_basic_type_mirrors(TRAPS) { ResetMirrorField reset(archived_mirror_h); InstanceKlass::cast(k)->do_nonstatic_fields(&reset); - log_trace(cds, mirror)("Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT, - type2name((BasicType)t), p2i(Universe::_mirrors[t]), p2i(archived_m)); + log_trace(cds, heap, mirror)( + "Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT, + type2name((BasicType)t), p2i(Universe::_mirrors[t]), p2i(archived_m)); Universe::_mirrors[t] = archived_m; } @@ -1133,8 +1134,9 @@ oop java_lang_Class::archive_mirror(Klass* k, TRAPS) { k->set_has_raw_archived_mirror(); ResourceMark rm; - log_trace(cds, mirror)("Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT, - k->external_name(), p2i(mirror), p2i(archived_mirror)); + log_trace(cds, heap, mirror)( + "Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT, + k->external_name(), p2i(mirror), p2i(archived_mirror)); return archived_mirror; } @@ -1186,8 +1188,9 @@ oop java_lang_Class::process_archived_mirror(Klass* k, oop mirror, // klass. Updated the field in the archived mirror to point to the relocated // klass in the archive. Klass *reloc_k = MetaspaceShared::get_relocated_klass(as_Klass(mirror)); - log_debug(cds, mirror)("Relocate mirror metadata field at _klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT, - p2i(as_Klass(mirror)), p2i(reloc_k)); + log_debug(cds, heap, mirror)( + "Relocate mirror metadata field at _klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT, + p2i(as_Klass(mirror)), p2i(reloc_k)); archived_mirror->metadata_field_put(_klass_offset, reloc_k); // The field at _array_klass_offset is pointing to the original one dimension @@ -1195,8 +1198,9 @@ oop java_lang_Class::process_archived_mirror(Klass* k, oop mirror, Klass *arr = array_klass_acquire(mirror); if (arr != NULL) { Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr); - log_debug(cds, mirror)("Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT, - p2i(arr), p2i(reloc_arr)); + log_debug(cds, heap, mirror)( + "Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT, + p2i(arr), p2i(reloc_arr)); archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr); } return archived_mirror; @@ -1247,7 +1251,8 @@ bool java_lang_Class::restore_archived_mirror(Klass *k, set_mirror_module_field(k, mirror, module, THREAD); ResourceMark rm; - log_trace(cds, mirror)("Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror())); + log_trace(cds, heap, mirror)( + "Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror())); return true; } @@ -4283,6 +4288,9 @@ int java_nio_Buffer::_limit_offset; int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset; int reflect_ConstantPool::_oop_offset; int reflect_UnsafeStaticFieldAccessorImpl::_base_offset; +int jdk_internal_module_ArchivedModuleGraph::_archivedSystemModules_offset; +int jdk_internal_module_ArchivedModuleGraph::_archivedModuleFinder_offset; +int jdk_internal_module_ArchivedModuleGraph::_archivedMainModule_offset; #define STACKTRACEELEMENT_FIELDS_DO(macro) \ macro(declaringClassObject_offset, k, "declaringClassObject", class_signature, false); \ @@ -4445,6 +4453,23 @@ static int member_offset(int hardcoded_offset) { return (hardcoded_offset * heapOopSize) + instanceOopDesc::base_offset_in_bytes(); } +#define MODULEBOOTSTRAP_FIELDS_DO(macro) \ + macro(_archivedSystemModules_offset, k, "archivedSystemModules", systemModules_signature, true); \ + macro(_archivedModuleFinder_offset, k, "archivedModuleFinder", moduleFinder_signature, true); \ + macro(_archivedMainModule_offset, k, "archivedMainModule", string_signature, true) + +void jdk_internal_module_ArchivedModuleGraph::compute_offsets() { + InstanceKlass* k = SystemDictionary::ArchivedModuleGraph_klass(); + assert(k != NULL, "must be loaded"); + MODULEBOOTSTRAP_FIELDS_DO(FIELD_COMPUTE_OFFSET); +} + +#if INCLUDE_CDS +void jdk_internal_module_ArchivedModuleGraph::serialize(SerializeClosure* f) { + MODULEBOOTSTRAP_FIELDS_DO(FIELD_SERIALIZE_OFFSET); +} +#endif + // Compute hard-coded offsets // Invoked before SystemDictionary::initialize, so pre-loaded classes // are not available to determine the offset_of_static_fields. @@ -4503,6 +4528,8 @@ void JavaClasses::compute_offsets() { java_lang_LiveStackFrameInfo::compute_offsets(); java_util_concurrent_locks_AbstractOwnableSynchronizer::compute_offsets(); + jdk_internal_module_ArchivedModuleGraph::compute_offsets(); + // generated interpreter code wants to know about the offsets we just computed: AbstractAssembler::update_delayed_values(); } diff --git a/src/src/hotspot/share/classfile/javaClasses.hpp b/src/src/hotspot/share/classfile/javaClasses.hpp index 0f77bd9bc39..aff4650d4a6 100644 --- a/src/src/hotspot/share/classfile/javaClasses.hpp +++ b/src/src/hotspot/share/classfile/javaClasses.hpp @@ -1493,6 +1493,19 @@ class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { static void serialize(SerializeClosure* f) NOT_CDS_RETURN; }; +class jdk_internal_module_ArchivedModuleGraph: AllStatic { + private: + static int _archivedSystemModules_offset; + static int _archivedModuleFinder_offset; + static int _archivedMainModule_offset; + public: + static int archivedSystemModules_offset() { return _archivedSystemModules_offset; } + static int archivedModuleFinder_offset() { return _archivedModuleFinder_offset; } + static int archivedMainModule_offset() { return _archivedMainModule_offset; } + static void compute_offsets(); + static void serialize(SerializeClosure* f) NOT_CDS_RETURN; +}; + // Use to declare fields that need to be injected into Java classes // for the JVM to use. The name_index and signature_index are // declared in vmSymbols. The may_be_java flag is used to declare diff --git a/src/src/hotspot/share/classfile/modules.cpp b/src/src/hotspot/share/classfile/modules.cpp index a7b41b1bf46..7d3a5e7676f 100644 --- a/src/src/hotspot/share/classfile/modules.cpp +++ b/src/src/hotspot/share/classfile/modules.cpp @@ -335,8 +335,8 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version, (package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) { const char* class_loader_name = loader_data->loader_name_and_id(); size_t pkg_len = strlen(package_name); - char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len); - strncpy(pkg_name, package_name, pkg_len); + char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len + 1); + strncpy(pkg_name, package_name, pkg_len + 1); StringUtils::replace_no_expand(pkg_name, "/", "."); const char* msg_text1 = "Class loader (instance of): "; const char* msg_text2 = " tried to define prohibited package name: "; diff --git a/src/src/hotspot/share/classfile/stringTable.cpp b/src/src/hotspot/share/classfile/stringTable.cpp index a152e0a02ed..82d69121439 100644 --- a/src/src/hotspot/share/classfile/stringTable.cpp +++ b/src/src/hotspot/share/classfile/stringTable.cpp @@ -789,6 +789,10 @@ oop StringTable::lookup_shared(jchar* name, int len, unsigned int hash) { oop StringTable::create_archived_string(oop s, Thread* THREAD) { assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); + if (MetaspaceShared::is_archive_object(s)) { + return s; + } + oop new_s = NULL; typeArrayOop v = java_lang_String::value_no_keepalive(s); typeArrayOop new_v = diff --git a/src/src/hotspot/share/classfile/systemDictionary.hpp b/src/src/hotspot/share/classfile/systemDictionary.hpp index d38dd0fd003..08bb089b878 100644 --- a/src/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/src/hotspot/share/classfile/systemDictionary.hpp @@ -187,6 +187,7 @@ class OopStorage; do_klass(jdk_internal_loader_ClassLoaders_AppClassLoader_klass, jdk_internal_loader_ClassLoaders_AppClassLoader, Pre ) \ do_klass(jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass, jdk_internal_loader_ClassLoaders_PlatformClassLoader, Pre ) \ do_klass(CodeSource_klass, java_security_CodeSource, Pre ) \ + do_klass(ArchivedModuleGraph_klass, jdk_internal_module_ArchivedModuleGraph, Pre ) \ \ do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \ \ diff --git a/src/src/hotspot/share/classfile/verifier.cpp b/src/src/hotspot/share/classfile/verifier.cpp index d2c18c88b07..ea4f74fc783 100644 --- a/src/src/hotspot/share/classfile/verifier.cpp +++ b/src/src/hotspot/share/classfile/verifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -2984,18 +2984,16 @@ void ClassVerifier::verify_anewarray( } // add one dimension to component length++; - arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length); - arr_sig_str[0] = '['; - strncpy(&arr_sig_str[1], component_name, length - 1); + arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1); + int n = os::snprintf(arr_sig_str, length + 1, "[%s", component_name); + assert(n == length, "Unexpected number of characters in string"); } else { // it's an object or interface const char* component_name = component_type.name()->as_utf8(); // add one dimension to component with 'L' prepended and ';' postpended. length = (int)strlen(component_name) + 3; - arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length); - arr_sig_str[0] = '['; - arr_sig_str[1] = 'L'; - strncpy(&arr_sig_str[2], component_name, length - 2); - arr_sig_str[length - 1] = ';'; + arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length + 1); + int n = os::snprintf(arr_sig_str, length + 1, "[L%s;", component_name); + assert(n == length, "Unexpected number of characters in string"); } Symbol* arr_sig = create_temporary_symbol( arr_sig_str, length, CHECK_VERIFY(this)); diff --git a/src/src/hotspot/share/classfile/vmSymbols.hpp b/src/src/hotspot/share/classfile/vmSymbols.hpp index 1351b864a0f..66249067c5a 100644 --- a/src/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/src/hotspot/share/classfile/vmSymbols.hpp @@ -125,6 +125,7 @@ template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ template(jdk_internal_vm_PostVMInitHook, "jdk/internal/vm/PostVMInitHook") \ template(sun_net_www_ParseUtil, "sun/net/www/ParseUtil") \ + template(jdk_internal_module_ArchivedModuleGraph, "jdk/internal/module/ArchivedModuleGraph") \ \ template(jdk_internal_loader_ClassLoaders_AppClassLoader, "jdk/internal/loader/ClassLoaders$AppClassLoader") \ template(jdk_internal_loader_ClassLoaders_PlatformClassLoader, "jdk/internal/loader/ClassLoaders$PlatformClassLoader") \ @@ -654,6 +655,8 @@ template(url_void_signature, "(Ljava/net/URL;)V") \ template(toFileURL_name, "toFileURL") \ template(toFileURL_signature, "(Ljava/lang/String;)Ljava/net/URL;") \ + template(moduleFinder_signature, "Ljava/lang/module/ModuleFinder;") \ + template(systemModules_signature, "Ljdk/internal/module/SystemModules;") \ \ /*end*/ @@ -1066,6 +1069,7 @@ \ /* support for Unsafe */ \ do_class(jdk_internal_misc_Unsafe, "jdk/internal/misc/Unsafe") \ + do_class(sun_misc_Unsafe, "sun/misc/Unsafe") \ \ do_intrinsic(_allocateInstance, jdk_internal_misc_Unsafe, allocateInstance_name, allocateInstance_signature, F_RN) \ do_name( allocateInstance_name, "allocateInstance") \ diff --git a/src/src/hotspot/share/code/codeCache.cpp b/src/src/hotspot/share/code/codeCache.cpp index d4c2b1e1ac9..7b0ce413860 100644 --- a/src/src/hotspot/share/code/codeCache.cpp +++ b/src/src/hotspot/share/code/codeCache.cpp @@ -274,10 +274,10 @@ void CodeCache::initialize_heaps() { } // Make sure we have enough space for VM internal code uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); - if (non_nmethod_size < (min_code_cache_size + code_buffers_size)) { + if (non_nmethod_size < min_code_cache_size) { vm_exit_during_initialization(err_msg( "Not enough space in non-nmethod code heap to run VM: " SIZE_FORMAT "K < " SIZE_FORMAT "K", - non_nmethod_size/K, (min_code_cache_size + code_buffers_size)/K)); + non_nmethod_size/K, min_code_cache_size/K)); } // Verify sizes and update flag values @@ -1391,7 +1391,7 @@ void CodeCache::report_codemem_full(int code_blob_type, bool print) { if (heap->full_count() == 0) { LogTarget(Debug, codecache) lt; if (lt.is_enabled()) { - CompileBroker::print_heapinfo(tty, "all", "4096"); // details, may be a lot! + CompileBroker::print_heapinfo(tty, "all", 4096); // details, may be a lot! } } } @@ -1678,7 +1678,7 @@ void CodeCache::log_state(outputStream* st) { //---< BEGIN >--- CodeHeap State Analytics. -void CodeCache::aggregate(outputStream *out, const char* granularity) { +void CodeCache::aggregate(outputStream *out, size_t granularity) { FOR_ALL_ALLOCABLE_HEAPS(heap) { CodeHeapState::aggregate(out, (*heap), granularity); } diff --git a/src/src/hotspot/share/code/codeCache.hpp b/src/src/hotspot/share/code/codeCache.hpp index fcf6cb404c0..b6614a4b714 100644 --- a/src/src/hotspot/share/code/codeCache.hpp +++ b/src/src/hotspot/share/code/codeCache.hpp @@ -302,7 +302,7 @@ class CodeCache : AllStatic { // CodeHeap State Analytics. // interface methods for CodeHeap printing, called by CompileBroker - static void aggregate(outputStream *out, const char* granularity); + static void aggregate(outputStream *out, size_t granularity); static void discard(outputStream *out); static void print_usedSpace(outputStream *out); static void print_freeSpace(outputStream *out); diff --git a/src/src/hotspot/share/code/codeHeapState.cpp b/src/src/hotspot/share/code/codeHeapState.cpp index 93813ea8c5a..b60660c4e50 100644 --- a/src/src/hotspot/share/code/codeHeapState.cpp +++ b/src/src/hotspot/share/code/codeHeapState.cpp @@ -91,7 +91,7 @@ /* _anyst name of the stream as used in the code */ \ /* _outst stream where final output will go to */ \ ResourceMark rm; \ - bufferedStream _sstobj = bufferedStream(4*K); \ + bufferedStream _sstobj(4*K); \ bufferedStream* _sstbuf = &_sstobj; \ outputStream* _outbuf = _outst; \ bufferedStream* _anyst = &_sstobj; /* any stream. Use this to just print - no buffer flush. */ @@ -440,7 +440,7 @@ void CodeHeapState::discard(outputStream* out, CodeHeap* heap) { } } -void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, const char* granularity_request) { +void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granularity) { unsigned int nBlocks_free = 0; unsigned int nBlocks_used = 0; unsigned int nBlocks_zomb = 0; @@ -516,7 +516,8 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, const char* gra // Finally, we adjust the granularity such that each granule covers at most 64k-1 segments. // This is necessary to prevent an unsigned short overflow while accumulating space information. // - size_t granularity = strtol(granularity_request, NULL, 0); + assert(granularity > 0, "granularity should be positive."); + if (granularity > size) { granularity = size; } diff --git a/src/src/hotspot/share/code/codeHeapState.hpp b/src/src/hotspot/share/code/codeHeapState.hpp index 46b860ba526..9b7b7790afb 100644 --- a/src/src/hotspot/share/code/codeHeapState.hpp +++ b/src/src/hotspot/share/code/codeHeapState.hpp @@ -98,7 +98,7 @@ class CodeHeapState : public CHeapObj { public: static void discard(outputStream* out, CodeHeap* heap); - static void aggregate(outputStream* out, CodeHeap* heap, const char* granularity); + static void aggregate(outputStream* out, CodeHeap* heap, size_t granularity); static void print_usedSpace(outputStream* out, CodeHeap* heap); static void print_freeSpace(outputStream* out, CodeHeap* heap); static void print_count(outputStream* out, CodeHeap* heap); diff --git a/src/src/hotspot/share/compiler/compileBroker.cpp b/src/src/hotspot/share/compiler/compileBroker.cpp index bc7c555e4e7..48d2357cb2c 100644 --- a/src/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/src/hotspot/share/compiler/compileBroker.cpp @@ -197,7 +197,7 @@ class CompilationLog : public StringEventLog { void log_compile(JavaThread* thread, CompileTask* task) { StringLogMessage lm; - stringStream sstr = lm.stream(); + stringStream sstr(lm.buffer(), lm.size()); // msg.time_stamp().update_to(tty->time_stamp().ticks()); task->print(&sstr, NULL, true, false); log(thread, "%s", (const char*)lm); @@ -257,14 +257,14 @@ CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) { } #endif CompileLog* log = thread->log(); - if (log != NULL) task->log_task_start(log); + if (log != NULL && !task->is_unloaded()) task->log_task_start(log); } CompileTaskWrapper::~CompileTaskWrapper() { CompilerThread* thread = CompilerThread::current(); CompileTask* task = thread->task(); CompileLog* log = thread->log(); - if (log != NULL) task->log_task_done(log); + if (log != NULL && !task->is_unloaded()) task->log_task_done(log); thread->set_task(NULL); task->set_code_handle(NULL); thread->set_env(NULL); @@ -443,6 +443,9 @@ CompileTask* CompileQueue::get() { { NoSafepointVerifier nsv; task = CompilationPolicy::policy()->select_task(this); + if (task != NULL) { + task = task->select_for_compilation(); + } } if (task != NULL) { @@ -452,9 +455,8 @@ CompileTask* CompileQueue::get() { save_hot_method = methodHandle(task->hot_method()); remove(task); - purge_stale_tasks(); // may temporarily release MCQ lock } - + purge_stale_tasks(); // may temporarily release MCQ lock return task; } @@ -482,7 +484,7 @@ void CompileQueue::purge_stale_tasks() { } void CompileQueue::remove(CompileTask* task) { - assert(MethodCompileQueue_lock->owned_by_self(), "must own lock"); + assert(MethodCompileQueue_lock->owned_by_self(), "must own lock"); if (task->prev() != NULL) { task->prev()->set_next(task->next()); } else { @@ -533,7 +535,7 @@ void CompileBroker::print_compile_queues(outputStream* st) { char buf[2000]; int buflen = sizeof(buf); - Threads::print_threads_compiling(st, buf, buflen); + Threads::print_threads_compiling(st, buf, buflen, /* short_form = */ true); st->cr(); if (_c1_compile_queue != NULL) { @@ -2674,7 +2676,7 @@ void CompileBroker::print_info(outputStream *out) { // That's a tradeoff which keeps together important blocks of output. // At the same time, continuous tty_lock hold time is kept in check, // preventing concurrently printing threads from stalling a long time. -void CompileBroker::print_heapinfo(outputStream* out, const char* function, const char* granularity) { +void CompileBroker::print_heapinfo(outputStream* out, const char* function, size_t granularity) { TimeStamp ts_total; TimeStamp ts; diff --git a/src/src/hotspot/share/compiler/compileBroker.hpp b/src/src/hotspot/share/compiler/compileBroker.hpp index 2deca8aa502..4aab3c71c3b 100644 --- a/src/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/src/hotspot/share/compiler/compileBroker.hpp @@ -234,7 +234,6 @@ class CompileBroker: AllStatic { AbstractCompiler* comp, bool compiler_thread, TRAPS); static void init_compiler_sweeper_threads(); static void possibly_add_compiler_threads(); - static bool compilation_is_complete (const methodHandle& method, int osr_bci, int comp_level); static bool compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level, bool excluded); static void preload_classes (const methodHandle& method, TRAPS); @@ -289,6 +288,7 @@ class CompileBroker: AllStatic { return NULL; } + static bool compilation_is_complete(const methodHandle& method, int osr_bci, int comp_level); static bool compilation_is_in_queue(const methodHandle& method); static void print_compile_queues(outputStream* st); static void print_directives(outputStream* st); @@ -424,7 +424,7 @@ class CompileBroker: AllStatic { // CodeHeap State Analytics. static void print_info(outputStream *out); - static void print_heapinfo(outputStream *out, const char* function, const char* granularity ); + static void print_heapinfo(outputStream *out, const char* function, size_t granularity); }; #endif // SHARE_VM_COMPILER_COMPILEBROKER_HPP diff --git a/src/src/hotspot/share/compiler/compileTask.cpp b/src/src/hotspot/share/compiler/compileTask.cpp index 370deff9e2a..ce8e3b8cacb 100644 --- a/src/src/hotspot/share/compiler/compileTask.cpp +++ b/src/src/hotspot/share/compiler/compileTask.cpp @@ -63,21 +63,25 @@ CompileTask* CompileTask::allocate() { /** * Add a task to the free list. */ - void CompileTask::free(CompileTask* task) { - MutexLocker locker(CompileTaskAlloc_lock); - if (!task->is_free()) { - task->set_code(NULL); - assert(!task->lock()->is_locked(), "Should not be locked when freed"); - JNIHandles::destroy_global(task->_method_holder); - JNIHandles::destroy_global(task->_hot_method_holder); - - task->set_is_free(true); - task->set_next(_task_free_list); - _task_free_list = task; - } -} + MutexLocker locker(CompileTaskAlloc_lock); + if (!task->is_free()) { + task->set_code(NULL); + assert(!task->lock()->is_locked(), "Should not be locked when freed"); + if ((task->_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_method_holder)) || + (task->_hot_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_hot_method_holder))) { + JNIHandles::destroy_weak_global(task->_method_holder); + JNIHandles::destroy_weak_global(task->_hot_method_holder); + } else { + JNIHandles::destroy_global(task->_method_holder); + JNIHandles::destroy_global(task->_hot_method_holder); + } + task->set_is_free(true); + task->set_next(_task_free_list); + _task_free_list = task; + } +} void CompileTask::initialize(int compile_id, const methodHandle& method, @@ -92,7 +96,7 @@ void CompileTask::initialize(int compile_id, Thread* thread = Thread::current(); _compile_id = compile_id; _method = method(); - _method_holder = JNIHandles::make_global(Handle(thread, method->method_holder()->klass_holder())); + _method_holder = JNIHandles::make_weak_global(Handle(thread, method->method_holder()->klass_holder())); _osr_bci = osr_bci; _is_blocking = is_blocking; JVMCI_ONLY(_has_waiter = CompileBroker::compiler(comp_level)->is_jvmci();) @@ -107,19 +111,19 @@ void CompileTask::initialize(int compile_id, _hot_method = NULL; _hot_method_holder = NULL; _hot_count = hot_count; - _time_queued = 0; // tidy + _time_queued = os::elapsed_counter(); + _time_started = 0; _compile_reason = compile_reason; _failure_reason = NULL; if (LogCompilation) { - _time_queued = os::elapsed_counter(); if (hot_method.not_null()) { if (hot_method == method) { _hot_method = _method; } else { _hot_method = hot_method(); // only add loader or mirror if different from _method_holder - _hot_method_holder = JNIHandles::make_global(Handle(thread, hot_method->method_holder()->klass_holder())); + _hot_method_holder = JNIHandles::make_weak_global(Handle(thread, hot_method->method_holder()->klass_holder())); } } } @@ -134,6 +138,24 @@ AbstractCompiler* CompileTask::compiler() { return CompileBroker::compiler(_comp_level); } +// Replace weak handles by strong handles to avoid unloading during compilation. +CompileTask* CompileTask::select_for_compilation() { + if (is_unloaded()) { + // Guard against concurrent class unloading + return NULL; + } + Thread* thread = Thread::current(); + assert(_method->method_holder()->is_loader_alive(), "should be alive"); + Handle method_holder(thread, _method->method_holder()->klass_holder()); + JNIHandles::destroy_weak_global(_method_holder); + JNIHandles::destroy_weak_global(_hot_method_holder); + _method_holder = JNIHandles::make_global(method_holder); + if (_hot_method != NULL) { + _hot_method_holder = JNIHandles::make_global(Handle(thread, _hot_method->method_holder()->klass_holder())); + } + return this; +} + // ------------------------------------------------------------------ // CompileTask::code/set_code // @@ -154,6 +176,9 @@ void CompileTask::set_code(nmethod* nm) { } void CompileTask::mark_on_stack() { + if (is_unloaded()) { + return; + } // Mark these methods as something redefine classes cannot remove. _method->set_on_stack(true); if (_hot_method != NULL) { @@ -161,8 +186,15 @@ void CompileTask::mark_on_stack() { } } +bool CompileTask::is_unloaded() const { + return _method_holder != NULL && JNIHandles::is_weak_global_handle(_method_holder) && JNIHandles::is_global_weak_cleared(_method_holder); +} + // RedefineClasses support void CompileTask::metadata_do(void f(Metadata*)) { + if (is_unloaded()) { + return; + } f(method()); if (hot_method() != NULL && hot_method() != method()) { f(hot_method()); @@ -199,10 +231,20 @@ void CompileTask::print_tty() { // ------------------------------------------------------------------ // CompileTask::print_impl void CompileTask::print_impl(outputStream* st, Method* method, int compile_id, int comp_level, - bool is_osr_method, int osr_bci, bool is_blocking, - const char* msg, bool short_form, bool cr) { + bool is_osr_method, int osr_bci, bool is_blocking, + const char* msg, bool short_form, bool cr, + jlong time_queued, jlong time_started) { if (!short_form) { - st->print("%7d ", (int) st->time_stamp().milliseconds()); // print timestamp + // Print current time + st->print("%7d ", (int)st->time_stamp().milliseconds()); + if (Verbose && time_queued != 0) { + // Print time in queue and time being processed by compiler thread + jlong now = os::elapsed_counter(); + st->print("%d ", (int)TimeHelper::counter_to_millis(now-time_queued)); + if (time_started != 0) { + st->print("%d ", (int)TimeHelper::counter_to_millis(now-time_started)); + } + } } // print compiler name if requested if (CIPrintCompilerName) { @@ -277,7 +319,7 @@ void CompileTask::print_inline_indent(int inline_level, outputStream* st) { // CompileTask::print_compilation void CompileTask::print(outputStream* st, const char* msg, bool short_form, bool cr) { bool is_osr_method = osr_bci() != InvocationEntryBci; - print_impl(st, method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), msg, short_form, cr); + print_impl(st, is_unloaded() ? NULL : method(), compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), msg, short_form, cr, _time_queued, _time_started); } // ------------------------------------------------------------------ diff --git a/src/src/hotspot/share/compiler/compileTask.hpp b/src/src/hotspot/share/compiler/compileTask.hpp index 3522ee4f10e..5a87124b238 100644 --- a/src/src/hotspot/share/compiler/compileTask.hpp +++ b/src/src/hotspot/share/compiler/compileTask.hpp @@ -98,7 +98,8 @@ class CompileTask : public CHeapObj { CompileTask* _next, *_prev; bool _is_free; // Fields used for logging why the compilation was initiated: - jlong _time_queued; // in units of os::elapsed_counter() + jlong _time_queued; // time when task was enqueued + jlong _time_started; // time when compilation started Method* _hot_method; // which method actually triggered this task jobject _hot_method_holder; int _hot_count; // information about its invocation counter @@ -154,11 +155,13 @@ class CompileTask : public CHeapObj { void mark_complete() { _is_complete = true; } void mark_success() { _is_success = true; } + void mark_started(jlong time) { _time_started = time; } int comp_level() { return _comp_level;} void set_comp_level(int comp_level) { _comp_level = comp_level;} AbstractCompiler* compiler(); + CompileTask* select_for_compilation(); int num_inlined_bytecodes() const { return _num_inlined_bytecodes; } void set_num_inlined_bytecodes(int n) { _num_inlined_bytecodes = n; } @@ -169,6 +172,7 @@ class CompileTask : public CHeapObj { void set_prev(CompileTask* prev) { _prev = prev; } bool is_free() const { return _is_free; } void set_is_free(bool val) { _is_free = val; } + bool is_unloaded() const; // RedefineClasses support void metadata_do(void f(Metadata*)); @@ -177,7 +181,8 @@ class CompileTask : public CHeapObj { private: static void print_impl(outputStream* st, Method* method, int compile_id, int comp_level, bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false, - const char* msg = NULL, bool short_form = false, bool cr = true); + const char* msg = NULL, bool short_form = false, bool cr = true, + jlong time_queued = 0, jlong time_started = 0); public: void print(outputStream* st = tty, const char* msg = NULL, bool short_form = false, bool cr = true); diff --git a/src/src/hotspot/share/compiler/compilerDirectives.cpp b/src/src/hotspot/share/compiler/compilerDirectives.cpp index bbd215b5444..0a976e2aa76 100644 --- a/src/src/hotspot/share/compiler/compilerDirectives.cpp +++ b/src/src/hotspot/share/compiler/compilerDirectives.cpp @@ -442,7 +442,7 @@ void DirectivesStack::init() { char str[] = "*.*"; const char* error_msg = NULL; _default_directives->add_match(str, error_msg); -#ifdef COMPILER1 +#if defined(COMPILER1) || INCLUDE_JVMCI _default_directives->_c1_store->EnableOption = true; #endif #ifdef COMPILER2 diff --git a/src/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp b/src/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp index 717a14157e5..5caa32d7e8c 100644 --- a/src/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp +++ b/src/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp @@ -72,6 +72,7 @@ Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) cons bool mismatched = (decorators & C2_MISMATCHED) != 0; bool unaligned = (decorators & C2_UNALIGNED) != 0; + bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0; bool requires_atomic_access = (decorators & MO_UNORDERED) == 0; bool in_native = (decorators & IN_NATIVE) != 0; @@ -85,7 +86,7 @@ Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) cons MemNode::MemOrd mo = access.mem_node_mo(); Node* store = kit->store_to_memory(kit->control(), access.addr().node(), val.node(), access.type(), - access.addr().type(), mo, requires_atomic_access, unaligned, mismatched); + access.addr().type(), mo, requires_atomic_access, unaligned, mismatched, unsafe); access.set_raw_access(store); return store; } @@ -102,6 +103,7 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con bool unaligned = (decorators & C2_UNALIGNED) != 0; bool control_dependent = (decorators & C2_CONTROL_DEPENDENT_LOAD) != 0; bool pinned = (decorators & C2_PINNED_LOAD) != 0; + bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0; bool in_native = (decorators & IN_NATIVE) != 0; assert(!in_native, "not supported yet"); @@ -111,7 +113,7 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con Node* control = control_dependent ? kit->control() : NULL; Node* load = kit->make_load(control, adr, val_type, access.type(), adr_type, mo, - dep, requires_atomic_access, unaligned, mismatched); + dep, requires_atomic_access, unaligned, mismatched, unsafe); access.set_raw_access(load); return load; @@ -119,10 +121,11 @@ Node* BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) con class C2AccessFence: public StackObj { C2Access& _access; + Node* _leading_membar; public: C2AccessFence(C2Access& access) : - _access(access) { + _access(access), _leading_membar(NULL) { GraphKit* kit = access.kit(); DecoratorSet decorators = access.decorators(); @@ -139,12 +142,12 @@ class C2AccessFence: public StackObj { // into actual barriers on most machines, but we still need rest of // compiler to respect ordering. if (is_release) { - kit->insert_mem_bar(Op_MemBarRelease); + _leading_membar = kit->insert_mem_bar(Op_MemBarRelease); } else if (is_volatile) { if (support_IRIW_for_not_multiple_copy_atomic_cpu) { - kit->insert_mem_bar(Op_MemBarVolatile); + _leading_membar = kit->insert_mem_bar(Op_MemBarVolatile); } else { - kit->insert_mem_bar(Op_MemBarRelease); + _leading_membar = kit->insert_mem_bar(Op_MemBarRelease); } } } else if (is_write) { @@ -152,7 +155,7 @@ class C2AccessFence: public StackObj { // floating down past the volatile write. Also prevents commoning // another volatile read. if (is_volatile || is_release) { - kit->insert_mem_bar(Op_MemBarRelease); + _leading_membar = kit->insert_mem_bar(Op_MemBarRelease); } } else { // Memory barrier to prevent normal and 'unsafe' accesses from @@ -161,7 +164,7 @@ class C2AccessFence: public StackObj { // so there's no problems making a strong assert about mixing users // of safe & unsafe memory. if (is_volatile && support_IRIW_for_not_multiple_copy_atomic_cpu) { - kit->insert_mem_bar(Op_MemBarVolatile); + _leading_membar = kit->insert_mem_bar(Op_MemBarVolatile); } } @@ -196,20 +199,30 @@ class C2AccessFence: public StackObj { if (is_atomic) { if (is_acquire || is_volatile) { - kit->insert_mem_bar(Op_MemBarAcquire); + Node* n = _access.raw_access(); + Node* mb = kit->insert_mem_bar(Op_MemBarAcquire, n); + if (_leading_membar != NULL) { + MemBarNode::set_load_store_pair(_leading_membar->as_MemBar(), mb->as_MemBar()); + } } } else if (is_write) { // If not multiple copy atomic, we do the MemBarVolatile before the load. if (is_volatile && !support_IRIW_for_not_multiple_copy_atomic_cpu) { - kit->insert_mem_bar(Op_MemBarVolatile); // Use fat membar + Node* n = _access.raw_access(); + Node* mb = kit->insert_mem_bar(Op_MemBarVolatile, n); // Use fat membar + if (_leading_membar != NULL) { + MemBarNode::set_store_pair(_leading_membar->as_MemBar(), mb->as_MemBar()); + } } } else { if (is_volatile || is_acquire) { - kit->insert_mem_bar(Op_MemBarAcquire, _access.raw_access()); + Node* n = _access.raw_access(); + assert(_leading_membar == NULL || support_IRIW_for_not_multiple_copy_atomic_cpu, "no leading membar expected"); + Node* mb = kit->insert_mem_bar(Op_MemBarAcquire, n); + mb->as_MemBar()->set_trailing_load(); } } } - }; Node* BarrierSetC2::store_at(C2Access& access, C2AccessValue& val) const { diff --git a/src/src/hotspot/share/gc/shared/taskqueue.hpp b/src/src/hotspot/share/gc/shared/taskqueue.hpp index b7edc47ea14..877b843ab12 100644 --- a/src/src/hotspot/share/gc/shared/taskqueue.hpp +++ b/src/src/hotspot/share/gc/shared/taskqueue.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_SHARED_TASKQUEUE_HPP #include "memory/allocation.hpp" +#include "memory/padded.hpp" #include "oops/oopsHierarchy.hpp" #include "utilities/ostream.hpp" #include "utilities/stack.hpp" @@ -428,7 +429,10 @@ class ParallelTaskTerminator: public StackObj { private: uint _n_threads; TaskQueueSetSuper* _queue_set; + + DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0); volatile uint _offered_termination; + DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile uint)); #ifdef TRACESPINNING static uint _total_yields; diff --git a/src/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp b/src/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp index 8456eeb1d89..858a5408f9c 100644 --- a/src/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp +++ b/src/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp @@ -226,7 +226,9 @@ void ThreadLocalAllocBuffer::startup_initialization() { // Assuming each thread's active tlab is, on average, // 1/2 full at a GC _target_refills = 100 / (2 * TLABWasteTargetPercent); - _target_refills = MAX2(_target_refills, (unsigned)1U); + // We need to set initial target refills to 2 to avoid a GC which causes VM + // abort during VM initialization. + _target_refills = MAX2(_target_refills, 2U); _global_stats = new GlobalTLABStats(); diff --git a/src/src/hotspot/share/gc/z/zBarrierSet.cpp b/src/src/hotspot/share/gc/z/zBarrierSet.cpp index 99c4e6adc9d..bfe8deaf7fc 100644 --- a/src/src/hotspot/share/gc/z/zBarrierSet.cpp +++ b/src/src/hotspot/share/gc/z/zBarrierSet.cpp @@ -40,8 +40,8 @@ class ZBarrierSetC2; ZBarrierSet::ZBarrierSet() : BarrierSet(make_barrier_set_assembler(), - make_barrier_set_c1(), - make_barrier_set_c2(), + COMPILER1_PRESENT( make_barrier_set_c1() ) NOT_COMPILER1(NULL), + COMPILER2_PRESENT( make_barrier_set_c2() ) NOT_COMPILER2(NULL), BarrierSet::FakeRtti(BarrierSet::ZBarrierSet)) {} ZBarrierSetAssembler* ZBarrierSet::assembler() { diff --git a/src/src/hotspot/share/gc/z/zBarrierSet.inline.hpp b/src/src/hotspot/share/gc/z/zBarrierSet.inline.hpp index 6a17b91ae1e..c8701a1d648 100644 --- a/src/src/hotspot/share/gc/z/zBarrierSet.inline.hpp +++ b/src/src/hotspot/share/gc/z/zBarrierSet.inline.hpp @@ -210,16 +210,10 @@ inline void ZBarrierSet::AccessBarrier::clone_in_heap(o template template inline oop ZBarrierSet::AccessBarrier::oop_load_not_in_heap(T* addr) { - const oop o = Raw::oop_load_not_in_heap(addr); - - if (HasDecorator::value) { - return load_barrier_on_oop_field_preloaded(addr, o); - } - - verify_decorators_present(); - verify_decorators_absent(); + verify_decorators_absent(); - return o; + const oop o = Raw::oop_load_not_in_heap(addr); + return load_barrier_on_oop_field_preloaded(addr, o); } template diff --git a/src/src/hotspot/share/gc/z/zStat.cpp b/src/src/hotspot/share/gc/z/zStat.cpp index 30665dae2c6..3b55bdaddea 100644 --- a/src/src/hotspot/share/gc/z/zStat.cpp +++ b/src/src/hotspot/share/gc/z/zStat.cpp @@ -56,7 +56,7 @@ struct ZStatSamplerData { void add(const ZStatSamplerData& new_sample) { _nsamples += new_sample._nsamples; - _sum += new_sample._nsamples; + _sum += new_sample._sum; _max = MAX2(_max, new_sample._max); } }; diff --git a/src/src/hotspot/share/include/jvm.h b/src/src/hotspot/share/include/jvm.h index 137fd9d503f..f20816b79d1 100644 --- a/src/src/hotspot/share/include/jvm.h +++ b/src/src/hotspot/share/include/jvm.h @@ -171,6 +171,8 @@ JVM_IsSupportedJNIVersion(jint version); JNIEXPORT jobjectArray JNICALL JVM_GetVmArguments(JNIEnv *env); +JNIEXPORT void JNICALL +JVM_InitializeFromArchive(JNIEnv* env, jclass cls); /* * java.lang.Throwable diff --git a/src/src/hotspot/share/interpreter/bytecodeInterpreter.cpp b/src/src/hotspot/share/interpreter/bytecodeInterpreter.cpp index 0a57ce6aa55..28852579cfd 100644 --- a/src/src/hotspot/share/interpreter/bytecodeInterpreter.cpp +++ b/src/src/hotspot/share/interpreter/bytecodeInterpreter.cpp @@ -2870,7 +2870,7 @@ BytecodeInterpreter::run(interpreterState istate) { METHOD->print_value_string(), (int)(istate->bcp() - METHOD->code_base()), (int)continuation_bci, p2i(THREAD)); - Exceptions::log_exception(except_oop, tempst); + Exceptions::log_exception(except_oop, tempst.as_string()); } // for AbortVMOnException flag Exceptions::debug_check_abort(except_oop); @@ -2887,7 +2887,7 @@ BytecodeInterpreter::run(interpreterState istate) { METHOD->print_value_string(), (int)(istate->bcp() - METHOD->code_base()), p2i(THREAD)); - Exceptions::log_exception(except_oop, tempst); + Exceptions::log_exception(except_oop, tempst.as_string()); } // for AbortVMOnException flag Exceptions::debug_check_abort(except_oop); diff --git a/src/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/src/hotspot/share/interpreter/interpreterRuntime.cpp index 37ed7d14957..8f4a13dea19 100644 --- a/src/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -543,7 +543,7 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea tempst.print("interpreter method <%s>\n" " at bci %d for thread " INTPTR_FORMAT " (%s)", h_method->print_value_string(), current_bci, p2i(thread), thread->name()); - Exceptions::log_exception(h_exception, tempst); + Exceptions::log_exception(h_exception, tempst.as_string()); } // Don't go paging in something which won't be used. // else if (extable->length() == 0) { diff --git a/src/src/hotspot/share/interpreter/templateInterpreter.cpp b/src/src/hotspot/share/interpreter/templateInterpreter.cpp index 4c7cba1226a..0c35250b3ea 100644 --- a/src/src/hotspot/share/interpreter/templateInterpreter.cpp +++ b/src/src/hotspot/share/interpreter/templateInterpreter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "interpreter/templateInterpreter.hpp" #include "interpreter/templateInterpreterGenerator.hpp" #include "interpreter/templateTable.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "runtime/timerTrace.hpp" @@ -283,9 +284,13 @@ static inline void copy_table(address* from, address* to, int size) { void TemplateInterpreter::notice_safepoints() { if (!_notice_safepoints) { + log_debug(interpreter, safepoint)("switching active_table to safept_table."); // switch to safepoint dispatch table _notice_safepoints = true; copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address)); + } else { + log_debug(interpreter, safepoint)("active_table is already safept_table; " + "notice_safepoints() call is no-op."); } } @@ -297,10 +302,17 @@ void TemplateInterpreter::notice_safepoints() { void TemplateInterpreter::ignore_safepoints() { if (_notice_safepoints) { if (!JvmtiExport::should_post_single_step()) { + log_debug(interpreter, safepoint)("switching active_table to normal_table."); // switch to normal dispatch table _notice_safepoints = false; copy_table((address*)&_normal_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address)); + } else { + log_debug(interpreter, safepoint)("single stepping is still active; " + "ignoring ignore_safepoints() call."); } + } else { + log_debug(interpreter, safepoint)("active_table is already normal_table; " + "ignore_safepoints() call is no-op."); } } diff --git a/src/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp b/src/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp index 2c1d400ec9e..ac33f282b0e 100644 --- a/src/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp +++ b/src/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp @@ -27,6 +27,8 @@ #include "classfile/classFileParser.hpp" #include "classfile/classFileStream.hpp" #include "classfile/javaClasses.inline.hpp" +#include "classfile/moduleEntry.hpp" +#include "classfile/modules.hpp" #include "classfile/stackMapTable.hpp" #include "classfile/verificationType.hpp" #include "interpreter/bytecodes.hpp" @@ -61,25 +63,26 @@ static const char* utf8_constants[] = { "J", // 1 "commit", // 2 "eventHandler", // 3 - "Ljdk/jfr/internal/handlers/EventHandler;", // 4 - "duration", // 5 - "begin", // 6 - "()V", // 7 - "isEnabled", // 8 - "()Z", // 9 - "end", // 10 - "shouldCommit", // 11 - "startTime", // 12 - "", // 13 - "jdk/jfr/FlightRecorder", // 14 - "register", // 15 - "(Ljava/lang/Class;)V", // 16 // LAST_REQUIRED_UTF8 - "StackMapTable", // 17 - "Exceptions", // 18 + "duration", // 4 + "begin", // 5 + "()V", // 6 + "isEnabled", // 7 + "()Z", // 8 + "end", // 9 + "shouldCommit", // 10 + "startTime", // 11 // LAST_REQUIRED_UTF8 + "Ljdk/jfr/internal/handlers/EventHandler;", // 12 + "Ljava/lang/Object;", // 13 + "", // 14 + "jdk/jfr/FlightRecorder", // 15 + "register", // 16 + "(Ljava/lang/Class;)V", // 17 + "StackMapTable", // 18 + "Exceptions", // 19 "LineNumberTable", // 20 "LocalVariableTable", // 21 "LocalVariableTypeTable", // 22 - "RuntimeVisibleAnnotation" // 23 + "RuntimeVisibleAnnotation", // 23 }; enum utf8_req_symbols { @@ -87,7 +90,6 @@ enum utf8_req_symbols { UTF8_REQ_J_FIELD_DESC, UTF8_REQ_commit, UTF8_REQ_eventHandler, - UTF8_REQ_eventHandler_FIELD_DESC, UTF8_REQ_duration, UTF8_REQ_begin, UTF8_REQ_EMPTY_VOID_METHOD_DESC, @@ -96,15 +98,17 @@ enum utf8_req_symbols { UTF8_REQ_end, UTF8_REQ_shouldCommit, UTF8_REQ_startTime, - UTF8_REQ_clinit, - UTF8_REQ_FlightRecorder, - UTF8_REQ_register, - UTF8_REQ_CLASS_VOID_METHOD_DESC, NOF_UTF8_REQ_SYMBOLS }; enum utf8_opt_symbols { - UTF8_OPT_StackMapTable = NOF_UTF8_REQ_SYMBOLS, + UTF8_OPT_eventHandler_FIELD_DESC = NOF_UTF8_REQ_SYMBOLS, + UTF8_OPT_LjavaLangObject, + UTF8_OPT_clinit, + UTF8_OPT_FlightRecorder, + UTF8_OPT_register, + UTF8_OPT_CLASS_VOID_METHOD_DESC, + UTF8_OPT_StackMapTable, UTF8_OPT_Exceptions, UTF8_OPT_LineNumberTable, UTF8_OPT_LocalVariableTable, @@ -353,7 +357,7 @@ class AnnotationIterator : public StackObj { static unsigned int unused_hash = 0; static const char value_name[] = "value"; -static bool has_registered_annotation(const InstanceKlass* ik, const Symbol* annotation_type, bool& value) { +static bool has_annotation(const InstanceKlass* ik, const Symbol* annotation_type, bool& value) { assert(annotation_type != NULL, "invariant"); AnnotationArray* class_annotations = ik->class_annotations(); if (class_annotations == NULL) { @@ -383,16 +387,51 @@ static bool has_registered_annotation(const InstanceKlass* ik, const Symbol* ann return false; } -static bool registered_annotation_value(const InstanceKlass* ik, const Symbol* const registered_symbol) { - assert(registered_symbol != NULL, "invariant"); +// Evaluate to the value of the first found Symbol* annotation type. +// Searching moves upwards in the klass hierarchy in order to support +// inherited annotations in addition to the ability to override. +static bool annotation_value(const InstanceKlass* ik, const Symbol* annotation_type, bool& value) { assert(ik != NULL, "invariant"); + assert(annotation_type != NULL, "invariant"); assert(JdkJfrEvent::is_a(ik), "invariant"); - bool registered_value = false; - if (has_registered_annotation(ik, registered_symbol, registered_value)) { - return registered_value; + if (has_annotation(ik, annotation_type, value)) { + return true; + } + InstanceKlass* const super = InstanceKlass::cast(ik->super()); + return super != NULL && JdkJfrEvent::is_a(super) ? annotation_value(super, annotation_type, value) : false; +} + +static const char jdk_jfr_module_name[] = "jdk.jfr"; + +static bool java_base_can_read_jdk_jfr() { + static bool can_read = false; + if (can_read) { + return true; + } + static Symbol* jdk_jfr_module_symbol = NULL; + if (jdk_jfr_module_symbol == NULL) { + jdk_jfr_module_symbol = SymbolTable::lookup_only(jdk_jfr_module_name, sizeof jdk_jfr_module_name - 1, unused_hash); + if (jdk_jfr_module_symbol == NULL) { + return false; + } + } + assert(jdk_jfr_module_symbol != NULL, "invariant"); + ModuleEntryTable* const table = Modules::get_module_entry_table(Handle()); + assert(table != NULL, "invariant"); + const ModuleEntry* const java_base_module = table->javabase_moduleEntry(); + if (java_base_module == NULL) { + return false; + } + assert(java_base_module != NULL, "invariant"); + ModuleEntry* const jdk_jfr_module = table->lookup_only(jdk_jfr_module_symbol); + if (jdk_jfr_module == NULL) { + return false; } - InstanceKlass* super = InstanceKlass::cast(ik->super()); - return registered_annotation_value(super, registered_symbol); + assert(jdk_jfr_module != NULL, "invariant"); + if (java_base_module->can_read(jdk_jfr_module)) { + can_read = true; + } + return can_read; } static const char registered_constant[] = "Ljdk/jfr/Registered;"; @@ -400,13 +439,24 @@ static const char registered_constant[] = "Ljdk/jfr/Registered;"; // Evaluate to the value of the first found "Ljdk/jfr/Registered;" annotation. // Searching moves upwards in the klass hierarchy in order to support // inherited annotations in addition to the ability to override. -static bool should_register_klass(const InstanceKlass* ik) { - static const Symbol* const registered_symbol = SymbolTable::lookup_only(registered_constant, - sizeof registered_constant - 1, - unused_hash); +static bool should_register_klass(const InstanceKlass* ik, bool& untypedEventHandler) { + assert(ik != NULL, "invariant"); + assert(JdkJfrEvent::is_a(ik), "invariant"); + assert(!untypedEventHandler, "invariant"); + static const Symbol* registered_symbol = NULL; + if (registered_symbol == NULL) { + registered_symbol = SymbolTable::lookup_only(registered_constant, sizeof registered_constant - 1, unused_hash); + if (registered_symbol == NULL) { + untypedEventHandler = true; + return false; + } + } assert(registered_symbol != NULL, "invariant"); - return registered_annotation_value(ik, registered_symbol); + bool value = false; // to be set by annotation_value + untypedEventHandler = !(annotation_value(ik, registered_symbol, value) || java_base_can_read_jdk_jfr()); + return value; } + /* * Map an utf8 constant back to its CONSTANT_UTF8_INFO */ @@ -450,6 +500,9 @@ static u2 add_method_ref_info(JfrBigEndianWriter& writer, u2 orig_cp_len, u2& number_of_new_constants, TRAPS) { + assert(cls_name_index != invalid_cp_index, "invariant"); + assert(method_index != invalid_cp_index, "invariant"); + assert(desc_index != invalid_cp_index, "invariant"); assert(is_index_within_range(cls_name_index, orig_cp_len, number_of_new_constants), "invariant"); assert(is_index_within_range(method_index, orig_cp_len, number_of_new_constants), "invariant"); assert(is_index_within_range(desc_index, orig_cp_len, number_of_new_constants), "invariant"); @@ -477,9 +530,9 @@ static u2 add_flr_register_method_constants(JfrBigEndianWriter& writer, TRAPS) { assert(utf8_indexes != NULL, "invariant"); return add_method_ref_info(writer, - utf8_indexes[UTF8_REQ_FlightRecorder], - utf8_indexes[UTF8_REQ_register], - utf8_indexes[UTF8_REQ_CLASS_VOID_METHOD_DESC], + utf8_indexes[UTF8_OPT_FlightRecorder], + utf8_indexes[UTF8_OPT_register], + utf8_indexes[UTF8_OPT_CLASS_VOID_METHOD_DESC], orig_cp_len, number_of_new_constants, THREAD); @@ -495,8 +548,8 @@ static u2 add_flr_register_method_constants(JfrBigEndianWriter& writer, * } */ static jlong add_field_info(JfrBigEndianWriter& writer, u2 name_index, u2 desc_index, bool is_static = false) { - assert(name_index > 0, "invariant"); - assert(desc_index > 0, "invariant"); + assert(name_index != invalid_cp_index, "invariant"); + assert(desc_index != invalid_cp_index, "invariant"); DEBUG_ONLY(const jlong start_offset = writer.current_offset();) writer.write(JVM_ACC_SYNTHETIC | JVM_ACC_PRIVATE | (is_static ? JVM_ACC_STATIC : JVM_ACC_TRANSIENT)); // flags writer.write(name_index); @@ -507,11 +560,11 @@ static jlong add_field_info(JfrBigEndianWriter& writer, u2 name_index, u2 desc_i return writer.current_offset(); } -static u2 add_field_infos(JfrBigEndianWriter& writer, const u2* utf8_indexes) { +static u2 add_field_infos(JfrBigEndianWriter& writer, const u2* utf8_indexes, bool untypedEventHandler) { assert(utf8_indexes != NULL, "invariant"); add_field_info(writer, utf8_indexes[UTF8_REQ_eventHandler], - utf8_indexes[UTF8_REQ_eventHandler_FIELD_DESC], + untypedEventHandler ? utf8_indexes[UTF8_OPT_LjavaLangObject] : utf8_indexes[UTF8_OPT_eventHandler_FIELD_DESC], true); // static add_field_info(writer, @@ -989,7 +1042,8 @@ static jlong insert_clinit_method(const InstanceKlass* ik, // This is to ensure that padding can be done // where needed and to simplify size calculations. static const u2 injected_code_length = 8; - const u2 name_index = utf8_indexes[UTF8_REQ_clinit]; + const u2 name_index = utf8_indexes[UTF8_OPT_clinit]; + assert(name_index != invalid_cp_index, "invariant"); const u2 desc_index = utf8_indexes[UTF8_REQ_EMPTY_VOID_METHOD_DESC]; const u2 max_stack = MAX2(clinit_method != NULL ? clinit_method->verifier_max_stack() : 1, 1); const u2 max_locals = MAX2(clinit_method != NULL ? clinit_method->max_locals() : 0, 0); @@ -1138,59 +1192,58 @@ static u2 resolve_utf8_indexes(JfrBigEndianWriter& writer, u2* const utf8_indexes, u2 orig_cp_len, const Method* clinit_method, + bool register_klass, + bool untypedEventHandler, TRAPS) { assert(utf8_indexes != NULL, "invariant"); u2 added_cp_entries = 0; // resolve all required symbols for (u2 index = 0; index < NOF_UTF8_REQ_SYMBOLS; ++index) { - utf8_indexes[index] = find_or_add_utf8_info(writer, - ik, - utf8_constants[index], - orig_cp_len, - added_cp_entries, - THREAD); - } - // Now determine optional constants (mainly "Code" attributes) + utf8_indexes[index] = find_or_add_utf8_info(writer, ik, utf8_constants[index], orig_cp_len, added_cp_entries, THREAD); + } + + // resolve optional constants + utf8_indexes[UTF8_OPT_eventHandler_FIELD_DESC] = untypedEventHandler ? invalid_cp_index : + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_eventHandler_FIELD_DESC], orig_cp_len, added_cp_entries, THREAD); + + utf8_indexes[UTF8_OPT_LjavaLangObject] = untypedEventHandler ? + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_LjavaLangObject], orig_cp_len, added_cp_entries, THREAD) : invalid_cp_index; + + if (register_klass) { + utf8_indexes[UTF8_OPT_clinit] = + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_clinit], orig_cp_len, added_cp_entries, THREAD); + utf8_indexes[UTF8_OPT_FlightRecorder] = + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_FlightRecorder], orig_cp_len, added_cp_entries, THREAD); + utf8_indexes[UTF8_OPT_register] = + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_register], orig_cp_len, added_cp_entries, THREAD); + utf8_indexes[UTF8_OPT_CLASS_VOID_METHOD_DESC] = + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_CLASS_VOID_METHOD_DESC], orig_cp_len, added_cp_entries, THREAD); + } else { + utf8_indexes[UTF8_OPT_clinit] = invalid_cp_index; + utf8_indexes[UTF8_OPT_FlightRecorder] = invalid_cp_index; + utf8_indexes[UTF8_OPT_register] = invalid_cp_index; + utf8_indexes[UTF8_OPT_CLASS_VOID_METHOD_DESC] = invalid_cp_index; + } + if (clinit_method != NULL && clinit_method->has_stackmap_table()) { utf8_indexes[UTF8_OPT_StackMapTable] = - find_or_add_utf8_info(writer, - ik, - utf8_constants[UTF8_OPT_StackMapTable], - orig_cp_len, - added_cp_entries, - THREAD); + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_StackMapTable], orig_cp_len, added_cp_entries, THREAD); } else { utf8_indexes[UTF8_OPT_StackMapTable] = invalid_cp_index; } if (clinit_method != NULL && clinit_method->has_linenumber_table()) { utf8_indexes[UTF8_OPT_LineNumberTable] = - find_or_add_utf8_info(writer, - ik, - utf8_constants[UTF8_OPT_LineNumberTable], - orig_cp_len, - added_cp_entries, - THREAD); + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_LineNumberTable], orig_cp_len, added_cp_entries, THREAD); } else { utf8_indexes[UTF8_OPT_LineNumberTable] = invalid_cp_index; } if (clinit_method != NULL && clinit_method->has_localvariable_table()) { utf8_indexes[UTF8_OPT_LocalVariableTable] = - find_or_add_utf8_info(writer, - ik, - utf8_constants[UTF8_OPT_LocalVariableTable], - orig_cp_len, - added_cp_entries, - THREAD); - + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_LocalVariableTable], orig_cp_len, added_cp_entries, THREAD); utf8_indexes[UTF8_OPT_LocalVariableTypeTable] = - find_or_add_utf8_info(writer, - ik, - utf8_constants[UTF8_OPT_LocalVariableTypeTable], - orig_cp_len, - added_cp_entries, - THREAD); + find_or_add_utf8_info(writer, ik, utf8_constants[UTF8_OPT_LocalVariableTypeTable], orig_cp_len, added_cp_entries, THREAD); } else { utf8_indexes[UTF8_OPT_LocalVariableTable] = invalid_cp_index; utf8_indexes[UTF8_OPT_LocalVariableTypeTable] = invalid_cp_index; @@ -1207,7 +1260,8 @@ static u1* new_bytes_for_lazy_instrumentation(const InstanceKlass* ik, // If the class already has a clinit method // we need to take that into account const Method* clinit_method = ik->class_initializer(); - const bool register_klass = should_register_klass(ik); + bool untypedEventHandler = false; + const bool register_klass = should_register_klass(ik, untypedEventHandler); const ClassFileStream* const orig_stream = parser.clone_stream(); const int orig_stream_size = orig_stream->length(); assert(orig_stream->current_offset() == 0, "invariant"); @@ -1241,7 +1295,8 @@ static u1* new_bytes_for_lazy_instrumentation(const InstanceKlass* ik, // Resolve_utf8_indexes will be conservative in attempting to // locate an existing UTF8_INFO; it will only append constants // that is absolutely required - u2 number_of_new_constants = resolve_utf8_indexes(writer, ik, utf8_indexes, orig_cp_len, clinit_method, THREAD); + u2 number_of_new_constants = + resolve_utf8_indexes(writer, ik, utf8_indexes, orig_cp_len, clinit_method, register_klass, untypedEventHandler, THREAD); // UTF8_INFO entries now added to the constant pool // In order to invoke a method we would need additional // constants, JVM_CONSTANT_Class, JVM_CONSTANT_NameAndType @@ -1274,7 +1329,7 @@ static u1* new_bytes_for_lazy_instrumentation(const InstanceKlass* ik, assert(writer.is_valid(), "invariant"); // We are sitting just after the original number of field_infos // so this is a position where we can add (append) new field_infos - const u2 number_of_new_fields = add_field_infos(writer, utf8_indexes); + const u2 number_of_new_fields = add_field_infos(writer, utf8_indexes, untypedEventHandler); assert(writer.is_valid(), "invariant"); const jlong new_method_len_offset = writer.current_offset(); // Additional field_infos added, update classfile fields_count diff --git a/src/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp b/src/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp index 2854c2c30c1..e750787fdba 100644 --- a/src/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp +++ b/src/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp @@ -133,7 +133,7 @@ jobject JfrEventClasses::get_all_event_classes(TRAPS) { DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD)); initialize(THREAD); assert(empty_java_util_arraylist != NULL, "should have been setup already!"); - static const char jdk_jfr_event_name[] = "jdk/jfr/Event"; + static const char jdk_jfr_event_name[] = "jdk/internal/event/Event"; unsigned int unused_hash = 0; Symbol* const event_klass_name = SymbolTable::lookup_only(jdk_jfr_event_name, sizeof jdk_jfr_event_name - 1, unused_hash); diff --git a/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp b/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp index 1a838d1cecc..eb1d5f29b97 100644 --- a/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp +++ b/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp @@ -76,22 +76,43 @@ static traceid next_class_loader_data_id() { return atomic_inc(&cld_id_counter) << TRACE_ID_SHIFT; } +static bool found_jdk_internal_event_klass = false; static bool found_jdk_jfr_event_klass = false; static void check_klass(const Klass* klass) { assert(klass != NULL, "invariant"); - if (found_jdk_jfr_event_klass) { + if (found_jdk_internal_event_klass && found_jdk_jfr_event_klass) { return; } + static const Symbol* jdk_internal_event_sym = NULL; + if (jdk_internal_event_sym == NULL) { + // setup when loading the first TypeArrayKlass (Universe::genesis) hence single threaded invariant + jdk_internal_event_sym = SymbolTable::new_permanent_symbol("jdk/internal/event/Event", Thread::current()); + } + assert(jdk_internal_event_sym != NULL, "invariant"); + static const Symbol* jdk_jfr_event_sym = NULL; if (jdk_jfr_event_sym == NULL) { // setup when loading the first TypeArrayKlass (Universe::genesis) hence single threaded invariant jdk_jfr_event_sym = SymbolTable::new_permanent_symbol("jdk/jfr/Event", Thread::current()); } assert(jdk_jfr_event_sym != NULL, "invariant"); - if (jdk_jfr_event_sym == klass->name() && klass->class_loader() == NULL) { - found_jdk_jfr_event_klass = true; - JfrTraceId::tag_as_jdk_jfr_event(klass); + const Symbol* const klass_name = klass->name(); + + if (!found_jdk_internal_event_klass) { + if (jdk_internal_event_sym == klass_name && klass->class_loader() == NULL) { + found_jdk_internal_event_klass = true; + JfrTraceId::tag_as_jdk_jfr_event(klass); + return; + } + } + + if (!found_jdk_jfr_event_klass) { + if (jdk_jfr_event_sym == klass_name && klass->class_loader() == NULL) { + found_jdk_jfr_event_klass = true; + JfrTraceId::tag_as_jdk_jfr_event(klass); + return; + } } } diff --git a/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp b/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp index 1721777e405..c15f571e0f4 100644 --- a/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp +++ b/src/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp @@ -112,10 +112,8 @@ inline bool JfrTraceId::is_jdk_jfr_event(const Klass* k) { inline void JfrTraceId::tag_as_jdk_jfr_event(const Klass* klass) { assert(klass != NULL, "invariant"); - assert(IS_NOT_AN_EVENT_KLASS(klass), "invariant"); SET_TAG(klass, JDK_JFR_EVENT_KLASS); assert(IS_JDK_JFR_EVENT_KLASS(klass), "invariant"); - assert(IS_NOT_AN_EVENT_SUB_KLASS(klass), "invariant"); } inline bool JfrTraceId::is_jdk_jfr_event_sub(const Klass* k) { @@ -125,7 +123,7 @@ inline bool JfrTraceId::is_jdk_jfr_event_sub(const Klass* k) { inline void JfrTraceId::tag_as_jdk_jfr_event_sub(const Klass* k) { assert(k != NULL, "invariant"); - if (IS_NOT_AN_EVENT_KLASS(k)) { + if (IS_NOT_AN_EVENT_SUB_KLASS(k)) { SET_TAG(k, JDK_JFR_EVENT_SUBKLASS); } assert(IS_JDK_JFR_EVENT_SUBKLASS(k), "invariant"); diff --git a/src/src/hotspot/share/jfr/recorder/jfrRecorder.cpp b/src/src/hotspot/share/jfr/recorder/jfrRecorder.cpp index 6653b5886d5..2e662959060 100644 --- a/src/src/hotspot/share/jfr/recorder/jfrRecorder.cpp +++ b/src/src/hotspot/share/jfr/recorder/jfrRecorder.cpp @@ -203,9 +203,6 @@ bool JfrRecorder::on_vm_start() { if (!validate_recording_options(thread)) { return false; } - if (!JfrJavaEventWriter::initialize()) { - return false; - } if (!JfrOptionSet::configure(thread)) { return false; } @@ -255,6 +252,9 @@ bool JfrRecorder::create_components() { ResourceMark rm; HandleMark hm; + if (!create_java_event_writer()) { + return false; + } if (!create_jvmti_agent()) { return false; } @@ -296,6 +296,10 @@ static JfrStringPool* _stringpool = NULL; static JfrOSInterface* _os_interface = NULL; static JfrThreadSampling* _thread_sampling = NULL; +bool JfrRecorder::create_java_event_writer() { + return JfrJavaEventWriter::initialize(); +} + bool JfrRecorder::create_jvmti_agent() { return JfrOptionSet::allow_retransforms() ? JfrJvmtiAgent::create() : true; } diff --git a/src/src/hotspot/share/jfr/recorder/jfrRecorder.hpp b/src/src/hotspot/share/jfr/recorder/jfrRecorder.hpp index ad1ff051869..45e27f5bbc6 100644 --- a/src/src/hotspot/share/jfr/recorder/jfrRecorder.hpp +++ b/src/src/hotspot/share/jfr/recorder/jfrRecorder.hpp @@ -40,6 +40,7 @@ class JfrRecorder : public JfrCHeapObj { private: static bool create_checkpoint_manager(); static bool create_chunk_repository(); + static bool create_java_event_writer(); static bool create_jvmti_agent(); static bool create_os_interface(); static bool create_post_box(); diff --git a/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp b/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp index f933998ebb8..27bc95f8a37 100644 --- a/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp +++ b/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp @@ -135,8 +135,7 @@ static bool setup_event_writer_offsets(TRAPS) { bool JfrJavaEventWriter::initialize() { static bool initialized = false; if (!initialized) { - Thread* thread = Thread::current(); - initialized = setup_event_writer_offsets(thread); + initialized = setup_event_writer_offsets(Thread::current()); } return initialized; } @@ -155,6 +154,7 @@ jboolean JfrJavaEventWriter::flush(jobject writer, jint used, jint requested, Ja // large enough to accommodate the "requested size". const bool is_valid = buffer->free_size() >= (size_t)(used + requested); u1* const new_current_position = is_valid ? buffer->pos() + used : buffer->pos(); + assert(start_pos_offset != invalid_offset, "invariant"); w->long_field_put(start_pos_offset, (jlong)buffer->pos()); w->long_field_put(current_pos_offset, (jlong)new_current_position); // only update java writer if underlying memory changed diff --git a/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.hpp b/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.hpp index 13303823e20..7c17dd9f8fb 100644 --- a/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.hpp +++ b/src/src/hotspot/share/jfr/writers/jfrJavaEventWriter.hpp @@ -33,13 +33,14 @@ class Thread; class JfrJavaEventWriter : AllStatic { friend class JfrCheckpointThreadClosure; - friend class JfrJavaEventWriterNotifyOperation; friend class JfrJavaEventWriterNotificationClosure; + friend class JfrJavaEventWriterNotifyOperation; + friend class JfrRecorder; private: + static bool initialize(); static void notify(JavaThread* jt); public: - static bool initialize(); static void notify(); static jobject event_writer(Thread* t); static jobject new_event_writer(TRAPS); diff --git a/src/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/src/hotspot/share/jvmci/jvmciRuntime.cpp index 85d74689ed7..58482c579f4 100644 --- a/src/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -284,7 +284,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t tempst.print("compiled method <%s>\n" " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT, cm->method()->print_value_string(), p2i(pc), p2i(thread)); - Exceptions::log_exception(exception, tempst); + Exceptions::log_exception(exception, tempst.as_string()); } // for AbortVMOnException flag NOT_PRODUCT(Exceptions::debug_check_abort(exception)); diff --git a/src/src/hotspot/share/memory/allocation.hpp b/src/src/hotspot/share/memory/allocation.hpp index c1f52c249bd..dee2a9b82f4 100644 --- a/src/src/hotspot/share/memory/allocation.hpp +++ b/src/src/hotspot/share/memory/allocation.hpp @@ -113,29 +113,31 @@ class AllocatedObj { */ enum MemoryType { // Memory type by sub systems. It occupies lower byte. - mtJavaHeap = 0x00, // Java heap - mtClass = 0x01, // memory class for Java classes - mtThread = 0x02, // memory for thread objects - mtThreadStack = 0x03, - mtCode = 0x04, // memory for generated code - mtGC = 0x05, // memory for GC - mtCompiler = 0x06, // memory for compiler - mtInternal = 0x07, // memory used by VM, but does not belong to - // any of above categories, and not used for - // native memory tracking - mtOther = 0x08, // memory not used by VM - mtSymbol = 0x09, // symbol - mtNMT = 0x0A, // memory used by native memory tracking - mtClassShared = 0x0B, // class data sharing - mtChunk = 0x0C, // chunk that holds content of arenas - mtTest = 0x0D, // Test type for verifying NMT - mtTracing = 0x0E, // memory used for Tracing - mtLogging = 0x0F, // memory for logging - mtArguments = 0x10, // memory for argument processing - mtModule = 0x11, // memory for module processing - mtNone = 0x12, // undefined - mt_number_of_types = 0x13 // number of memory types (mtDontTrack - // is not included as validate type) + mtJavaHeap, // Java heap + mtClass, // memory class for Java classes + mtThread, // memory for thread objects + mtThreadStack, + mtCode, // memory for generated code + mtGC, // memory for GC + mtCompiler, // memory for compiler + mtInternal, // memory used by VM, but does not belong to + // any of above categories, and not used for + // native memory tracking + mtOther, // memory not used by VM + mtSymbol, // symbol + mtNMT, // memory used by native memory tracking + mtClassShared, // class data sharing + mtChunk, // chunk that holds content of arenas + mtTest, // Test type for verifying NMT + mtTracing, // memory used for Tracing + mtLogging, // memory for logging + mtArguments, // memory for argument processing + mtModule, // memory for module processing + mtSynchronizer, // memory for synchronization primitives + mtSafepoint, // memory for safepoint support + mtNone, // undefined + mt_number_of_types // number of memory types (mtDontTrack + // is not included as validate type) }; typedef MemoryType MEMFLAGS; diff --git a/src/src/hotspot/share/memory/heapInspection.cpp b/src/src/hotspot/share/memory/heapInspection.cpp index 12c6ff0bbf3..9c2cdc1171c 100644 --- a/src/src/hotspot/share/memory/heapInspection.cpp +++ b/src/src/hotspot/share/memory/heapInspection.cpp @@ -120,6 +120,11 @@ void KlassInfoEntry::print_on(outputStream* st) const { } KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) { + // Can happen if k is an archived class that we haven't loaded yet. + if (k->java_mirror_no_keepalive() == NULL) { + return NULL; + } + KlassInfoEntry* elt = _list; while (elt != NULL) { if (elt->is_equal(k)) { @@ -197,7 +202,8 @@ KlassInfoEntry* KlassInfoTable::lookup(Klass* k) { assert(_buckets != NULL, "Allocation failure should have been caught"); KlassInfoEntry* e = _buckets[idx].lookup(k); // Lookup may fail if this is a new klass for which we - // could not allocate space for an new entry. + // could not allocate space for an new entry, or if it's + // an archived class that we haven't loaded yet. assert(e == NULL || k == e->klass(), "must be equal"); return e; } @@ -707,7 +713,7 @@ size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *fi ResourceMark rm; RecordInstanceClosure ric(cit, filter); - Universe::heap()->object_iterate(&ric); + Universe::heap()->safe_object_iterate(&ric); return ric.missed_count(); } @@ -780,8 +786,5 @@ void HeapInspection::find_instances_at_safepoint(Klass* k, GrowableArray* r // Iterate over objects in the heap FindInstanceClosure fic(k, result); - // If this operation encounters a bad object when using CMS, - // consider using safe_object_iterate() which avoids metadata - // objects that may contain bad references. - Universe::heap()->object_iterate(&fic); + Universe::heap()->safe_object_iterate(&fic); } diff --git a/src/src/hotspot/share/memory/heapShared.cpp b/src/src/hotspot/share/memory/heapShared.cpp new file mode 100644 index 00000000000..a8735a013b2 --- /dev/null +++ b/src/src/hotspot/share/memory/heapShared.cpp @@ -0,0 +1,506 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "classfile/javaClasses.inline.hpp" +#include "classfile/vmSymbols.hpp" +#include "logging/log.hpp" +#include "logging/logMessage.hpp" +#include "logging/logStream.hpp" +#include "memory/heapShared.hpp" +#include "memory/iterator.inline.hpp" +#include "memory/metadataFactory.hpp" +#include "memory/metaspaceClosure.hpp" +#include "memory/metaspaceShared.hpp" +#include "memory/resourceArea.hpp" +#include "oops/compressedOops.inline.hpp" +#include "oops/oop.inline.hpp" + +#if INCLUDE_CDS_JAVA_HEAP +KlassSubGraphInfo* HeapShared::_subgraph_info_list = NULL; +int HeapShared::_num_archived_subgraph_info_records = 0; +Array* HeapShared::_archived_subgraph_info_records = NULL; + +// Currently there is only one class mirror (ArchivedModuleGraph) with archived +// sub-graphs. +KlassSubGraphInfo* HeapShared::find_subgraph_info(Klass* k) { + KlassSubGraphInfo* info = _subgraph_info_list; + while (info != NULL) { + if (info->klass() == k) { + return info; + } + info = info->next(); + } + return NULL; +} + +// Get the subgraph_info for Klass k. A new subgraph_info is created if +// there is no existing one for k. The subgraph_info records the relocated +// Klass* of the original k. +KlassSubGraphInfo* HeapShared::get_subgraph_info(Klass* k) { + Klass* relocated_k = MetaspaceShared::get_relocated_klass(k); + KlassSubGraphInfo* info = find_subgraph_info(relocated_k); + if (info != NULL) { + return info; + } + + info = new KlassSubGraphInfo(relocated_k, _subgraph_info_list); + _subgraph_info_list = info; + return info; +} + +int HeapShared::num_of_subgraph_infos() { + int num = 0; + KlassSubGraphInfo* info = _subgraph_info_list; + while (info != NULL) { + num ++; + info = info->next(); + } + return num; +} + +// Add an entry field to the current KlassSubGraphInfo. +void KlassSubGraphInfo::add_subgraph_entry_field(int static_field_offset, oop v) { + assert(DumpSharedSpaces, "dump time only"); + if (_subgraph_entry_fields == NULL) { + _subgraph_entry_fields = + new(ResourceObj::C_HEAP, mtClass) GrowableArray(10, true); + } + _subgraph_entry_fields->append((juint)static_field_offset); + _subgraph_entry_fields->append(CompressedOops::encode(v)); +} + +// Add the Klass* for an object in the current KlassSubGraphInfo's subgraphs. +// Only objects of boot classes can be included in sub-graph. +void KlassSubGraphInfo::add_subgraph_object_klass(Klass* orig_k, Klass *relocated_k) { + assert(DumpSharedSpaces, "dump time only"); + assert(relocated_k == MetaspaceShared::get_relocated_klass(orig_k), + "must be the relocated Klass in the shared space"); + + if (_subgraph_object_klasses == NULL) { + _subgraph_object_klasses = + new(ResourceObj::C_HEAP, mtClass) GrowableArray(50, true); + } + + assert(relocated_k->is_shared(), "must be a shared class"); + if (relocated_k->is_instance_klass()) { + assert(InstanceKlass::cast(relocated_k)->is_shared_boot_class(), + "must be boot class"); + // SystemDictionary::xxx_klass() are not updated, need to check + // the original Klass* + if (orig_k == SystemDictionary::String_klass() || + orig_k == SystemDictionary::Object_klass()) { + // Initialized early during VM initialization. No need to be added + // to the sub-graph object class list. + return; + } + } else if (relocated_k->is_objArray_klass()) { + Klass* abk = ObjArrayKlass::cast(relocated_k)->bottom_klass(); + if (abk->is_instance_klass()) { + assert(InstanceKlass::cast(abk)->is_shared_boot_class(), + "must be boot class"); + } + if (relocated_k == Universe::objectArrayKlassObj()) { + // Initialized early during Universe::genesis. No need to be added + // to the list. + return; + } + } else { + assert(relocated_k->is_typeArray_klass(), "must be"); + // Primitive type arrays are created early during Universe::genesis. + return; + } + + _subgraph_object_klasses->append_if_missing(relocated_k); +} + +// Initialize an archived subgraph_info_record from the given KlassSubGraphInfo. +void ArchivedKlassSubGraphInfoRecord::init(KlassSubGraphInfo* info) { + _k = info->klass(); + _next = NULL; + _entry_field_records = NULL; + _subgraph_klasses = NULL; + + // populate the entry fields + GrowableArray* entry_fields = info->subgraph_entry_fields(); + if (entry_fields != NULL) { + int num_entry_fields = entry_fields->length(); + assert(num_entry_fields % 2 == 0, "sanity"); + _entry_field_records = + MetaspaceShared::new_ro_array(num_entry_fields); + for (int i = 0 ; i < num_entry_fields; i++) { + _entry_field_records->at_put(i, entry_fields->at(i)); + } + } + + // the Klasses of the objects in the sub-graphs + GrowableArray* subgraph_klasses = info->subgraph_object_klasses(); + if (subgraph_klasses != NULL) { + int num_subgraphs_klasses = subgraph_klasses->length(); + _subgraph_klasses = + MetaspaceShared::new_ro_array(num_subgraphs_klasses); + for (int i = 0; i < num_subgraphs_klasses; i++) { + Klass* subgraph_k = subgraph_klasses->at(i); + if (log_is_enabled(Info, cds, heap)) { + ResourceMark rm; + log_info(cds, heap)( + "Archived object klass (%d): %s in %s sub-graphs", + i, subgraph_k->external_name(), _k->external_name()); + } + _subgraph_klasses->at_put(i, subgraph_k); + } + } +} + +// Build the records of archived subgraph infos, which include: +// - Entry points to all subgraphs from the containing class mirror. The entry +// points are static fields in the mirror. For each entry point, the field +// offset and value are recorded in the sub-graph info. The value are stored +// back to the corresponding field at runtime. +// - A list of klasses that need to be loaded/initialized before archived +// java object sub-graph can be accessed at runtime. +// +// The records are saved in the archive file and reloaded at runtime. Currently +// there is only one class mirror (ArchivedModuleGraph) with archived sub-graphs. +// +// Layout of the archived subgraph info records: +// +// records_size | num_records | records* +// ArchivedKlassSubGraphInfoRecord | entry_fields | subgraph_object_klasses +size_t HeapShared::build_archived_subgraph_info_records(int num_records) { + // remember the start address + char* start_p = MetaspaceShared::read_only_space_top(); + + // now populate the archived subgraph infos, which will be saved in the + // archive file + _archived_subgraph_info_records = + MetaspaceShared::new_ro_array(num_records); + KlassSubGraphInfo* info = _subgraph_info_list; + int i = 0; + while (info != NULL) { + assert(i < _archived_subgraph_info_records->length(), "sanity"); + ArchivedKlassSubGraphInfoRecord* record = + _archived_subgraph_info_records->adr_at(i); + record->init(info); + info = info->next(); + i ++; + } + + // _subgraph_info_list is no longer needed + delete _subgraph_info_list; + _subgraph_info_list = NULL; + + char* end_p = MetaspaceShared::read_only_space_top(); + size_t records_size = end_p - start_p; + return records_size; +} + +// Write the subgraph info records in the shared _ro region +void HeapShared::write_archived_subgraph_infos() { + assert(DumpSharedSpaces, "dump time only"); + + Array* records_header = MetaspaceShared::new_ro_array(3); + + _num_archived_subgraph_info_records = num_of_subgraph_infos(); + size_t records_size = build_archived_subgraph_info_records( + _num_archived_subgraph_info_records); + + // Now write the header information: + // records_size, num_records, _archived_subgraph_info_records + assert(records_header != NULL, "sanity"); + intptr_t* p = (intptr_t*)(records_header->data()); + *p = (intptr_t)records_size; + p ++; + *p = (intptr_t)_num_archived_subgraph_info_records; + p ++; + *p = (intptr_t)_archived_subgraph_info_records; +} + +char* HeapShared::read_archived_subgraph_infos(char* buffer) { + Array* records_header = (Array*)buffer; + intptr_t* p = (intptr_t*)(records_header->data()); + size_t records_size = (size_t)(*p); + p ++; + _num_archived_subgraph_info_records = *p; + p ++; + _archived_subgraph_info_records = + (Array*)(*p); + + buffer = (char*)_archived_subgraph_info_records + records_size; + return buffer; +} + +void HeapShared::initialize_from_archived_subgraph(Klass* k) { + if (!MetaspaceShared::open_archive_heap_region_mapped()) { + return; // nothing to do + } + + if (_num_archived_subgraph_info_records == 0) { + return; // no subgraph info records + } + + // Initialize from archived data. Currently only ArchivedModuleGraph + // has archived object subgraphs, which is used during VM initialization + // time when bootstraping the system modules. No lock is needed. + Thread* THREAD = Thread::current(); + for (int i = 0; i < _archived_subgraph_info_records->length(); i++) { + ArchivedKlassSubGraphInfoRecord* record = _archived_subgraph_info_records->adr_at(i); + if (record->klass() == k) { + int i; + // Found the archived subgraph info record for the requesting klass. + // Load/link/initialize the klasses of the objects in the subgraph. + // NULL class loader is used. + Array* klasses = record->subgraph_klasses(); + if (klasses != NULL) { + for (i = 0; i < klasses->length(); i++) { + Klass* obj_k = klasses->at(i); + Klass* resolved_k = SystemDictionary::resolve_or_null( + (obj_k)->name(), THREAD); + if (resolved_k != obj_k) { + return; + } + if ((obj_k)->is_instance_klass()) { + InstanceKlass* ik = InstanceKlass::cast(obj_k); + ik->initialize(THREAD); + } else if ((obj_k)->is_objArray_klass()) { + ObjArrayKlass* oak = ObjArrayKlass::cast(obj_k); + oak->initialize(THREAD); + } + } + } + + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + // None of the field value will be set if there was an exception. + // The java code will not see any of the archived objects in the + // subgraphs referenced from k in this case. + return; + } + + // Load the subgraph entry fields from the record and store them back to + // the corresponding fields within the mirror. + oop m = k->java_mirror(); + Array* entry_field_records = record->entry_field_records(); + if (entry_field_records != NULL) { + int efr_len = entry_field_records->length(); + assert(efr_len % 2 == 0, "sanity"); + for (i = 0; i < efr_len;) { + int field_offset = entry_field_records->at(i); + // The object refereced by the field becomes 'known' by GC from this + // point. All objects in the subgraph reachable from the object are + // also 'known' by GC. + oop v = MetaspaceShared::materialize_archived_object( + CompressedOops::decode(entry_field_records->at(i+1))); + m->obj_field_put(field_offset, v); + i += 2; + } + } + + // Done. Java code can see the archived sub-graphs referenced from k's + // mirror after this point. + return; + } + } +} + +class WalkOopAndArchiveClosure: public BasicOopIterateClosure { + int _level; + KlassSubGraphInfo* _subgraph_info; + oop _orig_referencing_obj; + oop _archived_referencing_obj; + public: + WalkOopAndArchiveClosure(int level, KlassSubGraphInfo* subgraph_info, + oop orig, oop archived) : _level(level), + _subgraph_info(subgraph_info), + _orig_referencing_obj(orig), + _archived_referencing_obj(archived) {} + void do_oop(narrowOop *p) { WalkOopAndArchiveClosure::do_oop_work(p); } + void do_oop( oop *p) { WalkOopAndArchiveClosure::do_oop_work(p); } + + protected: + template void do_oop_work(T *p) { + oop obj = RawAccess<>::oop_load(p); + if (!CompressedOops::is_null(obj)) { + // A java.lang.Class instance can not be included in an archived + // object sub-graph. + if (java_lang_Class::is_instance(obj)) { + tty->print("Unknown java.lang.Class object is in the archived sub-graph\n"); + vm_exit(1); + } + + LogTarget(Debug, cds, heap) log; + LogStream ls(log); + outputStream* out = &ls; + { + ResourceMark rm; + log.print("(%d) %s <--- referenced from: %s", + _level, obj->klass()->external_name(), + CompressedOops::is_null(_orig_referencing_obj) ? + "" : _orig_referencing_obj->klass()->external_name()); + obj->print_on(out); + } + + if (MetaspaceShared::is_archive_object(obj)) { + // The current oop is an archived oop, nothing needs to be done + log.print("--- object is already archived ---"); + return; + } + + size_t field_delta = pointer_delta( + p, _orig_referencing_obj, sizeof(char)); + T* new_p = (T*)(address(_archived_referencing_obj) + field_delta); + oop archived = MetaspaceShared::find_archived_heap_object(obj); + if (archived != NULL) { + // There is an archived copy existing, update reference to point + // to the archived copy + RawAccess::oop_store(new_p, archived); + log.print( + "--- found existing archived copy, store archived " PTR_FORMAT " in " PTR_FORMAT, + p2i(archived), p2i(new_p)); + return; + } + + int l = _level + 1; + Thread* THREAD = Thread::current(); + // Archive the current oop before iterating through its references + archived = MetaspaceShared::archive_heap_object(obj, THREAD); + assert(MetaspaceShared::is_archive_object(archived), "must be archived"); + log.print("=== archiving oop " PTR_FORMAT " ==> " PTR_FORMAT, + p2i(obj), p2i(archived)); + + // Following the references in the current oop and archive any + // encountered objects during the process + WalkOopAndArchiveClosure walker(l, _subgraph_info, obj, archived); + obj->oop_iterate(&walker); + + // Update the reference in the archived copy of the referencing object + RawAccess::oop_store(new_p, archived); + log.print("=== store archived " PTR_FORMAT " in " PTR_FORMAT, + p2i(archived), p2i(new_p)); + + // Add the klass to the list of classes that need to be loaded before + // module system initialization + Klass *orig_k = obj->klass(); + Klass *relocated_k = archived->klass(); + _subgraph_info->add_subgraph_object_klass(orig_k, relocated_k); + } + } +}; + +// +// Start from the given static field in a java mirror and archive the +// complete sub-graph of java heap objects that are reached directly +// or indirectly from the starting object by following references. +// Currently, only ArchivedModuleGraph class instance (mirror) has archived +// object subgraphs. Sub-graph archiving restrictions (current): +// +// - All classes of objects in the archived sub-graph (including the +// entry class) must be boot class only. +// - No java.lang.Class instance (java mirror) can be included inside +// an archived sub-graph. Mirror can only be the sub-graph entry object. +// +// The Java heap object sub-graph archiving process (see +// WalkOopAndArchiveClosure): +// +// 1) Java object sub-graph archiving starts from a given static field +// within a Class instance (java mirror). If the static field is a +// refererence field and points to a non-null java object, proceed to +// the next step. +// +// 2) Archives the referenced java object. If an archived copy of the +// current object already exists, updates the pointer in the archived +// copy of the referencing object to point to the current archived object. +// Otherwise, proceed to the next step. +// +// 3) Follows all references within the current java object and recursively +// archive the sub-graph of objects starting from each reference. +// +// 4) Updates the pointer in the archived copy of referencing object to +// point to the current archived object. +// +// 5) The Klass of the current java object is added to the list of Klasses +// for loading and initialzing before any object in the archived graph can +// be accessed at runtime. +// +void HeapShared::archive_reachable_objects_from_static_field(Klass *k, + int field_offset, + BasicType field_type, + TRAPS) { + assert(DumpSharedSpaces, "dump time only"); + assert(k->is_instance_klass(), "sanity"); + assert(InstanceKlass::cast(k)->is_shared_boot_class(), + "must be boot class"); + + oop m = k->java_mirror(); + oop archived_m = MetaspaceShared::find_archived_heap_object(m); + if (CompressedOops::is_null(archived_m)) { + return; + } + + if (field_type == T_OBJECT) { + // obtain k's subGraph Info + KlassSubGraphInfo* subgraph_info = get_subgraph_info(k); + + // get the object referenced by the field + oop f = m->obj_field(field_offset); + if (!CompressedOops::is_null(f)) { + LogTarget(Debug, cds, heap) log; + LogStream ls(log); + outputStream* out = &ls; + log.print("Start from: "); + f->print_on(out); + + // get the archived copy of the field referenced object + oop af = MetaspaceShared::archive_heap_object(f, THREAD); + if (!MetaspaceShared::is_archive_object(f)) { + WalkOopAndArchiveClosure walker(1, subgraph_info, f, af); + f->oop_iterate(&walker); + } + + // The field value is not preserved in the archived mirror. + // Record the field as a new subGraph entry point. The recorded + // information is restored from the archive at runtime. + subgraph_info->add_subgraph_entry_field(field_offset, af); + Klass *relocated_k = af->klass(); + Klass *orig_k = f->klass(); + subgraph_info->add_subgraph_object_klass(orig_k, relocated_k); + } else { + // The field contains null, we still need to record the entry point, + // so it can be restored at runtime. + subgraph_info->add_subgraph_entry_field(field_offset, NULL); + } + } else { + ShouldNotReachHere(); + } +} + +#define do_module_object_graph(archive_object_graph_do) \ + archive_object_graph_do(SystemDictionary::ArchivedModuleGraph_klass(), jdk_internal_module_ArchivedModuleGraph::archivedSystemModules_offset(), T_OBJECT, CHECK); \ + archive_object_graph_do(SystemDictionary::ArchivedModuleGraph_klass(), jdk_internal_module_ArchivedModuleGraph::archivedModuleFinder_offset(), T_OBJECT, CHECK); \ + archive_object_graph_do(SystemDictionary::ArchivedModuleGraph_klass(), jdk_internal_module_ArchivedModuleGraph::archivedMainModule_offset(), T_OBJECT, CHECK) + +void HeapShared::archive_module_graph_objects(Thread* THREAD) { + do_module_object_graph(archive_reachable_objects_from_static_field); +} +#endif // INCLUDE_CDS_JAVA_HEAP diff --git a/src/src/hotspot/share/memory/heapShared.hpp b/src/src/hotspot/share/memory/heapShared.hpp new file mode 100644 index 00000000000..93ceb6ccfee --- /dev/null +++ b/src/src/hotspot/share/memory/heapShared.hpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_MEMORY_HEAPSHARED_HPP +#define SHARE_VM_MEMORY_HEAPSHARED_HPP + +#include "classfile/systemDictionary.hpp" +#include "memory/universe.hpp" +#include "oops/objArrayKlass.hpp" +#include "oops/oop.hpp" +#include "oops/typeArrayKlass.hpp" +#include "utilities/growableArray.hpp" + +#if INCLUDE_CDS_JAVA_HEAP +// A dump time sub-graph info for Klass _k. It includes the entry points +// (static fields in _k's mirror) of the archived sub-graphs reachable +// from _k's mirror. It also contains a list of Klasses of the objects +// within the sub-graphs. +class KlassSubGraphInfo: public CHeapObj { + private: + KlassSubGraphInfo* _next; + // The class that contains the static field(s) as the entry point(s) + // of archived object sub-graph(s). + Klass* _k; + // A list of classes need to be loaded and initialized before the archived + // object sub-graphs can be accessed at runtime. + GrowableArray* _subgraph_object_klasses; + // A list of _k's static fields as the entry points of archived sub-graphs. + // For each entry field, it is a pair of field_offset and field_value. + GrowableArray* _subgraph_entry_fields; + + public: + KlassSubGraphInfo(Klass* k, KlassSubGraphInfo* next) : + _next(next), _k(k), _subgraph_object_klasses(NULL), + _subgraph_entry_fields(NULL) {} + ~KlassSubGraphInfo() { + if (_subgraph_object_klasses != NULL) { + delete _subgraph_object_klasses; + } + if (_subgraph_entry_fields != NULL) { + delete _subgraph_entry_fields; + } + }; + + KlassSubGraphInfo* next() { return _next; } + Klass* klass() { return _k; } + GrowableArray* subgraph_object_klasses() { + return _subgraph_object_klasses; + } + GrowableArray* subgraph_entry_fields() { + return _subgraph_entry_fields; + } + void add_subgraph_entry_field(int static_field_offset, oop v); + void add_subgraph_object_klass(Klass *orig_k, Klass *relocated_k); +}; + +// An archived record of object sub-graphs reachable from static +// fields within _k's mirror. The record is reloaded from the archive +// at runtime. +class ArchivedKlassSubGraphInfoRecord { + private: + ArchivedKlassSubGraphInfoRecord* _next; + Klass* _k; + + // contains pairs of field offset and value for each subgraph entry field + Array* _entry_field_records; + + // klasses of objects in archived sub-graphs referenced from the entry points + // (static fields) in the containing class + Array* _subgraph_klasses; + public: + ArchivedKlassSubGraphInfoRecord() : + _next(NULL), _k(NULL), _entry_field_records(NULL), _subgraph_klasses(NULL) {} + void init(KlassSubGraphInfo* info); + Klass* klass() { return _k; } + ArchivedKlassSubGraphInfoRecord* next() { return _next; } + void set_next(ArchivedKlassSubGraphInfoRecord* next) { _next = next; } + Array* entry_field_records() { return _entry_field_records; } + Array* subgraph_klasses() { return _subgraph_klasses; } +}; +#endif // INCLUDE_CDS_JAVA_HEAP + +class HeapShared: AllStatic { + private: +#if INCLUDE_CDS_JAVA_HEAP + // This is a list of subgraph infos built at dump time while + // archiving object subgraphs. + static KlassSubGraphInfo* _subgraph_info_list; + + // Contains a list of ArchivedKlassSubGraphInfoRecords that is stored + // in the archive file and reloaded at runtime. + static int _num_archived_subgraph_info_records; + static Array* _archived_subgraph_info_records; + + // Archive object sub-graph starting from the given static field + // in Klass k's mirror. + static void archive_reachable_objects_from_static_field( + Klass* k, int field_ofset, BasicType field_type, TRAPS); + + static KlassSubGraphInfo* find_subgraph_info(Klass *k); + static KlassSubGraphInfo* get_subgraph_info(Klass *k); + static int num_of_subgraph_infos(); + + static size_t build_archived_subgraph_info_records(int num_records); +#endif // INCLUDE_CDS_JAVA_HEAP + public: + static char* read_archived_subgraph_infos(char* buffer) NOT_CDS_JAVA_HEAP_RETURN_(buffer); + static void write_archived_subgraph_infos() NOT_CDS_JAVA_HEAP_RETURN; + static void initialize_from_archived_subgraph(Klass* k) NOT_CDS_JAVA_HEAP_RETURN; + + static void archive_module_graph_objects(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN; +}; +#endif // SHARE_VM_MEMORY_HEAPSHARED_HPP diff --git a/src/src/hotspot/share/memory/metaspace.cpp b/src/src/hotspot/share/memory/metaspace.cpp index 459d9d6398e..a192ba9827c 100644 --- a/src/src/hotspot/share/memory/metaspace.cpp +++ b/src/src/hotspot/share/memory/metaspace.cpp @@ -535,6 +535,23 @@ void MetaspaceUtils::print_vs(outputStream* out, size_t scale) { } } +static void print_basic_switches(outputStream* out, size_t scale) { + out->print("MaxMetaspaceSize: "); + if (MaxMetaspaceSize >= (max_uintx) - (2 * os::vm_page_size())) { + // aka "very big". Default is max_uintx, but due to rounding in arg parsing the real + // value is smaller. + out->print("unlimited"); + } else { + print_human_readable_size(out, MaxMetaspaceSize, scale); + } + out->cr(); + if (Metaspace::using_class_space()) { + out->print("CompressedClassSpaceSize: "); + print_human_readable_size(out, CompressedClassSpaceSize, scale); + } + out->cr(); +} + // This will print out a basic metaspace usage report but // unlike print_report() is guaranteed not to lock or to walk the CLDG. void MetaspaceUtils::print_basic_report(outputStream* out, size_t scale) { @@ -615,6 +632,12 @@ void MetaspaceUtils::print_basic_report(outputStream* out, size_t scale) { Metaspace::chunk_manager_metadata()->free_chunks_total_bytes(), scale); out->cr(); } + + out->cr(); + + // Print basic settings + print_basic_switches(out, scale); + out->cr(); } @@ -799,19 +822,11 @@ void MetaspaceUtils::print_report(outputStream* out, size_t scale, int flags) { // Print some interesting settings out->cr(); out->cr(); - out->print("MaxMetaspaceSize: "); - print_human_readable_size(out, MaxMetaspaceSize, scale); + print_basic_switches(out, scale); + out->cr(); out->print("InitialBootClassLoaderMetaspaceSize: "); print_human_readable_size(out, InitialBootClassLoaderMetaspaceSize, scale); - out->cr(); - - out->print("UseCompressedClassPointers: %s", UseCompressedClassPointers ? "true" : "false"); - out->cr(); - if (Metaspace::using_class_space()) { - out->print("CompressedClassSpaceSize: "); - print_human_readable_size(out, CompressedClassSpaceSize, scale); - } out->cr(); out->cr(); @@ -1586,67 +1601,6 @@ void ClassLoaderMetaspace::add_to_statistics(ClassLoaderMetaspaceStatistics* out #ifndef PRODUCT -class TestMetaspaceUtilsTest : AllStatic { - public: - static void test_reserved() { - size_t reserved = MetaspaceUtils::reserved_bytes(); - - assert(reserved > 0, "assert"); - - size_t committed = MetaspaceUtils::committed_bytes(); - assert(committed <= reserved, "assert"); - - size_t reserved_metadata = MetaspaceUtils::reserved_bytes(Metaspace::NonClassType); - assert(reserved_metadata > 0, "assert"); - assert(reserved_metadata <= reserved, "assert"); - - if (UseCompressedClassPointers) { - size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType); - assert(reserved_class > 0, "assert"); - assert(reserved_class < reserved, "assert"); - } - } - - static void test_committed() { - size_t committed = MetaspaceUtils::committed_bytes(); - - assert(committed > 0, "assert"); - - size_t reserved = MetaspaceUtils::reserved_bytes(); - assert(committed <= reserved, "assert"); - - size_t committed_metadata = MetaspaceUtils::committed_bytes(Metaspace::NonClassType); - assert(committed_metadata > 0, "assert"); - assert(committed_metadata <= committed, "assert"); - - if (UseCompressedClassPointers) { - size_t committed_class = MetaspaceUtils::committed_bytes(Metaspace::ClassType); - assert(committed_class > 0, "assert"); - assert(committed_class < committed, "assert"); - } - } - - static void test_virtual_space_list_large_chunk() { - VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); - MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); - // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be - // vm_allocation_granularity aligned on Windows. - size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); - large_size += (os::vm_page_size()/BytesPerWord); - vs_list->get_new_chunk(large_size, 0); - } - - static void test() { - test_reserved(); - test_committed(); - test_virtual_space_list_large_chunk(); - } -}; - -void TestMetaspaceUtils_test() { - TestMetaspaceUtilsTest::test(); -} - class TestVirtualSpaceNodeTest { static void chunk_up(size_t words_left, size_t& num_medium_chunks, size_t& num_small_chunks, diff --git a/src/src/hotspot/share/memory/metaspaceShared.cpp b/src/src/hotspot/share/memory/metaspaceShared.cpp index 2b82d1305e5..f20f5305c50 100644 --- a/src/src/hotspot/share/memory/metaspaceShared.cpp +++ b/src/src/hotspot/share/memory/metaspaceShared.cpp @@ -39,6 +39,7 @@ #include "logging/log.hpp" #include "logging/logMessage.hpp" #include "memory/filemap.hpp" +#include "memory/heapShared.hpp" #include "memory/metaspace.hpp" #include "memory/metaspaceClosure.hpp" #include "memory/metaspaceShared.hpp" @@ -207,6 +208,10 @@ char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) { return _ro_region.allocate(num_bytes); } +char* MetaspaceShared::read_only_space_top() { + return _ro_region.top(); +} + void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() { assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled"); @@ -456,6 +461,7 @@ void MetaspaceShared::serialize_well_known_classes(SerializeClosure* soc) { java_lang_StackFrameInfo::serialize(soc); java_lang_LiveStackFrameInfo::serialize(soc); java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(soc); + jdk_internal_module_ArchivedModuleGraph::serialize(soc); } address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) { @@ -1350,6 +1356,11 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables() { char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t)); SystemDictionary::copy_table(table_top, _ro_region.top()); + // Write the archived object sub-graph infos. For each klass with sub-graphs, + // the info includes the static fields (sub-graph entry points) and Klasses + // of objects included in the sub-graph. + HeapShared::write_archived_subgraph_infos(); + // Write the other data to the output array. WriteClosure wc(&_ro_region); MetaspaceShared::serialize(&wc); @@ -1861,6 +1872,8 @@ void MetaspaceShared::dump_open_archive_heap_objects( MetaspaceShared::archive_klass_objects(THREAD); + HeapShared::archive_module_graph_objects(THREAD); + G1CollectedHeap::heap()->end_archive_alloc_range(open_archive, os::vm_allocation_granularity()); } @@ -1906,14 +1919,16 @@ oop MetaspaceShared::archive_heap_object(oop obj, Thread* THREAD) { ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache(); cache->put(obj, archived_oop); } - log_debug(cds)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT, - p2i(obj), p2i(archived_oop)); + log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT, + p2i(obj), p2i(archived_oop)); return archived_oop; } oop MetaspaceShared::materialize_archived_object(oop obj) { - assert(obj != NULL, "sanity"); - return G1CollectedHeap::heap()->materialize_archived_object(obj); + if (obj != NULL) { + return G1CollectedHeap::heap()->materialize_archived_object(obj); + } + return NULL; } void MetaspaceShared::archive_klass_objects(Thread* THREAD) { @@ -2120,6 +2135,9 @@ void MetaspaceShared::initialize_shared_spaces() { buffer += sizeof(intptr_t); buffer += len; + // The table of archived java heap object sub-graph infos + buffer = HeapShared::read_archived_subgraph_infos(buffer); + // Verify various attributes of the archive, plus initialize the // shared string/symbol tables intptr_t* array = (intptr_t*)buffer; diff --git a/src/src/hotspot/share/memory/metaspaceShared.hpp b/src/src/hotspot/share/memory/metaspaceShared.hpp index 148e8170bd3..24ca193d1b7 100644 --- a/src/src/hotspot/share/memory/metaspaceShared.hpp +++ b/src/src/hotspot/share/memory/metaspaceShared.hpp @@ -232,6 +232,8 @@ class MetaspaceShared : AllStatic { static char* misc_code_space_alloc(size_t num_bytes); static char* read_only_space_alloc(size_t num_bytes); + static char* read_only_space_top(); + template static Array* new_ro_array(int length) { #if INCLUDE_CDS diff --git a/src/src/hotspot/share/oops/constantPool.cpp b/src/src/hotspot/share/oops/constantPool.cpp index e531669ee6a..6ebf9513bfe 100644 --- a/src/src/hotspot/share/oops/constantPool.cpp +++ b/src/src/hotspot/share/oops/constantPool.cpp @@ -750,6 +750,10 @@ Symbol* ConstantPool::exception_message(const constantPoolHandle& this_cp, int w // return the method type signature in the error message message = this_cp->method_type_signature_at(which); break; + case JVM_CONSTANT_Dynamic: + // return the name of the condy in the error message + message = this_cp->uncached_name_ref_at(which); + break; default: ShouldNotReachHere(); } diff --git a/src/src/hotspot/share/oops/instanceKlass.cpp b/src/src/hotspot/share/oops/instanceKlass.cpp index aad2d0504b2..fa5300e95a1 100644 --- a/src/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/src/hotspot/share/oops/instanceKlass.cpp @@ -411,6 +411,8 @@ InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, Klass _static_field_size(parser.static_field_size()), _nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())), _itable_len(parser.itable_size()), + _init_thread(NULL), + _init_state(allocated), _reference_type(parser.reference_type()), _nest_members(NULL), _nest_host_index(0), @@ -689,15 +691,6 @@ bool InstanceKlass::verify_code(bool throw_verifyerror, TRAPS) { return Verifier::verify(this, mode, should_verify_class(), THREAD); } - -// Used exclusively by the shared spaces dump mechanism to prevent -// classes mapped into the shared regions in new VMs from appearing linked. - -void InstanceKlass::unlink_class() { - assert(is_linked(), "must be linked"); - _init_state = loaded; -} - void InstanceKlass::link_class(TRAPS) { assert(is_loaded(), "must be loaded"); if (!is_linked()) { @@ -1049,11 +1042,13 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) Handle h_init_lock(THREAD, init_lock()); if (h_init_lock() != NULL) { ObjectLocker ol(h_init_lock, THREAD); + set_init_thread(NULL); // reset _init_thread before changing _init_state set_init_state(state); fence_and_clear_init_lock(); ol.notify_all(CHECK); } else { assert(h_init_lock() != NULL, "The initialization state should never be set twice"); + set_init_thread(NULL); // reset _init_thread before changing _init_state set_init_state(state); } } @@ -2302,10 +2297,12 @@ void InstanceKlass::remove_unshareable_info() { return; } - // Unlink the class - if (is_linked()) { - unlink_class(); - } + // Reset to the 'allocated' state to prevent any premature accessing to + // a shared class at runtime while the class is still being loaded and + // restored. A class' init_state is set to 'loaded' at runtime when it's + // being added to class hierarchy (see SystemDictionary:::add_to_hierarchy()). + _init_state = allocated; + { MutexLocker ml(Compile_lock); init_implementor(); @@ -2352,6 +2349,10 @@ void InstanceKlass::remove_java_mirror() { } void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { + // SystemDictionary::add_to_hierarchy() sets the init_state to loaded + // before the InstanceKlass is added to the SystemDictionary. Make + // sure the current state is method(), n->osr_entry_bci(), n->comp_level(), true); + assert(prev == NULL || !prev->is_in_use(), + "redundunt OSR recompilation detected. memory leak in CodeCache!"); + } +#endif // only one compilation can be active { // This is a short non-blocking critical region, so the no safepoint check is ok. @@ -3073,7 +3081,9 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le } osr = osr->osr_link(); } - if (best != NULL && best->comp_level() >= comp_level && match_level == false) { + + assert(match_level == false || best == NULL, "shouldn't pick up anything if match_level is set"); + if (best != NULL && best->comp_level() >= comp_level) { return best; } return NULL; @@ -3671,6 +3681,7 @@ void InstanceKlass::set_init_state(ClassState state) { bool good_state = is_shared() ? (_init_state <= state) : (_init_state < state); assert(good_state || state == allocated, "illegal state transition"); + assert(_init_thread == NULL, "should be cleared before state change"); _init_state = (u1)state; } #endif diff --git a/src/src/hotspot/share/oops/instanceKlass.hpp b/src/src/hotspot/share/oops/instanceKlass.hpp index ef61f94add4..ea7062cb3a5 100644 --- a/src/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/src/hotspot/share/oops/instanceKlass.hpp @@ -245,7 +245,7 @@ class InstanceKlass: public Klass { u2 _misc_flags; u2 _minor_version; // minor version number of class file u2 _major_version; // major version number of class file - Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) + Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization) OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily) JNIid* _jni_ids; // First JNI identifier for static fields in this class jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none @@ -542,7 +542,6 @@ class InstanceKlass: public Klass { void initialize(TRAPS); void link_class(TRAPS); bool link_class_or_fail(TRAPS); // returns false on failure - void unlink_class(); void rewrite_class(TRAPS); void link_methods(TRAPS); Method* class_initializer() const; diff --git a/src/src/hotspot/share/oops/klass.cpp b/src/src/hotspot/share/oops/klass.cpp index fb41a9930a2..0342e63159d 100644 --- a/src/src/hotspot/share/oops/klass.cpp +++ b/src/src/hotspot/share/oops/klass.cpp @@ -57,6 +57,10 @@ oop Klass::java_mirror() const { return _java_mirror.resolve(); } +oop Klass::java_mirror_no_keepalive() const { + return _java_mirror.peek(); +} + bool Klass::is_cloneable() const { return _access_flags.is_cloneable_fast() || is_subtype_of(SystemDictionary::Cloneable_klass()); @@ -693,7 +697,7 @@ void Klass::oop_print_value_on(oop obj, outputStream* st) { // Size Statistics void Klass::collect_statistics(KlassSizeStats *sz) const { sz->_klass_bytes = sz->count(this); - sz->_mirror_bytes = sz->count(java_mirror()); + sz->_mirror_bytes = sz->count(java_mirror_no_keepalive()); sz->_secondary_supers_bytes = sz->count_array(secondary_supers()); sz->_ro_bytes += sz->_secondary_supers_bytes; @@ -725,8 +729,8 @@ void Klass::verify_on(outputStream* st) { } } - if (java_mirror() != NULL) { - guarantee(oopDesc::is_oop(java_mirror()), "should be instance"); + if (java_mirror_no_keepalive() != NULL) { + guarantee(oopDesc::is_oop(java_mirror_no_keepalive()), "should be instance"); } } diff --git a/src/src/hotspot/share/oops/klass.hpp b/src/src/hotspot/share/oops/klass.hpp index fed70085305..6680b35fd14 100644 --- a/src/src/hotspot/share/oops/klass.hpp +++ b/src/src/hotspot/share/oops/klass.hpp @@ -258,6 +258,7 @@ class Klass : public Metadata { // java mirror oop java_mirror() const; + oop java_mirror_no_keepalive() const; void set_java_mirror(Handle m); oop archived_java_mirror_raw() NOT_CDS_JAVA_HEAP_RETURN_(NULL); // no GC barrier diff --git a/src/src/hotspot/share/oops/klassVtable.cpp b/src/src/hotspot/share/oops/klassVtable.cpp index d9d28eb5e90..6f44603f5ab 100644 --- a/src/src/hotspot/share/oops/klassVtable.cpp +++ b/src/src/hotspot/share/oops/klassVtable.cpp @@ -649,6 +649,7 @@ bool klassVtable::needs_new_vtable_entry(const methodHandle& target_method, Method* super_method = NULL; InstanceKlass *holder = NULL; Method* recheck_method = NULL; + bool found_pkg_prvt_method = false; while (k != NULL) { // lookup through the hierarchy for a method with matching name and sign. super_method = InstanceKlass::cast(k)->lookup_method(name, signature); @@ -670,6 +671,16 @@ bool klassVtable::needs_new_vtable_entry(const methodHandle& target_method, return false; // else keep looking for transitive overrides } + // If we get here then one of the super classes has a package private method + // that will not get overridden because it is in a different package. But, + // that package private method does "override" any matching methods in super + // interfaces, so there will be no miranda vtable entry created. So, set flag + // to TRUE for use below, in case there are no methods in super classes that + // this target method overrides. + assert(super_method->is_package_private(), "super_method must be package private"); + assert(!superk->is_same_class_package(classloader(), classname), + "Must be different packages"); + found_pkg_prvt_method = true; } // Start with lookup result and continue to search up, for versions supporting transitive override @@ -680,6 +691,15 @@ bool klassVtable::needs_new_vtable_entry(const methodHandle& target_method, } } + // If found_pkg_prvt_method is set, then the ONLY matching method in the + // superclasses is package private in another package. That matching method will + // prevent a miranda vtable entry from being created. Because the target method can not + // override the package private method in another package, then it needs to be the root + // for its own vtable entry. + if (found_pkg_prvt_method) { + return true; + } + // if the target method is public or protected it may have a matching // miranda method in the super, whose entry it should re-use. // Actually, to handle cases that javac would not generate, we need @@ -687,7 +707,7 @@ bool klassVtable::needs_new_vtable_entry(const methodHandle& target_method, const InstanceKlass *sk = InstanceKlass::cast(super); if (sk->has_miranda_methods()) { if (sk->lookup_method_in_all_interfaces(name, signature, Klass::find_defaults) != NULL) { - return false; // found a matching miranda; we do not need a new entry + return false; // found a matching miranda; we do not need a new entry } } return true; // found no match; we need a new entry diff --git a/src/src/hotspot/share/oops/markOop.hpp b/src/src/hotspot/share/oops/markOop.hpp index d49beb33bfc..649217c8808 100644 --- a/src/src/hotspot/share/oops/markOop.hpp +++ b/src/src/hotspot/share/oops/markOop.hpp @@ -138,23 +138,15 @@ class markOopDesc: public oopDesc { epoch_mask_in_place = epoch_mask << epoch_shift, cms_mask = right_n_bits(cms_bits), cms_mask_in_place = cms_mask << cms_shift -#ifndef _WIN64 - ,hash_mask = right_n_bits(hash_bits), - hash_mask_in_place = (address_word)hash_mask << hash_shift -#endif }; + const static uintptr_t hash_mask = right_n_bits(hash_bits); + const static uintptr_t hash_mask_in_place = hash_mask << hash_shift; + // Alignment of JavaThread pointers encoded in object header required by biased locking enum { biased_lock_alignment = 2 << (epoch_shift + epoch_bits) }; -#ifdef _WIN64 - // These values are too big for Win64 - const static uintptr_t hash_mask = right_n_bits(hash_bits); - const static uintptr_t hash_mask_in_place = - (address_word)hash_mask << hash_shift; -#endif - enum { locked_value = 0, unlocked_value = 1, monitor_value = 2, diff --git a/src/src/hotspot/share/oops/methodData.cpp b/src/src/hotspot/share/oops/methodData.cpp index 0be0f66b964..6b99eb16594 100644 --- a/src/src/hotspot/share/oops/methodData.cpp +++ b/src/src/hotspot/share/oops/methodData.cpp @@ -1526,11 +1526,14 @@ bool MethodData::profile_jsr292(const methodHandle& m, int bci) { bool MethodData::profile_unsafe(const methodHandle& m, int bci) { Bytecode_invoke inv(m , bci); - if (inv.is_invokevirtual() && inv.klass() == vmSymbols::jdk_internal_misc_Unsafe()) { - ResourceMark rm; - char* name = inv.name()->as_C_string(); - if (!strncmp(name, "get", 3) || !strncmp(name, "put", 3)) { - return true; + if (inv.is_invokevirtual()) { + if (inv.klass() == vmSymbols::jdk_internal_misc_Unsafe() || + inv.klass() == vmSymbols::sun_misc_Unsafe()) { + ResourceMark rm; + char* name = inv.name()->as_C_string(); + if (!strncmp(name, "get", 3) || !strncmp(name, "put", 3)) { + return true; + } } } return false; diff --git a/src/src/hotspot/share/oops/oopHandle.hpp b/src/src/hotspot/share/oops/oopHandle.hpp index d2a1bd25151..e822d3710c9 100644 --- a/src/src/hotspot/share/oops/oopHandle.hpp +++ b/src/src/hotspot/share/oops/oopHandle.hpp @@ -44,6 +44,7 @@ class OopHandle { OopHandle(oop* w) : _obj(w) {} inline oop resolve() const; + inline oop peek() const; // Used only for removing handle. oop* ptr_raw() const { return _obj; } diff --git a/src/src/hotspot/share/oops/oopHandle.inline.hpp b/src/src/hotspot/share/oops/oopHandle.inline.hpp index 0adc46b3d83..db51413d2b8 100644 --- a/src/src/hotspot/share/oops/oopHandle.inline.hpp +++ b/src/src/hotspot/share/oops/oopHandle.inline.hpp @@ -32,5 +32,8 @@ inline oop OopHandle::resolve() const { return (_obj == NULL) ? (oop)NULL : NativeAccess<>::oop_load(_obj); } -#endif // SHARE_VM_OOPS_OOPHANDLE_INLINE_HPP +inline oop OopHandle::peek() const { + return (_obj == NULL) ? (oop)NULL : NativeAccess::oop_load(_obj); +} +#endif // SHARE_VM_OOPS_OOPHANDLE_INLINE_HPP diff --git a/src/src/hotspot/share/opto/c2compiler.cpp b/src/src/hotspot/share/opto/c2compiler.cpp index 0cdd8b9c0ab..7973a6b510c 100644 --- a/src/src/hotspot/share/opto/c2compiler.cpp +++ b/src/src/hotspot/share/opto/c2compiler.cpp @@ -616,7 +616,9 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt return true; } -int C2Compiler::initial_code_buffer_size() { - assert(SegmentedCodeCache, "Should be only used with a segmented code cache"); - return Compile::MAX_inst_size + Compile::MAX_locs_size + initial_const_capacity; +int C2Compiler::initial_code_buffer_size(int const_size) { + // See Compile::init_scratch_buffer_blob + int locs_size = sizeof(relocInfo) * Compile::MAX_locs_size; + int slop = 2 * CodeSection::end_slop(); // space between sections + return Compile::MAX_inst_size + Compile::MAX_stubs_size + const_size + slop + locs_size; } diff --git a/src/src/hotspot/share/opto/c2compiler.hpp b/src/src/hotspot/share/opto/c2compiler.hpp index d7eb0225841..33193bde3e5 100644 --- a/src/src/hotspot/share/opto/c2compiler.hpp +++ b/src/src/hotspot/share/opto/c2compiler.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_OPTO_C2COMPILER_HPP #include "compiler/abstractCompiler.hpp" +#include "opto/output.hpp" class C2Compiler : public AbstractCompiler { private: @@ -66,7 +67,7 @@ class C2Compiler : public AbstractCompiler { virtual bool is_intrinsic_supported(const methodHandle& method, bool is_virtual); // Initial size of the code buffer (may be increased at runtime) - static int initial_code_buffer_size(); + static int initial_code_buffer_size(int const_size = initial_const_capacity); }; #endif // SHARE_VM_OPTO_C2COMPILER_HPP diff --git a/src/src/hotspot/share/opto/callGenerator.cpp b/src/src/hotspot/share/opto/callGenerator.cpp index b778b5ebfe9..ffe50ed8689 100644 --- a/src/src/hotspot/share/opto/callGenerator.cpp +++ b/src/src/hotspot/share/opto/callGenerator.cpp @@ -46,9 +46,17 @@ const TypeFunc* CallGenerator::tf() const { return TypeFunc::make(method()); } -bool CallGenerator::is_inlined_method_handle_intrinsic(JVMState* jvms, ciMethod* callee) { - ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci()); - return symbolic_info->is_method_handle_intrinsic() && !callee->is_method_handle_intrinsic(); +bool CallGenerator::is_inlined_method_handle_intrinsic(JVMState* jvms, ciMethod* m) { + return is_inlined_method_handle_intrinsic(jvms->method(), jvms->bci(), m); +} + +bool CallGenerator::is_inlined_method_handle_intrinsic(ciMethod* caller, int bci, ciMethod* m) { + ciMethod* symbolic_info = caller->get_method_at_bci(bci); + return is_inlined_method_handle_intrinsic(symbolic_info, m); +} + +bool CallGenerator::is_inlined_method_handle_intrinsic(ciMethod* symbolic_info, ciMethod* m) { + return symbolic_info->is_method_handle_intrinsic() && !m->is_method_handle_intrinsic(); } //-----------------------------ParseGenerator--------------------------------- diff --git a/src/src/hotspot/share/opto/callGenerator.hpp b/src/src/hotspot/share/opto/callGenerator.hpp index 8b7ee546571..d7a9f1196af 100644 --- a/src/src/hotspot/share/opto/callGenerator.hpp +++ b/src/src/hotspot/share/opto/callGenerator.hpp @@ -176,6 +176,8 @@ class CallGenerator : public ResourceObj { } static bool is_inlined_method_handle_intrinsic(JVMState* jvms, ciMethod* m); + static bool is_inlined_method_handle_intrinsic(ciMethod* caller, int bci, ciMethod* m); + static bool is_inlined_method_handle_intrinsic(ciMethod* symbolic_info, ciMethod* m); }; diff --git a/src/src/hotspot/share/opto/callnode.cpp b/src/src/hotspot/share/opto/callnode.cpp index 0087c261d1c..383e97f3554 100644 --- a/src/src/hotspot/share/opto/callnode.cpp +++ b/src/src/hotspot/share/opto/callnode.cpp @@ -965,6 +965,21 @@ uint CallJavaNode::cmp( const Node &n ) const { return CallNode::cmp(call) && _method == call._method && _override_symbolic_info == call._override_symbolic_info; } +#ifdef ASSERT +bool CallJavaNode::validate_symbolic_info() const { + if (method() == NULL) { + return true; // call into runtime or uncommon trap + } + ciMethod* symbolic_info = jvms()->method()->get_method_at_bci(_bci); + ciMethod* callee = method(); + if (symbolic_info->is_method_handle_intrinsic() && !callee->is_method_handle_intrinsic()) { + assert(override_symbolic_info(), "should be set"); + } + assert(ciMethod::is_consistent_info(symbolic_info, callee), "inconsistent info"); + return true; +} +#endif + #ifndef PRODUCT void CallJavaNode::dump_spec(outputStream *st) const { if( _method ) _method->print_short_name(st); diff --git a/src/src/hotspot/share/opto/callnode.hpp b/src/src/hotspot/share/opto/callnode.hpp index f5cc9bcf237..7e59f7e448f 100644 --- a/src/src/hotspot/share/opto/callnode.hpp +++ b/src/src/hotspot/share/opto/callnode.hpp @@ -681,6 +681,8 @@ class CallJavaNode : public CallNode { void set_override_symbolic_info(bool f) { _override_symbolic_info = f; } bool override_symbolic_info() const { return _override_symbolic_info; } + DEBUG_ONLY( bool validate_symbolic_info() const; ) + #ifndef PRODUCT virtual void dump_spec(outputStream *st) const; virtual void dump_compact_spec(outputStream *st) const; diff --git a/src/src/hotspot/share/opto/compile.cpp b/src/src/hotspot/share/opto/compile.cpp index 6d7968e6eba..8534899d32d 100644 --- a/src/src/hotspot/share/opto/compile.cpp +++ b/src/src/hotspot/share/opto/compile.cpp @@ -544,7 +544,7 @@ void Compile::init_scratch_buffer_blob(int const_size) { ResourceMark rm; _scratch_const_size = const_size; - int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); + int size = C2Compiler::initial_code_buffer_size(const_size); blob = BufferBlob::create("Compile::scratch_buffer", size); // Record the buffer blob for next time. set_scratch_buffer_blob(blob); @@ -2758,6 +2758,17 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { LoadNode::is_immutable_value(n->in(MemNode::Address))), "raw memory operations should have control edge"); } + if (n->is_MemBar()) { + MemBarNode* mb = n->as_MemBar(); + if (mb->trailing_store() || mb->trailing_load_store()) { + assert(mb->leading_membar()->trailing_membar() == mb, "bad membar pair"); + Node* mem = mb->in(MemBarNode::Precedent); + assert((mb->trailing_store() && mem->is_Store() && mem->as_Store()->is_release()) || + (mb->trailing_load_store() && mem->is_LoadStore()), "missing mem op"); + } else if (mb->leading()) { + assert(mb->trailing_membar()->leading_membar() == mb, "bad membar pair"); + } + } #endif // Count FPU ops and common calls, implements item (3) switch( nop ) { @@ -3350,6 +3361,32 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { n->set_req(MemBarNode::Precedent, top()); } break; + case Op_MemBarAcquire: { + if (n->as_MemBar()->trailing_load() && n->req() > MemBarNode::Precedent) { + // At parse time, the trailing MemBarAcquire for a volatile load + // is created with an edge to the load. After optimizations, + // that input may be a chain of Phis. If those phis have no + // other use, then the MemBarAcquire keeps them alive and + // register allocation can be confused. + ResourceMark rm; + Unique_Node_List wq; + wq.push(n->in(MemBarNode::Precedent)); + n->set_req(MemBarNode::Precedent, top()); + while (wq.size() > 0) { + Node* m = wq.pop(); + if (m->outcnt() == 0) { + for (uint j = 0; j < m->req(); j++) { + Node* in = m->in(j); + if (in != NULL) { + wq.push(in); + } + } + m->disconnect_inputs(NULL, this); + } + } + } + break; + } case Op_RangeCheck: { RangeCheckNode* rc = n->as_RangeCheck(); Node* iff = new IfNode(rc->in(0), rc->in(1), rc->_prob, rc->_fcnt); diff --git a/src/src/hotspot/share/opto/compile.hpp b/src/src/hotspot/share/opto/compile.hpp index 302e2802eb0..446324ec473 100644 --- a/src/src/hotspot/share/opto/compile.hpp +++ b/src/src/hotspot/share/opto/compile.hpp @@ -1014,6 +1014,11 @@ class Compile : public Phase { ciMethodData* logmd = NULL); // Report if there were too many recompiles at a method and bci. bool too_many_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason); + // Report if there were too many traps or recompiles at a method and bci. + bool too_many_traps_or_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason) { + return too_many_traps(method, bci, reason) || + too_many_recompiles(method, bci, reason); + } // Return a bitset with the reasons where deoptimization is allowed, // i.e., where there were not too many uncommon traps. int _allowed_reasons; diff --git a/src/src/hotspot/share/opto/convertnode.cpp b/src/src/hotspot/share/opto/convertnode.cpp index aaf0cc2fc61..dab3cfbac71 100644 --- a/src/src/hotspot/share/opto/convertnode.cpp +++ b/src/src/hotspot/share/opto/convertnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -393,7 +393,11 @@ Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow"); assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow"); Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), NULL); + Node *hook = new Node(1); + hook->init_req(0, cx); // Add a use to cx to prevent him from dying Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), NULL); + hook->del_req(0); // Just yank bogus edge + hook->destruct(); switch (op) { case Op_AddI: return new AddLNode(cx, cy); case Op_SubI: return new SubLNode(cx, cy); diff --git a/src/src/hotspot/share/opto/doCall.cpp b/src/src/hotspot/share/opto/doCall.cpp index 0448236137b..246657316ec 100644 --- a/src/src/hotspot/share/opto/doCall.cpp +++ b/src/src/hotspot/share/opto/doCall.cpp @@ -209,7 +209,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool int morphism = profile.morphism(); if (speculative_receiver_type != NULL) { - if (!too_many_traps(caller, bci, Deoptimization::Reason_speculate_class_check)) { + if (!too_many_traps_or_recompiles(caller, bci, Deoptimization::Reason_speculate_class_check)) { // We have a speculative type, we should be able to resolve // the call. We do that before looking at the profiling at // this invoke because it may lead to bimorphic inlining which @@ -261,7 +261,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool Deoptimization::DeoptReason reason = morphism == 2 ? Deoptimization::Reason_bimorphic : Deoptimization::reason_class_check(speculative_receiver_type != NULL); if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) && - !too_many_traps(caller, bci, reason) + !too_many_traps_or_recompiles(caller, bci, reason) ) { // Generate uncommon trap for class check failure path // in case of monomorphic or bimorphic virtual call site. diff --git a/src/src/hotspot/share/opto/escape.cpp b/src/src/hotspot/share/opto/escape.cpp index 83047cb1fe9..dc77f1a0c18 100644 --- a/src/src/hotspot/share/opto/escape.cpp +++ b/src/src/hotspot/share/opto/escape.cpp @@ -1767,7 +1767,8 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj) { } for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { - if (n->fast_out(i)->is_LoadStore()) { + Node* u = n->fast_out(i); + if (u->is_LoadStore() || (u->is_Mem() && u->as_Mem()->is_mismatched_access())) { jobj->set_scalar_replaceable(false); return; } @@ -3046,6 +3047,11 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist, n->raise_bottom_type(tinst); igvn->hash_insert(n); record_for_optimizer(n); + // Allocate an alias index for the header fields. Accesses to + // the header emitted during macro expansion wouldn't have + // correct memory state otherwise. + _compile->get_alias_index(tinst->add_offset(oopDesc::mark_offset_in_bytes())); + _compile->get_alias_index(tinst->add_offset(oopDesc::klass_offset_in_bytes())); if (alloc->is_Allocate() && (t->isa_instptr() || t->isa_aryptr())) { // First, put on the worklist all Field edges from Connection Graph diff --git a/src/src/hotspot/share/opto/graphKit.cpp b/src/src/hotspot/share/opto/graphKit.cpp index de27cb49d42..63fb502f998 100644 --- a/src/src/hotspot/share/opto/graphKit.cpp +++ b/src/src/hotspot/share/opto/graphKit.cpp @@ -1489,18 +1489,19 @@ Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, LoadNode::ControlDependency control_dependency, bool require_atomic_access, bool unaligned, - bool mismatched) { + bool mismatched, + bool unsafe) { assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" ); const TypePtr* adr_type = NULL; // debug-mode-only argument debug_only(adr_type = C->get_adr_type(adr_idx)); Node* mem = memory(adr_idx); Node* ld; if (require_atomic_access && bt == T_LONG) { - ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched); + ld = LoadLNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe); } else if (require_atomic_access && bt == T_DOUBLE) { - ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched); + ld = LoadDNode::make_atomic(ctl, mem, adr, adr_type, t, mo, control_dependency, unaligned, mismatched, unsafe); } else { - ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched); + ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, mo, control_dependency, unaligned, mismatched, unsafe); } ld = _gvn.transform(ld); if (((bt == T_OBJECT) && C->do_escape_analysis()) || C->eliminate_boxing()) { @@ -1515,7 +1516,8 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt, MemNode::MemOrd mo, bool require_atomic_access, bool unaligned, - bool mismatched) { + bool mismatched, + bool unsafe) { assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); const TypePtr* adr_type = NULL; debug_only(adr_type = C->get_adr_type(adr_idx)); @@ -1534,6 +1536,9 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt, if (mismatched) { st->as_Store()->set_mismatched_access(); } + if (unsafe) { + st->as_Store()->set_unsafe_access(); + } st = _gvn.transform(st); set_memory(st, adr_idx); // Back-to-back stores can only remove intermediate store with DU info @@ -1790,12 +1795,13 @@ Node* GraphKit::set_results_for_java_call(CallJavaNode* call, bool separate_io_p // A better answer would be to separate out card marks from other memory. // For now, return the input memory state, so that it can be reused // after the call, if this call has restricted memory effects. -Node* GraphKit::set_predefined_input_for_runtime_call(SafePointNode* call) { +Node* GraphKit::set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem) { // Set fixed predefined input arguments Node* memory = reset_memory(); + Node* m = narrow_mem == NULL ? memory : narrow_mem; call->init_req( TypeFunc::Control, control() ); call->init_req( TypeFunc::I_O, top() ); // does no i/o - call->init_req( TypeFunc::Memory, memory ); // may gc ptrs + call->init_req( TypeFunc::Memory, m ); // may gc ptrs call->init_req( TypeFunc::FramePtr, frameptr() ); call->init_req( TypeFunc::ReturnAdr, top() ); return memory; @@ -2453,9 +2459,7 @@ Node* GraphKit::make_runtime_call(int flags, } else { assert(!wide_out, "narrow in => narrow out"); Node* narrow_mem = memory(adr_type); - prev_mem = reset_memory(); - map()->set_memory(narrow_mem); - set_predefined_input_for_runtime_call(call); + prev_mem = set_predefined_input_for_runtime_call(call, narrow_mem); } // Hook each parm in order. Stop looking at the first NULL. @@ -2816,7 +2820,7 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, Deoptimization::DeoptReason reason = Deoptimization::reason_class_check(spec_klass != NULL); // Make sure we haven't already deoptimized from this tactic. - if (too_many_traps(reason) || too_many_recompiles(reason)) + if (too_many_traps_or_recompiles(reason)) return NULL; // (No, this isn't a call, but it's enough like a virtual call @@ -2871,9 +2875,8 @@ Node* GraphKit::maybe_cast_profiled_obj(Node* obj, Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check; Deoptimization::DeoptReason null_reason = Deoptimization::Reason_speculate_null_check; - if (!too_many_traps(null_reason) && !too_many_recompiles(null_reason) && - !too_many_traps(class_reason) && - !too_many_recompiles(class_reason)) { + if (!too_many_traps_or_recompiles(null_reason) && + !too_many_traps_or_recompiles(class_reason)) { Node* not_null_obj = NULL; // not_null is true if we know the object is not null and // there's no need for a null check @@ -2898,8 +2901,7 @@ Node* GraphKit::maybe_cast_profiled_obj(Node* obj, obj = exact_obj; } } else { - if (!too_many_traps(Deoptimization::Reason_null_assert) && - !too_many_recompiles(Deoptimization::Reason_null_assert)) { + if (!too_many_traps_or_recompiles(Deoptimization::Reason_null_assert)) { Node* exact_obj = null_assert(obj); replace_in_map(obj, exact_obj); obj = exact_obj; @@ -3390,6 +3392,10 @@ Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, record_for_igvn(minit_in); // fold it up later, if possible Node* minit_out = memory(rawidx); assert(minit_out->is_Proj() && minit_out->in(0) == init, ""); + // Add an edge in the MergeMem for the header fields so an access + // to one of those has correct memory state + set_memory(minit_out, C->get_alias_index(oop_type->add_offset(oopDesc::mark_offset_in_bytes()))); + set_memory(minit_out, C->get_alias_index(oop_type->add_offset(oopDesc::klass_offset_in_bytes()))); if (oop_type->isa_aryptr()) { const TypePtr* telemref = oop_type->add_offset(Type::OffsetBot); int elemidx = C->get_alias_index(telemref); diff --git a/src/src/hotspot/share/opto/graphKit.hpp b/src/src/hotspot/share/opto/graphKit.hpp index 85172027e6f..1d003816c3f 100644 --- a/src/src/hotspot/share/opto/graphKit.hpp +++ b/src/src/hotspot/share/opto/graphKit.hpp @@ -518,27 +518,27 @@ class GraphKit : public Phase { Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false) { + bool mismatched = false, bool unsafe = false) { // This version computes alias_index from bottom_type return make_load(ctl, adr, t, bt, adr->bottom_type()->is_ptr(), mo, control_dependency, require_atomic_access, - unaligned, mismatched); + unaligned, mismatched, unsafe); } Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, const TypePtr* adr_type, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false) { + bool mismatched = false, bool unsafe = false) { // This version computes alias_index from an address type assert(adr_type != NULL, "use other make_load factory"); return make_load(ctl, adr, t, bt, C->get_alias_index(adr_type), mo, control_dependency, require_atomic_access, - unaligned, mismatched); + unaligned, mismatched, unsafe); } // This is the base version which is given an alias index. Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, int adr_idx, MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false); + bool mismatched = false, bool unsafe = false); // Create & transform a StoreNode and store the effect into the // parser's memory state. @@ -553,13 +553,14 @@ class GraphKit : public Phase { MemNode::MemOrd mo, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false) { + bool mismatched = false, + bool unsafe = false) { // This version computes alias_index from an address type assert(adr_type != NULL, "use other store_to_memory factory"); return store_to_memory(ctl, adr, val, bt, C->get_alias_index(adr_type), mo, require_atomic_access, - unaligned, mismatched); + unaligned, mismatched, unsafe); } // This is the base version which is given alias index // Return the new StoreXNode @@ -568,7 +569,8 @@ class GraphKit : public Phase { MemNode::MemOrd, bool require_atomic_access = false, bool unaligned = false, - bool mismatched = false); + bool mismatched = false, + bool unsafe = false); // Perform decorated accesses @@ -697,7 +699,7 @@ class GraphKit : public Phase { void set_predefined_output_for_runtime_call(Node* call, Node* keep_mem, const TypePtr* hook_mem); - Node* set_predefined_input_for_runtime_call(SafePointNode* call); + Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = NULL); // Replace the call with the current state of the kit. Requires // that the call was generated with separate io_projs so that @@ -749,6 +751,10 @@ class GraphKit : public Phase { return C->too_many_recompiles(method(), bci(), reason); } + bool too_many_traps_or_recompiles(Deoptimization::DeoptReason reason) { + return C->too_many_traps_or_recompiles(method(), bci(), reason); + } + // Returns the object (if any) which was created the moment before. Node* just_allocated_object(Node* current_control); diff --git a/src/src/hotspot/share/opto/ifnode.cpp b/src/src/hotspot/share/opto/ifnode.cpp index 0619cc30c3f..4342ba18159 100644 --- a/src/src/hotspot/share/opto/ifnode.cpp +++ b/src/src/hotspot/share/opto/ifnode.cpp @@ -633,7 +633,7 @@ Node* IfNode::up_one_dom(Node *curr, bool linear_only) { if( din4->is_Call() && // Handle a slow-path call on either arm (din4 = din4->in(0)) ) din4 = din4->in(0); - if( din3 == din4 && din3->is_If() ) + if (din3 != NULL && din3 == din4 && din3->is_If()) // Regions not degraded to a copy return din3; // Skip around diamonds } diff --git a/src/src/hotspot/share/opto/library_call.cpp b/src/src/hotspot/share/opto/library_call.cpp index ee5bc9d01f6..3b8cd93749a 100644 --- a/src/src/hotspot/share/opto/library_call.cpp +++ b/src/src/hotspot/share/opto/library_call.cpp @@ -1107,6 +1107,9 @@ bool LibraryCallKit::inline_string_compareTo(StrIntrinsicNode::ArgEnc ae) { Node* arg1 = argument(0); Node* arg2 = argument(1); + arg1 = must_be_not_null(arg1, true); + arg2 = must_be_not_null(arg2, true); + // Get start addr and length of first argument Node* arg1_start = array_element_address(arg1, intcon(0), T_BYTE); Node* arg1_cnt = load_array_length(arg1); @@ -1130,6 +1133,10 @@ bool LibraryCallKit::inline_string_equals(StrIntrinsicNode::ArgEnc ae) { Node* phi = new PhiNode(region, TypeInt::BOOL); if (!stopped()) { + + arg1 = must_be_not_null(arg1, true); + arg2 = must_be_not_null(arg2, true); + // Get start addr and length of first argument Node* arg1_start = array_element_address(arg1, intcon(0), T_BYTE); Node* arg1_cnt = load_array_length(arg1); @@ -1189,6 +1196,8 @@ bool LibraryCallKit::inline_hasNegatives() { Node* offset = argument(1); Node* len = argument(2); + ba = must_be_not_null(ba, true); + // Range checks generate_string_range_check(ba, offset, len, false); if (stopped()) { @@ -1261,6 +1270,9 @@ bool LibraryCallKit::inline_string_indexOf(StrIntrinsicNode::ArgEnc ae) { RegionNode* result_rgn = new RegionNode(4); Node* result_phi = new PhiNode(result_rgn, TypeInt::INT); + src = must_be_not_null(src, true); + tgt = must_be_not_null(tgt, true); + // Get start addr and length of source string Node* src_start = array_element_address(src, intcon(0), T_BYTE); Node* src_count = load_array_length(src); @@ -1305,6 +1317,9 @@ bool LibraryCallKit::inline_string_indexOfI(StrIntrinsicNode::ArgEnc ae) { Node* tgt_count = argument(3); // char count Node* from_index = argument(4); // char index + src = must_be_not_null(src, true); + tgt = must_be_not_null(tgt, true); + // Multiply byte array index by 2 if String is UTF16 encoded Node* src_offset = (ae == StrIntrinsicNode::LL) ? from_index : _gvn.transform(new LShiftINode(from_index, intcon(1))); src_count = _gvn.transform(new SubINode(src_count, from_index)); @@ -1390,6 +1405,8 @@ bool LibraryCallKit::inline_string_indexOfChar() { Node* from_index = argument(2); Node* max = argument(3); + src = must_be_not_null(src, true); + Node* src_offset = _gvn.transform(new LShiftINode(from_index, intcon(1))); Node* src_start = array_element_address(src, src_offset, T_BYTE); Node* src_count = _gvn.transform(new SubINode(max, from_index)); @@ -1460,6 +1477,9 @@ bool LibraryCallKit::inline_string_copy(bool compress) { (!compress && src_elem == T_BYTE && (dst_elem == T_BYTE || dst_elem == T_CHAR)), "Unsupported array types for inline_string_copy"); + src = must_be_not_null(src, true); + dst = must_be_not_null(dst, true); + // Convert char[] offsets to byte[] offsets bool convert_src = (compress && src_elem == T_BYTE); bool convert_dst = (!compress && dst_elem == T_BYTE); @@ -1716,6 +1736,8 @@ bool LibraryCallKit::inline_string_char_access(bool is_store) { return false; } + value = must_be_not_null(value, true); + Node* adr = array_element_address(value, index, T_CHAR); if (adr->is_top()) { return false; @@ -2365,7 +2387,10 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c val = is_store ? argument(4) : NULL; - const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); + const TypePtr* adr_type = _gvn.type(adr)->isa_ptr(); + if (adr_type == TypePtr::NULL_PTR) { + return false; // off-heap access with zero address + } // Try to categorize the address. Compile::AliasType* alias_type = C->alias_type(adr_type); @@ -3789,6 +3814,13 @@ LibraryCallKit::generate_method_call(vmIntrinsics::ID method_id, bool is_virtual method, bci()); slow_call->set_optimized_virtual(true); } + if (CallGenerator::is_inlined_method_handle_intrinsic(this->method(), bci(), callee())) { + // To be able to issue a direct call (optimized virtual or virtual) + // and skip a call to MH.linkTo*/invokeBasic adapter, additional information + // about the method being invoked should be attached to the call site to + // make resolution logic work (see SharedRuntime::resolve_{virtual,opt_virtual}_call_C). + slow_call->set_override_symbolic_info(true); + } set_arguments_for_java_call(slow_call); set_edges_for_java_call(slow_call); return slow_call; @@ -4873,6 +4905,9 @@ bool LibraryCallKit::inline_encodeISOArray() { Node *dst_offset = argument(3); Node *length = argument(4); + src = must_be_not_null(src, true); + dst = must_be_not_null(dst, true); + const Type* src_type = src->Value(&_gvn); const Type* dst_type = dst->Value(&_gvn); const TypeAryPtr* top_src = src_type->isa_aryptr(); @@ -4925,6 +4960,9 @@ bool LibraryCallKit::inline_multiplyToLen() { Node* ylen = argument(3); Node* z = argument(4); + x = must_be_not_null(x, true); + y = must_be_not_null(y, true); + const Type* x_type = x->Value(&_gvn); const Type* y_type = y->Value(&_gvn); const TypeAryPtr* top_x = x_type->isa_aryptr(); @@ -4970,7 +5008,12 @@ bool LibraryCallKit::inline_multiplyToLen() { } __ else_(); { // Update graphKit memory and control from IdealKit. sync_kit(ideal); - Node* zlen_arg = load_array_length(z); + Node *cast = new CastPPNode(z, TypePtr::NOTNULL); + cast->init_req(0, control()); + _gvn.set_type(cast, cast->bottom_type()); + C->record_for_igvn(cast); + + Node* zlen_arg = load_array_length(cast); // Update IdealKit memory and control from graphKit. __ sync_kit(this); __ if_then(zlen_arg, BoolTest::lt, zlen); { @@ -5025,6 +5068,9 @@ bool LibraryCallKit::inline_squareToLen() { Node* z = argument(2); Node* zlen = argument(3); + x = must_be_not_null(x, true); + z = must_be_not_null(z, true); + const Type* x_type = x->Value(&_gvn); const Type* z_type = z->Value(&_gvn); const TypeAryPtr* top_x = x_type->isa_aryptr(); @@ -5072,6 +5118,8 @@ bool LibraryCallKit::inline_mulAdd() { Node* len = argument(3); Node* k = argument(4); + out = must_be_not_null(out, true); + const Type* out_type = out->Value(&_gvn); const Type* in_type = in->Value(&_gvn); const TypeAryPtr* top_out = out_type->isa_aryptr(); @@ -5324,6 +5372,7 @@ bool LibraryCallKit::inline_updateBytesCRC32() { } // 'src_start' points to src array + scaled offset + src = must_be_not_null(src, true); Node* src_start = array_element_address(src, offset, src_elem); // We assume that range check is done by caller. @@ -5412,10 +5461,12 @@ bool LibraryCallKit::inline_updateBytesCRC32C() { } // 'src_start' points to src array + scaled offset + src = must_be_not_null(src, true); Node* src_start = array_element_address(src, offset, src_elem); // static final int[] byteTable in class CRC32C Node* table = get_table_from_crc32c_class(callee()->holder()); + table = must_be_not_null(table, true); Node* table_start = array_element_address(table, intcon(0), T_INT); // We assume that range check is done by caller. @@ -5459,6 +5510,7 @@ bool LibraryCallKit::inline_updateDirectByteBufferCRC32C() { // static final int[] byteTable in class CRC32C Node* table = get_table_from_crc32c_class(callee()->holder()); + table = must_be_not_null(table, true); Node* table_start = array_element_address(table, intcon(0), T_INT); // Call the stub. @@ -5702,6 +5754,9 @@ bool LibraryCallKit::inline_aescrypt_Block(vmIntrinsics::ID id) { Node* dest = argument(3); Node* dest_offset = argument(4); + src = must_be_not_null(src, true); + dest = must_be_not_null(dest, true); + // (1) src and dest are arrays. const Type* src_type = src->Value(&_gvn); const Type* dest_type = dest->Value(&_gvn); @@ -5772,6 +5827,9 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) { Node* dest = argument(4); Node* dest_offset = argument(5); + src = must_be_not_null(src, false); + dest = must_be_not_null(dest, false); + // (1) src and dest are arrays. const Type* src_type = src->Value(&_gvn); const Type* dest_type = dest->Value(&_gvn); @@ -5977,6 +6035,9 @@ Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypt // The receiver was checked for NULL already. Node* objCBC = argument(0); + Node* src = argument(1); + Node* dest = argument(4); + // Load embeddedCipher field of CipherBlockChaining object. Node* embeddedCipherObj = load_field_from_object(objCBC, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false); @@ -5995,6 +6056,10 @@ Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypt set_control(top()); // no regular fast path return ctrl; } + + src = must_be_not_null(src, true); + dest = must_be_not_null(dest, true); + ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt))); @@ -6012,8 +6077,7 @@ Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypt // see the original java code for why. RegionNode* region = new RegionNode(3); region->init_req(1, instof_false); - Node* src = argument(1); - Node* dest = argument(4); + Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest)); Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq)); Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN); @@ -6080,6 +6144,10 @@ bool LibraryCallKit::inline_ghash_processBlocks() { Node* state = argument(3); Node* subkeyH = argument(4); + state = must_be_not_null(state, true); + subkeyH = must_be_not_null(subkeyH, true); + data = must_be_not_null(data, true); + Node* state_start = array_element_address(state, intcon(0), T_LONG); assert(state_start, "state is NULL"); Node* subkeyH_start = array_element_address(subkeyH, intcon(0), T_LONG); @@ -6153,6 +6221,7 @@ bool LibraryCallKit::inline_sha_implCompress(vmIntrinsics::ID id) { return false; } // 'src_start' points to src array + offset + src = must_be_not_null(src, true); Node* src_start = array_element_address(src, ofs, src_elem); Node* state = NULL; address stubAddr; @@ -6222,6 +6291,7 @@ bool LibraryCallKit::inline_digestBase_implCompressMB(int predicate) { return false; } // 'src_start' points to src array + offset + src = must_be_not_null(src, false); Node* src_start = array_element_address(src, ofs, src_elem); const char* klass_SHA_name = NULL; diff --git a/src/src/hotspot/share/opto/loopTransform.cpp b/src/src/hotspot/share/opto/loopTransform.cpp index 16dceea5316..022364ad2fa 100644 --- a/src/src/hotspot/share/opto/loopTransform.cpp +++ b/src/src/hotspot/share/opto/loopTransform.cpp @@ -354,6 +354,10 @@ bool IdealLoopTree::policy_peeling( PhaseIdealLoop *phase ) const { // check for vectorized loops, any peeling done was already applied if (_head->is_CountedLoop() && _head->as_CountedLoop()->do_unroll_only()) return false; + if (_head->is_CountedLoop() && _head->as_CountedLoop()->trip_count() == 1) { + return false; + } + while( test != _head ) { // Scan till run off top of loop if( test->is_If() ) { // Test? Node *ctrl = phase->get_ctrl(test->in(1)); @@ -2035,13 +2039,20 @@ void PhaseIdealLoop::mark_reductions(IdealLoopTree *loop) { //------------------------------adjust_limit----------------------------------- // Helper function for add_constraint(). -Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl) { +Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl, bool round_up) { // Compute "I :: (limit-offset)/scale" Node *con = new SubINode(rc_limit, offset); register_new_node(con, pre_ctrl); Node *X = new DivINode(0, con, scale); register_new_node(X, pre_ctrl); + // When the absolute value of scale is greater than one, the integer + // division may round limit down so add one to the limit. + if (round_up) { + X = new AddINode(X, _igvn.intcon(1)); + register_new_node(X, pre_ctrl); + } + // Adjust loop limit loop_limit = (stride_con > 0) ? (Node*)(new MinINode(loop_limit, X)) @@ -2082,7 +2093,7 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // (upper_limit-offset) may overflow or underflow. // But it is fine since main loop will either have // less iterations or will be skipped in such case. - *main_limit = adjust_limit(stride_con, scale, offset, upper_limit, *main_limit, pre_ctrl); + *main_limit = adjust_limit(stride_con, scale, offset, upper_limit, *main_limit, pre_ctrl, false); // The underflow limit: low_limit <= scale*I+offset. // For pre-loop compute @@ -2117,7 +2128,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // max(pre_limit, original_limit) is used in do_range_check(). } // Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond); - *pre_limit = adjust_limit((-stride_con), scale, offset, low_limit, *pre_limit, pre_ctrl); + *pre_limit = adjust_limit((-stride_con), scale, offset, low_limit, *pre_limit, pre_ctrl, + scale_con > 1 && stride_con > 0); } else { // stride_con*scale_con < 0 // For negative stride*scale pre-loop checks for overflow and @@ -2143,7 +2155,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset Node *plus_one = new AddINode(offset, one); register_new_node( plus_one, pre_ctrl ); // Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond); - *pre_limit = adjust_limit((-stride_con), scale, plus_one, upper_limit, *pre_limit, pre_ctrl); + *pre_limit = adjust_limit((-stride_con), scale, plus_one, upper_limit, *pre_limit, pre_ctrl, + scale_con < -1 && stride_con > 0); if (low_limit->get_int() == -max_jint) { // We need this guard when scale*main_limit+offset >= limit @@ -2177,7 +2190,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // I > (low_limit-(offset+1))/scale // ) - *main_limit = adjust_limit(stride_con, scale, plus_one, low_limit, *main_limit, pre_ctrl); + *main_limit = adjust_limit(stride_con, scale, plus_one, low_limit, *main_limit, pre_ctrl, + false); } } diff --git a/src/src/hotspot/share/opto/loopnode.hpp b/src/src/hotspot/share/opto/loopnode.hpp index e354a8bbbe2..1c3fdb2e01f 100644 --- a/src/src/hotspot/share/opto/loopnode.hpp +++ b/src/src/hotspot/share/opto/loopnode.hpp @@ -1181,7 +1181,7 @@ class PhaseIdealLoop : public PhaseTransform { // loop. Scale_con, offset and limit are all loop invariant. void add_constraint( int stride_con, int scale_con, Node *offset, Node *low_limit, Node *upper_limit, Node *pre_ctrl, Node **pre_limit, Node **main_limit ); // Helper function for add_constraint(). - Node* adjust_limit( int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl ); + Node* adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl, bool round_up); // Partially peel loop up through last_peel node. bool partial_peel( IdealLoopTree *loop, Node_List &old_new ); diff --git a/src/src/hotspot/share/opto/loopopts.cpp b/src/src/hotspot/share/opto/loopopts.cpp index 2625804c33e..5d83c8a47a3 100644 --- a/src/src/hotspot/share/opto/loopopts.cpp +++ b/src/src/hotspot/share/opto/loopopts.cpp @@ -3383,12 +3383,19 @@ void PhaseIdealLoop::reorg_offsets(IdealLoopTree *loop) { if (dom_lca(exit, u_ctrl) != exit) continue; // Hit! Refactor use to use the post-incremented tripcounter. // Compute a post-increment tripcounter. - Node *opaq = new Opaque2Node( C, cle->incr() ); - register_new_node(opaq, exit); + Node* c = exit; + if (cl->is_strip_mined()) { + IdealLoopTree* outer_loop = get_loop(cl->outer_loop()); + if (!outer_loop->is_member(u_loop)) { + c = cl->outer_loop_exit(); + } + } + Node *opaq = new Opaque2Node(C, cle->incr()); + register_new_node(opaq, c); Node *neg_stride = _igvn.intcon(-cle->stride_con()); set_ctrl(neg_stride, C->root()); - Node *post = new AddINode( opaq, neg_stride); - register_new_node(post, exit); + Node *post = new AddINode(opaq, neg_stride); + register_new_node(post, c); _igvn.rehash_node_delayed(use); for (uint j = 1; j < use->req(); j++) { if (use->in(j) == phi) diff --git a/src/src/hotspot/share/opto/matcher.cpp b/src/src/hotspot/share/opto/matcher.cpp index 8b61fed4ccb..d65be1054ea 100644 --- a/src/src/hotspot/share/opto/matcher.cpp +++ b/src/src/hotspot/share/opto/matcher.cpp @@ -1168,6 +1168,7 @@ MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) { if( mcall->is_MachCallJava() ) { MachCallJavaNode *mcall_java = mcall->as_MachCallJava(); const CallJavaNode *call_java = call->as_CallJava(); + assert(call_java->validate_symbolic_info(), "inconsistent info"); method = call_java->method(); mcall_java->_method = method; mcall_java->_bci = call_java->_bci; @@ -2056,6 +2057,12 @@ void Matcher::find_shared( Node *n ) { // Node is shared and has no reason to clone. Flag it as shared. // This causes it to match into a register for the sharing. set_shared(n); // Flag as shared and + if (n->is_DecodeNarrowPtr()) { + // Oop field/array element loads must be shared but since + // they are shared through a DecodeN they may appear to have + // a single use so force sharing here. + set_shared(n->in(1)); + } mstack.pop(); // remove node from stack continue; } @@ -2198,13 +2205,6 @@ void Matcher::find_shared( Node *n ) { continue; // for(int i = ...) } - if( mop == Op_AddP && m->in(AddPNode::Base)->is_DecodeNarrowPtr()) { - // Bases used in addresses must be shared but since - // they are shared through a DecodeN they may appear - // to have a single use so force sharing here. - set_shared(m->in(AddPNode::Base)->in(1)); - } - // if 'n' and 'm' are part of a graph for BMI instruction, clone this node. #ifdef X86 if (UseBMI1Instructions && is_bmi_pattern(n, m)) { diff --git a/src/src/hotspot/share/opto/memnode.cpp b/src/src/hotspot/share/opto/memnode.cpp index d33985ed75a..aa44a0c7cd3 100644 --- a/src/src/hotspot/share/opto/memnode.cpp +++ b/src/src/hotspot/share/opto/memnode.cpp @@ -42,6 +42,7 @@ #include "opto/narrowptrnode.hpp" #include "opto/phaseX.hpp" #include "opto/regmask.hpp" +#include "opto/rootnode.hpp" #include "utilities/align.hpp" #include "utilities/copy.hpp" #include "utilities/macros.hpp" @@ -97,6 +98,9 @@ void MemNode::dump_spec(outputStream *st) const { if (_mismatched_access) { st->print(" mismatched"); } + if (_unsafe_access) { + st->print(" unsafe"); + } } void MemNode::dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st) { @@ -323,6 +327,24 @@ Node *MemNode::Ideal_common(PhaseGVN *phase, bool can_reshape) { const Type *t_adr = phase->type(address); if (t_adr == Type::TOP) return NodeSentinel; // caller will return NULL + if (can_reshape && is_unsafe_access() && (t_adr == TypePtr::NULL_PTR)) { + // Unsafe off-heap access with zero address. Remove access and other control users + // to not confuse optimizations and add a HaltNode to fail if this is ever executed. + assert(ctl != NULL, "unsafe accesses should be control dependent"); + for (DUIterator_Fast imax, i = ctl->fast_outs(imax); i < imax; i++) { + Node* u = ctl->fast_out(i); + if (u != ctl) { + igvn->rehash_node_delayed(u); + int nb = u->replace_edge(ctl, phase->C->top()); + --i, imax -= nb; + } + } + Node* frame = igvn->transform(new ParmNode(phase->C->start(), TypeFunc::FramePtr)); + Node* halt = igvn->transform(new HaltNode(ctl, frame)); + phase->C->root()->add_req(halt); + return this; + } + if (can_reshape && igvn != NULL && (igvn->_worklist.member(address) || (igvn->_worklist.size() > 0 && t_adr != adr_type())) ) { @@ -787,7 +809,7 @@ bool LoadNode::is_immutable_value(Node* adr) { //----------------------------LoadNode::make----------------------------------- // Polymorphic factory method: Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypePtr* adr_type, const Type *rt, BasicType bt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { Compile* C = gvn.C; // sanity check the alias category against the created node type @@ -835,6 +857,9 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP if (mismatched) { load->set_mismatched_access(); } + if (unsafe) { + load->set_unsafe_access(); + } if (load->Opcode() == Op_LoadN) { Node* ld = gvn.transform(load); return new DecodeNNode(ld, ld->bottom_type()->make_ptr()); @@ -844,7 +869,7 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP } LoadLNode* LoadLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { bool require_atomic = true; LoadLNode* load = new LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, control_dependency, require_atomic); if (unaligned) { @@ -853,11 +878,14 @@ LoadLNode* LoadLNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr if (mismatched) { load->set_mismatched_access(); } + if (unsafe) { + load->set_unsafe_access(); + } return load; } LoadDNode* LoadDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, - ControlDependency control_dependency, bool unaligned, bool mismatched) { + ControlDependency control_dependency, bool unaligned, bool mismatched, bool unsafe) { bool require_atomic = true; LoadDNode* load = new LoadDNode(ctl, mem, adr, adr_type, rt, mo, control_dependency, require_atomic); if (unaligned) { @@ -866,6 +894,9 @@ LoadDNode* LoadDNode::make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr if (mismatched) { load->set_mismatched_access(); } + if (unsafe) { + load->set_unsafe_access(); + } return load; } @@ -1370,6 +1401,14 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) { Node* in = mem->in(i); Node* m = optimize_memory_chain(in, t_oop, this, phase); if (m == mem) { + if (i == 1) { + // if the first edge was a loop, check second edge too. + // If both are replaceable - we are in an infinite loop + Node *n = optimize_memory_chain(mem->in(2), t_oop, this, phase); + if (n == mem) { + break; + } + } set_req(Memory, mem->in(cnt - i)); return this; // made change } @@ -2525,45 +2564,63 @@ Node* StoreNode::Identity(PhaseGVN* phase) { Node* adr = in(MemNode::Address); Node* val = in(MemNode::ValueIn); + Node* result = this; + // Load then Store? Then the Store is useless if (val->is_Load() && val->in(MemNode::Address)->eqv_uncast(adr) && val->in(MemNode::Memory )->eqv_uncast(mem) && val->as_Load()->store_Opcode() == Opcode()) { - return mem; + result = mem; } // Two stores in a row of the same value? - if (mem->is_Store() && + if (result == this && + mem->is_Store() && mem->in(MemNode::Address)->eqv_uncast(adr) && mem->in(MemNode::ValueIn)->eqv_uncast(val) && mem->Opcode() == Opcode()) { - return mem; + result = mem; } // Store of zero anywhere into a freshly-allocated object? // Then the store is useless. // (It must already have been captured by the InitializeNode.) - if (ReduceFieldZeroing && phase->type(val)->is_zero_type()) { + if (result == this && + ReduceFieldZeroing && phase->type(val)->is_zero_type()) { // a newly allocated object is already all-zeroes everywhere if (mem->is_Proj() && mem->in(0)->is_Allocate()) { - return mem; + result = mem; } - // the store may also apply to zero-bits in an earlier object - Node* prev_mem = find_previous_store(phase); - // Steps (a), (b): Walk past independent stores to find an exact match. - if (prev_mem != NULL) { - Node* prev_val = can_see_stored_value(prev_mem, phase); - if (prev_val != NULL && phase->eqv(prev_val, val)) { - // prev_val and val might differ by a cast; it would be good - // to keep the more informative of the two. - return mem; + if (result == this) { + // the store may also apply to zero-bits in an earlier object + Node* prev_mem = find_previous_store(phase); + // Steps (a), (b): Walk past independent stores to find an exact match. + if (prev_mem != NULL) { + Node* prev_val = can_see_stored_value(prev_mem, phase); + if (prev_val != NULL && phase->eqv(prev_val, val)) { + // prev_val and val might differ by a cast; it would be good + // to keep the more informative of the two. + result = mem; + } } } } - return this; + if (result != this && phase->is_IterGVN() != NULL) { + MemBarNode* trailing = trailing_membar(); + if (trailing != NULL) { +#ifdef ASSERT + const TypeOopPtr* t_oop = phase->type(in(Address))->isa_oopptr(); + assert(t_oop == NULL || t_oop->is_known_instance_field(), "only for non escaping objects"); +#endif + PhaseIterGVN* igvn = phase->is_IterGVN(); + trailing->remove(igvn); + } + } + + return result; } //------------------------------match_edge------------------------------------- @@ -2641,6 +2698,33 @@ bool StoreNode::value_never_loaded( PhaseTransform *phase) const { return true; } +MemBarNode* StoreNode::trailing_membar() const { + if (is_release()) { + MemBarNode* trailing_mb = NULL; + for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { + Node* u = fast_out(i); + if (u->is_MemBar()) { + if (u->as_MemBar()->trailing_store()) { + assert(u->Opcode() == Op_MemBarVolatile, ""); + assert(trailing_mb == NULL, "only one"); + trailing_mb = u->as_MemBar(); +#ifdef ASSERT + Node* leading = u->as_MemBar()->leading_membar(); + assert(leading->Opcode() == Op_MemBarRelease, "incorrect membar"); + assert(leading->as_MemBar()->leading_store(), "incorrect membar pair"); + assert(leading->as_MemBar()->trailing_membar() == u, "incorrect membar pair"); +#endif + } else { + assert(u->as_MemBar()->standalone(), ""); + } + } + } + return trailing_mb; + } + return NULL; +} + + //============================================================================= //------------------------------Ideal------------------------------------------ // If the store is from an AND mask that leaves the low bits untouched, then @@ -2753,6 +2837,30 @@ bool LoadStoreNode::result_not_used() const { return true; } +MemBarNode* LoadStoreNode::trailing_membar() const { + MemBarNode* trailing = NULL; + for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { + Node* u = fast_out(i); + if (u->is_MemBar()) { + if (u->as_MemBar()->trailing_load_store()) { + assert(u->Opcode() == Op_MemBarAcquire, ""); + assert(trailing == NULL, "only one"); + trailing = u->as_MemBar(); +#ifdef ASSERT + Node* leading = trailing->leading_membar(); + assert(support_IRIW_for_not_multiple_copy_atomic_cpu || leading->Opcode() == Op_MemBarRelease, "incorrect membar"); + assert(leading->as_MemBar()->leading_load_store(), "incorrect membar pair"); + assert(leading->as_MemBar()->trailing_membar() == trailing, "incorrect membar pair"); +#endif + } else { + assert(u->as_MemBar()->standalone(), "wrong barrier kind"); + } + } + } + + return trailing; +} + uint LoadStoreNode::size_of() const { return sizeof(*this); } //============================================================================= @@ -2938,7 +3046,10 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, //============================================================================= MemBarNode::MemBarNode(Compile* C, int alias_idx, Node* precedent) : MultiNode(TypeFunc::Parms + (precedent == NULL? 0: 1)), - _adr_type(C->get_adr_type(alias_idx)) + _adr_type(C->get_adr_type(alias_idx)), _kind(Standalone) +#ifdef ASSERT + , _pair_idx(0) +#endif { init_class_id(Class_MemBar); Node* top = C->top(); @@ -2973,6 +3084,21 @@ MemBarNode* MemBarNode::make(Compile* C, int opcode, int atp, Node* pn) { } } +void MemBarNode::remove(PhaseIterGVN *igvn) { + if (outcnt() != 2) { + return; + } + if (trailing_store() || trailing_load_store()) { + MemBarNode* leading = leading_membar(); + if (leading != NULL) { + assert(leading->trailing_membar() == this, "inconsistent leading/trailing membars"); + leading->remove(igvn); + } + } + igvn->replace_node(proj_out(TypeFunc::Memory), in(TypeFunc::Memory)); + igvn->replace_node(proj_out(TypeFunc::Control), in(TypeFunc::Control)); +} + //------------------------------Ideal------------------------------------------ // Return a node which is more "ideal" than the current node. Strip out // control copies @@ -3039,8 +3165,7 @@ Node *MemBarNode::Ideal(PhaseGVN *phase, bool can_reshape) { if (eliminate) { // Replace MemBar projections by its inputs. PhaseIterGVN* igvn = phase->is_IterGVN(); - igvn->replace_node(proj_out(TypeFunc::Memory), in(TypeFunc::Memory)); - igvn->replace_node(proj_out(TypeFunc::Control), in(TypeFunc::Control)); + remove(igvn); // Must return either the original node (now dead) or a new node // (Do not return a top here, since that would break the uniqueness of top.) return new ConINode(TypeInt::ZERO); @@ -3069,6 +3194,136 @@ Node *MemBarNode::match( const ProjNode *proj, const Matcher *m ) { return NULL; } +void MemBarNode::set_store_pair(MemBarNode* leading, MemBarNode* trailing) { + trailing->_kind = TrailingStore; + leading->_kind = LeadingStore; +#ifdef ASSERT + trailing->_pair_idx = leading->_idx; + leading->_pair_idx = leading->_idx; +#endif +} + +void MemBarNode::set_load_store_pair(MemBarNode* leading, MemBarNode* trailing) { + trailing->_kind = TrailingLoadStore; + leading->_kind = LeadingLoadStore; +#ifdef ASSERT + trailing->_pair_idx = leading->_idx; + leading->_pair_idx = leading->_idx; +#endif +} + +MemBarNode* MemBarNode::trailing_membar() const { + ResourceMark rm; + Node* trailing = (Node*)this; + VectorSet seen(Thread::current()->resource_area()); + Node_Stack multis(0); + do { + Node* c = trailing; + uint i = 0; + do { + trailing = NULL; + for (; i < c->outcnt(); i++) { + Node* next = c->raw_out(i); + if (next != c && next->is_CFG()) { + if (c->is_MultiBranch()) { + if (multis.node() == c) { + multis.set_index(i+1); + } else { + multis.push(c, i+1); + } + } + trailing = next; + break; + } + } + if (trailing != NULL && !seen.test_set(trailing->_idx)) { + break; + } + while (multis.size() > 0) { + c = multis.node(); + i = multis.index(); + if (i < c->req()) { + break; + } + multis.pop(); + } + } while (multis.size() > 0); + } while (!trailing->is_MemBar() || !trailing->as_MemBar()->trailing()); + + MemBarNode* mb = trailing->as_MemBar(); + assert((mb->_kind == TrailingStore && _kind == LeadingStore) || + (mb->_kind == TrailingLoadStore && _kind == LeadingLoadStore), "bad trailing membar"); + assert(mb->_pair_idx == _pair_idx, "bad trailing membar"); + return mb; +} + +MemBarNode* MemBarNode::leading_membar() const { + ResourceMark rm; + VectorSet seen(Thread::current()->resource_area()); + Node_Stack regions(0); + Node* leading = in(0); + while (leading != NULL && (!leading->is_MemBar() || !leading->as_MemBar()->leading())) { + while (leading == NULL || leading->is_top() || seen.test_set(leading->_idx)) { + leading = NULL; + while (regions.size() > 0 && leading == NULL) { + Node* r = regions.node(); + uint i = regions.index(); + if (i < r->req()) { + leading = r->in(i); + regions.set_index(i+1); + } else { + regions.pop(); + } + } + if (leading == NULL) { + assert(regions.size() == 0, "all paths should have been tried"); + return NULL; + } + } + if (leading->is_Region()) { + regions.push(leading, 2); + leading = leading->in(1); + } else { + leading = leading->in(0); + } + } +#ifdef ASSERT + Unique_Node_List wq; + wq.push((Node*)this); + uint found = 0; + for (uint i = 0; i < wq.size(); i++) { + Node* n = wq.at(i); + if (n->is_Region()) { + for (uint j = 1; j < n->req(); j++) { + Node* in = n->in(j); + if (in != NULL && !in->is_top()) { + wq.push(in); + } + } + } else { + if (n->is_MemBar() && n->as_MemBar()->leading()) { + assert(n == leading, "consistency check failed"); + found++; + } else { + Node* in = n->in(0); + if (in != NULL && !in->is_top()) { + wq.push(in); + } + } + } + } + assert(found == 1 || (found == 0 && leading == NULL), "consistency check failed"); +#endif + if (leading == NULL) { + return NULL; + } + MemBarNode* mb = leading->as_MemBar(); + assert((mb->_kind == LeadingStore && _kind == TrailingStore) || + (mb->_kind == LeadingLoadStore && _kind == TrailingLoadStore), "bad leading membar"); + assert(mb->_pair_idx == _pair_idx, "bad leading membar"); + return mb; +} + //===========================InitializeNode==================================== // SUMMARY: // This node acts as a memory barrier on raw memory, after some raw stores. diff --git a/src/src/hotspot/share/opto/memnode.hpp b/src/src/hotspot/share/opto/memnode.hpp index eb421b86f7b..e0ffedc06bc 100644 --- a/src/src/hotspot/share/opto/memnode.hpp +++ b/src/src/hotspot/share/opto/memnode.hpp @@ -42,6 +42,7 @@ class MemNode : public Node { private: bool _unaligned_access; // Unaligned access from unsafe bool _mismatched_access; // Mismatched access from unsafe: byte read in integer array for instance + bool _unsafe_access; // Access of unsafe origin. protected: #ifdef ASSERT const TypePtr* _adr_type; // What kind of memory is being addressed? @@ -62,17 +63,17 @@ class MemNode : public Node { } MemOrd; protected: MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at ) - : Node(c0,c1,c2 ), _unaligned_access(false), _mismatched_access(false) { + : Node(c0,c1,c2 ), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) { init_class_id(Class_Mem); debug_only(_adr_type=at; adr_type();) } MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3 ) - : Node(c0,c1,c2,c3), _unaligned_access(false), _mismatched_access(false) { + : Node(c0,c1,c2,c3), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) { init_class_id(Class_Mem); debug_only(_adr_type=at; adr_type();) } MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3, Node *c4) - : Node(c0,c1,c2,c3,c4), _unaligned_access(false), _mismatched_access(false) { + : Node(c0,c1,c2,c3,c4), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) { init_class_id(Class_Mem); debug_only(_adr_type=at; adr_type();) } @@ -137,6 +138,8 @@ class MemNode : public Node { bool is_unaligned_access() const { return _unaligned_access; } void set_mismatched_access() { _mismatched_access = true; } bool is_mismatched_access() const { return _mismatched_access; } + void set_unsafe_access() { _unsafe_access = true; } + bool is_unsafe_access() const { return _unsafe_access; } #ifndef PRODUCT static void dump_adr_type(const Node* mem, const TypePtr* adr_type, outputStream *st); @@ -207,7 +210,7 @@ class LoadNode : public MemNode { static Node* make(PhaseGVN& gvn, Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *rt, BasicType bt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false); virtual uint hash() const; // Check the type @@ -388,7 +391,7 @@ class LoadLNode : public LoadNode { bool require_atomic_access() const { return _require_atomic_access; } static LoadLNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { LoadNode::dump_spec(st); @@ -440,7 +443,7 @@ class LoadDNode : public LoadNode { bool require_atomic_access() const { return _require_atomic_access; } static LoadDNode* make_atomic(Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency = DependsOnlyOnTest, - bool unaligned = false, bool mismatched = false); + bool unaligned = false, bool mismatched = false, bool unsafe = false); #ifndef PRODUCT virtual void dump_spec(outputStream *st) const { LoadNode::dump_spec(st); @@ -607,6 +610,8 @@ class StoreNode : public MemNode { // have all possible loads of the value stored been optimized away? bool value_never_loaded(PhaseTransform *phase) const; + + MemBarNode* trailing_membar() const; }; //------------------------------StoreBNode------------------------------------- @@ -816,6 +821,7 @@ class LoadStoreNode : public Node { virtual const class TypePtr *adr_type() const { return _adr_type; } // returns bottom_type of address bool result_not_used() const; + MemBarNode* trailing_membar() const; }; class LoadStoreConditionalNode : public LoadStoreNode { @@ -1142,6 +1148,20 @@ class MemBarNode: public MultiNode { // Memory type this node is serializing. Usually either rawptr or bottom. const TypePtr* _adr_type; + // How is this membar related to a nearby memory access? + enum { + Standalone, + TrailingLoad, + TrailingStore, + LeadingStore, + TrailingLoadStore, + LeadingLoadStore + } _kind; + +#ifdef ASSERT + uint _pair_idx; +#endif + public: enum { Precedent = TypeFunc::Parms // optional edge to force precedence @@ -1159,6 +1179,24 @@ class MemBarNode: public MultiNode { static MemBarNode* make(Compile* C, int opcode, int alias_idx = Compile::AliasIdxBot, Node* precedent = NULL); + + MemBarNode* trailing_membar() const; + MemBarNode* leading_membar() const; + + void set_trailing_load() { _kind = TrailingLoad; } + bool trailing_load() const { return _kind == TrailingLoad; } + bool trailing_store() const { return _kind == TrailingStore; } + bool leading_store() const { return _kind == LeadingStore; } + bool trailing_load_store() const { return _kind == TrailingLoadStore; } + bool leading_load_store() const { return _kind == LeadingLoadStore; } + bool trailing() const { return _kind == TrailingLoad || _kind == TrailingStore || _kind == TrailingLoadStore; } + bool leading() const { return _kind == LeadingStore || _kind == LeadingLoadStore; } + bool standalone() const { return _kind == Standalone; } + + static void set_store_pair(MemBarNode* leading, MemBarNode* trailing); + static void set_load_store_pair(MemBarNode* leading, MemBarNode* trailing); + + void remove(PhaseIterGVN *igvn); }; // "Acquire" - no following ref can move before (but earlier refs can diff --git a/src/src/hotspot/share/opto/output.cpp b/src/src/hotspot/share/opto/output.cpp index 6e97899473f..b8f72ffca68 100644 --- a/src/src/hotspot/share/opto/output.cpp +++ b/src/src/hotspot/share/opto/output.cpp @@ -1556,6 +1556,8 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { } if (method() != NULL) { method()->print_metadata(); + } else if (stub_name() != NULL) { + tty->print_cr("Generating RuntimeStub - %s", stub_name()); } dump_asm(node_offsets, node_offset_limit); if (xtty != NULL) { @@ -2391,12 +2393,9 @@ void Scheduling::DoScheduling() { } assert(!last->is_Mach() || last->as_Mach()->ideal_Opcode() != Op_Con, ""); if( last->is_Catch() || - // Exclude unreachable path case when Halt node is in a separate block. - (_bb_end > 1 && last->is_Mach() && last->as_Mach()->ideal_Opcode() == Op_Halt) ) { - // There must be a prior call. Skip it. - while( !bb->get_node(--_bb_end)->is_MachCall() ) { - assert( bb->get_node(_bb_end)->is_MachProj(), "skipping projections after expected call" ); - } + (last->is_Mach() && last->as_Mach()->ideal_Opcode() == Op_Halt) ) { + // There might be a prior call. Skip it. + while (_bb_start < _bb_end && bb->get_node(--_bb_end)->is_MachProj()); } else if( last->is_MachNullCheck() ) { // Backup so the last null-checked memory instruction is // outside the schedulable range. Skip over the nullcheck, diff --git a/src/src/hotspot/share/opto/reg_split.cpp b/src/src/hotspot/share/opto/reg_split.cpp index 78789150c82..b1fd0c8bcc8 100644 --- a/src/src/hotspot/share/opto/reg_split.cpp +++ b/src/src/hotspot/share/opto/reg_split.cpp @@ -1192,9 +1192,8 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { (deflrg._direct_conflict || deflrg._must_spill)) || // Check for LRG being up in a register and we are inside a high // pressure area. Spill it down immediately. - (defup && is_high_pressure(b,&deflrg,insidx))) ) { + (defup && is_high_pressure(b,&deflrg,insidx) && !n->is_SpillCopy())) ) { assert( !n->rematerialize(), "" ); - assert( !n->is_SpillCopy(), "" ); // Do a split at the def site. maxlrg = split_DEF( n, b, insidx, maxlrg, Reachblock, debug_defs, splits, slidx ); // If it wasn't split bail diff --git a/src/src/hotspot/share/opto/superword.cpp b/src/src/hotspot/share/opto/superword.cpp index 66d9c40b22b..190b274b178 100644 --- a/src/src/hotspot/share/opto/superword.cpp +++ b/src/src/hotspot/share/opto/superword.cpp @@ -613,7 +613,7 @@ void SuperWord::find_adjacent_refs() { // alignment is set and vectors will be aligned. bool create_pack = true; if (memory_alignment(mem_ref, best_iv_adjustment) == 0 || _do_vector_loop) { - if (!Matcher::misaligned_vectors_ok()) { + if (!Matcher::misaligned_vectors_ok() || AlignVector) { int vw = vector_width(mem_ref); int vw_best = vector_width(best_align_to_mem_ref); if (vw > vw_best) { @@ -638,7 +638,7 @@ void SuperWord::find_adjacent_refs() { } else { // Allow independent (different type) unaligned memory operations // if HW supports them. - if (!Matcher::misaligned_vectors_ok()) { + if (!Matcher::misaligned_vectors_ok() || AlignVector) { create_pack = false; } else { // Check if packs of the same memory type but @@ -3280,9 +3280,9 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { _igvn.register_new_node_with_optimizer(e); _phase->set_ctrl(e, pre_ctrl); } - if (vw > ObjectAlignmentInBytes) { + if (vw > ObjectAlignmentInBytes || align_to_ref_p.base()->is_top()) { // incorporate base e +/- base && Mask >>> log2(elt) - Node* xbase = new CastP2XNode(NULL, align_to_ref_p.base()); + Node* xbase = new CastP2XNode(NULL, align_to_ref_p.adr()); _igvn.register_new_node_with_optimizer(xbase); #ifdef _LP64 xbase = new ConvL2INode(xbase); @@ -3474,8 +3474,8 @@ SWPointer::SWPointer(MemNode* mem, SuperWord* slp, Node_Stack *nstack, bool anal assert(!valid(), "base address is loop variant"); return; } - //unsafe reference could not be aligned appropriately without runtime checking - if (base == NULL || base->bottom_type() == Type::TOP) { + // unsafe references require misaligned vector access support + if (base->is_top() && !Matcher::misaligned_vectors_ok()) { assert(!valid(), "unsafe access"); return; } @@ -3499,6 +3499,16 @@ SWPointer::SWPointer(MemNode* mem, SuperWord* slp, Node_Stack *nstack, bool anal break; // stop looking at addp's } } + if (!invariant(adr)) { + assert(!valid(), "adr is loop variant"); + return; + } + + if (!base->is_top() && adr != base) { + assert(!valid(), "adr and base differ"); + return; + } + NOT_PRODUCT(if(_slp->is_trace_alignment()) _tracer.restore_depth();) NOT_PRODUCT(_tracer.ctor_6(mem);) diff --git a/src/src/hotspot/share/prims/forte.cpp b/src/src/hotspot/share/prims/forte.cpp index 2ed4c8b2e48..1ab813a4ae3 100644 --- a/src/src/hotspot/share/prims/forte.cpp +++ b/src/src/hotspot/share/prims/forte.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -70,7 +70,7 @@ enum { // Native interfaces for use by Forte tools. -#if !defined(IA64) && !defined(PPC64) +#if !defined(IA64) class vframeStreamForte : public vframeStreamCommon { public: @@ -639,16 +639,16 @@ void collector_func_load(char* name, #endif // !_WINDOWS } // end extern "C" -#endif // !IA64 && !PPC64 +#endif // !IA64 void Forte::register_stub(const char* name, address start, address end) { -#if !defined(_WINDOWS) && !defined(IA64) && !defined(PPC64) +#if !defined(_WINDOWS) && !defined(IA64) assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX, "Code size exceeds maximum range"); collector_func_load((char*)name, NULL, NULL, start, pointer_delta(end, start, sizeof(jbyte)), 0, NULL); -#endif // !_WINDOWS && !IA64 && !PPC64 +#endif // !_WINDOWS && !IA64 } #else // INCLUDE_JVMTI diff --git a/src/src/hotspot/share/prims/jni.cpp b/src/src/hotspot/share/prims/jni.cpp index 1601201d8d7..ac49e258d1d 100644 --- a/src/src/hotspot/share/prims/jni.cpp +++ b/src/src/hotspot/share/prims/jni.cpp @@ -823,9 +823,7 @@ JNI_QUICK_ENTRY(jboolean, jni_IsSameObject(JNIEnv *env, jobject r1, jobject r2)) HOTSPOT_JNI_ISSAMEOBJECT_ENTRY(env, r1, r2); - oop a = JNIHandles::resolve(r1); - oop b = JNIHandles::resolve(r2); - jboolean ret = oopDesc::equals(a, b) ? JNI_TRUE : JNI_FALSE; + jboolean ret = JNIHandles::is_same_object(r1, r2) ? JNI_TRUE : JNI_FALSE; HOTSPOT_JNI_ISSAMEOBJECT_RETURN(ret); return ret; diff --git a/src/src/hotspot/share/prims/jniCheck.cpp b/src/src/hotspot/share/prims/jniCheck.cpp index 31d5cb20271..829b6235345 100644 --- a/src/src/hotspot/share/prims/jniCheck.cpp +++ b/src/src/hotspot/share/prims/jniCheck.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -418,21 +418,20 @@ static void* check_wrapped_array_release(JavaThread* thr, const char* fn_name, size_t sz; void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); switch (mode) { + // As we never make copies, mode 0 and JNI_COMMIT are the same. case 0: - memcpy(orig_result, carray, sz); - GuardedMemory::free_copy(carray); - break; case JNI_COMMIT: memcpy(orig_result, carray, sz); break; case JNI_ABORT: - GuardedMemory::free_copy(carray); break; default: tty->print_cr("%s: Unrecognized mode %i releasing array " PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray)); NativeReportJNIFatalError(thr, "Unrecognized array release mode"); } + // We always need to release the copy we made with GuardedMemory + GuardedMemory::free_copy(carray); return orig_result; } diff --git a/src/src/hotspot/share/prims/jvm.cpp b/src/src/hotspot/share/prims/jvm.cpp index 35e789190c8..0ba01c6c30c 100644 --- a/src/src/hotspot/share/prims/jvm.cpp +++ b/src/src/hotspot/share/prims/jvm.cpp @@ -39,6 +39,7 @@ #include "interpreter/bytecode.hpp" #include "jfr/jfrEvents.hpp" #include "logging/log.hpp" +#include "memory/heapShared.hpp" #include "memory/oopFactory.hpp" #include "memory/referenceType.hpp" #include "memory/resourceArea.hpp" @@ -844,10 +845,6 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, Handle h_prot (THREAD, protection_domain); jclass result = find_class_from_class_loader(env, h_name, init, h_loader, h_prot, true, thread); - if (result != NULL) { - oop mirror = JNIHandles::resolve_non_null(result); - Klass* to_class = java_lang_Class::as_Klass(mirror); - } if (log_is_enabled(Debug, class, resolve) && result != NULL) { // this function is generally only used for class loading during verification. @@ -3590,6 +3587,13 @@ JVM_LEAF(jboolean, JVM_SupportsCX8()) return VM_Version::supports_cx8(); JVM_END +JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls)) + JVMWrapper("JVM_InitializeFromArchive"); + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); + assert(k->is_klass(), "just checking"); + HeapShared::initialize_from_archived_subgraph(k); +JVM_END + // Returns an array of all live Thread objects (VM internal JavaThreads, // jvmti agent threads, and JNI attaching threads are skipped) // See CR 6404306 regarding JNI attaching threads diff --git a/src/src/hotspot/share/prims/jvmtiEnvBase.hpp b/src/src/hotspot/share/prims/jvmtiEnvBase.hpp index 9a8f583e847..a38d8602eda 100644 --- a/src/src/hotspot/share/prims/jvmtiEnvBase.hpp +++ b/src/src/hotspot/share/prims/jvmtiEnvBase.hpp @@ -32,6 +32,7 @@ #include "oops/oopHandle.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/frame.hpp" +#include "runtime/orderAccess.hpp" #include "runtime/thread.hpp" #include "runtime/vm_operations.hpp" #include "utilities/growableArray.hpp" @@ -98,7 +99,7 @@ class JvmtiEnvBase : public CHeapObj { const void *_env_local_storage; // per env agent allocated data. jvmtiEventCallbacks _event_callbacks; jvmtiExtEventCallbacks _ext_event_callbacks; - JvmtiTagMap* _tag_map; + JvmtiTagMap* volatile _tag_map; JvmtiEnvEventEnable _env_event_enable; jvmtiCapabilities _current_capabilities; jvmtiCapabilities _prohibited_capabilities; @@ -253,6 +254,13 @@ class JvmtiEnvBase : public CHeapObj { return _tag_map; } + JvmtiTagMap* tag_map_acquire() { + return OrderAccess::load_acquire(&_tag_map); + } + + void release_set_tag_map(JvmtiTagMap* tag_map) { + OrderAccess::release_store(&_tag_map, tag_map); + } // return true if event is enabled globally or for any thread // True only if there is a callback for it. diff --git a/src/src/hotspot/share/prims/jvmtiEventController.cpp b/src/src/hotspot/share/prims/jvmtiEventController.cpp index 0c0a88e3041..8c1ceba64cd 100644 --- a/src/src/hotspot/share/prims/jvmtiEventController.cpp +++ b/src/src/hotspot/share/prims/jvmtiEventController.cpp @@ -263,7 +263,7 @@ class VM_ChangeSingleStep : public VM_Operation { VM_ChangeSingleStep::VM_ChangeSingleStep(bool on) - : _on(on != 0) + : _on(on) { } @@ -330,18 +330,20 @@ void JvmtiEventControllerPrivate::set_should_post_single_step(bool on) { } -// This change must always be occur when at a safepoint. -// Being at a safepoint causes the interpreter to use the -// safepoint dispatch table which we overload to find single -// step points. Just to be sure that it has been set, we -// call notice_safepoints when turning on single stepping. -// When we leave our current safepoint, should_post_single_step -// will be checked by the interpreter, and the table kept -// or changed accordingly. +// When _on == true, we use the safepoint interpreter dispatch table +// to allow us to find the single step points. Otherwise, we switch +// back to the regular interpreter dispatch table. +// Note: We call Interpreter::notice_safepoints() and ignore_safepoints() +// in a VM_Operation to safely make the dispatch table switch. We +// no longer rely on the safepoint mechanism to do any of this work +// for us. void VM_ChangeSingleStep::doit() { + log_debug(interpreter, safepoint)("changing single step to '%s'", _on ? "on" : "off"); JvmtiEventControllerPrivate::set_should_post_single_step(_on); if (_on) { Interpreter::notice_safepoints(); + } else { + Interpreter::ignore_safepoints(); } } diff --git a/src/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index b4a6a77a521..1b2070d686f 100644 --- a/src/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -1616,6 +1616,11 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( return JVMTI_ERROR_INTERNAL; } + if (old_cp->has_dynamic_constant()) { + merge_cp->set_has_dynamic_constant(); + scratch_cp->set_has_dynamic_constant(); + } + log_info(redefine, class, constantpool)("merge_cp_len=%d, index_map_len=%d", merge_cp_length, _index_map_count); if (_index_map_count == 0) { @@ -3239,6 +3244,10 @@ void VM_RedefineClasses::set_new_constant_pool( // reference to the cp holder is needed for copy_operands() smaller_cp->set_pool_holder(scratch_class); + if (scratch_cp->has_dynamic_constant()) { + smaller_cp->set_has_dynamic_constant(); + } + scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD); if (HAS_PENDING_EXCEPTION) { // Exception is handled in the caller diff --git a/src/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/src/hotspot/share/prims/jvmtiTagMap.cpp index a171bccccc2..42bf12c107c 100644 --- a/src/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -449,7 +449,7 @@ JvmtiTagMap::JvmtiTagMap(JvmtiEnv* env) : _hashmap = new JvmtiTagHashmap(); // finally add us to the environment - ((JvmtiEnvBase *)env)->set_tag_map(this); + ((JvmtiEnvBase *)env)->release_set_tag_map(this); } @@ -518,7 +518,7 @@ void JvmtiTagMap::destroy_entry(JvmtiTagHashmapEntry* entry) { // returns the tag map for the given environments. If the tag map // doesn't exist then it is created. JvmtiTagMap* JvmtiTagMap::tag_map_for(JvmtiEnv* env) { - JvmtiTagMap* tag_map = ((JvmtiEnvBase*)env)->tag_map(); + JvmtiTagMap* tag_map = ((JvmtiEnvBase*)env)->tag_map_acquire(); if (tag_map == NULL) { MutexLocker mu(JvmtiThreadState_lock); tag_map = ((JvmtiEnvBase*)env)->tag_map(); @@ -3303,7 +3303,7 @@ void JvmtiTagMap::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { if (JvmtiEnv::environments_might_exist()) { JvmtiEnvIterator it; for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) { - JvmtiTagMap* tag_map = env->tag_map(); + JvmtiTagMap* tag_map = env->tag_map_acquire(); if (tag_map != NULL && !tag_map->is_empty()) { tag_map->do_weak_oops(is_alive, f); } diff --git a/src/src/hotspot/share/prims/whitebox.cpp b/src/src/hotspot/share/prims/whitebox.cpp index aa661099709..08f1329153c 100644 --- a/src/src/hotspot/share/prims/whitebox.cpp +++ b/src/src/hotspot/share/prims/whitebox.cpp @@ -217,7 +217,6 @@ WB_END void TestReservedSpace_test(); void TestReserveMemorySpecial_test(); void TestVirtualSpace_test(); -void TestMetaspaceUtils_test(); #endif WB_ENTRY(void, WB_RunMemoryUnitTests(JNIEnv* env, jobject o)) @@ -225,7 +224,6 @@ WB_ENTRY(void, WB_RunMemoryUnitTests(JNIEnv* env, jobject o)) TestReservedSpace_test(); TestReserveMemorySpecial_test(); TestVirtualSpace_test(); - TestMetaspaceUtils_test(); #endif WB_END @@ -975,6 +973,24 @@ WB_ENTRY(jint, WB_MatchesMethod(JNIEnv* env, jobject o, jobject method, jstring return result; WB_END +WB_ENTRY(void, WB_MarkMethodProfiled(JNIEnv* env, jobject o, jobject method)) + jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION(env); + methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); + + MethodData* mdo = mh->method_data(); + if (mdo == NULL) { + Method::build_interpreter_method_data(mh, CHECK_AND_CLEAR); + mdo = mh->method_data(); + } + mdo->init(); + InvocationCounter* icnt = mdo->invocation_counter(); + InvocationCounter* bcnt = mdo->backedge_counter(); + // set i-counter according to TieredThresholdPolicy::is_method_profiled + icnt->set(InvocationCounter::wait_for_compile, Tier4MinInvocationThreshold); + bcnt->set(InvocationCounter::wait_for_compile, Tier4CompileThreshold); +WB_END + WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); CHECK_JNI_EXCEPTION(env); @@ -2068,6 +2084,8 @@ static JNINativeMethod methods[] = { CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, {CC"enqueueInitializerForCompilation0", CC"(Ljava/lang/Class;I)Z", (void*)&WB_EnqueueInitializerForCompilation}, + {CC"markMethodProfiled", + CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_MarkMethodProfiled}, {CC"clearMethodState0", CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, {CC"lockCompilation", CC"()V", (void*)&WB_LockCompilation}, diff --git a/src/src/hotspot/share/runtime/arguments.cpp b/src/src/hotspot/share/runtime/arguments.cpp index 911e200048c..16c7906dc6c 100644 --- a/src/src/hotspot/share/runtime/arguments.cpp +++ b/src/src/hotspot/share/runtime/arguments.cpp @@ -2495,9 +2495,15 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m (is_absolute_path = match_option(option, "-agentpath:", &tail))) { if(tail != NULL) { const char* pos = strchr(tail, '='); - size_t len = (pos == NULL) ? strlen(tail) : pos - tail; - char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtArguments), tail, len); - name[len] = '\0'; + char* name; + if (pos == NULL) { + name = os::strdup_check_oom(tail, mtArguments); + } else { + size_t len = pos - tail; + name = NEW_C_HEAP_ARRAY(char, len + 1, mtArguments); + memcpy(name, tail, len); + name[len] = '\0'; + } char *options = NULL; if(pos != NULL) { diff --git a/src/src/hotspot/share/runtime/compilationPolicy.cpp b/src/src/hotspot/share/runtime/compilationPolicy.cpp index 5749a46fe87..617a335ff51 100644 --- a/src/src/hotspot/share/runtime/compilationPolicy.cpp +++ b/src/src/hotspot/share/runtime/compilationPolicy.cpp @@ -37,15 +37,22 @@ #include "runtime/frame.hpp" #include "runtime/handles.inline.hpp" #include "runtime/rframe.hpp" -#include "runtime/simpleThresholdPolicy.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/thread.hpp" +#include "runtime/tieredThresholdPolicy.hpp" #include "runtime/timer.hpp" #include "runtime/vframe.hpp" #include "runtime/vm_operations.hpp" #include "utilities/events.hpp" #include "utilities/globalDefinitions.hpp" +#ifdef COMPILER1 +#include "c1/c1_Compiler.hpp" +#endif +#ifdef COMPILER2 +#include "opto/c2compiler.hpp" +#endif + CompilationPolicy* CompilationPolicy::_policy; elapsedTimer CompilationPolicy::_accumulated_time; bool CompilationPolicy::_in_vm_startup; @@ -68,7 +75,7 @@ void compilationPolicy_init() { break; case 2: #ifdef TIERED - CompilationPolicy::set_policy(new SimpleThresholdPolicy()); + CompilationPolicy::set_policy(new TieredThresholdPolicy()); #else Unimplemented(); #endif @@ -181,6 +188,14 @@ bool CompilationPolicy::is_compilation_enabled() { } CompileTask* CompilationPolicy::select_task_helper(CompileQueue* compile_queue) { + // Remove unloaded methods from the queue + for (CompileTask* task = compile_queue->first(); task != NULL; ) { + CompileTask* next = task->next(); + if (task->is_unloaded()) { + compile_queue->remove_and_mark_stale(task); + } + task = next; + } #if INCLUDE_JVMCI if (UseJVMCICompiler && !BackgroundCompilation) { /* @@ -222,6 +237,19 @@ void NonTieredCompPolicy::initialize() { // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine. // May help big-app startup time. _compiler_count = MAX2(log2_int(os::active_processor_count())-1,1); + // Make sure there is enough space in the code cache to hold all the compiler buffers + size_t buffer_size = 1; +#ifdef COMPILER1 + buffer_size = is_client_compilation_mode_vm() ? Compiler::code_buffer_size() : buffer_size; +#endif +#ifdef COMPILER2 + buffer_size = is_server_compilation_mode_vm() ? C2Compiler::initial_code_buffer_size() : buffer_size; +#endif + int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size; + if (_compiler_count > max_count) { + // Lower the compiler count such that all buffers fit into the code cache + _compiler_count = MAX2(max_count, 1); + } FLAG_SET_ERGO(intx, CICompilerCount, _compiler_count); } else { _compiler_count = CICompilerCount; diff --git a/src/src/hotspot/share/runtime/globals.hpp b/src/src/hotspot/share/runtime/globals.hpp index 9050b109b3d..c77c77cff99 100644 --- a/src/src/hotspot/share/runtime/globals.hpp +++ b/src/src/hotspot/share/runtime/globals.hpp @@ -542,7 +542,7 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); diagnostic(bool, LogEvents, true, \ "Enable the various ring buffer event logs") \ \ - diagnostic(uintx, LogEventsBufferEntries, 10, \ + diagnostic(uintx, LogEventsBufferEntries, 20, \ "Number of ring buffer event logs") \ range(1, NOT_LP64(1*K) LP64_ONLY(1*M)) \ \ diff --git a/src/src/hotspot/share/runtime/handshake.cpp b/src/src/hotspot/share/runtime/handshake.cpp index 610cc3b9a8f..7aac48969d5 100644 --- a/src/src/hotspot/share/runtime/handshake.cpp +++ b/src/src/hotspot/share/runtime/handshake.cpp @@ -314,13 +314,14 @@ void HandshakeState::process_self_inner(JavaThread* thread) { return; } - CautiouslyPreserveExceptionMark pem(thread); ThreadInVMForHandshake tivm(thread); if (!_semaphore.trywait()) { _semaphore.wait_with_safepoint_check(thread); } HandshakeOperation* op = OrderAccess::load_acquire(&_operation); if (op != NULL) { + HandleMark hm(thread); + CautiouslyPreserveExceptionMark pem(thread); // Disarm before execute the operation clear_handshake(thread); op->do_handshake(thread); diff --git a/src/src/hotspot/share/runtime/interfaceSupport.inline.hpp b/src/src/hotspot/share/runtime/interfaceSupport.inline.hpp index 1868f0b3325..c3bb7fd6d77 100644 --- a/src/src/hotspot/share/runtime/interfaceSupport.inline.hpp +++ b/src/src/hotspot/share/runtime/interfaceSupport.inline.hpp @@ -194,6 +194,12 @@ class ThreadInVMForHandshake : public ThreadStateTransition { SafepointMechanism::block_if_requested(_thread); _thread->set_thread_state(_original_state); + + if (_original_state != _thread_blocked_trans && _original_state != _thread_in_vm_trans && + _thread->has_special_runtime_exit_condition()) { + _thread->handle_special_runtime_exit_condition( + !_thread->is_at_poll_safepoint() && (_original_state != _thread_in_native_trans)); + } } public: diff --git a/src/src/hotspot/share/runtime/java.cpp b/src/src/hotspot/share/runtime/java.cpp index 47d12cfc7da..58faff832c0 100644 --- a/src/src/hotspot/share/runtime/java.cpp +++ b/src/src/hotspot/share/runtime/java.cpp @@ -319,7 +319,7 @@ void print_statistics() { // Does also call NMethodSweeper::print(tty) LogTarget(Trace, codecache) lt; if (lt.is_enabled()) { - CompileBroker::print_heapinfo(NULL, "all", "4096"); // details + CompileBroker::print_heapinfo(NULL, "all", 4096); // details } else if (PrintMethodFlushingStatistics) { NMethodSweeper::print(tty); } @@ -387,7 +387,7 @@ void print_statistics() { // Does also call NMethodSweeper::print(tty) LogTarget(Trace, codecache) lt; if (lt.is_enabled()) { - CompileBroker::print_heapinfo(NULL, "all", "4096"); // details + CompileBroker::print_heapinfo(NULL, "all", 4096); // details } else if (PrintMethodFlushingStatistics) { NMethodSweeper::print(tty); } diff --git a/src/src/hotspot/share/runtime/jniHandles.cpp b/src/src/hotspot/share/runtime/jniHandles.cpp index 2e7c2605d5e..af2d79d315f 100644 --- a/src/src/hotspot/share/runtime/jniHandles.cpp +++ b/src/src/hotspot/share/runtime/jniHandles.cpp @@ -152,17 +152,11 @@ jobject JNIHandles::make_weak_global(Handle obj, AllocFailType alloc_failmode) { oop JNIHandles::resolve_external_guard(jobject handle) { oop result = NULL; if (handle != NULL) { - result = resolve_impl(handle); + result = resolve_impl<0 /* decorators */, true /* external_guard */>(handle); } return result; } -oop JNIHandles::resolve_jweak(jweak handle) { - assert(handle != NULL, "precondition"); - assert(is_jweak(handle), "precondition"); - return NativeAccess::oop_load(jweak_ptr(handle)); -} - bool JNIHandles::is_global_weak_cleared(jweak handle) { assert(handle != NULL, "precondition"); assert(is_jweak(handle), "not a weak handle"); diff --git a/src/src/hotspot/share/runtime/jniHandles.hpp b/src/src/hotspot/share/runtime/jniHandles.hpp index 3c6be3b6b1a..4c8c9fc1148 100644 --- a/src/src/hotspot/share/runtime/jniHandles.hpp +++ b/src/src/hotspot/share/runtime/jniHandles.hpp @@ -42,8 +42,10 @@ class JNIHandles : AllStatic { inline static oop* jobject_ptr(jobject handle); // NOT jweak! inline static oop* jweak_ptr(jobject handle); - template inline static oop resolve_impl(jobject handle); - static oop resolve_jweak(jweak handle); + template inline static oop resolve_impl(jobject handle); + + // Resolve handle into oop, without keeping the object alive + inline static oop resolve_no_keepalive(jobject handle); // This method is not inlined in order to avoid circular includes between // this header file and thread.hpp. @@ -70,6 +72,9 @@ class JNIHandles : AllStatic { // Resolve externally provided handle into oop with some guards static oop resolve_external_guard(jobject handle); + // Check for equality without keeping objects alive + static bool is_same_object(jobject handle1, jobject handle2); + // Local handles static jobject make_local(oop obj); static jobject make_local(JNIEnv* env, oop obj); // Fast version when env is known diff --git a/src/src/hotspot/share/runtime/jniHandles.inline.hpp b/src/src/hotspot/share/runtime/jniHandles.inline.hpp index d8b9c7770b1..43e284196c0 100644 --- a/src/src/hotspot/share/runtime/jniHandles.inline.hpp +++ b/src/src/hotspot/share/runtime/jniHandles.inline.hpp @@ -49,15 +49,15 @@ inline oop* JNIHandles::jweak_ptr(jobject handle) { } // external_guard is true if called from resolve_external_guard. -template +template inline oop JNIHandles::resolve_impl(jobject handle) { assert(handle != NULL, "precondition"); assert(!current_thread_in_native(), "must not be in native"); oop result; if (is_jweak(handle)) { // Unlikely - result = resolve_jweak(handle); + result = NativeAccess::oop_load(jweak_ptr(handle)); } else { - result = NativeAccess<>::oop_load(jobject_ptr(handle)); + result = NativeAccess::oop_load(jobject_ptr(handle)); // Construction of jobjects canonicalize a null value into a null // jobject, so for non-jweak the pointee should never be null. assert(external_guard || result != NULL, "Invalid JNI handle"); @@ -68,14 +68,28 @@ inline oop JNIHandles::resolve_impl(jobject handle) { inline oop JNIHandles::resolve(jobject handle) { oop result = NULL; if (handle != NULL) { - result = resolve_impl(handle); + result = resolve_impl<0 /* decorators */, false /* external_guard */>(handle); } return result; } +inline oop JNIHandles::resolve_no_keepalive(jobject handle) { + oop result = NULL; + if (handle != NULL) { + result = resolve_impl(handle); + } + return result; +} + +inline bool JNIHandles::is_same_object(jobject handle1, jobject handle2) { + oop obj1 = resolve_no_keepalive(handle1); + oop obj2 = resolve_no_keepalive(handle2); + return oopDesc::equals(obj1, obj2); +} + inline oop JNIHandles::resolve_non_null(jobject handle) { assert(handle != NULL, "JNI handle should not be null"); - oop result = resolve_impl(handle); + oop result = resolve_impl<0 /* decorators */, false /* external_guard */>(handle); assert(result != NULL, "NULL read from jni handle"); return result; } diff --git a/src/src/hotspot/share/runtime/monitorChunk.cpp b/src/src/hotspot/share/runtime/monitorChunk.cpp index a7e0237d8ec..32c5069087e 100644 --- a/src/src/hotspot/share/runtime/monitorChunk.cpp +++ b/src/src/hotspot/share/runtime/monitorChunk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ MonitorChunk::MonitorChunk(int number_on_monitors) { _number_of_monitors = number_on_monitors; - _monitors = NEW_C_HEAP_ARRAY(BasicObjectLock, number_on_monitors, mtInternal); + _monitors = NEW_C_HEAP_ARRAY(BasicObjectLock, number_on_monitors, mtSynchronizer); _next = NULL; } diff --git a/src/src/hotspot/share/runtime/monitorChunk.hpp b/src/src/hotspot/share/runtime/monitorChunk.hpp index 13540e512f7..4aa9354f382 100644 --- a/src/src/hotspot/share/runtime/monitorChunk.hpp +++ b/src/src/hotspot/share/runtime/monitorChunk.hpp @@ -30,7 +30,7 @@ // Data structure for holding monitors for one activation during // deoptimization. -class MonitorChunk: public CHeapObj { +class MonitorChunk: public CHeapObj { private: int _number_of_monitors; BasicObjectLock* _monitors; diff --git a/src/src/hotspot/share/runtime/mutex.hpp b/src/src/hotspot/share/runtime/mutex.hpp index 5e15734cb24..8c1efd7806e 100644 --- a/src/src/hotspot/share/runtime/mutex.hpp +++ b/src/src/hotspot/share/runtime/mutex.hpp @@ -79,7 +79,7 @@ class ParkEvent ; // TODO: Check if _name[MONITOR_NAME_LEN] should better get replaced by const char*. static const int MONITOR_NAME_LEN = 64; -class Monitor : public CHeapObj { +class Monitor : public CHeapObj { public: // A special lock: Is a lock where you are guaranteed not to block while you are diff --git a/src/src/hotspot/share/runtime/os.hpp b/src/src/hotspot/share/runtime/os.hpp index 8b392b7821a..89f147297cb 100644 --- a/src/src/hotspot/share/runtime/os.hpp +++ b/src/src/hotspot/share/runtime/os.hpp @@ -632,6 +632,7 @@ class os: AllStatic { // Loads .dll/.so and // in case of error it checks if .dll/.so was built for the // same architecture as HotSpot is running on + // in case of an error NULL is returned and an error message is stored in ebuf static void* dll_load(const char *name, char *ebuf, int ebuflen); // lookup symbol in a shared library diff --git a/src/src/hotspot/share/runtime/safepoint.hpp b/src/src/hotspot/share/runtime/safepoint.hpp index 364184a26ad..1ec280bed45 100644 --- a/src/src/hotspot/share/runtime/safepoint.hpp +++ b/src/src/hotspot/share/runtime/safepoint.hpp @@ -225,7 +225,7 @@ class SafepointSynchronize : AllStatic { assert(!SafepointSynchronize::is_at_safepoint(), __VA_ARGS__) // State class for a thread suspended at a safepoint -class ThreadSafepointState: public CHeapObj { +class ThreadSafepointState: public CHeapObj { public: // These states are maintained by VM thread while threads are being brought // to a safepoint. After SafepointSynchronize::end(), they are reset to diff --git a/src/src/hotspot/share/runtime/safepointMechanism.cpp b/src/src/hotspot/share/runtime/safepointMechanism.cpp index 3de81b6b7da..f16a04438cf 100644 --- a/src/src/hotspot/share/runtime/safepointMechanism.cpp +++ b/src/src/hotspot/share/runtime/safepointMechanism.cpp @@ -51,7 +51,7 @@ void SafepointMechanism::default_initialize() { const size_t allocation_size = 2 * page_size; char* polling_page = os::reserve_memory(allocation_size, NULL, page_size); os::commit_memory_or_exit(polling_page, allocation_size, false, "Unable to commit Safepoint polling page"); - MemTracker::record_virtual_memory_type((address)polling_page, mtInternal); + MemTracker::record_virtual_memory_type((address)polling_page, mtSafepoint); char* bad_page = polling_page; char* good_page = polling_page + page_size; @@ -76,6 +76,7 @@ void SafepointMechanism::default_initialize() { char* polling_page = os::reserve_memory(page_size, NULL, page_size); os::commit_memory_or_exit(polling_page, page_size, false, "Unable to commit Safepoint polling page"); os::protect_memory(polling_page, page_size, os::MEM_PROT_READ); + MemTracker::record_virtual_memory_type((address)polling_page, mtSafepoint); log_info(os)("SafePoint Polling address: " INTPTR_FORMAT, p2i(polling_page)); os::set_polling_page((address)(polling_page)); diff --git a/src/src/hotspot/share/runtime/semaphore.hpp b/src/src/hotspot/share/runtime/semaphore.hpp index b97a695e347..3cd6d52dcfc 100644 --- a/src/src/hotspot/share/runtime/semaphore.hpp +++ b/src/src/hotspot/share/runtime/semaphore.hpp @@ -40,7 +40,7 @@ class JavaThread; // Implements the limited, platform independent Semaphore API. -class Semaphore : public CHeapObj { +class Semaphore : public CHeapObj { SemaphoreImpl _impl; // Prevent copying and assignment of Semaphore instances. diff --git a/src/src/hotspot/share/runtime/sharedRuntime.cpp b/src/src/hotspot/share/runtime/sharedRuntime.cpp index 00f0c0e4ee5..881990a26df 100644 --- a/src/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/src/hotspot/share/runtime/sharedRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -1970,7 +1970,7 @@ char* SharedRuntime::generate_class_cast_message( const char* caster_name = caster_klass->external_name(); assert(target_klass != NULL || target_klass_name != NULL, "one must be provided"); - const char* target_name = target_klass == NULL ? target_klass_name->as_C_string() : + const char* target_name = target_klass == NULL ? target_klass_name->as_klass_external_name() : target_klass->external_name(); size_t msglen = strlen(caster_name) + strlen("class ") + strlen(" cannot be cast to class ") + strlen(target_name) + 1; diff --git a/src/src/hotspot/share/runtime/simpleThresholdPolicy.inline.hpp b/src/src/hotspot/share/runtime/simpleThresholdPolicy.inline.hpp deleted file mode 100644 index e2d1b36b98b..00000000000 --- a/src/src/hotspot/share/runtime/simpleThresholdPolicy.inline.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_INLINE_HPP -#define SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_INLINE_HPP - -#include "compiler/compilerOracle.hpp" -#include "oops/method.inline.hpp" - -#ifdef TIERED - -template -bool SimpleThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) { - double threshold_scaling; - if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { - scale *= threshold_scaling; - } - switch(level) { - case CompLevel_aot: - return (i >= Tier3AOTInvocationThreshold * scale) || - (i >= Tier3AOTMinInvocationThreshold * scale && i + b >= Tier3AOTCompileThreshold * scale); - case CompLevel_none: - case CompLevel_limited_profile: - return (i >= Tier3InvocationThreshold * scale) || - (i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale); - case CompLevel_full_profile: - return (i >= Tier4InvocationThreshold * scale) || - (i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale); - } - return true; -} - -template -bool SimpleThresholdPolicy::loop_predicate_helper(int i, int b, double scale, Method* method) { - double threshold_scaling; - if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { - scale *= threshold_scaling; - } - switch(level) { - case CompLevel_aot: - return b >= Tier3AOTBackEdgeThreshold * scale; - case CompLevel_none: - case CompLevel_limited_profile: - return b >= Tier3BackEdgeThreshold * scale; - case CompLevel_full_profile: - return b >= Tier4BackEdgeThreshold * scale; - } - return true; -} - -// Simple methods are as good being compiled with C1 as C2. -// Determine if a given method is such a case. -bool SimpleThresholdPolicy::is_trivial(Method* method) { - if (method->is_accessor() || - method->is_constant_getter()) { - return true; - } -#if INCLUDE_JVMCI - if (UseJVMCICompiler) { - AbstractCompiler* comp = CompileBroker::compiler(CompLevel_full_optimization); - if (TieredCompilation && comp != NULL && comp->is_trivial(method)) { - return true; - } - } -#endif - if (method->has_loops() || method->code_size() >= 15) { - return false; - } - MethodData* mdo = method->method_data(); - if (mdo != NULL && !mdo->would_profile() && - (method->code_size() < 5 || (mdo->num_blocks() < 4))) { - return true; - } - return false; -} - -inline CompLevel SimpleThresholdPolicy::comp_level(Method* method) { - CompiledMethod *nm = method->code(); - if (nm != NULL && nm->is_in_use()) { - return (CompLevel)nm->comp_level(); - } - return CompLevel_none; -} - -#endif // TIERED - -#endif // SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_INLINE_HPP diff --git a/src/src/hotspot/share/runtime/thread.cpp b/src/src/hotspot/share/runtime/thread.cpp index 9ecd3a01b01..34ecfe0df25 100644 --- a/src/src/hotspot/share/runtime/thread.cpp +++ b/src/src/hotspot/share/runtime/thread.cpp @@ -2577,8 +2577,7 @@ void JavaThread::remove_stack_guard_pages() { } void JavaThread::enable_stack_reserved_zone() { - assert(_stack_guard_state != stack_guard_unused, "must be using guard pages."); - assert(_stack_guard_state != stack_guard_enabled, "already enabled"); + assert(_stack_guard_state == stack_guard_reserved_disabled, "inconsistent state"); // The base notation is from the stack's point of view, growing downward. // We need to adjust it to work correctly with guard_memory() @@ -2596,11 +2595,10 @@ void JavaThread::enable_stack_reserved_zone() { } void JavaThread::disable_stack_reserved_zone() { - assert(_stack_guard_state != stack_guard_unused, "must be using guard pages."); - assert(_stack_guard_state != stack_guard_reserved_disabled, "already disabled"); + assert(_stack_guard_state == stack_guard_enabled, "inconsistent state"); // Simply return if called for a thread that does not use guard pages. - if (_stack_guard_state == stack_guard_unused) return; + if (_stack_guard_state != stack_guard_enabled) return; // The base notation is from the stack's point of view, growing downward. // We need to adjust it to work correctly with guard_memory() @@ -4688,7 +4686,7 @@ void Threads::print_on_error(outputStream* st, Thread* current, char* buf, print_threads_compiling(st, buf, buflen); } -void Threads::print_threads_compiling(outputStream* st, char* buf, int buflen) { +void Threads::print_threads_compiling(outputStream* st, char* buf, int buflen, bool short_form) { ALL_JAVA_THREADS(thread) { if (thread->is_Compiler_thread()) { CompilerThread* ct = (CompilerThread*) thread; @@ -4700,7 +4698,7 @@ void Threads::print_threads_compiling(outputStream* st, char* buf, int buflen) { CompileTask* task = ct->task(); if (task != NULL) { thread->print_name_on_error(st, buf, buflen); - task->print(st, NULL, true, true); + task->print(st, NULL, short_form, true); } } } diff --git a/src/src/hotspot/share/runtime/thread.hpp b/src/src/hotspot/share/runtime/thread.hpp index fb450d2735c..90cb7cb17a8 100644 --- a/src/src/hotspot/share/runtime/thread.hpp +++ b/src/src/hotspot/share/runtime/thread.hpp @@ -2194,7 +2194,7 @@ class Threads: AllStatic { static void print_on_error(outputStream* st, Thread* current, char* buf, int buflen); static void print_on_error(Thread* this_thread, outputStream* st, Thread* current, char* buf, int buflen, bool* found_current); - static void print_threads_compiling(outputStream* st, char* buf, int buflen); + static void print_threads_compiling(outputStream* st, char* buf, int buflen, bool short_form = false); // Get Java threads that are waiting to enter a monitor. static GrowableArray* get_pending_threads(ThreadsList * t_list, diff --git a/src/src/hotspot/share/runtime/simpleThresholdPolicy.cpp b/src/src/hotspot/share/runtime/tieredThresholdPolicy.cpp similarity index 84% rename from src/src/hotspot/share/runtime/simpleThresholdPolicy.cpp rename to src/src/hotspot/share/runtime/tieredThresholdPolicy.cpp index 4f9ab21282f..0e9e90a64b4 100644 --- a/src/src/hotspot/share/runtime/simpleThresholdPolicy.cpp +++ b/src/src/hotspot/share/runtime/tieredThresholdPolicy.cpp @@ -24,20 +24,81 @@ #include "precompiled.hpp" #include "compiler/compileBroker.hpp" +#include "compiler/compilerOracle.hpp" #include "memory/resourceArea.hpp" #include "runtime/arguments.hpp" #include "runtime/handles.inline.hpp" #include "runtime/safepointVerifiers.hpp" -#include "runtime/simpleThresholdPolicy.hpp" -#include "runtime/simpleThresholdPolicy.inline.hpp" +#include "runtime/tieredThresholdPolicy.hpp" #include "code/scopeDesc.hpp" +#include "oops/method.inline.hpp" #if INCLUDE_JVMCI #include "jvmci/jvmciRuntime.hpp" #endif #ifdef TIERED -void SimpleThresholdPolicy::print_counters(const char* prefix, const methodHandle& mh) { +#include "c1/c1_Compiler.hpp" +#include "opto/c2compiler.hpp" + +template +bool TieredThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) { + double threshold_scaling; + if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { + scale *= threshold_scaling; + } + switch(level) { + case CompLevel_aot: + return (i >= Tier3AOTInvocationThreshold * scale) || + (i >= Tier3AOTMinInvocationThreshold * scale && i + b >= Tier3AOTCompileThreshold * scale); + case CompLevel_none: + case CompLevel_limited_profile: + return (i >= Tier3InvocationThreshold * scale) || + (i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale); + case CompLevel_full_profile: + return (i >= Tier4InvocationThreshold * scale) || + (i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale); + } + return true; +} + +template +bool TieredThresholdPolicy::loop_predicate_helper(int i, int b, double scale, Method* method) { + double threshold_scaling; + if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { + scale *= threshold_scaling; + } + switch(level) { + case CompLevel_aot: + return b >= Tier3AOTBackEdgeThreshold * scale; + case CompLevel_none: + case CompLevel_limited_profile: + return b >= Tier3BackEdgeThreshold * scale; + case CompLevel_full_profile: + return b >= Tier4BackEdgeThreshold * scale; + } + return true; +} + +// Simple methods are as good being compiled with C1 as C2. +// Determine if a given method is such a case. +bool TieredThresholdPolicy::is_trivial(Method* method) { + if (method->is_accessor() || + method->is_constant_getter()) { + return true; + } + return false; +} + +inline CompLevel TieredThresholdPolicy::comp_level(Method* method) { + CompiledMethod *nm = method->code(); + if (nm != NULL && nm->is_in_use()) { + return (CompLevel)nm->comp_level(); + } + return CompLevel_none; +} + +void TieredThresholdPolicy::print_counters(const char* prefix, const methodHandle& mh) { int invocation_count = mh->invocation_count(); int backedge_count = mh->backedge_count(); MethodData* mdh = mh->method_data(); @@ -58,7 +119,7 @@ void SimpleThresholdPolicy::print_counters(const char* prefix, const methodHandl } // Print an event. -void SimpleThresholdPolicy::print_event(EventType type, const methodHandle& mh, const methodHandle& imh, +void TieredThresholdPolicy::print_event(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level) { bool inlinee_event = mh() != imh(); @@ -139,8 +200,9 @@ void SimpleThresholdPolicy::print_event(EventType type, const methodHandle& mh, tty->print_cr("]"); } -void SimpleThresholdPolicy::initialize() { +void TieredThresholdPolicy::initialize() { int count = CICompilerCount; + bool c1_only = TieredStopAtLevel < CompLevel_full_optimization; #ifdef _LP64 // Turn on ergonomic compiler count selection if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) { @@ -151,6 +213,15 @@ void SimpleThresholdPolicy::initialize() { int log_cpu = log2_int(os::active_processor_count()); int loglog_cpu = log2_int(MAX2(log_cpu, 1)); count = MAX2(log_cpu * loglog_cpu * 3 / 2, 2); + // Make sure there is enough space in the code cache to hold all the compiler buffers + size_t c1_size = Compiler::code_buffer_size(); + size_t c2_size = C2Compiler::initial_code_buffer_size(); + size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3); + int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size; + if (count > max_count) { + // Lower the compiler count such that all buffers fit into the code cache + count = MAX2(max_count, c1_only ? 1 : 2); + } FLAG_SET_ERGO(intx, CICompilerCount, count); } #else @@ -167,7 +238,7 @@ void SimpleThresholdPolicy::initialize() { } #endif - if (TieredStopAtLevel < CompLevel_full_optimization) { + if (c1_only) { // No C2 compiler thread required set_c1_count(count); } else { @@ -193,14 +264,14 @@ void SimpleThresholdPolicy::initialize() { set_start_time(os::javaTimeMillis()); } -void SimpleThresholdPolicy::set_carry_if_necessary(InvocationCounter *counter) { +void TieredThresholdPolicy::set_carry_if_necessary(InvocationCounter *counter) { if (!counter->carry() && counter->count() > InvocationCounter::count_limit / 2) { counter->set_carry_flag(); } } // Set carry flags on the counters if necessary -void SimpleThresholdPolicy::handle_counter_overflow(Method* method) { +void TieredThresholdPolicy::handle_counter_overflow(Method* method) { MethodCounters *mcs = method->method_counters(); if (mcs != NULL) { set_carry_if_necessary(mcs->invocation_counter()); @@ -214,7 +285,7 @@ void SimpleThresholdPolicy::handle_counter_overflow(Method* method) { } // Called with the queue locked and with at least one element -CompileTask* SimpleThresholdPolicy::select_task(CompileQueue* compile_queue) { +CompileTask* TieredThresholdPolicy::select_task(CompileQueue* compile_queue) { CompileTask *max_blocking_task = NULL; CompileTask *max_task = NULL; Method* max_method = NULL; @@ -223,28 +294,24 @@ CompileTask* SimpleThresholdPolicy::select_task(CompileQueue* compile_queue) { for (CompileTask* task = compile_queue->first(); task != NULL;) { CompileTask* next_task = task->next(); Method* method = task->method(); - update_rate(t, method); - if (max_task == NULL) { - max_task = task; - max_method = method; - } else { - // If a method has been stale for some time, remove it from the queue. - // Blocking tasks and tasks submitted from whitebox API don't become stale - if (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { + // If a method was unloaded or has been stale for some time, remove it from the queue. + // Blocking tasks and tasks submitted from whitebox API don't become stale + if (task->is_unloaded() || (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method))) { + if (!task->is_unloaded()) { if (PrintTieredEvents) { - print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level()); + print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel) task->comp_level()); } - compile_queue->remove_and_mark_stale(task); method->clear_queued_for_compilation(); - task = next_task; - continue; - } - - // Select a method with a higher rate - if (compare_methods(method, max_method)) { - max_task = task; - max_method = method; } + compile_queue->remove_and_mark_stale(task); + task = next_task; + continue; + } + update_rate(t, method); + if (max_task == NULL || compare_methods(method, max_method)) { + // Select a method with the highest rate + max_task = task; + max_method = method; } if (task->is_blocking()) { @@ -270,6 +337,16 @@ CompileTask* SimpleThresholdPolicy::select_task(CompileQueue* compile_queue) { TieredStopAtLevel > CompLevel_full_profile && max_method != NULL && is_method_profiled(max_method)) { max_task->set_comp_level(CompLevel_limited_profile); + + if (CompileBroker::compilation_is_complete(max_method, max_task->osr_bci(), CompLevel_limited_profile)) { + if (PrintTieredEvents) { + print_event(REMOVE_FROM_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); + } + compile_queue->remove_and_mark_stale(max_task); + max_method->clear_queued_for_compilation(); + return NULL; + } + if (PrintTieredEvents) { print_event(UPDATE_IN_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); } @@ -278,7 +355,7 @@ CompileTask* SimpleThresholdPolicy::select_task(CompileQueue* compile_queue) { return max_task; } -void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { +void TieredThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) { if (PrintTieredEvents) { methodHandle mh(sd->method()); @@ -292,7 +369,7 @@ void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { } } -nmethod* SimpleThresholdPolicy::event(const methodHandle& method, const methodHandle& inlinee, +nmethod* TieredThresholdPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) { if (comp_level == CompLevel_none && JvmtiExport::can_post_interpreter_events() && @@ -329,7 +406,7 @@ nmethod* SimpleThresholdPolicy::event(const methodHandle& method, const methodHa } // Check if the method can be compiled, change level if necessary -void SimpleThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { +void TieredThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { assert(level <= TieredStopAtLevel, "Invalid compilation level"); if (level == CompLevel_none) { return; @@ -374,14 +451,14 @@ void SimpleThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel l } // Update the rate and submit compile -void SimpleThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { +void TieredThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); update_rate(os::javaTimeMillis(), mh()); CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread); } // Print an event. -void SimpleThresholdPolicy::print_specific(EventType type, const methodHandle& mh, const methodHandle& imh, +void TieredThresholdPolicy::print_specific(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level) { tty->print(" rate="); if (mh->prev_time() == 0) tty->print("n/a"); @@ -393,7 +470,7 @@ void SimpleThresholdPolicy::print_specific(EventType type, const methodHandle& m } // update_rate() is called from select_task() while holding a compile queue lock. -void SimpleThresholdPolicy::update_rate(jlong t, Method* m) { +void TieredThresholdPolicy::update_rate(jlong t, Method* m) { // Skip update if counters are absent. // Can't allocate them since we are holding compile queue lock. if (m->method_counters() == NULL) return; @@ -429,9 +506,9 @@ void SimpleThresholdPolicy::update_rate(jlong t, Method* m) { } } -// Check if this method has been stale from a given number of milliseconds. +// Check if this method has been stale for a given number of milliseconds. // See select_task(). -bool SimpleThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) { +bool TieredThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) { jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint(); jlong delta_t = t - m->prev_time(); if (delta_t > timeout && delta_s > timeout) { @@ -445,17 +522,17 @@ bool SimpleThresholdPolicy::is_stale(jlong t, jlong timeout, Method* m) { // We don't remove old methods from the compile queue even if they have // very low activity. See select_task(). -bool SimpleThresholdPolicy::is_old(Method* method) { +bool TieredThresholdPolicy::is_old(Method* method) { return method->invocation_count() > 50000 || method->backedge_count() > 500000; } -double SimpleThresholdPolicy::weight(Method* method) { +double TieredThresholdPolicy::weight(Method* method) { return (double)(method->rate() + 1) * (method->invocation_count() + 1) * (method->backedge_count() + 1); } // Apply heuristics and return true if x should be compiled before y -bool SimpleThresholdPolicy::compare_methods(Method* x, Method* y) { +bool TieredThresholdPolicy::compare_methods(Method* x, Method* y) { if (x->highest_comp_level() > y->highest_comp_level()) { // recompilation after deopt return true; @@ -469,7 +546,7 @@ bool SimpleThresholdPolicy::compare_methods(Method* x, Method* y) { } // Is method profiled enough? -bool SimpleThresholdPolicy::is_method_profiled(Method* method) { +bool TieredThresholdPolicy::is_method_profiled(Method* method) { MethodData* mdo = method->method_data(); if (mdo != NULL) { int i = mdo->invocation_count_delta(); @@ -479,7 +556,7 @@ bool SimpleThresholdPolicy::is_method_profiled(Method* method) { return false; } -double SimpleThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) { +double TieredThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) { double queue_size = CompileBroker::queue_size(level); int comp_count = compiler_count(level); double k = queue_size / (feedback_k * comp_count) + 1; @@ -503,7 +580,7 @@ double SimpleThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) { // Tier?LoadFeedback is basically a coefficient that determines of // how many methods per compiler thread can be in the queue before // the threshold values double. -bool SimpleThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, Method* method) { +bool TieredThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, Method* method) { switch(cur_level) { case CompLevel_aot: { double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); @@ -523,7 +600,7 @@ bool SimpleThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, Me } } -bool SimpleThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, Method* method) { +bool TieredThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, Method* method) { switch(cur_level) { case CompLevel_aot: { double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); @@ -544,7 +621,7 @@ bool SimpleThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, Me } // Determine is a method is mature. -bool SimpleThresholdPolicy::is_mature(Method* method) { +bool TieredThresholdPolicy::is_mature(Method* method) { if (is_trivial(method)) return true; MethodData* mdo = method->method_data(); if (mdo != NULL) { @@ -560,7 +637,7 @@ bool SimpleThresholdPolicy::is_mature(Method* method) { // If a method is old enough and is still in the interpreter we would want to // start profiling without waiting for the compiled method to arrive. // We also take the load on compilers into the account. -bool SimpleThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_level) { +bool TieredThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_level) { if (cur_level == CompLevel_none && CompileBroker::queue_size(CompLevel_full_optimization) <= Tier3DelayOn * compiler_count(CompLevel_full_optimization)) { @@ -574,7 +651,7 @@ bool SimpleThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_leve // Inlining control: if we're compiling a profiled method with C1 and the callee // is known to have OSRed in a C2 version, don't inline it. -bool SimpleThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) { +bool TieredThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) { CompLevel comp_level = (CompLevel)env->comp_level(); if (comp_level == CompLevel_full_profile || comp_level == CompLevel_limited_profile) { @@ -584,7 +661,7 @@ bool SimpleThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) { } // Create MDO if necessary. -void SimpleThresholdPolicy::create_mdo(const methodHandle& mh, JavaThread* THREAD) { +void TieredThresholdPolicy::create_mdo(const methodHandle& mh, JavaThread* THREAD) { if (mh->is_native() || mh->is_abstract() || mh->is_accessor() || @@ -636,7 +713,7 @@ void SimpleThresholdPolicy::create_mdo(const methodHandle& mh, JavaThread* THREA */ // Common transition function. Given a predicate determines if a method should transition to another level. -CompLevel SimpleThresholdPolicy::common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback) { +CompLevel TieredThresholdPolicy::common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback) { CompLevel next_level = cur_level; int i = method->invocation_count(); int b = method->backedge_count(); @@ -740,10 +817,10 @@ CompLevel SimpleThresholdPolicy::common(Predicate p, Method* method, CompLevel c } // Determine if a method should be compiled with a normal entry point at a different level. -CompLevel SimpleThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread * thread) { +CompLevel TieredThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread * thread) { CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), - common(&SimpleThresholdPolicy::loop_predicate, method, cur_level, true)); - CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level); + common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true)); + CompLevel next_level = common(&TieredThresholdPolicy::call_predicate, method, cur_level); // If OSR method level is greater than the regular method level, the levels should be // equalized by raising the regular method level in order to avoid OSRs during each @@ -766,8 +843,8 @@ CompLevel SimpleThresholdPolicy::call_event(Method* method, CompLevel cur_level, } // Determine if we should do an OSR compilation of a given method. -CompLevel SimpleThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) { - CompLevel next_level = common(&SimpleThresholdPolicy::loop_predicate, method, cur_level, true); +CompLevel TieredThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) { + CompLevel next_level = common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true); if (cur_level == CompLevel_none) { // If there is a live OSR method that means that we deopted to the interpreter // for the transition. @@ -784,7 +861,7 @@ CompLevel SimpleThresholdPolicy::loop_event(Method* method, CompLevel cur_level, return next_level; } -bool SimpleThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) { +bool TieredThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread) { if (UseAOT && !delay_compilation_during_startup()) { if (cur_level == CompLevel_full_profile || cur_level == CompLevel_none) { // If the current level is full profile or interpreter and we're switching to any other level, @@ -805,7 +882,7 @@ bool SimpleThresholdPolicy::maybe_switch_to_aot(const methodHandle& mh, CompLeve // Handle the invocation event. -void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, +void TieredThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, CompLevel level, CompiledMethod* nm, JavaThread* thread) { if (should_create_mdo(mh(), level)) { create_mdo(mh, thread); @@ -824,7 +901,7 @@ void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, cons // Handle the back branch event. Notice that we can compile the method // with a regular entry from here. -void SimpleThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, +void TieredThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) { if (should_create_mdo(mh(), level)) { create_mdo(mh, thread); diff --git a/src/src/hotspot/share/runtime/simpleThresholdPolicy.hpp b/src/src/hotspot/share/runtime/tieredThresholdPolicy.hpp similarity index 97% rename from src/src/hotspot/share/runtime/simpleThresholdPolicy.hpp rename to src/src/hotspot/share/runtime/tieredThresholdPolicy.hpp index 4f668f197c4..a7eab913f33 100644 --- a/src/src/hotspot/share/runtime/simpleThresholdPolicy.hpp +++ b/src/src/hotspot/share/runtime/tieredThresholdPolicy.hpp @@ -22,8 +22,8 @@ * */ -#ifndef SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP -#define SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP +#ifndef SHARE_VM_RUNTIME_TIEREDTHRESHOLDPOLICY_HPP +#define SHARE_VM_RUNTIME_TIEREDTHRESHOLDPOLICY_HPP #include "code/nmethod.hpp" #include "oops/methodData.hpp" @@ -162,7 +162,7 @@ class CompileQueue; * to be zero if no events occurred in TieredRateUpdateMaxTime. */ -class SimpleThresholdPolicy : public CompilationPolicy { +class TieredThresholdPolicy : public CompilationPolicy { jlong _start_time; int _c1_count, _c2_count; @@ -173,7 +173,7 @@ class SimpleThresholdPolicy : public CompilationPolicy { // Call and loop predicates determine whether a transition to a higher compilation // level should be performed (pointers to predicate functions are passed to common_TF(). // Predicates also take compiler load into account. - typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level, Method* method); + typedef bool (TieredThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level, Method* method); bool call_predicate(int i, int b, CompLevel cur_level, Method* method); bool loop_predicate(int i, int b, CompLevel cur_level, Method* method); // Common transition function. Given a predicate determines if a method should transition to another level. @@ -250,7 +250,7 @@ class SimpleThresholdPolicy : public CompilationPolicy { jlong start_time() const { return _start_time; } public: - SimpleThresholdPolicy() : _start_time(0), _c1_count(0), _c2_count(0) { } + TieredThresholdPolicy() : _start_time(0), _c1_count(0), _c2_count(0) { } virtual int compiler_count(CompLevel comp_level) { if (is_c1_compile(comp_level)) return c1_count(); if (is_c2_compile(comp_level)) return c2_count(); @@ -274,4 +274,4 @@ class SimpleThresholdPolicy : public CompilationPolicy { #endif // TIERED -#endif // SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP +#endif // SHARE_VM_RUNTIME_TIEREDTHRESHOLDPOLICY_HPP diff --git a/src/src/hotspot/share/runtime/vm_version.cpp b/src/src/hotspot/share/runtime/vm_version.cpp index eb05460adef..32fae61a7de 100644 --- a/src/src/hotspot/share/runtime/vm_version.cpp +++ b/src/src/hotspot/share/runtime/vm_version.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -44,6 +44,8 @@ bool Abstract_VM_Version::_supports_atomic_getadd8 = false; unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U; unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0; +VirtualizationType Abstract_VM_Version::_detected_virtualization = NoDetectedVirtualization; + #ifndef HOTSPOT_VERSION_STRING #error HOTSPOT_VERSION_STRING must be defined #endif @@ -301,7 +303,6 @@ unsigned int Abstract_VM_Version::jvm_version() { (Abstract_VM_Version::vm_build_number() & 0xFF); } - void VM_Version_init() { VM_Version::initialize(); @@ -313,6 +314,30 @@ void VM_Version_init() { } } +bool Abstract_VM_Version::print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) { + char line[500]; + FILE* fp = fopen(filename, "r"); + if (fp == NULL) { + return false; + } + + st->print_cr("Virtualization information:"); + while (fgets(line, sizeof(line), fp) != NULL) { + int i = 0; + while (keywords_to_match[i] != NULL) { + if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) { + st->print("%s", line); + break; + } + i++; + } + } + fclose(fp); + return true; +} + + + unsigned int Abstract_VM_Version::nof_parallel_worker_threads( unsigned int num, unsigned int den, diff --git a/src/src/hotspot/share/runtime/vm_version.hpp b/src/src/hotspot/share/runtime/vm_version.hpp index e0f89ea958c..89bd840a3d9 100644 --- a/src/src/hotspot/share/runtime/vm_version.hpp +++ b/src/src/hotspot/share/runtime/vm_version.hpp @@ -29,6 +29,14 @@ #include "utilities/ostream.hpp" #include "utilities/macros.hpp" +typedef enum { + NoDetectedVirtualization, + XenHVM, + KVM, + VMWare, + HyperV +} VirtualizationType; + // VM_Version provides information about the VM. class Abstract_VM_Version: AllStatic { @@ -56,6 +64,9 @@ class Abstract_VM_Version: AllStatic { static int _vm_security_version; static int _vm_patch_version; static int _vm_build_number; + + static VirtualizationType _detected_virtualization; + static unsigned int _parallel_worker_threads; static bool _parallel_worker_threads_initialized; @@ -116,6 +127,14 @@ class Abstract_VM_Version: AllStatic { return _features_string; } + static VirtualizationType get_detected_virtualization() { + return _detected_virtualization; + } + + // platforms that need to specialize this + // define VM_Version::print_platform_virtualization_info() + static void print_platform_virtualization_info(outputStream*) { } + // does HW support an 8-byte compare-exchange operation? static bool supports_cx8() { #ifdef SUPPORTS_NATIVE_CX8 @@ -159,6 +178,8 @@ class Abstract_VM_Version: AllStatic { // Does this CPU support spin wait instruction? static bool supports_on_spin_wait() { return false; } + + static bool print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]); }; #include CPU_HEADER(vm_version) diff --git a/src/src/hotspot/share/services/allocationSite.hpp b/src/src/hotspot/share/services/allocationSite.hpp index edf55b34353..ec8c470432a 100644 --- a/src/src/hotspot/share/services/allocationSite.hpp +++ b/src/src/hotspot/share/services/allocationSite.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_VM_SERVICES_ALLOCATION_SITE_HPP #define SHARE_VM_SERVICES_ALLOCATION_SITE_HPP +#include "memory/allocation.hpp" #include "utilities/nativeCallStack.hpp" // Allocation site represents a code path that makes a memory @@ -33,8 +34,9 @@ template class AllocationSite { private: NativeCallStack _call_stack; E e; + MEMFLAGS _flag; public: - AllocationSite(const NativeCallStack& stack) : _call_stack(stack) { } + AllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : _call_stack(stack), _flag(flag) { } int hash() const { return _call_stack.hash(); } bool equals(const NativeCallStack& stack) const { return _call_stack.equals(stack); @@ -51,6 +53,8 @@ template class AllocationSite { // Information regarding this allocation E* data() { return &e; } const E* peek() const { return &e; } + + MEMFLAGS flag() const { return _flag; } }; #endif // SHARE_VM_SERVICES_ALLOCATION_SITE_HPP diff --git a/src/src/hotspot/share/services/diagnosticArgument.cpp b/src/src/hotspot/share/services/diagnosticArgument.cpp index c3d6886bd9e..71719f0b6e8 100644 --- a/src/src/hotspot/share/services/diagnosticArgument.cpp +++ b/src/src/hotspot/share/services/diagnosticArgument.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -179,9 +179,9 @@ template <> void DCmdArgument::parse_value(const char* str, if (str == NULL) { _value = NULL; } else { - _value = NEW_C_HEAP_ARRAY(char, len+1, mtInternal); - strncpy(_value, str, len); - _value[len] = 0; + _value = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal); + int n = os::snprintf(_value, len + 1, "%.*s", (int)len, str); + assert((size_t)n <= len, "Unexpected number of characters in string"); } } diff --git a/src/src/hotspot/share/services/diagnosticCommand.cpp b/src/src/hotspot/share/services/diagnosticCommand.cpp index 814376b6765..a6462e3c5fa 100644 --- a/src/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/src/hotspot/share/services/diagnosticCommand.cpp @@ -943,13 +943,20 @@ void CodeCacheDCmd::execute(DCmdSource source, TRAPS) { CodeHeapAnalyticsDCmd::CodeHeapAnalyticsDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), _function("function", "Function to be performed (aggregate, UsedSpace, FreeSpace, MethodCount, MethodSpace, MethodAge, MethodNames, discard", "STRING", false, "all"), - _granularity("granularity", "Detail level - smaller value -> more detail", "STRING", false, "4096") { + _granularity("granularity", "Detail level - smaller value -> more detail", "INT", false, "4096") { _dcmdparser.add_dcmd_argument(&_function); _dcmdparser.add_dcmd_argument(&_granularity); } void CodeHeapAnalyticsDCmd::execute(DCmdSource source, TRAPS) { - CompileBroker::print_heapinfo(output(), _function.value(), _granularity.value()); + jlong granularity = _granularity.value(); + if (granularity < 1) { + Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(), + "Invalid granularity value " JLONG_FORMAT ". Should be positive.\n", granularity); + return; + } + + CompileBroker::print_heapinfo(output(), _function.value(), granularity); } int CodeHeapAnalyticsDCmd::num_arguments() { diff --git a/src/src/hotspot/share/services/diagnosticCommand.hpp b/src/src/hotspot/share/services/diagnosticCommand.hpp index 45bb2a32107..38b620e0a06 100644 --- a/src/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/src/hotspot/share/services/diagnosticCommand.hpp @@ -646,7 +646,7 @@ class CodeCacheDCmd : public DCmd { class CodeHeapAnalyticsDCmd : public DCmdWithParser { protected: DCmdArgument _function; - DCmdArgument _granularity; + DCmdArgument _granularity; public: CodeHeapAnalyticsDCmd(outputStream* output, bool heap); static const char* name() { diff --git a/src/src/hotspot/share/services/heapDumper.cpp b/src/src/hotspot/share/services/heapDumper.cpp index 1ce98d5084e..89feeec88d6 100644 --- a/src/src/hotspot/share/services/heapDumper.cpp +++ b/src/src/hotspot/share/services/heapDumper.cpp @@ -955,6 +955,11 @@ void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k // creates HPROF_GC_INSTANCE_DUMP record for the given object void DumperSupport::dump_instance(DumpWriter* writer, oop o) { Klass* k = o->klass(); + if (k->java_mirror() == NULL) { + // Ignoring this object since the corresponding java mirror is not loaded. + // Might be a dormant archive object. + return; + } writer->write_u1(HPROF_GC_INSTANCE_DUMP); writer->write_objectID(o); diff --git a/src/src/hotspot/share/services/mallocSiteTable.cpp b/src/src/hotspot/share/services/mallocSiteTable.cpp index 24fa2a54a4b..9156430b25e 100644 --- a/src/src/hotspot/share/services/mallocSiteTable.cpp +++ b/src/src/hotspot/share/services/mallocSiteTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -163,7 +163,7 @@ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* b MallocSiteHashtableEntry* head = _table[index]; while (head != NULL && (*pos_idx) <= MAX_BUCKET_LENGTH) { MallocSite* site = head->data(); - if (site->flags() == flags && site->equals(key)) { + if (site->flag() == flags && site->equals(key)) { return head->data(); } diff --git a/src/src/hotspot/share/services/mallocSiteTable.hpp b/src/src/hotspot/share/services/mallocSiteTable.hpp index 3a99ad384ad..febca63680c 100644 --- a/src/src/hotspot/share/services/mallocSiteTable.hpp +++ b/src/src/hotspot/share/services/mallocSiteTable.hpp @@ -37,15 +37,12 @@ // MallocSite represents a code path that eventually calls // os::malloc() to allocate memory class MallocSite : public AllocationSite { - private: - MEMFLAGS _flags; - public: MallocSite() : - AllocationSite(NativeCallStack::empty_stack()), _flags(mtNone) {} + AllocationSite(NativeCallStack::empty_stack(), mtNone) {} MallocSite(const NativeCallStack& stack, MEMFLAGS flags) : - AllocationSite(stack), _flags(flags) {} + AllocationSite(stack, flags) {} void allocate(size_t size) { data()->allocate(size); } @@ -55,7 +52,6 @@ class MallocSite : public AllocationSite { size_t size() const { return peek()->size(); } // The number of calls were made size_t count() const { return peek()->count(); } - MEMFLAGS flags() const { return (MEMFLAGS)_flags; } }; // Malloc site hashtable entry diff --git a/src/src/hotspot/share/services/memBaseline.cpp b/src/src/hotspot/share/services/memBaseline.cpp index a56bf50a75a..b10f6dd8e96 100644 --- a/src/src/hotspot/share/services/memBaseline.cpp +++ b/src/src/hotspot/share/services/memBaseline.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -64,7 +64,7 @@ int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) { int res = compare_malloc_site(s1, s2); if (res == 0) { - res = (int)(s1.flags() - s2.flags()); + res = (int)(s1.flag() - s2.flag()); } return res; @@ -212,7 +212,7 @@ bool MemBaseline::aggregate_virtual_memory_allocation_sites() { const ReservedMemoryRegion* rgn; VirtualMemoryAllocationSite* site; while ((rgn = itr.next()) != NULL) { - VirtualMemoryAllocationSite tmp(*rgn->call_stack()); + VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->flag()); site = allocation_sites.find(tmp); if (site == NULL) { LinkedListNode* node = diff --git a/src/src/hotspot/share/services/memReporter.cpp b/src/src/hotspot/share/services/memReporter.cpp index 1d0e7076ec8..a6e815d4f86 100644 --- a/src/src/hotspot/share/services/memReporter.cpp +++ b/src/src/hotspot/share/services/memReporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -240,7 +240,7 @@ void MemDetailReporter::report_malloc_sites() { const NativeCallStack* stack = malloc_site->call_stack(); stack->print_on(out); out->print("%29s", " "); - MEMFLAGS flag = malloc_site->flags(); + MEMFLAGS flag = malloc_site->flag(); assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone, "Must have a valid memory type"); print_malloc(malloc_site->size(), malloc_site->count(),flag); @@ -266,6 +266,10 @@ void MemDetailReporter::report_virtual_memory_allocation_sites() { stack->print_on(out); out->print("%28s (", " "); print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); + MEMFLAGS flag = virtual_memory_site->flag(); + if (flag != mtNone) { + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + } out->print_cr(")\n"); } } @@ -690,24 +694,24 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const { void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), - 0, 0, malloc_site->flags()); + 0, 0, malloc_site->flag()); } void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), - malloc_site->count(), malloc_site->flags()); + malloc_site->count(), malloc_site->flag()); } void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, const MallocSite* current) const { - if (early->flags() != current->flags()) { + if (early->flag() != current->flag()) { // If malloc site type changed, treat it as deallocation of old type and // allocation of new type. old_malloc_site(early); new_malloc_site(current); } else { diff_malloc_site(current->call_stack(), current->size(), current->count(), - early->size(), early->count(), early->flags()); + early->size(), early->count(), early->flag()); } } @@ -731,21 +735,22 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_ void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); + diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->flag()); } void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); + diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->flag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, const VirtualMemoryAllocationSite* current) const { + assert(early->flag() == current->flag(), "Should be the same"); diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), - early->reserved(), early->committed()); + early->reserved(), early->committed(), current->flag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed) const { + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const { outputStream* out = output(); // no change @@ -759,5 +764,9 @@ void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stac print_virtual_memory_diff(current_reserved, current_committed, early_reserved, early_committed); + if (flag != mtNone) { + out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + } + out->print_cr(")\n"); } diff --git a/src/src/hotspot/share/services/memReporter.hpp b/src/src/hotspot/share/services/memReporter.hpp index 3fdec239365..8642990aa9b 100644 --- a/src/src/hotspot/share/services/memReporter.hpp +++ b/src/src/hotspot/share/services/memReporter.hpp @@ -230,7 +230,7 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter { void diff_malloc_site(const NativeCallStack* stack, size_t current_size, size_t currrent_count, size_t early_size, size_t early_count, MEMFLAGS flags) const; void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed) const; + size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const; }; #endif // INCLUDE_NMT diff --git a/src/src/hotspot/share/services/memTracker.cpp b/src/src/hotspot/share/services/memTracker.cpp index 98dd1b98988..6ed064132d6 100644 --- a/src/src/hotspot/share/services/memTracker.cpp +++ b/src/src/hotspot/share/services/memTracker.cpp @@ -32,6 +32,7 @@ #include "services/memReporter.hpp" #include "services/mallocTracker.inline.hpp" #include "services/memTracker.hpp" +#include "utilities/debug.hpp" #include "utilities/defaultStream.hpp" #include "utilities/vmError.hpp" @@ -55,6 +56,10 @@ bool MemTracker::_is_nmt_env_valid = true; static const size_t buffer_size = 64; NMT_TrackingLevel MemTracker::init_tracking_level() { + // Memory type is encoded into tracking header as a byte field, + // make sure that we don't overflow it. + STATIC_ASSERT(mt_number_of_types <= max_jubyte); + char nmt_env_variable[buffer_size]; jio_snprintf(nmt_env_variable, sizeof(nmt_env_variable), "NMT_LEVEL_%d", os::current_process_id()); const char* nmt_env_value; diff --git a/src/src/hotspot/share/services/nmtCommon.cpp b/src/src/hotspot/share/services/nmtCommon.cpp index 5f8bb5631d9..017e04dc0dd 100644 --- a/src/src/hotspot/share/services/nmtCommon.cpp +++ b/src/src/hotspot/share/services/nmtCommon.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, 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 @@ -44,6 +44,8 @@ const char* NMTUtil::_memory_type_names[] = { "Logging", "Arguments", "Module", + "Synchronizer", + "Safepoint", "Unknown" }; diff --git a/src/src/hotspot/share/services/virtualMemoryTracker.hpp b/src/src/hotspot/share/services/virtualMemoryTracker.hpp index 1102e9c2ea5..dcb70d93e66 100644 --- a/src/src/hotspot/share/services/virtualMemoryTracker.hpp +++ b/src/src/hotspot/share/services/virtualMemoryTracker.hpp @@ -70,8 +70,8 @@ class VirtualMemory { // Virtual memory allocation site, keeps track where the virtual memory is reserved. class VirtualMemoryAllocationSite : public AllocationSite { public: - VirtualMemoryAllocationSite(const NativeCallStack& stack) : - AllocationSite(stack) { } + VirtualMemoryAllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : + AllocationSite(stack, flag) { } inline void reserve_memory(size_t sz) { data()->reserve_memory(sz); } inline void commit_memory (size_t sz) { data()->commit_memory(sz); } diff --git a/src/src/hotspot/share/utilities/debug.cpp b/src/src/hotspot/share/utilities/debug.cpp index 6118f48c6a4..3a5bebab69a 100644 --- a/src/src/hotspot/share/utilities/debug.cpp +++ b/src/src/hotspot/share/utilities/debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -34,6 +34,7 @@ #include "gc/shared/collectedHeap.hpp" #include "interpreter/bytecodeHistogram.hpp" #include "interpreter/interpreter.hpp" +#include "memory/allocation.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" @@ -52,6 +53,7 @@ #include "runtime/vframe.hpp" #include "runtime/vm_version.hpp" #include "services/heapDumper.hpp" +#include "services/memTracker.hpp" #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" #include "utilities/formatBuffer.hpp" @@ -707,6 +709,7 @@ static ucontext_t g_stored_assertion_context; void initialize_assert_poison() { char* page = os::reserve_memory(os::vm_page_size()); if (page) { + MemTracker::record_virtual_memory_type(page, mtInternal); if (os::commit_memory(page, os::vm_page_size(), false) && os::protect_memory(page, os::vm_page_size(), os::MEM_PROT_NONE)) { g_assert_poison = page; diff --git a/src/src/hotspot/share/utilities/events.hpp b/src/src/hotspot/share/utilities/events.hpp index 29ed9bd9079..56efc8595cd 100644 --- a/src/src/hotspot/share/utilities/events.hpp +++ b/src/src/hotspot/share/utilities/events.hpp @@ -136,11 +136,6 @@ template class EventLogBase : public EventLog { // A simple wrapper class for fixed size text messages. class StringLogMessage : public FormatBuffer<256> { - public: - // Wrap this buffer in a stringStream. - stringStream stream() { - return stringStream(_buf, size()); - } }; // A simple ring buffer of fixed size text messages. @@ -210,7 +205,7 @@ class Events : AllStatic { }; inline void Events::log(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _messages != NULL) { va_list ap; va_start(ap, format); _messages->logv(thread, format, ap); @@ -219,7 +214,7 @@ inline void Events::log(Thread* thread, const char* format, ...) { } inline void Events::log_exception(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _exceptions != NULL) { va_list ap; va_start(ap, format); _exceptions->logv(thread, format, ap); @@ -228,7 +223,7 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) { } inline void Events::log_redefinition(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _redefinitions != NULL) { va_list ap; va_start(ap, format); _redefinitions->logv(thread, format, ap); @@ -237,7 +232,7 @@ inline void Events::log_redefinition(Thread* thread, const char* format, ...) { } inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { - if (LogEvents) { + if (LogEvents && _deopt_messages != NULL) { va_list ap; va_start(ap, format); _deopt_messages->logv(thread, format, ap); diff --git a/src/src/hotspot/share/utilities/exceptions.cpp b/src/src/hotspot/share/utilities/exceptions.cpp index 420b49b73f2..3e5ac5a52a4 100644 --- a/src/src/hotspot/share/utilities/exceptions.cpp +++ b/src/src/hotspot/share/utilities/exceptions.cpp @@ -527,17 +527,17 @@ void Exceptions::debug_check_abort_helper(Handle exception, const char* message) } // for logging exceptions -void Exceptions::log_exception(Handle exception, stringStream tempst) { +void Exceptions::log_exception(Handle exception, const char* message) { ResourceMark rm; - Symbol* message = java_lang_Throwable::detail_message(exception()); - if (message != NULL) { + Symbol* detail_message = java_lang_Throwable::detail_message(exception()); + if (detail_message != NULL) { log_info(exceptions)("Exception <%s: %s>\n thrown in %s", exception->print_value_string(), - message->as_C_string(), - tempst.as_string()); + detail_message->as_C_string(), + message); } else { log_info(exceptions)("Exception <%s>\n thrown in %s", exception->print_value_string(), - tempst.as_string()); + message); } } diff --git a/src/src/hotspot/share/utilities/exceptions.hpp b/src/src/hotspot/share/utilities/exceptions.hpp index 18c40b51780..cb974efb3ae 100644 --- a/src/src/hotspot/share/utilities/exceptions.hpp +++ b/src/src/hotspot/share/utilities/exceptions.hpp @@ -185,7 +185,7 @@ class Exceptions { static void debug_check_abort(const char *value_string, const char* message = NULL); // for logging exceptions - static void log_exception(Handle exception, stringStream tempst); + static void log_exception(Handle exception, const char* message); }; diff --git a/src/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index 705a75fb7e3..8563bf61d7d 100644 --- a/src/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/src/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -281,8 +281,8 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53017 // // GCC versions older than 4.6.4 would fail even with "+0", and needs additional -// cast to typeof(x) to work around the similar bug. +// cast to __typeof__(x) to work around the similar bug. // -#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned((typeof(x))x+0))) +#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned((__typeof__(x))x+0))) #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/src/src/hotspot/share/utilities/internalVMTests.cpp b/src/src/hotspot/share/utilities/internalVMTests.cpp index de74a2303e1..b3513d4415f 100644 --- a/src/src/hotspot/share/utilities/internalVMTests.cpp +++ b/src/src/hotspot/share/utilities/internalVMTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -45,7 +45,6 @@ void InternalVMTests::run() { run_unit_test(TestReservedSpace_test); run_unit_test(TestReserveMemorySpecial_test); run_unit_test(TestVirtualSpace_test); - run_unit_test(TestMetaspaceUtils_test); run_unit_test(GCTimer_test); run_unit_test(ObjectMonitor_test); // These tests require the "C" locale to correctly parse decimal values diff --git a/src/src/hotspot/share/utilities/ostream.hpp b/src/src/hotspot/share/utilities/ostream.hpp index f7052e380c3..62a9f156353 100644 --- a/src/src/hotspot/share/utilities/ostream.hpp +++ b/src/src/hotspot/share/utilities/ostream.hpp @@ -42,6 +42,10 @@ DEBUG_ONLY(class ResourceMark;) // This allows for redirection via -XX:+DisplayVMOutputToStdout and // -XX:+DisplayVMOutputToStderr class outputStream : public ResourceObj { + private: + outputStream(const outputStream&); + outputStream& operator=(const outputStream&); + protected: int _indentation; // current indentation int _width; // width of the page diff --git a/src/src/hotspot/share/utilities/virtualizationSupport.cpp b/src/src/hotspot/share/utilities/virtualizationSupport.cpp new file mode 100644 index 00000000000..0c4f31dda32 --- /dev/null +++ b/src/src/hotspot/share/utilities/virtualizationSupport.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "runtime/os.hpp" +#include "utilities/virtualizationSupport.hpp" + +static void *dlHandle = NULL; + +static GuestLib_StatGet_t GuestLib_StatGet = NULL; +static GuestLib_StatFree_t GuestLib_StatFree = NULL; + +static bool has_host_information = false; +static bool has_resource_information = false; + +// host + resource information; avoid the session and other special info vectors +static char host_information[300]; +static char extended_resource_info_at_startup[600]; + +void VirtualizationSupport::initialize() { + if (!ExtensiveErrorReports) return; + + // open vmguestlib and bind SDK functions + char ebuf[1024]; + dlHandle = os::dll_load("vmGuestLib", ebuf, sizeof ebuf); + +#ifdef LINUX + if (dlHandle == NULL) { + // the open-vm-tools have a different guest lib name + // on some distros e.g. SLES12 the open-vm-tools are the default, + // so use the different libname as a fallback + dlHandle = os::dll_load("/usr/lib64/libguestlib.so.0", ebuf, sizeof ebuf); + } +#endif + if (dlHandle == NULL) { + return; + } + + GuestLib_StatGet = CAST_TO_FN_PTR(GuestLib_StatGet_t, os::dll_lookup(dlHandle, "VMGuestLib_StatGet")); + GuestLib_StatFree = CAST_TO_FN_PTR(GuestLib_StatFree_t, os::dll_lookup(dlHandle, "VMGuestLib_StatFree")); + + if (GuestLib_StatGet != NULL && GuestLib_StatFree != NULL) { + char* result_info = NULL; + size_t result_size = 0; + VMGuestLibError sg_error = GuestLib_StatGet("text", "resources", &result_info, &result_size); + if (sg_error == VMGUESTLIB_ERROR_SUCCESS) { + has_resource_information = true; + os::snprintf(extended_resource_info_at_startup, sizeof(extended_resource_info_at_startup), "%s", result_info); + GuestLib_StatFree(result_info, result_size); + } + sg_error = GuestLib_StatGet("text", "host", &result_info, &result_size); + if (sg_error == VMGUESTLIB_ERROR_SUCCESS) { + has_host_information = true; + os::snprintf(host_information, sizeof(host_information), "%s", result_info); + GuestLib_StatFree(result_info, result_size); + } + } +} + +void VirtualizationSupport::print_virtualization_info(outputStream* st) { + if (has_host_information) { + st->print_cr("vSphere host information:"); + st->print_cr("%s", host_information); + } + // resource info at startup + if (has_resource_information) { + st->print_cr("vSphere resource information collected at VM startup:"); + st->print_cr("%s", extended_resource_info_at_startup); + } + // current resource info + if (GuestLib_StatGet != NULL && GuestLib_StatFree != NULL) { + char* result_info = NULL; + size_t result_size = 0; + VMGuestLibError sg_error = GuestLib_StatGet("text", "resources", &result_info, &result_size); + if (sg_error == VMGUESTLIB_ERROR_SUCCESS) { + st->print_cr("vSphere resource information available now:"); + st->print_cr("%s", result_info); + GuestLib_StatFree(result_info, result_size); + } + } +} + diff --git a/src/src/hotspot/share/utilities/virtualizationSupport.hpp b/src/src/hotspot/share/utilities/virtualizationSupport.hpp new file mode 100644 index 00000000000..c8d7404d4d6 --- /dev/null +++ b/src/src/hotspot/share/utilities/virtualizationSupport.hpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_UTILITIES_VIRTUALIZATIONSUPPORT_HPP +#define SHARE_UTILITIES_VIRTUALIZATIONSUPPORT_HPP + +#include "utilities/ostream.hpp" + +typedef enum { + VMGUESTLIB_ERROR_SUCCESS = 0, // no error occured + VMGUESTLIB_ERROR_OTHER, + VMGUESTLIB_ERROR_NOT_RUNNING_IN_VM, + VMGUESTLIB_ERROR_NOT_ENABLED, + VMGUESTLIB_ERROR_NOT_AVAILABLE, + VMGUESTLIB_ERROR_NO_INFO, + VMGUESTLIB_ERROR_MEMORY, + VMGUESTLIB_ERROR_BUFFER_TOO_SMALL, + VMGUESTLIB_ERROR_INVALID_HANDLE, + VMGUESTLIB_ERROR_INVALID_ARG, + VMGUESTLIB_ERROR_UNSUPPORTED_VERSION +} VMGuestLibError; + +// new SDK functions from VMWare SDK 6.0; need VMware Tools version 9.10 installed +typedef VMGuestLibError (*GuestLib_StatGet_t)(const char*, const char*, char**, size_t*); +typedef VMGuestLibError (*GuestLib_StatFree_t)(char*, size_t); + +class VirtualizationSupport { + public: + static void initialize(); + static void print_virtualization_info(outputStream* st); +}; + +#endif + diff --git a/src/src/hotspot/share/utilities/xmlstream.cpp b/src/src/hotspot/share/utilities/xmlstream.cpp index 904c45ce4f4..c13b62442d8 100644 --- a/src/src/hotspot/share/utilities/xmlstream.cpp +++ b/src/src/hotspot/share/utilities/xmlstream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -353,11 +353,15 @@ void xmlStream::va_done(const char* format, va_list ap) { guarantee(format_len + 10 < sizeof(buffer), "bigger format buffer"); const char* kind = format; const char* kind_end = strchr(kind, ' '); - size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : format_len; - strncpy(buffer, kind, kind_len); - strcpy(buffer + kind_len, "_done"); + size_t kind_len; if (kind_end != NULL) { - strncat(buffer, format + kind_len, sizeof(buffer) - (kind_len + 5 /* _done */) - 1); + kind_len = kind_end - kind; + int n = os::snprintf(buffer, sizeof(buffer), "%.*s_done", (int)kind_len, kind); + assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string"); + } else { + kind_len = format_len; + int n = os::snprintf(buffer, sizeof(buffer), "%s_done%s", kind, kind + kind_len); + assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string"); } // Output the trailing event with the timestamp. va_begin_elem(buffer, ap); diff --git a/src/src/java.base/aix/classes/sun/nio/fs/AixFileSystemProvider.java b/src/src/java.base/aix/classes/sun/nio/fs/AixFileSystemProvider.java index 7d14fa84229..c0d17dd44b5 100644 --- a/src/src/java.base/aix/classes/sun/nio/fs/AixFileSystemProvider.java +++ b/src/src/java.base/aix/classes/sun/nio/fs/AixFileSystemProvider.java @@ -32,7 +32,7 @@ * AIX implementation of FileSystemProvider */ -public class AixFileSystemProvider extends UnixFileSystemProvider { +class AixFileSystemProvider extends UnixFileSystemProvider { public AixFileSystemProvider() { super(); } diff --git a/src/src/java.base/aix/classes/sun/nio/fs/DefaultFileSystemProvider.java b/src/src/java.base/aix/classes/sun/nio/fs/DefaultFileSystemProvider.java index 8c33d7e5a59..5bc5b882542 100644 --- a/src/src/java.base/aix/classes/sun/nio/fs/DefaultFileSystemProvider.java +++ b/src/src/java.base/aix/classes/sun/nio/fs/DefaultFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,29 @@ package sun.nio.fs; -import java.nio.file.spi.FileSystemProvider; +import java.nio.file.FileSystem; /** * Creates this platform's default FileSystemProvider. */ public class DefaultFileSystemProvider { + private static final AixFileSystemProvider INSTANCE + = new AixFileSystemProvider(); + private DefaultFileSystemProvider() { } /** - * Returns the default FileSystemProvider. + * Returns the platform's default file system provider. + */ + public static AixFileSystemProvider instance() { + return INSTANCE; + } + + /** + * Returns the platform's default file system. */ - public static FileSystemProvider create() { - return new AixFileSystemProvider(); + public static FileSystem theFileSystem() { + return INSTANCE.theFileSystem(); } } diff --git a/src/src/java.base/aix/native/libjli/java_md_aix.c b/src/src/java.base/aix/native/libjli/java_md_aix.c index 8ab48005934..994a335e307 100644 --- a/src/src/java.base/aix/native/libjli/java_md_aix.c +++ b/src/src/java.base/aix/native/libjli/java_md_aix.c @@ -27,7 +27,7 @@ #include "java_md_aix.h" -static unsigned char dladdr_buffer[0x4000]; +static unsigned char dladdr_buffer[0x8000]; static int fill_dll_info(void) { return loadquery(L_GETINFO, dladdr_buffer, sizeof(dladdr_buffer)); diff --git a/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java b/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java index 7d6c0b7bdd9..9851dc16e51 100644 --- a/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java +++ b/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -125,13 +125,13 @@ private static Metrics initContainerSubSystems() { /** * createSubSystem objects and initialize mount points */ - private static void createSubSystem(Metrics metric, String [] mountentry) { + private static void createSubSystem(Metrics metric, String[] mountentry) { if (mountentry.length < 5) return; Path p = Paths.get(mountentry[4]); - String subsystemName = p.getFileName().toString(); + String[] subsystemNames = p.getFileName().toString().split(","); - if (subsystemName != null) { + for (String subsystemName: subsystemNames) { switch (subsystemName) { case "memory": metric.setMemorySubSystem(new SubSystem(mountentry[3], mountentry[4])); @@ -139,11 +139,6 @@ private static void createSubSystem(Metrics metric, String [] mountentry) { case "cpuset": metric.setCpuSetSubSystem(new SubSystem(mountentry[3], mountentry[4])); break; - case "cpu,cpuacct": - case "cpuacct,cpu": - metric.setCpuSubSystem(new SubSystem(mountentry[3], mountentry[4])); - metric.setCpuAcctSubSystem(new SubSystem(mountentry[3], mountentry[4])); - break; case "cpuacct": metric.setCpuAcctSubSystem(new SubSystem(mountentry[3], mountentry[4])); break; @@ -163,7 +158,7 @@ private static void createSubSystem(Metrics metric, String [] mountentry) { /** * setSubSystemPath based on the contents of /proc/self/cgroup */ - private static void setSubSystemPath(Metrics metric, String [] entry) { + private static void setSubSystemPath(Metrics metric, String[] entry) { String controller; String base; SubSystem subsystem = null; @@ -299,15 +294,15 @@ public long getCpuSystemUsage() { public long getCpuPeriod() { - return SubSystem.getLongValue(cpuacct, "cpu.cfs_period_us"); + return SubSystem.getLongValue(cpu, "cpu.cfs_period_us"); } public long getCpuQuota() { - return SubSystem.getLongValue(cpuacct, "cpu.cfs_quota_us"); + return SubSystem.getLongValue(cpu, "cpu.cfs_quota_us"); } public long getCpuShares() { - long retval = SubSystem.getLongValue(cpuacct, "cpu.shares"); + long retval = SubSystem.getLongValue(cpu, "cpu.shares"); if (retval == 0 || retval == 1024) return -1; else @@ -315,15 +310,15 @@ public long getCpuShares() { } public long getCpuNumPeriods() { - return SubSystem.getLongEntry(cpuacct, "cpu.stat", "nr_periods"); + return SubSystem.getLongEntry(cpu, "cpu.stat", "nr_periods"); } public long getCpuNumThrottled() { - return SubSystem.getLongEntry(cpuacct, "cpu.stat", "nr_throttled"); + return SubSystem.getLongEntry(cpu, "cpu.stat", "nr_throttled"); } public long getCpuThrottledTime() { - return SubSystem.getLongEntry(cpuacct, "cpu.stat", "throttled_time"); + return SubSystem.getLongEntry(cpu, "cpu.stat", "throttled_time"); } public long getEffectiveCpuCount() { diff --git a/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java b/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java index 7d2a045e253..54babeabf00 100644 --- a/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java +++ b/src/src/java.base/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -48,7 +48,7 @@ public SubSystem(String root, String mountPoint) { public void setPath(String cgroupPath) { if (root != null && cgroupPath != null) { if (root.equals("/")) { - if (cgroupPath.equals("/")) { + if (!cgroupPath.equals("/")) { path = mountPoint + cgroupPath; } else { @@ -60,7 +60,7 @@ public void setPath(String cgroupPath) { path = mountPoint; } else { - if (root.indexOf(cgroupPath) == 0) { + if (cgroupPath.startsWith(root)) { if (cgroupPath.length() > root.length()) { String cgroupSubstr = cgroupPath.substring(root.length()); path = mountPoint + cgroupSubstr; @@ -109,7 +109,7 @@ public static long getLongValue(SubSystem subsystem, String parm) { retval = Long.parseLong(strval); } catch (NumberFormatException e) { // For some properties (e.g. memory.limit_in_bytes) we may overflow the range of signed long. - // In this case, return Long.max + // In this case, return Long.MAX_VALUE BigInteger b = new BigInteger(strval); if (b.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { return Long.MAX_VALUE; diff --git a/src/src/java.base/linux/classes/sun/nio/fs/DefaultFileSystemProvider.java b/src/src/java.base/linux/classes/sun/nio/fs/DefaultFileSystemProvider.java index 82a06b7ea50..17afe262fe0 100644 --- a/src/src/java.base/linux/classes/sun/nio/fs/DefaultFileSystemProvider.java +++ b/src/src/java.base/linux/classes/sun/nio/fs/DefaultFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,29 @@ package sun.nio.fs; -import java.nio.file.spi.FileSystemProvider; +import java.nio.file.FileSystem; /** * Creates this platform's default FileSystemProvider. */ public class DefaultFileSystemProvider { + private static final LinuxFileSystemProvider INSTANCE + = new LinuxFileSystemProvider(); + private DefaultFileSystemProvider() { } /** - * Returns the default FileSystemProvider. + * Returns the platform's default file system provider. + */ + public static LinuxFileSystemProvider instance() { + return INSTANCE; + } + + /** + * Returns the platform's default file system. */ - public static FileSystemProvider create() { - return new LinuxFileSystemProvider(); + public static FileSystem theFileSystem() { + return INSTANCE.theFileSystem(); } } diff --git a/src/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java b/src/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java index 1692c775b39..a1c2aed4bd2 100644 --- a/src/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java +++ b/src/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java @@ -36,7 +36,7 @@ * Linux implementation of FileSystemProvider */ -public class LinuxFileSystemProvider extends UnixFileSystemProvider { +class LinuxFileSystemProvider extends UnixFileSystemProvider { public LinuxFileSystemProvider() { super(); } diff --git a/src/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/src/java.base/macosx/classes/apple/security/KeychainStore.java index 7ed9956b80c..9f17704508b 100644 --- a/src/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -102,6 +102,8 @@ class TrustedCertEntry { private static final int iterationCount = 1024; private static final int SALT_LEN = 20; + private static final Debug debug = Debug.getInstance("keystore"); + static { AccessController.doPrivileged( new PrivilegedAction() { @@ -773,6 +775,10 @@ public void engineLoad(InputStream stream, char[] password) entries.clear(); _scanKeychain(); + if (debug != null) { + debug.println("KeychainStore load entry count: " + + entries.size()); + } } } diff --git a/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java b/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java index b73218ead5f..dee29805020 100644 --- a/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java +++ b/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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 @@ -62,22 +62,14 @@ UnixMountEntry findMountEntry() throws IOException { } // step 2: find mount point - UnixPath parent = path.getParent(); - while (parent != null) { - UnixFileAttributes attrs = null; - try { - attrs = UnixFileAttributes.get(parent, true); - } catch (UnixException x) { - x.rethrowAsIOException(parent); - } - if (attrs.dev() != dev()) - break; - path = parent; - parent = parent.getParent(); + byte[] dir = null; + try { + dir = BsdNativeDispatcher.getmntonname(path); + } catch (UnixException x) { + x.rethrowAsIOException(path); } // step 3: lookup mounted file systems - byte[] dir = path.asByteArray(); for (UnixMountEntry entry: fs.getMountEntries()) { if (Arrays.equals(dir, entry.dir())) return entry; diff --git a/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystemProvider.java b/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystemProvider.java index 3bb08d7d94c..0bef4000544 100644 --- a/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystemProvider.java +++ b/src/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystemProvider.java @@ -31,7 +31,7 @@ * Bsd implementation of FileSystemProvider */ -public class BsdFileSystemProvider extends UnixFileSystemProvider { +class BsdFileSystemProvider extends UnixFileSystemProvider { public BsdFileSystemProvider() { super(); } diff --git a/src/src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java b/src/src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java index 7acbc4fa750..b5174e7a983 100644 --- a/src/src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java +++ b/src/src/java.base/macosx/classes/sun/nio/fs/BsdNativeDispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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 @@ -51,6 +51,20 @@ static native int fsstatEntry(long iter, UnixMountEntry entry) */ static native void endfsstat(long iter) throws UnixException; + /** + * int statfs(const char *path, struct statfs *buf); + * returns buf->f_mntonname (directory on which mounted) + */ + static byte[] getmntonname(UnixPath path) throws UnixException { + NativeBuffer pathBuffer = copyToNativeBuffer(path); + try { + return getmntonname0(pathBuffer.address()); + } finally { + pathBuffer.release(); + } + } + static native byte[] getmntonname0(long pathAddress) throws UnixException; + // initialize field IDs private static native void initIDs(); diff --git a/src/src/java.base/macosx/classes/sun/nio/fs/DefaultFileSystemProvider.java b/src/src/java.base/macosx/classes/sun/nio/fs/DefaultFileSystemProvider.java index 917d9f3a25b..acb95b93cc8 100644 --- a/src/src/java.base/macosx/classes/sun/nio/fs/DefaultFileSystemProvider.java +++ b/src/src/java.base/macosx/classes/sun/nio/fs/DefaultFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,29 @@ package sun.nio.fs; -import java.nio.file.spi.FileSystemProvider; +import java.nio.file.FileSystem; /** * Creates this platform's default FileSystemProvider. */ public class DefaultFileSystemProvider { + private static final MacOSXFileSystemProvider INSTANCE + = new MacOSXFileSystemProvider(); + private DefaultFileSystemProvider() { } /** - * Returns the default FileSystemProvider. + * Returns the platform's default file system provider. + */ + public static MacOSXFileSystemProvider instance() { + return INSTANCE; + } + + /** + * Returns the platform's default file system. */ - public static FileSystemProvider create() { - return new MacOSXFileSystemProvider(); + public static FileSystem theFileSystem() { + return INSTANCE.theFileSystem(); } } diff --git a/src/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java b/src/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java index 1f6755e850a..256a9b5e613 100644 --- a/src/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java +++ b/src/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java @@ -34,7 +34,7 @@ * MacOSX implementation of FileSystemProvider */ -public class MacOSXFileSystemProvider extends BsdFileSystemProvider { +class MacOSXFileSystemProvider extends BsdFileSystemProvider { public MacOSXFileSystemProvider() { super(); } diff --git a/src/src/java.base/macosx/native/libjava/java_props_macosx.c b/src/src/java.base/macosx/native/libjava/java_props_macosx.c index 058d71c1e25..e3adc5b2542 100644 --- a/src/src/java.base/macosx/native/libjava/java_props_macosx.c +++ b/src/src/java.base/macosx/native/libjava/java_props_macosx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -92,18 +92,22 @@ char *getMacOSXLocale(int cat) { if (hyphenPos == NULL || // languageString contains ISO639 only, e.g., "en" languageString + langStrLen - hyphenPos == 5) { // ISO639-ScriptCode, e.g., "en-Latn" - CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()), - localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding()); - char *underscorePos = strrchr(localeString, '_'); - char *region = NULL; - - if (underscorePos != NULL) { - region = underscorePos + 1; - } + CFLocaleRef cflocale = CFLocaleCopyCurrent(); + if (cflocale != NULL) { + CFStringGetCString(CFLocaleGetIdentifier(cflocale), + localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding()); + char *underscorePos = strrchr(localeString, '_'); + char *region = NULL; + + if (underscorePos != NULL) { + region = underscorePos + 1; + } - if (region != NULL) { - strcat(languageString, "-"); - strcat(languageString, region); + if (region != NULL) { + strcat(languageString, "-"); + strcat(languageString, region); + } + CFRelease(cflocale); } } @@ -113,12 +117,19 @@ char *getMacOSXLocale(int cat) { default: { - if (!CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()), - localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding())) { + CFLocaleRef cflocale = CFLocaleCopyCurrent(); + if (cflocale != NULL) { + if (!CFStringGetCString(CFLocaleGetIdentifier(cflocale), + localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding())) { + CFRelease(cflocale); + return NULL; + } + + retVal = localeString; + CFRelease(cflocale); + } else { return NULL; } - - retVal = localeString; } break; } diff --git a/src/src/java.base/macosx/native/libnio/fs/BsdNativeDispatcher.c b/src/src/java.base/macosx/native/libnio/fs/BsdNativeDispatcher.c index 9453f75d3de..056d08eecc0 100644 --- a/src/src/java.base/macosx/native/libnio/fs/BsdNativeDispatcher.c +++ b/src/src/java.base/macosx/native/libnio/fs/BsdNativeDispatcher.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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 @@ -203,3 +203,24 @@ Java_sun_nio_fs_BsdNativeDispatcher_endfsstat(JNIEnv* env, jclass this, jlong va free(iter); } } + +JNIEXPORT jbyteArray JNICALL +Java_sun_nio_fs_BsdNativeDispatcher_getmntonname0(JNIEnv *env, jclass this, + jlong pathAddress) +{ + struct statfs buf; + const char* path = (const char*)jlong_to_ptr(pathAddress); + + if (statfs(path, &buf) != 0) { + throwUnixException(env, errno); + } + + jsize len = strlen(buf.f_mntonname); + jbyteArray mntonname = (*env)->NewByteArray(env, len); + if (mntonname != NULL) { + (*env)->SetByteArrayRegion(env, mntonname, 0, len, + (jbyte*)buf.f_mntonname); + } + + return mntonname; +} diff --git a/src/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m b/src/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m index e678bce28de..c9ddeefe3e6 100644 --- a/src/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m +++ b/src/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -562,6 +562,9 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore) err = SecKeychainItemImport(cfDataToImport, NULL, &dataFormat, NULL, 0, ¶mBlock, defaultKeychain, &createdItems); + if (cfDataToImport != NULL) { + CFRelease(cfDataToImport); + } if (err == noErr) { SecKeychainItemRef anItem = (SecKeychainItemRef)CFArrayGetValueAtIndex(createdItems, 0); diff --git a/src/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java b/src/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java index bceb60da76d..e1ee770fa10 100644 --- a/src/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/src/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.crypto.provider; +import sun.security.util.Debug; + import java.io.*; import java.util.*; import java.security.AccessController; @@ -59,6 +61,7 @@ public final class JceKeyStore extends KeyStoreSpi { + private static final Debug debug = Debug.getInstance("keystore"); private static final int JCEKS_MAGIC = 0xcececece; private static final int JKS_MAGIC = 0xfeedfeed; private static final int VERSION_1 = 0x01; @@ -680,6 +683,7 @@ public void engineLoad(InputStream stream, char[] password) Hashtable cfs = null; ByteArrayInputStream bais = null; byte[] encoded = null; + int trustedKeyCount = 0, privateKeyCount = 0, secretKeyCount = 0; if (stream == null) return; @@ -726,7 +730,7 @@ public void engineLoad(InputStream stream, char[] password) tag = dis.readInt(); if (tag == 1) { // private-key entry - + privateKeyCount++; PrivateKeyEntry entry = new PrivateKeyEntry(); // read the alias @@ -786,7 +790,7 @@ public void engineLoad(InputStream stream, char[] password) entries.put(alias, entry); } else if (tag == 2) { // trusted certificate entry - + trustedKeyCount++; TrustedCertEntry entry = new TrustedCertEntry(); // read the alias @@ -825,7 +829,7 @@ public void engineLoad(InputStream stream, char[] password) entries.put(alias, entry); } else if (tag == 3) { // secret-key entry - + secretKeyCount++; SecretKeyEntry entry = new SecretKeyEntry(); // read the alias @@ -858,10 +862,18 @@ public void engineLoad(InputStream stream, char[] password) entries.put(alias, entry); } else { - throw new IOException("Unrecognized keystore entry"); + throw new IOException("Unrecognized keystore entry: " + + tag); } } + if (debug != null) { + debug.println("JceKeyStore load: private key count: " + + privateKeyCount + ". trusted key count: " + + trustedKeyCount + ". secret key count: " + + secretKeyCount); + } + /* * If a password has been provided, we check the keyed digest * at the end. If this check fails, the store has been tampered diff --git a/src/src/java.base/share/classes/com/sun/crypto/provider/PBES1Core.java b/src/src/java.base/share/classes/com/sun/crypto/provider/PBES1Core.java index 54bd4eb67e7..f634a639c19 100644 --- a/src/src/java.base/share/classes/com/sun/crypto/provider/PBES1Core.java +++ b/src/src/java.base/share/classes/com/sun/crypto/provider/PBES1Core.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -268,17 +268,20 @@ private byte[] deriveCipherKey(byte[] passwdBytes) { if (algo.equals("DES")) { // P || S (password concatenated with salt) - byte[] concat = new byte[Math.addExact(passwdBytes.length, salt.length)]; - System.arraycopy(passwdBytes, 0, concat, 0, passwdBytes.length); - System.arraycopy(salt, 0, concat, passwdBytes.length, salt.length); - - // digest P || S with c iterations - byte[] toBeHashed = concat; - for (int i = 0; i < iCount; i++) { + md.update(passwdBytes); + md.update(salt); + // digest P || S with iCount iterations + // first iteration + byte[] toBeHashed = md.digest(); // this resets the digest + // remaining (iCount - 1) iterations + for (int i = 1; i < iCount; ++i) { md.update(toBeHashed); - toBeHashed = md.digest(); // this resets the digest + try { + md.digest(toBeHashed, 0, toBeHashed.length); + } catch (DigestException e) { + throw new ProviderException("Internal error", e); + } } - Arrays.fill(concat, (byte)0x00); result = toBeHashed; } else if (algo.equals("DESede")) { // if the 2 salt halves are the same, invert one of them @@ -305,13 +308,19 @@ private byte[] deriveCipherKey(byte[] passwdBytes) { result = new byte[DESedeKeySpec.DES_EDE_KEY_LEN + DESConstants.DES_BLOCK_SIZE]; for (i = 0; i < 2; i++) { - toBeHashed = new byte[salt.length/2]; - System.arraycopy(salt, i*(salt.length/2), toBeHashed, 0, - toBeHashed.length); - for (int j=0; j < iCount; j++) { + // first iteration + md.update(salt, i * (salt.length / 2), salt.length / 2); + md.update(passwdBytes); + toBeHashed = md.digest(); + // remaining (iCount - 1) iterations + for (int j = 1; j < iCount; ++j) { md.update(toBeHashed); md.update(passwdBytes); - toBeHashed = md.digest(); + try { + md.digest(toBeHashed, 0, toBeHashed.length); + } catch (DigestException e) { + throw new ProviderException("Internal error", e); + } } System.arraycopy(toBeHashed, 0, result, i*16, toBeHashed.length); diff --git a/src/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/src/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java index 64d474d102d..6ea08796d8b 100644 --- a/src/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java +++ b/src/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -113,12 +113,7 @@ private static byte[] getPasswordBytes(char[] passwd) { } else if (keyLength < 0) { throw new InvalidKeySpecException("Key length is negative"); } - this.prf = Mac.getInstance(prfAlgo); - // SunPKCS11 requires a non-empty PBE password - if (passwdBytes.length == 0 && - this.prf.getProvider().getName().startsWith("SunPKCS11")) { - this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance()); - } + this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance()); this.key = deriveKey(prf, passwdBytes, salt, iterCount, keyLength); } catch (NoSuchAlgorithmException nsae) { // not gonna happen; re-throw just in case @@ -207,7 +202,7 @@ public boolean equals(Object obj) { } } } catch (GeneralSecurityException gse) { - throw new RuntimeException("Error deriving PBKDF2 keys"); + throw new RuntimeException("Error deriving PBKDF2 keys", gse); } return key; } diff --git a/src/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java b/src/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java index e8ff8951716..8f2ed6a8bdf 100644 --- a/src/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java +++ b/src/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java @@ -996,7 +996,7 @@ void tokenizeLayout(Layout self, int curCble, String layout, List 0) + if (verbose && !zipc.isEmpty()) System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc)); if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) { System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile)); @@ -552,7 +552,7 @@ String parseCommandOptions(List args, if (words.length == 0) continue loadOptmap; String opt = words[0]; words[0] = ""; // initial word is not a spec - if (opt.length() == 0 && words.length >= 1) { + if (opt.isEmpty() && words.length >= 1) { opt = words[1]; // initial "word" is empty due to leading ' ' words[1] = ""; } @@ -622,7 +622,7 @@ String parseCommandOptions(List args, switch (specop) { case '+': // + means we want an non-empty val suffix. - ok = (val.length() != 0); + ok = !val.isEmpty(); specop = spec.charAt(sidx++); break; case '*': @@ -641,10 +641,10 @@ String parseCommandOptions(List args, String specarg = spec.substring(sidx); switch (specop) { case '.': // terminate the option sequence - resultString = (specarg.length() != 0)? specarg.intern(): opt; + resultString = specarg.isEmpty() ? opt : specarg.intern(); break doArgs; case '?': // abort the option sequence - resultString = (specarg.length() != 0)? specarg.intern(): arg; + resultString = specarg.isEmpty() ? arg : specarg.intern(); isError = true; break eachSpec; case '@': // change the effective opt name @@ -655,14 +655,14 @@ String parseCommandOptions(List args, val = ""; break; case '!': // negation option - String negopt = (specarg.length() != 0)? specarg.intern(): opt; + String negopt = specarg.isEmpty() ? opt : specarg.intern(); properties.remove(negopt); properties.put(negopt, null); // leave placeholder didAction = true; break; case '$': // normal "boolean" option String boolval; - if (specarg.length() != 0) { + if (!specarg.isEmpty()) { // If there is a given spec token, store it. boolval = specarg; } else { diff --git a/src/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java b/src/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java index c79ef43c2b6..2142dd50ebb 100644 --- a/src/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java +++ b/src/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java @@ -153,7 +153,7 @@ public static final KeyManagerFactory getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory", provider); diff --git a/src/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java b/src/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java index d23148b18f8..84cc2d1182a 100644 --- a/src/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java +++ b/src/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java @@ -109,7 +109,7 @@ public static SSLContext getInstance(String protocol) public static SSLContext getInstance(String protocol, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext", provider); diff --git a/src/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java b/src/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java index d011ce74ed1..b580f04af34 100644 --- a/src/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java +++ b/src/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java @@ -155,7 +155,7 @@ public static final TrustManagerFactory getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory", provider); diff --git a/src/src/java.base/share/classes/java/io/Console.java b/src/src/java.base/share/classes/java/io/Console.java index a2406ecd5db..3c99025392e 100644 --- a/src/src/java.base/share/classes/java/io/Console.java +++ b/src/src/java.base/share/classes/java/io/Console.java @@ -247,7 +247,7 @@ public String readLine(String fmt, Object ... args) { String line = null; synchronized (writeLock) { synchronized(readLock) { - if (fmt.length() != 0) + if (!fmt.isEmpty()) pw.format(fmt, args); try { char[] ca = readline(false); @@ -319,7 +319,7 @@ public char[] readPassword(String fmt, Object ... args) { } IOError ioe = null; try { - if (fmt.length() != 0) + if (!fmt.isEmpty()) pw.format(fmt, args); passwd = readline(true); } catch (IOException x) { diff --git a/src/src/java.base/share/classes/java/io/FilePermission.java b/src/src/java.base/share/classes/java/io/FilePermission.java index 0cdb660145f..2876fdd5fc4 100644 --- a/src/src/java.base/share/classes/java/io/FilePermission.java +++ b/src/src/java.base/share/classes/java/io/FilePermission.java @@ -25,7 +25,6 @@ package java.io; -import java.net.URI; import java.nio.file.*; import java.security.*; import java.util.Enumeration; @@ -199,12 +198,11 @@ public final class FilePermission extends Permission implements Serializable { private static final long serialVersionUID = 7930732926638008763L; /** - * Always use the internal default file system, in case it was modified - * with java.nio.file.spi.DefaultFileSystemProvider. + * Use the platform's default file system to avoid recursive initialization + * issues when the VM is configured to use a custom file system provider. */ private static final java.nio.file.FileSystem builtInFS = - DefaultFileSystemProvider.create() - .getFileSystem(URI.create("file:///")); + DefaultFileSystemProvider.theFileSystem(); private static final Path here = builtInFS.getPath( GetPropertyAction.privilegedGetProperty("user.dir")); @@ -326,7 +324,7 @@ private void init(int mask) { if (name.equals("<>")) { allFiles = true; - npath = builtInFS.getPath(""); + npath = EMPTY_PATH; // other fields remain default return; } @@ -351,7 +349,7 @@ private void init(int mask) { npath = npath.getParent(); } if (npath == null) { - npath = builtInFS.getPath(""); + npath = EMPTY_PATH; } invalid = false; } catch (InvalidPathException ipe) { @@ -368,12 +366,22 @@ private void init(int mask) { this.mask = mask; if (cpath.equals("<>")) { + allFiles = true; directory = true; recursive = true; cpath = ""; return; } + // Validate path by platform's default file system + try { + String name = cpath.endsWith("*") ? cpath.substring(0, cpath.length() - 1) + "-" : cpath; + builtInFS.getPath(new File(name).getPath()); + } catch (InvalidPathException ipe) { + invalid = true; + return; + } + // store only the canonical cpath if possible cpath = AccessController.doPrivileged(new PrivilegedAction<>() { public String run() { @@ -464,6 +472,9 @@ public String run() { *

    * The default value of the {@code jdk.io.permissionsUseCanonicalPath} * system property is {@code false} in this implementation. + *

    + * The value can also be set with a security property using the same name, + * but setting a system property will override the security property value. * * @param path the pathname of the file/directory. * @param actions the action string. @@ -574,19 +585,19 @@ public boolean implies(Permission p) { * @return the effective mask */ boolean impliesIgnoreMask(FilePermission that) { + if (this == that) { + return true; + } + if (allFiles) { + return true; + } + if (this.invalid || that.invalid) { + return false; + } + if (that.allFiles) { + return false; + } if (FilePermCompat.nb) { - if (this == that) { - return true; - } - if (allFiles) { - return true; - } - if (this.invalid || that.invalid) { - return false; - } - if (that.allFiles) { - return false; - } // Left at least same level of wildness as right if ((this.recursive && that.recursive) != that.recursive || (this.directory && that.directory) != that.directory) { @@ -784,10 +795,10 @@ public boolean equals(Object obj) { FilePermission that = (FilePermission) obj; + if (this.invalid || that.invalid) { + return false; + } if (FilePermCompat.nb) { - if (this.invalid || that.invalid) { - return false; - } return (this.mask == that.mask) && (this.allFiles == that.allFiles) && this.npath.equals(that.npath) && @@ -796,6 +807,7 @@ public boolean equals(Object obj) { (this.recursive == that.recursive); } else { return (this.mask == that.mask) && + (this.allFiles == that.allFiles) && this.cpath.equals(that.cpath) && (this.directory == that.directory) && (this.recursive == that.recursive); diff --git a/src/src/java.base/share/classes/java/io/LineNumberReader.java b/src/src/java.base/share/classes/java/io/LineNumberReader.java index c9ecbe0734a..bffda6e1c2c 100644 --- a/src/src/java.base/share/classes/java/io/LineNumberReader.java +++ b/src/src/java.base/share/classes/java/io/LineNumberReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -261,6 +261,11 @@ public long skip(long n) throws IOException { */ public void mark(int readAheadLimit) throws IOException { synchronized (lock) { + // If the most recently read character is '\r', then increment the + // read ahead limit as in this case if the next character is '\n', + // two characters would actually be read by the next read(). + if (skipLF) + readAheadLimit++; super.mark(readAheadLimit); markedLineNumber = lineNumber; markedSkipLF = skipLF; diff --git a/src/src/java.base/share/classes/java/io/ObjectStreamClass.java b/src/src/java.base/share/classes/java/io/ObjectStreamClass.java index 954e4a0e30a..5bd93027690 100644 --- a/src/src/java.base/share/classes/java/io/ObjectStreamClass.java +++ b/src/src/java.base/share/classes/java/io/ObjectStreamClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -2275,7 +2275,7 @@ private static FieldReflector getReflector(ObjectStreamField[] fields, */ private static class FieldReflectorKey extends WeakReference> { - private final String sigs; + private final String[] sigs; private final int hash; private final boolean nullClass; @@ -2284,13 +2284,13 @@ private static class FieldReflectorKey extends WeakReference> { { super(cl, queue); nullClass = (cl == null); - StringBuilder sbuf = new StringBuilder(); - for (int i = 0; i < fields.length; i++) { + sigs = new String[2 * fields.length]; + for (int i = 0, j = 0; i < fields.length; i++) { ObjectStreamField f = fields[i]; - sbuf.append(f.getName()).append(f.getSignature()); + sigs[j++] = f.getName(); + sigs[j++] = f.getSignature(); } - sigs = sbuf.toString(); - hash = System.identityHashCode(cl) + sigs.hashCode(); + hash = System.identityHashCode(cl) + Arrays.hashCode(sigs); } public int hashCode() { @@ -2308,7 +2308,7 @@ public boolean equals(Object obj) { return (nullClass ? other.nullClass : ((referent = get()) != null) && (referent == other.get())) && - sigs.equals(other.sigs); + Arrays.equals(sigs, other.sigs); } else { return false; } diff --git a/src/src/java.base/share/classes/java/lang/ClassLoader.java b/src/src/java.base/share/classes/java/lang/ClassLoader.java index ed2c827847c..aa211b07900 100644 --- a/src/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/src/src/java.base/share/classes/java/lang/ClassLoader.java @@ -1119,7 +1119,7 @@ static native Class defineClass2(ClassLoader loader, String name, java.nio.By // true if the name is null or has the potential to be a valid binary name private boolean checkName(String name) { - if ((name == null) || (name.length() == 0)) + if ((name == null) || (name.isEmpty())) return true; if ((name.indexOf('/') != -1) || (name.charAt(0) == '[')) return false; diff --git a/src/src/java.base/share/classes/java/lang/Integer.java b/src/src/java.base/share/classes/java/lang/Integer.java index fa059a54bbb..959a434e969 100644 --- a/src/src/java.base/share/classes/java/lang/Integer.java +++ b/src/src/java.base/share/classes/java/lang/Integer.java @@ -1388,7 +1388,7 @@ public static Integer decode(String nm) throws NumberFormatException { boolean negative = false; Integer result; - if (nm.length() == 0) + if (nm.isEmpty()) throw new NumberFormatException("Zero length string"); char firstChar = nm.charAt(0); // Handle sign, if present diff --git a/src/src/java.base/share/classes/java/lang/Long.java b/src/src/java.base/share/classes/java/lang/Long.java index d9066ff32c6..489417ac5fa 100644 --- a/src/src/java.base/share/classes/java/lang/Long.java +++ b/src/src/java.base/share/classes/java/lang/Long.java @@ -1229,7 +1229,7 @@ public static Long decode(String nm) throws NumberFormatException { boolean negative = false; Long result; - if (nm.length() == 0) + if (nm.isEmpty()) throw new NumberFormatException("Zero length string"); char firstChar = nm.charAt(0); // Handle sign, if present diff --git a/src/src/java.base/share/classes/java/lang/Package.java b/src/src/java.base/share/classes/java/lang/Package.java index f49547bc426..ccf4afa1365 100644 --- a/src/src/java.base/share/classes/java/lang/Package.java +++ b/src/src/java.base/share/classes/java/lang/Package.java @@ -397,11 +397,11 @@ public int hashCode(){ public String toString() { String spec = versionInfo.specTitle; String ver = versionInfo.specVersion; - if (spec != null && spec.length() > 0) + if (spec != null && !spec.isEmpty()) spec = ", " + spec; else spec = ""; - if (ver != null && ver.length() > 0) + if (ver != null && !ver.isEmpty()) ver = ", version " + ver; else ver = ""; diff --git a/src/src/java.base/share/classes/java/lang/Runtime.java b/src/src/java.base/share/classes/java/lang/Runtime.java index e11eaacbf5d..128e6dbc85e 100644 --- a/src/src/java.base/share/classes/java/lang/Runtime.java +++ b/src/src/java.base/share/classes/java/lang/Runtime.java @@ -405,7 +405,7 @@ public Process exec(String command, String[] envp) throws IOException { */ public Process exec(String command, String[] envp, File dir) throws IOException { - if (command.length() == 0) + if (command.isEmpty()) throw new IllegalArgumentException("Empty command"); StringTokenizer st = new StringTokenizer(command); diff --git a/src/src/java.base/share/classes/java/lang/String.java b/src/src/java.base/share/classes/java/lang/String.java index 3f497c74926..7ff9ed49b11 100644 --- a/src/src/java.base/share/classes/java/lang/String.java +++ b/src/src/java.base/share/classes/java/lang/String.java @@ -1934,8 +1934,7 @@ public CharSequence subSequence(int beginIndex, int endIndex) { * characters followed by the string argument's characters. */ public String concat(String str) { - int olen = str.length(); - if (olen == 0) { + if (str.isEmpty()) { return this; } if (coder() == str.coder()) { @@ -1947,6 +1946,7 @@ public String concat(String str) { return new String(buf, coder); } int len = length(); + int olen = str.length(); byte[] buf = StringUTF16.newBytesFor(len + olen); getBytes(buf, 0, UTF16); str.getBytes(buf, len, UTF16); @@ -2307,7 +2307,7 @@ public String[] split(String regex, int limit) { // Construct result int resultSize = list.size(); if (limit == 0) { - while (resultSize > 0 && list.get(resultSize - 1).length() == 0) { + while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) { resultSize--; } } diff --git a/src/src/java.base/share/classes/java/lang/System.java b/src/src/java.base/share/classes/java/lang/System.java index e4ce3901dfb..2bb5390c01a 100644 --- a/src/src/java.base/share/classes/java/lang/System.java +++ b/src/src/java.base/share/classes/java/lang/System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2019, 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 @@ -72,6 +72,7 @@ import jdk.internal.logger.LoggerFinderLoader; import jdk.internal.logger.LazyLoggers; import jdk.internal.logger.LocalizedLoggerWrapper; +import sun.nio.fs.DefaultFileSystemProvider; import sun.reflect.annotation.AnnotationType; import sun.nio.ch.Interruptible; import sun.security.util.SecurityConstants; @@ -318,6 +319,8 @@ public static void setSecurityManager(final SecurityManager s) { if (security == null) { // ensure image reader is initialized Object.class.getResource("java/lang/ANY"); + // ensure the default file system is initialized + DefaultFileSystemProvider.theFileSystem(); } if (s != null) { try { @@ -949,7 +952,7 @@ private static void checkKey(String key) { *

    If a security manager exists, its * {@link SecurityManager#checkPermission checkPermission} * method is called with a - * {@code {@link RuntimePermission}("getenv."+name)} + * {@link RuntimePermission RuntimePermission("getenv."+name)} * permission. This may result in a {@link SecurityException} * being thrown. If no exception is thrown the value of the * variable {@code name} is returned. @@ -1020,7 +1023,7 @@ public static String getenv(String name) { *

    If a security manager exists, its * {@link SecurityManager#checkPermission checkPermission} * method is called with a - * {@code {@link RuntimePermission}("getenv.*")} permission. + * {@link RuntimePermission RuntimePermission("getenv.*")} permission. * This may result in a {@link SecurityException} being thrown. * *

    When passing information to a Java subprocess, diff --git a/src/src/java.base/share/classes/java/lang/VersionProps.java.template b/src/src/java.base/share/classes/java/lang/VersionProps.java.template index e8585e4b0a3..f96ad9b0498 100644 --- a/src/src/java.base/share/classes/java/lang/VersionProps.java.template +++ b/src/src/java.base/share/classes/java/lang/VersionProps.java.template @@ -66,7 +66,7 @@ class VersionProps { "@@VENDOR_VERSION_STRING@@"; private static final String vendor_version = - (VENDOR_VERSION_STRING.length() > 0 + (!VENDOR_VERSION_STRING.isEmpty() ? " " + VENDOR_VERSION_STRING : ""); static { @@ -78,7 +78,7 @@ class VersionProps { System.setProperty("java.version.date", java_version_date); System.setProperty("java.runtime.version", java_runtime_version); System.setProperty("java.runtime.name", java_runtime_name); - if (VENDOR_VERSION_STRING.length() > 0) + if (!VENDOR_VERSION_STRING.isEmpty()) System.setProperty("java.vendor.version", VENDOR_VERSION_STRING); } diff --git a/src/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java b/src/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java index 871b87061a0..0cf01320d2b 100644 --- a/src/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java +++ b/src/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java @@ -103,7 +103,7 @@ public static Class primitiveClass(MethodHandles.Lookup lookup, String name, if (type != Class.class) { throw new IllegalArgumentException(); } - if (name.length() == 0 || name.length() > 1) { + if (name.length() != 1) { throw new IllegalArgumentException(String.format("not primitive: %s", name)); } diff --git a/src/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/src/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index c8c9379c4a9..f620bb327d5 100644 --- a/src/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/src/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -197,7 +197,7 @@ public static Lookup privateLookupIn(Class targetClass, Lookup lookup) throws throw new IllegalAccessException(callerModule + " does not read " + targetModule); if (targetModule.isNamed()) { String pn = targetClass.getPackageName(); - assert pn.length() > 0 : "unnamed package cannot be in named module"; + assert !pn.isEmpty() : "unnamed package cannot be in named module"; if (!targetModule.isOpen(pn, callerModule)) throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule); } @@ -4871,8 +4871,10 @@ public static MethodHandle loop(MethodHandle[]... clauses) { // Step 1C: determine loop return type. // Step 1D: check other types. - final Class loopReturnType = fini.stream().filter(Objects::nonNull).map(MethodHandle::type). - map(MethodType::returnType).findFirst().orElse(void.class); + // local variable required here; see JDK-8223553 + Stream> cstream = fini.stream().filter(Objects::nonNull).map(MethodHandle::type) + .map(MethodType::returnType); + final Class loopReturnType = cstream.findFirst().orElse(void.class); loopChecks1cd(pred, fini, loopReturnType); // Step 2: determine parameter lists. diff --git a/src/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java b/src/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java index 2737bd5a4bf..f1f5ef673e0 100644 --- a/src/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java +++ b/src/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java @@ -62,7 +62,7 @@ public static ProxyClassesDumper getInstance(String path) { } try { path = path.trim(); - final Path dir = Path.of(path.length() == 0 ? "." : path); + final Path dir = Path.of(path.isEmpty() ? "." : path); AccessController.doPrivileged(new PrivilegedAction<>() { @Override public Void run() { diff --git a/src/src/java.base/share/classes/java/net/HttpCookie.java b/src/src/java.base/share/classes/java/net/HttpCookie.java index 7cc7d6e8ebc..c644db1481e 100644 --- a/src/src/java.base/share/classes/java/net/HttpCookie.java +++ b/src/src/java.base/share/classes/java/net/HttpCookie.java @@ -143,7 +143,7 @@ public HttpCookie(String name, String value) { private HttpCookie(String name, String value, String header) { name = name.trim(); - if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') { + if (name.isEmpty() || !isToken(name) || name.charAt(0) == '$') { throw new IllegalArgumentException("Illegal cookie name"); } diff --git a/src/src/java.base/share/classes/java/net/Inet6Address.java b/src/src/java.base/share/classes/java/net/Inet6Address.java index 8e1b0858bd4..8376d8b87aa 100644 --- a/src/src/java.base/share/classes/java/net/Inet6Address.java +++ b/src/src/java.base/share/classes/java/net/Inet6Address.java @@ -433,7 +433,7 @@ public static Inet6Address getByAddress(String host, byte[] addr, NetworkInterface nif) throws UnknownHostException { - if (host != null && host.length() > 0 && host.charAt(0) == '[') { + if (host != null && !host.isEmpty() && host.charAt(0) == '[') { if (host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); } @@ -466,7 +466,7 @@ public static Inet6Address getByAddress(String host, byte[] addr, int scope_id) throws UnknownHostException { - if (host != null && host.length() > 0 && host.charAt(0) == '[') { + if (host != null && !host.isEmpty() && host.charAt(0) == '[') { if (host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); } @@ -601,7 +601,7 @@ private void readObject(ObjectInputStream s) boolean scope_ifname_set = gf.get("scope_ifname_set", false); String ifname = (String)gf.get("ifname", null); - if (ifname != null && !"".equals (ifname)) { + if (ifname != null && !ifname.isEmpty()) { try { scope_ifname = NetworkInterface.getByName(ifname); if (scope_ifname == null) { diff --git a/src/src/java.base/share/classes/java/net/InetAddress.java b/src/src/java.base/share/classes/java/net/InetAddress.java index 5ee59a85565..27629164a8d 100644 --- a/src/src/java.base/share/classes/java/net/InetAddress.java +++ b/src/src/java.base/share/classes/java/net/InetAddress.java @@ -1187,7 +1187,7 @@ private static NameService createNameService() { */ public static InetAddress getByAddress(String host, byte[] addr) throws UnknownHostException { - if (host != null && host.length() > 0 && host.charAt(0) == '[') { + if (host != null && !host.isEmpty() && host.charAt(0) == '[') { if (host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); } @@ -1301,7 +1301,7 @@ public static InetAddress[] getAllByName(String host) private static InetAddress[] getAllByName(String host, InetAddress reqAddr) throws UnknownHostException { - if (host == null || host.length() == 0) { + if (host == null || host.isEmpty()) { InetAddress[] ret = new InetAddress[1]; ret[0] = impl.loopbackAddress(); return ret; diff --git a/src/src/java.base/share/classes/java/net/NetPermission.java b/src/src/java.base/share/classes/java/net/NetPermission.java index 0df2c91a299..745bb9e7db4 100644 --- a/src/src/java.base/share/classes/java/net/NetPermission.java +++ b/src/src/java.base/share/classes/java/net/NetPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -145,6 +145,15 @@ * * * + * setSocketImpl + * The ability to create a sub-class of Socket or ServerSocket with a + * user specified SocketImpl. + * Malicious user-defined SocketImpls can change the behavior of + * Socket and ServerSocket in surprising ways, by virtue of their + * ability to access the protected fields of SocketImpl. + * + * + * * specifyStreamHandler * The ability * to specify a stream handler when constructing a URL diff --git a/src/src/java.base/share/classes/java/net/ServerSocket.java b/src/src/java.base/share/classes/java/net/ServerSocket.java index 92a8b8ca8fd..c666d6c7886 100644 --- a/src/src/java.base/share/classes/java/net/ServerSocket.java +++ b/src/src/java.base/share/classes/java/net/ServerSocket.java @@ -27,6 +27,7 @@ import jdk.internal.misc.JavaNetSocketAccess; import jdk.internal.misc.SharedSecrets; +import sun.security.util.SecurityConstants; import java.io.FileDescriptor; import java.io.IOException; @@ -78,12 +79,25 @@ class ServerSocket implements java.io.Closeable { /** * Package-private constructor to create a ServerSocket associated with * the given SocketImpl. + * + * @throws SecurityException if a security manager is set and + * its {@code checkPermission} method doesn't allow + * {@code NetPermission("setSocketImpl")}. */ ServerSocket(SocketImpl impl) { + checkPermission(); this.impl = impl; impl.setServerSocket(this); } + private static Void checkPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION); + } + return null; + } + /** * Creates an unbound server socket. * diff --git a/src/src/java.base/share/classes/java/net/Socket.java b/src/src/java.base/share/classes/java/net/Socket.java index b875ce7cd0f..3f6a530c552 100644 --- a/src/src/java.base/share/classes/java/net/Socket.java +++ b/src/src/java.base/share/classes/java/net/Socket.java @@ -25,6 +25,8 @@ package java.net; +import sun.security.util.SecurityConstants; + import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; @@ -161,9 +163,14 @@ public Socket(Proxy proxy) { * * @exception SocketException if there is an error in the underlying protocol, * such as a TCP error. + * + * @throws SecurityException if {@code impl} is non-null and a security manager is set + * and its {@code checkPermission} method doesn't allow {@code NetPermission("setSocketImpl")}. + * * @since 1.1 */ protected Socket(SocketImpl impl) throws SocketException { + checkPermission(impl); this.impl = impl; if (impl != null) { checkOldImpl(); @@ -171,6 +178,17 @@ protected Socket(SocketImpl impl) throws SocketException { } } + private static Void checkPermission(SocketImpl impl) { + if (impl == null) { + return null; + } + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION); + } + return null; + } + /** * Creates a stream socket and connects it to the specified port * number on the named host. diff --git a/src/src/java.base/share/classes/java/net/SocketPermission.java b/src/src/java.base/share/classes/java/net/SocketPermission.java index 6878458e0eb..6b1f449669f 100644 --- a/src/src/java.base/share/classes/java/net/SocketPermission.java +++ b/src/src/java.base/share/classes/java/net/SocketPermission.java @@ -460,7 +460,7 @@ private void init(String host, int mask) { } return; } else { - if (host.length() > 0) { + if (!host.isEmpty()) { // see if we are being initialized with an IP address. char ch = host.charAt(0); if (ch == ':' || Character.digit(ch, 16) != -1) { @@ -705,8 +705,7 @@ private boolean match(String cname, String hname) { .orElse(b); } - return cdomain.length() != 0 && hdomain.length() != 0 - && cdomain.equals(hdomain); + return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain); } private boolean authorized(String cname, byte[] addr) { diff --git a/src/src/java.base/share/classes/java/net/URI.java b/src/src/java.base/share/classes/java/net/URI.java index 7cc241b6389..8ef05191619 100644 --- a/src/src/java.base/share/classes/java/net/URI.java +++ b/src/src/java.base/share/classes/java/net/URI.java @@ -1936,10 +1936,8 @@ private static void checkPath(String s, String scheme, String path) throws URISyntaxException { if (scheme != null) { - if ((path != null) - && ((path.length() > 0) && (path.charAt(0) != '/'))) - throw new URISyntaxException(s, - "Relative path in absolute URI"); + if (path != null && !path.isEmpty() && path.charAt(0) != '/') + throw new URISyntaxException(s, "Relative path in absolute URI"); } } @@ -2140,7 +2138,7 @@ private static URI resolve(URI base, URI child) { ru.port = base.port; String cp = (child.path == null) ? "" : child.path; - if ((cp.length() > 0) && (cp.charAt(0) == '/')) { + if (!cp.isEmpty() && cp.charAt(0) == '/') { // 5.2 (5): Child path is absolute ru.path = child.path; } else { @@ -2164,7 +2162,7 @@ private static URI resolve(URI base, URI child) { // o.w., return a new URI containing the normalized path. // private static URI normalize(URI u) { - if (u.isOpaque() || (u.path == null) || (u.path.length() == 0)) + if (u.isOpaque() || u.path == null || u.path.isEmpty()) return u; String np = normalize(u.path); diff --git a/src/src/java.base/share/classes/java/net/URL.java b/src/src/java.base/share/classes/java/net/URL.java index 2f859f4d906..0d258708333 100644 --- a/src/src/java.base/share/classes/java/net/URL.java +++ b/src/src/java.base/share/classes/java/net/URL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2019, 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 @@ -457,6 +457,16 @@ public URL(String protocol, String host, int port, String file, throw new MalformedURLException(s); } } + if ("jar".equalsIgnoreCase(protocol)) { + if (handler instanceof sun.net.www.protocol.jar.Handler) { + // URL.openConnection() would throw a confusing exception + // so generate a better exception here instead. + String s = ((sun.net.www.protocol.jar.Handler) handler).checkNestedProtocol(file); + if (s != null) { + throw new MalformedURLException(s); + } + } + } } /** @@ -1386,8 +1396,9 @@ static URLStreamHandler getURLStreamHandler(String protocol) { URLStreamHandlerFactory fac; boolean checkedWithFactory = false; + boolean overrideableProtocol = isOverrideable(protocol); - if (isOverrideable(protocol) && jdk.internal.misc.VM.isBooted()) { + if (overrideableProtocol && jdk.internal.misc.VM.isBooted()) { // Use the factory (if any). Volatile read makes // URLStreamHandlerFactory appear fully initialized to current thread. fac = factory; @@ -1423,7 +1434,8 @@ static URLStreamHandler getURLStreamHandler(String protocol) { // Check with factory if another thread set a // factory since our last check - if (!checkedWithFactory && (fac = factory) != null) { + if (overrideableProtocol && !checkedWithFactory && + (fac = factory) != null) { handler2 = fac.createURLStreamHandler(protocol); } @@ -1502,7 +1514,7 @@ private synchronized void readObject(java.io.ObjectInputStream s) String ref = (String)gf.get("ref", null); int hashCode = gf.get("hashCode", -1); if (authority == null - && ((host != null && host.length() > 0) || port != -1)) { + && ((host != null && !host.isEmpty()) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; @@ -1549,7 +1561,7 @@ private URL setDeserializedFields(URLStreamHandler handler) { // Construct authority part if (authority == null - && ((host != null && host.length() > 0) || port != -1)) { + && ((host != null && !host.isEmpty()) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; @@ -1709,7 +1721,7 @@ String reconstituteUrlString() { // pre-compute length of StringBuffer int len = protocol.length() + 1; - if (authority != null && authority.length() > 0) + if (authority != null && !authority.isEmpty()) len += 2 + authority.length(); if (file != null) { len += file.length(); @@ -1719,7 +1731,7 @@ String reconstituteUrlString() { StringBuilder result = new StringBuilder(len); result.append(protocol); result.append(":"); - if (authority != null && authority.length() > 0) { + if (authority != null && !authority.isEmpty()) { result.append("//"); result.append(authority); } diff --git a/src/src/java.base/share/classes/java/net/URLClassLoader.java b/src/src/java.base/share/classes/java/net/URLClassLoader.java index bab14c8bb11..7d73a7f03ce 100644 --- a/src/src/java.base/share/classes/java/net/URLClassLoader.java +++ b/src/src/java.base/share/classes/java/net/URLClassLoader.java @@ -778,7 +778,7 @@ protected PermissionCollection getPermissions(CodeSource codesource) locUrl = ((JarURLConnection)urlConnection).getJarFileURL(); } String host = locUrl.getHost(); - if (host != null && (host.length() > 0)) + if (host != null && !host.isEmpty()) p = new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION); } diff --git a/src/src/java.base/share/classes/java/net/URLDecoder.java b/src/src/java.base/share/classes/java/net/URLDecoder.java index 69330299673..c65272d767d 100644 --- a/src/src/java.base/share/classes/java/net/URLDecoder.java +++ b/src/src/java.base/share/classes/java/net/URLDecoder.java @@ -133,7 +133,7 @@ public static String decode(String s) { * @since 1.4 */ public static String decode(String s, String enc) throws UnsupportedEncodingException { - if (enc.length() == 0) { + if (enc.isEmpty()) { throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); } diff --git a/src/src/java.base/share/classes/java/net/URLPermission.java b/src/src/java.base/share/classes/java/net/URLPermission.java index 31441749659..9b3a88cebd0 100644 --- a/src/src/java.base/share/classes/java/net/URLPermission.java +++ b/src/src/java.base/share/classes/java/net/URLPermission.java @@ -383,7 +383,7 @@ private List normalizeMethods(String methods) { char c = methods.charAt(i); if (c == ',') { String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); b = new StringBuilder(); } else if (c == ' ' || c == '\t') { @@ -397,7 +397,7 @@ private List normalizeMethods(String methods) { } } String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); return l; } @@ -422,7 +422,7 @@ private List normalizeHeaders(String headers) { b.append(c); } else if (c == ',') { String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); b = new StringBuilder(); capitalizeNext = true; @@ -432,7 +432,7 @@ private List normalizeHeaders(String headers) { } } String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); return l; } diff --git a/src/src/java.base/share/classes/java/net/URLStreamHandler.java b/src/src/java.base/share/classes/java/net/URLStreamHandler.java index 8f1aa071f95..f9a1c0a6bbd 100644 --- a/src/src/java.base/share/classes/java/net/URLStreamHandler.java +++ b/src/src/java.base/share/classes/java/net/URLStreamHandler.java @@ -235,7 +235,7 @@ protected void parseURL(URL u, String spec, int start, int limit) { start = i; // If the authority is defined then the path is defined by the // spec only; See RFC 2396 Section 5.2.4. - if (authority != null && authority.length() > 0) + if (authority != null && !authority.isEmpty()) path = ""; } @@ -247,7 +247,7 @@ protected void parseURL(URL u, String spec, int start, int limit) { if (start < limit) { if (spec.charAt(start) == '/') { path = spec.substring(start, limit); - } else if (path != null && path.length() > 0) { + } else if (path != null && !path.isEmpty()) { isRelPath = true; int ind = path.lastIndexOf('/'); String seperator = ""; @@ -483,11 +483,11 @@ protected String toExternalForm(URL u) { String s; return u.getProtocol() + ':' - + (((s = u.getAuthority()) != null && s.length() > 0) + + ((s = u.getAuthority()) != null && !s.isEmpty() ? "//" + s : "") - + (((s = u.getPath()) != null) ? s : "") - + (((s = u.getQuery()) != null) ? '?' + s : "") - + (((s = u.getRef()) != null) ? '#' + s : ""); + + ((s = u.getPath()) != null ? s : "") + + ((s = u.getQuery()) != null ? '?' + s : "") + + ((s = u.getRef()) != null ? '#' + s : ""); } /** @@ -547,7 +547,7 @@ protected void setURL(URL u, String protocol, String host, int port, */ String authority = null; String userInfo = null; - if (host != null && host.length() != 0) { + if (host != null && !host.isEmpty()) { authority = (port == -1) ? host : host + ":" + port; int at = host.lastIndexOf('@'); if (at != -1) { diff --git a/src/src/java.base/share/classes/java/nio/file/FileSystems.java b/src/src/java.base/share/classes/java/nio/file/FileSystems.java index 8e5db1f3b6a..ebbe47d32c6 100644 --- a/src/src/java.base/share/classes/java/nio/file/FileSystems.java +++ b/src/src/java.base/share/classes/java/nio/file/FileSystems.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, 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 @@ -37,6 +37,7 @@ import java.util.ServiceLoader; import jdk.internal.misc.VM; +import sun.nio.fs.DefaultFileSystemProvider; /** * Factory methods for file systems. This class defines the {@link #getDefault @@ -88,16 +89,6 @@ public final class FileSystems { private FileSystems() { } - // Built-in file system provider - private static final FileSystemProvider builtinFileSystemProvider = - sun.nio.fs.DefaultFileSystemProvider.create(); - - // built-in file system - private static class BuiltinFileSystemHolder { - static final FileSystem builtinFileSystem = - builtinFileSystemProvider.getFileSystem(URI.create("file:///")); - } - // lazy initialization of default file system private static class DefaultFileSystemHolder { static final FileSystem defaultFileSystem = defaultFileSystem(); @@ -118,7 +109,8 @@ public FileSystemProvider run() { // returns default provider private static FileSystemProvider getDefaultProvider() { - FileSystemProvider provider = builtinFileSystemProvider; + // start with the platform's default file system provider + FileSystemProvider provider = DefaultFileSystemProvider.instance(); // if the property java.nio.file.spi.DefaultFileSystemProvider is // set then its value is the name of the default provider (or a list) @@ -189,7 +181,8 @@ public static FileSystem getDefault() { if (VM.isModuleSystemInited()) { return DefaultFileSystemHolder.defaultFileSystem; } else { - return BuiltinFileSystemHolder.builtinFileSystem; + // always use the platform's default file system during startup + return DefaultFileSystemProvider.theFileSystem(); } } diff --git a/src/src/java.base/share/classes/java/nio/file/LinkPermission.java b/src/src/java.base/share/classes/java/nio/file/LinkPermission.java index a7c3cc8a4ca..c8385499640 100644 --- a/src/src/java.base/share/classes/java/nio/file/LinkPermission.java +++ b/src/src/java.base/share/classes/java/nio/file/LinkPermission.java @@ -104,7 +104,7 @@ public LinkPermission(String name) { public LinkPermission(String name, String actions) { super(name); checkName(name); - if (actions != null && actions.length() > 0) { + if (actions != null && !actions.isEmpty()) { throw new IllegalArgumentException("actions: " + actions); } } diff --git a/src/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java b/src/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java index cc9ad853bf9..0be6b0de33a 100644 --- a/src/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java +++ b/src/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java @@ -228,7 +228,7 @@ public static AlgorithmParameterGenerator getInstance(String algorithm, throws NoSuchAlgorithmException, NoSuchProviderException { Objects.requireNonNull(algorithm, "null algorithm name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = Security.getImpl(algorithm, "AlgorithmParameterGenerator", diff --git a/src/src/java.base/share/classes/java/security/AlgorithmParameters.java b/src/src/java.base/share/classes/java/security/AlgorithmParameters.java index a5ed953e65b..930fa09f38e 100644 --- a/src/src/java.base/share/classes/java/security/AlgorithmParameters.java +++ b/src/src/java.base/share/classes/java/security/AlgorithmParameters.java @@ -209,7 +209,7 @@ public static AlgorithmParameters getInstance(String algorithm, throws NoSuchAlgorithmException, NoSuchProviderException { Objects.requireNonNull(algorithm, "null algorithm name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters", provider); diff --git a/src/src/java.base/share/classes/java/security/CodeSource.java b/src/src/java.base/share/classes/java/security/CodeSource.java index a1f98eeb557..c27068cf27a 100644 --- a/src/src/java.base/share/classes/java/security/CodeSource.java +++ b/src/src/java.base/share/classes/java/security/CodeSource.java @@ -57,7 +57,7 @@ public class CodeSource implements java.io.Serializable { * * @serial */ - private URL location; + private final URL location; /* * The code signers. diff --git a/src/src/java.base/share/classes/java/security/KeyStore.java b/src/src/java.base/share/classes/java/security/KeyStore.java index acb34db2383..80aa019ecd3 100644 --- a/src/src/java.base/share/classes/java/security/KeyStore.java +++ b/src/src/java.base/share/classes/java/security/KeyStore.java @@ -920,7 +920,7 @@ public static KeyStore getInstance(String type, String provider) throws KeyStoreException, NoSuchProviderException { Objects.requireNonNull(type, "null type name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); try { Object[] objs = Security.getImpl(type, "KeyStore", provider); diff --git a/src/src/java.base/share/classes/java/security/MessageDigest.java b/src/src/java.base/share/classes/java/security/MessageDigest.java index 4f4987ceb46..565f4349018 100644 --- a/src/src/java.base/share/classes/java/security/MessageDigest.java +++ b/src/src/java.base/share/classes/java/security/MessageDigest.java @@ -237,7 +237,7 @@ public static MessageDigest getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { Objects.requireNonNull(algorithm, "null algorithm name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider); if (objs[0] instanceof MessageDigest) { diff --git a/src/src/java.base/share/classes/java/security/Permission.java b/src/src/java.base/share/classes/java/security/Permission.java index 0eb0496ce3b..e1c526e7a9e 100644 --- a/src/src/java.base/share/classes/java/security/Permission.java +++ b/src/src/java.base/share/classes/java/security/Permission.java @@ -222,7 +222,7 @@ public PermissionCollection newPermissionCollection() { */ public String toString() { String actions = getActions(); - if ((actions == null) || (actions.length() == 0)) { // OPTIONAL + if (actions == null || actions.isEmpty()) { // OPTIONAL return "(\"" + getClass().getName() + "\" \"" + name + "\")"; } else { return "(\"" + getClass().getName() + "\" \"" + name + diff --git a/src/src/java.base/share/classes/java/security/Policy.java b/src/src/java.base/share/classes/java/security/Policy.java index 54663a5a0f8..5c13529c9dc 100644 --- a/src/src/java.base/share/classes/java/security/Policy.java +++ b/src/src/java.base/share/classes/java/security/Policy.java @@ -456,7 +456,7 @@ public static Policy getInstance(String type, throws NoSuchProviderException, NoSuchAlgorithmException { Objects.requireNonNull(type, "null type name"); - if (provider == null || provider.length() == 0) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } diff --git a/src/src/java.base/share/classes/java/security/SecureRandom.java b/src/src/java.base/share/classes/java/security/SecureRandom.java index 254f378aac6..09ecdf1c6e6 100644 --- a/src/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/src/java.base/share/classes/java/security/SecureRandom.java @@ -942,7 +942,7 @@ public String run() { } }); - if ((property == null) || (property.length() == 0)) { + if (property == null || property.isEmpty()) { throw new NoSuchAlgorithmException( "Null/empty securerandom.strongAlgorithms Security Property"); } diff --git a/src/src/java.base/share/classes/java/security/Security.java b/src/src/java.base/share/classes/java/security/Security.java index e551ebe90f5..b36510a376b 100644 --- a/src/src/java.base/share/classes/java/security/Security.java +++ b/src/src/java.base/share/classes/java/security/Security.java @@ -30,6 +30,8 @@ import java.io.*; import java.net.URL; +import jdk.internal.event.EventHelper; +import jdk.internal.event.SecurityPropertyModificationEvent; import jdk.internal.misc.SharedSecrets; import jdk.internal.util.StaticProperty; import sun.security.util.Debug; @@ -647,7 +649,7 @@ public static Provider[] getProviders(Map filter) { } } - if ((candidates == null) || (candidates.isEmpty())) + if (candidates == null || candidates.isEmpty()) return null; Object[] candidatesArray = candidates.toArray(); @@ -792,9 +794,19 @@ public static String getProperty(String key) { * @see java.security.SecurityPermission */ public static void setProperty(String key, String datum) { - check("setProperty."+key); + check("setProperty." + key); props.put(key, datum); invalidateSMCache(key); /* See below. */ + + SecurityPropertyModificationEvent spe = new SecurityPropertyModificationEvent(); + // following is a no-op if event is disabled + spe.key = key; + spe.value = datum; + spe.commit(); + + if (EventHelper.isLoggingSecurity()) { + EventHelper.logSecurityPropertyEvent(key, datum); + } } /* @@ -993,11 +1005,11 @@ static String[] getFilterComponents(String filterKey, String filterValue) { String algName = null; String attrName = null; - if (filterValue.length() == 0) { + if (filterValue.isEmpty()) { // The filterValue is an empty string. So the filterKey // should be in the format of .. algName = filterKey.substring(algIndex + 1).trim(); - if (algName.length() == 0) { + if (algName.isEmpty()) { // There must be a algorithm or type name. throw new InvalidParameterException("Invalid filter"); } @@ -1012,7 +1024,7 @@ static String[] getFilterComponents(String filterKey, String filterValue) { throw new InvalidParameterException("Invalid filter"); } else { attrName = filterKey.substring(attrIndex + 1).trim(); - if (attrName.length() == 0) { + if (attrName.isEmpty()) { // There is no attribute name in the filter. throw new InvalidParameterException("Invalid filter"); } @@ -1058,7 +1070,7 @@ static String[] getFilterComponents(String filterKey, String filterValue) { **/ public static Set getAlgorithms(String serviceName) { - if ((serviceName == null) || (serviceName.length() == 0) || + if ((serviceName == null) || (serviceName.isEmpty()) || (serviceName.endsWith("."))) { return Collections.emptySet(); } diff --git a/src/src/java.base/share/classes/java/security/Signature.java b/src/src/java.base/share/classes/java/security/Signature.java index 141237ad94b..c83efce1ab7 100644 --- a/src/src/java.base/share/classes/java/security/Signature.java +++ b/src/src/java.base/share/classes/java/security/Signature.java @@ -40,6 +40,8 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.BadPaddingException; import javax.crypto.NoSuchPaddingException; +import jdk.internal.misc.JavaSecuritySignatureAccess; +import jdk.internal.misc.SharedSecrets; import sun.security.util.Debug; import sun.security.jca.*; @@ -118,6 +120,34 @@ public abstract class Signature extends SignatureSpi { + static { + SharedSecrets.setJavaSecuritySignatureAccess( + new JavaSecuritySignatureAccess() { + @Override + public void initVerify(Signature s, PublicKey publicKey, + AlgorithmParameterSpec params) + throws InvalidKeyException, + InvalidAlgorithmParameterException { + s.initVerify(publicKey, params); + } + @Override + public void initVerify(Signature s, + java.security.cert.Certificate certificate, + AlgorithmParameterSpec params) + throws InvalidKeyException, + InvalidAlgorithmParameterException { + s.initVerify(certificate, params); + } + @Override + public void initSign(Signature s, PrivateKey privateKey, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, + InvalidAlgorithmParameterException { + s.initSign(privateKey, params, random); + } + }); + } + private static final Debug debug = Debug.getInstance("jca", "Signature"); @@ -360,7 +390,7 @@ public static Signature getInstance(String algorithm, String provider) Objects.requireNonNull(algorithm, "null algorithm name"); if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { // exception compatibility with existing code - if ((provider == null) || (provider.length() == 0)) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } Provider p = Security.getProvider(provider); @@ -482,6 +512,53 @@ public final void initVerify(PublicKey publicKey) } } + /** + * Initialize this object for verification. If this method is called + * again with different arguments, it negates the effect + * of this call. + * + * @param publicKey the public key of the identity whose signature is + * going to be verified. + * @param params the parameters used for verifying this signature. + * + * @exception InvalidKeyException if the key is invalid. + * @exception InvalidAlgorithmParameterException if the params is invalid. + */ + final void initVerify(PublicKey publicKey, AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException { + engineInitVerify(publicKey, params); + state = VERIFY; + + if (!skipDebug && pdebug != null) { + pdebug.println("Signature." + algorithm + + " verification algorithm from: " + getProviderName()); + } + } + + private static PublicKey getPublicKeyFromCert(Certificate cert) + throws InvalidKeyException { + // If the certificate is of type X509Certificate, + // we should check whether it has a Key Usage + // extension marked as critical. + //if (cert instanceof java.security.cert.X509Certificate) { + if (cert instanceof X509Certificate) { + // Check whether the cert has a key usage extension + // marked as a critical extension. + // The OID for KeyUsage extension is 2.5.29.15. + X509Certificate c = (X509Certificate)cert; + Set critSet = c.getCriticalExtensionOIDs(); + + if (critSet != null && !critSet.isEmpty() + && critSet.contains("2.5.29.15")) { + boolean[] keyUsageInfo = c.getKeyUsage(); + // keyUsageInfo[0] is for digitalSignature. + if ((keyUsageInfo != null) && (keyUsageInfo[0] == false)) + throw new InvalidKeyException("Wrong key usage"); + } + } + return cert.getPublicKey(); + } + /** * Initializes this object for verification, using the public key from * the given certificate. @@ -502,27 +579,40 @@ public final void initVerify(PublicKey publicKey) */ public final void initVerify(Certificate certificate) throws InvalidKeyException { - // If the certificate is of type X509Certificate, - // we should check whether it has a Key Usage - // extension marked as critical. - if (certificate instanceof java.security.cert.X509Certificate) { - // Check whether the cert has a key usage extension - // marked as a critical extension. - // The OID for KeyUsage extension is 2.5.29.15. - X509Certificate cert = (X509Certificate)certificate; - Set critSet = cert.getCriticalExtensionOIDs(); + engineInitVerify(getPublicKeyFromCert(certificate)); + state = VERIFY; - if (critSet != null && !critSet.isEmpty() - && critSet.contains("2.5.29.15")) { - boolean[] keyUsageInfo = cert.getKeyUsage(); - // keyUsageInfo[0] is for digitalSignature. - if ((keyUsageInfo != null) && (keyUsageInfo[0] == false)) - throw new InvalidKeyException("Wrong key usage"); - } + if (!skipDebug && pdebug != null) { + pdebug.println("Signature." + algorithm + + " verification algorithm from: " + getProviderName()); } + } - PublicKey publicKey = certificate.getPublicKey(); - engineInitVerify(publicKey); + /** + * Initializes this object for verification, using the public key from + * the given certificate. + *

    If the certificate is of type X.509 and has a key usage + * extension field marked as critical, and the value of the key usage + * extension field implies that the public key in + * the certificate and its corresponding private key are not + * supposed to be used for digital signatures, an + * {@code InvalidKeyException} is thrown. + * + * @param certificate the certificate of the identity whose signature is + * going to be verified. + * @param params the parameters used for verifying this signature. + * + * @exception InvalidKeyException if the public key in the certificate + * is not encoded properly or does not include required parameter + * information or cannot be used for digital signature purposes. + * @exception InvalidAlgorithmParameterException if the params is invalid. + * + * @since 13 + */ + final void initVerify(Certificate certificate, + AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException { + engineInitVerify(getPublicKeyFromCert(certificate), params); state = VERIFY; if (!skipDebug && pdebug != null) { @@ -575,6 +665,31 @@ public final void initSign(PrivateKey privateKey, SecureRandom random) } } + /** + * Initialize this object for signing. If this method is called + * again with different arguments, it negates the effect + * of this call. + * + * @param privateKey the private key of the identity whose signature + * is going to be generated. + * @param params the parameters used for generating signature. + * @param random the source of randomness for this signature. + * + * @exception InvalidKeyException if the key is invalid. + * @exception InvalidAlgorithmParameterException if the params is invalid + */ + final void initSign(PrivateKey privateKey, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { + engineInitSign(privateKey, params, random); + state = SIGN; + + if (!skipDebug && pdebug != null) { + pdebug.println("Signature." + algorithm + + " signing algorithm from: " + getProviderName()); + } + } + /** * Returns the signature bytes of all the data updated. * The format of the signature depends on the underlying @@ -1111,11 +1226,13 @@ void chooseFirstProvider() { } } - private void chooseProvider(int type, Key key, SecureRandom random) - throws InvalidKeyException { + // Used by engineSetParameter/engineInitSign/engineInitVerify() to + // find the right provider with the supplied key, parameters, random source + private void chooseProvider(int type, Key key, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { synchronized (lock) { if (sigSpi != null) { - init(sigSpi, type, key, random); return; } Exception lastException = null; @@ -1128,7 +1245,7 @@ private void chooseProvider(int type, Key key, SecureRandom random) s = serviceIterator.next(); } // if provider says it does not support this key, ignore it - if (s.supportsParameter(key) == false) { + if (key != null && s.supportsParameter(key) == false) { continue; } // if instance is not a SignatureSpi, ignore it @@ -1137,7 +1254,7 @@ private void chooseProvider(int type, Key key, SecureRandom random) } try { SignatureSpi spi = newInstance(s); - init(spi, type, key, random); + tryOperation(spi, type, key, params, random); provider = s.getProvider(); sigSpi = spi; firstService = null; @@ -1159,6 +1276,10 @@ private void chooseProvider(int type, Key key, SecureRandom random) if (lastException instanceof RuntimeException) { throw (RuntimeException)lastException; } + if (lastException instanceof InvalidAlgorithmParameterException) { + throw (InvalidAlgorithmParameterException)lastException; + } + String k = (key != null) ? key.getClass().getName() : "(null)"; throw new InvalidKeyException ("No installed provider supports this key: " @@ -1166,22 +1287,35 @@ private void chooseProvider(int type, Key key, SecureRandom random) } } - private static final int I_PUB = 1; - private static final int I_PRIV = 2; - private static final int I_PRIV_SR = 3; + private static final int I_PUB = 1; + private static final int I_PRIV = 2; + private static final int I_PRIV_SR = 3; + private static final int I_PUB_PARAM = 4; + private static final int I_PRIV_PARAM_SR = 5; + private static final int S_PARAM = 6; - private void init(SignatureSpi spi, int type, Key key, - SecureRandom random) throws InvalidKeyException { + private void tryOperation(SignatureSpi spi, int type, Key key, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { switch (type) { case I_PUB: spi.engineInitVerify((PublicKey)key); break; + case I_PUB_PARAM: + spi.engineInitVerify((PublicKey)key, params); + break; case I_PRIV: spi.engineInitSign((PrivateKey)key); break; case I_PRIV_SR: spi.engineInitSign((PrivateKey)key, random); break; + case I_PRIV_PARAM_SR: + spi.engineInitSign((PrivateKey)key, params, random); + break; + case S_PARAM: + spi.engineSetParameter(params); + break; default: throw new AssertionError("Internal error: " + type); } @@ -1192,7 +1326,22 @@ protected void engineInitVerify(PublicKey publicKey) if (sigSpi != null) { sigSpi.engineInitVerify(publicKey); } else { - chooseProvider(I_PUB, publicKey, null); + try { + chooseProvider(I_PUB, publicKey, null, null); + } catch (InvalidAlgorithmParameterException iape) { + // should not happen, re-throw as IKE just in case + throw new InvalidKeyException(iape); + } + } + } + + void engineInitVerify(PublicKey publicKey, + AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException { + if (sigSpi != null) { + sigSpi.engineInitVerify(publicKey, params); + } else { + chooseProvider(I_PUB_PARAM, publicKey, params, null); } } @@ -1201,7 +1350,12 @@ protected void engineInitSign(PrivateKey privateKey) if (sigSpi != null) { sigSpi.engineInitSign(privateKey); } else { - chooseProvider(I_PRIV, privateKey, null); + try { + chooseProvider(I_PRIV, privateKey, null, null); + } catch (InvalidAlgorithmParameterException iape) { + // should not happen, re-throw as IKE just in case + throw new InvalidKeyException(iape); + } } } @@ -1210,7 +1364,22 @@ protected void engineInitSign(PrivateKey privateKey, SecureRandom sr) if (sigSpi != null) { sigSpi.engineInitSign(privateKey, sr); } else { - chooseProvider(I_PRIV_SR, privateKey, sr); + try { + chooseProvider(I_PRIV_SR, privateKey, null, sr); + } catch (InvalidAlgorithmParameterException iape) { + // should not happen, re-throw as IKE just in case + throw new InvalidKeyException(iape); + } + } + } + + void engineInitSign(PrivateKey privateKey, + AlgorithmParameterSpec params, SecureRandom sr) + throws InvalidKeyException, InvalidAlgorithmParameterException { + if (sigSpi != null) { + sigSpi.engineInitSign(privateKey, params, sr); + } else { + chooseProvider(I_PRIV_PARAM_SR, privateKey, params, sr); } } @@ -1261,8 +1430,16 @@ protected void engineSetParameter(String param, Object value) protected void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException { - chooseFirstProvider(); - sigSpi.engineSetParameter(params); + if (sigSpi != null) { + sigSpi.engineSetParameter(params); + } else { + try { + chooseProvider(S_PARAM, null, params, null); + } catch (InvalidKeyException ike) { + // should never happen, rethrow just in case + throw new InvalidAlgorithmParameterException(ike); + } + } } protected Object engineGetParameter(String param) diff --git a/src/src/java.base/share/classes/java/security/SignatureSpi.java b/src/src/java.base/share/classes/java/security/SignatureSpi.java index 884f3cb22c9..f0f925d18e0 100644 --- a/src/src/java.base/share/classes/java/security/SignatureSpi.java +++ b/src/src/java.base/share/classes/java/security/SignatureSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -70,6 +70,33 @@ public abstract class SignatureSpi { protected abstract void engineInitVerify(PublicKey publicKey) throws InvalidKeyException; + /** + * Initializes this signature object with the specified + * public key for verification operations. + * + * @param publicKey the public key of the identity whose signature is + * going to be verified. + * @param params the parameters for generating this signature + * + * @exception InvalidKeyException if the key is improperly + * encoded, does not work with the given parameters, and so on. + * @exception InvalidAlgorithmParameterException if the given parameters + * is invalid. + */ + void engineInitVerify(PublicKey publicKey, + AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException { + if (params != null) { + try { + engineSetParameter(params); + } catch (UnsupportedOperationException usoe) { + // error out if not overrridden + throw new InvalidAlgorithmParameterException(usoe); + } + } + engineInitVerify(publicKey); + } + /** * Initializes this signature object with the specified * private key for signing operations. @@ -98,10 +125,41 @@ protected abstract void engineInitSign(PrivateKey privateKey) * encoded, parameters are missing, and so on. */ protected void engineInitSign(PrivateKey privateKey, - SecureRandom random) - throws InvalidKeyException { - this.appRandom = random; - engineInitSign(privateKey); + SecureRandom random) + throws InvalidKeyException { + this.appRandom = random; + engineInitSign(privateKey); + } + + /** + * Initializes this signature object with the specified + * private key and source of randomness for signing operations. + * + *

    This concrete method has been added to this previously-defined + * abstract class. (For backwards compatibility, it cannot be abstract.) + * + * @param privateKey the private key of the identity whose signature + * will be generated. + * @param params the parameters for generating this signature + * @param random the source of randomness + * + * @exception InvalidKeyException if the key is improperly + * encoded, parameters are missing, and so on. + * @exception InvalidAlgorithmParameterException if the parameters is + * invalid. + */ + void engineInitSign(PrivateKey privateKey, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { + if (params != null) { + try { + engineSetParameter(params); + } catch (UnsupportedOperationException usoe) { + // error out if not overrridden + throw new InvalidAlgorithmParameterException(usoe); + } + } + engineInitSign(privateKey, random); } /** @@ -127,7 +185,7 @@ protected void engineInitSign(PrivateKey privateKey, * properly */ protected abstract void engineUpdate(byte[] b, int off, int len) - throws SignatureException; + throws SignatureException; /** * Updates the data to be signed or verified using the specified @@ -223,7 +281,7 @@ protected void engineUpdate(ByteBuffer input) { * @since 1.2 */ protected int engineSign(byte[] outbuf, int offset, int len) - throws SignatureException { + throws SignatureException { byte[] sig = engineSign(); if (len < sig.length) { throw new SignatureException @@ -251,7 +309,7 @@ protected int engineSign(byte[] outbuf, int offset, int len) * process the input data provided, etc. */ protected abstract boolean engineVerify(byte[] sigBytes) - throws SignatureException; + throws SignatureException; /** * Verifies the passed-in signature in the specified array @@ -273,7 +331,7 @@ protected abstract boolean engineVerify(byte[] sigBytes) * @since 1.4 */ protected boolean engineVerify(byte[] sigBytes, int offset, int length) - throws SignatureException { + throws SignatureException { byte[] sigBytesCopy = new byte[length]; System.arraycopy(sigBytes, offset, sigBytesCopy, 0, length); return engineVerify(sigBytesCopy); @@ -305,7 +363,7 @@ protected boolean engineVerify(byte[] sigBytes, int offset, int length) */ @Deprecated protected abstract void engineSetParameter(String param, Object value) - throws InvalidParameterException; + throws InvalidParameterException; /** *

    This method is overridden by providers to initialize @@ -321,8 +379,8 @@ protected abstract void engineSetParameter(String param, Object value) * are inappropriate for this signature engine */ protected void engineSetParameter(AlgorithmParameterSpec params) - throws InvalidAlgorithmParameterException { - throw new UnsupportedOperationException(); + throws InvalidAlgorithmParameterException { + throw new UnsupportedOperationException(); } /** diff --git a/src/src/java.base/share/classes/java/security/cert/TrustAnchor.java b/src/src/java.base/share/classes/java/security/cert/TrustAnchor.java index 8b765a29ced..78ff2f04e12 100644 --- a/src/src/java.base/share/classes/java/security/cert/TrustAnchor.java +++ b/src/src/java.base/share/classes/java/security/cert/TrustAnchor.java @@ -210,7 +210,7 @@ public TrustAnchor(String caName, PublicKey pubKey, byte[] nameConstraints) if (caName == null) throw new NullPointerException("the caName parameter must be " + "non-null"); - if (caName.length() == 0) + if (caName.isEmpty()) throw new IllegalArgumentException("the caName " + "parameter must be a non-empty String"); // check if caName is formatted correctly diff --git a/src/src/java.base/share/classes/java/security/cert/X509CRL.java b/src/src/java.base/share/classes/java/security/cert/X509CRL.java index 64f2656f117..a9b56f639b6 100644 --- a/src/src/java.base/share/classes/java/security/cert/X509CRL.java +++ b/src/src/java.base/share/classes/java/security/cert/X509CRL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -239,16 +239,15 @@ public abstract void verify(PublicKey key, String sigProvider) public void verify(PublicKey key, Provider sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { + String sigAlgName = getSigAlgName(); Signature sig = (sigProvider == null) - ? Signature.getInstance(getSigAlgName()) - : Signature.getInstance(getSigAlgName(), sigProvider); + ? Signature.getInstance(sigAlgName) + : Signature.getInstance(sigAlgName, sigProvider); - sig.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selections occur when key is set try { - SignatureUtil.specialSetParameter(sig, getSigAlgParams()); + byte[] paramBytes = getSigAlgParams(); + SignatureUtil.initVerifyWithParam(sig, key, + SignatureUtil.getParamSpec(sigAlgName, paramBytes)); } catch (ProviderException e) { throw new CRLException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { diff --git a/src/src/java.base/share/classes/java/security/cert/X509CertSelector.java b/src/src/java.base/share/classes/java/security/cert/X509CertSelector.java index 268bd42198a..70c77258ad0 100644 --- a/src/src/java.base/share/classes/java/security/cert/X509CertSelector.java +++ b/src/src/java.base/share/classes/java/security/cert/X509CertSelector.java @@ -2115,8 +2115,11 @@ private boolean matchSubjectKeyID(X509Certificate xcert) { if (certSubjectKeyID == null || !Arrays.equals(subjectKeyID, certSubjectKeyID)) { if (debug != null) { - debug.println("X509CertSelector.match: " - + "subject key IDs don't match"); + debug.println("X509CertSelector.match: subject key IDs " + + "don't match\nX509CertSelector.match: subjectKeyID: " + + Arrays.toString(subjectKeyID) + + "\nX509CertSelector.match: certSubjectKeyID: " + + Arrays.toString(certSubjectKeyID)); } return false; } diff --git a/src/src/java.base/share/classes/java/security/cert/X509Certificate.java b/src/src/java.base/share/classes/java/security/cert/X509Certificate.java index d9f2729f5f7..60de9a1327a 100644 --- a/src/src/java.base/share/classes/java/security/cert/X509Certificate.java +++ b/src/src/java.base/share/classes/java/security/cert/X509Certificate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -676,16 +676,14 @@ public Collection> getIssuerAlternativeNames() public void verify(PublicKey key, Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { + String sigName = getSigAlgName(); Signature sig = (sigProvider == null) - ? Signature.getInstance(getSigAlgName()) - : Signature.getInstance(getSigAlgName(), sigProvider); + ? Signature.getInstance(sigName) + : Signature.getInstance(sigName, sigProvider); - sig.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selections occur when key is set try { - SignatureUtil.specialSetParameter(sig, getSigAlgParams()); + SignatureUtil.initVerifyWithParam(sig, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { diff --git a/src/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java b/src/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java index 6f801638d76..d6925b08385 100644 --- a/src/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java +++ b/src/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package java.security.spec; import java.util.Objects; -import java.security.spec.MGF1ParameterSpec; /** * This class specifies a parameter spec for RSASSA-PSS signature scheme, @@ -218,4 +217,14 @@ public int getSaltLength() { public int getTrailerField() { return trailerField; } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("MD: " + mdName + "\n") + .append("MGF: " + mgfSpec + "\n") + .append("SaltLength: " + saltLen + "\n") + .append("TrailerField: " + trailerField + "\n"); + return sb.toString(); + } } diff --git a/src/src/java.base/share/classes/java/text/AttributedString.java b/src/src/java.base/share/classes/java/text/AttributedString.java index fc62f5c71fd..2e6e0e72ff9 100644 --- a/src/src/java.base/share/classes/java/text/AttributedString.java +++ b/src/src/java.base/share/classes/java/text/AttributedString.java @@ -85,7 +85,7 @@ public class AttributedString { text = buffer.toString(); - if (text.length() > 0) { + if (!text.isEmpty()) { // Determine the runs, creating a new run when the attributes // differ. int offset = 0; @@ -144,7 +144,7 @@ public AttributedString(String text, } this.text = text; - if (text.length() == 0) { + if (text.isEmpty()) { if (attributes.isEmpty()) return; throw new IllegalArgumentException("Can't add attribute to 0-length text"); diff --git a/src/src/java.base/share/classes/java/text/CollationElementIterator.java b/src/src/java.base/share/classes/java/text/CollationElementIterator.java index 9da55b26625..22d100c1a10 100644 --- a/src/src/java.base/share/classes/java/text/CollationElementIterator.java +++ b/src/src/java.base/share/classes/java/text/CollationElementIterator.java @@ -125,7 +125,7 @@ public final class CollationElementIterator CollationElementIterator(String sourceText, RuleBasedCollator owner) { this.owner = owner; ordering = owner.getTables(); - if ( sourceText.length() != 0 ) { + if (!sourceText.isEmpty()) { NormalizerBase.Mode mode = CollatorUtilities.toNormalizerMode(owner.getDecomposition()); text = new NormalizerBase(sourceText, mode); diff --git a/src/src/java.base/share/classes/java/text/DecimalFormat.java b/src/src/java.base/share/classes/java/text/DecimalFormat.java index 3cc1e0a8018..950df6dfe3c 100644 --- a/src/src/java.base/share/classes/java/text/DecimalFormat.java +++ b/src/src/java.base/share/classes/java/text/DecimalFormat.java @@ -1072,11 +1072,9 @@ private void resetFastPathData(boolean fastPathWasOn) { // Records the need for adding prefix or suffix fastPathData.positiveAffixesRequired - = (positivePrefix.length() != 0) - || (positiveSuffix.length() != 0); + = !positivePrefix.isEmpty() || !positiveSuffix.isEmpty(); fastPathData.negativeAffixesRequired - = (negativePrefix.length() != 0) - || (negativeSuffix.length() != 0); + = !negativePrefix.isEmpty() || !negativeSuffix.isEmpty(); // Creates a cached char container for result, with max possible size. int maxNbIntegralDigits = 10; @@ -1990,7 +1988,7 @@ private void append(StringBuffer result, String string, Format.Field signAttribute) { int start = result.length(); - if (string.length() > 0) { + if (!string.isEmpty()) { result.append(string); for (int counter = 0, max = positions.length; counter < max; counter++) { @@ -2945,7 +2943,7 @@ private FieldPosition[] expandAffix(String pattern) { } else { string = symbols.getCurrencySymbol(); } - if (string.length() > 0) { + if (!string.isEmpty()) { if (positions == null) { positions = new ArrayList<>(2); } @@ -3516,7 +3514,7 @@ else if (ch == percent) { } } - if (pattern.length() == 0) { + if (pattern.isEmpty()) { posPrefixPattern = posSuffixPattern = ""; setMinimumIntegerDigits(0); setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS); diff --git a/src/src/java.base/share/classes/java/text/DecimalFormatSymbols.java b/src/src/java.base/share/classes/java/text/DecimalFormatSymbols.java index 59e68600589..acaf3bfbcf1 100644 --- a/src/src/java.base/share/classes/java/text/DecimalFormatSymbols.java +++ b/src/src/java.base/share/classes/java/text/DecimalFormatSymbols.java @@ -663,7 +663,7 @@ private void initializeCurrency(Locale locale) { // Check for empty country string separately because it's a valid // country ID for Locale (and used for the C locale), but not a valid // ISO 3166 country code, and exceptions are expensive. - if (locale.getCountry().length() > 0) { + if (!locale.getCountry().isEmpty()) { try { currency = Currency.getInstance(locale); } catch (IllegalArgumentException e) { diff --git a/src/src/java.base/share/classes/java/text/MergeCollation.java b/src/src/java.base/share/classes/java/text/MergeCollation.java index 4e5e5a53ae0..1bfcbf018ac 100644 --- a/src/src/java.base/share/classes/java/text/MergeCollation.java +++ b/src/src/java.base/share/classes/java/text/MergeCollation.java @@ -92,7 +92,7 @@ public String getPattern(boolean withWhiteSpace) { int i; for (i = 0; i < patterns.size(); ++i) { PatternEntry entry = patterns.get(i); - if (entry.extension.length() != 0) { + if (!entry.extension.isEmpty()) { if (extList == null) extList = new ArrayList<>(); extList.add(entry); @@ -122,7 +122,7 @@ public String getPattern(boolean withWhiteSpace) { private final PatternEntry findLastWithNoExtension(int i) { for (--i;i >= 0; --i) { PatternEntry entry = patterns.get(i); - if (entry.extension.length() == 0) { + if (entry.extension.isEmpty()) { return entry; } } diff --git a/src/src/java.base/share/classes/java/text/MessageFormat.java b/src/src/java.base/share/classes/java/text/MessageFormat.java index 4560abd822b..e54033cb8ff 100644 --- a/src/src/java.base/share/classes/java/text/MessageFormat.java +++ b/src/src/java.base/share/classes/java/text/MessageFormat.java @@ -1330,7 +1330,7 @@ private StringBuffer subformat(Object[] arguments, StringBuffer result, } arg = null; } - if (arg != null && arg.length() > 0) { + if (arg != null && !arg.isEmpty()) { result.append(arg); characterIterators.add( createAttributedCharacterIterator( @@ -1476,7 +1476,7 @@ private void makeFormat(int position, int offsetNumber, // now get the format Format newFormat = null; - if (segments[SEG_TYPE].length() != 0) { + if (!segments[SEG_TYPE].isEmpty()) { int type = findKeyword(segments[SEG_TYPE], TYPE_KEYWORDS); switch (type) { case TYPE_NULL: diff --git a/src/src/java.base/share/classes/java/text/PatternEntry.java b/src/src/java.base/share/classes/java/text/PatternEntry.java index 07af4b8aaeb..3e065dff403 100644 --- a/src/src/java.base/share/classes/java/text/PatternEntry.java +++ b/src/src/java.base/share/classes/java/text/PatternEntry.java @@ -141,7 +141,7 @@ void addToBuffer(StringBuffer toAddTo, if (showWhiteSpace) toAddTo.append(' '); appendQuoted(chars,toAddTo); - if (showExtension && extension.length() != 0) { + if (showExtension && !extension.isEmpty()) { toAddTo.append('/'); appendQuoted(extension,toAddTo); } diff --git a/src/src/java.base/share/classes/java/text/RBTableBuilder.java b/src/src/java.base/share/classes/java/text/RBTableBuilder.java index 99ac56ef56d..0210112f289 100644 --- a/src/src/java.base/share/classes/java/text/RBTableBuilder.java +++ b/src/src/java.base/share/classes/java/text/RBTableBuilder.java @@ -75,13 +75,10 @@ public RBTableBuilder(RBCollationTables.BuildAPI tables) { * @exception ParseException If the rules format is incorrect. */ - public void build(String pattern, int decmp) throws ParseException - { - boolean isSource = true; - int i = 0; + public void build(String pattern, int decmp) throws ParseException { String expChars; String groupChars; - if (pattern.length() == 0) + if (pattern.isEmpty()) throw new ParseException("Build rules empty.", 0); // This array maps Unicode characters to their collation ordering @@ -119,8 +116,7 @@ public void build(String pattern, int decmp) throws ParseException int order = 0; // Now walk though each entry and add it to my own tables - for (i = 0; i < mPattern.getCount(); ++i) - { + for (int i = 0; i < mPattern.getCount(); ++i) { PatternEntry entry = mPattern.getItemAt(i); if (entry != null) { groupChars = entry.getChars(); @@ -140,7 +136,7 @@ public void build(String pattern, int decmp) throws ParseException order = increment(entry.getStrength(), order); expChars = entry.getExtension(); - if (expChars.length() != 0) { + if (!expChars.isEmpty()) { addExpandOrder(groupChars, expChars, order); } else if (groupChars.length() > 1) { char ch = groupChars.charAt(0); diff --git a/src/src/java.base/share/classes/java/time/ZoneId.java b/src/src/java.base/share/classes/java/time/ZoneId.java index 8bd135ab611..b6b19f7d7ee 100644 --- a/src/src/java.base/share/classes/java/time/ZoneId.java +++ b/src/src/java.base/share/classes/java/time/ZoneId.java @@ -372,7 +372,7 @@ public static ZoneId of(String zoneId) { public static ZoneId ofOffset(String prefix, ZoneOffset offset) { Objects.requireNonNull(prefix, "prefix"); Objects.requireNonNull(offset, "offset"); - if (prefix.length() == 0) { + if (prefix.isEmpty()) { return offset; } diff --git a/src/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java b/src/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java index 28e58797b47..e8d9f34cfa2 100644 --- a/src/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/src/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -1435,7 +1435,7 @@ public DateTimeFormatterBuilder appendLiteral(char literal) { */ public DateTimeFormatterBuilder appendLiteral(String literal) { Objects.requireNonNull(literal, "literal"); - if (literal.length() > 0) { + if (!literal.isEmpty()) { if (literal.length() == 1) { appendInternal(new CharLiteralPrinterParser(literal.charAt(0))); } else { @@ -1828,7 +1828,7 @@ private void parsePattern(String pattern) { throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern); } String str = pattern.substring(start + 1, pos); - if (str.length() == 0) { + if (str.isEmpty()) { appendLiteral('\''); } else { appendLiteral(str.replace("''", "'")); @@ -4327,7 +4327,7 @@ private PrefixTree(String k, String v, PrefixTree child) { this.key = k; this.value = v; this.child = child; - if (k.length() == 0){ + if (k.isEmpty()) { c0 = 0xffff; } else { c0 = key.charAt(0); diff --git a/src/src/java.base/share/classes/java/time/zone/Ser.java b/src/src/java.base/share/classes/java/time/zone/Ser.java index 31c2f2d2bc1..0017fb83bb6 100644 --- a/src/src/java.base/share/classes/java/time/zone/Ser.java +++ b/src/src/java.base/share/classes/java/time/zone/Ser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -91,7 +91,7 @@ final class Ser implements Externalizable { static final byte ZRULES = 1; /** Type for ZoneOffsetTransition. */ static final byte ZOT = 2; - /** Type for ZoneOffsetTransition. */ + /** Type for ZoneOffsetTransitionRule. */ static final byte ZOTRULE = 3; /** The type being serialized. */ diff --git a/src/src/java.base/share/classes/java/time/zone/ZoneOffsetTransitionRule.java b/src/src/java.base/share/classes/java/time/zone/ZoneOffsetTransitionRule.java index 9c700d5ec70..68d34699a55 100644 --- a/src/src/java.base/share/classes/java/time/zone/ZoneOffsetTransitionRule.java +++ b/src/src/java.base/share/classes/java/time/zone/ZoneOffsetTransitionRule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -256,7 +256,7 @@ private void readObject(ObjectInputStream s) throws InvalidObjectException { * for the encoding of epoch seconds and offsets. *

    {@code
          *
    -     *      out.writeByte(3);                // identifies a ZoneOffsetTransition
    +     *      out.writeByte(3);                // identifies a ZoneOffsetTransitionRule
          *      final int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay());
          *      final int stdOffset = standardOffset.getTotalSeconds();
          *      final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
    diff --git a/src/src/java.base/share/classes/java/util/Calendar.java b/src/src/java.base/share/classes/java/util/Calendar.java
    index 3debbb62cd2..037318c5d92 100644
    --- a/src/src/java.base/share/classes/java/util/Calendar.java
    +++ b/src/src/java.base/share/classes/java/util/Calendar.java
    @@ -2232,7 +2232,7 @@ private Map getDisplayNamesImpl(int field, int style, Locale loc
             if (strings != null) {
                 Map names = new HashMap<>();
                 for (int i = 0; i < strings.length; i++) {
    -                if (strings[i].length() == 0) {
    +                if (strings[i].isEmpty()) {
                         continue;
                     }
                     names.put(strings[i], i);
    diff --git a/src/src/java.base/share/classes/java/util/Collections.java b/src/src/java.base/share/classes/java/util/Collections.java
    index b5d9a826da8..d8420108f2c 100644
    --- a/src/src/java.base/share/classes/java/util/Collections.java
    +++ b/src/src/java.base/share/classes/java/util/Collections.java
    @@ -461,7 +461,7 @@ public static void shuffle(List list, Random rnd) {
                 for (int i=size; i>1; i--)
                     swap(list, i-1, rnd.nextInt(i));
             } else {
    -            Object arr[] = list.toArray();
    +            Object[] arr = list.toArray();
     
                 // Shuffle array
                 for (int i=size; i>1; i--)
    @@ -5103,6 +5103,53 @@ public List subList(int fromIndex, int toIndex) {
                 return new CopiesList<>(toIndex - fromIndex, element);
             }
     
    +        @Override
    +        public int hashCode() {
    +            if (n == 0) return 1;
    +            // hashCode of n repeating elements is 31^n + elementHash * Sum(31^k, k = 0..n-1)
    +            // this implementation completes in O(log(n)) steps taking advantage of
    +            // 31^(2*n) = (31^n)^2 and Sum(31^k, k = 0..(2*n-1)) = Sum(31^k, k = 0..n-1) * (31^n + 1)
    +            int pow = 31;
    +            int sum = 1;
    +            for (int i = Integer.numberOfLeadingZeros(n) + 1; i < Integer.SIZE; i++) {
    +                sum *= pow + 1;
    +                pow *= pow;
    +                if ((n << i) < 0) {
    +                    pow *= 31;
    +                    sum = sum * 31 + 1;
    +                }
    +            }
    +            return pow + sum * (element == null ? 0 : element.hashCode());
    +        }
    +
    +        @Override
    +        public boolean equals(Object o) {
    +            if (o == this)
    +                return true;
    +            if (o instanceof CopiesList) {
    +                CopiesList other = (CopiesList) o;
    +                return n == other.n && (n == 0 || eq(element, other.element));
    +            }
    +            if (!(o instanceof List))
    +                return false;
    +
    +            int remaining = n;
    +            E e = element;
    +            Iterator itr = ((List) o).iterator();
    +            if (e == null) {
    +                while (itr.hasNext() && remaining-- > 0) {
    +                    if (itr.next() != null)
    +                        return false;
    +                }
    +            } else {
    +                while (itr.hasNext() && remaining-- > 0) {
    +                    if (!e.equals(itr.next()))
    +                        return false;
    +                }
    +            }
    +            return remaining == 0 && !itr.hasNext();
    +        }
    +
             // Override default methods in Collection
             @Override
             public Stream stream() {
    diff --git a/src/src/java.base/share/classes/java/util/Locale.java b/src/src/java.base/share/classes/java/util/Locale.java
    index f58b67b8ef8..f36066f38b2 100644
    --- a/src/src/java.base/share/classes/java/util/Locale.java
    +++ b/src/src/java.base/share/classes/java/util/Locale.java
    @@ -1396,11 +1396,11 @@ LocaleExtensions getLocaleExtensions() {
          */
         @Override
         public final String toString() {
    -        boolean l = (baseLocale.getLanguage().length() != 0);
    -        boolean s = (baseLocale.getScript().length() != 0);
    -        boolean r = (baseLocale.getRegion().length() != 0);
    -        boolean v = (baseLocale.getVariant().length() != 0);
    -        boolean e = (localeExtensions != null && localeExtensions.getID().length() != 0);
    +        boolean l = !baseLocale.getLanguage().isEmpty();
    +        boolean s = !baseLocale.getScript().isEmpty();
    +        boolean r = !baseLocale.getRegion().isEmpty();
    +        boolean v = !baseLocale.getVariant().isEmpty();
    +        boolean e = localeExtensions != null && !localeExtensions.getID().isEmpty();
     
             StringBuilder result = new StringBuilder(baseLocale.getLanguage());
             if (r || (l && (v || s || e))) {
    @@ -1504,18 +1504,18 @@ public String toLanguageTag() {
             StringBuilder buf = new StringBuilder();
     
             String subtag = tag.getLanguage();
    -        if (subtag.length() > 0) {
    +        if (!subtag.isEmpty()) {
                 buf.append(LanguageTag.canonicalizeLanguage(subtag));
             }
     
             subtag = tag.getScript();
    -        if (subtag.length() > 0) {
    +        if (!subtag.isEmpty()) {
                 buf.append(LanguageTag.SEP);
                 buf.append(LanguageTag.canonicalizeScript(subtag));
             }
     
             subtag = tag.getRegion();
    -        if (subtag.length() > 0) {
    +        if (!subtag.isEmpty()) {
                 buf.append(LanguageTag.SEP);
                 buf.append(LanguageTag.canonicalizeRegion(subtag));
             }
    @@ -1534,7 +1534,7 @@ public String toLanguageTag() {
             }
     
             subtag = tag.getPrivateuse();
    -        if (subtag.length() > 0) {
    +        if (!subtag.isEmpty()) {
                 if (buf.length() > 0) {
                     buf.append(LanguageTag.SEP);
                 }
    @@ -1684,7 +1684,7 @@ public static Locale forLanguageTag(String languageTag) {
             bldr.setLanguageTag(tag);
             BaseLocale base = bldr.getBaseLocale();
             LocaleExtensions exts = bldr.getLocaleExtensions();
    -        if (exts == null && base.getVariant().length() > 0) {
    +        if (exts == null && !base.getVariant().isEmpty()) {
                 exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(),
                                                   base.getRegion(), base.getVariant());
             }
    @@ -1917,7 +1917,7 @@ public final String getDisplayVariant() {
          * @exception NullPointerException if inLocale is null
          */
         public String getDisplayVariant(Locale inLocale) {
    -        if (baseLocale.getVariant().length() == 0)
    +        if (baseLocale.getVariant().isEmpty())
                 return "";
     
             LocaleResources lr = LocaleProviderAdapter
    @@ -1998,14 +1998,14 @@ public String getDisplayName(Locale inLocale) {
             // The display name consists of a main name, followed by qualifiers.
             // Typically, the format is "MainName (Qualifier, Qualifier)" but this
             // depends on what pattern is stored in the display locale.
    -        String   mainName       = null;
    -        String[] qualifierNames = null;
    +        String   mainName;
    +        String[] qualifierNames;
     
             // The main name is the language, or if there is no language, the script,
             // then if no script, the country. If there is no language/script/country
             // (an anomalous situation) then the display name is simply the variant's
             // display name.
    -        if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) {
    +        if (languageName.isEmpty() && scriptName.isEmpty() && countryName.isEmpty()) {
                 if (variantNames.length == 0) {
                     return "";
                 } else {
    @@ -2013,13 +2013,13 @@ public String getDisplayName(Locale inLocale) {
                 }
             }
             ArrayList names = new ArrayList<>(4);
    -        if (languageName.length() != 0) {
    +        if (!languageName.isEmpty()) {
                 names.add(languageName);
             }
    -        if (scriptName.length() != 0) {
    +        if (!scriptName.isEmpty()) {
                 names.add(scriptName);
             }
    -        if (countryName.length() != 0) {
    +        if (!countryName.isEmpty()) {
                 names.add(countryName);
             }
             if (variantNames.length != 0) {
    @@ -2305,7 +2305,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
             String variant = (String)fields.get("variant", "");
             String extStr = (String)fields.get("extensions", "");
             baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
    -        if (extStr.length() > 0) {
    +        if (!extStr.isEmpty()) {
                 try {
                     InternalLocaleBuilder bldr = new InternalLocaleBuilder();
                     bldr.setExtensions(extStr);
    @@ -2363,13 +2363,13 @@ private static LocaleExtensions getCompatibilityExtensions(String language,
             LocaleExtensions extensions = null;
             // Special cases for backward compatibility support
             if (LocaleUtils.caseIgnoreMatch(language, "ja")
    -                && script.length() == 0
    +                && script.isEmpty()
                     && LocaleUtils.caseIgnoreMatch(country, "jp")
                     && "JP".equals(variant)) {
                 // ja_JP_JP -> u-ca-japanese (calendar = japanese)
                 extensions = LocaleExtensions.CALENDAR_JAPANESE;
             } else if (LocaleUtils.caseIgnoreMatch(language, "th")
    -                && script.length() == 0
    +                && script.isEmpty()
                     && LocaleUtils.caseIgnoreMatch(country, "th")
                     && "TH".equals(variant)) {
                 // th_TH_TH -> u-nu-thai (numbersystem = thai)
    @@ -2802,7 +2802,7 @@ public Builder clearExtensions() {
             public Locale build() {
                 BaseLocale baseloc = localeBuilder.getBaseLocale();
                 LocaleExtensions extensions = localeBuilder.getLocaleExtensions();
    -            if (extensions == null && baseloc.getVariant().length() > 0) {
    +            if (extensions == null && !baseloc.getVariant().isEmpty()) {
                     extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(),
                             baseloc.getRegion(), baseloc.getVariant());
                 }
    diff --git a/src/src/java.base/share/classes/java/util/Properties.java b/src/src/java.base/share/classes/java/util/Properties.java
    index 397ba4450b6..84c9eb27bc9 100644
    --- a/src/src/java.base/share/classes/java/util/Properties.java
    +++ b/src/src/java.base/share/classes/java/util/Properties.java
    @@ -404,17 +404,15 @@ public synchronized void load(InputStream inStream) throws IOException {
             load0(new LineReader(inStream));
         }
     
    -    private void load0 (LineReader lr) throws IOException {
    -        char[] convtBuf = new char[1024];
    +    private void load0(LineReader lr) throws IOException {
    +        StringBuilder outBuffer = new StringBuilder();
             int limit;
             int keyLen;
             int valueStart;
    -        char c;
             boolean hasSep;
             boolean precedingBackslash;
     
             while ((limit = lr.readLine()) >= 0) {
    -            c = 0;
                 keyLen = 0;
                 valueStart = limit;
                 hasSep = false;
    @@ -422,7 +420,7 @@ private void load0 (LineReader lr) throws IOException {
                 //System.out.println("line=<" + new String(lineBuf, 0, limit) + ">");
                 precedingBackslash = false;
                 while (keyLen < limit) {
    -                c = lr.lineBuf[keyLen];
    +                char c = lr.lineBuf[keyLen];
                     //need check if escaped.
                     if ((c == '=' ||  c == ':') && !precedingBackslash) {
                         valueStart = keyLen + 1;
    @@ -440,7 +438,7 @@ private void load0 (LineReader lr) throws IOException {
                     keyLen++;
                 }
                 while (valueStart < limit) {
    -                c = lr.lineBuf[valueStart];
    +                char c = lr.lineBuf[valueStart];
                     if (c != ' ' && c != '\t' &&  c != '\f') {
                         if (!hasSep && (c == '=' ||  c == ':')) {
                             hasSep = true;
    @@ -450,8 +448,8 @@ private void load0 (LineReader lr) throws IOException {
                     }
                     valueStart++;
                 }
    -            String key = loadConvert(lr.lineBuf, 0, keyLen, convtBuf);
    -            String value = loadConvert(lr.lineBuf, valueStart, limit - valueStart, convtBuf);
    +            String key = loadConvert(lr.lineBuf, 0, keyLen, outBuffer);
    +            String value = loadConvert(lr.lineBuf, valueStart, limit - valueStart, outBuffer);
                 put(key, value);
             }
         }
    @@ -462,64 +460,56 @@ private void load0 (LineReader lr) throws IOException {
          * Method returns the char length of the "logical line" and stores
          * the line in "lineBuf".
          */
    -    class LineReader {
    -        public LineReader(InputStream inStream) {
    +    private static class LineReader {
    +        LineReader(InputStream inStream) {
                 this.inStream = inStream;
                 inByteBuf = new byte[8192];
             }
     
    -        public LineReader(Reader reader) {
    +        LineReader(Reader reader) {
                 this.reader = reader;
                 inCharBuf = new char[8192];
             }
     
    -        byte[] inByteBuf;
    -        char[] inCharBuf;
             char[] lineBuf = new char[1024];
    -        int inLimit = 0;
    -        int inOff = 0;
    -        InputStream inStream;
    -        Reader reader;
    +        private byte[] inByteBuf;
    +        private char[] inCharBuf;
    +        private int inLimit = 0;
    +        private int inOff = 0;
    +        private InputStream inStream;
    +        private Reader reader;
     
             int readLine() throws IOException {
    +            // use locals to optimize for interpreted performance
                 int len = 0;
    -            char c = 0;
    +            int off = inOff;
    +            int limit = inLimit;
     
                 boolean skipWhiteSpace = true;
    -            boolean isCommentLine = false;
    -            boolean isNewLine = true;
                 boolean appendedLineBegin = false;
                 boolean precedingBackslash = false;
    -            boolean skipLF = false;
    +            boolean fromStream = inStream != null;
    +            byte[] byteBuf = inByteBuf;
    +            char[] charBuf = inCharBuf;
    +            char[] lineBuf = this.lineBuf;
    +            char c;
     
                 while (true) {
    -                if (inOff >= inLimit) {
    -                    inLimit = (inStream==null)?reader.read(inCharBuf)
    -                                              :inStream.read(inByteBuf);
    -                    inOff = 0;
    -                    if (inLimit <= 0) {
    -                        if (len == 0 || isCommentLine) {
    +                if (off >= limit) {
    +                    inLimit = limit = fromStream ? inStream.read(byteBuf)
    +                                                 : reader.read(charBuf);
    +                    if (limit <= 0) {
    +                        if (len == 0) {
                                 return -1;
                             }
    -                        if (precedingBackslash) {
    -                            len--;
    -                        }
    -                        return len;
    -                    }
    -                }
    -                if (inStream != null) {
    -                    //The line below is equivalent to calling a
    -                    //ISO8859-1 decoder.
    -                    c = (char)(inByteBuf[inOff++] & 0xFF);
    -                } else {
    -                    c = inCharBuf[inOff++];
    -                }
    -                if (skipLF) {
    -                    skipLF = false;
    -                    if (c == '\n') {
    -                        continue;
    +                        return precedingBackslash ? len - 1 : len;
                         }
    +                    off = 0;
                     }
    +
    +                // (char)(byte & 0xFF) is equivalent to calling a ISO8859-1 decoder.
    +                c = (fromStream) ? (char)(byteBuf[off++] & 0xFF) : charBuf[off++];
    +
                     if (skipWhiteSpace) {
                         if (c == ' ' || c == '\t' || c == '\f') {
                             continue;
    @@ -529,81 +519,106 @@ int readLine() throws IOException {
                         }
                         skipWhiteSpace = false;
                         appendedLineBegin = false;
    +
                     }
    -                if (isNewLine) {
    -                    isNewLine = false;
    +                if (len == 0) { // Still on a new logical line
                         if (c == '#' || c == '!') {
    -                        // Comment, quickly consume the rest of the line,
    -                        // resume on line-break and backslash.
    -                        if (inStream != null) {
    -                            while (inOff < inLimit) {
    -                                byte b = inByteBuf[inOff++];
    -                                if (b == '\n' || b == '\r' || b == '\\') {
    -                                    c = (char)(b & 0xFF);
    -                                    break;
    +                        // Comment, quickly consume the rest of the line
    +
    +                        // When checking for new line characters a range check,
    +                        // starting with the higher bound ('\r') means one less
    +                        // branch in the common case.
    +                        commentLoop: while (true) {
    +                            if (fromStream) {
    +                                byte b;
    +                                while (off < limit) {
    +                                    b = byteBuf[off++];
    +                                    if (b <= '\r' && (b == '\r' || b == '\n'))
    +                                        break commentLoop;
                                     }
    -                            }
    -                        } else {
    -                            while (inOff < inLimit) {
    -                                c = inCharBuf[inOff++];
    -                                if (c == '\n' || c == '\r' || c == '\\') {
    -                                    break;
    +                                if (off == limit) {
    +                                    inLimit = limit = inStream.read(byteBuf);
    +                                    if (limit <= 0) { // EOF
    +                                        return -1;
    +                                    }
    +                                    off = 0;
    +                                }
    +                            } else {
    +                                while (off < limit) {
    +                                    c = charBuf[off++];
    +                                    if (c <= '\r' && (c == '\r' || c == '\n'))
    +                                        break commentLoop;
    +                                }
    +                                if (off == limit) {
    +                                    inLimit = limit = reader.read(charBuf);
    +                                    if (limit <= 0) { // EOF
    +                                        return -1;
    +                                    }
    +                                    off = 0;
                                     }
                                 }
                             }
    -                        isCommentLine = true;
    +                        skipWhiteSpace = true;
    +                        continue;
                         }
                     }
     
                     if (c != '\n' && c != '\r') {
                         lineBuf[len++] = c;
                         if (len == lineBuf.length) {
    -                        int newLength = lineBuf.length * 2;
    -                        if (newLength < 0) {
    -                            newLength = Integer.MAX_VALUE;
    +                        int maxLen = Integer.MAX_VALUE - 8; // VM allocation limit
    +                        int newLen = len * 2;
    +                        if (newLen < 0 || newLen > maxLen) { // check for under/overflow
    +                            newLen = maxLen;
                             }
    -                        char[] buf = new char[newLength];
    -                        System.arraycopy(lineBuf, 0, buf, 0, lineBuf.length);
    -                        lineBuf = buf;
    -                    }
    -                    //flip the preceding backslash flag
    -                    if (c == '\\') {
    -                        precedingBackslash = !precedingBackslash;
    -                    } else {
    -                        precedingBackslash = false;
    +                        if (newLen <= len) { // still not good? last-ditch attempt then
    +                           if (len != Integer.MAX_VALUE) {
    +                               newLen = len + 1;
    +                           } else {
    +                               throw new OutOfMemoryError("Required array length too large");
    +                           }
    +                        }
    +                        lineBuf = new char[newLen];
    +                        System.arraycopy(this.lineBuf, 0, lineBuf, 0, len);
    +                        this.lineBuf = lineBuf;
                         }
    -                }
    -                else {
    +                    // flip the preceding backslash flag
    +                    precedingBackslash = (c == '\\') ? !precedingBackslash : false;
    +                } else {
                         // reached EOL
    -                    if (isCommentLine || len == 0) {
    -                        isCommentLine = false;
    -                        isNewLine = true;
    +                    if (len == 0) {
                             skipWhiteSpace = true;
    -                        len = 0;
                             continue;
                         }
    -                    if (inOff >= inLimit) {
    -                        inLimit = (inStream==null)
    -                                  ?reader.read(inCharBuf)
    -                                  :inStream.read(inByteBuf);
    -                        inOff = 0;
    -                        if (inLimit <= 0) {
    -                            if (precedingBackslash) {
    -                                len--;
    -                            }
    -                            return len;
    +                    if (off >= limit) {
    +                        inLimit = limit = fromStream ? inStream.read(byteBuf)
    +                                                     : reader.read(charBuf);
    +                        off = 0;
    +                        if (limit <= 0) { // EOF
    +                            return precedingBackslash ? len - 1 : len;
                             }
                         }
                         if (precedingBackslash) {
    +                        // backslash at EOL is not part of the line
                             len -= 1;
    -                        //skip the leading whitespace characters in following line
    +                        // skip leading whitespace characters in the following line
                             skipWhiteSpace = true;
                             appendedLineBegin = true;
                             precedingBackslash = false;
    +                        // take care not to include any subsequent \n
                             if (c == '\r') {
    -                            skipLF = true;
    +                            if (fromStream) {
    +                                if (byteBuf[off] == '\n') {
    +                                    off++;
    +                                }
    +                            } else {
    +                                if (charBuf[off] == '\n') {
    +                                    off++;
    +                                }
    +                            }
                             }
                         } else {
    +                        inOff = off;
                             return len;
                         }
                     }
    @@ -615,18 +630,24 @@ int readLine() throws IOException {
          * Converts encoded \uxxxx to unicode chars
          * and changes special saved chars to their original forms
          */
    -    private String loadConvert (char[] in, int off, int len, char[] convtBuf) {
    -        if (convtBuf.length < len) {
    -            int newLen = len * 2;
    -            if (newLen < 0) {
    -                newLen = Integer.MAX_VALUE;
    -            }
    -            convtBuf = new char[newLen];
    -        }
    +    private String loadConvert(char[] in, int off, int len, StringBuilder out) {
             char aChar;
    -        char[] out = convtBuf;
    -        int outLen = 0;
             int end = off + len;
    +        int start = off;
    +        while (off < end) {
    +            aChar = in[off++];
    +            if (aChar == '\\') {
    +                break;
    +            }
    +        }
    +        if (off == end) { // No backslash
    +            return new String(in, start, len);
    +        }
    +
    +        // backslash found at off - 1, reset the shared buffer, rewind offset
    +        out.setLength(0);
    +        off--;
    +        out.append(in, start, off - start);
     
             while (off < end) {
                 aChar = in[off++];
    @@ -654,20 +675,20 @@ private String loadConvert (char[] in, int off, int len, char[] convtBuf) {
                                   throw new IllegalArgumentException(
                                                "Malformed \\uxxxx encoding.");
                             }
    -                     }
    -                    out[outLen++] = (char)value;
    +                    }
    +                    out.append((char)value);
                     } else {
                         if (aChar == 't') aChar = '\t';
                         else if (aChar == 'r') aChar = '\r';
                         else if (aChar == 'n') aChar = '\n';
                         else if (aChar == 'f') aChar = '\f';
    -                    out[outLen++] = aChar;
    +                    out.append(aChar);
                     }
                 } else {
    -                out[outLen++] = aChar;
    +                out.append(aChar);
                 }
             }
    -        return new String (out, 0, outLen);
    +        return out.toString();
         }
     
         /*
    diff --git a/src/src/java.base/share/classes/java/util/ResourceBundle.java b/src/src/java.base/share/classes/java/util/ResourceBundle.java
    index 55647cd7c61..4141fbc9119 100644
    --- a/src/src/java.base/share/classes/java/util/ResourceBundle.java
    +++ b/src/src/java.base/share/classes/java/util/ResourceBundle.java
    @@ -771,8 +771,8 @@ private Throwable getCause() {
             @Override
             public String toString() {
                 String l = locale.toString();
    -            if (l.length() == 0) {
    -                if (locale.getVariant().length() != 0) {
    +            if (l.isEmpty()) {
    +                if (!locale.getVariant().isEmpty()) {
                         l = "__" + locale.getVariant();
                     } else {
                         l = "\"\"";
    @@ -2903,7 +2903,7 @@ protected List createObject(BaseLocale base) {
                         List bokmalList = new LinkedList<>();
                         for (Locale l : tmpList) {
                             bokmalList.add(l);
    -                        if (l.getLanguage().length() == 0) {
    +                        if (l.getLanguage().isEmpty()) {
                                 break;
                             }
                             bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
    @@ -2921,7 +2921,7 @@ protected List createObject(BaseLocale base) {
                     }
                     // Special handling for Chinese
                     else if (language.equals("zh")) {
    -                    if (script.length() == 0 && region.length() > 0) {
    +                    if (script.isEmpty() && !region.isEmpty()) {
                             // Supply script for users who want to use zh_Hans/zh_Hant
                             // as bundle names (recommended for Java7+)
                             switch (region) {
    @@ -2944,7 +2944,7 @@ else if (language.equals("zh")) {
                 private static List getDefaultList(String language, String script, String region, String variant) {
                     List variants = null;
     
    -                if (variant.length() > 0) {
    +                if (!variant.isEmpty()) {
                         variants = new LinkedList<>();
                         int idx = variant.length();
                         while (idx != -1) {
    @@ -2960,14 +2960,14 @@ private static List getDefaultList(String language, String script, Strin
                             list.add(Locale.getInstance(language, script, region, v, null));
                         }
                     }
    -                if (region.length() > 0) {
    +                if (!region.isEmpty()) {
                         list.add(Locale.getInstance(language, script, region, "", null));
                     }
    -                if (script.length() > 0) {
    +                if (!script.isEmpty()) {
                         list.add(Locale.getInstance(language, script, "", "", null));
                         // Special handling for Chinese
                         if (language.equals("zh")) {
    -                        if (region.length() == 0) {
    +                        if (region.isEmpty()) {
                                 // Supply region(country) for users who still package Chinese
                                 // bundles using old convension.
                                 switch (script) {
    @@ -2988,11 +2988,11 @@ private static List getDefaultList(String language, String script, Strin
                                 list.add(Locale.getInstance(language, "", region, v, null));
                             }
                         }
    -                    if (region.length() > 0) {
    +                    if (!region.isEmpty()) {
                             list.add(Locale.getInstance(language, "", region, "", null));
                         }
                     }
    -                if (language.length() > 0) {
    +                if (!language.isEmpty()) {
                         list.add(Locale.getInstance(language, "", "", "", null));
                     }
                     // Add root locale at the end
    diff --git a/src/src/java.base/share/classes/java/util/Scanner.java b/src/src/java.base/share/classes/java/util/Scanner.java
    index bde2ae328eb..b36d9d1ec4e 100644
    --- a/src/src/java.base/share/classes/java/util/Scanner.java
    +++ b/src/src/java.base/share/classes/java/util/Scanner.java
    @@ -1297,16 +1297,16 @@ public Scanner useLocale(Locale locale) {
             nanString = "\\Q" + dfs.getNaN() + "\\E";
             infinityString = "\\Q" + dfs.getInfinity() + "\\E";
             positivePrefix = df.getPositivePrefix();
    -        if (positivePrefix.length() > 0)
    +        if (!positivePrefix.isEmpty())
                 positivePrefix = "\\Q" + positivePrefix + "\\E";
             negativePrefix = df.getNegativePrefix();
    -        if (negativePrefix.length() > 0)
    +        if (!negativePrefix.isEmpty())
                 negativePrefix = "\\Q" + negativePrefix + "\\E";
             positiveSuffix = df.getPositiveSuffix();
    -        if (positiveSuffix.length() > 0)
    +        if (!positiveSuffix.isEmpty())
                 positiveSuffix = "\\Q" + positiveSuffix + "\\E";
             negativeSuffix = df.getNegativeSuffix();
    -        if (negativeSuffix.length() > 0)
    +        if (!negativeSuffix.isEmpty())
                 negativeSuffix = "\\Q" + negativeSuffix + "\\E";
     
             // Force rebuilding and recompilation of locale dependent
    diff --git a/src/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/src/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
    index 1cd73476699..92888f7a59e 100644
    --- a/src/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
    +++ b/src/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
    @@ -1712,9 +1712,8 @@ public boolean equals(Object o) {
             Map m = (Map) o;
             try {
                 Comparator cmp = comparator;
    -            @SuppressWarnings("unchecked")
    -            Iterator> it =
    -                (Iterator>)m.entrySet().iterator();
    +            // See JDK-8223553 for Iterator type wildcard rationale
    +            Iterator> it = m.entrySet().iterator();
                 if (m instanceof SortedMap &&
                     ((SortedMap)m).comparator() == cmp) {
                     Node b, n;
    diff --git a/src/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/src/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
    index a4414b54df8..900a4ad4e1e 100644
    --- a/src/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
    +++ b/src/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
    @@ -413,8 +413,9 @@ public E set(int index, E element) {
                 if (oldValue != element) {
                     es = es.clone();
                     es[index] = element;
    -                setArray(es);
                 }
    +            // Ensure volatile write semantics even when oldvalue == element
    +            setArray(es);
                 return oldValue;
             }
         }
    diff --git a/src/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/src/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
    index 2c5ea168c64..233c99700d8 100644
    --- a/src/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
    +++ b/src/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java
    @@ -922,13 +922,13 @@ private boolean addWorker(Runnable firstTask, boolean core) {
     
                         if (isRunning(c) ||
                             (runStateLessThan(c, STOP) && firstTask == null)) {
    -                        if (t.isAlive()) // precheck that t is startable
    +                        if (t.getState() != Thread.State.NEW)
                                 throw new IllegalThreadStateException();
                             workers.add(w);
    +                        workerAdded = true;
                             int s = workers.size();
                             if (s > largestPoolSize)
                                 largestPoolSize = s;
    -                        workerAdded = true;
                         }
                     } finally {
                         mainLock.unlock();
    diff --git a/src/src/java.base/share/classes/java/util/regex/Pattern.java b/src/src/java.base/share/classes/java/util/regex/Pattern.java
    index cd7cd39f55d..37232f1d1cc 100644
    --- a/src/src/java.base/share/classes/java/util/regex/Pattern.java
    +++ b/src/src/java.base/share/classes/java/util/regex/Pattern.java
    @@ -1390,7 +1390,7 @@ private void readObject(java.io.ObjectInputStream s)
             localTCNCount = 0;
     
             // if length > 0, the Pattern is lazily compiled
    -        if (pattern.length() == 0) {
    +        if (pattern.isEmpty()) {
                 root = new Start(lastAccept);
                 matchRoot = lastAccept;
                 compiled = true;
    @@ -1423,8 +1423,12 @@ private Pattern(String p, int f) {
             localCount = 0;
             localTCNCount = 0;
     
    -        if (pattern.length() > 0) {
    -            compile();
    +        if (!pattern.isEmpty()) {
    +            try {
    +                compile();
    +            } catch (StackOverflowError soe) {
    +                throw error("Stack overflow during pattern compilation");
    +            }
             } else {
                 root = new Start(lastAccept);
                 matchRoot = lastAccept;
    @@ -1963,6 +1967,10 @@ private int parsePastLine() {
             int ch = temp[cursor++];
             while (ch != 0 && !isLineSeparator(ch))
                 ch = temp[cursor++];
    +        if (ch == 0 && cursor > patternLength) {
    +            cursor = patternLength;
    +            ch = temp[cursor++];
    +        }
             return ch;
         }
     
    @@ -1973,6 +1981,10 @@ private int peekPastLine() {
             int ch = temp[++cursor];
             while (ch != 0 && !isLineSeparator(ch))
                 ch = temp[++cursor];
    +        if (ch == 0 && cursor > patternLength) {
    +            cursor = patternLength;
    +            ch = temp[cursor];
    +        }
             return ch;
         }
     
    @@ -3407,9 +3419,10 @@ private int u() {
         private int N() {
             if (read() == '{') {
                 int i = cursor;
    -            while (cursor < patternLength && read() != '}') {}
    -            if (cursor > patternLength)
    -                throw error("Unclosed character name escape sequence");
    +            while (read() != '}') {
    +                if (cursor >= patternLength)
    +                    throw error("Unclosed character name escape sequence");
    +            }
                 String name = new String(temp, i, cursor - i - 1);
                 try {
                     return Character.codePointOf(name);
    diff --git a/src/src/java.base/share/classes/java/util/zip/ZipEntry.java b/src/src/java.base/share/classes/java/util/zip/ZipEntry.java
    index 9a58ad19893..11846701ac1 100644
    --- a/src/src/java.base/share/classes/java/util/zip/ZipEntry.java
    +++ b/src/src/java.base/share/classes/java/util/zip/ZipEntry.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1995, 2019, 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
    @@ -522,7 +522,7 @@ public int getMethod() {
          * @see #getExtra()
          */
         public void setExtra(byte[] extra) {
    -        setExtra0(extra, false);
    +        setExtra0(extra, false, true);
         }
     
         /**
    @@ -532,8 +532,11 @@ public void setExtra(byte[] extra) {
          *        the extra field data bytes
          * @param doZIP64
          *        if true, set size and csize from ZIP64 fields if present
    +     * @param isLOC
    +     *        true if setting the extra field for a LOC, false if for
    +     *        a CEN
          */
    -    void setExtra0(byte[] extra, boolean doZIP64) {
    +    void setExtra0(byte[] extra, boolean doZIP64, boolean isLOC) {
             if (extra != null) {
                 if (extra.length > 0xFFFF) {
                     throw new IllegalArgumentException("invalid extra field length");
    @@ -550,15 +553,29 @@ void setExtra0(byte[] extra, boolean doZIP64) {
                     switch (tag) {
                     case EXTID_ZIP64:
                         if (doZIP64) {
    -                        // LOC extra zip64 entry MUST include BOTH original
    -                        // and compressed file size fields.
    -                        // If invalid zip64 extra fields, simply skip. Even
    -                        // it's rare, it's possible the entry size happens to
    -                        // be the magic value and it "accidently" has some
    -                        // bytes in extra match the id.
    -                        if (sz >= 16) {
    -                            size = get64(extra, off);
    -                            csize = get64(extra, off + 8);
    +                        if (isLOC) {
    +                            // LOC extra zip64 entry MUST include BOTH original
    +                            // and compressed file size fields.
    +                            // If invalid zip64 extra fields, simply skip. Even
    +                            // it's rare, it's possible the entry size happens to
    +                            // be the magic value and it "accidently" has some
    +                            // bytes in extra match the id.
    +                            if (sz >= 16) {
    +                                size = get64(extra, off);
    +                                csize = get64(extra, off + 8);
    +                            }
    +                        } else {
    +                            // CEN extra zip64
    +                            if (size == ZIP64_MAGICVAL) {
    +                                if (off + 8 > len)  // invalid zip64 extra
    +                                    break;          // fields, just skip
    +                                size = get64(extra, off);
    +                            }
    +                            if (csize == ZIP64_MAGICVAL) {
    +                                if (off + 16 > len)  // invalid zip64 extra
    +                                    break;           // fields, just skip
    +                                csize = get64(extra, off + 8);
    +                            }
                             }
                         }
                         break;
    diff --git a/src/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/src/java.base/share/classes/java/util/zip/ZipFile.java
    index 601f8375e3f..94a586ab2a7 100644
    --- a/src/src/java.base/share/classes/java/util/zip/ZipFile.java
    +++ b/src/src/java.base/share/classes/java/util/zip/ZipFile.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1995, 2019, 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
    @@ -681,7 +681,7 @@ private ZipEntry getZipEntry(String name, byte[] bname, int pos,
             e.method = CENHOW(cen, pos);
             if (elen != 0) {
                 int start = pos + CENHDR + nlen;
    -            e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true);
    +            e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true, false);
             }
             if (clen != 0) {
                 int start = pos + CENHDR + nlen + elen;
    diff --git a/src/src/java.base/share/classes/java/util/zip/ZipInputStream.java b/src/src/java.base/share/classes/java/util/zip/ZipInputStream.java
    index 1dcdcfae4e3..9f518a37bf1 100644
    --- a/src/src/java.base/share/classes/java/util/zip/ZipInputStream.java
    +++ b/src/src/java.base/share/classes/java/util/zip/ZipInputStream.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1996, 2019, 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
    @@ -321,7 +321,7 @@ private ZipEntry readLOC() throws IOException {
                 byte[] extra = new byte[len];
                 readFully(extra, 0, len);
                 e.setExtra0(extra,
    -                        e.csize == ZIP64_MAGICVAL || e.size == ZIP64_MAGICVAL);
    +                        e.csize == ZIP64_MAGICVAL || e.size == ZIP64_MAGICVAL, true);
             }
             return e;
         }
    diff --git a/src/src/java.base/share/classes/javax/crypto/Cipher.java b/src/src/java.base/share/classes/javax/crypto/Cipher.java
    index d9b5f102432..fded2e1c12a 100644
    --- a/src/src/java.base/share/classes/javax/crypto/Cipher.java
    +++ b/src/src/java.base/share/classes/javax/crypto/Cipher.java
    @@ -341,7 +341,7 @@ private static String[] tokenizeTransformation(String transformation)
                 throw new NoSuchAlgorithmException("Invalid transformation " +
                                                "format:" + transformation);
             }
    -        if ((parts[0] == null) || (parts[0].length() == 0)) {
    +        if ((parts[0] == null) || (parts[0].isEmpty())) {
                 throw new NoSuchAlgorithmException("Invalid transformation:" +
                                        "algorithm not specified-"
                                        + transformation);
    @@ -445,10 +445,10 @@ private static List getTransforms(String transformation)
             String alg = parts[0];
             String mode = parts[1];
             String pad = parts[2];
    -        if ((mode != null) && (mode.length() == 0)) {
    +        if ((mode != null) && (mode.isEmpty())) {
                 mode = null;
             }
    -        if ((pad != null) && (pad.length() == 0)) {
    +        if ((pad != null) && (pad.isEmpty())) {
                 pad = null;
             }
     
    @@ -614,7 +614,7 @@ public static final Cipher getInstance(String transformation,
             if ((transformation == null) || transformation.equals("")) {
                 throw new NoSuchAlgorithmException("Null or empty transformation");
             }
    -        if ((provider == null) || (provider.length() == 0)) {
    +        if ((provider == null) || (provider.isEmpty())) {
                 throw new IllegalArgumentException("Missing provider");
             }
             Provider p = Security.getProvider(provider);
    diff --git a/src/src/java.base/share/classes/javax/crypto/SealedObject.java b/src/src/java.base/share/classes/javax/crypto/SealedObject.java
    index 9c31f375325..435394a6761 100644
    --- a/src/src/java.base/share/classes/javax/crypto/SealedObject.java
    +++ b/src/src/java.base/share/classes/javax/crypto/SealedObject.java
    @@ -337,7 +337,7 @@ public final Object getObject(Key key, String provider)
             if (key == null) {
                 throw new NullPointerException("key is null");
             }
    -        if (provider == null || provider.length() == 0) {
    +        if (provider == null || provider.isEmpty()) {
                 throw new IllegalArgumentException("missing provider");
             }
     
    diff --git a/src/src/java.base/share/classes/javax/net/ssl/SSLSessionContext.java b/src/src/java.base/share/classes/javax/net/ssl/SSLSessionContext.java
    index b6f6fb6df40..6361f6bc56d 100644
    --- a/src/src/java.base/share/classes/javax/net/ssl/SSLSessionContext.java
    +++ b/src/src/java.base/share/classes/javax/net/ssl/SSLSessionContext.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2018, 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
    @@ -87,10 +87,17 @@ public interface SSLSessionContext {
          * A check for sessions exceeding the timeout is made immediately whenever
          * the timeout limit is changed for this SSLSessionContext.
          *
    +     * @apiNote Note that the JDK Implementation uses default values for both
    +     *          the session cache size and timeout.  See
    +     *          {@code getSessionCacheSize} and {@code getSessionTimeout} for
    +     *          more information.  Applications should consider their
    +     *          performance requirements and override the defaults if necessary.
    +     *
          * @param seconds the new session timeout limit in seconds; zero means
    -     *          there is no limit.
    +     *        there is no limit.
    +     *
    +     * @throws IllegalArgumentException if the timeout specified is {@code < 0}.
          *
    -     * @exception IllegalArgumentException if the timeout specified is {@code < 0}.
          * @see #getSessionTimeout
          */
         public void setSessionTimeout(int seconds)
    @@ -109,33 +116,50 @@ public void setSessionTimeout(int seconds)
          * whenever the timeout limit is changed for this
          * SSLSessionContext.
          *
    +     * @implNote The JDK implementation returns the session timeout as set by
    +     *           the {@code setSessionTimeout} method, or if not set, a default
    +     *           value of 86400 seconds (24 hours).
    +     *
          * @return the session timeout limit in seconds; zero means there is no
    -     * limit.
    +     *         limit.
    +     *
          * @see #setSessionTimeout
          */
         public int getSessionTimeout();
     
         /**
    -     * Sets the size of the cache used for storing
    -     * SSLSession objects grouped under this
    -     * SSLSessionContext.
    +     * Sets the size of the cache used for storing SSLSession
    +     * objects grouped under this SSLSessionContext.
    +     *
    +     * @apiNote Note that the JDK Implementation uses default values for both
    +     *          the session cache size and timeout.  See
    +     *          {@code getSessionCacheSize} and {@code getSessionTimeout} for
    +     *          more information.  Applications should consider their
    +     *          performance requirements and override the defaults if necessary.
          *
          * @param size the new session cache size limit; zero means there is no
    -     * limit.
    -     * @exception IllegalArgumentException if the specified size is {@code < 0}.
    +     *        limit.
    +     *
    +     * @throws IllegalArgumentException if the specified size is {@code < 0}.
    +     *
          * @see #getSessionCacheSize
          */
         public void setSessionCacheSize(int size)
                      throws IllegalArgumentException;
     
         /**
    -     * Returns the size of the cache used for storing
    -     * SSLSession objects grouped under this
    -     * SSLSessionContext.
    +     * Returns the size of the cache used for storing SSLSession
    +     * objects grouped under this SSLSessionContext.
    +     *
    +     * @implNote The JDK implementation returns the cache size as set by
    +     *           the {@code setSessionCacheSize} method, or if not set, the
    +     *           value of the {@systemProperty javax.net.ssl.sessionCacheSize}
    +     *           system property.  If neither is set, it returns a default
    +     *           value of 20480.
          *
          * @return size of the session cache; zero means there is no size limit.
    +     *
          * @see #setSessionCacheSize
          */
         public int getSessionCacheSize();
    -
     }
    diff --git a/src/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java b/src/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java
    index 8029b7d6b9a..39a9918d465 100644
    --- a/src/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java
    +++ b/src/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java
    @@ -133,7 +133,7 @@ public String run() {
                     String s = java.security.Security.getProperty(name);
                     if (s != null) {
                         s = s.trim();
    -                    if (s.length() == 0) {
    +                    if (s.isEmpty()) {
                             s = null;
                         }
                     }
    diff --git a/src/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java b/src/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java
    index fdd1d017986..f183a4eb2c0 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java
    @@ -312,7 +312,7 @@ public PermissionCollection newPermissionCollection() {
     
         private void init(String name) {
     
    -        if (name == null || name.trim().length() == 0) {
    +        if (name == null || name.trim().isEmpty()) {
                 throw new IllegalArgumentException("invalid empty name");
             }
     
    diff --git a/src/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java b/src/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java
    index 564a7984551..b11f8943a15 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java
    @@ -98,13 +98,13 @@ public class ChoiceCallback implements Callback, java.io.Serializable {
         public ChoiceCallback(String prompt, String[] choices,
                     int defaultChoice, boolean multipleSelectionsAllowed) {
     
    -        if (prompt == null || prompt.length() == 0 ||
    +        if (prompt == null || prompt.isEmpty() ||
                 choices == null || choices.length == 0 ||
                 defaultChoice < 0 || defaultChoice >= choices.length)
                 throw new IllegalArgumentException();
     
             for (int i = 0; i < choices.length; i++) {
    -            if (choices[i] == null || choices[i].length() == 0)
    +            if (choices[i] == null || choices[i].isEmpty())
                     throw new IllegalArgumentException();
             }
     
    diff --git a/src/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java b/src/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java
    index 99bb5f8c17f..78113195ebf 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java
    @@ -248,7 +248,7 @@ public ConfirmationCallback(int messageType,
                 throw new IllegalArgumentException();
     
             for (int i = 0; i < options.length; i++) {
    -            if (options[i] == null || options[i].length() == 0)
    +            if (options[i] == null || options[i].isEmpty())
                     throw new IllegalArgumentException();
             }
     
    @@ -294,7 +294,7 @@ public ConfirmationCallback(int messageType,
         public ConfirmationCallback(String prompt, int messageType,
                     int optionType, int defaultOption) {
     
    -        if (prompt == null || prompt.length() == 0 ||
    +        if (prompt == null || prompt.isEmpty() ||
                 messageType < INFORMATION || messageType > ERROR ||
                 optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
                 throw new IllegalArgumentException();
    @@ -357,14 +357,14 @@ public ConfirmationCallback(String prompt, int messageType,
         public ConfirmationCallback(String prompt, int messageType,
                     String[] options, int defaultOption) {
     
    -        if (prompt == null || prompt.length() == 0 ||
    +        if (prompt == null || prompt.isEmpty() ||
                 messageType < INFORMATION || messageType > ERROR ||
                 options == null || options.length == 0 ||
                 defaultOption < 0 || defaultOption >= options.length)
                 throw new IllegalArgumentException();
     
             for (int i = 0; i < options.length; i++) {
    -            if (options[i] == null || options[i].length() == 0)
    +            if (options[i] == null || options[i].isEmpty())
                     throw new IllegalArgumentException();
             }
     
    diff --git a/src/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java b/src/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java
    index 5c289df2c43..bda3b59382b 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java
    @@ -62,7 +62,7 @@ public class NameCallback implements Callback, java.io.Serializable {
          *                  or if {@code prompt} has a length of 0.
          */
         public NameCallback(String prompt) {
    -        if (prompt == null || prompt.length() == 0)
    +        if (prompt == null || prompt.isEmpty())
                 throw new IllegalArgumentException();
             this.prompt = prompt;
         }
    @@ -82,8 +82,8 @@ public NameCallback(String prompt) {
          *                  or if {@code defaultName} has a length of 0.
          */
         public NameCallback(String prompt, String defaultName) {
    -        if (prompt == null || prompt.length() == 0 ||
    -            defaultName == null || defaultName.length() == 0)
    +        if (prompt == null || prompt.isEmpty() ||
    +            defaultName == null || defaultName.isEmpty())
                 throw new IllegalArgumentException();
     
             this.prompt = prompt;
    diff --git a/src/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java b/src/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java
    index 63e52fea112..0611d7f0f99 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java
    @@ -67,7 +67,7 @@ public class PasswordCallback implements Callback, java.io.Serializable {
          *                  if {@code prompt} has a length of 0.
          */
         public PasswordCallback(String prompt, boolean echoOn) {
    -        if (prompt == null || prompt.length() == 0)
    +        if (prompt == null || prompt.isEmpty())
                 throw new IllegalArgumentException();
     
             this.prompt = prompt;
    diff --git a/src/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java b/src/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java
    index 0fea6a3c7d6..ccaf11b5470 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java
    @@ -63,7 +63,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
          *                  or if {@code prompt} has a length of 0.
          */
         public TextInputCallback(String prompt) {
    -        if (prompt == null || prompt.length() == 0)
    +        if (prompt == null || prompt.isEmpty())
                 throw new IllegalArgumentException();
             this.prompt = prompt;
         }
    @@ -83,8 +83,8 @@ public TextInputCallback(String prompt) {
          *                  or if {@code defaultText} has a length of 0.
          */
         public TextInputCallback(String prompt, String defaultText) {
    -        if (prompt == null || prompt.length() == 0 ||
    -            defaultText == null || defaultText.length() == 0)
    +        if (prompt == null || prompt.isEmpty() ||
    +            defaultText == null || defaultText.isEmpty())
                 throw new IllegalArgumentException();
     
             this.prompt = prompt;
    diff --git a/src/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java b/src/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java
    index ba4551e3880..57f9278af17 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java
    @@ -74,7 +74,7 @@ public class TextOutputCallback implements Callback, java.io.Serializable {
         public TextOutputCallback(int messageType, String message) {
             if ((messageType != INFORMATION &&
                     messageType != WARNING && messageType != ERROR) ||
    -            message == null || message.length() == 0)
    +            message == null || message.isEmpty())
                 throw new IllegalArgumentException();
     
             this.messageType = messageType;
    diff --git a/src/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java b/src/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java
    index f567b3be871..2084e4e3f8c 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java
    @@ -75,7 +75,7 @@ public AppConfigurationEntry(String loginModuleName,
                                     LoginModuleControlFlag controlFlag,
                                     Map options)
         {
    -        if (loginModuleName == null || loginModuleName.length() == 0 ||
    +        if (loginModuleName == null || loginModuleName.isEmpty() ||
                 (controlFlag != LoginModuleControlFlag.REQUIRED &&
                     controlFlag != LoginModuleControlFlag.REQUISITE &&
                     controlFlag != LoginModuleControlFlag.SUFFICIENT &&
    diff --git a/src/src/java.base/share/classes/javax/security/auth/login/Configuration.java b/src/src/java.base/share/classes/javax/security/auth/login/Configuration.java
    index e08bf3eb3d7..067b94cc398 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/login/Configuration.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/login/Configuration.java
    @@ -418,7 +418,7 @@ public static Configuration getInstance(String type,
                     throws NoSuchProviderException, NoSuchAlgorithmException {
     
             Objects.requireNonNull(type, "null type name");
    -        if (provider == null || provider.length() == 0) {
    +        if (provider == null || provider.isEmpty()) {
                 throw new IllegalArgumentException("missing provider");
             }
     
    diff --git a/src/src/java.base/share/classes/javax/security/auth/login/LoginContext.java b/src/src/java.base/share/classes/javax/security/auth/login/LoginContext.java
    index deaf3aac426..820cb159318 100644
    --- a/src/src/java.base/share/classes/javax/security/auth/login/LoginContext.java
    +++ b/src/src/java.base/share/classes/javax/security/auth/login/LoginContext.java
    @@ -300,7 +300,7 @@ private void loadDefaultCallbackHandler() throws LoginException {
                     public CallbackHandler run() throws Exception {
                         String defaultHandler = java.security.Security.getProperty
                             (DEFAULT_HANDLER);
    -                    if (defaultHandler == null || defaultHandler.length() == 0)
    +                    if (defaultHandler == null || defaultHandler.isEmpty())
                             return null;
                         Class c = Class.forName(
                                 defaultHandler, true,
    diff --git a/src/src/java.base/share/classes/javax/security/cert/X509Certificate.java b/src/src/java.base/share/classes/javax/security/cert/X509Certificate.java
    index 232134037b6..f4fecae131a 100644
    --- a/src/src/java.base/share/classes/javax/security/cert/X509Certificate.java
    +++ b/src/src/java.base/share/classes/javax/security/cert/X509Certificate.java
    @@ -210,7 +210,7 @@ private static final X509Certificate getInst(Object value)
              * under JDK1.1.
              */
             String className = X509Provider;
    -        if (className == null || className.length() == 0) {
    +        if (className == null || className.isEmpty()) {
                 // shouldn't happen, but assume corrupted properties file
                 // provide access to sun implementation
                 className = "com.sun.security.cert.internal.x509.X509V1CertImpl";
    diff --git a/src/src/java.base/share/classes/jdk/internal/event/Event.java b/src/src/java.base/share/classes/jdk/internal/event/Event.java
    new file mode 100644
    index 00000000000..0ca2840f47a
    --- /dev/null
    +++ b/src/src/java.base/share/classes/jdk/internal/event/Event.java
    @@ -0,0 +1,94 @@
    +/*
    + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
    + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    + *
    + * This code is free software; you can redistribute it and/or modify it
    + * under the terms of the GNU General Public License version 2 only, as
    + * published by the Free Software Foundation.  Oracle designates this
    + * particular file as subject to the "Classpath" exception as provided
    + * by Oracle in the LICENSE file that accompanied this code.
    + *
    + * This code is distributed in the hope that it will be useful, but WITHOUT
    + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    + * version 2 for more details (a copy is included in the LICENSE file that
    + * accompanied this code).
    + *
    + * You should have received a copy of the GNU General Public License version
    + * 2 along with this work; if not, write to the Free Software Foundation,
    + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    + *
    + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    + * or visit www.oracle.com if you need additional information or have any
    + * questions.
    + */
    +
    +package jdk.internal.event;
    +
    +/**
    + * Base class for events, to be subclassed in order to define events and their
    + * fields.
    + */
    +public abstract class Event {
    +    /**
    +     * Sole constructor, for invocation by subclass constructors, typically
    +     * implicit.
    +     */
    +    protected Event() {
    +    }
    +
    +    /**
    +     * Starts the timing of this event.
    +     */
    +    public void begin() {
    +    }
    +
    +    /**
    +     * Ends the timing of this event.
    +     *
    +     * The {@code end} method must be invoked after the {@code begin} method.
    +     */
    +    public void end() {
    +    }
    +
    +    /**
    +     * Writes the field values, time stamp, and event duration.
    +     * 

    + * If the event starts with an invocation of the {@code begin} method, but does + * not end with an explicit invocation of the {@code end} method, then the event + * ends when the {@code commit} method is invoked. + */ + public void commit() { + } + + /** + * Returns {@code true} if the event is enabled, {@code false} otherwise + * + * @return {@code true} if event is enabled, {@code false} otherwise + */ + public boolean isEnabled() { + return false; + } + + /** + * Returns {@code true} if the event is enabled and if the duration is within + * the threshold for the event, {@code false} otherwise. + * + * @return {@code true} if the event can be written, {@code false} otherwise + */ + public boolean shouldCommit() { + return false; + } + + /** + * Sets a field value. + * + * @param index the index of the field to set + * @param value value to set, can be {@code null} + * @throws UnsupportedOperationException if functionality is not supported + * @throws IndexOutOfBoundsException if {@code index} is less than {@code 0} or + * greater than or equal to the number of fields specified for the event + */ + public void set(int index, Object value) { + } +} diff --git a/src/src/java.base/share/classes/jdk/internal/event/EventHelper.java b/src/src/java.base/share/classes/jdk/internal/event/EventHelper.java new file mode 100644 index 00000000000..2832945ee81 --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/event/EventHelper.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.event; + +import java.time.Duration; +import java.time.Instant; +import java.util.Date; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +/** + * A helper class to have events logged to a JDK Event Logger. + */ + +public final class EventHelper { + + private static final System.Logger.Level LOG_LEVEL = System.Logger.Level.DEBUG; + + // helper class used for logging security related events for now + private static final String SECURITY_LOGGER_NAME = "jdk.event.security"; + private static final System.Logger SECURITY_LOGGER = + System.getLogger(SECURITY_LOGGER_NAME); + private static final boolean LOGGING_SECURITY = + SECURITY_LOGGER.isLoggable(LOG_LEVEL); + + public static void logTLSHandshakeEvent(Instant start, + String peerHost, + int peerPort, + String cipherSuite, + String protocolVersion, + long peerCertId) { + String prepend = getDurationString(start); + SECURITY_LOGGER.log(LOG_LEVEL, prepend + + " TLSHandshake: {0}:{1,number,#}, {2}, {3}, {4,number,#}", + peerHost, peerPort, protocolVersion, cipherSuite, peerCertId); + } + + public static void logSecurityPropertyEvent(String key, + String value) { + + if (isLoggingSecurity()) { + SECURITY_LOGGER.log(LOG_LEVEL, + "SecurityPropertyModification: key:{0}, value:{1}", key, value); + } + } + + public static void logX509ValidationEvent(int anchorCertId, + int[] certIds) { + String codes = IntStream.of(certIds) + .mapToObj(Integer::toString) + .collect(Collectors.joining(", ")); + SECURITY_LOGGER.log(LOG_LEVEL, + "ValidationChain: {0,number,#}, {1}", anchorCertId, codes); + } + + public static void logX509CertificateEvent(String algId, + String serialNum, + String subject, + String issuer, + String keyType, + int length, + long certId, + long beginDate, + long endDate) { + SECURITY_LOGGER.log(LOG_LEVEL, "X509Certificate: Alg:{0}, Serial:{1}" + + ", Subject:{2}, Issuer:{3}, Key type:{4}, Length:{5,number,#}" + + ", Cert Id:{6,number,#}, Valid from:{7}, Valid until:{8}", + algId, serialNum, subject, issuer, keyType, length, + certId, new Date(beginDate), new Date(endDate)); + } + + /** + * Method to calculate a duration timestamp for events which measure + * the start and end times of certain operations. + * @param start Instant indicating when event started recording + * @return A string representing duraction from start time to + * time of this method call. Empty string is start is null. + */ + private static String getDurationString(Instant start) { + if (start != null) { + Duration duration = Duration.between(start, Instant.now()); + long micros = duration.toNanos() / 1_000; + if (micros < 1_000_000) { + return "duration = " + (micros / 1_000.0) + " ms:"; + } else { + return "duration = " + ((micros / 1_000) / 1_000.0) + " s:"; + } + } else { + return ""; + } + } + + /** + * Helper to determine if security events are being logged + * at a preconfigured logging level. The configuration value + * is read once at class initialization. + * + * @return boolean indicating whether an event should be logged + */ + public static boolean isLoggingSecurity() { + return LOGGING_SECURITY; + } +} diff --git a/src/src/java.base/share/classes/jdk/internal/event/SecurityPropertyModificationEvent.java b/src/src/java.base/share/classes/jdk/internal/event/SecurityPropertyModificationEvent.java new file mode 100644 index 00000000000..294ff902cf7 --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/event/SecurityPropertyModificationEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.event; + +/** + * Event details relating to the modification of a Security property. + */ + +public final class SecurityPropertyModificationEvent extends Event { + public String key; + public String value; +} diff --git a/src/src/java.base/share/classes/jdk/internal/event/TLSHandshakeEvent.java b/src/src/java.base/share/classes/jdk/internal/event/TLSHandshakeEvent.java new file mode 100644 index 00000000000..f763a0e4d29 --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/event/TLSHandshakeEvent.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.event; + +/** + * Event recording details of successful TLS handshakes. + */ + +public final class TLSHandshakeEvent extends Event { + public String peerHost; + public int peerPort; + public String protocolVersion; + public String cipherSuite; + public long certificateId; +} diff --git a/src/src/java.base/share/classes/jdk/internal/event/X509CertificateEvent.java b/src/src/java.base/share/classes/jdk/internal/event/X509CertificateEvent.java new file mode 100644 index 00000000000..b145abceb69 --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/event/X509CertificateEvent.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.event; + + +/** + * Event recording details of X.509 Certificate. + */ + +public final class X509CertificateEvent extends Event { + public String algorithm; + public String serialNumber; + public String subject; + public String issuer; + public String keyType; + public int keyLength; + public long certificateId; + public long validFrom; + public long validUntil; +} diff --git a/src/src/java.base/share/classes/jdk/internal/event/X509ValidationEvent.java b/src/src/java.base/share/classes/jdk/internal/event/X509ValidationEvent.java new file mode 100644 index 00000000000..854b1a05c2a --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/event/X509ValidationEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.event; + +/** + * Event recording details of X.509 Certificate serial numbers + * used in X509 cert path validation. + */ + +public final class X509ValidationEvent extends Event { + public long certificateId; + public int certificatePosition; + public long validationCounter; +} diff --git a/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java b/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java index a9a1df29c33..9b65995f61f 100644 --- a/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java +++ b/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java @@ -60,7 +60,7 @@ public static String reconstruct(String formatted, List arguments) { switch (c) { case 'L': { String pkg = arguments.get(arg_index); - if(pkg.length() > 0) { + if(!pkg.isEmpty()) { out.append(pkg).append("/"); } arg_index+=1; diff --git a/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java b/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java index 1284a3f129f..807f8e2adf2 100644 --- a/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java +++ b/src/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java @@ -168,7 +168,7 @@ private static String reconstruct(StringsProvider reader, DataInputStream cr) int index = indices.get(argIndex); argIndex += 1; String pkg = reader.getString(index); - if (pkg.length() > 0) { + if (!pkg.isEmpty()) { pkg = pkg + "/"; byte[] encoded = getEncoded(pkg); buffer = safeAdd(buffer, encoded); diff --git a/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java b/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java index d544e4c0deb..b28addc9921 100644 --- a/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java +++ b/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java @@ -131,7 +131,7 @@ public JrtPath getPath(String first, String... more) { StringBuilder sb = new StringBuilder(); sb.append(first); for (String path : more) { - if (path.length() > 0) { + if (!path.isEmpty()) { if (sb.length() > 0) { sb.append('/'); } diff --git a/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java b/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java index 81ef3b9af2a..39a22f640fe 100644 --- a/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java +++ b/src/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java @@ -88,7 +88,7 @@ public final JrtPath getRoot() { @Override public final JrtPath getFileName() { - if (path.length() == 0) + if (path.isEmpty()) return this; if (path.length() == 1 && path.charAt(0) == '/') return null; @@ -210,7 +210,7 @@ public final JrtPath relativize(Path other) { if (o.equals(this)) { return new JrtPath(jrtfs, "", true); } - if (path.length() == 0) { + if (path.isEmpty()) { return o; } if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) { @@ -262,16 +262,16 @@ public JrtFileSystem getFileSystem() { @Override public final boolean isAbsolute() { - return path.length() > 0 && path.charAt(0) == '/'; + return !path.isEmpty() && path.charAt(0) == '/'; } @Override public final JrtPath resolve(Path other) { final JrtPath o = checkPath(other); - if (this.path.length() == 0 || o.isAbsolute()) { + if (this.path.isEmpty() || o.isAbsolute()) { return o; } - if (o.path.length() == 0) { + if (o.path.isEmpty()) { return this; } StringBuilder sb = new StringBuilder(path.length() + o.path.length() + 1); @@ -301,7 +301,7 @@ public final boolean startsWith(Path other) { } int off = op.length(); if (off == 0) { - return tp.length() == 0; + return tp.isEmpty(); } // check match is on name boundary return tp.length() == off || tp.charAt(off) == '/' || diff --git a/src/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java b/src/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java index 5421e14975d..159bf840637 100644 --- a/src/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java +++ b/src/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java @@ -25,8 +25,6 @@ package jdk.internal.loader; -import java.io.File; -import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.lang.module.ModuleDescriptor; @@ -40,7 +38,6 @@ import java.security.AccessController; import java.security.CodeSigner; import java.security.CodeSource; -import java.security.Permission; import java.security.PermissionCollection; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; @@ -64,6 +61,7 @@ import jdk.internal.misc.VM; import jdk.internal.module.ModulePatcher.PatchedModuleReader; import jdk.internal.module.Resources; +import sun.security.util.LazyCodeSourcePermissionCollection; /** @@ -945,39 +943,9 @@ private boolean isSealed(String pn, Manifest man) { */ @Override protected PermissionCollection getPermissions(CodeSource cs) { - PermissionCollection perms = super.getPermissions(cs); - - // add the permission to access the resource - URL url = cs.getLocation(); - if (url == null) - return perms; - - // avoid opening connection when URL is to resource in run-time image - if (url.getProtocol().equals("jrt")) { - perms.add(new RuntimePermission("accessSystemModules")); - return perms; - } - - // open connection to determine the permission needed - try { - Permission p = url.openConnection().getPermission(); - if (p != null) { - // for directories then need recursive access - if (p instanceof FilePermission) { - String path = p.getName(); - if (path.endsWith(File.separator)) { - path += "-"; - p = new FilePermission(path, "read"); - } - } - perms.add(p); - } - } catch (IOException ioe) { } - - return perms; + return new LazyCodeSourcePermissionCollection(super.getPermissions(cs), cs); } - // -- miscellaneous supporting methods /** diff --git a/src/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/src/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java index 8d1a9e5ba37..f7c71e63265 100644 --- a/src/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java +++ b/src/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java @@ -59,7 +59,7 @@ private ClassLoaders() { } // -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute String append = VM.getSavedProperty("jdk.boot.class.path.append"); BOOT_LOADER = - new BootClassLoader((append != null && append.length() > 0) + new BootClassLoader((append != null && !append.isEmpty()) ? new URLClassPath(append, true) : null); PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER); @@ -70,7 +70,7 @@ private ClassLoaders() { } // contrary, we drop this historic interpretation of the empty // string and instead treat it as unspecified. String cp = System.getProperty("java.class.path"); - if (cp == null || cp.length() == 0) { + if (cp == null || cp.isEmpty()) { String initialModuleName = System.getProperty("jdk.module.main"); cp = (initialModuleName == null) ? "" : null; } diff --git a/src/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java b/src/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java index 4bda10c668c..b8280e94d32 100644 --- a/src/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java +++ b/src/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -190,7 +190,7 @@ public URLClassPath(URL[] urls, AccessControlContext acc) { String element = (next == -1) ? cp.substring(off) : cp.substring(off, next); - if (element.length() > 0 || !skipEmptyElements) { + if (!element.isEmpty() || !skipEmptyElements) { URL url = toFileURL(element); if (url != null) path.add(url); } @@ -1092,10 +1092,15 @@ private static URL[] parseClassPath(URL base, String value) int i = 0; while (st.hasMoreTokens()) { String path = st.nextToken(); - URL url = DISABLE_CP_URL_CHECK ? new URL(base, path) : safeResolve(base, path); + URL url = DISABLE_CP_URL_CHECK ? new URL(base, path) : tryResolve(base, path); if (url != null) { urls[i] = url; i++; + } else { + if (DEBUG_CP_URL_CHECK) { + System.err.println("Class-Path entry: \"" + path + + "\" ignored in JAR file " + base); + } } } if (i == 0) { @@ -1107,36 +1112,74 @@ private static URL[] parseClassPath(URL base, String value) return urls; } - /* - * Return a URL for the given path resolved against the base URL, or - * null if the resulting URL is invalid. + static URL tryResolve(URL base, String input) throws MalformedURLException { + if ("file".equalsIgnoreCase(base.getProtocol())) { + return tryResolveFile(base, input); + } else { + return tryResolveNonFile(base, input); + } + } + + /** + * Attempt to return a file URL by resolving input against a base file + * URL. The input is an absolute or relative file URL that encodes a + * file path. + * + * @apiNote Nonsensical input such as a Windows file path with a drive + * letter cannot be disambiguated from an absolute URL so will be rejected + * (by returning null) by this method. + * + * @return the resolved URL or null if the input is an absolute URL with + * a scheme other than file (ignoring case) + * @throws MalformedURLException */ - static URL safeResolve(URL base, String path) { - String child = path.replace(File.separatorChar, '/'); - try { - if (!URI.create(child).isAbsolute()) { - URL url = new URL(base, child); - if (base.getProtocol().equalsIgnoreCase("file")) { - return url; - } else { - String bp = base.getPath(); - String urlp = url.getPath(); - int pos = bp.lastIndexOf('/'); - if (pos == -1) { - pos = bp.length() - 1; - } - if (urlp.regionMatches(0, bp, 0, pos + 1) - && urlp.indexOf("..", pos) == -1) { - return url; - } - } + static URL tryResolveFile(URL base, String input) throws MalformedURLException { + int index = input.indexOf(':'); + boolean isFile; + if (index >= 0) { + String scheme = input.substring(0, index); + isFile = "file".equalsIgnoreCase(scheme); + } else { + isFile = true; + } + return (isFile) ? new URL(base, input) : null; + } + + /** + * Attempt to return a URL by resolving input against a base URL. Returns + * null if the resolved URL is not contained by the base URL. + * + * @return the resolved URL or null + * @throws MalformedURLException + */ + static URL tryResolveNonFile(URL base, String input) throws MalformedURLException { + String child = input.replace(File.separatorChar, '/'); + if (isRelative(child)) { + URL url = new URL(base, child); + String bp = base.getPath(); + String urlp = url.getPath(); + int pos = bp.lastIndexOf('/'); + if (pos == -1) { + pos = bp.length() - 1; + } + if (urlp.regionMatches(0, bp, 0, pos + 1) + && urlp.indexOf("..", pos) == -1) { + return url; } - } catch (MalformedURLException | IllegalArgumentException e) {} - if (DEBUG_CP_URL_CHECK) { - System.err.println("Class-Path entry: \"" + path + "\" ignored in JAR file " + base); } return null; } + + /** + * Returns true if the given input is a relative URI. + */ + static boolean isRelative(String child) { + try { + return !URI.create(child).isAbsolute(); + } catch (IllegalArgumentException e) { + return false; + } + } } /* diff --git a/src/src/java.base/share/classes/jdk/internal/misc/JavaSecuritySignatureAccess.java b/src/src/java.base/share/classes/jdk/internal/misc/JavaSecuritySignatureAccess.java new file mode 100644 index 00000000000..4f3b5db2329 --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/misc/JavaSecuritySignatureAccess.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.misc; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; + +public interface JavaSecuritySignatureAccess { + + void initVerify(Signature s, PublicKey publicKey, AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException; + + void initVerify(Signature s, java.security.cert.Certificate certificate, + AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException; + + void initSign(Signature s, PrivateKey privateKey, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException; +} diff --git a/src/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/src/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java index e44e9e7007d..b669f57cece 100644 --- a/src/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java +++ b/src/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java @@ -36,6 +36,7 @@ import java.io.ObjectInputStream; import java.io.RandomAccessFile; import java.security.ProtectionDomain; +import java.security.Signature; /** A repository of "shared secrets", which are a mechanism for calling implementation-private methods in another package without @@ -72,6 +73,7 @@ public class SharedSecrets { private static JavaObjectInputStreamAccess javaObjectInputStreamAccess; private static JavaObjectInputFilterAccess javaObjectInputFilterAccess; private static JavaIORandomAccessFileAccess javaIORandomAccessFileAccess; + private static JavaSecuritySignatureAccess javaSecuritySignatureAccess; private static JavaxCryptoSealedObjectAccess javaxCryptoSealedObjectAccess; public static JavaUtilJarAccess javaUtilJarAccess() { @@ -326,6 +328,17 @@ public static JavaIORandomAccessFileAccess getJavaIORandomAccessFileAccess() { return javaIORandomAccessFileAccess; } + public static void setJavaSecuritySignatureAccess(JavaSecuritySignatureAccess jssa) { + javaSecuritySignatureAccess = jssa; + } + + public static JavaSecuritySignatureAccess getJavaSecuritySignatureAccess() { + if (javaSecuritySignatureAccess == null) { + unsafe.ensureClassInitialized(Signature.class); + } + return javaSecuritySignatureAccess; + } + public static void setJavaxCryptoSealedObjectAccess(JavaxCryptoSealedObjectAccess jcsoa) { javaxCryptoSealedObjectAccess = jcsoa; } diff --git a/src/src/java.base/share/classes/jdk/internal/misc/VM.java b/src/src/java.base/share/classes/jdk/internal/misc/VM.java index 7ab63073540..53e4a200097 100644 --- a/src/src/java.base/share/classes/jdk/internal/misc/VM.java +++ b/src/src/java.base/share/classes/jdk/internal/misc/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2018, 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 @@ -413,4 +413,15 @@ public static boolean isSetUID() { initialize(); } private static native void initialize(); + + /** + * Initialize archived static fields in the given Class using archived + * values from CDS dump time. Also initialize the classes of objects in + * the archived graph referenced by those fields. + * + * Those static fields remain as uninitialized if there is no mapped CDS + * java heap data or there is any error during initialization of the + * object class in the archived graph. + */ + public static native void initializeFromArchive(Class c); } diff --git a/src/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java b/src/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java new file mode 100644 index 00000000000..35b4d09718b --- /dev/null +++ b/src/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.module; + +import java.lang.module.ModuleFinder; +import java.util.Objects; +import jdk.internal.misc.VM; + +/** + * Used by ModuleBootstrap to obtain the archived system modules and finder. + */ +final class ArchivedModuleGraph { + private static String archivedMainModule; + private static SystemModules archivedSystemModules; + private static ModuleFinder archivedModuleFinder; + + private final SystemModules systemModules; + private final ModuleFinder finder; + + private ArchivedModuleGraph(SystemModules modules, ModuleFinder finder) { + this.systemModules = modules; + this.finder = finder; + } + + SystemModules systemModules() { + return systemModules; + } + + ModuleFinder finder() { + return finder; + } + + // A factory method that ModuleBootstrap can use to obtain the + // ArchivedModuleGraph. + static ArchivedModuleGraph get(String mainModule) { + if (Objects.equals(mainModule, archivedMainModule) + && archivedSystemModules != null + && archivedModuleFinder != null) { + return new ArchivedModuleGraph(archivedSystemModules, + archivedModuleFinder); + } else { + return null; + } + } + + // Used at CDS dump time + static void archive(String mainModule, SystemModules systemModules, + ModuleFinder finder) { + if (archivedMainModule != null) + throw new UnsupportedOperationException(); + archivedMainModule = mainModule; + archivedSystemModules = systemModules; + archivedModuleFinder = finder; + } + + static { + VM.initializeFromArchive(ArchivedModuleGraph.class); + } +} diff --git a/src/src/java.base/share/classes/jdk/internal/module/Checks.java b/src/src/java.base/share/classes/jdk/internal/module/Checks.java index 4d772df129a..3b7dd137225 100644 --- a/src/src/java.base/share/classes/jdk/internal/module/Checks.java +++ b/src/src/java.base/share/classes/jdk/internal/module/Checks.java @@ -62,22 +62,6 @@ public static String requireModuleName(String name) { return name; } - /** - * Returns {@code true} if the given name is a legal module name. - */ - public static boolean isModuleName(String name) { - int next; - int off = 0; - while ((next = name.indexOf('.', off)) != -1) { - String id = name.substring(off, next); - if (!isJavaIdentifier(id)) - return false; - off = next+1; - } - String last = name.substring(off); - return isJavaIdentifier(last); - } - /** * Checks a name to ensure that it's a legal package name. * @@ -181,20 +165,20 @@ private static String requireTypeName(String what, String name) { } /** - * Returns true if the given char sequence is a legal Java identifier, + * Returns true if the given string is a legal Java identifier, * otherwise false. */ - private static boolean isJavaIdentifier(CharSequence cs) { - if (cs.length() == 0 || RESERVED.contains(cs)) + private static boolean isJavaIdentifier(String str) { + if (str.isEmpty() || RESERVED.contains(str)) return false; - int first = Character.codePointAt(cs, 0); + int first = Character.codePointAt(str, 0); if (!Character.isJavaIdentifierStart(first)) return false; int i = Character.charCount(first); - while (i < cs.length()) { - int cp = Character.codePointAt(cs, i); + while (i < str.length()) { + int cp = Character.codePointAt(str, i); if (!Character.isJavaIdentifierPart(cp)) return false; i += Character.charCount(cp); diff --git a/src/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/src/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java index 5ea0d73a1b3..694ec1ea7c8 100644 --- a/src/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java +++ b/src/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java @@ -54,6 +54,7 @@ import jdk.internal.misc.JavaLangAccess; import jdk.internal.misc.JavaLangModuleAccess; import jdk.internal.misc.SharedSecrets; +import jdk.internal.misc.VM; import jdk.internal.perf.PerfCounter; /** @@ -172,23 +173,45 @@ public static ModuleLayer boot() throws Exception { boolean haveModulePath = (appModulePath != null || upgradeModulePath != null); boolean needResolution = true; - if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) { - systemModules = SystemModuleFinders.systemModules(mainModule); - if (systemModules != null && !isPatched && (traceOutput == null)) { - needResolution = false; - } - } - if (systemModules == null) { - // all system modules are observable - systemModules = SystemModuleFinders.allSystemModules(); - } - if (systemModules != null) { - // images build - systemModuleFinder = SystemModuleFinders.of(systemModules); + // If the java heap was archived at CDS dump time and the environment + // at dump time matches the current environment then use the archived + // system modules and finder. + ArchivedModuleGraph archivedModuleGraph = ArchivedModuleGraph.get(mainModule); + if (archivedModuleGraph != null + && !haveModulePath + && addModules.isEmpty() + && limitModules.isEmpty() + && !isPatched) { + systemModules = archivedModuleGraph.systemModules(); + systemModuleFinder = archivedModuleGraph.finder(); + needResolution = (traceOutput != null); } else { - // exploded build or testing - systemModules = new ExplodedSystemModules(); - systemModuleFinder = SystemModuleFinders.ofSystem(); + boolean canArchive = false; + if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) { + systemModules = SystemModuleFinders.systemModules(mainModule); + if (systemModules != null && !isPatched) { + needResolution = (traceOutput != null); + canArchive = true; + } + } + if (systemModules == null) { + // all system modules are observable + systemModules = SystemModuleFinders.allSystemModules(); + } + if (systemModules != null) { + // images build + systemModuleFinder = SystemModuleFinders.of(systemModules); + } else { + // exploded build or testing + systemModules = new ExplodedSystemModules(); + systemModuleFinder = SystemModuleFinders.ofSystem(); + } + + // Module graph can be archived at CDS dump time. Only allow the + // unnamed module case for now. + if (canArchive && (mainModule == null)) { + ArchivedModuleGraph.archive(mainModule, systemModules, systemModuleFinder); + } } Counters.add("jdk.module.boot.1.systemModulesTime", t1); @@ -550,7 +573,8 @@ private static Set addModules() { Set modules = new HashSet<>(); while (value != null) { for (String s : value.split(",")) { - if (s.length() > 0) modules.add(s); + if (!s.isEmpty()) + modules.add(s); } index++; value = getAndRemoveProperty(prefix + index); @@ -842,7 +866,7 @@ private static Map> decode(String prefix, List values = map.computeIfAbsent(key, k -> new ArrayList<>()); int ntargets = 0; for (String s : rhs.split(regex)) { - if (s.length() > 0) { + if (!s.isEmpty()) { values.add(s); ntargets++; } diff --git a/src/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java b/src/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java index 613e31fc069..8b50e12dec6 100644 --- a/src/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java +++ b/src/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java @@ -553,7 +553,7 @@ public int getContentLength() throws IOException { public Stream list() throws IOException { return Files.walk(dir, Integer.MAX_VALUE) .map(f -> Resources.toResourceName(dir, f)) - .filter(s -> s.length() > 0); + .filter(s -> !s.isEmpty()); } } diff --git a/src/src/java.base/share/classes/jdk/internal/module/ModulePath.java b/src/src/java.base/share/classes/jdk/internal/module/ModulePath.java index c2360546a2e..2e5918627b5 100644 --- a/src/src/java.base/share/classes/jdk/internal/module/ModulePath.java +++ b/src/src/java.base/share/classes/jdk/internal/module/ModulePath.java @@ -547,7 +547,7 @@ private ModuleDescriptor deriveModuleDescriptor(JarFile jf) = new BufferedReader(new InputStreamReader(in, "UTF-8")); String cn; while ((cn = nextLine(reader)) != null) { - if (cn.length() > 0) { + if (!cn.isEmpty()) { String pn = packageName(cn); if (!packages.contains(pn)) { String msg = "Provider class " + cn + " not in module"; @@ -600,7 +600,7 @@ private static String cleanModuleName(String mn) { mn = Patterns.REPEATING_DOTS.matcher(mn).replaceAll("."); // drop leading dots - if (mn.length() > 0 && mn.charAt(0) == '.') + if (!mn.isEmpty() && mn.charAt(0) == '.') mn = Patterns.LEADING_DOTS.matcher(mn).replaceAll(""); // drop trailing dots diff --git a/src/src/java.base/share/classes/jdk/internal/module/Resources.java b/src/src/java.base/share/classes/jdk/internal/module/Resources.java index d224d1aba84..924f262d776 100644 --- a/src/src/java.base/share/classes/jdk/internal/module/Resources.java +++ b/src/src/java.base/share/classes/jdk/internal/module/Resources.java @@ -78,7 +78,7 @@ public static String toResourceName(Path dir, Path file) { String s = dir.relativize(file) .toString() .replace(File.separatorChar, '/'); - if (s.length() > 0 && Files.isDirectory(file)) + if (!s.isEmpty() && Files.isDirectory(file)) s += "/"; return s; } diff --git a/src/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java b/src/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java index 3930ae34604..9ed3b54c01c 100644 --- a/src/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java +++ b/src/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java @@ -83,7 +83,7 @@ public final class SystemModuleFinders { if (value == null) { USE_FAST_PATH = true; } else { - USE_FAST_PATH = (value.length() > 0) && !Boolean.parseBoolean(value); + USE_FAST_PATH = !value.isEmpty() && !Boolean.parseBoolean(value); } } diff --git a/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java b/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java index 31fe2bc6826..267fc16e5dc 100644 --- a/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java +++ b/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java @@ -161,7 +161,7 @@ public int getStepArgument(int index) { * @return the corresponding TypePath object, or null if the path is empty. */ public static TypePath fromString(final String typePath) { - if (typePath == null || typePath.length() == 0) { + if (typePath == null || typePath.isEmpty()) { return null; } int n = typePath.length(); diff --git a/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java b/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java index d4e50a51f6a..90475607e4e 100644 --- a/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java +++ b/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java @@ -1307,7 +1307,7 @@ static void checkIdentifier(final String name, final int start, */ static void checkMethodIdentifier(int version, final String name, final String msg) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Invalid " + msg + " (must not be null or empty)"); } @@ -1347,7 +1347,7 @@ static void checkMethodIdentifier(int version, final String name, * a message to be used in case of error. */ static void checkInternalName(final String name, final String msg) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Invalid " + msg + " (must not be null or empty)"); } diff --git a/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java b/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java index cdfcc68a9c8..9f89e60d7b8 100644 --- a/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java +++ b/src/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java @@ -358,7 +358,7 @@ public void visitEnd() { } private void checkClassName(final String name, final String msg) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Invalid " + msg + " (must not be null or empty)"); } @@ -371,7 +371,7 @@ private void checkClassName(final String name, final String msg) { } private void checkIdentifier(final String name, final String msg) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Invalid " + msg + " (must not be null or empty)"); } diff --git a/src/src/java.base/share/classes/jdk/internal/org/xml/sax/DTDHandler.java b/src/src/java.base/share/classes/jdk/internal/org/xml/sax/DTDHandler.java index 6e004ef5e54..3c2a5e939ae 100644 --- a/src/src/java.base/share/classes/jdk/internal/org/xml/sax/DTDHandler.java +++ b/src/src/java.base/share/classes/jdk/internal/org/xml/sax/DTDHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,6 @@ */ public interface DTDHandler { - /** * Receive notification of a notation declaration event. * @@ -136,6 +135,39 @@ public abstract void unparsedEntityDecl (String name, String notationName) throws SAXException; + // from SAX2 extension DeclHandler + /** + * Receive notification of the start of DTD declarations. + * + * The start/endDTD events appear within the start/endDocument events + * from ContentHandler. + * + * @param name The document type name. + * @param publicId The declared public identifier for the + * external DTD subset, or null if none was declared. + * @param systemId The declared system identifier for the + * external DTD subset, or null if none was declared. + * (Note that this is not resolved against the document + * base URI.) + * @throws SAXException the event receiver may throw an exception during processing + */ + default public void startDTD (String name, String publicId, String systemId) + throws SAXException + { + // no op + } + + // Custom API for the Properties + + /** + * Receive notification of the start of DTD internal subset. + * + * @throws SAXException the event receiver may throw an exception during processing + */ + default public void startInternalSub () throws SAXException + { + // no op + } } // end of DTDHandler.java diff --git a/src/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java b/src/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java index d75db5374cb..1c6fd0046a5 100644 --- a/src/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java +++ b/src/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java @@ -151,10 +151,10 @@ protected String getSetMessage(String attemptedType, String attemptedValue) { if (isFinal) err += " final"; err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to "; - if (attemptedValue.length() > 0) { + if (!attemptedValue.isEmpty()) { err += "(" + attemptedType + ")" + attemptedValue; } else { - if (attemptedType.length() > 0) + if (!attemptedType.isEmpty()) err += attemptedType; else err += "null value"; diff --git a/src/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java b/src/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java index f0d14a886a5..d41b09f5fce 100644 --- a/src/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java +++ b/src/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java @@ -291,7 +291,7 @@ public void read(InputStream is) throws IOException { while((line = br.readLine()) != null && !line.endsWith(".jar")); for(;line != null; line = br.readLine()) { - if (line.length() == 0) + if (line.isEmpty()) continue; if (line.endsWith(".jar")) { diff --git a/src/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java b/src/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java index b72deaccbee..3df193734d4 100644 --- a/src/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java +++ b/src/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -54,11 +54,11 @@ public class PropertiesDefaultHandler extends DefaultHandler { private static final String ATTR_KEY = "key"; // The required DTD URI for exported properties private static final String PROPS_DTD_DECL = - ""; + ""; private static final String PROPS_DTD_URI = - "http://java.sun.com/dtd/properties.dtd"; + "http://java.sun.com/dtd/properties.dtd"; private static final String PROPS_DTD = - "" + "" + "" + "" + " 0) { + if (comment != null && !comment.isEmpty()) { writer.writeStartElement(ELEMENT_COMMENT); writer.writeCharacters(comment); writer.writeEndElement(); @@ -136,15 +136,15 @@ public void store(Properties props, OutputStream os, String comment, Charset cha //////////////////////////////////////////////////////////////////// // Validate while parsing //////////////////////////////////////////////////////////////////// - static final String ALLOWED_ELEMENTS = "properties, comment, entry"; + static final String ALLOWED_ELEMENTS = "comment, entry"; static final String ALLOWED_COMMENT = "comment"; //////////////////////////////////////////////////////////////////// // Handler methods //////////////////////////////////////////////////////////////////// - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); + boolean sawRoot = false; // whether a valid root element exists boolean sawComment = false; boolean validEntry = false; - int rootElem = 0; String key; String rootElm; @@ -152,32 +152,38 @@ public void store(Properties props, OutputStream os, String comment, Charset cha public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if (rootElem < 2) { - rootElem++; - } - - if (rootElm == null) { - fatalError(new SAXParseException("An XML properties document must contain" + if (sawRoot) { + if (!ALLOWED_ELEMENTS.contains(qName)) { + fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null)); + } + } else { + // check whether the root has been declared in the DTD + if (rootElm == null) { + fatalError(new SAXParseException("An XML properties document must contain" + " the DOCTYPE declaration as defined by java.util.Properties.", null)); - } + } - if (rootElem == 1 && !rootElm.equals(qName)) { - fatalError(new SAXParseException("Document root element \"" + qName + // check whether the element name matches the declaration + if (!rootElm.equals(qName)) { + fatalError(new SAXParseException("Document root element \"" + qName + "\", must match DOCTYPE root \"" + rootElm + "\"", null)); + } + + // this is a valid root element + sawRoot = true; } - if (!ALLOWED_ELEMENTS.contains(qName)) { - fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null)); - } + if (qName.equals(ELEMENT_ENTRY)) { validEntry = true; key = attributes.getValue(ATTR_KEY); if (key == null) { - fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null)); + fatalError(new SAXParseException("Attribute \"key\" is required and " + + "must be specified for element type \"entry\"", null)); } } else if (qName.equals(ALLOWED_COMMENT)) { if (sawComment) { fatalError(new SAXParseException("Only one comment element may be allowed. " - + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null)); + + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null)); } sawComment = true; } @@ -192,8 +198,9 @@ public void characters(char[] ch, int start, int length) throws SAXException { @Override public void endElement(String uri, String localName, String qName) throws SAXException { - if (!ALLOWED_ELEMENTS.contains(qName)) { - fatalError(new SAXParseException("Element: " + qName + " is invalid, must match \"(comment?,entry*)\".", null)); + if (!ALLOWED_ELEMENTS.contains(qName) && !ELEMENT_ROOT.equals(qName)) { + fatalError(new SAXParseException("Element: " + qName + + " is invalid, must match \"(comment?,entry*)\".", null)); } if (validEntry) { @@ -203,20 +210,13 @@ public void endElement(String uri, String localName, String qName) throws SAXExc } } - @Override - public void notationDecl(String name, String publicId, String systemId) throws SAXException { - rootElm = name; - } - @Override public InputSource resolveEntity(String pubid, String sysid) - throws SAXException, IOException { + throws SAXException, IOException { { if (sysid.equals(PROPS_DTD_URI)) { - InputSource is; - is = new InputSource(new StringReader(PROPS_DTD)); - is.setSystemId(PROPS_DTD_URI); - return is; + // The properties DTD is known to the handler, no need to parse it + return null; } throw new SAXException("Invalid system identifier: " + sysid); } @@ -236,4 +236,24 @@ public void fatalError(SAXParseException x) throws SAXException { public void warning(SAXParseException x) throws SAXException { throw x; } + + // SAX2 extension from DTDHandler + + @Override + public void startDTD (String name, String publicId, String systemId) throws SAXException + { + if (!ELEMENT_ROOT.equals(name) || !PROPS_DTD_URI.equals(systemId)) { + fatalError(new SAXParseException("An XML properties document must contain" + + " the DOCTYPE declaration as defined by java.util.Properties.", null)); + } + rootElm = name; + } + + @Override + public void startInternalSub () throws SAXException + { + fatalError(new SAXParseException("Internal DTD subset is not allowed. " + + "The Properties XML document must have the following DOCTYPE declaration: \n" + + PROPS_DTD_DECL, null)); + } } diff --git a/src/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java b/src/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java index 4d31aafe720..b50b1293fb7 100644 --- a/src/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java +++ b/src/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -650,6 +650,8 @@ private void dtd() throws Exception { * @exception IOException */ private void dtdsub() throws Exception { + startInternalSub(); // reports the event before parsing the subset + char ch; for (short st = 0; st >= 0;) { ch = getch(); @@ -1589,7 +1591,7 @@ private void pi() throws Exception { str = name(false); // PI target name may not be empty string [#2.6] // PI target name 'XML' is reserved [#2.6] - if ((str.length() == 0) + if ((str.isEmpty()) || (mXml.name.equals(str.toLowerCase()) == true)) { panic(FAULT); } @@ -2230,6 +2232,13 @@ protected char wsskip() protected abstract void docType(String name, String pubid, String sysid) throws SAXException; + /** + * Reports the start of DTD internal subset. + * + * @throws SAXException if the receiver throws SAXException + */ + public abstract void startInternalSub () throws SAXException; + /** * Reports a comment. * diff --git a/src/src/java.base/share/classes/jdk/internal/util/xml/impl/ParserSAX.java b/src/src/java.base/share/classes/jdk/internal/util/xml/impl/ParserSAX.java index 412a686129c..a208ee84e6c 100644 --- a/src/src/java.base/share/classes/jdk/internal/util/xml/impl/ParserSAX.java +++ b/src/src/java.base/share/classes/jdk/internal/util/xml/impl/ParserSAX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -551,7 +551,16 @@ private void parse() throws SAXException, IOException { * @param sysid The system identifier of the entity or null. */ protected void docType(String name, String pubid, String sysid) throws SAXException { - mHandDtd.notationDecl(name, pubid, sysid); + mHandDtd.startDTD(name, pubid, sysid); + } + + /** + * Reports the start of DTD internal subset. + * + * @throws SAXException if the receiver throws SAXException + */ + public void startInternalSub () throws SAXException { + mHandDtd.startInternalSub(); } /** diff --git a/src/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java b/src/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java index fb4dde6be17..20a3af833a2 100644 --- a/src/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java +++ b/src/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java @@ -205,7 +205,7 @@ public void writeDTD(String dtd) throws XMLStreamException { * @throws XMLStreamException */ public void writeStartElement(String localName) throws XMLStreamException { - if (localName == null || localName.length() == 0) { + if (localName == null || localName.isEmpty()) { throw new XMLStreamException("Local Name cannot be null or empty"); } @@ -420,7 +420,7 @@ private void writeXMLContent(char[] content, int start, int length, boolean esca } private void writeXMLContent(String content) throws XMLStreamException { - if ((content != null) && (content.length() > 0)) { + if (content != null && !content.isEmpty()) { writeXMLContent(content, _escapeCharacters, // boolean = escapeChars false); // false = escapeDoubleQuotes diff --git a/src/src/java.base/share/classes/module-info.java b/src/src/java.base/share/classes/module-info.java index 517622452ba..f6558191b78 100644 --- a/src/src/java.base/share/classes/module-info.java +++ b/src/src/java.base/share/classes/module-info.java @@ -136,6 +136,8 @@ java.security.sasl; exports jdk.internal to jdk.jfr; + exports jdk.internal.event to + jdk.jfr; exports jdk.internal.jimage to jdk.jlink; exports jdk.internal.jimage.decompressor to diff --git a/src/src/java.base/share/classes/sun/invoke/util/BytecodeName.java b/src/src/java.base/share/classes/sun/invoke/util/BytecodeName.java index 26b4076213d..8ba6840f1b8 100644 --- a/src/src/java.base/share/classes/sun/invoke/util/BytecodeName.java +++ b/src/src/java.base/share/classes/sun/invoke/util/BytecodeName.java @@ -451,7 +451,7 @@ private static void checkSafeBytecodeName(String s) * @return true if the name is non-empty and all of its characters are safe */ public static boolean isSafeBytecodeName(String s) { - if (s.length() == 0) return false; + if (s.isEmpty()) return false; // check occurrences of each DANGEROUS char for (char xc : DANGEROUS_CHARS_A) { if (xc == ESCAPE_C) continue; // not really that dangerous @@ -476,7 +476,7 @@ private static boolean looksMangled(String s) { } private static String mangle(String s) { - if (s.length() == 0) + if (s.isEmpty()) return NULL_ESCAPE; // build this lazily, when we first need an escape: diff --git a/src/src/java.base/share/classes/sun/net/TransferProtocolClient.java b/src/src/java.base/share/classes/sun/net/TransferProtocolClient.java index daa929ad3ef..e0b866e68cc 100644 --- a/src/src/java.base/share/classes/sun/net/TransferProtocolClient.java +++ b/src/src/java.base/share/classes/sun/net/TransferProtocolClient.java @@ -76,7 +76,7 @@ public int readServerResponse() throws IOException { System.out.print(response); } - if (response.length() == 0) { + if (response.isEmpty()) { code = -1; } else { try { diff --git a/src/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java b/src/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java index 21994bde722..078ced8d87d 100644 --- a/src/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/src/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java @@ -433,7 +433,7 @@ private int readServerResponse() throws IOException { logger.finest("Server [" + serverAddr + "] --> " + response); } - if (response.length() == 0) { + if (response.isEmpty()) { code = -1; } else { try { @@ -1049,7 +1049,7 @@ public sun.net.ftp.FtpClient login(String user, char[] password) throws sun.net. if (!isConnected()) { throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE); } - if (user == null || user.length() == 0) { + if (user == null || user.isEmpty()) { throw new IllegalArgumentException("User name can't be null or empty"); } tryLogin(user, password); @@ -1088,7 +1088,7 @@ public sun.net.ftp.FtpClient login(String user, char[] password, String account) if (!isConnected()) { throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE); } - if (user == null || user.length() == 0) { + if (user == null || user.isEmpty()) { throw new IllegalArgumentException("User name can't be null or empty"); } tryLogin(user, password); @@ -1152,7 +1152,7 @@ public boolean isLoggedIn() { * @exception FtpProtocolException */ public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException { - if (remoteDirectory == null || "".equals(remoteDirectory)) { + if (remoteDirectory == null || remoteDirectory.isEmpty()) { throw new IllegalArgumentException("directory can't be null or empty"); } @@ -1738,7 +1738,7 @@ public InputStream nameList(String path) throws sun.net.ftp.FtpProtocolException * @throws IOException if an error occurs during the transmission. */ public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException { - if (path == null || path.length() == 0) { + if (path == null || path.isEmpty()) { throw new IllegalArgumentException("path can't be null or empty"); } issueCommandCheck("SIZE " + path); diff --git a/src/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java b/src/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java index 05c4a466f0c..371a1a1dfdb 100644 --- a/src/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java +++ b/src/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java @@ -240,7 +240,7 @@ public Proxy[] run() { if (phost != null && phost.length() != 0) break; } - if (phost == null || phost.length() == 0) { + if (phost == null || phost.isEmpty()) { /** * No system property defined for that * protocol. Let's check System Proxy @@ -269,7 +269,7 @@ public Proxy[] run() { nprop.hostsSource = null; nprop.pattern = null; } - } else if (nphosts.length() != 0) { + } else if (!nphosts.isEmpty()) { // add the required default patterns // but only if property no set. If it // is empty, leave empty. diff --git a/src/src/java.base/share/classes/sun/net/util/SocketExceptions.java b/src/src/java.base/share/classes/sun/net/util/SocketExceptions.java index 6812c4ce8e2..24f6d8e9bad 100644 --- a/src/src/java.base/share/classes/sun/net/util/SocketExceptions.java +++ b/src/src/java.base/share/classes/sun/net/util/SocketExceptions.java @@ -30,43 +30,14 @@ import java.net.InetSocketAddress; import java.security.AccessController; import java.security.PrivilegedAction; -import java.security.Security; + +import sun.security.util.SecurityProperties; public final class SocketExceptions { private SocketExceptions() {} - /** - * Security or system property which specifies categories of - * (potentially sensitive) information that may be included - * in exception text. This class only defines one category: - * "hostInfo" which represents the hostname and port number - * of the remote peer relating to a socket exception. - * The property value is a comma separated list of - * case insignificant category names. - */ - private static final String enhancedTextPropname = "jdk.includeInExceptions"; - - private static final boolean enhancedExceptionText = initTextProp(); - - private static boolean initTextProp() { - return AccessController.doPrivileged(new PrivilegedAction() { - public Boolean run() { - String val = System.getProperty(enhancedTextPropname); - if (val == null) { - val = Security.getProperty(enhancedTextPropname); - if (val == null) - return false; - } - String[] tokens = val.split(","); - for (String token : tokens) { - if (token.equalsIgnoreCase("hostinfo")) - return true; - } - return false; - } - }); - } - + private static final boolean enhancedExceptionText = + SecurityProperties.includedInExceptions("hostInfo"); /** * Utility which takes an exception and returns either the same exception @@ -74,8 +45,9 @@ public Boolean run() { * and detail message enhanced with addressing information from the * given InetSocketAddress. * - * If the system/security property "jdk.net.enhanceExceptionText" is not - * set or is false, then the original exception is returned. + * If the system/security property "jdk.includeInExceptions" is not + * set or does not contain the category hostInfo, + * then the original exception is returned. * * Only specific IOException subtypes are supported. */ diff --git a/src/src/java.base/share/classes/sun/net/www/HeaderParser.java b/src/src/java.base/share/classes/sun/net/www/HeaderParser.java index f9db1df64de..a4b2ab50497 100644 --- a/src/src/java.base/share/classes/sun/net/www/HeaderParser.java +++ b/src/src/java.base/share/classes/sun/net/www/HeaderParser.java @@ -226,7 +226,7 @@ public String toString () { for (int i=0; k.hasNext(); i++) { String key = k.next(); String val = findValue (i); - if (val != null && "".equals (val)) { + if (val != null && val.isEmpty()) { val = null; } sb.append(" {").append(key).append(val == null ? "" : "," + val) diff --git a/src/src/java.base/share/classes/sun/net/www/MimeEntry.java b/src/src/java.base/share/classes/sun/net/www/MimeEntry.java index 44b7c49b3fa..5690db0fb78 100644 --- a/src/src/java.base/share/classes/sun/net/www/MimeEntry.java +++ b/src/src/java.base/share/classes/sun/net/www/MimeEntry.java @@ -201,9 +201,7 @@ public synchronized void setExtensions(String extensionString) { } private boolean isStarred(String typeName) { - return (typeName != null) - && (typeName.length() > 0) - && (typeName.endsWith("/*")); + return typeName != null && typeName.endsWith("/*"); } /** @@ -300,7 +298,7 @@ public synchronized String toProperty() { } String extensions = getExtensionsAsList(); - if (extensions.length() > 0) { + if (!extensions.isEmpty()) { sj.add("file_extensions=" + extensions); } diff --git a/src/src/java.base/share/classes/sun/net/www/MimeLauncher.java b/src/src/java.base/share/classes/sun/net/www/MimeLauncher.java index a2cfefab33c..452e3a1e4d0 100644 --- a/src/src/java.base/share/classes/sun/net/www/MimeLauncher.java +++ b/src/src/java.base/share/classes/sun/net/www/MimeLauncher.java @@ -162,7 +162,7 @@ public void run() { location the application. If a valid path is not found, it returns false else true. */ private boolean findExecutablePath(String str) { - if (str == null || str.length() == 0) { + if (str == null || str.isEmpty()) { return false; } diff --git a/src/src/java.base/share/classes/sun/net/www/ParseUtil.java b/src/src/java.base/share/classes/sun/net/www/ParseUtil.java index 9ff0c2a4f6c..92f2965b136 100644 --- a/src/src/java.base/share/classes/sun/net/www/ParseUtil.java +++ b/src/src/java.base/share/classes/sun/net/www/ParseUtil.java @@ -536,8 +536,7 @@ private static void checkPath(String s, String scheme, String path) throws URISyntaxException { if (scheme != null) { - if ((path != null) - && ((path.length() > 0) && (path.charAt(0) != '/'))) + if (path != null && !path.isEmpty() && path.charAt(0) != '/') throw new URISyntaxException(s, "Relative path in absolute URI"); } diff --git a/src/src/java.base/share/classes/sun/net/www/http/HttpClient.java b/src/src/java.base/share/classes/sun/net/www/http/HttpClient.java index 57d734e5166..8b1a81a6df1 100644 --- a/src/src/java.base/share/classes/sun/net/www/http/HttpClient.java +++ b/src/src/java.base/share/classes/sun/net/www/http/HttpClient.java @@ -603,7 +603,7 @@ public String getURLFile() throws IOException { StringBuilder result = new StringBuilder(128); result.append(url.getProtocol()); result.append(":"); - if (url.getAuthority() != null && url.getAuthority().length() > 0) { + if (url.getAuthority() != null && !url.getAuthority().isEmpty()) { result.append("//"); result.append(url.getAuthority()); } @@ -619,7 +619,7 @@ public String getURLFile() throws IOException { } else { fileName = url.getFile(); - if ((fileName == null) || (fileName.length() == 0)) { + if ((fileName == null) || (fileName.isEmpty())) { fileName = "/"; } else if (fileName.charAt(0) == '?') { /* HTTP/1.1 spec says in 5.1.2. about Request-URI: diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java b/src/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java index ca825b135af..fccf99b337b 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java @@ -358,7 +358,7 @@ private void decodePath(String path) { path.charAt(0) == '/') { path = path.substring(1); } - if (path == null || path.length() == 0) { + if (path == null || path.isEmpty()) { path = "./"; } if (!path.endsWith("/")) { @@ -572,7 +572,7 @@ public OutputStream getOutputStream() throws IOException { } decodePath(url.getPath()); - if (filename == null || filename.length() == 0) { + if (filename == null || filename.isEmpty()) { throw new IOException("illegal filename for a PUT"); } try { diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java b/src/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java index c7f369eda23..f3f89459c6f 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java @@ -248,7 +248,7 @@ public AuthenticationInfo(char type, AuthScheme authScheme, URL url, String real this.realm = realm; String urlPath = url.getPath(); - if (urlPath.length() == 0) + if (urlPath.isEmpty()) this.path = urlPath; else { this.path = reducePath (urlPath); diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java b/src/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java index 7d49792b099..077a95e3d47 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java @@ -279,7 +279,7 @@ public boolean isAuthorizationStale (String header) { if (s == null || !s.equals("true")) return false; String newNonce = p.findValue ("nonce"); - if (newNonce == null || "".equals(newNonce)) { + if (newNonce == null || newNonce.isEmpty()) { return false; } params.setNonce (newNonce); @@ -323,7 +323,7 @@ public boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) { + authMethod.substring(1).toLowerCase(); } String algorithm = p.findValue("algorithm"); - if (algorithm == null || "".equals(algorithm)) { + if (algorithm == null || algorithm.isEmpty()) { algorithm = "MD5"; // The default, accoriding to rfc2069 } params.setAlgorithm (algorithm); @@ -451,7 +451,7 @@ public void checkResponse (String header, String method, String uri) } /* Check if there is a nextnonce field */ String nextnonce = p.findValue ("nextnonce"); - if (nextnonce != null && ! "".equals(nextnonce)) { + if (nextnonce != null && !nextnonce.isEmpty()) { params.setNonce (nextnonce); } diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 99baf0b1b21..54ec8e00bd5 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -2165,6 +2165,10 @@ public synchronized void doTunneling() throws IOException { } while (retryTunnel < maxRedirects); if (retryTunnel >= maxRedirects || (respCode != HTTP_OK)) { + if (respCode != HTTP_PROXY_AUTH) { + // remove all but authenticate responses + responses.reset(); + } throw new IOException("Unable to tunnel through proxy."+ " Proxy returns \"" + statusLine + "\""); @@ -3032,7 +3036,7 @@ private String filterHeaderField(String name, String value) { // Filtering only if there is a cookie handler. [Assumption: the // cookie handler will store/retrieve the HttpOnly cookies] - if (cookieHandler == null || value.length() == 0) + if (cookieHandler == null || value.isEmpty()) return value; JavaNetHttpCookieAccess access = diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java b/src/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java index e5b8aa6973c..41bbafd5e93 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java @@ -143,7 +143,7 @@ final class HttpsClient extends HttpClient String cipherString = GetPropertyAction.privilegedGetProperty("https.cipherSuites"); - if (cipherString == null || "".equals(cipherString)) { + if (cipherString == null || cipherString.isEmpty()) { ciphers = null; } else { StringTokenizer tokenizer; @@ -167,7 +167,7 @@ final class HttpsClient extends HttpClient String protocolString = GetPropertyAction.privilegedGetProperty("https.protocols"); - if (protocolString == null || "".equals(protocolString)) { + if (protocolString == null || protocolString.isEmpty()) { protocols = null; } else { StringTokenizer tokenizer; @@ -187,7 +187,7 @@ final class HttpsClient extends HttpClient private String getUserAgent() { String userAgent = GetPropertyAction.privilegedGetProperty("https.agent"); - if (userAgent == null || userAgent.length() == 0) { + if (userAgent == null || userAgent.isEmpty()) { userAgent = "JSSE"; } return userAgent; diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java b/src/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java index 57b01b90300..d492e688cab 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -121,6 +121,13 @@ protected int hashCode(URL u) { return h; } + public String checkNestedProtocol(String spec) { + if (spec.regionMatches(true, 0, "jar:", 0, 4)) { + return "Nested JAR URLs are not supported"; + } else { + return null; + } + } @Override @SuppressWarnings("deprecation") @@ -146,6 +153,12 @@ protected void parseURL(URL url, String spec, : false; spec = spec.substring(start, limit); + String exceptionMessage = checkNestedProtocol(spec); + if (exceptionMessage != null) { + // NPE will be transformed into MalformedURLException by the caller + throw new NullPointerException(exceptionMessage); + } + if (absoluteSpec) { file = parseAbsoluteSpec(spec); } else if (!refOnly) { diff --git a/src/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java b/src/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java index c7446082edd..29dac993a8d 100644 --- a/src/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java +++ b/src/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java @@ -66,7 +66,7 @@ public class JavaRuntimeURLConnection extends URLConnection { JavaRuntimeURLConnection(URL url) throws IOException { super(url); String path = url.getPath(); - if (path.length() == 0 || path.charAt(0) != '/') + if (path.isEmpty() || path.charAt(0) != '/') throw new MalformedURLException(url + " missing path or /"); if (path.length() == 1) { this.module = null; diff --git a/src/src/java.base/share/classes/sun/nio/ch/Net.java b/src/src/java.base/share/classes/sun/nio/ch/Net.java index 856efce30b9..fe8b12670e2 100644 --- a/src/src/java.base/share/classes/sun/nio/ch/Net.java +++ b/src/src/java.base/share/classes/sun/nio/ch/Net.java @@ -403,14 +403,8 @@ static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, public static boolean isFastTcpLoopbackRequested() { String loopbackProp = GetPropertyAction - .privilegedGetProperty("jdk.net.useFastTcpLoopback"); - boolean enable; - if ("".equals(loopbackProp)) { - enable = true; - } else { - enable = Boolean.parseBoolean(loopbackProp); - } - return enable; + .privilegedGetProperty("jdk.net.useFastTcpLoopback", "false"); + return loopbackProp.isEmpty() ? true : Boolean.parseBoolean(loopbackProp); } // -- Socket operations -- diff --git a/src/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java b/src/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java index 0e325414f5d..679f5857132 100644 --- a/src/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java +++ b/src/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java @@ -73,7 +73,7 @@ public final void setAttribute(Path file, throws IOException { String[] s = split(attribute); - if (s[0].length() == 0) + if (s[0].isEmpty()) throw new IllegalArgumentException(attribute); DynamicFileAttributeView view = getFileAttributeView(file, s[0], options); if (view == null) @@ -86,7 +86,7 @@ public final Map readAttributes(Path file, String attributes, Lin throws IOException { String[] s = split(attributes); - if (s[0].length() == 0) + if (s[0].isEmpty()) throw new IllegalArgumentException(attributes); DynamicFileAttributeView view = getFileAttributeView(file, s[0], options); if (view == null) diff --git a/src/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java b/src/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java index 3886aa1b114..a349b08ccf6 100644 --- a/src/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java +++ b/src/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java @@ -83,7 +83,7 @@ public final Map readAttributes(String[] attributes) names = list(); break; } else { - if (name.length() == 0) + if (name.isEmpty()) throw new IllegalArgumentException(); names.add(name); } diff --git a/src/src/java.base/share/classes/sun/security/jca/GetInstance.java b/src/src/java.base/share/classes/sun/security/jca/GetInstance.java index a5e5602dc4d..fd513c47edb 100644 --- a/src/src/java.base/share/classes/sun/security/jca/GetInstance.java +++ b/src/src/java.base/share/classes/sun/security/jca/GetInstance.java @@ -75,7 +75,7 @@ public static Service getService(String type, String algorithm) public static Service getService(String type, String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if ((provider == null) || (provider.length() == 0)) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } Provider p = Providers.getProviderList().getProvider(provider); diff --git a/src/src/java.base/share/classes/sun/security/jca/ProviderConfig.java b/src/src/java.base/share/classes/sun/security/jca/ProviderConfig.java index 2f52c8b2ca8..ffa06f51fb5 100644 --- a/src/src/java.base/share/classes/sun/security/jca/ProviderConfig.java +++ b/src/src/java.base/share/classes/sun/security/jca/ProviderConfig.java @@ -114,7 +114,7 @@ public Boolean run() { } private boolean hasArgument() { - return argument.length() != 0; + return !argument.isEmpty(); } // should we try to load this provider? diff --git a/src/src/java.base/share/classes/sun/security/jca/ProviderList.java b/src/src/java.base/share/classes/sun/security/jca/ProviderList.java index 68597c891b2..5b17366d5de 100644 --- a/src/src/java.base/share/classes/sun/security/jca/ProviderList.java +++ b/src/src/java.base/share/classes/sun/security/jca/ProviderList.java @@ -175,7 +175,7 @@ private ProviderList() { while ((entry = Security.getProperty("security.provider." + i)) != null) { entry = entry.trim(); - if (entry.length() == 0) { + if (entry.isEmpty()) { System.err.println("invalid entry for " + "security.provider." + i); break; @@ -200,7 +200,7 @@ private ProviderList() { // Load config entries for use when getInstance is called entry = Security.getProperty("jdk.security.provider.preferred"); - if (entry != null && (entry = entry.trim()).length() > 0) { + if (entry != null && !(entry = entry.trim()).isEmpty()) { String[] entries = entry.split(","); if (ProviderList.preferredPropList == null) { ProviderList.preferredPropList = new PreferredList(); diff --git a/src/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java b/src/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java index 4df92670441..d3bdc9084e8 100644 --- a/src/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java +++ b/src/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -447,15 +447,13 @@ SignerInfo verify(PKCS7 block, byte[] data) Signature sig = Signature.getInstance(algname); - sig.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selections occur when key is set AlgorithmParameters ap = digestEncryptionAlgorithmId.getParameters(); try { - SignatureUtil.specialSetParameter(sig, ap); - } catch (ProviderException | InvalidAlgorithmParameterException e) { + SignatureUtil.initVerifyWithParam(sig, key, + SignatureUtil.getParamSpec(algname, ap)); + } catch (ProviderException | InvalidAlgorithmParameterException | + InvalidKeyException e) { throw new SignatureException(e.getMessage(), e); } @@ -466,8 +464,6 @@ SignerInfo verify(PKCS7 block, byte[] data) } catch (IOException e) { throw new SignatureException("IO error verifying signature:\n" + e.getMessage()); - } catch (InvalidKeyException e) { - throw new SignatureException("InvalidKey: " + e.getMessage()); } return null; } diff --git a/src/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java b/src/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java index f49d3a1394e..92b3b51c377 100644 --- a/src/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java +++ b/src/src/java.base/share/classes/sun/security/pkcs10/PKCS10.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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,7 +32,6 @@ import java.security.cert.CertificateException; import java.security.*; -import java.security.spec.AlgorithmParameterSpec; import java.util.Base64; @@ -168,12 +167,8 @@ public PKCS10(byte[] data) try { sigAlg = id.getName(); sig = Signature.getInstance(sigAlg); - - sig.initVerify(subjectPublicKeyInfo); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selections occur when key is set - SignatureUtil.specialSetParameter(sig, id.getParameters()); + SignatureUtil.initVerifyWithParam(sig, subjectPublicKeyInfo, + SignatureUtil.getParamSpec(sigAlg, id.getParameters())); sig.update(data); if (!sig.verify(sigData)) { @@ -237,10 +232,14 @@ public void encodeAndSign(X500Name subject, Signature signature) */ AlgorithmId algId = null; try { - algId = AlgorithmId.get(signature.getAlgorithm()); + AlgorithmParameters params = signature.getParameters(); + algId = params == null + ? AlgorithmId.get(signature.getAlgorithm()) + : AlgorithmId.get(params); } catch (NoSuchAlgorithmException nsae) { throw new SignatureException(nsae); } + algId.encode(scratch); // sig algorithm scratch.putBitString(sig); // sig diff --git a/src/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 59d081bb56f..3751537750d 100644 --- a/src/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/src/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -2202,18 +2202,9 @@ public synchronized void engineLoad(InputStream stream, char[] password) } if (debug != null) { - if (privateKeyCount > 0) { - debug.println("Loaded " + privateKeyCount + - " protected private key(s)"); - } - if (secretKeyCount > 0) { - debug.println("Loaded " + secretKeyCount + - " protected secret key(s)"); - } - if (certificateCount > 0) { - debug.println("Loaded " + certificateCount + - " certificate(s)"); - } + debug.println("PKCS12KeyStore load: private key count: " + + privateKeyCount + ". secret key count: " + secretKeyCount + + ". certificate count: " + certificateCount); } certEntries.clear(); diff --git a/src/src/java.base/share/classes/sun/security/provider/ConfigFile.java b/src/src/java.base/share/classes/sun/security/provider/ConfigFile.java index 450a4292cff..080a44f8c89 100644 --- a/src/src/java.base/share/classes/sun/security/provider/ConfigFile.java +++ b/src/src/java.base/share/classes/sun/security/provider/ConfigFile.java @@ -626,7 +626,7 @@ private InputStream getInputStream(URL url) throws IOException { return url.openStream(); } catch (Exception e) { String file = url.getPath(); - if (url.getHost().length() > 0) { // For Windows UNC + if (!url.getHost().isEmpty()) { // For Windows UNC file = "//" + url.getHost() + file; } if (debugConfig != null) { @@ -651,7 +651,7 @@ private String expand(String value) return value; } String s = PropertyExpander.expand(value); - if (s == null || s.length() == 0) { + if (s == null || s.isEmpty()) { throw ioException( "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value", linenum, value); diff --git a/src/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java b/src/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java index c0a1455cf5b..49b3550ef3d 100644 --- a/src/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java +++ b/src/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -34,6 +34,7 @@ import sun.security.pkcs.EncryptedPrivateKeyInfo; import sun.security.pkcs12.PKCS12KeyStore; +import sun.security.util.Debug; import sun.security.util.IOUtils; import sun.security.util.KeyStoreDelegator; @@ -74,6 +75,7 @@ public DualFormatJKS() { } } + private static final Debug debug = Debug.getInstance("keystore"); private static final int MAGIC = 0xfeedfeed; private static final int VERSION_1 = 0x01; private static final int VERSION_2 = 0x02; @@ -643,6 +645,7 @@ public void engineLoad(InputStream stream, char[] password) Hashtable cfs = null; ByteArrayInputStream bais = null; byte[] encoded = null; + int trustedKeyCount = 0, privateKeyCount = 0; if (stream == null) return; @@ -681,7 +684,7 @@ public void engineLoad(InputStream stream, char[] password) tag = dis.readInt(); if (tag == 1) { // private key entry - + privateKeyCount++; KeyEntry entry = new KeyEntry(); // Read the alias @@ -730,7 +733,7 @@ public void engineLoad(InputStream stream, char[] password) entries.put(alias, entry); } else if (tag == 2) { // trusted certificate entry - + trustedKeyCount++; TrustedCertEntry entry = new TrustedCertEntry(); // Read the alias @@ -765,10 +768,16 @@ public void engineLoad(InputStream stream, char[] password) entries.put(alias, entry); } else { - throw new IOException("Unrecognized keystore entry"); + throw new IOException("Unrecognized keystore entry: " + + tag); } } + if (debug != null) { + debug.println("JavaKeyStore load: private key count: " + + privateKeyCount + ". trusted key count: " + trustedKeyCount); + } + /* * If a password has been provided, we check the keyed digest * at the end. If this check fails, the store has been tampered diff --git a/src/src/java.base/share/classes/sun/security/provider/PolicyParser.java b/src/src/java.base/share/classes/sun/security/provider/PolicyParser.java index 017f667698f..3edb35a3a9f 100644 --- a/src/src/java.base/share/classes/sun/security/provider/PolicyParser.java +++ b/src/src/java.base/share/classes/sun/security/provider/PolicyParser.java @@ -391,9 +391,9 @@ private void writeKeyStoreEntry(PrintWriter out) { out.print("keystore \""); out.print(keyStoreUrlString); out.print('"'); - if (keyStoreType != null && keyStoreType.length() > 0) + if (keyStoreType != null && !keyStoreType.isEmpty()) out.print(", \"" + keyStoreType + "\""); - if (keyStoreProvider != null && keyStoreProvider.length() > 0) + if (keyStoreProvider != null && !keyStoreProvider.isEmpty()) out.print(", \"" + keyStoreProvider + "\""); out.println(";"); out.println(); @@ -446,7 +446,7 @@ private GrantEntry parseGrantEntry() String alias = aliases.nextToken().trim(); if (alias.equals(",")) cctr++; - else if (alias.length() > 0) + else if (!alias.isEmpty()) actr++; } if (actr <= cctr) diff --git a/src/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/src/src/java.base/share/classes/sun/security/provider/SeedGenerator.java index ac3a9f86a1a..d4360724ac7 100644 --- a/src/src/java.base/share/classes/sun/security/provider/SeedGenerator.java +++ b/src/src/java.base/share/classes/sun/security/provider/SeedGenerator.java @@ -113,7 +113,7 @@ abstract class SeedGenerator { + "generator: " + e.toString()); } } - } else if (egdSource.length() != 0) { + } else if (!egdSource.isEmpty()) { try { instance = new URLSeedGenerator(egdSource); if (debug != null) { diff --git a/src/src/java.base/share/classes/sun/security/provider/X509Factory.java b/src/src/java.base/share/classes/sun/security/provider/X509Factory.java index 34a3c8e1ac4..47466820838 100644 --- a/src/src/java.base/share/classes/sun/security/provider/X509Factory.java +++ b/src/src/java.base/share/classes/sun/security/provider/X509Factory.java @@ -26,12 +26,15 @@ package sun.security.provider; import java.io.*; +import java.security.PublicKey; import java.util.*; import java.security.cert.*; +import jdk.internal.event.EventHelper; +import jdk.internal.event.X509CertificateEvent; +import sun.security.util.KeyUtil; import sun.security.util.Pem; -import sun.security.x509.X509CertImpl; -import sun.security.x509.X509CRLImpl; +import sun.security.x509.*; import sun.security.pkcs.PKCS7; import sun.security.provider.certpath.X509CertPath; import sun.security.provider.certpath.X509CertificatePair; @@ -101,6 +104,8 @@ public Certificate engineGenerateCertificate(InputStream is) } cert = new X509CertImpl(encoding); addToCache(certCache, cert.getEncodedInternal(), cert); + // record cert details if necessary + commitEvent(cert); return cert; } else { throw new IOException("Empty input"); @@ -761,4 +766,43 @@ private static int readBERInternal(InputStream is, } return tag; } + + private void commitEvent(X509CertImpl info) { + X509CertificateEvent xce = new X509CertificateEvent(); + if (xce.shouldCommit() || EventHelper.isLoggingSecurity()) { + PublicKey pKey = info.getPublicKey(); + String algId = info.getSigAlgName(); + String serNum = info.getSerialNumber().toString(16); + String subject = info.getSubjectDN().getName(); + String issuer = info.getIssuerDN().getName(); + String keyType = pKey.getAlgorithm(); + int length = KeyUtil.getKeySize(pKey); + int hashCode = info.hashCode(); + long beginDate = info.getNotBefore().getTime(); + long endDate = info.getNotAfter().getTime(); + if (xce.shouldCommit()) { + xce.algorithm = algId; + xce.serialNumber = serNum; + xce.subject = subject; + xce.issuer = issuer; + xce.keyType = keyType; + xce.keyLength = length; + xce.certificateId = hashCode; + xce.validFrom = beginDate; + xce.validUntil = endDate; + xce.commit(); + } + if (EventHelper.isLoggingSecurity()) { + EventHelper.logX509CertificateEvent(algId, + serNum, + subject, + issuer, + keyType, + length, + hashCode, + beginDate, + endDate); + } + } + } } diff --git a/src/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java b/src/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java index 80497e774fd..fe0e2fc5daf 100644 --- a/src/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java +++ b/src/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java @@ -29,7 +29,10 @@ import java.security.InvalidAlgorithmParameterException; import java.security.cert.*; import java.util.*; +import java.util.concurrent.atomic.AtomicLong; +import jdk.internal.event.X509ValidationEvent; +import jdk.internal.event.EventHelper; import sun.security.provider.certpath.PKIX.ValidatorParams; import sun.security.validator.Validator; import sun.security.x509.X509CertImpl; @@ -47,6 +50,7 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi { private static final Debug debug = Debug.getInstance("certpath"); + private static final AtomicLong validationCounter = new AtomicLong(); /** * Default constructor. @@ -234,7 +238,33 @@ private static PKIXCertPathValidatorResult validate(TrustAnchor anchor, params.certificates(), certPathCheckers); + X509ValidationEvent xve = new X509ValidationEvent(); + if (xve.shouldCommit() || EventHelper.isLoggingSecurity()) { + int[] certIds = params.certificates().stream() + .mapToInt(x -> x.hashCode()) + .toArray(); + int anchorCertId = + anchor.getTrustedCert().hashCode(); + if (xve.shouldCommit()) { + xve.certificateId = anchorCertId; + int certificatePos = 1; //anchor cert + xve.certificatePosition = certificatePos; + xve.validationCounter = validationCounter.incrementAndGet(); + xve.commit(); + // now, iterate through remaining + for (int id : certIds) { + xve.certificateId = id; + xve.certificatePosition = ++certificatePos; + xve.commit(); + + } + } + if (EventHelper.isLoggingSecurity()) { + EventHelper.logX509ValidationEvent(anchorCertId, certIds); + } + } return new PKIXCertPathValidatorResult(anchor, pc.getPolicyTree(), bc.getPublicKey()); } + } diff --git a/src/src/java.base/share/classes/sun/security/rsa/PSSParameters.java b/src/src/java.base/share/classes/sun/security/rsa/PSSParameters.java index 6797dbbb694..25625a89f59 100644 --- a/src/src/java.base/share/classes/sun/security/rsa/PSSParameters.java +++ b/src/src/java.base/share/classes/sun/security/rsa/PSSParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -52,13 +52,7 @@ public final class PSSParameters extends AlgorithmParametersSpi { - private String mdName; - private MGF1ParameterSpec mgfSpec; - private int saltLength; - private int trailerField; - - private static final ObjectIdentifier OID_MGF1 = - ObjectIdentifier.newInternal(new int[] {1,2,840,113549,1,1,8}); + private PSSParameterSpec spec; public PSSParameters() { } @@ -71,9 +65,9 @@ protected void engineInit(AlgorithmParameterSpec paramSpec) ("Inappropriate parameter specification"); } PSSParameterSpec spec = (PSSParameterSpec) paramSpec; - this.mdName = spec.getDigestAlgorithm(); + String mgfName = spec.getMGFAlgorithm(); - if (!mgfName.equalsIgnoreCase("MGF1")) { + if (!spec.getMGFAlgorithm().equalsIgnoreCase("MGF1")) { throw new InvalidParameterSpecException("Unsupported mgf " + mgfName + "; MGF1 only"); } @@ -82,31 +76,30 @@ protected void engineInit(AlgorithmParameterSpec paramSpec) throw new InvalidParameterSpecException("Inappropriate mgf " + "parameters; non-null MGF1ParameterSpec only"); } - this.mgfSpec = (MGF1ParameterSpec) mgfSpec; - this.saltLength = spec.getSaltLength(); - this.trailerField = spec.getTrailerField(); + this.spec = spec; } @Override protected void engineInit(byte[] encoded) throws IOException { // first initialize with the DEFAULT values before // retrieving from the encoding bytes - this.mdName = DEFAULT.getDigestAlgorithm(); - this.mgfSpec = (MGF1ParameterSpec) DEFAULT.getMGFParameters(); - this.saltLength = DEFAULT.getSaltLength(); - this.trailerField = DEFAULT.getTrailerField(); + String mdName = DEFAULT.getDigestAlgorithm(); + MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec) DEFAULT.getMGFParameters(); + int saltLength = DEFAULT.getSaltLength(); + int trailerField = DEFAULT.getTrailerField(); DerInputStream der = new DerInputStream(encoded); DerValue[] datum = der.getSequence(4); + for (DerValue d : datum) { if (d.isContextSpecific((byte) 0x00)) { // hash algid - this.mdName = AlgorithmId.parse + mdName = AlgorithmId.parse (d.data.getDerValue()).getName(); } else if (d.isContextSpecific((byte) 0x01)) { // mgf algid AlgorithmId val = AlgorithmId.parse(d.data.getDerValue()); - if (!val.getOID().equals(OID_MGF1)) { + if (!val.getOID().equals(AlgorithmId.mgf1_oid)) { throw new IOException("Only MGF1 mgf is supported"); } AlgorithmId params = AlgorithmId.parse( @@ -114,25 +107,25 @@ protected void engineInit(byte[] encoded) throws IOException { String mgfDigestName = params.getName(); switch (mgfDigestName) { case "SHA-1": - this.mgfSpec = MGF1ParameterSpec.SHA1; + mgfSpec = MGF1ParameterSpec.SHA1; break; case "SHA-224": - this.mgfSpec = MGF1ParameterSpec.SHA224; + mgfSpec = MGF1ParameterSpec.SHA224; break; case "SHA-256": - this.mgfSpec = MGF1ParameterSpec.SHA256; + mgfSpec = MGF1ParameterSpec.SHA256; break; case "SHA-384": - this.mgfSpec = MGF1ParameterSpec.SHA384; + mgfSpec = MGF1ParameterSpec.SHA384; break; case "SHA-512": - this.mgfSpec = MGF1ParameterSpec.SHA512; + mgfSpec = MGF1ParameterSpec.SHA512; break; case "SHA-512/224": - this.mgfSpec = MGF1ParameterSpec.SHA512_224; + mgfSpec = MGF1ParameterSpec.SHA512_224; break; case "SHA-512/256": - this.mgfSpec = MGF1ParameterSpec.SHA512_256; + mgfSpec = MGF1ParameterSpec.SHA512_256; break; default: throw new IOException @@ -141,21 +134,24 @@ protected void engineInit(byte[] encoded) throws IOException { } } else if (d.isContextSpecific((byte) 0x02)) { // salt length - this.saltLength = d.data.getDerValue().getInteger(); - if (this.saltLength < 0) { + saltLength = d.data.getDerValue().getInteger(); + if (saltLength < 0) { throw new IOException("Negative value for saltLength"); } } else if (d.isContextSpecific((byte) 0x03)) { // trailer field - this.trailerField = d.data.getDerValue().getInteger(); - if (this.trailerField != 1) { + trailerField = d.data.getDerValue().getInteger(); + if (trailerField != 1) { throw new IOException("Unsupported trailerField value " + - this.trailerField); + trailerField); } } else { throw new IOException("Invalid encoded PSSParameters"); } } + + this.spec = new PSSParameterSpec(mdName, "MGF1", mgfSpec, + saltLength, trailerField); } @Override @@ -173,9 +169,7 @@ protected void engineInit(byte[] encoded, String decodingMethod) T engineGetParameterSpec(Class paramSpec) throws InvalidParameterSpecException { if (PSSParameterSpec.class.isAssignableFrom(paramSpec)) { - return paramSpec.cast( - new PSSParameterSpec(mdName, "MGF1", mgfSpec, - saltLength, trailerField)); + return paramSpec.cast(spec); } else { throw new InvalidParameterSpecException ("Inappropriate parameter specification"); @@ -184,72 +178,97 @@ T engineGetParameterSpec(Class paramSpec) @Override protected byte[] engineGetEncoded() throws IOException { + return getEncoded(spec); + } + + @Override + protected byte[] engineGetEncoded(String encMethod) throws IOException { + if ((encMethod != null) && + (!encMethod.equalsIgnoreCase("ASN.1"))) { + throw new IllegalArgumentException("Only support ASN.1 format"); + } + return engineGetEncoded(); + } + + @Override + protected String engineToString() { + return spec.toString(); + } + + /** + * Returns the encoding of a {@link PSSParameterSpec} object. This method + * is used in this class and {@link AlgorithmId}. + * + * @param spec a {@code PSSParameterSpec} object + * @return its DER encoding + * @throws IOException if the name of a MessageDigest or MaskGenAlgorithm + * is unsupported + */ + public static byte[] getEncoded(PSSParameterSpec spec) throws IOException { + + AlgorithmParameterSpec mgfSpec = spec.getMGFParameters(); + if (!(mgfSpec instanceof MGF1ParameterSpec)) { + throw new IOException("Cannot encode " + mgfSpec); + } + + MGF1ParameterSpec mgf1Spec = (MGF1ParameterSpec)mgfSpec; + DerOutputStream tmp = new DerOutputStream(); DerOutputStream tmp2, tmp3; // MD AlgorithmId mdAlgId; try { - mdAlgId = AlgorithmId.get(mdName); + mdAlgId = AlgorithmId.get(spec.getDigestAlgorithm()); } catch (NoSuchAlgorithmException nsae) { - throw new IOException("AlgorithmId " + mdName + - " impl not found"); + throw new IOException("AlgorithmId " + spec.getDigestAlgorithm() + + " impl not found"); + } + if (!mdAlgId.getOID().equals(AlgorithmId.SHA_oid)) { + tmp2 = new DerOutputStream(); + mdAlgId.derEncode(tmp2); + tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0), + tmp2); } - tmp2 = new DerOutputStream(); - mdAlgId.derEncode(tmp2); - tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0), - tmp2); // MGF - tmp2 = new DerOutputStream(); - tmp2.putOID(OID_MGF1); AlgorithmId mgfDigestId; try { - mgfDigestId = AlgorithmId.get(mgfSpec.getDigestAlgorithm()); + mgfDigestId = AlgorithmId.get(mgf1Spec.getDigestAlgorithm()); } catch (NoSuchAlgorithmException nase) { throw new IOException("AlgorithmId " + - mgfSpec.getDigestAlgorithm() + " impl not found"); + mgf1Spec.getDigestAlgorithm() + " impl not found"); + } + + if (!mgfDigestId.getOID().equals(AlgorithmId.SHA_oid)) { + tmp2 = new DerOutputStream(); + tmp2.putOID(AlgorithmId.mgf1_oid); + mgfDigestId.encode(tmp2); + tmp3 = new DerOutputStream(); + tmp3.write(DerValue.tag_Sequence, tmp2); + tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 1), + tmp3); } - mgfDigestId.encode(tmp2); - tmp3 = new DerOutputStream(); - tmp3.write(DerValue.tag_Sequence, tmp2); - tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)1), - tmp3); // SaltLength - tmp2 = new DerOutputStream(); - tmp2.putInteger(saltLength); - tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)2), - tmp2); + if (spec.getSaltLength() != 20) { + tmp2 = new DerOutputStream(); + tmp2.putInteger(spec.getSaltLength()); + tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 2), + tmp2); + } // TrailerField - tmp2 = new DerOutputStream(); - tmp2.putInteger(trailerField); - tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)3), - tmp2); + if (spec.getTrailerField() != PSSParameterSpec.TRAILER_FIELD_BC) { + tmp2 = new DerOutputStream(); + tmp2.putInteger(spec.getTrailerField()); + tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 3), + tmp2); + } // Put all together under a SEQUENCE tag DerOutputStream out = new DerOutputStream(); out.write(DerValue.tag_Sequence, tmp); return out.toByteArray(); } - - @Override - protected byte[] engineGetEncoded(String encMethod) throws IOException { - if ((encMethod != null) && - (!encMethod.equalsIgnoreCase("ASN.1"))) { - throw new IllegalArgumentException("Only support ASN.1 format"); - } - return engineGetEncoded(); - } - - @Override - protected String engineToString() { - StringBuilder sb = new StringBuilder(); - sb.append("MD: " + mdName + "\n") - .append("MGF: MGF1" + mgfSpec.getDigestAlgorithm() + "\n") - .append("SaltLength: " + saltLength + "\n") - .append("TrailerField: " + trailerField + "\n"); - return sb.toString(); - } } diff --git a/src/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java b/src/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java index 36898c9c8fa..a38cfbfe486 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java +++ b/src/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java @@ -439,7 +439,7 @@ private void onCertificate(ClientHandshakeContext chc, // It is not necessary to check the certificate update if // endpoint identification is enabled. String identityAlg = chc.sslConfig.identificationProtocol; - if ((identityAlg == null || identityAlg.length() == 0) && + if ((identityAlg == null || identityAlg.isEmpty()) && !isIdentityEquivalent(x509Certs[0], chc.reservedServerCerts[0])) { throw chc.conContext.fatal(Alert.BAD_CERTIFICATE, diff --git a/src/src/java.base/share/classes/sun/security/ssl/ClientHello.java b/src/src/java.base/share/classes/sun/security/ssl/ClientHello.java index b16a9b5a163..6fbac3103e5 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/ClientHello.java +++ b/src/src/java.base/share/classes/sun/security/ssl/ClientHello.java @@ -493,7 +493,7 @@ public byte[] produce(ConnectionContext context) throws IOException { // It is fine to move on with abbreviate handshake if // endpoint identification is enabled. String identityAlg = chc.sslConfig.identificationProtocol; - if ((identityAlg == null || identityAlg.length() == 0)) { + if (identityAlg == null || identityAlg.isEmpty()) { if (isEmsAvailable) { if (!session.useExtendedMasterSecret) { // perform full handshake instead diff --git a/src/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java b/src/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java index 1f63301e57f..49f5a90254b 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java +++ b/src/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java @@ -253,7 +253,7 @@ public byte[] encode() { static { String property = GetPropertyAction.privilegedGetProperty( "jdk.tls.ephemeralDHKeySize"); - if (property == null || property.length() == 0) { + if (property == null || property.isEmpty()) { useLegacyEphemeralDHKeys = false; useSmartEphemeralDHKeys = false; customizedDHKeySize = -1; diff --git a/src/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java b/src/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java index a6604a25017..2a90bc63fb9 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java +++ b/src/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java @@ -239,9 +239,8 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length, fragLen = Record.maxDataSize; } - if (fragmentSize > 0) { - fragLen = Math.min(fragLen, fragmentSize); - } + // Calculate more impact, for example TLS 1.3 padding. + fragLen = calculateFragmentSize(fragLen); int dstPos = destination.position(); int dstLim = destination.limit(); @@ -459,9 +458,8 @@ Ciphertext acquireCiphertext(ByteBuffer dstBuf) throws IOException { fragLen = Record.maxDataSize; } - if (fragmentSize > 0) { - fragLen = Math.min(fragLen, fragmentSize); - } + // Calculate more impact, for example TLS 1.3 padding. + fragLen = calculateFragmentSize(fragLen); int dstPos = dstBuf.position(); int dstLim = dstBuf.limit(); diff --git a/src/src/java.base/share/classes/sun/security/ssl/Finished.java b/src/src/java.base/share/classes/sun/security/ssl/Finished.java index f53bd4986d7..aabf09a290f 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/Finished.java +++ b/src/src/java.base/share/classes/sun/security/ssl/Finished.java @@ -40,6 +40,10 @@ import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import javax.net.ssl.SSLPeerUnverifiedException; + +import jdk.internal.event.EventHelper; +import jdk.internal.event.TLSHandshakeEvent; import sun.security.internal.spec.TlsPrfParameterSpec; import sun.security.ssl.CipherSuite.HashAlg; import static sun.security.ssl.CipherSuite.HashAlg.H_NONE; @@ -547,6 +551,7 @@ private void onConsumeFinished(ClientHandshakeContext chc, // handshake context cleanup. chc.handshakeFinished = true; + recordEvent(chc.conContext.conSession); // May need to retransmit the last flight for DTLS. if (!chc.sslContext.isDTLS()) { @@ -596,6 +601,7 @@ private void onConsumeFinished(ServerHandshakeContext shc, // handshake context cleanup. shc.handshakeFinished = true; + recordEvent(shc.conContext.conSession); // May need to retransmit the last flight for DTLS. if (!shc.sslContext.isDTLS()) { @@ -734,6 +740,8 @@ private byte[] onProduceFinished(ClientHandshakeContext chc, // handshake context cleanup. chc.handshakeFinished = true; chc.conContext.finishHandshake(); + recordEvent(chc.conContext.conSession); + // The handshake message has been delivered. return null; @@ -1081,6 +1089,7 @@ private void onConsumeFinished(ServerHandshakeContext shc, if (!shc.sslContext.isDTLS()) { shc.conContext.finishHandshake(); } + recordEvent(shc.conContext.conSession); // // produce @@ -1092,4 +1101,35 @@ private void onConsumeFinished(ServerHandshakeContext shc, } } + + private static void recordEvent(SSLSessionImpl session) { + TLSHandshakeEvent event = new TLSHandshakeEvent(); + if (event.shouldCommit() || EventHelper.isLoggingSecurity()) { + int peerCertificateId = 0; + try { + // use hash code for Id + peerCertificateId = session + .getCertificateChain()[0] + .hashCode(); + } catch (SSLPeerUnverifiedException e) { + // not verified msg + } + if (event.shouldCommit()) { + event.peerHost = session.getPeerHost(); + event.peerPort = session.getPeerPort(); + event.cipherSuite = session.getCipherSuite(); + event.protocolVersion = session.getProtocol(); + event.certificateId = peerCertificateId; + event.commit(); + } + if (EventHelper.isLoggingSecurity()) { + EventHelper.logTLSHandshakeEvent(null, + session.getPeerHost(), + session.getPeerPort(), + session.getCipherSuite(), + session.getProtocol(), + peerCertificateId); + } + } + } } diff --git a/src/src/java.base/share/classes/sun/security/ssl/OutputRecord.java b/src/src/java.base/share/classes/sun/security/ssl/OutputRecord.java index a340cfe80ee..e0f01208327 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/OutputRecord.java +++ b/src/src/java.base/share/classes/sun/security/ssl/OutputRecord.java @@ -63,7 +63,7 @@ abstract class OutputRecord int packetSize; // fragment size - int fragmentSize; + private int fragmentSize; // closed or not? volatile boolean isClosed; @@ -245,6 +245,24 @@ boolean isClosed() { // shared helpers // + private static final class T13PaddingHolder { + private static final byte[] zeros = new byte[16]; + } + + int calculateFragmentSize(int fragmentLimit) { + if (fragmentSize > 0) { + fragmentLimit = Math.min(fragmentLimit, fragmentSize); + } + + if (protocolVersion.useTLS13PlusSpec()) { + // No negative integer checking as the fragment capacity should + // have been ensured. + return fragmentLimit - T13PaddingHolder.zeros.length - 1; + } + + return fragmentLimit; + } + // Encrypt a fragment and wrap up a record. // // To be consistent with the spec of SSLEngine.wrap() methods, the @@ -326,8 +344,12 @@ private static long t13Encrypt( if (!encCipher.isNullCipher()) { // inner plaintext, using zero length padding. int endOfPt = destination.limit(); - destination.limit(endOfPt + 1); - destination.put(endOfPt, contentType); + int startOfPt = destination.position(); + destination.position(endOfPt); + destination.limit(endOfPt + 1 + T13PaddingHolder.zeros.length); + destination.put(contentType); + destination.put(T13PaddingHolder.zeros); + destination.position(startOfPt); } // use the right TLSCiphertext.opaque_type and legacy_record_version @@ -395,10 +417,6 @@ long encrypt( } } - private static final class T13PaddingHolder { - private static final byte[] zeros = new byte[16]; - } - private long t13Encrypt( SSLWriteCipher encCipher, byte contentType, int headerSize) { if (!encCipher.isNullCipher()) { diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java b/src/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java index dc206d07398..f6d1e3575af 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java @@ -237,7 +237,7 @@ private static class SupportedSignatureAlgorithmConstraints public boolean permits(Set primitives, String algorithm, AlgorithmParameters parameters) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException( "No algorithm name specified"); } @@ -276,7 +276,7 @@ public final boolean permits(Set primitives, Key key) { public final boolean permits(Set primitives, String algorithm, Key key, AlgorithmParameters parameters) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException( "No algorithm name specified"); } diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLCipher.java b/src/src/java.base/share/classes/sun/security/ssl/SSLCipher.java index 338c4ac994f..13917d2fa5c 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLCipher.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLCipher.java @@ -31,6 +31,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Key; +import java.security.NoSuchAlgorithmException; import java.security.PrivilegedAction; import java.security.SecureRandom; import java.security.Security; @@ -465,16 +466,31 @@ private SSLCipher(String transformation, // availability of this bulk cipher // - // We assume all supported ciphers are always available since they are - // shipped with the SunJCE provider. However, AES/256 is unavailable - // when the default JCE policy jurisdiction files are installed because - // of key length restrictions. - this.isAvailable = allowed && isUnlimited(keySize, transformation); + // AES/256 is unavailable when the default JCE policy jurisdiction files + // are installed because of key length restrictions. + this.isAvailable = allowed && isUnlimited(keySize, transformation) && + isTransformationAvailable(transformation); this.readCipherGenerators = readCipherGenerators; this.writeCipherGenerators = writeCipherGenerators; } + private static boolean isTransformationAvailable(String transformation) { + if (transformation.equals("NULL")) { + return true; + } + try { + JsseJce.getCipher(transformation); + return true; + } catch (NoSuchAlgorithmException e) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.fine("Transformation " + transformation + " is" + + " not available."); + } + } + return false; + } + SSLReadCipher createReadCipher(Authenticator authenticator, ProtocolVersion protocolVersion, SecretKey key, IvParameterSpec iv, diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/src/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 79cda60cc0c..7dd7bfa6e73 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -387,7 +387,8 @@ private static List getApplicableCipherSuites( boolean isSupported = false; for (ProtocolVersion protocol : protocols) { - if (!suite.supports(protocol)) { + if (!suite.supports(protocol) || + !suite.bulkCipher.isAvailable()) { continue; } @@ -428,7 +429,7 @@ private static Collection getCustomizedCipherSuites( "System property " + propertyName + " is set to '" + property + "'"); } - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { // remove double quote marks from beginning/end of the property if (property.length() > 1 && property.charAt(0) == '"' && property.charAt(property.length() - 1) == '"') { @@ -436,7 +437,7 @@ private static Collection getCustomizedCipherSuites( } } - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { String[] cipherSuiteNames = property.split(","); Collection cipherSuites = new ArrayList<>(cipherSuiteNames.length); @@ -837,7 +838,7 @@ private static void populate(String propname, return; } - if (property.length() != 0) { + if (!property.isEmpty()) { // remove double quote marks from beginning/end of the property if (property.length() > 1 && property.charAt(0) == '"' && property.charAt(property.length() - 1) == '"') { @@ -845,7 +846,7 @@ private static void populate(String propname, } } - if (property.length() != 0) { + if (!property.isEmpty()) { String[] protocols = property.split(","); for (int i = 0; i < protocols.length; i++) { protocols[i] = protocols[i].trim(); @@ -1101,7 +1102,7 @@ public Object run() throws Exception { KeyStore ks = null; char[] passwd = null; try { - if (defaultKeyStore.length() != 0 && + if (!defaultKeyStore.isEmpty() && !NONE.equals(defaultKeyStore)) { fs = AccessController.doPrivileged( new PrivilegedExceptionAction() { @@ -1113,7 +1114,7 @@ public FileInputStream run() throws Exception { } String defaultKeyStorePassword = props.get("keyStorePasswd"); - if (defaultKeyStorePassword.length() != 0) { + if (!defaultKeyStorePassword.isEmpty()) { passwd = defaultKeyStorePassword.toCharArray(); } @@ -1124,7 +1125,7 @@ public FileInputStream run() throws Exception { if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) { SSLLogger.finest("init keystore"); } - if (defaultKeyStoreProvider.length() == 0) { + if (defaultKeyStoreProvider.isEmpty()) { ks = KeyStore.getInstance(defaultKeyStoreType); } else { ks = KeyStore.getInstance(defaultKeyStoreType, @@ -1539,7 +1540,7 @@ private void checkAdditionalTrust(X509Certificate[] chain, // check endpoint identity String identityAlg = sslSocket.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { X509TrustManagerImpl.checkIdentity(session, chain, identityAlg, checkClientTrusted); } @@ -1579,7 +1580,7 @@ private void checkAdditionalTrust(X509Certificate[] chain, // check endpoint identity String identityAlg = engine.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { X509TrustManagerImpl.checkIdentity(session, chain, identityAlg, checkClientTrusted); } diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java b/src/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java index 45621f3233c..ee82d2743a3 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java @@ -232,9 +232,8 @@ private Ciphertext encode(ByteBuffer[] sources, int offset, int length, fragLen = Record.maxDataSize; } - if (fragmentSize > 0) { - fragLen = Math.min(fragLen, fragmentSize); - } + // Calculate more impact, for example TLS 1.3 padding. + fragLen = calculateFragmentSize(fragLen); } int dstPos = destination.position(); @@ -439,9 +438,8 @@ Ciphertext acquireCiphertext(ByteBuffer dstBuf) throws IOException { fragLen = Record.maxDataSize; } - if (fragmentSize > 0) { - fragLen = Math.min(fragLen, fragmentSize); - } + // Calculate more impact, for example TLS 1.3 padding. + fragLen = calculateFragmentSize(fragLen); int dstPos = dstBuf.position(); int dstLim = dstBuf.limit(); diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java b/src/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java index b7754478ae9..08966a7160b 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLSessionContextImpl.java @@ -31,10 +31,14 @@ import java.util.Locale; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSessionContext; + +import sun.security.action.GetIntegerAction; import sun.security.util.Cache; final class SSLSessionContextImpl implements SSLSessionContext { + private final static int DEFAULT_MAX_CACHE_SIZE = 20480; + private final Cache sessionCache; // session cache, session id as key private final Cache sessionHostPortCache; @@ -194,22 +198,29 @@ void remove(SessionId key) { } private static int getDefaultCacheLimit() { - int defaultCacheLimit = 0; try { - String s = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - @Override - public String run() { - return System.getProperty( - "javax.net.ssl.sessionCacheSize"); - } - }); - defaultCacheLimit = (s != null) ? Integer.parseInt(s) : 0; + int defaultCacheLimit = GetIntegerAction.privilegedGetProperty( + "javax.net.ssl.sessionCacheSize", DEFAULT_MAX_CACHE_SIZE); + + if (defaultCacheLimit >= 0) { + return defaultCacheLimit; + } else if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.warning( + "invalid System Property javax.net.ssl.sessionCacheSize, " + + "use the default session cache size (" + + DEFAULT_MAX_CACHE_SIZE + ") instead"); + } } catch (Exception e) { - // swallow the exception + // unlikely, log it for safe + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.warning( + "the System Property javax.net.ssl.sessionCacheSize is " + + "not available, use the default value (" + + DEFAULT_MAX_CACHE_SIZE + ") instead"); + } } - return (defaultCacheLimit > 0) ? defaultCacheLimit : 0; + return DEFAULT_MAX_CACHE_SIZE; } private boolean isTimedout(SSLSession sess) { diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java index 3f074ea3aa0..0d85bc7d87d 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java @@ -878,7 +878,7 @@ public void close() throws IOException { } try { - shutdownInput(false); + SSLSocketImpl.this.close(); } catch (IOException ioe) { // ignore the exception if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { @@ -1003,7 +1003,7 @@ public void close() throws IOException { } try { - shutdownOutput(); + SSLSocketImpl.this.close(); } catch (IOException ioe) { // ignore the exception if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { @@ -1204,7 +1204,7 @@ private void tryKeyUpdate() throws IOException { synchronized void doneConnect() throws IOException { // In server mode, it is not necessary to set host and serverNames. // Otherwise, would require a reverse DNS lookup to get the hostname. - if ((peerHost == null) || (peerHost.length() == 0)) { + if (peerHost == null || peerHost.isEmpty()) { boolean useNameService = trustNameService && conContext.sslConfig.isClientMode; useImplicitHost(useNameService); @@ -1239,8 +1239,7 @@ private void useImplicitHost(boolean useNameService) { JavaNetInetAddressAccess jna = SharedSecrets.getJavaNetInetAddressAccess(); String originalHostname = jna.getOriginalHostName(inetAddress); - if ((originalHostname != null) && - (originalHostname.length() != 0)) { + if (originalHostname != null && !originalHostname.isEmpty()) { this.peerHost = originalHostname; if (conContext.sslConfig.serverNames.isEmpty() && diff --git a/src/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java b/src/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java index 2eff804cfe1..23205061e5f 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java @@ -290,9 +290,8 @@ synchronized void deliver( fragLen = Record.maxDataSize; } - if (fragmentSize > 0) { - fragLen = Math.min(fragLen, fragmentSize); - } + // Calculate more impact, for example TLS 1.3 padding. + fragLen = calculateFragmentSize(fragLen); if (isFirstRecordOfThePayload && needToSplitPayload()) { fragLen = 1; @@ -382,9 +381,8 @@ private int getFragLimit() { fragLimit = Record.maxDataSize; } - if (fragmentSize > 0) { - fragLimit = Math.min(fragLimit, fragmentSize); - } + // Calculate more impact, for example TLS 1.3 padding. + fragLimit = calculateFragmentSize(fragLimit); return fragLimit; } diff --git a/src/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java b/src/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java index 19c9b55fba8..377be7ab146 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java @@ -42,6 +42,7 @@ import sun.security.ssl.SupportedGroupsExtension.NamedGroup; import sun.security.ssl.SupportedGroupsExtension.NamedGroupType; import sun.security.util.KeyUtil; +import sun.security.util.SignatureUtil; enum SignatureScheme { // EdDSA algorithms @@ -468,16 +469,11 @@ Signature getSignature(Key key) throws NoSuchAlgorithmException, Signature signer = JsseJce.getSignature(algorithm); if (key instanceof PublicKey) { - signer.initVerify((PublicKey)(key)); + SignatureUtil.initVerifyWithParam(signer, (PublicKey)key, + signAlgParameter); } else { - signer.initSign((PrivateKey)key); - } - - // Important note: Please don't set the parameters before signature - // or verification initialization, so that the crypto provider can - // be selected properly. - if (signAlgParameter != null) { - signer.setParameter(signAlgParameter); + SignatureUtil.initSignWithParam(signer, (PrivateKey)key, + signAlgParameter, null); } return signer; diff --git a/src/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java b/src/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java index 565b60fac80..df21c4f8215 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java +++ b/src/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java @@ -483,7 +483,7 @@ static class SupportedGroups { // default groups and preferences will be used. String property = GetPropertyAction .privilegedGetProperty("jdk.tls.namedGroups"); - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { // remove double quote marks from beginning/end of the property if (property.length() > 1 && property.charAt(0) == '"' && property.charAt(property.length() - 1) == '"') { @@ -492,7 +492,7 @@ static class SupportedGroups { } ArrayList groupList; - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { String[] groups = property.split(","); groupList = new ArrayList<>(groups.length); for (String group : groups) { @@ -521,12 +521,6 @@ static class SupportedGroups { NamedGroup.SECP256_R1, NamedGroup.SECP384_R1, NamedGroup.SECP521_R1, - NamedGroup.SECT283_K1, - NamedGroup.SECT283_R1, - NamedGroup.SECT409_K1, - NamedGroup.SECT409_R1, - NamedGroup.SECT571_K1, - NamedGroup.SECT571_R1, // FFDHE 2048 NamedGroup.FFDHE_2048, @@ -541,15 +535,6 @@ static class SupportedGroups { NamedGroup.SECP256_R1, NamedGroup.SECP384_R1, NamedGroup.SECP521_R1, - NamedGroup.SECT283_K1, - NamedGroup.SECT283_R1, - NamedGroup.SECT409_K1, - NamedGroup.SECT409_R1, - NamedGroup.SECT571_K1, - NamedGroup.SECT571_R1, - - // non-NIST curves - NamedGroup.SECP256_K1, // FFDHE 2048 NamedGroup.FFDHE_2048, diff --git a/src/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java b/src/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java index 495dc3d6531..3fa58757c9b 100644 --- a/src/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java +++ b/src/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java @@ -148,7 +148,7 @@ private Validator checkTrustedInit(X509Certificate[] chain, "null or zero-length certificate chain"); } - if (authType == null || authType.length() == 0) { + if (authType == null || authType.isEmpty()) { throw new IllegalArgumentException( "null or zero-length authentication type"); } @@ -225,7 +225,7 @@ private void checkTrusted(X509Certificate[] chain, // check endpoint identity String identityAlg = sslSocket.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { checkIdentity(session, trustedChain, identityAlg, checkClientTrusted); } @@ -279,7 +279,7 @@ private void checkTrusted(X509Certificate[] chain, // check endpoint identity String identityAlg = engine.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { checkIdentity(session, trustedChain, identityAlg, checkClientTrusted); } @@ -444,7 +444,7 @@ static void checkIdentity(String hostname, X509Certificate cert, private static void checkIdentity(String hostname, X509Certificate cert, String algorithm, boolean chainsToPublicCA) throws CertificateException { - if (algorithm != null && algorithm.length() != 0) { + if (algorithm != null && !algorithm.isEmpty()) { // if IPv6 strip off the "[]" if ((hostname != null) && hostname.startsWith("[") && hostname.endsWith("]")) { diff --git a/src/src/java.base/share/classes/sun/security/tools/PathList.java b/src/src/java.base/share/classes/sun/security/tools/PathList.java index 1bd9cb76e41..69caeaf90f9 100644 --- a/src/src/java.base/share/classes/sun/security/tools/PathList.java +++ b/src/src/java.base/share/classes/sun/security/tools/PathList.java @@ -46,9 +46,9 @@ public class PathList { * @return the resulting path */ public static String appendPath(String pathTo, String pathFrom) { - if (pathTo == null || pathTo.length() == 0) { + if (pathTo == null || pathTo.isEmpty()) { return pathFrom; - } else if (pathFrom == null || pathFrom.length() == 0) { + } else if (pathFrom == null || pathFrom.isEmpty()) { return pathTo; } else { return pathTo + File.pathSeparator + pathFrom; diff --git a/src/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java b/src/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java index 85037622c1b..743e550ee13 100644 --- a/src/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java +++ b/src/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -30,12 +30,12 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateEncodingException; import java.security.*; +import java.security.spec.AlgorithmParameterSpec; import java.util.Date; import sun.security.pkcs10.PKCS10; import sun.security.x509.*; - /** * Generate a pair of keys, and provide access to them. This class is * provided primarily for ease of use. @@ -123,6 +123,21 @@ public void setRandom (SecureRandom generator) // want "public void generate (X509Certificate)" ... inherit DSA/D-H param + public void generate(int keyBits) { + if (keyBits != -1) { + try { + if (prng == null) { + prng = new SecureRandom(); + } + keyGen.initialize(keyBits, prng); + + } catch (Exception e) { + throw new IllegalArgumentException(e.getMessage()); + } + } + generateInternal(); + } + /** * Generates a random public/private key pair, with a given key * size. Different algorithms provide different degrees of security @@ -140,21 +155,8 @@ public void setRandom (SecureRandom generator) * @exception InvalidKeyException if the environment does not * provide X.509 public keys for this signature algorithm. */ - public void generate (int keyBits) - throws InvalidKeyException - { - KeyPair pair; - - try { - if (prng == null) { - prng = new SecureRandom(); - } - keyGen.initialize(keyBits, prng); - pair = keyGen.generateKeyPair(); - - } catch (Exception e) { - throw new IllegalArgumentException(e.getMessage()); - } + public void generateInternal() { + KeyPair pair = keyGen.generateKeyPair(); publicKey = pair.getPublic(); privateKey = pair.getPrivate(); @@ -262,12 +264,14 @@ public X509Certificate getSelfCertificate (X500Name myname, Date firstDate, new CertificateValidity(firstDate,lastDate); X509CertInfo info = new X509CertInfo(); + AlgorithmParameterSpec params = AlgorithmId + .getDefaultAlgorithmParameterSpec(sigAlg, privateKey); // Add all mandatory attributes info.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V3)); info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber( new java.util.Random().nextInt() & 0x7fffffff)); - AlgorithmId algID = AlgorithmId.get(sigAlg); + AlgorithmId algID = AlgorithmId.getWithParameterSpec(sigAlg, params); info.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algID)); info.set(X509CertInfo.SUBJECT, myname); @@ -277,13 +281,19 @@ public X509Certificate getSelfCertificate (X500Name myname, Date firstDate, if (ext != null) info.set(X509CertInfo.EXTENSIONS, ext); cert = new X509CertImpl(info); - cert.sign(privateKey, this.sigAlg); + cert.sign(privateKey, + params, + sigAlg, + null); return (X509Certificate)cert; } catch (IOException e) { throw new CertificateEncodingException("getSelfCert: " + e.getMessage()); + } catch (InvalidAlgorithmParameterException e2) { + throw new SignatureException( + "Unsupported PSSParameterSpec: " + e2.getMessage()); } } @@ -309,6 +319,7 @@ public X509Certificate getSelfCertificate (X500Name myname, long validity) * @exception InvalidKeyException on key handling errors. * @exception SignatureException on signature handling errors. */ + // This method is not used inside JDK. Will not update it. public PKCS10 getCertRequest (X500Name myname) throws InvalidKeyException, SignatureException { diff --git a/src/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/src/java.base/share/classes/sun/security/tools/keytool/Main.java index f3e8d4c0bc4..6b46c155fa8 100644 --- a/src/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -49,7 +49,7 @@ import java.security.cert.CertificateException; import java.security.cert.URICertStoreParameters; - +import java.security.spec.AlgorithmParameterSpec; import java.text.Collator; import java.text.MessageFormat; import java.util.*; @@ -75,6 +75,7 @@ import sun.security.provider.certpath.ssl.SSLServerCertStore; import sun.security.util.Password; import sun.security.util.SecurityProviderConstants; +import sun.security.util.SignatureUtil; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; @@ -1406,17 +1407,20 @@ private void doGenCert(String alias, String sigAlgName, InputStream in, PrintStr sigAlgName = getCompatibleSigAlgName(privateKey); } Signature signature = Signature.getInstance(sigAlgName); - signature.initSign(privateKey); + AlgorithmParameterSpec params = AlgorithmId + .getDefaultAlgorithmParameterSpec(sigAlgName, privateKey); + + SignatureUtil.initSignWithParam(signature, privateKey, params, null); X509CertInfo info = new X509CertInfo(); + AlgorithmId algID = AlgorithmId.getWithParameterSpec(sigAlgName, params); info.set(X509CertInfo.VALIDITY, interval); info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber( new java.util.Random().nextInt() & 0x7fffffff)); info.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V3)); info.set(X509CertInfo.ALGORITHM_ID, - new CertificateAlgorithmId( - AlgorithmId.get(sigAlgName))); + new CertificateAlgorithmId(algID)); info.set(X509CertInfo.ISSUER, issuer); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); @@ -1460,7 +1464,7 @@ private void doGenCert(String alias, String sigAlgName, InputStream in, PrintStr signerCert.getPublicKey()); info.set(X509CertInfo.EXTENSIONS, ext); X509CertImpl cert = new X509CertImpl(info); - cert.sign(privateKey, sigAlgName); + cert.sign(privateKey, params, sigAlgName, null); dumpCert(cert, out); for (Certificate ca: keyStore.getCertificateChain(alias)) { if (ca instanceof X509Certificate) { @@ -1562,7 +1566,10 @@ private void doCertReq(String alias, String sigAlgName, PrintStream out) } Signature signature = Signature.getInstance(sigAlgName); - signature.initSign(privKey); + AlgorithmParameterSpec params = AlgorithmId + .getDefaultAlgorithmParameterSpec(sigAlgName, privKey); + SignatureUtil.initSignWithParam(signature, privKey, params, null); + X500Name subject = dname == null? new X500Name(((X509Certificate)cert).getSubjectDN().toString()): new X500Name(dname); @@ -2866,7 +2873,9 @@ private void doSelfCert(String alias, String dname, String sigAlgName) // other solution: We first sign the cert, then retrieve the // outer sigalg and use it to set the inner sigalg X509CertImpl newCert = new X509CertImpl(certInfo); - newCert.sign(privKey, sigAlgName); + AlgorithmParameterSpec params = AlgorithmId + .getDefaultAlgorithmParameterSpec(sigAlgName, privKey); + newCert.sign(privKey, params, sigAlgName, null); AlgorithmId sigAlgid = (AlgorithmId)newCert.get(X509CertImpl.SIG_ALG); certInfo.set(CertificateAlgorithmId.NAME + "." + CertificateAlgorithmId.ALGORITHM, sigAlgid); @@ -2883,7 +2892,7 @@ private void doSelfCert(String alias, String dname, String sigAlgName) certInfo.set(X509CertInfo.EXTENSIONS, ext); // Sign the new certificate newCert = new X509CertImpl(certInfo); - newCert.sign(privKey, sigAlgName); + newCert.sign(privKey, params, sigAlgName, null); // Store the new certificate as a single-element certificate chain keyStore.setKeyEntry(alias, privKey, diff --git a/src/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java b/src/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java index 2f7bc0c16af..bc021411f0c 100644 --- a/src/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java +++ b/src/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java @@ -75,7 +75,7 @@ public String run() { static boolean checkAlgorithm(String[] algorithms, String algorithm, AlgorithmDecomposer decomposer) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException("No algorithm name specified"); } diff --git a/src/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java b/src/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java index 4e1e6241dc5..ee97d461ac1 100644 --- a/src/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java +++ b/src/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java @@ -80,7 +80,7 @@ private static Set decomposeImpl(String algorithm) { * Please override the method if need to support more name pattern. */ public Set decompose(String algorithm) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { return new HashSet<>(); } @@ -167,7 +167,7 @@ private static void hasLoop(Set elements, String find, String replace) { * message digest algorithm name to avoid overly complicated checking. */ public static Set decomposeOneHash(String algorithm) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { return new HashSet<>(); } diff --git a/src/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/src/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java index 4c50289532e..60699404070 100644 --- a/src/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java +++ b/src/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java @@ -135,7 +135,7 @@ public final boolean permits(Set primitives, Key key) { public final boolean permits(Set primitives, String algorithm, Key key, AlgorithmParameters parameters) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException("No algorithm name specified"); } @@ -188,7 +188,7 @@ private boolean checkConstraints(Set primitives, } // check the signature algorithm with parameters - if (algorithm != null && algorithm.length() != 0) { + if (algorithm != null && !algorithm.isEmpty()) { if (!permits(primitives, algorithm, parameters)) { return false; } diff --git a/src/src/java.base/share/classes/sun/security/util/FilePermCompat.java b/src/src/java.base/share/classes/sun/security/util/FilePermCompat.java index b427e05e2e8..c3e1f8ef5df 100644 --- a/src/src/java.base/share/classes/sun/security/util/FilePermCompat.java +++ b/src/src/java.base/share/classes/sun/security/util/FilePermCompat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -42,8 +42,11 @@ public class FilePermCompat { public static final boolean compat; static { - String flag = GetPropertyAction.privilegedGetProperty( - "jdk.io.permissionsUseCanonicalPath", "false"); + String flag = SecurityProperties.privilegedGetOverridable( + "jdk.io.permissionsUseCanonicalPath"); + if (flag == null) { + flag = "false"; + } switch (flag) { case "true": nb = false; diff --git a/src/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java b/src/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java new file mode 100644 index 00000000000..89711e83b17 --- /dev/null +++ b/src/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.security.util; + +import java.io.File; +import java.io.FilePermission; +import java.io.IOException; +import java.net.URL; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.util.Enumeration; + +/** + * This {@code PermissionCollection} implementation delegates to another + * {@code PermissionCollection}, taking care to lazily add the permission needed + * to read from the given {@code CodeSource} at first use, i.e., when either of + * {@link #elements}, {@link #implies} or {@link #toString} is called, or when + * the collection is serialized. + */ +public final class LazyCodeSourcePermissionCollection + extends PermissionCollection +{ + private static final long serialVersionUID = -6727011328946861783L; + private final PermissionCollection perms; + private final CodeSource cs; + private volatile boolean permissionAdded; + + public LazyCodeSourcePermissionCollection(PermissionCollection perms, + CodeSource cs) { + this.perms = perms; + this.cs = cs; + } + + private void ensureAdded() { + if (!permissionAdded) { + synchronized(perms) { + if (permissionAdded) + return; + + // open connection to determine the permission needed + URL location = cs.getLocation(); + if (location != null) { + try { + Permission p = location.openConnection().getPermission(); + if (p != null) { + // for directories then need recursive access + if (p instanceof FilePermission) { + String path = p.getName(); + if (path.endsWith(File.separator)) { + path += "-"; + p = new FilePermission(path, + SecurityConstants.FILE_READ_ACTION); + } + } + perms.add(p); + } + } catch (IOException ioe) { + } + } + if (isReadOnly()) { + perms.setReadOnly(); + } + permissionAdded = true; + } + } + } + + @Override + public void add(Permission permission) { + if (isReadOnly()) + throw new SecurityException( + "attempt to add a Permission to a readonly PermissionCollection"); + perms.add(permission); + } + + @Override + public boolean implies(Permission permission) { + ensureAdded(); + return perms.implies(permission); + } + + @Override + public Enumeration elements() { + ensureAdded(); + return perms.elements(); + } + + @Override + public String toString() { + ensureAdded(); + return perms.toString(); + } + + /** + * On serialization, initialize and replace with the underlying + * permissions. This removes the laziness on deserialization. + */ + private Object writeReplace() { + ensureAdded(); + return perms; + } +} diff --git a/src/src/java.base/share/classes/sun/security/util/SecurityConstants.java b/src/src/java.base/share/classes/sun/security/util/SecurityConstants.java index ae935a66562..a13181b37a5 100644 --- a/src/src/java.base/share/classes/sun/security/util/SecurityConstants.java +++ b/src/src/java.base/share/classes/sun/security/util/SecurityConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -97,6 +97,10 @@ private SecurityConstants () { public static final NetPermission GET_RESPONSECACHE_PERMISSION = new NetPermission("getResponseCache"); + // java.net.ServerSocket, java.net.Socket + public static final NetPermission SET_SOCKETIMPL_PERMISSION = + new NetPermission("setSocketImpl"); + // java.lang.SecurityManager, sun.applet.AppletPanel public static final RuntimePermission CREATE_CLASSLOADER_PERMISSION = new RuntimePermission("createClassLoader"); diff --git a/src/src/java.base/share/classes/sun/security/util/SecurityProperties.java b/src/src/java.base/share/classes/sun/security/util/SecurityProperties.java new file mode 100644 index 00000000000..7a1ca6a250f --- /dev/null +++ b/src/src/java.base/share/classes/sun/security/util/SecurityProperties.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.security.util; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.Security; + +public class SecurityProperties { + + /** + * Returns the value of the security property propName, which can be overridden + * by a system property of the same name + * + * @param propName the name of the system or security property + * @return the value of the system or security property + */ + public static String privilegedGetOverridable(String propName) { + if (System.getSecurityManager() == null) { + return getOverridableProperty(propName); + } else { + return AccessController.doPrivileged((PrivilegedAction) () -> getOverridableProperty(propName)); + } + } + + private static String getOverridableProperty(String propName) { + String val = System.getProperty(propName); + if (val == null) { + return Security.getProperty(propName); + } else { + return val; + } + } + + /** + * Returns true in case the system or security property "jdk.includeInExceptions" + * contains the category refName + * + * @param refName the category to check + * @return true in case the system or security property "jdk.includeInExceptions" + * contains refName, false otherwise + */ + public static boolean includedInExceptions(String refName) { + String val = privilegedGetOverridable("jdk.includeInExceptions"); + if (val == null) { + return false; + } + + String[] tokens = val.split(","); + for (String token : tokens) { + token = token.trim(); + if (token.equalsIgnoreCase(refName)) { + return true; + } + } + return false; + } +} diff --git a/src/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index 35b06aa554c..4342c655cee 100644 --- a/src/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/src/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java @@ -423,7 +423,7 @@ String getWeakAlgorithms(String header) { // This means we have an error in finding weak algorithms, run in // debug mode to see permittedAlgs map's values. - if (w.length() == 0) { + if (w.isEmpty()) { return "Unknown Algorithm(s)"; } diff --git a/src/src/java.base/share/classes/sun/security/util/SignatureUtil.java b/src/src/java.base/share/classes/sun/security/util/SignatureUtil.java index 2d85566e48d..1b7fcb3f765 100644 --- a/src/src/java.base/share/classes/sun/security/util/SignatureUtil.java +++ b/src/src/java.base/share/classes/sun/security/util/SignatureUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -28,9 +28,8 @@ import java.io.IOException; import java.security.*; import java.security.spec.*; -import sun.security.util.ObjectIdentifier; -import sun.security.x509.AlgorithmId; import sun.security.rsa.RSAUtil; +import jdk.internal.misc.SharedSecrets; /** * Utility class for Signature related operations. Currently used by various @@ -41,12 +40,25 @@ */ public class SignatureUtil { + private static String checkName(String algName) throws ProviderException { + if (algName.indexOf(".") == -1) { + return algName; + } + // convert oid to String + try { + return Signature.getInstance(algName).getAlgorithm(); + } catch (Exception e) { + throw new ProviderException("Error mapping algorithm name", e); + } + } + // Utility method of creating an AlgorithmParameters object with // the specified algorithm name and encoding private static AlgorithmParameters createAlgorithmParameters(String algName, byte[] paramBytes) throws ProviderException { try { + algName = checkName(algName); AlgorithmParameters result = AlgorithmParameters.getInstance(algName); result.init(paramBytes); @@ -56,60 +68,81 @@ private static AlgorithmParameters createAlgorithmParameters(String algName, } } - private static AlgorithmParameterSpec getParamSpec(String sigName, + // Utility method for converting the specified AlgorithmParameters object + // into an AlgorithmParameterSpec object. + public static AlgorithmParameterSpec getParamSpec(String sigName, AlgorithmParameters params) - throws InvalidAlgorithmParameterException, ProviderException { + throws ProviderException { - if (params == null) return null; - - if (sigName.toUpperCase().indexOf("RSA") == -1) { - throw new ProviderException - ("Unrecognized algorithm for signature parameters " + - sigName); - } - // AlgorithmParameters.getAlgorithm() may returns oid if it's - // created during DER decoding. Convert to use the standard name - // before passing it to RSAUtil - String alg = params.getAlgorithm(); - if (alg.equalsIgnoreCase(sigName) || alg.indexOf(".") != -1) { - try { - params = createAlgorithmParameters(sigName, - params.getEncoded()); - } catch (IOException e) { - throw new ProviderException(e); + sigName = checkName(sigName); + AlgorithmParameterSpec paramSpec = null; + if (params != null) { + if (sigName.toUpperCase().indexOf("RSA") == -1) { + throw new ProviderException + ("Unrecognized algorithm for signature parameters " + + sigName); + } + // AlgorithmParameters.getAlgorithm() may returns oid if it's + // created during DER decoding. Convert to use the standard name + // before passing it to RSAUtil + if (params.getAlgorithm().indexOf(".") != -1) { + try { + params = createAlgorithmParameters(sigName, + params.getEncoded()); + } catch (IOException e) { + throw new ProviderException(e); + } } + paramSpec = RSAUtil.getParamSpec(params); } - return RSAUtil.getParamSpec(params); + return paramSpec; } - // Special method for setting the specified parameter bytes into the - // specified Signature object as signature parameters. - public static void specialSetParameter(Signature sig, byte[] paramBytes) - throws InvalidAlgorithmParameterException, ProviderException { - - AlgorithmParameters params = null; + // Utility method for converting the specified parameter bytes into an + // AlgorithmParameterSpec object. + public static AlgorithmParameterSpec getParamSpec(String sigName, + byte[] paramBytes) + throws ProviderException { + sigName = checkName(sigName); + AlgorithmParameterSpec paramSpec = null; if (paramBytes != null) { - String sigName = sig.getAlgorithm(); - params = createAlgorithmParameters(sigName, paramBytes); + if (sigName.toUpperCase().indexOf("RSA") == -1) { + throw new ProviderException + ("Unrecognized algorithm for signature parameters " + + sigName); + } + AlgorithmParameters params = + createAlgorithmParameters(sigName, paramBytes); + paramSpec = RSAUtil.getParamSpec(params); } - specialSetParameter(sig, params); + return paramSpec; } - // Special method for setting the specified AlgorithmParameter object - // into the specified Signature object as signature parameters. - public static void specialSetParameter(Signature sig, - AlgorithmParameters params) - throws InvalidAlgorithmParameterException, ProviderException { + // Utility method for initializing the specified Signature object + // for verification with the specified key and params (may be null) + public static void initVerifyWithParam(Signature s, PublicKey key, + AlgorithmParameterSpec params) + throws ProviderException, InvalidAlgorithmParameterException, + InvalidKeyException { + SharedSecrets.getJavaSecuritySignatureAccess().initVerify(s, key, params); + } - String sigName = sig.getAlgorithm(); - if (params != null) { - sig.setParameter(getParamSpec(sigName, params)); - } else { - try { - sig.setParameter(null); - } catch (UnsupportedOperationException e) { - // ignore for maintaining backward compatibility - } - } + // Utility method for initializing the specified Signature object + // for verification with the specified Certificate and params (may be null) + public static void initVerifyWithParam(Signature s, + java.security.cert.Certificate cert, + AlgorithmParameterSpec params) + throws ProviderException, InvalidAlgorithmParameterException, + InvalidKeyException { + SharedSecrets.getJavaSecuritySignatureAccess().initVerify(s, cert, params); + } + + // Utility method for initializing the specified Signature object + // for signing with the specified key and params (may be null) + public static void initSignWithParam(Signature s, PrivateKey key, + AlgorithmParameterSpec params, SecureRandom sr) + throws ProviderException, InvalidAlgorithmParameterException, + InvalidKeyException { + SharedSecrets.getJavaSecuritySignatureAccess().initSign(s, key, params, sr); } } diff --git a/src/src/java.base/share/classes/sun/security/x509/AVA.java b/src/src/java.base/share/classes/sun/security/x509/AVA.java index 6ff24c9264d..0a3739845ff 100644 --- a/src/src/java.base/share/classes/sun/security/x509/AVA.java +++ b/src/src/java.base/share/classes/sun/security/x509/AVA.java @@ -1246,7 +1246,7 @@ private boolean isCompliant(int standard) { } boolean number = false; - if (keyword.length() != 0) { + if (!keyword.isEmpty()) { char ch = keyword.charAt(0); if ((ch >= '0') && (ch <= '9')) { number = true; @@ -1286,7 +1286,7 @@ static String getKeyword(ObjectIdentifier oid, int standard) { return ak.keyword; } } else { - if (keywordString.length() == 0) { + if (keywordString.isEmpty()) { throw new IllegalArgumentException("keyword cannot be empty"); } keywordString = keywordString.trim(); diff --git a/src/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/src/src/java.base/share/classes/sun/security/x509/AlgorithmId.java index ffb0974df8b..a7cbb465a22 100644 --- a/src/src/java.base/share/classes/sun/security/x509/AlgorithmId.java +++ b/src/src/java.base/share/classes/sun/security/x509/AlgorithmId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,14 @@ package sun.security.x509; import java.io.*; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.InvalidParameterSpecException; +import java.security.spec.MGF1ParameterSpec; +import java.security.spec.PSSParameterSpec; import java.util.*; import java.security.*; +import sun.security.rsa.PSSParameters; import sun.security.util.*; @@ -190,7 +195,12 @@ public void derEncode (OutputStream out) throws IOException { } else { bytes.putNull(); }*/ - bytes.putNull(); + if (algid.equals(RSASSA_PSS_oid)) { + // RFC 4055 3.3: when an RSASSA-PSS key does not require + // parameter validation, field is absent. + } else { + bytes.putNull(); + } } else { bytes.putDerValue(params); } @@ -689,6 +699,8 @@ private static HashMap computeOidTable() oid(1, 2, 840, 113549, 1, 1, 1); public static final ObjectIdentifier RSAES_OAEP_oid = oid(1, 2, 840, 113549, 1, 1, 7); + public static final ObjectIdentifier mgf1_oid = + oid(1, 2, 840, 113549, 1, 1, 8); public static final ObjectIdentifier RSASSA_PSS_oid = oid(1, 2, 840, 113549, 1, 1, 10); @@ -1054,6 +1066,81 @@ public static String getDefaultSigAlgForKey(PrivateKey k) { } } + // Most commonly used PSSParameterSpec and AlgorithmId + private static class PSSParamsHolder { + + final static PSSParameterSpec PSS_256_SPEC = new PSSParameterSpec( + "SHA-256", "MGF1", + new MGF1ParameterSpec("SHA-256"), + 32, PSSParameterSpec.TRAILER_FIELD_BC); + final static PSSParameterSpec PSS_384_SPEC = new PSSParameterSpec( + "SHA-384", "MGF1", + new MGF1ParameterSpec("SHA-384"), + 48, PSSParameterSpec.TRAILER_FIELD_BC); + final static PSSParameterSpec PSS_512_SPEC = new PSSParameterSpec( + "SHA-512", "MGF1", + new MGF1ParameterSpec("SHA-512"), + 64, PSSParameterSpec.TRAILER_FIELD_BC); + + final static AlgorithmId PSS_256_ID; + final static AlgorithmId PSS_384_ID; + final static AlgorithmId PSS_512_ID; + + static { + try { + PSS_256_ID = new AlgorithmId(RSASSA_PSS_oid, + new DerValue(PSSParameters.getEncoded(PSS_256_SPEC))); + PSS_384_ID = new AlgorithmId(RSASSA_PSS_oid, + new DerValue(PSSParameters.getEncoded(PSS_384_SPEC))); + PSS_512_ID = new AlgorithmId(RSASSA_PSS_oid, + new DerValue(PSSParameters.getEncoded(PSS_512_SPEC))); + } catch (IOException e) { + throw new AssertionError("Should not happen", e); + } + } + } + + public static AlgorithmId getWithParameterSpec(String algName, + AlgorithmParameterSpec spec) throws NoSuchAlgorithmException { + + if (spec == null) { + return AlgorithmId.get(algName); + } else if (spec == PSSParamsHolder.PSS_256_SPEC) { + return PSSParamsHolder.PSS_256_ID; + } else if (spec == PSSParamsHolder.PSS_384_SPEC) { + return PSSParamsHolder.PSS_384_ID; + } else if (spec == PSSParamsHolder.PSS_512_SPEC) { + return PSSParamsHolder.PSS_512_ID; + } else { + try { + AlgorithmParameters result = + AlgorithmParameters.getInstance(algName); + result.init(spec); + return get(result); + } catch (InvalidParameterSpecException | NoSuchAlgorithmException e) { + throw new ProviderException(e); + } + } + } + + public static PSSParameterSpec getDefaultAlgorithmParameterSpec( + String sigAlg, PrivateKey k) { + if (sigAlg.equalsIgnoreCase("RSASSA-PSS")) { + switch (ifcFfcStrength(KeyUtil.getKeySize(k))) { + case "SHA256": + return PSSParamsHolder.PSS_256_SPEC; + case "SHA384": + return PSSParamsHolder.PSS_384_SPEC; + case "SHA512": + return PSSParamsHolder.PSS_512_SPEC; + default: + throw new AssertionError("Should not happen"); + } + } else { + return null; + } + } + // Values from SP800-57 part 1 rev 4 tables 2 and 3 private static String ecStrength (int bitLength) { if (bitLength >= 512) { // 256 bits of strength diff --git a/src/src/java.base/share/classes/sun/security/x509/DNSName.java b/src/src/java.base/share/classes/sun/security/x509/DNSName.java index f0b8c27576a..5ddce75833b 100644 --- a/src/src/java.base/share/classes/sun/security/x509/DNSName.java +++ b/src/src/java.base/share/classes/sun/security/x509/DNSName.java @@ -72,7 +72,7 @@ public DNSName(DerValue derValue) throws IOException { * @throws IOException if the name is not a valid DNSName subjectAltName */ public DNSName(String name) throws IOException { - if (name == null || name.length() == 0) + if (name == null || name.isEmpty()) throw new IOException("DNSName must not be null or empty"); if (name.contains(" ")) throw new IOException("DNSName with blank components is not permitted"); diff --git a/src/src/java.base/share/classes/sun/security/x509/IPAddressName.java b/src/src/java.base/share/classes/sun/security/x509/IPAddressName.java index 50f045758be..f9451744059 100644 --- a/src/src/java.base/share/classes/sun/security/x509/IPAddressName.java +++ b/src/src/java.base/share/classes/sun/security/x509/IPAddressName.java @@ -125,7 +125,7 @@ public IPAddressName(byte[] address) throws IOException { */ public IPAddressName(String name) throws IOException { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IOException("IPAddress cannot be null or empty"); } if (name.charAt(name.length() - 1) == '/') { diff --git a/src/src/java.base/share/classes/sun/security/x509/RDN.java b/src/src/java.base/share/classes/sun/security/x509/RDN.java index 2ee060930db..f73dc813aa4 100644 --- a/src/src/java.base/share/classes/sun/security/x509/RDN.java +++ b/src/src/java.base/share/classes/sun/security/x509/RDN.java @@ -121,7 +121,7 @@ public RDN(String name, Map keywordMap) throws IOException { * Plus sign is a separator */ String avaString = name.substring(avaOffset, nextPlus); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } @@ -141,7 +141,7 @@ public RDN(String name, Map keywordMap) throws IOException { // parse last or only AVA String avaString = name.substring(avaOffset); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } AVA ava = new AVA(new StringReader(avaString), keywordMap); @@ -199,7 +199,7 @@ public RDN(String name, Map keywordMap) throws IOException { * Plus sign is a separator */ String avaString = name.substring(avaOffset, nextPlus); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } @@ -217,7 +217,7 @@ public RDN(String name, Map keywordMap) throws IOException { // parse last or only AVA String avaString = name.substring(avaOffset); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } AVA ava = new AVA(new StringReader(avaString), AVA.RFC2253, keywordMap); diff --git a/src/src/java.base/share/classes/sun/security/x509/RFC822Name.java b/src/src/java.base/share/classes/sun/security/x509/RFC822Name.java index 8644254e5b5..916b1beeecb 100644 --- a/src/src/java.base/share/classes/sun/security/x509/RFC822Name.java +++ b/src/src/java.base/share/classes/sun/security/x509/RFC822Name.java @@ -79,12 +79,12 @@ public RFC822Name(String name) throws IOException { * @throws IOException if name is not valid */ public void parseName(String name) throws IOException { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IOException("RFC822Name may not be null or empty"); } // See if domain is a valid domain name String domain = name.substring(name.indexOf('@')+1); - if (domain.length() == 0) { + if (domain.isEmpty()) { throw new IOException("RFC822Name may not end with @"); } else { //An RFC822 NameConstraint could start with a ., although diff --git a/src/src/java.base/share/classes/sun/security/x509/X500Name.java b/src/src/java.base/share/classes/sun/security/x509/X500Name.java index 6d5bf78cd9d..5d26140d1a8 100644 --- a/src/src/java.base/share/classes/sun/security/x509/X500Name.java +++ b/src/src/java.base/share/classes/sun/security/x509/X500Name.java @@ -865,7 +865,7 @@ public byte[] getEncoded() throws IOException { */ private void parseDN(String input, Map keywordMap) throws IOException { - if (input == null || input.length() == 0) { + if (input == null || input.isEmpty()) { names = new RDN[0]; return; } @@ -937,7 +937,7 @@ private void parseDN(String input, Map keywordMap) } private void parseRFC2253DN(String dnString) throws IOException { - if (dnString.length() == 0) { + if (dnString.isEmpty()) { names = new RDN[0]; return; } diff --git a/src/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java b/src/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java index 8a53ba85728..44585e8896f 100644 --- a/src/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java +++ b/src/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -370,18 +370,16 @@ public synchronized void verify(PublicKey key, String sigProvider) throw new CRLException("Uninitialized CRL"); } Signature sigVerf = null; - if (sigProvider.length() == 0) { - sigVerf = Signature.getInstance(sigAlgId.getName()); + String sigName = sigAlgId.getName(); + if (sigProvider.isEmpty()) { + sigVerf = Signature.getInstance(sigName); } else { - sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider); + sigVerf = Signature.getInstance(sigName, sigProvider); } - sigVerf.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selection happens when key is set try { - SignatureUtil.specialSetParameter(sigVerf, getSigAlgParams()); + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CRLException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { @@ -425,18 +423,16 @@ public synchronized void verify(PublicKey key, Provider sigProvider) throw new CRLException("Uninitialized CRL"); } Signature sigVerf = null; + String sigName = sigAlgId.getName(); if (sigProvider == null) { - sigVerf = Signature.getInstance(sigAlgId.getName()); + sigVerf = Signature.getInstance(sigName); } else { - sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider); + sigVerf = Signature.getInstance(sigName, sigProvider); } - sigVerf.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selection happens when key is set try { - SignatureUtil.specialSetParameter(sigVerf, getSigAlgParams()); + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CRLException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { @@ -495,14 +491,14 @@ public void sign(PrivateKey key, String algorithm, String provider) if (readOnly) throw new CRLException("cannot over-write existing CRL"); Signature sigEngine = null; - if ((provider == null) || (provider.length() == 0)) + if (provider == null || provider.isEmpty()) sigEngine = Signature.getInstance(algorithm); else sigEngine = Signature.getInstance(algorithm, provider); sigEngine.initSign(key); - // in case the name is reset + // in case the name is reset sigAlgId = AlgorithmId.get(sigEngine.getAlgorithm()); infoSigAlgId = sigAlgId; diff --git a/src/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/src/src/java.base/share/classes/sun/security/x509/X509CertImpl.java index 30dcd1db685..b5af13f381c 100644 --- a/src/src/java.base/share/classes/sun/security/x509/X509CertImpl.java +++ b/src/src/java.base/share/classes/sun/security/x509/X509CertImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -42,7 +42,6 @@ import javax.security.auth.x500.X500Principal; -import java.util.Base64; import sun.security.util.*; import sun.security.provider.X509Factory; @@ -429,18 +428,16 @@ public synchronized void verify(PublicKey key, String sigProvider) } // Verify the signature ... Signature sigVerf = null; - if (sigProvider.length() == 0) { - sigVerf = Signature.getInstance(algId.getName()); + String sigName = algId.getName(); + if (sigProvider.isEmpty()) { + sigVerf = Signature.getInstance(sigName); } else { - sigVerf = Signature.getInstance(algId.getName(), sigProvider); + sigVerf = Signature.getInstance(sigName, sigProvider); } - sigVerf.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selection happens when key is set try { - SignatureUtil.specialSetParameter(sigVerf, getSigAlgParams()); + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { @@ -485,18 +482,16 @@ public synchronized void verify(PublicKey key, Provider sigProvider) } // Verify the signature ... Signature sigVerf = null; + String sigName = algId.getName(); if (sigProvider == null) { - sigVerf = Signature.getInstance(algId.getName()); + sigVerf = Signature.getInstance(sigName); } else { - sigVerf = Signature.getInstance(algId.getName(), sigProvider); + sigVerf = Signature.getInstance(sigName, sigProvider); } - sigVerf.initVerify(key); - - // set parameters after Signature.initSign/initVerify call, - // so the deferred provider selection happens when key is set try { - SignatureUtil.specialSetParameter(sigVerf, getSigAlgParams()); + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { @@ -594,27 +589,20 @@ public void sign(PrivateKey key, AlgorithmParameterSpec signingParams, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchProviderException, SignatureException { try { - if (readOnly) + if (readOnly) { throw new CertificateEncodingException( - "cannot over-write existing certificate"); + "cannot over-write existing certificate"); + } Signature sigEngine = null; - if ((provider == null) || (provider.length() == 0)) + if (provider == null || provider.isEmpty()) { sigEngine = Signature.getInstance(algorithm); - else + } else { sigEngine = Signature.getInstance(algorithm, provider); - - sigEngine.initSign(key); - - // set parameters after Signature.initSign/initVerify call, so - // the deferred provider selection happens when the key is set - try { - sigEngine.setParameter(signingParams); - } catch (UnsupportedOperationException e) { - // for backward compatibility, only re-throw when - // parameters is not null - if (signingParams != null) throw e; } + SignatureUtil.initSignWithParam(sigEngine, key, signingParams, + null); + // in case the name is reset if (signingParams != null) { algId = AlgorithmId.get(sigEngine.getParameters()); diff --git a/src/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java b/src/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java index f3929ee389f..d94df036b87 100644 --- a/src/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java +++ b/src/src/java.base/share/classes/sun/util/calendar/ZoneInfo.java @@ -273,7 +273,7 @@ private int getOffsets(long date, int[] offsets, int type) { } // beyond the transitions, delegate to SimpleTimeZone if there - // is a rule; otherwise, return rawOffset. + // is a rule; otherwise, return the offset of the last transition. SimpleTimeZone tz = getLastRule(); if (tz != null) { int rawoffset = tz.getRawOffset(); @@ -293,13 +293,18 @@ private int getOffsets(long date, int[] offsets, int type) { offsets[1] = dstoffset; } return rawoffset + dstoffset; + } else { + // use the last transition + long val = transitions[transitions.length - 1]; + int offset = this.offsets[(int)(val & OFFSET_MASK)] + rawOffsetDiff; + if (offsets != null) { + int dst = (int)((val >>> DST_NSHIFT) & 0xfL); + int save = (dst == 0) ? 0 : this.offsets[dst]; + offsets[0] = offset - save; + offsets[1] = save; + } + return offset; } - int offset = getLastRawOffset(); - if (offsets != null) { - offsets[0] = offset; - offsets[1] = 0; - } - return offset; } private int getTransitionIndex(long date, int type) { @@ -502,8 +507,10 @@ public boolean inDaylightTime(Date date) { SimpleTimeZone tz = getLastRule(); if (tz != null) { return tz.inDaylightTime(date); - } - return false; + } else { + // use the last transition + return (transitions[transitions.length - 1] & DST_MASK) != 0; + } } /** diff --git a/src/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java b/src/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java index e3f703d14fa..720be39e2bb 100644 --- a/src/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java +++ b/src/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -609,8 +609,6 @@ private static ZoneInfo getZoneInfo(String zoneId, dstSavings = (startRule.offsetAfter - startRule.offsetBefore) * 1000; // Note: known mismatching -> Asia/Amman - // Asia/Gaza - // Asia/Hebron // ZoneInfo : startDayOfWeek=5 <= Thursday // startTime=86400000 <= 24 hours // This: startDayOfWeek=6 @@ -619,18 +617,14 @@ private static ZoneInfo getZoneInfo(String zoneId, // its endDayOfWeek and endTime // Below is the workarounds, it probably slows down everyone a little if (params[2] == 6 && params[3] == 0 && - (zoneId.equals("Asia/Amman") || - zoneId.equals("Asia/Gaza") || - zoneId.equals("Asia/Hebron"))) { + (zoneId.equals("Asia/Amman"))) { params[2] = 5; params[3] = 86400000; } // Additional check for startDayOfWeek=6 and starTime=86400000 - // is needed for Asia/Amman; Asia/Gasa and Asia/Hebron + // is needed for Asia/Amman; if (params[2] == 7 && params[3] == 0 && - (zoneId.equals("Asia/Amman") || - zoneId.equals("Asia/Gaza") || - zoneId.equals("Asia/Hebron"))) { + (zoneId.equals("Asia/Amman"))) { params[2] = 6; // Friday params[3] = 86400000; // 24h } diff --git a/src/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java b/src/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java index e829889b3df..3216ef543e8 100644 --- a/src/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java +++ b/src/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -148,6 +148,12 @@ private void deriveFallbackNames(String[] names, Locale locale) { private void deriveFallbackName(String[] names, int index, Locale locale, boolean noDST) { if (exists(names, index)) { + if (names[index].equals(NO_INHERITANCE_MARKER)) { + // CLDR's "no inheritance marker" + names[index] = toGMTFormat(names[INDEX_TZID], + index == INDEX_DST_LONG || index == INDEX_DST_SHORT, + index % 2 != 0, locale); + } return; } diff --git a/src/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java b/src/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java index b5e0fb47865..a3bf018f03c 100644 --- a/src/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java +++ b/src/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java @@ -331,7 +331,7 @@ private InternalLocaleBuilder setExtensions(List bcpExtensions, String p done.add(key); } } - if (privateuse != null && privateuse.length() > 0) { + if (privateuse != null && !privateuse.isEmpty()) { // privateuse string contains prefix, e.g. "x-abc-def" if (extensions == null) { extensions = new HashMap<>(1); @@ -406,19 +406,19 @@ else if (language.equals("no") && region.equals("NO") && variant.equals("NY")) { // Validate base locale fields before updating internal state. // LocaleExtensions always store validated/canonicalized values, // so no checks are necessary. - if (language.length() > 0 && !LanguageTag.isLanguage(language)) { + if (!language.isEmpty() && !LanguageTag.isLanguage(language)) { throw new LocaleSyntaxException("Ill-formed language: " + language); } - if (script.length() > 0 && !LanguageTag.isScript(script)) { + if (!script.isEmpty() && !LanguageTag.isScript(script)) { throw new LocaleSyntaxException("Ill-formed script: " + script); } - if (region.length() > 0 && !LanguageTag.isRegion(region)) { + if (!region.isEmpty() && !LanguageTag.isRegion(region)) { throw new LocaleSyntaxException("Ill-formed region: " + region); } - if (variant.length() > 0) { + if (!variant.isEmpty()) { int errIdx = checkVariants(variant, BaseLocale.SEP); if (errIdx != -1) { throw new LocaleSyntaxException("Ill-formed variant: " + variant, errIdx); diff --git a/src/src/java.base/share/classes/sun/util/locale/LanguageTag.java b/src/src/java.base/share/classes/sun/util/locale/LanguageTag.java index 3fd7f7dbe5e..a2d745794ab 100644 --- a/src/src/java.base/share/classes/sun/util/locale/LanguageTag.java +++ b/src/src/java.base/share/classes/sun/util/locale/LanguageTag.java @@ -212,7 +212,7 @@ public static LanguageTag parse(String languageTag, ParseStatus sts) { if (!itr.isDone() && !sts.isError()) { String s = itr.current(); sts.errorIndex = itr.currentStart(); - if (s.length() == 0) { + if (s.isEmpty()) { sts.errorMsg = "Empty subtag"; } else { sts.errorMsg = "Invalid subtag: " + s; @@ -454,7 +454,7 @@ public static LanguageTag parseLocale(BaseLocale baseLocale, LocaleExtensions lo variant = ""; } - if (variant.length() > 0) { + if (!variant.isEmpty()) { List variants = null; StringTokenIterator varitr = new StringTokenIterator(variant, BaseLocale.SEP); while (!varitr.isDone()) { @@ -527,7 +527,7 @@ public static LanguageTag parseLocale(BaseLocale baseLocale, LocaleExtensions lo tag.privateuse = privateuse; } - if (tag.language.length() == 0 && (hasSubtag || privateuse == null)) { + if (tag.language.isEmpty() && (hasSubtag || privateuse == null)) { // use lang "und" when 1) no language is available AND // 2) any of other subtags other than private use are available or // no private use tag is available @@ -712,18 +712,18 @@ public static String canonicalizePrivateuseSubtag(String s) { public String toString() { StringBuilder sb = new StringBuilder(); - if (language.length() > 0) { + if (!language.isEmpty()) { sb.append(language); for (String extlang : extlangs) { sb.append(SEP).append(extlang); } - if (script.length() > 0) { + if (!script.isEmpty()) { sb.append(SEP).append(script); } - if (region.length() > 0) { + if (!region.isEmpty()) { sb.append(SEP).append(region); } @@ -735,7 +735,7 @@ public String toString() { sb.append(SEP).append(extension); } } - if (privateuse.length() > 0) { + if (!privateuse.isEmpty()) { if (sb.length() > 0) { sb.append(SEP); } diff --git a/src/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java b/src/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java index 4dbec843ea7..7ec5ab6709f 100644 --- a/src/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java +++ b/src/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java @@ -402,7 +402,7 @@ public static String lookupTag(List priorityList, } String rangeForRegex = range.replace("*", "\\p{Alnum}*"); - while (rangeForRegex.length() > 0) { + while (!rangeForRegex.isEmpty()) { for (String tag : tags) { // change to lowercase for case-insensitive matching String lowerCaseTag = tag.toLowerCase(Locale.ROOT); @@ -437,7 +437,7 @@ private static boolean shouldIgnoreLookupMatch(List zeroRange, } String rangeForRegex = range.replace("*", "\\p{Alnum}*"); - while (rangeForRegex.length() > 0) { + while (!rangeForRegex.isEmpty()) { if (tag.matches(rangeForRegex)) { return true; } @@ -591,7 +591,7 @@ private static String replaceFirstSubStringMatch(String range, private static String[] getEquivalentsForLanguage(String range) { String r = range; - while (r.length() > 0) { + while (!r.isEmpty()) { if (LocaleEquivalentMaps.singleEquivMap.containsKey(r)) { String equiv = LocaleEquivalentMaps.singleEquivMap.get(r); // Return immediately for performance if the first matching @@ -680,7 +680,7 @@ public static List mapEquivalents( String r = range; boolean hasEquivalent = false; - while (r.length() > 0) { + while (!r.isEmpty()) { if (keyMap.containsKey(r)) { hasEquivalent = true; List equivalents = map.get(keyMap.get(r)); diff --git a/src/src/java.base/share/classes/sun/util/locale/LocaleUtils.java b/src/src/java.base/share/classes/sun/util/locale/LocaleUtils.java index ead48fc2493..264c50086cc 100644 --- a/src/src/java.base/share/classes/sun/util/locale/LocaleUtils.java +++ b/src/src/java.base/share/classes/sun/util/locale/LocaleUtils.java @@ -207,7 +207,7 @@ public static boolean isAlphaNumericString(String s) { } static boolean isEmpty(String str) { - return str == null || str.length() == 0; + return str == null || str.isEmpty(); } static boolean isEmpty(Set set) { diff --git a/src/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java b/src/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java index 51a723aea25..634932e9e19 100644 --- a/src/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java +++ b/src/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java @@ -80,7 +80,7 @@ private UnicodeLocaleExtension(String key, String value) { String value = keyword.getValue(); sj.add(key); - if (value.length() > 0) { + if (!value.isEmpty()) { sj.add(value); } } diff --git a/src/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java b/src/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java index 7df153348f9..7293e9fad36 100644 --- a/src/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java +++ b/src/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java @@ -117,7 +117,7 @@ public String getDisplayNameImpl(String calendarType, int field, int value, int } name = strings[value]; // If name is empty in standalone, try its `format' style. - if (name.length() == 0 + if (name.isEmpty() && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, @@ -183,7 +183,7 @@ private Map getDisplayNamesImpl(String calendarType, int field, String name = strings[i]; // Ignore any empty string (some standalone month names // are not defined) - if (name.length() == 0) { + if (name.isEmpty()) { continue; } map.put(name, base + i); diff --git a/src/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java b/src/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java index 6fcdf8d9509..89005429700 100644 --- a/src/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java +++ b/src/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java @@ -503,7 +503,7 @@ private static Locale[] createAvailableLocales() { */ String supportedLocaleString = createSupportedLocaleString("AvailableLocales"); - if (supportedLocaleString.length() == 0) { + if (supportedLocaleString.isEmpty()) { throw new InternalError("No available locales for JRE"); } diff --git a/src/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java b/src/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java index d99b48dcd7b..751aa120830 100644 --- a/src/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java +++ b/src/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java @@ -121,7 +121,7 @@ public String getTextResourcesPackage() { List typeList = new ArrayList<>(); // Check user specified adapter preference - if (order != null && order.length() != 0) { + if (order != null && !order.isEmpty()) { String[] types = order.split(","); for (String type : types) { type = type.trim().toUpperCase(Locale.ROOT); diff --git a/src/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java b/src/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java index 4ecee24297a..2dc1f2de332 100644 --- a/src/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java +++ b/src/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -370,7 +370,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, @@ -691,6 +691,9 @@ protected final Object[][] getContents() { {"Asia/Pontianak", WIT}, {"Asia/Pyongyang", KST}, {"Asia/Qatar", ARAST}, + {"Asia/Qostanay", new String[] {"Kostanay Standard Time", "QOST", + "Kostanay Summer Time", "QOSST", + "Kostanay Time", "QOST"}}, {"Asia/Qyzylorda", new String[] {"Qyzylorda Time", "QYZT", "Qyzylorda Summer Time", "QYZST", "Qyzylorda Time", "QYZT"}}, diff --git a/src/src/java.base/share/conf/security/java.security b/src/src/java.base/share/conf/security/java.security index 438120c0da0..e4afe9e3ceb 100644 --- a/src/src/java.base/share/conf/security/java.security +++ b/src/src/java.base/share/conf/security/java.security @@ -1086,6 +1086,24 @@ jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep # #jdk.includeInExceptions=hostInfo +# +# Disabled mechanisms for the Simple Authentication and Security Layer (SASL) +# +# Disabled mechanisms will not be negotiated by both SASL clients and servers. +# These mechanisms will be ignored if they are specified in the "mechanisms" +# argument of "Sasl.createSaslClient" or the "mechanism" argument of +# "Sasl.createSaslServer". +# +# The value of this property is a comma-separated list of SASL mechanisms. +# The mechanisms are case-sensitive. Whitespaces around the commas are ignored. +# +# Note: This property is currently used by the JDK Reference implementation. +# It is not guaranteed to be examined and used by other implementations. +# +# Example: +# jdk.sasl.disabledMechanisms=PLAIN, CRAM-MD5, DIGEST-MD5 +jdk.sasl.disabledMechanisms= + # # Policies for distrusting Certificate Authorities (CAs). # @@ -1116,3 +1134,51 @@ jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep # jdk.security.caDistrustPolicies=SYMANTEC_TLS +# +# FilePermission path canonicalization +# +# This security property dictates how the path argument is processed and stored +# while constructing a FilePermission object. If the value is set to true, the +# path argument is canonicalized and FilePermission methods (such as implies, +# equals, and hashCode) are implemented based on this canonicalized result. +# Otherwise, the path argument is not canonicalized and FilePermission methods are +# implemented based on the original input. See the implementation note of the +# FilePermission class for more details. +# +# If a system property of the same name is also specified, it supersedes the +# security property value defined here. +# +# The default value for this property is false. +# +jdk.io.permissionsUseCanonicalPath=false + + +# +# Policies for the proxy_impersonator Kerberos ccache configuration entry +# +# The proxy_impersonator ccache configuration entry indicates that the ccache +# is a synthetic delegated credential for use with S4U2Proxy by an intermediate +# server. The ccache file should also contain the TGT of this server and +# an evidence ticket from the default principal of the ccache to this server. +# +# This security property determines how Java uses this configuration entry. +# There are 3 possible values: +# +# no-impersonate - Ignore this configuration entry, and always act as +# the owner of the TGT (if it exists). +# +# try-impersonate - Try impersonation when this configuration entry exists. +# If no matching TGT or evidence ticket is found, +# fallback to no-impersonate. +# +# always-impersonate - Always impersonate when this configuration entry exists. +# If no matching TGT or evidence ticket is found, +# no initial credential is read from the ccache. +# +# The default value is "always-impersonate". +# +# If a system property of the same name is also specified, it supersedes the +# security property value defined here. +# +#jdk.security.krb5.default.initiate.credential=always-impersonate + diff --git a/src/src/java.base/share/legal/public_suffix.md b/src/src/java.base/share/legal/public_suffix.md index 5f7cd5a3025..b1120f1d238 100644 --- a/src/src/java.base/share/legal/public_suffix.md +++ b/src/src/java.base/share/legal/public_suffix.md @@ -11,7 +11,7 @@ If you do not wish to use the Public Suffix List, you may remove the The Source Code of this file is available under the Mozilla Public License, v. 2.0 and is located at -https://raw.githubusercontent.com/publicsuffix/list/2225db8d9f4a2a27ec697c883360632fa0c16261/public_suffix_list.dat. +https://raw.githubusercontent.com/publicsuffix/list/ce0d1a5fba657e55adea3abde4b7f1e50636ff10/public_suffix_list.dat. If a copy of the MPL was not distributed with this file, you can obtain one at https://mozilla.org/MPL/2.0/. diff --git a/src/src/java.base/share/native/libjava/VM.c b/src/src/java.base/share/native/libjava/VM.c index 9e99528c63d..b88cb617ea9 100644 --- a/src/src/java.base/share/native/libjava/VM.c +++ b/src/src/java.base/share/native/libjava/VM.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2018, 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 @@ -60,3 +60,9 @@ JNIEXPORT jobjectArray JNICALL Java_jdk_internal_misc_VM_getRuntimeArguments(JNIEnv *env, jclass cls) { return JVM_GetVmArguments(env); } + +JNIEXPORT void JNICALL +Java_jdk_internal_misc_VM_initializeFromArchive(JNIEnv *env, jclass ignore, + jclass c) { + JVM_InitializeFromArchive(env, c); +} diff --git a/src/src/java.base/share/native/libjli/jli_util.h b/src/src/java.base/share/native/libjli/jli_util.h index b8987010f31..402a06ef818 100644 --- a/src/src/java.base/share/native/libjli/jli_util.h +++ b/src/src/java.base/share/native/libjli/jli_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -89,7 +89,8 @@ JLI_GetAppArgIndex(); #include #define JLI_StrCaseCmp(p1, p2) stricmp((p1), (p2)) #define JLI_StrNCaseCmp(p1, p2, p3) strnicmp((p1), (p2), (p3)) -int JLI_Snprintf(char *buffer, size_t size, const char *format, ...); +int JLI_Snprintf(char *buffer, size_t size, const char *format, ...); +int JLI_Open(const char* name, int flags); JNIEXPORT void JNICALL JLI_CmdToArgs(char *cmdline); #define JLI_Lseek _lseeki64 @@ -101,6 +102,7 @@ JLI_CmdToArgs(char *cmdline); #define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2)) #define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3)) #define JLI_Snprintf snprintf +#define JLI_Open open #define JLI_PutEnv putenv #define JLI_GetPid getpid #ifdef __solaris__ diff --git a/src/src/java.base/share/native/libjli/parse_manifest.c b/src/src/java.base/share/native/libjli/parse_manifest.c index 4f9f23c1920..2889fab0686 100644 --- a/src/src/java.base/share/native/libjli/parse_manifest.c +++ b/src/src/java.base/share/native/libjli/parse_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -362,9 +362,11 @@ find_file(int fd, zentry *entry, const char *file_name) bp = buffer; if (find_positions(fd, bp, &base_offset, &censtart) == -1) { + free(buffer); return -1; } if (JLI_Lseek(fd, censtart, SEEK_SET) < (jlong) 0) { + free(buffer); return -1; } @@ -583,7 +585,7 @@ JLI_ParseManifest(char *jarfile, manifest_info *info) int rc; char *splashscreen_name = NULL; - if ((fd = open(jarfile, O_RDONLY + if ((fd = JLI_Open(jarfile, O_RDONLY #ifdef O_LARGEFILE | O_LARGEFILE /* large file mode */ #endif @@ -640,7 +642,7 @@ JLI_JarUnpackFile(const char *jarfile, const char *filename, int *size) { zentry entry; void *data = NULL; - if ((fd = open(jarfile, O_RDONLY + if ((fd = JLI_Open(jarfile, O_RDONLY #ifdef O_LARGEFILE | O_LARGEFILE /* large file mode */ #endif @@ -688,7 +690,7 @@ JLI_ManifestIterate(const char *jarfile, attribute_closure ac, void *user_data) char *value; int rc; - if ((fd = open(jarfile, O_RDONLY + if ((fd = JLI_Open(jarfile, O_RDONLY #ifdef O_LARGEFILE | O_LARGEFILE /* large file mode */ #endif diff --git a/src/src/java.base/share/native/libzip/Deflater.c b/src/src/java.base/share/native/libzip/Deflater.c index bf204f1d68e..2a5791ec62d 100644 --- a/src/src/java.base/share/native/libzip/Deflater.c +++ b/src/src/java.base/share/native/libzip/Deflater.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -76,9 +76,8 @@ Java_java_util_zip_Deflater_init(JNIEnv *env, jclass cls, jint level, } } -static void doSetDictionary(JNIEnv *env, jlong addr, jbyte *buf, jint len) +static void checkSetDictionaryResult(JNIEnv *env, jlong addr, jint res) { - int res = deflateSetDictionary(jlong_to_ptr(addr), (Bytef *) buf, len); switch (res) { case Z_OK: break; @@ -95,30 +94,33 @@ JNIEXPORT void JNICALL Java_java_util_zip_Deflater_setDictionary(JNIEnv *env, jclass cls, jlong addr, jbyteArray b, jint off, jint len) { - jbyte *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); + int res; + Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); if (buf == NULL) /* out of memory */ return; - doSetDictionary(env, addr, buf + off, len); + res = deflateSetDictionary(jlong_to_ptr(addr), buf, len); (*env)->ReleasePrimitiveArrayCritical(env, b, buf, 0); + checkSetDictionaryResult(env, addr, res); } JNIEXPORT void JNICALL Java_java_util_zip_Deflater_setDictionaryBuffer(JNIEnv *env, jclass cls, jlong addr, jlong bufferAddr, jint len) { - jbyte *buf = jlong_to_ptr(bufferAddr); - doSetDictionary(env, addr, buf, len); + int res; + Bytef *buf = jlong_to_ptr(bufferAddr); + res = deflateSetDictionary(jlong_to_ptr(addr), buf, len); + checkSetDictionaryResult(env, addr, res); } -static jlong doDeflate(JNIEnv *env, jobject this, jlong addr, +static jint doDeflate(JNIEnv *env, jlong addr, jbyte *input, jint inputLen, jbyte *output, jint outputLen, jint flush, jint params) { z_stream *strm = jlong_to_ptr(addr); - jint inputUsed = 0, outputUsed = 0; - int finished = 0; int setParams = params & 1; + int res; strm->next_in = (Bytef *) input; strm->next_out = (Bytef *) output; @@ -128,7 +130,24 @@ static jlong doDeflate(JNIEnv *env, jobject this, jlong addr, if (setParams) { int strategy = (params >> 1) & 3; int level = params >> 3; - int res = deflateParams(strm, level, strategy); + res = deflateParams(strm, level, strategy); + } else { + res = deflate(strm, flush); + } + return res; +} + +static jlong checkDeflateStatus(JNIEnv *env, jlong addr, + jint inputLen, + jint outputLen, + jint params, int res) +{ + z_stream *strm = jlong_to_ptr(addr); + jint inputUsed = 0, outputUsed = 0; + int finished = 0; + int setParams = params & 1; + + if (setParams) { switch (res) { case Z_OK: setParams = 0; @@ -142,7 +161,6 @@ static jlong doDeflate(JNIEnv *env, jobject this, jlong addr, return 0; } } else { - int res = deflate(strm, flush); switch (res) { case Z_STREAM_END: finished = 1; @@ -169,6 +187,8 @@ Java_java_util_zip_Deflater_deflateBytesBytes(JNIEnv *env, jobject this, jlong a jbyte *input = (*env)->GetPrimitiveArrayCritical(env, inputArray, 0); jbyte *output; jlong retVal; + jint res; + if (input == NULL) { if (inputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); @@ -182,14 +202,13 @@ Java_java_util_zip_Deflater_deflateBytesBytes(JNIEnv *env, jobject this, jlong a return 0L; } - retVal = doDeflate(env, this, addr, - input + inputOff, inputLen, - output + outputOff, outputLen, - flush, params); + res = doDeflate(env, addr, input + inputOff, inputLen,output + outputOff, + outputLen, flush, params); (*env)->ReleasePrimitiveArrayCritical(env, outputArray, output, 0); (*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0); + retVal = checkDeflateStatus(env, addr, inputLen, outputLen, params, res); return retVal; } @@ -203,6 +222,7 @@ Java_java_util_zip_Deflater_deflateBytesBuffer(JNIEnv *env, jobject this, jlong jbyte *input = (*env)->GetPrimitiveArrayCritical(env, inputArray, 0); jbyte *output; jlong retVal; + jint res; if (input == NULL) { if (inputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); @@ -210,13 +230,12 @@ Java_java_util_zip_Deflater_deflateBytesBuffer(JNIEnv *env, jobject this, jlong } output = jlong_to_ptr(outputBuffer); - retVal = doDeflate(env, this, addr, - input + inputOff, inputLen, - output, outputLen, - flush, params); + res = doDeflate(env, addr, input + inputOff, inputLen, output, outputLen, + flush, params); (*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0); + retVal = checkDeflateStatus(env, addr, inputLen, outputLen, params, res); return retVal; } @@ -229,19 +248,18 @@ Java_java_util_zip_Deflater_deflateBufferBytes(JNIEnv *env, jobject this, jlong jbyte *input = jlong_to_ptr(inputBuffer); jbyte *output = (*env)->GetPrimitiveArrayCritical(env, outputArray, 0); jlong retVal; + jint res; if (output == NULL) { if (outputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0L; } - retVal = doDeflate(env, this, addr, - input, inputLen, - output + outputOff, outputLen, - flush, params); - + res = doDeflate(env, addr, input, inputLen, output + outputOff, outputLen, + flush, params); (*env)->ReleasePrimitiveArrayCritical(env, outputArray, input, 0); + retVal = checkDeflateStatus(env, addr, inputLen, outputLen, params, res); return retVal; } @@ -253,11 +271,12 @@ Java_java_util_zip_Deflater_deflateBufferBuffer(JNIEnv *env, jobject this, jlong { jbyte *input = jlong_to_ptr(inputBuffer); jbyte *output = jlong_to_ptr(outputBuffer); + jlong retVal; + jint res; - return doDeflate(env, this, addr, - input, inputLen, - output, outputLen, - flush, params); + res = doDeflate(env, addr, input, inputLen, output, outputLen, flush, params); + retVal = checkDeflateStatus(env, addr, inputLen, outputLen, params, res); + return retVal; } JNIEXPORT jint JNICALL diff --git a/src/src/java.base/share/native/libzip/Inflater.c b/src/src/java.base/share/native/libzip/Inflater.c index 1b1040bd7fb..a41e9775bfa 100644 --- a/src/src/java.base/share/native/libzip/Inflater.c +++ b/src/src/java.base/share/native/libzip/Inflater.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -87,9 +87,8 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap) } } -static void doSetDictionary(JNIEnv *env, jlong addr, jbyte *buf, jint len) +static void checkSetDictionaryResult(JNIEnv *env, jlong addr, int res) { - int res = inflateSetDictionary(jlong_to_ptr(addr), (Bytef *) buf, len); switch (res) { case Z_OK: break; @@ -107,30 +106,31 @@ JNIEXPORT void JNICALL Java_java_util_zip_Inflater_setDictionary(JNIEnv *env, jclass cls, jlong addr, jbyteArray b, jint off, jint len) { - jbyte *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); + jint res; + Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); if (buf == NULL) /* out of memory */ return; - doSetDictionary(env, addr, buf + off, len); + res = inflateSetDictionary(jlong_to_ptr(addr), buf + off, len); (*env)->ReleasePrimitiveArrayCritical(env, b, buf, 0); + checkSetDictionaryResult(env, addr, res); } JNIEXPORT void JNICALL Java_java_util_zip_Inflater_setDictionaryBuffer(JNIEnv *env, jclass cls, jlong addr, jlong bufferAddr, jint len) { - jbyte *buf = jlong_to_ptr(bufferAddr); - doSetDictionary(env, addr, buf, len); + jint res; + Bytef *buf = jlong_to_ptr(bufferAddr); + res = inflateSetDictionary(jlong_to_ptr(addr), buf, len); + checkSetDictionaryResult(env, addr, res); } -static jlong doInflate(JNIEnv *env, jobject this, jlong addr, +static jint doInflate(jlong addr, jbyte *input, jint inputLen, jbyte *output, jint outputLen) { + jint ret; z_stream *strm = jlong_to_ptr(addr); - jint inputUsed = 0, outputUsed = 0; - int finished = 0; - int needDict = 0; - int ret; strm->next_in = (Bytef *) input; strm->next_out = (Bytef *) output; @@ -138,6 +138,16 @@ static jlong doInflate(JNIEnv *env, jobject this, jlong addr, strm->avail_out = outputLen; ret = inflate(strm, Z_PARTIAL_FLUSH); + return ret; +} + +static jlong checkInflateStatus(JNIEnv *env, jobject this, jlong addr, + jint inputLen, jint outputLen, jint ret ) +{ + z_stream *strm = jlong_to_ptr(addr); + jint inputUsed = 0, outputUsed = 0; + int finished = 0; + int needDict = 0; switch (ret) { case Z_STREAM_END: @@ -180,6 +190,7 @@ Java_java_util_zip_Inflater_inflateBytesBytes(JNIEnv *env, jobject this, jlong a { jbyte *input = (*env)->GetPrimitiveArrayCritical(env, inputArray, 0); jbyte *output; + jint ret; jlong retVal; if (input == NULL) { @@ -195,13 +206,13 @@ Java_java_util_zip_Inflater_inflateBytesBytes(JNIEnv *env, jobject this, jlong a return 0L; } - retVal = doInflate(env, this, addr, - input + inputOff, inputLen, - output + outputOff, outputLen); + ret = doInflate(addr, input + inputOff, inputLen, output + outputOff, + outputLen); (*env)->ReleasePrimitiveArrayCritical(env, outputArray, output, 0); (*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0); + retVal = checkInflateStatus(env, this, addr, inputLen, outputLen, ret ); return retVal; } @@ -212,6 +223,7 @@ Java_java_util_zip_Inflater_inflateBytesBuffer(JNIEnv *env, jobject this, jlong { jbyte *input = (*env)->GetPrimitiveArrayCritical(env, inputArray, 0); jbyte *output; + jint ret; jlong retVal; if (input == NULL) { @@ -221,11 +233,10 @@ Java_java_util_zip_Inflater_inflateBytesBuffer(JNIEnv *env, jobject this, jlong } output = jlong_to_ptr(outputBuffer); - retVal = doInflate(env, this, addr, - input + inputOff, inputLen, - output, outputLen); + ret = doInflate(addr, input + inputOff, inputLen, output, outputLen); (*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0); + retVal = checkInflateStatus(env, this, addr, inputLen, outputLen, ret ); return retVal; } @@ -237,6 +248,7 @@ Java_java_util_zip_Inflater_inflateBufferBytes(JNIEnv *env, jobject this, jlong { jbyte *input = jlong_to_ptr(inputBuffer); jbyte *output = (*env)->GetPrimitiveArrayCritical(env, outputArray, 0); + jint ret; jlong retVal; if (output == NULL) { @@ -245,11 +257,10 @@ Java_java_util_zip_Inflater_inflateBufferBytes(JNIEnv *env, jobject this, jlong return 0L; } - retVal = doInflate(env, this, addr, - input, inputLen, - output + outputOff, outputLen); + ret = doInflate(addr, input, inputLen, output + outputOff, outputLen); (*env)->ReleasePrimitiveArrayCritical(env, outputArray, output, 0); + retVal = checkInflateStatus(env, this, addr, inputLen, outputLen, ret ); return retVal; } @@ -261,10 +272,12 @@ Java_java_util_zip_Inflater_inflateBufferBuffer(JNIEnv *env, jobject this, jlong { jbyte *input = jlong_to_ptr(inputBuffer); jbyte *output = jlong_to_ptr(outputBuffer); + jint ret; + jlong retVal; - return doInflate(env, this, addr, - input, inputLen, - output, outputLen); + ret = doInflate(addr, input, inputLen, output, outputLen); + retVal = checkInflateStatus(env, this, addr, inputLen, outputLen, ret); + return retVal; } JNIEXPORT jint JNICALL diff --git a/src/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java b/src/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java index 83fddff2a54..9953dfbca17 100644 --- a/src/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java +++ b/src/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,29 @@ package sun.nio.fs; -import java.nio.file.spi.FileSystemProvider; +import java.nio.file.FileSystem; /** * Creates this platform's default FileSystemProvider. */ public class DefaultFileSystemProvider { + private static final SolarisFileSystemProvider INSTANCE + = new SolarisFileSystemProvider(); + private DefaultFileSystemProvider() { } /** - * Returns the default FileSystemProvider. + * Returns the platform's default file system provider. + */ + public static SolarisFileSystemProvider instance() { + return INSTANCE; + } + + /** + * Returns the platform's default file system. */ - public static FileSystemProvider create() { - return new SolarisFileSystemProvider(); + public static FileSystem theFileSystem() { + return INSTANCE.theFileSystem(); } } diff --git a/src/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java b/src/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java index 231b770f087..cbc14803a45 100644 --- a/src/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java +++ b/src/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java @@ -36,7 +36,7 @@ * Solaris implementation of FileSystemProvider */ -public class SolarisFileSystemProvider extends UnixFileSystemProvider { +class SolarisFileSystemProvider extends UnixFileSystemProvider { public SolarisFileSystemProvider() { super(); } diff --git a/src/src/java.base/unix/classes/java/io/UnixFileSystem.java b/src/src/java.base/unix/classes/java/io/UnixFileSystem.java index 23d3e52bad8..068593cfba5 100644 --- a/src/src/java.base/unix/classes/java/io/UnixFileSystem.java +++ b/src/src/java.base/unix/classes/java/io/UnixFileSystem.java @@ -96,7 +96,7 @@ public String normalize(String pathname) { } public int prefixLength(String pathname) { - if (pathname.length() == 0) return 0; + if (pathname.isEmpty()) return 0; return (pathname.charAt(0) == '/') ? 1 : 0; } @@ -247,7 +247,7 @@ static String parentOrNull(String path) { public int getBooleanAttributes(File f) { int rv = getBooleanAttributes0(f); String name = f.getName(); - boolean hidden = (name.length() > 0) && (name.charAt(0) == '.'); + boolean hidden = !name.isEmpty() && name.charAt(0) == '.'; return rv | (hidden ? BA_HIDDEN : 0); } diff --git a/src/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java b/src/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java index b422bdc11de..6507b2961b9 100644 --- a/src/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java +++ b/src/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java @@ -59,9 +59,9 @@ public String getPath () { return path; } String host = url.getHost(); - if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) { + if (host == null || host.isEmpty() || "localhost".equalsIgnoreCase(host)) { path = url.getFile(); - path = ParseUtil.decode (path); + path = ParseUtil.decode(path); } return path; } diff --git a/src/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java b/src/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java index 46fd008681e..5036465d46d 100644 --- a/src/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java +++ b/src/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java @@ -68,14 +68,14 @@ private LinkedList resolvconf(String keyword, String line; while ((line = in.readLine()) != null) { int maxvalues = maxperkeyword; - if (line.length() == 0) + if (line.isEmpty()) continue; if (line.charAt(0) == '#' || line.charAt(0) == ';') continue; if (!line.startsWith(keyword)) continue; String value = line.substring(keyword.length()); - if (value.length() == 0) + if (value.isEmpty()) continue; if (value.charAt(0) != ' ' && value.charAt(0) != '\t') continue; @@ -181,7 +181,7 @@ public LinkedList run() { // LOCALDOMAIN has absolute priority on Solaris String localDomain = localDomain0(); - if (localDomain != null && localDomain.length() > 0) { + if (localDomain != null && !localDomain.isEmpty()) { sl = new LinkedList<>(); sl.add(localDomain); return sl; @@ -211,7 +211,7 @@ public LinkedList run() { sl = new LinkedList<>(); String domain = fallbackDomain0(); - if (domain != null && domain.length() > 0) { + if (domain != null && !domain.isEmpty()) { sl.add(domain); } diff --git a/src/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java b/src/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java index 6cc4b0094b9..c082bb6f02c 100644 --- a/src/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java +++ b/src/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java @@ -77,7 +77,7 @@ public SdpProvider() { String logfile = props.getProperty("com.sun.sdp.debug"); if (logfile != null) { out = System.out; - if (logfile.length() > 0) { + if (!logfile.isEmpty()) { try { out = new PrintStream(logfile); } catch (IOException ignore) { } @@ -167,9 +167,9 @@ private static int[] parsePortRange(String s) { result[1] = all ? MAX_PORT : result[0]; } else { String low = s.substring(0, pos); - if (low.length() == 0) low = "*"; + if (low.isEmpty()) low = "*"; String high = s.substring(pos+1); - if (high.length() == 0) high = "*"; + if (high.isEmpty()) high = "*"; result[0] = low.equals("*") ? 0 : Integer.parseInt(low); result[1] = high.equals("*") ? MAX_PORT : Integer.parseInt(high); } @@ -199,7 +199,7 @@ private static List loadRulesFromFile(String file) String line = scanner.nextLine().trim(); // skip blank lines and comments - if (line.length() == 0 || line.charAt(0) == '#') + if (line.isEmpty() || line.charAt(0) == '#') continue; // must have 3 fields diff --git a/src/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java b/src/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java index ce280dc455a..ba228f0451d 100644 --- a/src/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java +++ b/src/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java @@ -127,9 +127,9 @@ protected boolean hostsEqual(URL u1, URL u2) { */ String s1 = u1.getHost(); String s2 = u2.getHost(); - if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2))) + if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty())) return true; - if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1))) + if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty())) return true; return super.hostsEqual(u1, u2); } diff --git a/src/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java b/src/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java index dc9d344106b..ef0735fcba2 100644 --- a/src/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java +++ b/src/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, 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 @@ -49,8 +49,8 @@ private static enum OpType { CONNECT, READ, WRITE }; static { String propValue = GetPropertyAction.privilegedGetProperty( "sun.nio.ch.disableSynchronousRead", "false"); - disableSynchronousRead = (propValue.length() == 0) ? - true : Boolean.valueOf(propValue); + disableSynchronousRead = propValue.isEmpty() ? + true : Boolean.parseBoolean(propValue); } private final Port port; @@ -273,6 +273,7 @@ private void finishConnect(boolean mayInvokeDirect) { // invoke handler and set result CompletionHandler handler = connectHandler; + connectHandler = null; Object att = connectAttachment; PendingFuture future = connectFuture; if (handler == null) { @@ -405,6 +406,7 @@ private void finishRead(boolean mayInvokeDirect) { this.readBuffer = null; this.readBuffers = null; this.readAttachment = null; + this.readHandler = null; // allow another read to be initiated enableReading(); @@ -600,6 +602,7 @@ private void finishWrite(boolean mayInvokeDirect) { this.writeBuffer = null; this.writeBuffers = null; this.writeAttachment = null; + this.writeHandler = null; // allow another write to be initiated enableWriting(); diff --git a/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java b/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java index 96225f08d6f..f3a98bdfced 100644 --- a/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java +++ b/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java @@ -58,8 +58,7 @@ abstract class UnixFileSystem // default directory. String propValue = GetPropertyAction .privilegedGetProperty("sun.nio.fs.chdirAllowed", "false"); - boolean chdirAllowed = (propValue.length() == 0) ? - true : Boolean.valueOf(propValue); + boolean chdirAllowed = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue); if (chdirAllowed) { this.needToResolveAgainstDefaultDirectory = true; } else { @@ -269,7 +268,7 @@ public final Path getPath(String first, String... more) { StringBuilder sb = new StringBuilder(); sb.append(first); for (String segment: more) { - if (segment.length() > 0) { + if (!segment.isEmpty()) { if (sb.length() > 0) sb.append('/'); sb.append(segment); diff --git a/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java b/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java index b738cc3c5d2..e92711f0168 100644 --- a/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java +++ b/src/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, 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 @@ -56,6 +56,10 @@ public UnixFileSystemProvider() { theFileSystem = newFileSystem(userDir); } + UnixFileSystem theFileSystem() { + return theFileSystem; + } + /** * Constructs a new file system using the given default directory. */ diff --git a/src/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java b/src/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java index e6a62faf966..fe2d0f3f1a5 100644 --- a/src/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java +++ b/src/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java @@ -36,7 +36,7 @@ class UnixNativeDispatcher { protected UnixNativeDispatcher() { } // returns a NativeBuffer containing the given path - private static NativeBuffer copyToNativeBuffer(UnixPath path) { + static NativeBuffer copyToNativeBuffer(UnixPath path) { byte[] cstr = path.getByteArrayForSysCalls(); int size = cstr.length + 1; NativeBuffer buffer = NativeBuffers.getNativeBufferFromCache(size); diff --git a/src/src/java.base/unix/native/jspawnhelper/jspawnhelper.c b/src/src/java.base/unix/native/jspawnhelper/jspawnhelper.c index e522b0cf73a..13882017163 100644 --- a/src/src/java.base/unix/native/jspawnhelper/jspawnhelper.c +++ b/src/src/java.base/unix/native/jspawnhelper/jspawnhelper.c @@ -49,7 +49,10 @@ extern int errno; #define ERR_ARGS 3 void error (int fd, int err) { - write (fd, &err, sizeof(err)); + if (write (fd, &err, sizeof(err)) != sizeof(err)) { + /* Not sure what to do here. I have no one to speak to. */ + exit(0x80 + err); + } exit (1); } diff --git a/src/src/java.base/unix/native/libjava/canonicalize_md.c b/src/src/java.base/unix/native/libjava/canonicalize_md.c index e985c39b31f..cb8ce69c885 100644 --- a/src/src/java.base/unix/native/libjava/canonicalize_md.c +++ b/src/src/java.base/unix/native/libjava/canonicalize_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2019, 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 @@ -211,11 +211,10 @@ canonicalize(char *original, char *resolved, int len) char *p, *end, *r = NULL; char path[PATH_MAX + 1]; - strncpy(path, original, sizeof(path)); - if (path[PATH_MAX] != '\0') { - errno = ENAMETOOLONG; - return -1; - } + // strlen(original) <= PATH_MAX, see above + strncpy(path, original, PATH_MAX); + // append null for == case + path[PATH_MAX] = '\0'; end = path + strlen(path); for (p = end; p > path;) { diff --git a/src/src/java.base/unix/native/libjava/childproc.c b/src/src/java.base/unix/native/libjava/childproc.c index 7af19e4f369..b84ca56cc7e 100644 --- a/src/src/java.base/unix/native/libjava/childproc.c +++ b/src/src/java.base/unix/native/libjava/childproc.c @@ -316,6 +316,7 @@ int childProcess(void *arg) { const ChildStuff* p = (const ChildStuff*) arg; + int fail_pipe_fd = p->fail[1]; /* Close the parent sides of the pipes. Closing pipe fds here is redundant, since closeDescriptors() @@ -346,9 +347,12 @@ childProcess(void *arg) goto WhyCantJohnnyExec; } - if (moveDescriptor(p->fail[1], FAIL_FILENO) == -1) + if (moveDescriptor(fail_pipe_fd, FAIL_FILENO) == -1) goto WhyCantJohnnyExec; + /* We moved the fail pipe fd */ + fail_pipe_fd = FAIL_FILENO; + /* close everything */ if (closeDescriptors() == 0) { /* failed, close the old way */ int max_fd = (int)sysconf(_SC_OPEN_MAX); @@ -380,9 +384,9 @@ childProcess(void *arg) */ { int errnum = errno; - restartableWrite(FAIL_FILENO, &errnum, sizeof(errnum)); + restartableWrite(fail_pipe_fd, &errnum, sizeof(errnum)); } - close(FAIL_FILENO); + close(fail_pipe_fd); _exit(-1); return 0; /* Suppress warning "no return value from function" */ } diff --git a/src/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/src/src/java.base/windows/classes/java/io/WinNTFileSystem.java index 94cac268ceb..15e7d3d22a0 100644 --- a/src/src/java.base/windows/classes/java/io/WinNTFileSystem.java +++ b/src/src/java.base/windows/classes/java/io/WinNTFileSystem.java @@ -62,7 +62,7 @@ private boolean isLetter(char c) { } private String slashify(String p) { - if ((p.length() > 0) && (p.charAt(0) != slash)) return slash + p; + if (!p.isEmpty() && p.charAt(0) != slash) return slash + p; else return p; } diff --git a/src/src/java.base/windows/classes/java/lang/ProcessImpl.java b/src/src/java.base/windows/classes/java/lang/ProcessImpl.java index d4063bdc606..8daa7ac58b7 100644 --- a/src/src/java.base/windows/classes/java/lang/ProcessImpl.java +++ b/src/src/java.base/windows/classes/java/lang/ProcessImpl.java @@ -38,6 +38,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Locale; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; @@ -46,6 +47,8 @@ import jdk.internal.misc.JavaIOFileDescriptorAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.ref.CleanerFactory; +import sun.security.action.GetBooleanAction; +import sun.security.action.GetPropertyAction; /* This class is for the exclusive use of ProcessBuilder.start() to * create new processes. @@ -205,12 +208,15 @@ private static String[] getTokensFromCommand(String command) { private static final int VERIFICATION_CMD_BAT = 0; private static final int VERIFICATION_WIN32 = 1; - private static final int VERIFICATION_LEGACY = 2; + private static final int VERIFICATION_WIN32_SAFE = 2; // inside quotes not allowed + private static final int VERIFICATION_LEGACY = 3; + // See Command shell overview for documentation of special characters. + // https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490954(v=technet.10) private static final char ESCAPE_VERIFICATION[][] = { // We guarantee the only command file execution for implicit [cmd.exe] run. // http://technet.microsoft.com/en-us/library/bb490954.aspx {' ', '\t', '<', '>', '&', '|', '^'}, - + {' ', '\t', '<', '>'}, {' ', '\t', '<', '>'}, {' ', '\t'} }; @@ -227,8 +233,25 @@ private static String createCommandLine(int verificationType, cmdbuf.append(' '); String s = cmd[i]; if (needsEscaping(verificationType, s)) { - cmdbuf.append('"').append(s); + cmdbuf.append('"'); + if (verificationType == VERIFICATION_WIN32_SAFE) { + // Insert the argument, adding '\' to quote any interior quotes + int length = s.length(); + for (int j = 0; j < length; j++) { + char c = s.charAt(j); + if (c == DOUBLEQUOTE) { + int count = countLeadingBackslash(verificationType, s, j); + while (count-- > 0) { + cmdbuf.append(BACKSLASH); // double the number of backslashes + } + cmdbuf.append(BACKSLASH); // backslash to quote the quote + } + cmdbuf.append(c); + } + } else { + cmdbuf.append(s); + } // The code protects the [java.exe] and console command line // parser, that interprets the [\"] combination as an escape // sequence for the ["] char. @@ -241,8 +264,9 @@ private static String createCommandLine(int verificationType, // command line parser. The case of the [""] tail escape // sequence could not be realized due to the argument validation // procedure. - if ((verificationType != VERIFICATION_CMD_BAT) && s.endsWith("\\")) { - cmdbuf.append('\\'); + int count = countLeadingBackslash(verificationType, s, s.length()); + while (count-- > 0) { + cmdbuf.append(BACKSLASH); // double the number of backslashes } cmdbuf.append('"'); } else { @@ -252,26 +276,16 @@ private static String createCommandLine(int verificationType, return cmdbuf.toString(); } - private static boolean isQuoted(boolean noQuotesInside, String arg, - String errorMessage) { - int lastPos = arg.length() - 1; - if (lastPos >=1 && arg.charAt(0) == '"' && arg.charAt(lastPos) == '"') { - // The argument has already been quoted. - if (noQuotesInside) { - if (arg.indexOf('"', 1) != lastPos) { - // There is ["] inside. - throw new IllegalArgumentException(errorMessage); - } - } - return true; - } - if (noQuotesInside) { - if (arg.indexOf('"') >= 0) { - // There is ["] inside. - throw new IllegalArgumentException(errorMessage); - } - } - return false; + /** + * Return the argument without quotes (1st and last) if present, else the arg. + * @param str a string + * @return the string without 1st and last quotes + */ + private static String unQuote(String str) { + int len = str.length(); + return (len >= 2 && str.charAt(0) == DOUBLEQUOTE && str.charAt(len - 1) == DOUBLEQUOTE) + ? str.substring(1, len - 1) + : str; } private static boolean needsEscaping(int verificationType, String arg) { @@ -282,9 +296,26 @@ private static boolean needsEscaping(int verificationType, String arg) { // For [.exe] or [.com] file the unpaired/internal ["] // in the argument is not a problem. - boolean argIsQuoted = isQuoted( - (verificationType == VERIFICATION_CMD_BAT), - arg, "Argument has embedded quote, use the explicit CMD.EXE call."); + String unquotedArg = unQuote(arg); + boolean argIsQuoted = !arg.equals(unquotedArg); + boolean embeddedQuote = unquotedArg.indexOf(DOUBLEQUOTE) >= 0; + + switch (verificationType) { + case VERIFICATION_CMD_BAT: + if (embeddedQuote) { + throw new IllegalArgumentException("Argument has embedded quote, " + + "use the explicit CMD.EXE call."); + } + break; // break determine whether to quote + case VERIFICATION_WIN32_SAFE: + if (argIsQuoted && embeddedQuote) { + throw new IllegalArgumentException("Malformed argument has embedded quote: " + + unquotedArg); + } + break; + default: + break; + } if (!argIsQuoted) { char testEscape[] = ESCAPE_VERIFICATION[verificationType]; @@ -300,13 +331,13 @@ private static boolean needsEscaping(int verificationType, String arg) { private static String getExecutablePath(String path) throws IOException { - boolean pathIsQuoted = isQuoted(true, path, - "Executable name has embedded quote, split the arguments"); - + String name = unQuote(path); + if (name.indexOf(DOUBLEQUOTE) >= 0) { + throw new IllegalArgumentException("Executable name has embedded quote, " + + "split the arguments: " + name); + } // Win32 CreateProcess requires path to be normalized - File fileToRun = new File(pathIsQuoted - ? path.substring(1, path.length() - 1) - : path); + File fileToRun = new File(name); // From the [CreateProcess] function documentation: // @@ -321,13 +352,26 @@ private static String getExecutablePath(String path) // sequence:..." // // In practice ANY non-existent path is extended by [.exe] extension - // in the [CreateProcess] funcion with the only exception: + // in the [CreateProcess] function with the only exception: // the path ends by (.) return fileToRun.getPath(); } + /** + * An executable is any program that is an EXE or does not have an extension + * and the Windows createProcess will be looking for .exe. + * The comparison is case insensitive based on the name. + * @param executablePath the executable file + * @return true if the path ends in .exe or does not have an extension. + */ + private boolean isExe(String executablePath) { + File file = new File(executablePath); + String upName = file.getName().toUpperCase(Locale.ROOT); + return (upName.endsWith(".EXE") || upName.indexOf('.') < 0); + } + // Old version that can be bypassed private boolean isShellFile(String executablePath) { String upPath = executablePath.toUpperCase(); return (upPath.endsWith(".CMD") || upPath.endsWith(".BAT")); @@ -338,6 +382,21 @@ private String quoteString(String arg) { return argbuf.append('"').append(arg).append('"').toString(); } + // Count backslashes before start index of string. + // .bat files don't include backslashes as part of the quote + private static int countLeadingBackslash(int verificationType, + CharSequence input, int start) { + if (verificationType == VERIFICATION_CMD_BAT) + return 0; + int j; + for (j = start - 1; j >= 0 && input.charAt(j) == BACKSLASH; j--) { + // just scanning backwards + } + return (start - 1) - j; // number of BACKSLASHES + } + + private static final char DOUBLEQUOTE = '\"'; + private static final char BACKSLASH = '\\'; private final long handle; private final ProcessHandle processHandle; @@ -353,15 +412,13 @@ private ProcessImpl(String cmd[], throws IOException { String cmdstr; - SecurityManager security = System.getSecurityManager(); - boolean allowAmbiguousCommands = false; - if (security == null) { - allowAmbiguousCommands = true; - String value = System.getProperty("jdk.lang.Process.allowAmbiguousCommands"); - if (value != null) - allowAmbiguousCommands = !"false".equalsIgnoreCase(value); - } - if (allowAmbiguousCommands) { + final SecurityManager security = System.getSecurityManager(); + final String value = GetPropertyAction. + privilegedGetProperty("jdk.lang.Process.allowAmbiguousCommands", + (security == null ? "true" : "false")); + final boolean allowAmbiguousCommands = !"false".equalsIgnoreCase(value); + + if (allowAmbiguousCommands && security == null) { // Legacy mode. // Normalize path if possible. @@ -408,11 +465,12 @@ private ProcessImpl(String cmd[], // Quotation protects from interpretation of the [path] argument as // start of longer path with spaces. Quotation has no influence to // [.exe] extension heuristic. + boolean isShell = allowAmbiguousCommands ? isShellFile(executablePath) + : !isExe(executablePath); cmdstr = createCommandLine( - // We need the extended verification procedure for CMD files. - isShellFile(executablePath) - ? VERIFICATION_CMD_BAT - : VERIFICATION_WIN32, + // We need the extended verification procedures + isShell ? VERIFICATION_CMD_BAT + : (allowAmbiguousCommands ? VERIFICATION_WIN32 : VERIFICATION_WIN32_SAFE), quoteString(executablePath), cmd); } diff --git a/src/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java b/src/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java index 7b931e5ded4..5f4df7aa1dd 100644 --- a/src/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java +++ b/src/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java @@ -145,9 +145,9 @@ protected boolean hostsEqual(URL u1, URL u2) { */ String s1 = u1.getHost(); String s2 = u2.getHost(); - if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2))) + if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty())) return true; - if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1))) + if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty())) return true; return super.hostsEqual(u1, u2); } diff --git a/src/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/src/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java index ef1269d4fdd..1fec7349274 100644 --- a/src/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java +++ b/src/src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2019, 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 @@ -202,7 +202,17 @@ public static boolean isTrustedSite(URL url) { } } - static native boolean isTrustedSite(String url); + private static final boolean isTrustedSiteAvailable = isTrustedSiteAvailable(); + + private static native boolean isTrustedSiteAvailable(); + + private static boolean isTrustedSite(String url) { + if (isTrustedSiteAvailable) + return isTrustedSite0(url); + return false; + } + + private static native boolean isTrustedSite0(String url); /** * Not supported. Must use the setHeaders() method diff --git a/src/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java b/src/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java index bc35a5d710f..53dfc86a69f 100644 --- a/src/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java +++ b/src/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java @@ -141,14 +141,8 @@ int setDirectIO(FileDescriptor fd, String path) { static boolean isFastFileTransferRequested() { String fileTransferProp = GetPropertyAction - .privilegedGetProperty("jdk.nio.enableFastFileTransfer"); - boolean enable; - if ("".equals(fileTransferProp)) { - enable = true; - } else { - enable = Boolean.parseBoolean(fileTransferProp); - } - return enable; + .privilegedGetProperty("jdk.nio.enableFastFileTransfer", "false"); + return fileTransferProp.isEmpty() ? true : Boolean.parseBoolean(fileTransferProp); } static { diff --git a/src/src/java.base/windows/classes/sun/nio/fs/DefaultFileSystemProvider.java b/src/src/java.base/windows/classes/sun/nio/fs/DefaultFileSystemProvider.java index 29ad11c78c3..bee8a08ee46 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/DefaultFileSystemProvider.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/DefaultFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,28 @@ package sun.nio.fs; -import java.nio.file.spi.FileSystemProvider; +import java.nio.file.FileSystem; /** - * Creates default provider on Windows + * Creates this platform's default FileSystemProvider. */ public class DefaultFileSystemProvider { + private static final WindowsFileSystemProvider INSTANCE + = new WindowsFileSystemProvider(); + private DefaultFileSystemProvider() { } - public static FileSystemProvider create() { - return new WindowsFileSystemProvider(); + + /** + * Returns the platform's default file system provider. + */ + public static WindowsFileSystemProvider instance() { + return INSTANCE; + } + + /** + * Returns the platform's default file system. + */ + public static FileSystem theFileSystem() { + return INSTANCE.theFileSystem(); } } diff --git a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java index bba794e21a7..62ba3716df0 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java @@ -116,8 +116,7 @@ class WindowsFileAttributes static { String propValue = GetPropertyAction.privilegedGetProperty( "sun.nio.fs.ensureAccurateMetadata", "false"); - ensureAccurateMetadata = (propValue.length() == 0) ? - true : Boolean.valueOf(propValue); + ensureAccurateMetadata = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue); } // attributes diff --git a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java index 9e74c6ed107..4dd90c714da 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java @@ -52,7 +52,7 @@ private WindowsFileStore(String root) throws WindowsException { // file store "display name" is the volume name if available String vol = volInfo.volumeName(); - if (vol.length() > 0) { + if (!vol.isEmpty()) { this.displayName = vol; } else { // TBD - should we map all types? Does this need to be localized? diff --git a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java index b07d50a0fc8..e9a65218163 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java @@ -218,7 +218,7 @@ public final Path getPath(String first, String... more) { StringBuilder sb = new StringBuilder(); sb.append(first); for (String segment: more) { - if (segment.length() > 0) { + if (!segment.isEmpty()) { if (sb.length() > 0) sb.append('\\'); sb.append(segment); diff --git a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java index 0ddcdcbc682..8db11c81907 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, 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 @@ -42,7 +42,7 @@ import static sun.nio.fs.WindowsSecurity.*; import static sun.nio.fs.WindowsConstants.*; -public class WindowsFileSystemProvider +class WindowsFileSystemProvider extends AbstractFileSystemProvider { private static final Unsafe unsafe = Unsafe.getUnsafe(); @@ -53,6 +53,10 @@ public WindowsFileSystemProvider() { theFileSystem = new WindowsFileSystem(this, StaticProperty.userDir()); } + WindowsFileSystem theFileSystem() { + return theFileSystem; + } + @Override public String getScheme() { return "file"; diff --git a/src/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java b/src/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java index 70fde0eb49d..3746c8b1db5 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java @@ -329,7 +329,7 @@ private static String readLinkImpl(long handle) throws IOException { // remove special prefix String target = stripPrefix(new String(name)); - if (target.length() == 0) { + if (target.isEmpty()) { throw new IOException("Symbolic link target is invalid"); } return target; diff --git a/src/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java b/src/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java index f4d70f94ad5..4500c733a34 100644 --- a/src/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java +++ b/src/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java @@ -243,7 +243,7 @@ private String getAbsolutePath() throws WindowsException { // relative to default directory String remaining = path.substring(root.length()); String defaultDirectory = getFileSystem().defaultDirectory(); - if (remaining.length() == 0) { + if (remaining.isEmpty()) { return defaultDirectory; } else if (defaultDirectory.endsWith("\\")) { return defaultDirectory + remaining; @@ -299,7 +299,7 @@ public WindowsFileSystem getFileSystem() { // -- Path operations -- private boolean isEmpty() { - return path.length() == 0; + return path.isEmpty(); } private WindowsPath emptyPath() { @@ -340,7 +340,7 @@ public WindowsPath getParent() { @Override public WindowsPath getRoot() { - if (root.length() == 0) + if (root.isEmpty()) return null; return new WindowsPath(getFileSystem(), type, root, root); } @@ -556,7 +556,7 @@ public WindowsPath normalize() { // corner case - all names removed if (remaining == 0) { - return (root.length() == 0) ? emptyPath() : getRoot(); + return root.isEmpty() ? emptyPath() : getRoot(); } // re-constitute the path from the remaining names. diff --git a/src/src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java b/src/src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java index 2f4fd0e89c6..85deffa746e 100644 --- a/src/src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java +++ b/src/src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -510,8 +510,15 @@ public String getDisplayLanguage(String languageCode, Locale locale) { public String getDisplayCountry(String countryCode, Locale locale) { // Retrieves the display country name by calling // GetLocaleInfoEx(LOCALE_SLOCALIZEDCOUNTRYNAME). - return getDisplayString(locale.toLanguageTag(), - DN_LOCALE_REGION, nativeDisplayLanguage+"-"+countryCode); + String str = getDisplayString(locale.toLanguageTag(), + DN_LOCALE_REGION, + nativeDisplayLanguage+"-"+countryCode); + // Hack: Windows 10 returns translated "Unknown Region (XX)" + // for localized XX region name. Take that as not known. + if (str != null && str.endsWith("("+countryCode+")")) { + return null; + } + return str; } @Override diff --git a/src/src/java.base/windows/native/libjava/HostLocaleProviderAdapter_md.c b/src/src/java.base/windows/native/libjava/HostLocaleProviderAdapter_md.c index 28663f768b5..8c1001a0154 100644 --- a/src/src/java.base/windows/native/libjava/HostLocaleProviderAdapter_md.c +++ b/src/src/java.base/windows/native/libjava/HostLocaleProviderAdapter_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -168,11 +168,6 @@ WCHAR * fixes[2][2][3][16] = } }; - -// Localized region name for unknown regions (Windows 10) -#define UNKNOWN_REGION L"Unknown Region (" -#define UNKNOWN_REGION_SIZE wcslen(UNKNOWN_REGION) - /* * Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl * Method: initialize @@ -755,15 +750,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte (*env)->ReleaseStringChars(env, jStr, pjChar); if (got) { - // Hack: Windows 10 returns "Unknown Region (XX)" for localized XX region name. - // Take that as not known. - if (type != sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_LOCALE_REGION || - wcsncmp(UNKNOWN_REGION, buf, UNKNOWN_REGION_SIZE) != 0) { - return (*env)->NewString(env, buf, (jsize)wcslen(buf)); - } + return (*env)->NewString(env, buf, (jsize)wcslen(buf)); + } else { + return NULL; } - - return NULL; } int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) { diff --git a/src/src/java.base/windows/native/libjli/java_md.c b/src/src/java.base/windows/native/libjli/java_md.c index f1458675594..36f59f9e781 100644 --- a/src/src/java.base/windows/native/libjli/java_md.c +++ b/src/src/java.base/windows/native/libjli/java_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -41,6 +41,8 @@ #define JVM_DLL "jvm.dll" #define JAVA_DLL "java.dll" +#define ELP_PREFIX L"\\\\?\\" + /* * Prototypes. */ @@ -495,6 +497,57 @@ JLI_Snprintf(char* buffer, size_t size, const char* format, ...) { return rc; } +/* On Windows, if _open fails, retry again with CreateFileW and + * "\\?\" prefix ( extended-length paths) - this allows to open paths with larger file names; + * otherwise we run into the MAX_PATH limitation */ +int JLI_Open(const char* name, int flags) { + int fd = _open(name, flags); + if (fd == -1 && errno == ENOENT) { + wchar_t* wname = NULL; + wchar_t* wfullname = NULL; + wchar_t* wfullname_w_prefix = NULL; + size_t wnamelen, wfullnamelen, elplen; + HANDLE h; + + wnamelen = strlen(name) + 1; + wname = (wchar_t*) malloc(wnamelen*sizeof(wchar_t)); + if (wname == NULL) { + goto end; + } + if (mbstowcs(wname, name, wnamelen - 1) == -1) { + goto end; + } + wname[wnamelen - 1] = L'\0'; + wfullname = _wfullpath(wfullname, wname, 0); + if (wfullname == NULL) { + goto end; + } + + wfullnamelen = wcslen(wfullname); + if (wfullnamelen > 247) { + elplen = wcslen(ELP_PREFIX); + wfullname_w_prefix = (wchar_t*) malloc((elplen+wfullnamelen+1)*sizeof(wchar_t)); + wcscpy(wfullname_w_prefix, ELP_PREFIX); + wcscpy(wfullname_w_prefix+elplen, wfullname); + + h = CreateFileW(wfullname_w_prefix, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) { + goto end; + } + /* associates fd with handle */ + fd = _open_osfhandle((intptr_t)h, _O_RDONLY); + } +end: + free(wname); + free(wfullname); + free(wfullname_w_prefix); + } + return fd; +} + + + JNIEXPORT void JNICALL JLI_ReportErrorMessage(const char* fmt, ...) { va_list vl; diff --git a/src/src/java.base/windows/native/libnet/NTLMAuthentication.c b/src/src/java.base/windows/native/libnet/NTLMAuthentication.c index 8e18f37d185..a97fc0bc077 100644 --- a/src/src/java.base/windows/native/libnet/NTLMAuthentication.c +++ b/src/src/java.base/windows/native/libnet/NTLMAuthentication.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,19 +26,44 @@ #include #include #include "jni_util.h" +#include "jdk_util.h" #include -JNIEXPORT jboolean JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthentication_isTrustedSite(JNIEnv *env, jclass clazz, jstring url ) +typedef HRESULT (WINAPI *CoInternetCreateSecurityManagerType) + (IServiceProvider*,IInternetSecurityManager**,DWORD); + +static CoInternetCreateSecurityManagerType fn_CoInternetCreateSecurityManager; + +JNIEXPORT jboolean JNICALL +Java_sun_net_www_protocol_http_ntlm_NTLMAuthentication_isTrustedSiteAvailable + (JNIEnv *env, jclass clazz) { + HMODULE libUrlmon = JDK_LoadSystemLibrary("urlmon.dll"); + if (libUrlmon != NULL) { + fn_CoInternetCreateSecurityManager = (CoInternetCreateSecurityManagerType) + GetProcAddress(libUrlmon, "CoInternetCreateSecurityManager"); + if (fn_CoInternetCreateSecurityManager != NULL) { + return JNI_TRUE; + } + } + return JNI_FALSE; +} +JNIEXPORT jboolean JNICALL +Java_sun_net_www_protocol_http_ntlm_NTLMAuthentication_isTrustedSite0 + (JNIEnv *env, jclass clazz, jstring url) +{ HRESULT hr; DWORD dwZone; DWORD pPolicy = 0; IInternetSecurityManager *spSecurityManager; jboolean ret; + if (fn_CoInternetCreateSecurityManager == NULL) + return JNI_FALSE; + // Create IInternetSecurityManager - hr = CoInternetCreateSecurityManager(NULL, &spSecurityManager, (DWORD)0); + hr = fn_CoInternetCreateSecurityManager(NULL, &spSecurityManager, (DWORD)0); if (FAILED(hr)) { return JNI_FALSE; } diff --git a/src/src/java.desktop/aix/native/libawt/porting_aix.c b/src/src/java.desktop/aix/native/libawt/porting_aix.c index 46d181c873a..73751e6356a 100644 --- a/src/src/java.desktop/aix/native/libawt/porting_aix.c +++ b/src/src/java.desktop/aix/native/libawt/porting_aix.c @@ -30,7 +30,7 @@ #include "porting_aix.h" -static unsigned char dladdr_buffer[0x4000]; +static unsigned char dladdr_buffer[0x8000]; static void fill_dll_info(void) { int rc = loadquery(L_GETINFO,dladdr_buffer, sizeof(dladdr_buffer)); diff --git a/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m index e497d06d523..a4cab6d42a6 100644 --- a/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m +++ b/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2018, 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 @@ -142,6 +142,11 @@ - (void) dealloc { fInputMethodLOCKABLE = NULL; } + if (rolloverTrackingArea != nil) { + [self removeTrackingArea:rolloverTrackingArea]; + [rolloverTrackingArea release]; + rolloverTrackingArea = nil; + } [super dealloc]; } @@ -282,7 +287,7 @@ - (void) keyDown: (NSEvent *)event { // Allow TSM to look at the event and potentially send back NSTextInputClient messages. [self interpretKeyEvents:[NSArray arrayWithObject:event]]; - if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] && + if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] && fInputMethodLOCKABLE) { fProcessingKeystroke = NO; @@ -290,7 +295,7 @@ - (void) keyDown: (NSEvent *)event { fInPressAndHold = YES; fPAHNeedsToSelect = YES; } else { - // Abandon input to reset IM and unblock input after canceling + // Abandon input to reset IM and unblock input after canceling // input accented symbols switch([event keyCode]) { diff --git a/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index 169cb30ffeb..cd279ffb7c4 100644 --- a/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/src/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -456,7 +456,7 @@ - (void) dealloc { JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; [self.javaPlatformWindow setJObject:nil withEnv:env]; - + self.javaPlatformWindow = nil; self.nsWindow = nil; self.ownerWindow = nil; [super dealloc]; diff --git a/src/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m b/src/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m index 0fb91161eb9..2e507a98c75 100644 --- a/src/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m +++ b/src/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m @@ -184,7 +184,7 @@ static JNF_MEMBER_CACHE(jm_displayReconfiguration, return; } - [wrapper setJObject:NULL withEnv:env]; // more efficiant to pre-clear + [wrapper setJObject:NULL withEnv:env]; // more efficient to pre-clear [wrapper release]; JNF_COCOA_EXIT(env); diff --git a/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java index 2dade4d67a4..54e4145aa01 100644 --- a/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java +++ b/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java @@ -535,6 +535,34 @@ public void paintMenuBarBackground(SynthContext context, Graphics g, } } + private int getBrightness(Color c) { + return Math.max(c.getRed(), Math.max(c.getGreen(), c.getBlue())); + } + + private int getMaxColorDiff(Color c1, Color c2) { + return Math.max(Math.abs(c1.getRed() - c2.getRed()), + Math.max(Math.abs(c1.getGreen() - c2.getGreen()), + Math.abs(c1.getBlue() - c2.getBlue()))); + } + + private int scaleColorComponent(int color, double scaleFactor) { + return (int)(color + color * scaleFactor); + } + private Color deriveColor(Color originalColor, int originalBrightness, + int targetBrightness) { + int r, g, b; + if (originalBrightness == 0) { + r = g = b = targetBrightness; + } else { + double scaleFactor = (targetBrightness - originalBrightness) + / originalBrightness ; + r = scaleColorComponent(originalColor.getRed(), scaleFactor); + g = scaleColorComponent(originalColor.getGreen(), scaleFactor); + b = scaleColorComponent(originalColor.getBlue(), scaleFactor); + } + return new Color(r, g, b); + } + // // MENU // @@ -551,6 +579,57 @@ public void paintMenuItemBackground(SynthContext context, int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); if (gtkState == SynthConstants.MOUSE_OVER) { + if (GTKLookAndFeel.is3() && context.getRegion() == Region.MENU) { + GTKStyle style = (GTKStyle)context.getStyle(); + Color highlightColor = style.getGTKColor( + GTKEngine.WidgetType.MENU_ITEM.ordinal(), + gtkState, ColorType.BACKGROUND.getID()); + Color backgroundColor = style.getGTKColor( + GTKEngine.WidgetType.MENU_BAR.ordinal(), + SynthConstants.ENABLED, ColorType.BACKGROUND.getID()); + + int minBrightness = 0, maxBrightness = 255; + int minBrightnessDifference = 100; + int actualBrightnessDifference = + getMaxColorDiff(highlightColor, backgroundColor); + if (actualBrightnessDifference < minBrightnessDifference) { + int highlightBrightness = + getBrightness(highlightColor); + int backgroundBrightness = + getBrightness(backgroundColor); + int originalHighlightBrightness = + highlightBrightness; + if (highlightBrightness >= backgroundBrightness) { + if (backgroundBrightness + minBrightnessDifference <= + maxBrightness) { + highlightBrightness = + backgroundBrightness + + minBrightnessDifference; + } else { + highlightBrightness = + backgroundBrightness - + minBrightnessDifference; + } + } else { + if (backgroundBrightness - minBrightnessDifference >= + minBrightness) { + highlightBrightness = + backgroundBrightness - + minBrightnessDifference; + } else { + highlightBrightness = + backgroundBrightness + + minBrightnessDifference; + } + } + + g.setColor(deriveColor(highlightColor, + originalHighlightBrightness, + highlightBrightness)); + g.fillRect(x, y, w, h); + return; + } + } Region id = Region.MENU_ITEM; synchronized (UNIXToolkit.GTK_LOCK) { if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) { diff --git a/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index 10b96e43fa5..f875f5bc622 100644 --- a/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/src/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -205,6 +205,14 @@ Color getGTKColor(int state, ColorType type) { return getGTKColor(null, state, type); } + Color getGTKColor(int widgetType, int state, int colorType) { + synchronized (sun.awt.UNIXToolkit.GTK_LOCK) { + int rgb = nativeGetColorForState(widgetType, state, + colorType); + return new ColorUIResource(rgb); + } + } + /** * Returns the color for the specified state. * diff --git a/src/src/java.desktop/share/classes/java/awt/Font.java b/src/src/java.desktop/share/classes/java/awt/Font.java index 55171679cd6..e8d6f001083 100644 --- a/src/src/java.desktop/share/classes/java/awt/Font.java +++ b/src/src/java.desktop/share/classes/java/awt/Font.java @@ -1936,6 +1936,7 @@ private void readObject(java.io.ObjectInputStream s) // value is the default. if (fRequestedAttributes != null) { + try { values = getAttributeValues(); // init AttributeValues extras = AttributeValues.fromSerializableHashtable(fRequestedAttributes); @@ -1945,10 +1946,13 @@ private void readObject(java.io.ObjectInputStream s) values = getAttributeValues().merge(extras); this.nonIdentityTx = values.anyNonDefault(EXTRA_MASK); this.hasLayoutAttributes = values.anyNonDefault(LAYOUT_MASK); - + } catch (Throwable t) { + throw new IOException(t); + } finally { fRequestedAttributes = null; // don't need it any more } } + } /** * Returns the number of glyphs in this {@code Font}. Glyph codes diff --git a/src/src/java.desktop/share/classes/sun/font/CMap.java b/src/src/java.desktop/share/classes/sun/font/CMap.java index ae31082a8b8..0e9bddb8ec9 100644 --- a/src/src/java.desktop/share/classes/sun/font/CMap.java +++ b/src/src/java.desktop/share/classes/sun/font/CMap.java @@ -130,7 +130,7 @@ abstract class CMap { static final char noSuchChar = (char)0xfffd; static final int SHORTMASK = 0x0000ffff; - static final int INTMASK = 0xffffffff; + static final int INTMASK = 0x7fffffff; static final char[][] converterMaps = new char[7][]; @@ -919,7 +919,11 @@ static class CMapFormat8 extends CMap { bbuffer.position(12); bbuffer.get(is32); - nGroups = bbuffer.getInt(); + nGroups = bbuffer.getInt() & INTMASK; + // A map group record is three uint32's making for 12 bytes total + if (bbuffer.remaining() < (12 * (long)nGroups)) { + throw new RuntimeException("Format 8 table exceeded"); + } startCharCode = new int[nGroups]; endCharCode = new int[nGroups]; startGlyphID = new int[nGroups]; @@ -947,9 +951,13 @@ static class CMapFormat10 extends CMap { CMapFormat10(ByteBuffer bbuffer, int offset, char[] xlat) { + bbuffer.position(offset+12); firstCode = bbuffer.getInt() & INTMASK; entryCount = bbuffer.getInt() & INTMASK; - bbuffer.position(offset+20); + // each glyph is a uint16, so 2 bytes per value. + if (bbuffer.remaining() < (2 * (long)entryCount)) { + throw new RuntimeException("Format 10 table exceeded"); + } CharBuffer buffer = bbuffer.asCharBuffer(); glyphIdArray = new char[entryCount]; for (int i=0; i< entryCount; i++) { @@ -989,11 +997,15 @@ static class CMapFormat12 extends CMap { throw new RuntimeException("xlat array for cmap fmt=12"); } - numGroups = buffer.getInt(offset+12); + buffer.position(offset+12); + numGroups = buffer.getInt() & INTMASK; + // A map group record is three uint32's making for 12 bytes total + if (buffer.remaining() < (12 * (long)numGroups)) { + throw new RuntimeException("Format 12 table exceeded"); + } startCharCode = new long[numGroups]; endCharCode = new long[numGroups]; startGlyphID = new int[numGroups]; - buffer.position(offset+16); buffer = buffer.slice(); IntBuffer ibuffer = buffer.asIntBuffer(); for (int i=0; i 0) { buffer.position(offset+tableOffset); numUVSMapping[i] = buffer.getInt() & INTMASK; + // a UVS mapping record is one 3 byte int + uint16 + // making for 5 bytes per record. + if (buffer.remaining() < (5 * (long)numUVSMapping[i])) { + throw new RuntimeException("Variations exceed buffer"); + } unicodeValue[i] = new int[numUVSMapping[i]]; glyphID[i] = new char[numUVSMapping[i]]; diff --git a/src/src/java.desktop/share/classes/sun/font/FileFont.java b/src/src/java.desktop/share/classes/sun/font/FileFont.java index 6764c309851..42f38206b2c 100644 --- a/src/src/java.desktop/share/classes/sun/font/FileFont.java +++ b/src/src/java.desktop/share/classes/sun/font/FileFont.java @@ -172,7 +172,7 @@ synchronized void deregisterFontAndClearStrikeCache() { } } if (scaler != null) { - scaler.dispose(); + scaler.disposeScaler(); } scaler = FontScaler.getNullScaler(); } diff --git a/src/src/java.desktop/share/classes/sun/font/FontScaler.java b/src/src/java.desktop/share/classes/sun/font/FontScaler.java index 566170f2f69..690f42c4a7d 100644 --- a/src/src/java.desktop/share/classes/sun/font/FontScaler.java +++ b/src/src/java.desktop/share/classes/sun/font/FontScaler.java @@ -173,6 +173,12 @@ abstract GeneralPath getGlyphVectorOutline(long pScalerContext, int[] glyphs, scaler context objects! */ public void dispose() {} + /** + * Used when the native resources held by the scaler need + * to be released before the 2D disposer runs. + */ + public void disposeScaler() {} + /* At the moment these 3 methods are needed for Type1 fonts only. * For Truetype fonts we extract required info outside of scaler * on java layer. diff --git a/src/src/java.desktop/share/classes/sun/font/FreetypeFontScaler.java b/src/src/java.desktop/share/classes/sun/font/FreetypeFontScaler.java index a7413d0a7b8..b6f309d1e05 100644 --- a/src/src/java.desktop/share/classes/sun/font/FreetypeFontScaler.java +++ b/src/src/java.desktop/share/classes/sun/font/FreetypeFontScaler.java @@ -167,6 +167,9 @@ synchronized long getLayoutTableCache() throws FontScalerException { return getLayoutTableCacheNative(nativeScaler); } + /* This method should not be called directly, in case + * it is being invoked from a thread with a native context. + */ public synchronized void dispose() { if (nativeScaler != 0L) { disposeNativeScaler(font.get(), nativeScaler); @@ -174,6 +177,21 @@ public synchronized void dispose() { } } + public synchronized void disposeScaler() { + if (nativeScaler != 0L) { + /* + * The current thread may be calling this method from the context + * of a JNI up-call. It will hold the native lock from the + * original down-call so can directly enter dispose and free + * the resources. So we need to schedule the disposal to happen + * only once we've returned from native. So by running the dispose + * on another thread which does nothing except that disposal we + * are sure that this is safe. + */ + new Thread(null, () -> dispose(), "free scaler", 0, false).start(); + } + } + synchronized int getNumGlyphs() throws FontScalerException { if (nativeScaler != 0L) { return getNumGlyphsNative(nativeScaler); @@ -210,7 +228,7 @@ synchronized long getUnitsPerEm() { return getUnitsPerEMNative(nativeScaler); } - long createScalerContext(double[] matrix, + synchronized long createScalerContext(double[] matrix, int aa, int fm, float boldness, float italic, boolean disableHinting) { if (nativeScaler != 0L) { @@ -240,7 +258,7 @@ private native GeneralPath getGlyphOutlineNative(Font2D font, private native GeneralPath getGlyphVectorOutlineNative(Font2D font, long pScalerContext, long pScaler, int[] glyphs, int numGlyphs, float x, float y); - native Point2D.Float getGlyphPointNative(Font2D font, + private native Point2D.Float getGlyphPointNative(Font2D font, long pScalerContext, long pScaler, int glyphCode, int ptNumber); private native long getLayoutTableCacheNative(long pScaler); @@ -253,7 +271,7 @@ native Point2D.Float getGlyphPointNative(Font2D font, private native long getUnitsPerEMNative(long pScaler); - native long createScalerContextNative(long pScaler, double[] matrix, + private native long createScalerContextNative(long pScaler, double[] matrix, int aa, int fm, float boldness, float italic); /* Freetype scaler context does not contain any pointers that diff --git a/src/src/java.desktop/share/classes/sun/font/GlyphList.java b/src/src/java.desktop/share/classes/sun/font/GlyphList.java index 6d124869cd4..f7abe09f57d 100644 --- a/src/src/java.desktop/share/classes/sun/font/GlyphList.java +++ b/src/src/java.desktop/share/classes/sun/font/GlyphList.java @@ -303,6 +303,14 @@ public int[] getBounds() { */ public void setGlyphIndex(int i) { glyphindex = i; + if (images[i] == 0L) { + metrics[0] = (int)gposx; + metrics[1] = (int)gposy; + metrics[2] = 0; + metrics[3] = 0; + metrics[4] = 0; + return; + } float gx = StrikeCache.unsafe.getFloat(images[i]+StrikeCache.topLeftXOffset); float gy = @@ -341,6 +349,9 @@ public byte[] getGrayBits() { graybits = new byte[len]; } } + if (images[glyphindex] == 0L) { + return graybits; + } long pixelDataAddress = StrikeCache.unsafe.getAddress(images[glyphindex] + StrikeCache.pixelDataOffset); @@ -448,6 +459,9 @@ private void fillBounds(int[] bounds) { char gw, gh; float gx, gy, gx0, gy0, gx1, gy1; for (int i=0; i data.length) { + if (offset < 0 || length < 0 || offset + length < length || + offset + length > data.length) { throw new ArrayIndexOutOfBoundsException("bad offset/length"); } if (font.hasLayoutAttributes()) { @@ -3053,7 +3054,8 @@ public void drawBytes(byte data[], int offset, int length, int x, int y) { if (data == null) { throw new NullPointerException("byte data is null"); } - if (offset < 0 || length < 0 || offset + length > data.length) { + if (offset < 0 || length < 0 || offset + length < length || + offset + length > data.length) { throw new ArrayIndexOutOfBoundsException("bad offset/length"); } /* Byte data is interpreted as 8-bit ASCII. Re-use drawChars loops */ diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java index ea2b929ef5d..98d540f0264 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java @@ -47,6 +47,8 @@ final class DDasher implements DPathConsumer2D, MarlinConst { static final double CURVE_LEN_ERR = MarlinProperties.getCurveLengthError(); // 0.01 initial static final double MIN_T_INC = 1.0d / (1 << REC_LIMIT); + static final double EPS = 1e-6d; + // More than 24 bits of mantissa means we can no longer accurately // measure the number of times cycled through the dash array so we // punt and override the phase to just be 0 past that point. @@ -269,6 +271,9 @@ public void moveTo(final double x0, final double y0) { private void emitSeg(double[] buf, int off, int type) { switch (type) { + case 4: + out.lineTo(buf[off], buf[off + 1]); + return; case 8: out.curveTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3], @@ -278,9 +283,6 @@ private void emitSeg(double[] buf, int off, int type) { out.quadTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3]); return; - case 4: - out.lineTo(buf[off], buf[off + 1]); - return; default: } } @@ -361,7 +363,7 @@ public void lineTo(final double x1, final double y1) { // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -416,13 +418,13 @@ private void _lineTo(final double x1, final double y1) { boolean _dashOn = dashOn; double _phase = phase; - double leftInThisDashSegment, d; + double leftInThisDashSegment, rem; while (true) { - d = _dash[_idx]; - leftInThisDashSegment = d - _phase; + leftInThisDashSegment = _dash[_idx] - _phase; + rem = len - leftInThisDashSegment; - if (len <= leftInThisDashSegment) { + if (rem <= EPS) { _curCurvepts[0] = x1; _curCurvepts[1] = y1; @@ -431,8 +433,8 @@ private void _lineTo(final double x1, final double y1) { // Advance phase within current dash segment _phase += len; - // TODO: compare double values using epsilon: - if (len == leftInThisDashSegment) { + // compare values using epsilon: + if (Math.abs(rem) <= EPS) { _phase = 0.0d; _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -440,17 +442,12 @@ private void _lineTo(final double x1, final double y1) { break; } - if (_phase == 0.0d) { - _curCurvepts[0] = cx0 + d * cx; - _curCurvepts[1] = cy0 + d * cy; - } else { - _curCurvepts[0] = cx0 + leftInThisDashSegment * cx; - _curCurvepts[1] = cy0 + leftInThisDashSegment * cy; - } + _curCurvepts[0] = cx0 + leftInThisDashSegment * cx; + _curCurvepts[1] = cy0 + leftInThisDashSegment * cy; goTo(_curCurvepts, 0, 4, _dashOn); - len -= leftInThisDashSegment; + len = rem; // Advance to next dash segment _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -506,18 +503,18 @@ public void skipLen() { _dashOn = (iterations + (_dashOn ? 1L : 0L) & 1L) == 1L; } - double leftInThisDashSegment, d; + double leftInThisDashSegment, rem; while (true) { - d = _dash[_idx]; - leftInThisDashSegment = d - _phase; + leftInThisDashSegment = _dash[_idx] - _phase; + rem = len - leftInThisDashSegment; - if (len <= leftInThisDashSegment) { + if (rem <= EPS) { // Advance phase within current dash segment _phase += len; - // TODO: compare double values using epsilon: - if (len == leftInThisDashSegment) { + // compare values using epsilon: + if (Math.abs(rem) <= EPS) { _phase = 0.0d; _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -525,7 +522,7 @@ public void skipLen() { break; } - len -= leftInThisDashSegment; + len = rem; // Advance to next dash segment _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -579,7 +576,9 @@ private void somethingTo(final int type) { goTo(_curCurvepts, curCurveoff + 2, type, _dashOn); _phase += _li.lastSegLen(); - if (_phase >= _dash[_idx]) { + + // compare values using epsilon: + if (_phase + EPS >= _dash[_idx]) { _phase = 0.0d; _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -938,7 +937,7 @@ public void curveTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -1024,7 +1023,7 @@ public void quadTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java index b5ef8904acd..cb9f9449c02 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java @@ -243,7 +243,7 @@ static int findSubdivPoints(final DCurve c, final double[] pts, final double y12 = pts[3] - pts[1]; // if the curve is already parallel to either axis we gain nothing // from rotating it. - if ((y12 != 0.0d && x12 != 0.0d)) { + if ((y12 != 0.0d) && (x12 != 0.0d)) { // we rotate it so that the first vector in the control polygon is // parallel to the x-axis. This will ensure that rotated quarter // circles won't be subdivided. @@ -764,17 +764,17 @@ void pullAll(final DPathConsumer2D io) { io.lineTo(_curves[e], _curves[e+1]); e += 2; continue; - case TYPE_QUADTO: - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - e += 4; - continue; case TYPE_CUBICTO: io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); e += 6; continue; + case TYPE_QUADTO: + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + e += 4; + continue; default: } } @@ -806,17 +806,17 @@ void popAll(final DPathConsumer2D io) { e -= 2; io.lineTo(_curves[e], _curves[e+1]); continue; - case TYPE_QUADTO: - e -= 4; - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - continue; case TYPE_CUBICTO: e -= 6; io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); continue; + case TYPE_QUADTO: + e -= 4; + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + continue; default: } } diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java index 5fecec848a6..bd14b8fe44c 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java @@ -540,7 +540,7 @@ private void lineTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -634,6 +634,9 @@ public void closePath() { emitReverse(); this.prev = CLOSE; + this.cx0 = sx0; + this.cy0 = sy0; + this.cOutCode = sOutCode; if (opened) { // do not emit close @@ -668,7 +671,9 @@ private void finish(final int outcode) { // i.e. if caps must be drawn or not ? // Solution: use the ClosedPathDetector before Stroker to determine // if the path is a closed path or not - if (!rdrCtx.closedPath) { + if (rdrCtx.closedPath) { + emitReverse(); + } else { if (outcode == 0) { // current point = end's cap: if (capStyle == CAP_ROUND) { @@ -693,8 +698,6 @@ private void finish(final int outcode) { } } } - } else { - emitReverse(); } emitClose(); } @@ -1058,7 +1061,7 @@ public void curveTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -1206,7 +1209,7 @@ public void quadTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java index 353f9defe70..17667295f41 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java @@ -530,6 +530,9 @@ static final class PathClipFilter implements DPathConsumer2D { private boolean outside = false; + // The starting point of the path + private double sx0, sy0; + // The current point (TODO stupid repeated info) private double cx0, cy0; @@ -630,17 +633,26 @@ public void closePath() { finishPath(); out.closePath(); + + // back to starting point: + this.cOutCode = DHelpers.outcode(sx0, sy0, clipRect); + this.cx0 = sx0; + this.cy0 = sy0; } @Override public void moveTo(final double x0, final double y0) { finishPath(); - this.cOutCode = DHelpers.outcode(x0, y0, clipRect); - this.outside = false; out.moveTo(x0, y0); + + // update starting point: + this.cOutCode = DHelpers.outcode(x0, y0, clipRect); this.cx0 = x0; this.cy0 = y0; + + this.sx0 = x0; + this.sy0 = y0; } @Override @@ -655,7 +667,7 @@ public void lineTo(final double xe, final double ye) { // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -754,7 +766,7 @@ public void curveTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -816,7 +828,7 @@ public void quadTo(final double x1, final double y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -1153,13 +1165,13 @@ PathTracer init(DPathConsumer2D out) { @Override public void moveTo(double x0, double y0) { - log("moveTo (" + x0 + ", " + y0 + ')'); + log("p.moveTo(" + x0 + ", " + y0 + ");"); out.moveTo(x0, y0); } @Override public void lineTo(double x1, double y1) { - log("lineTo (" + x1 + ", " + y1 + ')'); + log("p.lineTo(" + x1 + ", " + y1 + ");"); out.lineTo(x1, y1); } @@ -1168,25 +1180,26 @@ public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { - log("curveTo P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ") P3(" + x3 + ", " + y3 + ')'); + log("p.curveTo(" + x1 + ", " + y1 + ", " + x2 + ", " + y2 + ", " + x3 + ", " + y3 + ");"); out.curveTo(x1, y1, x2, y2, x3, y3); } @Override - public void quadTo(double x1, double y1, double x2, double y2) { - log("quadTo P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ')'); + public void quadTo(double x1, double y1, + double x2, double y2) { + log("p.quadTo(" + x1 + ", " + y1 + ", " + x2 + ", " + y2 + ");"); out.quadTo(x1, y1, x2, y2); } @Override public void closePath() { - log("closePath"); + log("p.closePath();"); out.closePath(); } @Override public void pathDone() { - log("pathDone"); + log("p.pathDone();"); out.pathDone(); } diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java index 1cfbf401136..c69fe09f20c 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java @@ -48,6 +48,8 @@ final class Dasher implements PathConsumer2D, MarlinConst { static final float CURVE_LEN_ERR = MarlinProperties.getCurveLengthError(); // 0.01 static final float MIN_T_INC = 1.0f / (1 << REC_LIMIT); + static final float EPS = 1e-6f; + // More than 24 bits of mantissa means we can no longer accurately // measure the number of times cycled through the dash array so we // punt and override the phase to just be 0 past that point. @@ -270,6 +272,9 @@ public void moveTo(final float x0, final float y0) { private void emitSeg(float[] buf, int off, int type) { switch (type) { + case 4: + out.lineTo(buf[off], buf[off + 1]); + return; case 8: out.curveTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3], @@ -279,9 +284,6 @@ private void emitSeg(float[] buf, int off, int type) { out.quadTo(buf[off ], buf[off + 1], buf[off + 2], buf[off + 3]); return; - case 4: - out.lineTo(buf[off], buf[off + 1]); - return; default: } } @@ -362,7 +364,7 @@ public void lineTo(final float x1, final float y1) { // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -417,13 +419,13 @@ private void _lineTo(final float x1, final float y1) { boolean _dashOn = dashOn; float _phase = phase; - float leftInThisDashSegment, d; + float leftInThisDashSegment, rem; while (true) { - d = _dash[_idx]; - leftInThisDashSegment = d - _phase; + leftInThisDashSegment = _dash[_idx] - _phase; + rem = len - leftInThisDashSegment; - if (len <= leftInThisDashSegment) { + if (rem <= EPS) { _curCurvepts[0] = x1; _curCurvepts[1] = y1; @@ -432,8 +434,8 @@ private void _lineTo(final float x1, final float y1) { // Advance phase within current dash segment _phase += len; - // TODO: compare float values using epsilon: - if (len == leftInThisDashSegment) { + // compare values using epsilon: + if (Math.abs(rem) <= EPS) { _phase = 0.0f; _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -441,17 +443,12 @@ private void _lineTo(final float x1, final float y1) { break; } - if (_phase == 0.0f) { - _curCurvepts[0] = cx0 + d * cx; - _curCurvepts[1] = cy0 + d * cy; - } else { - _curCurvepts[0] = cx0 + leftInThisDashSegment * cx; - _curCurvepts[1] = cy0 + leftInThisDashSegment * cy; - } + _curCurvepts[0] = cx0 + leftInThisDashSegment * cx; + _curCurvepts[1] = cy0 + leftInThisDashSegment * cy; goTo(_curCurvepts, 0, 4, _dashOn); - len -= leftInThisDashSegment; + len = rem; // Advance to next dash segment _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -507,18 +504,18 @@ public void skipLen() { _dashOn = (iterations + (_dashOn ? 1L : 0L) & 1L) == 1L; } - float leftInThisDashSegment, d; + float leftInThisDashSegment, rem; while (true) { - d = _dash[_idx]; - leftInThisDashSegment = d - _phase; + leftInThisDashSegment = _dash[_idx] - _phase; + rem = len - leftInThisDashSegment; - if (len <= leftInThisDashSegment) { + if (rem <= EPS) { // Advance phase within current dash segment _phase += len; - // TODO: compare float values using epsilon: - if (len == leftInThisDashSegment) { + // compare values using epsilon: + if (Math.abs(rem) <= EPS) { _phase = 0.0f; _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -526,7 +523,7 @@ public void skipLen() { break; } - len -= leftInThisDashSegment; + len = rem; // Advance to next dash segment _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -580,7 +577,9 @@ private void somethingTo(final int type) { goTo(_curCurvepts, curCurveoff + 2, type, _dashOn); _phase += _li.lastSegLen(); - if (_phase >= _dash[_idx]) { + + // compare values using epsilon: + if (_phase + EPS >= _dash[_idx]) { _phase = 0.0f; _idx = (_idx + 1) % _dashLen; _dashOn = !_dashOn; @@ -939,7 +938,7 @@ public void curveTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -1025,7 +1024,7 @@ public void quadTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java index a531f083992..2043ab3ce6e 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java @@ -251,7 +251,7 @@ static int findSubdivPoints(final Curve c, final float[] pts, final float y12 = pts[3] - pts[1]; // if the curve is already parallel to either axis we gain nothing // from rotating it. - if ((y12 != 0.0f && x12 != 0.0f)) { + if ((y12 != 0.0f) && (x12 != 0.0f)) { // we rotate it so that the first vector in the control polygon is // parallel to the x-axis. This will ensure that rotated quarter // circles won't be subdivided. @@ -772,17 +772,17 @@ void pullAll(final PathConsumer2D io) { io.lineTo(_curves[e], _curves[e+1]); e += 2; continue; - case TYPE_QUADTO: - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - e += 4; - continue; case TYPE_CUBICTO: io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); e += 6; continue; + case TYPE_QUADTO: + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + e += 4; + continue; default: } } @@ -814,17 +814,17 @@ void popAll(final PathConsumer2D io) { e -= 2; io.lineTo(_curves[e], _curves[e+1]); continue; - case TYPE_QUADTO: - e -= 4; - io.quadTo(_curves[e], _curves[e+1], - _curves[e+2], _curves[e+3]); - continue; case TYPE_CUBICTO: e -= 6; io.curveTo(_curves[e], _curves[e+1], _curves[e+2], _curves[e+3], _curves[e+4], _curves[e+5]); continue; + case TYPE_QUADTO: + e -= 4; + io.quadTo(_curves[e], _curves[e+1], + _curves[e+2], _curves[e+3]); + continue; default: } } diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java index 1e18941a0c1..255e0fe0aed 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java @@ -542,7 +542,7 @@ private void lineTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -636,6 +636,9 @@ public void closePath() { emitReverse(); this.prev = CLOSE; + this.cx0 = sx0; + this.cy0 = sy0; + this.cOutCode = sOutCode; if (opened) { // do not emit close @@ -670,7 +673,9 @@ private void finish(final int outcode) { // i.e. if caps must be drawn or not ? // Solution: use the ClosedPathDetector before Stroker to determine // if the path is a closed path or not - if (!rdrCtx.closedPath) { + if (rdrCtx.closedPath) { + emitReverse(); + } else { if (outcode == 0) { // current point = end's cap: if (capStyle == CAP_ROUND) { @@ -695,8 +700,6 @@ private void finish(final int outcode) { } } } - } else { - emitReverse(); } emitClose(); } @@ -1060,7 +1063,7 @@ public void curveTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -1208,7 +1211,7 @@ public void quadTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java index fb4c34f0a24..f8af398eefc 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java @@ -531,6 +531,9 @@ static final class PathClipFilter implements PathConsumer2D { private boolean outside = false; + // The starting point of the path + private float sx0, sy0; + // The current point (TODO stupid repeated info) private float cx0, cy0; @@ -631,17 +634,26 @@ public void closePath() { finishPath(); out.closePath(); + + // back to starting point: + this.cOutCode = Helpers.outcode(sx0, sy0, clipRect); + this.cx0 = sx0; + this.cy0 = sy0; } @Override public void moveTo(final float x0, final float y0) { finishPath(); - this.cOutCode = Helpers.outcode(x0, y0, clipRect); - this.outside = false; out.moveTo(x0, y0); + + // update starting point: + this.cOutCode = Helpers.outcode(x0, y0, clipRect); this.cx0 = x0; this.cy0 = y0; + + this.sx0 = x0; + this.sy0 = y0; } @Override @@ -656,7 +668,7 @@ public void lineTo(final float xe, final float ye) { // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -755,7 +767,7 @@ public void curveTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -817,7 +829,7 @@ public void quadTo(final float x1, final float y1, // basic rejection criteria: if (sideCode == 0) { - // ovelap clip: + // overlap clip: if (subdivide) { // avoid reentrance subdivide = false; @@ -1154,13 +1166,13 @@ PathTracer init(PathConsumer2D out) { @Override public void moveTo(float x0, float y0) { - log("moveTo (" + x0 + ", " + y0 + ')'); + log("p.moveTo(" + x0 + ", " + y0 + ");"); out.moveTo(x0, y0); } @Override public void lineTo(float x1, float y1) { - log("lineTo (" + x1 + ", " + y1 + ')'); + log("p.lineTo(" + x1 + ", " + y1 + ");"); out.lineTo(x1, y1); } @@ -1169,25 +1181,26 @@ public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) { - log("curveTo P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ") P3(" + x3 + ", " + y3 + ')'); + log("p.curveTo(" + x1 + ", " + y1 + ", " + x2 + ", " + y2 + ", " + x3 + ", " + y3 + ");"); out.curveTo(x1, y1, x2, y2, x3, y3); } @Override - public void quadTo(float x1, float y1, float x2, float y2) { - log("quadTo P1(" + x1 + ", " + y1 + ") P2(" + x2 + ", " + y2 + ')'); + public void quadTo(float x1, float y1, + float x2, float y2) { + log("p.quadTo(" + x1 + ", " + y1 + ", " + x2 + ", " + y2 + ");"); out.quadTo(x1, y1, x2, y2); } @Override public void closePath() { - log("closePath"); + log("p.closePath();"); out.closePath(); } @Override public void pathDone() { - log("pathDone"); + log("p.pathDone();"); out.pathDone(); } diff --git a/src/src/java.desktop/share/classes/sun/java2d/marlin/Version.java b/src/src/java.desktop/share/classes/sun/java2d/marlin/Version.java index 8a1f8e544fa..e7e94ffe397 100644 --- a/src/src/java.desktop/share/classes/sun/java2d/marlin/Version.java +++ b/src/src/java.desktop/share/classes/sun/java2d/marlin/Version.java @@ -27,7 +27,7 @@ public final class Version { - private static final String VERSION = "marlin-0.9.1.1-Unsafe-OpenJDK"; + private static final String VERSION = "marlin-0.9.1.2-Unsafe-OpenJDK"; public static String getVersion() { return VERSION; diff --git a/src/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/src/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index 0f5a99fe49d..30e4c11f8ec 100644 --- a/src/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/src/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -1275,10 +1275,12 @@ protected void setAttributes(PrintRequestAttributeSet attributes) printerResAttr = (PrinterResolution) service.getDefaultAttributeValue(PrinterResolution.class); } - double xr = - printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI); - double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI); - setXYRes(xr, yr); + if (printerResAttr != null) { + double xr = + printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI); + double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI); + setXYRes(xr, yr); + } } pageRangesAttr = (PageRanges)attributes.get(PageRanges.class); diff --git a/src/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java b/src/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java index 5ba53ed42e3..cdfd258e605 100644 --- a/src/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java +++ b/src/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java @@ -524,11 +524,15 @@ public static void drawString(JComponent c, Graphics g, String text, String trimmedText = trimTrailingSpaces(text); if (!trimmedText.isEmpty()) { float screenWidth = (float) g2d.getFont().getStringBounds - (trimmedText, DEFAULT_FRC).getWidth(); + (trimmedText, getFontRenderContext(c)).getWidth(); TextLayout layout = createTextLayout(c, text, g2d.getFont(), g2d.getFontRenderContext()); - layout = layout.getJustifiedLayout(screenWidth); + // If text fits the screenWidth, then do not need to justify + if (SwingUtilities2.stringWidth(c, g2d.getFontMetrics(), + trimmedText) > screenWidth) { + layout = layout.getJustifiedLayout(screenWidth); + } /* Use alternate print color if specified */ Color col = g2d.getColor(); if (col instanceof PrintColorUIResource) { @@ -677,8 +681,12 @@ public static void drawStringUnderlineCharAt(JComponent c, Graphics g, g2d.getFontRenderContext()); if (isPrinting) { float screenWidth = (float)g2d.getFont(). - getStringBounds(text, DEFAULT_FRC).getWidth(); - layout = layout.getJustifiedLayout(screenWidth); + getStringBounds(text, getFontRenderContext(c)).getWidth(); + // If text fits the screenWidth, then do not need to justify + if (SwingUtilities2.stringWidth(c, g2d.getFontMetrics(), + text) > screenWidth) { + layout = layout.getJustifiedLayout(screenWidth); + } } TextHitInfo leading = TextHitInfo.leading(underlinedIndex); @@ -863,7 +871,11 @@ public static float drawChars(JComponent c, Graphics g, if (!trimmedText.isEmpty()) { float screenWidth = (float)g2d.getFont(). getStringBounds(trimmedText, frc).getWidth(); - layout = layout.getJustifiedLayout(screenWidth); + // If text fits the screenWidth, then do not need to justify + if (SwingUtilities2.stringWidth(c, g2d.getFontMetrics(), + trimmedText) > screenWidth) { + layout = layout.getJustifiedLayout(screenWidth); + } /* Use alternate print color if specified */ Color col = g2d.getColor(); diff --git a/src/src/java.desktop/share/legal/freetype.md b/src/src/java.desktop/share/legal/freetype.md index d943e083981..2e960020838 100644 --- a/src/src/java.desktop/share/legal/freetype.md +++ b/src/src/java.desktop/share/legal/freetype.md @@ -1,4 +1,4 @@ -## The FreeType Project: Freetype v2.9.1 +## The FreeType Project: Freetype v2.10.0 ### FreeType Notice diff --git a/src/src/java.desktop/share/legal/libpng.md b/src/src/java.desktop/share/legal/libpng.md index 746946c99b6..655cd095fe8 100644 --- a/src/src/java.desktop/share/legal/libpng.md +++ b/src/src/java.desktop/share/legal/libpng.md @@ -1,57 +1,87 @@ -## libpng v1.6.35 +## libpng v1.6.37 ### libpng License

     
    -This copy of the libpng notices is provided for your convenience.  In case of
    -any discrepancy between this copy and the notices in the file png.h that is
    -included in the libpng distribution, the latter shall prevail.
    +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
    +=========================================
     
    -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
    +PNG Reference Library License version 2
    +---------------------------------------
     
    -If you modify libpng you may insert additional notices immediately following
    -this sentence.
    + * Copyright (c) 1995-2019 The PNG Reference Library Authors.
    + * Copyright (c) 2018-2019 Cosmin Truta.
    + * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
    + * Copyright (c) 1996-1997 Andreas Dilger.
    + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
     
    -This code is released under the libpng license.
    +The software is supplied "as is", without warranty of any kind,
    +express or implied, including, without limitation, the warranties
    +of merchantability, fitness for a particular purpose, title, and
    +non-infringement.  In no event shall the Copyright owners, or
    +anyone distributing the software, be liable for any damages or
    +other liability, whether in contract, tort or otherwise, arising
    +from, out of, or in connection with the software, or the use or
    +other dealings in the software, even if advised of the possibility
    +of such damage.
     
    -libpng versions 1.0.7, July 1, 2000 through 1.6.35, September 29, 2017 are
    +Permission is hereby granted to use, copy, modify, and distribute
    +this software, or portions hereof, for any purpose, without fee,
    +subject to the following restrictions:
    +
    + 1. The origin of this software must not be misrepresented; you
    +    must not claim that you wrote the original software.  If you
    +    use this software in a product, an acknowledgment in the product
    +    documentation would be appreciated, but is not required.
    +
    + 2. Altered source versions must be plainly marked as such, and must
    +    not be misrepresented as being the original software.
    +
    + 3. This Copyright notice may not be removed or altered from any
    +    source or altered source distribution.
    +
    +
    +PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
    +-----------------------------------------------------------------------
    +
    +libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
     Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
     derived from libpng-1.0.6, and are distributed according to the same
     disclaimer and license as libpng-1.0.6 with the following individuals
     added to the list of Contributing Authors:
     
    -   Simon-Pierre Cadieux
    -   Eric S. Raymond
    -   Mans Rullgard
    -   Cosmin Truta
    -   Gilles Vollant
    -   James Yu
    -   Mandar Sahastrabuddhe
    -   Google Inc.
    -   Vadim Barkov
    +    Simon-Pierre Cadieux
    +    Eric S. Raymond
    +    Mans Rullgard
    +    Cosmin Truta
    +    Gilles Vollant
    +    James Yu
    +    Mandar Sahastrabuddhe
    +    Google Inc.
    +    Vadim Barkov
     
     and with the following additions to the disclaimer:
     
    -   There is no warranty against interference with your enjoyment of the
    -   library or against infringement.  There is no warranty that our
    -   efforts or the library will fulfill any of your particular purposes
    -   or needs.  This library is provided with all faults, and the entire
    -   risk of satisfactory quality, performance, accuracy, and effort is with
    -   the user.
    +    There is no warranty against interference with your enjoyment of
    +    the library or against infringement.  There is no warranty that our
    +    efforts or the library will fulfill any of your particular purposes
    +    or needs.  This library is provided with all faults, and the entire
    +    risk of satisfactory quality, performance, accuracy, and effort is
    +    with the user.
     
     Some files in the "contrib" directory and some configure-generated
    -files that are distributed with libpng have other copyright owners and
    +files that are distributed with libpng have other copyright owners, and
     are released under other open source licenses.
     
     libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
     Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
     libpng-0.96, and are distributed according to the same disclaimer and
    -license as libpng-0.96, with the following individuals added to the list
    -of Contributing Authors:
    +license as libpng-0.96, with the following individuals added to the
    +list of Contributing Authors:
     
    -   Tom Lane
    -   Glenn Randers-Pehrson
    -   Willem van Schaik
    +    Tom Lane
    +    Glenn Randers-Pehrson
    +    Willem van Schaik
     
     libpng versions 0.89, June 1996, through 0.96, May 1997, are
     Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
    @@ -59,14 +89,14 @@ and are distributed according to the same disclaimer and license as
     libpng-0.88, with the following individuals added to the list of
     Contributing Authors:
     
    -   John Bowler
    -   Kevin Bracey
    -   Sam Bushell
    -   Magnus Holmgren
    -   Greg Roelofs
    -   Tom Tanner
    +    John Bowler
    +    Kevin Bracey
    +    Sam Bushell
    +    Magnus Holmgren
    +    Greg Roelofs
    +    Tom Tanner
     
    -Some files in the "scripts" directory have other copyright owners
    +Some files in the "scripts" directory have other copyright owners,
     but are released under this license.
     
     libpng versions 0.5, May 1995, through 0.88, January 1996, are
    @@ -75,38 +105,37 @@ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
     For the purposes of this copyright and license, "Contributing Authors"
     is defined as the following set of individuals:
     
    -   Andreas Dilger
    -   Dave Martindale
    -   Guy Eric Schalnat
    -   Paul Schmidt
    -   Tim Wegner
    -
    -The PNG Reference Library is supplied "AS IS".  The Contributing Authors
    -and Group 42, Inc. disclaim all warranties, expressed or implied,
    -including, without limitation, the warranties of merchantability and of
    -fitness for any purpose.  The Contributing Authors and Group 42, Inc.
    -assume no liability for direct, indirect, incidental, special, exemplary,
    -or consequential damages, which may result from the use of the PNG
    -Reference Library, even if advised of the possibility of such damage.
    +    Andreas Dilger
    +    Dave Martindale
    +    Guy Eric Schalnat
    +    Paul Schmidt
    +    Tim Wegner
    +
    +The PNG Reference Library is supplied "AS IS".  The Contributing
    +Authors and Group 42, Inc. disclaim all warranties, expressed or
    +implied, including, without limitation, the warranties of
    +merchantability and of fitness for any purpose.  The Contributing
    +Authors and Group 42, Inc. assume no liability for direct, indirect,
    +incidental, special, exemplary, or consequential damages, which may
    +result from the use of the PNG Reference Library, even if advised of
    +the possibility of such damage.
     
     Permission is hereby granted to use, copy, modify, and distribute this
     source code, or portions hereof, for any purpose, without fee, subject
     to the following restrictions:
     
    -  1. The origin of this source code must not be misrepresented.
    -
    -  2. Altered versions must be plainly marked as such and must not
    -     be misrepresented as being the original source.
    + 1. The origin of this source code must not be misrepresented.
     
    -  3. This Copyright notice may not be removed or altered from any
    -     source or altered source distribution.
    + 2. Altered versions must be plainly marked as such and must not
    +    be misrepresented as being the original source.
     
    -The Contributing Authors and Group 42, Inc. specifically permit, without
    -fee, and encourage the use of this source code as a component to
    -supporting the PNG file format in commercial products.  If you use this
    -source code in a product, acknowledgment is not required but would be
    -appreciated.
    + 3. This Copyright notice may not be removed or altered from any
    +    source or altered source distribution.
     
    -END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
    +The Contributing Authors and Group 42, Inc. specifically permit,
    +without fee, and encourage the use of this source code as a component
    +to supporting the PNG file format in commercial products.  If you use
    +this source code in a product, acknowledgment is not required but would
    +be appreciated.
     
     
    diff --git a/src/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c b/src/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c index c96791f76cc..8e577e11788 100644 --- a/src/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c +++ b/src/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -208,21 +208,22 @@ OGLBlitSwToSurface(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, j2d_glPixelZoom(scalex, -scaley); + GLvoid *pSrc = PtrCoord(srcInfo->rasBase, sx1, srcInfo->pixelStride, + sy1, srcInfo->scanStride); + // in case pixel stride is not a multiple of scanline stride the copy // has to be done line by line (see 6207877) if (srcInfo->scanStride % srcInfo->pixelStride != 0) { jint width = sx2-sx1; jint height = sy2-sy1; - GLvoid *pSrc = srcInfo->rasBase; - while (height > 0) { j2d_glDrawPixels(width, 1, pf->format, pf->type, pSrc); - j2d_glBitmap(0, 0, 0, 0, (GLfloat)0, (GLfloat)-1, NULL); + j2d_glBitmap(0, 0, 0, 0, (GLfloat)0, (GLfloat)-scaley, NULL); pSrc = PtrAddBytes(pSrc, srcInfo->scanStride); height--; } } else { - j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, srcInfo->rasBase); + j2d_glDrawPixels(sx2-sx1, sy2-sy1, pf->format, pf->type, pSrc); } j2d_glPixelZoom(1.0, 1.0); @@ -317,12 +318,11 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, ty2 = ((GLdouble)sh) / th; if (swsurface) { + GLvoid *pSrc = PtrCoord(srcInfo->rasBase, + sx, srcInfo->pixelStride, + sy, srcInfo->scanStride); if (slowPath) { jint tmph = sh; - GLvoid *pSrc = PtrCoord(srcInfo->rasBase, - sx, srcInfo->pixelStride, - sy, srcInfo->scanStride); - while (tmph > 0) { j2d_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, sh - tmph, sw, 1, @@ -332,16 +332,10 @@ OGLBlitToSurfaceViaTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo, tmph--; } } else { - j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx); - j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy); - j2d_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, sw, sh, pf->format, pf->type, - srcInfo->rasBase); - - j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + pSrc); } // the texture image is "right side up", so we align the @@ -638,8 +632,9 @@ OGLBlitLoops_Blit(JNIEnv *env, J2dTraceLn4(J2D_TRACE_VERBOSE, " dx1=%f dy1=%f dx2=%f dy2=%f", dx1, dy1, dx2, dy2); - j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx1); - j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sy1); + // Note: we will calculate x/y positions in the raster manually + j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); j2d_glPixelStorei(GL_UNPACK_ROW_LENGTH, srcInfo.scanStride / srcInfo.pixelStride); j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, pf.alignment); @@ -696,8 +691,6 @@ OGLBlitLoops_Blit(JNIEnv *env, } } - j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); j2d_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } @@ -717,8 +710,8 @@ void flip(void *pDst, juint w, juint h, jint scanStride, jboolean convert) { juint step = 0; // vertical flip and convert argbpre to argb if necessary for (; i < h / 2; ++i) { - juint *r1 = PtrAddBytes(pDst, (i * scanStride)); - juint *r2 = PtrAddBytes(pDst, (h - i - 1) * scanStride); + juint *r1 = PtrPixelsRow(pDst, i, scanStride); + juint *r2 = PtrPixelsRow(pDst, h - i - 1, scanStride); if (tempRow) { // fast path memcpy(tempRow, r1, clippedStride); @@ -740,7 +733,7 @@ void flip(void *pDst, juint w, juint h, jint scanStride, jboolean convert) { } // convert the middle line if necessary if (convert && h % 2) { - juint *r1 = PtrAddBytes(pDst, (i * scanStride)); + juint *r1 = PtrPixelsRow(pDst, i, scanStride); for (step = 0; step < w; ++step) { LoadIntArgbPreTo1IntArgb(r1, 0, step, r1[step]); } @@ -813,7 +806,7 @@ OGLBlitLoops_SurfaceToSwBlit(JNIEnv *env, OGLContext *oglc, height = srcInfo.bounds.y2 - srcInfo.bounds.y1; pDst = PtrAddBytes(pDst, dstx * dstInfo.pixelStride); - pDst = PtrAddBytes(pDst, dsty * dstInfo.scanStride); + pDst = PtrPixelsRow(pDst, dsty, dstInfo.scanStride); j2d_glPixelStorei(GL_PACK_ROW_LENGTH, dstInfo.scanStride / dstInfo.pixelStride); diff --git a/src/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h b/src/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h index 58e203dc0cb..788ba931da2 100644 --- a/src/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h +++ b/src/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h @@ -490,6 +490,8 @@ extern struct _CompositeTypes { #define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, \ ((ptrdiff_t)(y))*(yinc) + \ ((ptrdiff_t)(x))*(xinc)) +#define PtrPixelsRow(p, y, scanStride) PtrAddBytes(p, \ + ((intptr_t) (y)) * (scanStride)) /* * The function to call with an array of NativePrimitive structures diff --git a/src/src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h b/src/src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h index d9019d83111..5a353e62cd3 100644 --- a/src/src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h +++ b/src/src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h @@ -137,7 +137,7 @@ do { \ juint w = WIDTH; \ jint tmpsxloc = SXLOC; \ - SRCPTR = PtrAddBytes(SRCBASE, ((SYLOC >> SHIFT) * srcScan)); \ + SRCPTR = PtrPixelsRow(SRCBASE, (SYLOC >> SHIFT), srcScan); \ Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \ do { \ jint XVAR = (tmpsxloc >> SHIFT); \ @@ -2067,7 +2067,7 @@ void NAME_TRANSFORMHELPER_NN(SRC)(SurfaceDataRasInfo *pSrcInfo, \ \ Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \ while (pRGB < pEnd) { \ - SRC ## DataType *pRow = PtrAddBytes(pBase, WholeOfLong(ylong) * scan); \ + SRC ## DataType *pRow = PtrPixelsRow(pBase, WholeOfLong(ylong), scan); \ Copy ## SRC ## ToIntArgbPre(pRGB, 0, \ SrcRead, pRow, WholeOfLong(xlong)); \ pRGB++; \ @@ -2115,7 +2115,7 @@ void NAME_TRANSFORMHELPER_BL(SRC)(SurfaceDataRasInfo *pSrcInfo, \ ydelta &= scan; \ \ xwhole += cx; \ - pRow = PtrAddBytes(pSrcInfo->rasBase, (ywhole + cy) * scan); \ + pRow = PtrPixelsRow(pSrcInfo->rasBase, ywhole + cy, scan); \ Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole); \ Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole+xdelta); \ pRow = PtrAddBytes(pRow, ydelta); \ @@ -2173,7 +2173,7 @@ void NAME_TRANSFORMHELPER_BC(SRC)(SurfaceDataRasInfo *pSrcInfo, \ ydelta1 += (isneg & -scan); \ \ xwhole += cx; \ - pRow = PtrAddBytes(pSrcInfo->rasBase, (ywhole + cy) * scan); \ + pRow = PtrPixelsRow(pSrcInfo->rasBase, ywhole + cy, scan); \ pRow = PtrAddBytes(pRow, ydelta0); \ Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole+xdelta0); \ Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole ); \ diff --git a/src/src/java.desktop/share/native/libfontmanager/DrawGlyphList.c b/src/src/java.desktop/share/native/libfontmanager/DrawGlyphList.c index c4dcdf99f60..0db65e3a9db 100644 --- a/src/src/java.desktop/share/native/libfontmanager/DrawGlyphList.c +++ b/src/src/java.desktop/share/native/libfontmanager/DrawGlyphList.c @@ -532,6 +532,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) { */ if (subPixPos && len > 0) { ginfo = (GlyphInfo*)imagePtrs[0]; + if (ginfo == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphImages, + imagePtrs, JNI_ABORT); + free(gbv); + return (GlyphBlitVector*)NULL; + } /* rowBytes==width tests if its a B&W or LCD glyph */ if (ginfo->width == ginfo->rowBytes) { subPixPos = JNI_FALSE; @@ -561,6 +567,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) { jfloat px, py; ginfo = (GlyphInfo*)imagePtrs[g]; + if (ginfo == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, glyphImages, + imagePtrs, JNI_ABORT); + free(gbv); + return (GlyphBlitVector*)NULL; + } gbv->glyphs[g].glyphInfo = ginfo; gbv->glyphs[g].pixels = ginfo->image; gbv->glyphs[g].width = ginfo->width; @@ -636,6 +648,12 @@ GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) { } else { for (g=0; gReleasePrimitiveArrayCritical(env, glyphImages, + imagePtrs, JNI_ABORT); + free(gbv); + return (GlyphBlitVector*)NULL; + } gbv->glyphs[g].glyphInfo = ginfo; gbv->glyphs[g].pixels = ginfo->image; gbv->glyphs[g].width = ginfo->width; diff --git a/src/src/java.desktop/share/native/libfontmanager/freetypeScaler.c b/src/src/java.desktop/share/native/libfontmanager/freetypeScaler.c index 13fc86a6288..014074b050b 100644 --- a/src/src/java.desktop/share/native/libfontmanager/freetypeScaler.c +++ b/src/src/java.desktop/share/native/libfontmanager/freetypeScaler.c @@ -150,7 +150,31 @@ static unsigned long ReadTTFontFileFunc(FT_Stream stream, jobject bBuffer; int bread = 0; - if (numBytes == 0) return 0; + /* A call with numBytes == 0 is a seek. It should return 0 if the + * seek position is within the file and non-zero otherwise. + * For all other cases, ie numBytes !=0, return the number of bytes + * actually read. This applies to truncated reads and also failed reads. + */ + + if (numBytes == 0) { + if (offset >= scalerInfo->fileSize) { + return -1; + } else { + return 0; + } + } + + if (offset + numBytes < offset) { + return 0; // ft should not do this, but just in case. + } + + if (offset >= scalerInfo->fileSize) { + return 0; + } + + if (offset + numBytes > scalerInfo->fileSize) { + numBytes = scalerInfo->fileSize - offset; + } /* Large reads will bypass the cache and data copying */ if (numBytes > FILEDATACACHESIZE) { @@ -160,7 +184,11 @@ static unsigned long ReadTTFontFileFunc(FT_Stream stream, scalerInfo->font2D, sunFontIDs.ttReadBlockMID, bBuffer, offset, numBytes); - return bread; + if (bread < 0) { + return 0; + } else { + return bread; + } } else { /* We probably hit bug 4845371. For reasons that * are currently unclear, the call stacks after the initial @@ -175,9 +203,18 @@ static unsigned long ReadTTFontFileFunc(FT_Stream stream, (*env)->CallObjectMethod(env, scalerInfo->font2D, sunFontIDs.ttReadBytesMID, offset, numBytes); - (*env)->GetByteArrayRegion(env, byteArray, - 0, numBytes, (jbyte*)destBuffer); - return numBytes; + /* If there's an OutofMemoryError then byteArray will be null */ + if (byteArray == NULL) { + return 0; + } else { + jsize len = (*env)->GetArrayLength(env, byteArray); + if (len < numBytes) { + numBytes = len; // don't get more bytes than there are .. + } + (*env)->GetByteArrayRegion(env, byteArray, + 0, numBytes, (jbyte*)destBuffer); + return numBytes; + } } } /* Do we have a cache hit? */ else if (scalerInfo->fontDataOffset <= offset && @@ -199,6 +236,11 @@ static unsigned long ReadTTFontFileFunc(FT_Stream stream, sunFontIDs.ttReadBlockMID, bBuffer, offset, scalerInfo->fontDataLength); + if (bread <= 0) { + return 0; + } else if (bread < numBytes) { + numBytes = bread; + } memcpy(destBuffer, scalerInfo->fontData, numBytes); return numBytes; } @@ -541,16 +583,17 @@ Java_sun_font_FreetypeFontScaler_getGlyphAdvanceNative( to avoid unnecesary work with bitmaps. */ GlyphInfo *info; - jfloat advance; + jfloat advance = 0.0f; jlong image; image = Java_sun_font_FreetypeFontScaler_getGlyphImageNative( env, scaler, font2D, pScalerContext, pScaler, glyphCode); info = (GlyphInfo*) jlong_to_ptr(image); - advance = info->advanceX; - - free(info); + if (info != NULL) { + advance = info->advanceX; + free(info); + } return advance; } @@ -688,6 +731,13 @@ static void CopyFTSubpixelVToSubpixel(const void* srcImage, int srcRowBytes, } +/* JDK does not use glyph images for fonts with a + * pixel size > 100 (see THRESHOLD in OutlineTextRenderer.java) + * so if the glyph bitmap image dimension is > 1024 pixels, + * something is up. + */ +#define MAX_GLYPH_DIM 1024 + /* * Class: sun_font_FreetypeFontScaler * Method: getGlyphImageNative @@ -764,6 +814,14 @@ Java_sun_font_FreetypeFontScaler_getGlyphImageNative( /* generate bitmap if it is not done yet e.g. if algorithmic styling is performed and style was added to outline */ if (ftglyph->format == FT_GLYPH_FORMAT_OUTLINE) { + FT_BBox bbox; + FT_Outline_Get_CBox(&(ftglyph->outline), &bbox); + int w = (int)((bbox.xMax>>6)-(bbox.xMin>>6)); + int h = (int)((bbox.yMax>>6)-(bbox.yMin>>6)); + if (w > MAX_GLYPH_DIM || h > MAX_GLYPH_DIM) { + glyphInfo = getNullGlyphImage(); + return ptr_to_jlong(glyphInfo); + } error = FT_Render_Glyph(ftglyph, FT_LOAD_TARGET_MODE(target)); if (error != 0) { return ptr_to_jlong(getNullGlyphImage()); @@ -772,6 +830,11 @@ Java_sun_font_FreetypeFontScaler_getGlyphImageNative( width = (UInt16) ftglyph->bitmap.width; height = (UInt16) ftglyph->bitmap.rows; + if (width > MAX_GLYPH_DIM || height > MAX_GLYPH_DIM) { + glyphInfo = getNullGlyphImage(); + return ptr_to_jlong(glyphInfo); + } + imageSize = width*height; glyphInfo = (GlyphInfo*) malloc(sizeof(GlyphInfo) + imageSize); diff --git a/src/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/src/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index 1c7eed0ab0e..2563f014557 100644 --- a/src/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/src/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -339,6 +339,9 @@ reference_table(hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) { } length = env->GetArrayLength(tableBytes); buffer = calloc(length, sizeof(jbyte)); + if (buffer == NULL) { + return NULL; + } env->GetByteArrayRegion(tableBytes, 0, length, (jbyte*)buffer); if (cacheIdx >= LAYOUTCACHE_ENTRIES) { // not a cacheable table diff --git a/src/src/java.desktop/share/native/libfreetype/UPDATING.txt b/src/src/java.desktop/share/native/libfreetype/UPDATING.txt index 8f7595dc342..14929029ff1 100644 --- a/src/src/java.desktop/share/native/libfreetype/UPDATING.txt +++ b/src/src/java.desktop/share/native/libfreetype/UPDATING.txt @@ -21,9 +21,16 @@ sources. Use "expand" and "sed" to remove tabs and trailing white space from the imported sources. The current version of freetype is quite clean in this respect. -./src/base/md5.h and ./src/base/md5.c are the only files with tabs, -and ./include/freetype/ftdriver.h has the only trailing white space. +None of files we import have tabs, and ./include/freetype/freetype.h, +./include/freetype/ftlcdfil.h and ./include/freetype/ftstroke.h have the +only trailing white space. If you forget this step, or aren't thorough, jcheck will remind you. Remember to update the freetype version identified in src/java.desktop/share/legal/freetype.md + +When updating specify --with-freetype=bundled to test builds to +expose build issues. +This is important because presently on Linux and Solaris the build +defaults to linking against the system library and does not attempt +to compile the sources. diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h index eedebf4082e..94666033775 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftconfig.h @@ -1,39 +1,38 @@ -/***************************************************************************/ -/* */ -/* ftconfig.h */ -/* */ -/* ANSI-specific configuration file (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This header file contains a number of macro definitions that are used */ - /* by the rest of the engine. Most of the macros here are automatically */ - /* determined at compile time, and you should not need to change it to */ - /* port FreeType, except to compile the library with a non-ANSI */ - /* compiler. */ - /* */ - /* Note however that if some specific modifications are needed, we */ - /* advise you to place a modified copy in your build directory. */ - /* */ - /* The build directory is usually `builds/', and contains */ - /* system-specific files that are always included first when building */ - /* the library. */ - /* */ - /* This ANSI version should stay in `include/config/'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftconfig.h + * + * ANSI-specific configuration file (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This header file contains a number of macro definitions that are used by + * the rest of the engine. Most of the macros here are automatically + * determined at compile time, and you should not need to change it to port + * FreeType, except to compile the library with a non-ANSI compiler. + * + * Note however that if some specific modifications are needed, we advise + * you to place a modified copy in your build directory. + * + * The build directory is usually `builds/`, and contains + * system-specific files that are always included first when building the + * library. + * + * This ANSI version should stay in `include/config/`. + * + */ #ifndef FTCONFIG_H_ #define FTCONFIG_H_ @@ -46,32 +45,32 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ - /* */ - /* These macros can be toggled to suit a specific system. The current */ - /* ones are defaults used to compile FreeType in an ANSI C environment */ - /* (16bit compilers are also supported). Copy this file to your own */ - /* `builds/' directory, and edit it to port the engine. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * PLATFORM-SPECIFIC CONFIGURATION MACROS + * + * These macros can be toggled to suit a specific system. The current ones + * are defaults used to compile FreeType in an ANSI C environment (16bit + * compilers are also supported). Copy this file to your own + * `builds/` directory, and edit it to port the engine. + * + */ - /* There are systems (like the Texas Instruments 'C54x) where a `char' */ - /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ - /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ - /* is probably unexpected. */ - /* */ - /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ - /* `char' type. */ + /* There are systems (like the Texas Instruments 'C54x) where a `char` */ + /* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */ + /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */ + /* is probably unexpected. */ + /* */ + /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */ + /* `char` type. */ #ifndef FT_CHAR_BIT #define FT_CHAR_BIT CHAR_BIT #endif - /* The size of an `int' type. */ + /* The size of an `int` type. */ #if FT_UINT_MAX == 0xFFFFUL #define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT ) #elif FT_UINT_MAX == 0xFFFFFFFFUL @@ -82,7 +81,7 @@ FT_BEGIN_HEADER #error "Unsupported size of `int' type!" #endif - /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ + /* The size of a `long` type. A five-byte `long` (as used e.g. on the */ /* DM642) is recognized but avoided. */ #if FT_ULONG_MAX == 0xFFFFFFFFUL #define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT ) @@ -95,35 +94,35 @@ FT_BEGIN_HEADER #endif - /* FT_UNUSED is a macro used to indicate that a given parameter is not */ - /* used -- this is only used to get rid of unpleasant compiler warnings */ + /* `FT_UNUSED` indicates that a given parameter is not used -- */ + /* this is only used to get rid of unpleasant compiler warnings. */ #ifndef FT_UNUSED #define FT_UNUSED( arg ) ( (arg) = (arg) ) #endif - /*************************************************************************/ - /* */ - /* AUTOMATIC CONFIGURATION MACROS */ - /* */ - /* These macros are computed from the ones defined above. Don't touch */ - /* their definition, unless you know precisely what you are doing. No */ - /* porter should need to mess with them. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Mac support */ - /* */ - /* This is the only necessary change, so it is defined here instead */ - /* providing a new configuration file. */ - /* */ + /************************************************************************** + * + * AUTOMATIC CONFIGURATION MACROS + * + * These macros are computed from the ones defined above. Don't touch + * their definition, unless you know precisely what you are doing. No + * porter should need to mess with them. + * + */ + + + /************************************************************************** + * + * Mac support + * + * This is the only necessary change, so it is defined here instead + * providing a new configuration file. + */ #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) - /* no Carbon frameworks for 64bit 10.4.x */ - /* AvailabilityMacros.h is available since Mac OS X 10.2, */ - /* so guess the system version by maximum errno before inclusion */ + /* No Carbon frameworks for 64bit 10.4.x. */ + /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */ + /* so guess the system version by maximum errno before inclusion. */ #include #ifdef ECANCELED /* defined since 10.2 */ #include "AvailabilityMacros.h" @@ -143,7 +142,7 @@ FT_BEGIN_HEADER #endif - /* Fix compiler warning with sgi compiler */ + /* Fix compiler warning with sgi compiler. */ #if defined( __sgi ) && !defined( __GNUC__ ) #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) #pragma set woff 3505 @@ -151,33 +150,33 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /*
    */ - /* basic_types */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * basic_types + * + */ - /*************************************************************************/ - /* */ - /* */ - /* FT_Int16 */ - /* */ - /* */ - /* A typedef for a 16bit signed integer type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int16 + * + * @description: + * A typedef for a 16bit signed integer type. + */ typedef signed short FT_Int16; - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt16 */ - /* */ - /* */ - /* A typedef for a 16bit unsigned integer type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt16 + * + * @description: + * A typedef for a 16bit unsigned integer type. + */ typedef unsigned short FT_UInt16; /* */ @@ -186,50 +185,50 @@ FT_BEGIN_HEADER /* this #if 0 ... #endif clause is for documentation purposes */ #if 0 - /*************************************************************************/ - /* */ - /* */ - /* FT_Int32 */ - /* */ - /* */ - /* A typedef for a 32bit signed integer type. The size depends on */ - /* the configuration. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int32 + * + * @description: + * A typedef for a 32bit signed integer type. The size depends on the + * configuration. + */ typedef signed XXX FT_Int32; - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt32 */ - /* */ - /* A typedef for a 32bit unsigned integer type. The size depends on */ - /* the configuration. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt32 + * + * A typedef for a 32bit unsigned integer type. The size depends on the + * configuration. + */ typedef unsigned XXX FT_UInt32; - /*************************************************************************/ - /* */ - /* */ - /* FT_Int64 */ - /* */ - /* A typedef for a 64bit signed integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int64 + * + * A typedef for a 64bit signed integer type. The size depends on the + * configuration. Only defined if there is real 64bit support; + * otherwise, it gets emulated with a structure (if necessary). + */ typedef signed XXX FT_Int64; - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt64 */ - /* */ - /* A typedef for a 64bit unsigned integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt64 + * + * A typedef for a 64bit unsigned integer type. The size depends on the + * configuration. Only defined if there is real 64bit support; + * otherwise, it gets emulated with a structure (if necessary). + */ typedef unsigned XXX FT_UInt64; /* */ @@ -251,7 +250,7 @@ FT_BEGIN_HEADER #endif - /* look up an integer type that is at least 32 bits */ + /* look up an integer type that is at least 32~bits */ #if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT ) typedef int FT_Fast; @@ -265,22 +264,22 @@ FT_BEGIN_HEADER #endif - /* determine whether we have a 64-bit int type for platforms without */ - /* Autoconf */ + /* determine whether we have a 64-bit `int` type for platforms without */ + /* Autoconf */ #if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT ) - /* FT_LONG64 must be defined if a 64-bit type is available */ + /* `FT_LONG64` must be defined if a 64-bit type is available */ #define FT_LONG64 #define FT_INT64 long #define FT_UINT64 unsigned long - /*************************************************************************/ - /* */ - /* A 64-bit data type may create compilation problems if you compile */ - /* in strict ANSI mode. To avoid them, we disable other 64-bit data */ - /* types if __STDC__ is defined. You can however ignore this rule */ - /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ - /* */ + /************************************************************************** + * + * A 64-bit data type may create compilation problems if you compile in + * strict ANSI mode. To avoid them, we disable other 64-bit data types if + * `__STDC__` is defined. You can however ignore this rule by defining the + * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro. + */ #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L @@ -289,19 +288,19 @@ FT_BEGIN_HEADER #define FT_INT64 long long int #define FT_UINT64 unsigned long long int -#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ +#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ - /* this compiler provides the __int64 type */ + /* this compiler provides the `__int64` type */ #define FT_LONG64 #define FT_INT64 __int64 #define FT_UINT64 unsigned __int64 #elif defined( __BORLANDC__ ) /* Borland C++ */ - /* XXXX: We should probably check the value of __BORLANDC__ in order */ - /* to test the compiler version. */ + /* XXXX: We should probably check the value of `__BORLANDC__` in order */ + /* to test the compiler version. */ - /* this compiler provides the __int64 type */ + /* this compiler provides the `__int64` type */ #define FT_LONG64 #define FT_INT64 __int64 #define FT_UINT64 unsigned __int64 @@ -318,7 +317,7 @@ FT_BEGIN_HEADER #elif defined( __GNUC__ ) - /* GCC provides the `long long' type */ + /* GCC provides the `long long` type */ #define FT_LONG64 #define FT_INT64 long long int #define FT_UINT64 unsigned long long int @@ -342,11 +341,11 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * miscellaneous + * + */ #define FT_BEGIN_STMNT do { @@ -354,7 +353,7 @@ FT_BEGIN_HEADER #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT - /* typeof condition taken from gnulib's `intprops.h' header file */ + /* `typeof` condition taken from gnulib's `intprops.h` header file */ #if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \ ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \ defined( __IBM__TYPEOF__ ) ) || \ @@ -365,14 +364,14 @@ FT_BEGIN_HEADER #endif - /* Use FT_LOCAL and FT_LOCAL_DEF to declare and define, respectively, */ - /* a function that gets used only within the scope of a module. */ - /* Normally, both the header and source code files for such a */ - /* function are within a single module directory. */ - /* */ - /* Intra-module arrays should be tagged with FT_LOCAL_ARRAY and */ - /* FT_LOCAL_ARRAY_DEF. */ - /* */ + /* Use `FT_LOCAL` and `FT_LOCAL_DEF` to declare and define, */ + /* respectively, a function that gets used only within the scope of a */ + /* module. Normally, both the header and source code files for such a */ + /* function are within a single module directory. */ + /* */ + /* Intra-module arrays should be tagged with `FT_LOCAL_ARRAY` and */ + /* `FT_LOCAL_ARRAY_DEF`. */ + /* */ #ifdef FT_MAKE_OPTION_SINGLE_OBJECT #define FT_LOCAL( x ) static x @@ -394,12 +393,12 @@ FT_BEGIN_HEADER #define FT_LOCAL_ARRAY_DEF( x ) const x - /* Use FT_BASE and FT_BASE_DEF to declare and define, respectively, */ - /* functions that are used in more than a single module. In the */ - /* current setup this implies that the declaration is in a header */ - /* file in the `include/freetype/internal' directory, and the */ - /* function body is in a file in `src/base'. */ - /* */ + /* Use `FT_BASE` and `FT_BASE_DEF` to declare and define, respectively, */ + /* functions that are used in more than a single module. In the */ + /* current setup this implies that the declaration is in a header file */ + /* in the `include/freetype/internal` directory, and the function body */ + /* is in a file in `src/base`. */ + /* */ #ifndef FT_BASE #ifdef __cplusplus @@ -422,45 +421,50 @@ FT_BEGIN_HEADER #endif /* !FT_BASE_DEF */ - /* When compiling FreeType as a DLL or DSO with hidden visibility */ - /* some systems/compilers need a special attribute in front OR after */ - /* the return type of function declarations. */ - /* */ - /* Two macros are used within the FreeType source code to define */ - /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ - /* */ - /* FT_EXPORT( return_type ) */ - /* */ - /* is used in a function declaration, as in */ - /* */ - /* FT_EXPORT( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ); */ - /* */ - /* */ - /* FT_EXPORT_DEF( return_type ) */ - /* */ - /* is used in a function definition, as in */ - /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ - /* { */ - /* ... some code ... */ - /* return FT_Err_Ok; */ - /* } */ - /* */ - /* You can provide your own implementation of FT_EXPORT and */ - /* FT_EXPORT_DEF here if you want. */ - /* */ - /* To export a variable, use FT_EXPORT_VAR. */ - /* */ + /* When compiling FreeType as a DLL or DSO with hidden visibility */ + /* some systems/compilers need a special attribute in front OR after */ + /* the return type of function declarations. */ + /* */ + /* Two macros are used within the FreeType source code to define */ + /* exported library functions: `FT_EXPORT` and `FT_EXPORT_DEF`. */ + /* */ + /* - `FT_EXPORT( return_type )` */ + /* */ + /* is used in a function declaration, as in */ + /* */ + /* ``` */ + /* FT_EXPORT( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ); */ + /* ``` */ + /* */ + /* - `FT_EXPORT_DEF( return_type )` */ + /* */ + /* is used in a function definition, as in */ + /* */ + /* ``` */ + /* FT_EXPORT_DEF( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ) */ + /* { */ + /* ... some code ... */ + /* return FT_Err_Ok; */ + /* } */ + /* ``` */ + /* */ + /* You can provide your own implementation of `FT_EXPORT` and */ + /* `FT_EXPORT_DEF` here if you want. */ + /* */ + /* To export a variable, use `FT_EXPORT_VAR`. */ + /* */ #ifndef FT_EXPORT #ifdef FT2_BUILD_LIBRARY -#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) ) +#if defined( _WIN32 ) && defined( DLL_EXPORT ) #define FT_EXPORT( x ) __declspec( dllexport ) x #elif defined( __GNUC__ ) && __GNUC__ >= 4 #define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x +#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550 +#define FT_EXPORT( x ) __global x #elif defined( __cplusplus ) #define FT_EXPORT( x ) extern "C" x #else @@ -469,7 +473,7 @@ FT_BEGIN_HEADER #else -#if defined( FT2_DLLIMPORT ) +#if defined( _WIN32 ) && defined( DLL_IMPORT ) #define FT_EXPORT( x ) __declspec( dllimport ) x #elif defined( __cplusplus ) #define FT_EXPORT( x ) extern "C" x @@ -508,7 +512,7 @@ FT_BEGIN_HEADER /* C++ compiler and with 16bit compilers. */ /* */ - /* This is special. Within C++, you must specify `extern "C"' for */ + /* This is special. Within C++, you must specify `extern "C"` for */ /* functions which are used via function pointers, and you also */ /* must do that for structures which contain function pointers to */ /* assure C linkage -- it's not possible to have (local) anonymous */ @@ -531,7 +535,7 @@ FT_BEGIN_HEADER /* */ /* */ /* Some 16bit compilers have to redefine these macros to insert */ - /* the infamous `_cdecl' or `__fastcall' declarations. */ + /* the infamous `_cdecl` or `__fastcall` declarations. */ /* */ #ifndef FT_CALLBACK_DEF #ifdef __cplusplus diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h index 702f77cc422..696d6ba9066 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftheader.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftheader.h */ -/* */ -/* Build macros of the FreeType 2 library. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftheader.h + * + * Build macros of the FreeType 2 library. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTHEADER_H_ #define FTHEADER_H_ @@ -27,7 +27,7 @@ /* */ /* This macro is used in association with @FT_END_HEADER in header */ /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* encapsulated in an `extern "C" { .. }` block when included from a */ /* C++ compiler. */ /* */ #ifdef __cplusplus @@ -45,7 +45,7 @@ /* */ /* This macro is used in association with @FT_BEGIN_HEADER in header */ /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* encapsulated in an `extern "C" { .. }` block when included from a */ /* C++ compiler. */ /* */ #ifdef __cplusplus @@ -55,54 +55,54 @@ #endif - /*************************************************************************/ - /* */ - /* Aliases for the FreeType 2 public and configuration files. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Aliases for the FreeType 2 public and configuration files. + * + */ - /*************************************************************************/ - /* */ - /*
    */ - /* header_file_macros */ - /* */ - /* */ - /* Header File Macros */ - /* */ - /* <Abstract> */ - /* Macro definitions used to #include specific header files. */ - /* */ - /* <Description> */ - /* The following macros are defined to the name of specific */ - /* FreeType~2 header files. They can be used directly in #include */ - /* statements as in: */ - /* */ - /* { */ - /* #include FT_FREETYPE_H */ - /* #include FT_MULTIPLE_MASTERS_H */ - /* #include FT_GLYPH_H */ - /* } */ - /* */ - /* There are several reasons why we are now using macros to name */ - /* public header files. The first one is that such macros are not */ - /* limited to the infamous 8.3~naming rule required by DOS (and */ - /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */ - /* */ - /* The second reason is that it allows for more flexibility in the */ - /* way FreeType~2 is installed on a given system. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * header_file_macros + * + * @title: + * Header File Macros + * + * @abstract: + * Macro definitions used to `#include` specific header files. + * + * @description: + * The following macros are defined to the name of specific FreeType~2 + * header files. They can be used directly in `#include` statements as + * in: + * + * ``` + * #include FT_FREETYPE_H + * #include FT_MULTIPLE_MASTERS_H + * #include FT_GLYPH_H + * ``` + * + * There are several reasons why we are now using macros to name public + * header files. The first one is that such macros are not limited to + * the infamous 8.3~naming rule required by DOS (and + * `FT_MULTIPLE_MASTERS_H` is a lot more meaningful than `ftmm.h`). + * + * The second reason is that it allows for more flexibility in the way + * FreeType~2 is installed on a given system. + * + */ /* configuration files */ - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_CONFIG_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * FreeType~2 configuration data. * */ @@ -111,13 +111,13 @@ #endif - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_STANDARD_LIBRARY_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * FreeType~2 interface to the standard C library functions. * */ @@ -126,13 +126,13 @@ #endif - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_OPTIONS_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * FreeType~2 project-specific configuration options. * */ @@ -141,13 +141,13 @@ #endif - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_MODULES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list of FreeType~2 modules that are statically linked to new library * instances in @FT_Init_FreeType. * @@ -160,26 +160,26 @@ /* public headers */ - /************************************************************************* + /************************************************************************** * * @macro: * FT_FREETYPE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * base FreeType~2 API. * */ #define FT_FREETYPE_H <freetype/freetype.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_ERRORS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list of FreeType~2 error codes (and messages). * * It is included by @FT_FREETYPE_H. @@ -188,26 +188,26 @@ #define FT_ERRORS_H <freetype/fterrors.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MODULE_ERRORS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list of FreeType~2 module error offsets (and messages). * */ #define FT_MODULE_ERRORS_H <freetype/ftmoderr.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SYSTEM_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 interface to low-level operations (i.e., memory management * and stream i/o). * @@ -217,13 +217,13 @@ #define FT_SYSTEM_H <freetype/ftsystem.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_IMAGE_H * * @description: - * A macro used in #include statements to name the file containing type + * A macro used in `#include` statements to name the file containing type * definitions related to glyph images (i.e., bitmaps, outlines, * scan-converter parameters). * @@ -233,13 +233,13 @@ #define FT_IMAGE_H <freetype/ftimage.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TYPES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * basic data types defined by FreeType~2. * * It is included by @FT_FREETYPE_H. @@ -248,13 +248,13 @@ #define FT_TYPES_H <freetype/fttypes.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_LIST_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list management API of FreeType~2. * * (Most applications will never need to include this file.) @@ -263,151 +263,151 @@ #define FT_LIST_H <freetype/ftlist.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_OUTLINE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * scalable outline management API of FreeType~2. * */ #define FT_OUTLINE_H <freetype/ftoutln.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SIZES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API which manages multiple @FT_Size objects per face. * */ #define FT_SIZES_H <freetype/ftsizes.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MODULE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * module management API of FreeType~2. * */ #define FT_MODULE_H <freetype/ftmodapi.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_RENDER_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * renderer module management API of FreeType~2. * */ #define FT_RENDER_H <freetype/ftrender.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the driver modules. * */ #define FT_DRIVER_H <freetype/ftdriver.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_AUTOHINTER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the auto-hinting module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_AUTOHINTER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_CFF_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the CFF driver module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_CFF_DRIVER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the TrueType driver module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_TRUETYPE_DRIVER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_PCF_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the PCF driver module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_PCF_DRIVER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_TYPE1_TABLES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * types and API specific to the Type~1 format. * */ #define FT_TYPE1_TABLES_H <freetype/t1tables.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_IDS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * enumeration values which identify name strings, languages, encodings, * etc. This file really contains a _large_ set of constant macro * definitions, taken from the TrueType and OpenType specifications. @@ -416,174 +416,172 @@ #define FT_TRUETYPE_IDS_H <freetype/ttnameid.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_TABLES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * types and API specific to the TrueType (as well as OpenType) format. * */ #define FT_TRUETYPE_TABLES_H <freetype/tttables.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_TAGS_H * * @description: - * A macro used in #include statements to name the file containing the - * definitions of TrueType four-byte `tags' which identify blocks in + * A macro used in `#include` statements to name the file containing the + * definitions of TrueType four-byte 'tags' which identify blocks in * SFNT-based font formats (i.e., TrueType and OpenType). * */ #define FT_TRUETYPE_TAGS_H <freetype/tttags.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BDF_H * * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which accesses BDF-specific strings from a - * face. + * A macro used in `#include` statements to name the file containing the + * definitions of an API which accesses BDF-specific strings from a face. * */ #define FT_BDF_H <freetype/ftbdf.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_CID_H * * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which access CID font information from a - * face. + * A macro used in `#include` statements to name the file containing the + * definitions of an API which access CID font information from a face. * */ #define FT_CID_H <freetype/ftcid.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GZIP_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports gzip-compressed files. * */ #define FT_GZIP_H <freetype/ftgzip.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_LZW_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports LZW-compressed files. * */ #define FT_LZW_H <freetype/ftlzw.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BZIP2_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports bzip2-compressed files. * */ #define FT_BZIP2_H <freetype/ftbzip2.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_WINFONTS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports Windows FNT files. * */ #define FT_WINFONTS_H <freetype/ftwinfnt.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GLYPH_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional glyph management component. * */ #define FT_GLYPH_H <freetype/ftglyph.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BITMAP_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional bitmap conversion component. * */ #define FT_BITMAP_H <freetype/ftbitmap.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BBOX_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional exact bounding box computation routines. * */ #define FT_BBOX_H <freetype/ftbbox.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_CACHE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional FreeType~2 cache sub-system. * */ #define FT_CACHE_H <freetype/ftcache.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MAC_H * * @description: - * A macro used in #include statements to name the file containing the - * Macintosh-specific FreeType~2 API. The latter is used to access - * fonts embedded in resource forks. + * A macro used in `#include` statements to name the file containing the + * Macintosh-specific FreeType~2 API. The latter is used to access fonts + * embedded in resource forks. * * This header file must be explicitly included by client applications * compiled on the Mac (note that the base API still works though). @@ -592,105 +590,105 @@ #define FT_MAC_H <freetype/ftmac.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MULTIPLE_MASTERS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * optional multiple-masters management API of FreeType~2. * */ #define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SFNT_NAMES_H * * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which accesses embedded `name' strings in + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which accesses embedded 'name' strings in * SFNT-based font formats (i.e., TrueType and OpenType). * */ #define FT_SFNT_NAMES_H <freetype/ftsnames.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_OPENTYPE_VALIDATE_H * * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates OpenType tables (BASE, GDEF, - * GPOS, GSUB, JSTF). + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which validates OpenType tables ('BASE', + * 'GDEF', 'GPOS', 'GSUB', 'JSTF'). * */ #define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GX_VALIDATE_H * * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat, - * mort, morx, bsln, just, kern, opbd, trak, prop). + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which validates TrueTypeGX/AAT tables ('feat', + * 'mort', 'morx', 'bsln', 'just', 'kern', 'opbd', 'trak', 'prop'). * */ #define FT_GX_VALIDATE_H <freetype/ftgxval.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_PFR_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which accesses PFR-specific data. * */ #define FT_PFR_H <freetype/ftpfr.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_STROKER_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which provides functions to stroke outline paths. */ #define FT_STROKER_H <freetype/ftstroke.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SYNTHESIS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs artificial obliquing and emboldening. */ #define FT_SYNTHESIS_H <freetype/ftsynth.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_FONT_FORMATS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which provides functions specific to font formats. */ #define FT_FONT_FORMATS_H <freetype/ftfntfmt.h> @@ -699,67 +697,79 @@ #define FT_XFREE86_H FT_FONT_FORMATS_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRIGONOMETRY_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs trigonometric computations (e.g., * cosines and arc tangents). */ #define FT_TRIGONOMETRY_H <freetype/fttrigon.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_LCD_FILTER_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs color filtering for subpixel rendering. */ #define FT_LCD_FILTER_H <freetype/ftlcdfil.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_INCREMENTAL_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs incremental glyph loading. */ #define FT_INCREMENTAL_H <freetype/ftincrem.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GASP_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which returns entries from the TrueType GASP table. */ #define FT_GASP_H <freetype/ftgasp.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_ADVANCES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which returns individual and ranged glyph advances. */ #define FT_ADVANCES_H <freetype/ftadvanc.h> + /************************************************************************** + * + * @macro: + * FT_COLOR_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which handles the OpenType 'CPAL' table. + */ +#define FT_COLOR_H <freetype/ftcolor.h> + + /* */ /* These header files don't need to be included by the user. */ @@ -770,14 +780,14 @@ #define FT_UNPATENTED_HINTING_H <freetype/ftparams.h> #define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h> - /* FT_CACHE_H is the only header file needed for the cache subsystem. */ + /* `FT_CACHE_H` is the only header file needed for the cache subsystem. */ #define FT_CACHE_IMAGE_H FT_CACHE_H #define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H #define FT_CACHE_CHARMAP_H FT_CACHE_H /* The internals of the cache sub-system are no longer exposed. We */ - /* default to FT_CACHE_H at the moment just in case, but we know of */ - /* no rogue client that uses them. */ + /* default to `FT_CACHE_H` at the moment just in case, but we know */ + /* of no rogue client that uses them. */ /* */ #define FT_CACHE_MANAGER_H FT_CACHE_H #define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H @@ -789,8 +799,8 @@ /* - * Include internal headers definitions from <internal/...> - * only when building the library. + * Include internal headers definitions from `<internal/...>` only when + * building the library. */ #ifdef FT2_BUILD_LIBRARY #define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftmodule.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftmodule.h index 139014404ce..bb7a7f26516 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftmodule.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftmodule.h @@ -1,12 +1,12 @@ /* - * This file registers the FreeType modules compiled into the library. + * This file registers the FreeType modules compiled into the library. * - * If you use GNU make, this file IS NOT USED! Instead, it is created in - * the objects directory (normally `<topdir>/objs/') based on information - * from `<topdir>/modules.cfg'. + * If you use GNU make, this file IS NOT USED! Instead, it is created in + * the objects directory (normally `<topdir>/objs/`) based on information + * from `<topdir>/modules.cfg`. * - * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile - * FreeType without GNU make. + * Please read `docs/INSTALL.ANY` and `docs/CUSTOMIZE` how to compile + * FreeType without GNU make. * */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h index 8bd0ffc31b2..fadc77a0235 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftoption.h */ -/* */ -/* User-selectable configuration macros (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftoption.h + * + * User-selectable configuration macros (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTOPTION_H_ @@ -25,45 +25,47 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* USER-SELECTABLE CONFIGURATION MACROS */ - /* */ - /* This file contains the default configuration macro definitions for */ - /* a standard build of the FreeType library. There are three ways to */ - /* use this file to build project-specific versions of the library: */ - /* */ - /* - You can modify this file by hand, but this is not recommended in */ - /* cases where you would like to build several versions of the */ - /* library from a single source directory. */ - /* */ - /* - You can put a copy of this file in your build directory, more */ - /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ - /* is the name of a directory that is included _before_ the FreeType */ - /* include path during compilation. */ - /* */ - /* The default FreeType Makefiles and Jamfiles use the build */ - /* directory `builds/<system>' by default, but you can easily change */ - /* that for your own projects. */ - /* */ - /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */ - /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ - /* locate this file during the build. For example, */ - /* */ - /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */ - /* #include <freetype/config/ftheader.h> */ - /* */ - /* will use `$BUILD/myftoptions.h' instead of this file for macro */ - /* definitions. */ - /* */ - /* Note also that you can similarly pre-define the macro */ - /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ - /* that are statically linked to the library at compile time. By */ - /* default, this file is <freetype/config/ftmodule.h>. */ - /* */ - /* We highly recommend using the third method whenever possible. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * USER-SELECTABLE CONFIGURATION MACROS + * + * This file contains the default configuration macro definitions for a + * standard build of the FreeType library. There are three ways to use + * this file to build project-specific versions of the library: + * + * - You can modify this file by hand, but this is not recommended in + * cases where you would like to build several versions of the library + * from a single source directory. + * + * - You can put a copy of this file in your build directory, more + * precisely in `$BUILD/freetype/config/ftoption.h`, where `$BUILD` is + * the name of a directory that is included _before_ the FreeType include + * path during compilation. + * + * The default FreeType Makefiles and Jamfiles use the build directory + * `builds/<system>` by default, but you can easily change that for your + * own projects. + * + * - Copy the file <ft2build.h> to `$BUILD/ft2build.h` and modify it + * slightly to pre-define the macro `FT_CONFIG_OPTIONS_H` used to locate + * this file during the build. For example, + * + * ``` + * #define FT_CONFIG_OPTIONS_H <myftoptions.h> + * #include <freetype/config/ftheader.h> + * ``` + * + * will use `$BUILD/myftoptions.h` instead of this file for macro + * definitions. + * + * Note also that you can similarly pre-define the macro + * `FT_CONFIG_MODULES_H` used to locate the file listing of the modules + * that are statically linked to the library at compile time. By + * default, this file is `<freetype/config/ftmodule.h>`. + * + * We highly recommend using the third method whenever possible. + * + */ /*************************************************************************/ @@ -75,444 +77,433 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*#***********************************************************************/ - /* */ - /* If you enable this configuration option, FreeType recognizes an */ - /* environment variable called `FREETYPE_PROPERTIES', which can be used */ - /* to control the various font drivers and modules. The controllable */ - /* properties are listed in the section @properties. */ - /* */ - /* You have to undefine this configuration option on platforms that lack */ - /* the concept of environment variables (and thus don't have the */ - /* `getenv' function), for example Windows CE. */ - /* */ - /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */ - /* multiple lines for better readability). */ - /* */ - /* { */ - /* <optional whitespace> */ - /* <module-name1> ':' */ - /* <property-name1> '=' <property-value1> */ - /* <whitespace> */ - /* <module-name2> ':' */ - /* <property-name2> '=' <property-value2> */ - /* ... */ - /* } */ - /* */ - /* Example: */ - /* */ - /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ - /* cff:no-stem-darkening=1 \ */ - /* autofitter:warping=1 */ - /* */ + /*#************************************************************************ + * + * If you enable this configuration option, FreeType recognizes an + * environment variable called `FREETYPE_PROPERTIES`, which can be used to + * control the various font drivers and modules. The controllable + * properties are listed in the section @properties. + * + * You have to undefine this configuration option on platforms that lack + * the concept of environment variables (and thus don't have the `getenv` + * function), for example Windows CE. + * + * `FREETYPE_PROPERTIES` has the following syntax form (broken here into + * multiple lines for better readability). + * + * ``` + * <optional whitespace> + * <module-name1> ':' + * <property-name1> '=' <property-value1> + * <whitespace> + * <module-name2> ':' + * <property-name2> '=' <property-value2> + * ... + * ``` + * + * Example: + * + * ``` + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=1 \ + * autofitter:warping=1 + * ``` + * + */ #define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - /*************************************************************************/ - /* */ - /* Uncomment the line below if you want to activate LCD rendering */ - /* technology similar to ClearType in this build of the library. This */ - /* technology triples the resolution in the direction color subpixels. */ - /* To mitigate color fringes inherent to this technology, you also need */ - /* to explicitly set up LCD filtering. */ - /* */ - /* Note that this feature is covered by several Microsoft patents */ - /* and should not be activated in any default build of the library. */ - /* When this macro is not defined, FreeType offers alternative LCD */ - /* rendering technology that produces excellent output without LCD */ - /* filtering. */ - /* */ + /************************************************************************** + * + * Uncomment the line below if you want to activate LCD rendering + * technology similar to ClearType in this build of the library. This + * technology triples the resolution in the direction color subpixels. To + * mitigate color fringes inherent to this technology, you also need to + * explicitly set up LCD filtering. + * + * Note that this feature is covered by several Microsoft patents and + * should not be activated in any default build of the library. When this + * macro is not defined, FreeType offers alternative LCD rendering + * technology that produces excellent output without LCD filtering. + */ /* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /*************************************************************************/ - /* */ - /* Many compilers provide a non-ANSI 64-bit data type that can be used */ - /* by FreeType to speed up some computations. However, this will create */ - /* some problems when compiling the library in strict ANSI mode. */ - /* */ - /* For this reason, the use of 64-bit integers is normally disabled when */ - /* the __STDC__ macro is defined. You can however disable this by */ - /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ - /* */ - /* For most compilers, this will only create compilation warnings when */ - /* building the library. */ - /* */ - /* ObNote: The compiler-specific 64-bit integers are detected in the */ - /* file `ftconfig.h' either statically or through the */ - /* `configure' script on supported platforms. */ - /* */ + /************************************************************************** + * + * Many compilers provide a non-ANSI 64-bit data type that can be used by + * FreeType to speed up some computations. However, this will create some + * problems when compiling the library in strict ANSI mode. + * + * For this reason, the use of 64-bit integers is normally disabled when + * the `__STDC__` macro is defined. You can however disable this by + * defining the macro `FT_CONFIG_OPTION_FORCE_INT64` here. + * + * For most compilers, this will only create compilation warnings when + * building the library. + * + * ObNote: The compiler-specific 64-bit integers are detected in the + * file `ftconfig.h` either statically or through the `configure` + * script on supported platforms. + */ #undef FT_CONFIG_OPTION_FORCE_INT64 - /*************************************************************************/ - /* */ - /* If this macro is defined, do not try to use an assembler version of */ - /* performance-critical functions (e.g. FT_MulFix). You should only do */ - /* that to verify that the assembler function works properly, or to */ - /* execute benchmark tests of the various implementations. */ + /************************************************************************** + * + * If this macro is defined, do not try to use an assembler version of + * performance-critical functions (e.g., @FT_MulFix). You should only do + * that to verify that the assembler function works properly, or to execute + * benchmark tests of the various implementations. + */ /* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ - /*************************************************************************/ - /* */ - /* If this macro is defined, try to use an inlined assembler version of */ - /* the `FT_MulFix' function, which is a `hotspot' when loading and */ - /* hinting glyphs, and which should be executed as fast as possible. */ - /* */ - /* Note that if your compiler or CPU is not supported, this will default */ - /* to the standard and portable implementation found in `ftcalc.c'. */ - /* */ + /************************************************************************** + * + * If this macro is defined, try to use an inlined assembler version of the + * @FT_MulFix function, which is a 'hotspot' when loading and hinting + * glyphs, and which should be executed as fast as possible. + * + * Note that if your compiler or CPU is not supported, this will default to + * the standard and portable implementation found in `ftcalc.c`. + */ #define FT_CONFIG_OPTION_INLINE_MULFIX - /*************************************************************************/ - /* */ - /* LZW-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `compress' program. This is mostly used to parse many of the PCF */ - /* files that come with various X11 distributions. The implementation */ - /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ - /* (see src/lzw/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ + /************************************************************************** + * + * LZW-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `compress` program. This is mostly used to parse many of the PCF + * files that come with various X11 distributions. The implementation + * uses NetBSD's `zopen` to partially uncompress the file on the fly (see + * `src/lzw/ftgzip.c`). + * + * Define this macro if you want to enable this 'feature'. + */ /* #define FT_CONFIG_OPTION_USE_LZW */ - /*************************************************************************/ - /* */ - /* Gzip-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `gzip' program. This is mostly used to parse many of the PCF files */ - /* that come with XFree86. The implementation uses `zlib' to */ - /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. See also */ - /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ - /* */ + /************************************************************************** + * + * Gzip-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `gzip` program. This is mostly used to parse many of the PCF files + * that come with XFree86. The implementation uses 'zlib' to partially + * uncompress the file on the fly (see `src/gzip/ftgzip.c`). + * + * Define this macro if you want to enable this 'feature'. See also the + * macro `FT_CONFIG_OPTION_SYSTEM_ZLIB` below. + */ /* #define FT_CONFIG_OPTION_USE_ZLIB */ - /*************************************************************************/ - /* */ - /* ZLib library selection */ - /* */ - /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ - /* It allows FreeType's `ftgzip' component to link to the system's */ - /* installation of the ZLib library. This is useful on systems like */ - /* Unix or VMS where it generally is already available. */ - /* */ - /* If you let it undefined, the component will use its own copy */ - /* of the zlib sources instead. These have been modified to be */ - /* included directly within the component and *not* export external */ - /* function names. This allows you to link any program with FreeType */ - /* _and_ ZLib without linking conflicts. */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * ZLib library selection + * + * This macro is only used when `FT_CONFIG_OPTION_USE_ZLIB` is defined. + * It allows FreeType's 'ftgzip' component to link to the system's + * installation of the ZLib library. This is useful on systems like + * Unix or VMS where it generally is already available. + * + * If you let it undefined, the component will use its own copy of the + * zlib sources instead. These have been modified to be included + * directly within the component and **not** export external function + * names. This allows you to link any program with FreeType _and_ ZLib + * without linking conflicts. + * + * Do not `#undef` this macro here since the build system might define + * it for certain configurations only. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ - /*************************************************************************/ - /* */ - /* Bzip2-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `bzip2' program. This is mostly used to parse many of the PCF */ - /* files that come with XFree86. The implementation uses `libbz2' to */ - /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ - /* Contrary to gzip, bzip2 currently is not included and need to use */ - /* the system available bzip2 implementation. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * Bzip2-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `bzip2` program. This is mostly used to parse many of the PCF files + * that come with XFree86. The implementation uses `libbz2` to partially + * uncompress the file on the fly (see `src/bzip2/ftbzip2.c`). Contrary + * to gzip, bzip2 currently is not included and need to use the system + * available bzip2 implementation. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_USE_BZIP2 */ - /*************************************************************************/ - /* */ - /* Define to disable the use of file stream functions and types, FILE, */ - /* fopen() etc. Enables the use of smaller system libraries on embedded */ - /* systems that have multiple system libraries, some with or without */ - /* file stream support, in the cases where file stream support is not */ - /* necessary such as memory loading of font files. */ - /* */ + /************************************************************************** + * + * Define to disable the use of file stream functions and types, `FILE`, + * `fopen`, etc. Enables the use of smaller system libraries on embedded + * systems that have multiple system libraries, some with or without file + * stream support, in the cases where file stream support is not necessary + * such as memory loading of font files. + */ /* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ - /*************************************************************************/ - /* */ - /* PNG bitmap support. */ - /* */ - /* FreeType now handles loading color bitmap glyphs in the PNG format. */ - /* This requires help from the external libpng library. Uncompressed */ - /* color bitmaps do not need any external libraries and will be */ - /* supported regardless of this configuration. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * PNG bitmap support. + * + * FreeType now handles loading color bitmap glyphs in the PNG format. + * This requires help from the external libpng library. Uncompressed + * color bitmaps do not need any external libraries and will be supported + * regardless of this configuration. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_USE_PNG */ - /*************************************************************************/ - /* */ - /* HarfBuzz support. */ - /* */ - /* FreeType uses the HarfBuzz library to improve auto-hinting of */ - /* OpenType fonts. If available, many glyphs not directly addressable */ - /* by a font's character map will be hinted also. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * HarfBuzz support. + * + * FreeType uses the HarfBuzz library to improve auto-hinting of OpenType + * fonts. If available, many glyphs not directly addressable by a font's + * character map will be hinted also. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ - /*************************************************************************/ - /* */ - /* Glyph Postscript Names handling */ - /* */ - /* By default, FreeType 2 is compiled with the `psnames' module. This */ - /* module is in charge of converting a glyph name string into a */ - /* Unicode value, or return a Macintosh standard glyph name for the */ - /* use with the TrueType `post' table. */ - /* */ - /* Undefine this macro if you do not want `psnames' compiled in your */ - /* build of FreeType. This has the following effects: */ - /* */ - /* - The TrueType driver will provide its own set of glyph names, */ - /* if you build it to support postscript names in the TrueType */ - /* `post' table, but will not synthesize a missing Unicode charmap. */ - /* */ - /* - The Type 1 driver will not be able to synthesize a Unicode */ - /* charmap out of the glyphs found in the fonts. */ - /* */ - /* You would normally undefine this configuration macro when building */ - /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ - /* */ + /************************************************************************** + * + * Glyph Postscript Names handling + * + * By default, FreeType 2 is compiled with the 'psnames' module. This + * module is in charge of converting a glyph name string into a Unicode + * value, or return a Macintosh standard glyph name for the use with the + * TrueType 'post' table. + * + * Undefine this macro if you do not want 'psnames' compiled in your + * build of FreeType. This has the following effects: + * + * - The TrueType driver will provide its own set of glyph names, if you + * build it to support postscript names in the TrueType 'post' table, + * but will not synthesize a missing Unicode charmap. + * + * - The Type~1 driver will not be able to synthesize a Unicode charmap + * out of the glyphs found in the fonts. + * + * You would normally undefine this configuration macro when building a + * version of FreeType that doesn't contain a Type~1 or CFF driver. + */ #define FT_CONFIG_OPTION_POSTSCRIPT_NAMES - /*************************************************************************/ - /* */ - /* Postscript Names to Unicode Values support */ - /* */ - /* By default, FreeType 2 is built with the `PSNames' module compiled */ - /* in. Among other things, the module is used to convert a glyph name */ - /* into a Unicode value. This is especially useful in order to */ - /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ - /* through a big table named the `Adobe Glyph List' (AGL). */ - /* */ - /* Undefine this macro if you do not want the Adobe Glyph List */ - /* compiled in your `PSNames' module. The Type 1 driver will not be */ - /* able to synthesize a Unicode charmap out of the glyphs found in the */ - /* fonts. */ - /* */ + /************************************************************************** + * + * Postscript Names to Unicode Values support + * + * By default, FreeType~2 is built with the 'psnames' module compiled in. + * Among other things, the module is used to convert a glyph name into a + * Unicode value. This is especially useful in order to synthesize on + * the fly a Unicode charmap from the CFF/Type~1 driver through a big + * table named the 'Adobe Glyph List' (AGL). + * + * Undefine this macro if you do not want the Adobe Glyph List compiled + * in your 'psnames' module. The Type~1 driver will not be able to + * synthesize a Unicode charmap out of the glyphs found in the fonts. + */ #define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - /*************************************************************************/ - /* */ - /* Support for Mac fonts */ - /* */ - /* Define this macro if you want support for outline fonts in Mac */ - /* format (mac dfont, mac resource, macbinary containing a mac */ - /* resource) on non-Mac platforms. */ - /* */ - /* Note that the `FOND' resource isn't checked. */ - /* */ + /************************************************************************** + * + * Support for Mac fonts + * + * Define this macro if you want support for outline fonts in Mac format + * (mac dfont, mac resource, macbinary containing a mac resource) on + * non-Mac platforms. + * + * Note that the 'FOND' resource isn't checked. + */ #define FT_CONFIG_OPTION_MAC_FONTS - /*************************************************************************/ - /* */ - /* Guessing methods to access embedded resource forks */ - /* */ - /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ - /* GNU/Linux). */ - /* */ - /* Resource forks which include fonts data are stored sometimes in */ - /* locations which users or developers don't expected. In some cases, */ - /* resource forks start with some offset from the head of a file. In */ - /* other cases, the actual resource fork is stored in file different */ - /* from what the user specifies. If this option is activated, */ - /* FreeType tries to guess whether such offsets or different file */ - /* names must be used. */ - /* */ - /* Note that normal, direct access of resource forks is controlled via */ - /* the FT_CONFIG_OPTION_MAC_FONTS option. */ - /* */ + /************************************************************************** + * + * Guessing methods to access embedded resource forks + * + * Enable extra Mac fonts support on non-Mac platforms (e.g., GNU/Linux). + * + * Resource forks which include fonts data are stored sometimes in + * locations which users or developers don't expected. In some cases, + * resource forks start with some offset from the head of a file. In + * other cases, the actual resource fork is stored in file different from + * what the user specifies. If this option is activated, FreeType tries + * to guess whether such offsets or different file names must be used. + * + * Note that normal, direct access of resource forks is controlled via + * the `FT_CONFIG_OPTION_MAC_FONTS` option. + */ #ifdef FT_CONFIG_OPTION_MAC_FONTS #define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK #endif - /*************************************************************************/ - /* */ - /* Allow the use of FT_Incremental_Interface to load typefaces that */ - /* contain no glyph data, but supply it via a callback function. */ - /* This is required by clients supporting document formats which */ - /* supply font data incrementally as the document is parsed, such */ - /* as the Ghostscript interpreter for the PostScript language. */ - /* */ + /************************************************************************** + * + * Allow the use of `FT_Incremental_Interface` to load typefaces that + * contain no glyph data, but supply it via a callback function. This is + * required by clients supporting document formats which supply font data + * incrementally as the document is parsed, such as the Ghostscript + * interpreter for the PostScript language. + */ #define FT_CONFIG_OPTION_INCREMENTAL - /*************************************************************************/ - /* */ - /* The size in bytes of the render pool used by the scan-line converter */ - /* to do all of its work. */ - /* */ + /************************************************************************** + * + * The size in bytes of the render pool used by the scan-line converter to + * do all of its work. + */ #define FT_RENDER_POOL_SIZE 16384L - /*************************************************************************/ - /* */ - /* FT_MAX_MODULES */ - /* */ - /* The maximum number of modules that can be registered in a single */ - /* FreeType library object. 32 is the default. */ - /* */ + /************************************************************************** + * + * FT_MAX_MODULES + * + * The maximum number of modules that can be registered in a single + * FreeType library object. 32~is the default. + */ #define FT_MAX_MODULES 32 - /*************************************************************************/ - /* */ - /* Debug level */ - /* */ - /* FreeType can be compiled in debug or trace mode. In debug mode, */ - /* errors are reported through the `ftdebug' component. In trace */ - /* mode, additional messages are sent to the standard output during */ - /* execution. */ - /* */ - /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ - /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ - /* */ - /* Don't define any of these macros to compile in `release' mode! */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ + /************************************************************************** + * + * Debug level + * + * FreeType can be compiled in debug or trace mode. In debug mode, + * errors are reported through the 'ftdebug' component. In trace mode, + * additional messages are sent to the standard output during execution. + * + * Define `FT_DEBUG_LEVEL_ERROR` to build the library in debug mode. + * Define `FT_DEBUG_LEVEL_TRACE` to build it in trace mode. + * + * Don't define any of these macros to compile in 'release' mode! + * + * Do not `#undef` these macros here since the build system might define + * them for certain configurations only. + */ /* #define FT_DEBUG_LEVEL_ERROR */ /* #define FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* Autofitter debugging */ - /* */ - /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ - /* control the autofitter behaviour for debugging purposes with global */ - /* boolean variables (consequently, you should *never* enable this */ - /* while compiling in `release' mode): */ - /* */ - /* _af_debug_disable_horz_hints */ - /* _af_debug_disable_vert_hints */ - /* _af_debug_disable_blue_hints */ - /* */ - /* Additionally, the following functions provide dumps of various */ - /* internal autofit structures to stdout (using `printf'): */ - /* */ - /* af_glyph_hints_dump_points */ - /* af_glyph_hints_dump_segments */ - /* af_glyph_hints_dump_edges */ - /* af_glyph_hints_get_num_segments */ - /* af_glyph_hints_get_segment_offset */ - /* */ - /* As an argument, they use another global variable: */ - /* */ - /* _af_debug_hints */ - /* */ - /* Please have a look at the `ftgrid' demo program to see how those */ - /* variables and macros should be used. */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ + /************************************************************************** + * + * Autofitter debugging + * + * If `FT_DEBUG_AUTOFIT` is defined, FreeType provides some means to + * control the autofitter behaviour for debugging purposes with global + * boolean variables (consequently, you should **never** enable this + * while compiling in 'release' mode): + * + * ``` + * _af_debug_disable_horz_hints + * _af_debug_disable_vert_hints + * _af_debug_disable_blue_hints + * ``` + * + * Additionally, the following functions provide dumps of various + * internal autofit structures to stdout (using `printf`): + * + * ``` + * af_glyph_hints_dump_points + * af_glyph_hints_dump_segments + * af_glyph_hints_dump_edges + * af_glyph_hints_get_num_segments + * af_glyph_hints_get_segment_offset + * ``` + * + * As an argument, they use another global variable: + * + * ``` + * _af_debug_hints + * ``` + * + * Please have a look at the `ftgrid` demo program to see how those + * variables and macros should be used. + * + * Do not `#undef` these macros here since the build system might define + * them for certain configurations only. + */ /* #define FT_DEBUG_AUTOFIT */ - /*************************************************************************/ - /* */ - /* Memory Debugging */ - /* */ - /* FreeType now comes with an integrated memory debugger that is */ - /* capable of detecting simple errors like memory leaks or double */ - /* deletes. To compile it within your build of the library, you */ - /* should define FT_DEBUG_MEMORY here. */ - /* */ - /* Note that the memory debugger is only activated at runtime when */ - /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ + /************************************************************************** + * + * Memory Debugging + * + * FreeType now comes with an integrated memory debugger that is capable + * of detecting simple errors like memory leaks or double deletes. To + * compile it within your build of the library, you should define + * `FT_DEBUG_MEMORY` here. + * + * Note that the memory debugger is only activated at runtime when when + * the _environment_ variable `FT2_DEBUG_MEMORY` is defined also! + * + * Do not `#undef` this macro here since the build system might define it + * for certain configurations only. + */ /* #define FT_DEBUG_MEMORY */ - /*************************************************************************/ - /* */ - /* Module errors */ - /* */ - /* If this macro is set (which is _not_ the default), the higher byte */ - /* of an error code gives the module in which the error has occurred, */ - /* while the lower byte is the real error code. */ - /* */ - /* Setting this macro makes sense for debugging purposes only, since */ - /* it would break source compatibility of certain programs that use */ - /* FreeType 2. */ - /* */ - /* More details can be found in the files ftmoderr.h and fterrors.h. */ - /* */ + /************************************************************************** + * + * Module errors + * + * If this macro is set (which is _not_ the default), the higher byte of + * an error code gives the module in which the error has occurred, while + * the lower byte is the real error code. + * + * Setting this macro makes sense for debugging purposes only, since it + * would break source compatibility of certain programs that use + * FreeType~2. + * + * More details can be found in the files `ftmoderr.h` and `fterrors.h`. + */ #undef FT_CONFIG_OPTION_USE_MODULE_ERRORS - /*************************************************************************/ - /* */ - /* Position Independent Code */ - /* */ - /* If this macro is set (which is _not_ the default), FreeType2 will */ - /* avoid creating constants that require address fixups. Instead the */ - /* constants will be moved into a struct and additional intialization */ - /* code will be used. */ - /* */ - /* Setting this macro is needed for systems that prohibit address */ - /* fixups, such as BREW. [Note that standard compilers like gcc or */ - /* clang handle PIC generation automatically; you don't have to set */ - /* FT_CONFIG_OPTION_PIC, which is only necessary for very special */ - /* compilers.] */ - /* */ - /* Note that FT_CONFIG_OPTION_PIC support is not available for all */ - /* modules (see `modules.cfg' for a complete list). For building with */ - /* FT_CONFIG_OPTION_PIC support, do the following. */ - /* */ - /* 0. Clone the repository. */ - /* 1. Define FT_CONFIG_OPTION_PIC. */ - /* 2. Remove all subdirectories in `src' that don't have */ - /* FT_CONFIG_OPTION_PIC support. */ - /* 3. Comment out the corresponding modules in `modules.cfg'. */ - /* 4. Compile. */ - /* */ -/* #define FT_CONFIG_OPTION_PIC */ + /************************************************************************** + * + * Error Strings + * + * If this macro is set, `FT_Error_String` will return meaningful + * descriptions. This is not enabled by default to reduce the overall + * size of FreeType. + * + * More details can be found in the file `fterrors.h`. + */ +/* #define FT_CONFIG_OPTION_ERROR_STRINGS */ /*************************************************************************/ @@ -524,50 +515,60 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ - /* embedded bitmaps in all formats using the SFNT module (namely */ - /* TrueType & OpenType). */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_EMBEDDED_BITMAPS` if you want to support + * embedded bitmaps in all formats using the 'sfnt' module (namely + * TrueType~& OpenType). + */ #define TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ - /* load and enumerate the glyph Postscript names in a TrueType or */ - /* OpenType file. */ - /* */ - /* Note that when you do not compile the `PSNames' module by undefining */ - /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ - /* contain additional code used to read the PS Names table from a font. */ - /* */ - /* (By default, the module uses `PSNames' to extract glyph names.) */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_COLOR_LAYERS` if you want to support coloured + * outlines (from the 'COLR'/'CPAL' tables) in all formats using the 'sfnt' + * module (namely TrueType~& OpenType). + */ +#define TT_CONFIG_OPTION_COLOR_LAYERS + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_POSTSCRIPT_NAMES` if you want to be able to + * load and enumerate the glyph Postscript names in a TrueType or OpenType + * file. + * + * Note that when you do not compile the 'psnames' module by undefining the + * above `FT_CONFIG_OPTION_POSTSCRIPT_NAMES`, the 'sfnt' module will + * contain additional code used to read the PS Names table from a font. + * + * (By default, the module uses 'psnames' to extract glyph names.) + */ #define TT_CONFIG_OPTION_POSTSCRIPT_NAMES - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ - /* access the internal name table in a SFNT-based format like TrueType */ - /* or OpenType. The name table contains various strings used to */ - /* describe the font, like family name, copyright, version, etc. It */ - /* does not contain any glyph name though. */ - /* */ - /* Accessing SFNT names is done through the functions declared in */ - /* `ftsnames.h'. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_SFNT_NAMES` if your applications need to access + * the internal name table in a SFNT-based format like TrueType or + * OpenType. The name table contains various strings used to describe the + * font, like family name, copyright, version, etc. It does not contain + * any glyph name though. + * + * Accessing SFNT names is done through the functions declared in + * `ftsnames.h`. + */ #define TT_CONFIG_OPTION_SFNT_NAMES - /*************************************************************************/ - /* */ - /* TrueType CMap support */ - /* */ - /* Here you can fine-tune which TrueType CMap table format shall be */ - /* supported. */ + /************************************************************************** + * + * TrueType CMap support + * + * Here you can fine-tune which TrueType CMap table format shall be + * supported. + */ #define TT_CONFIG_CMAP_FORMAT_0 #define TT_CONFIG_CMAP_FORMAT_2 #define TT_CONFIG_CMAP_FORMAT_4 @@ -587,131 +588,130 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ - /* a bytecode interpreter in the TrueType driver. */ - /* */ - /* By undefining this, you will only compile the code necessary to load */ - /* TrueType glyphs without hinting. */ - /* */ - /* Do not #undef this macro here, since the build system might */ - /* define it for certain configurations only. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` if you want to compile a + * bytecode interpreter in the TrueType driver. + * + * By undefining this, you will only compile the code necessary to load + * TrueType glyphs without hinting. + * + * Do not `#undef` this macro here, since the build system might define it + * for certain configurations only. + */ #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ - /* subpixel hinting support into the TrueType driver. This modifies the */ - /* TrueType hinting mechanism when anything but FT_RENDER_MODE_MONO is */ - /* requested. */ - /* */ - /* In particular, it modifies the bytecode interpreter to interpret (or */ - /* not) instructions in a certain way so that all TrueType fonts look */ - /* like they do in a Windows ClearType (DirectWrite) environment. See */ - /* [1] for a technical overview on what this means. See `ttinterp.h' */ - /* for more details on the LEAN option. */ - /* */ - /* There are three possible values. */ - /* */ - /* Value 1: */ - /* This value is associated with the `Infinality' moniker, */ - /* contributed by an individual nicknamed Infinality with the goal of */ - /* making TrueType fonts render better than on Windows. A high */ - /* amount of configurability and flexibility, down to rules for */ - /* single glyphs in fonts, but also very slow. Its experimental and */ - /* slow nature and the original developer losing interest meant that */ - /* this option was never enabled in default builds. */ - /* */ - /* The corresponding interpreter version is v38. */ - /* */ - /* Value 2: */ - /* The new default mode for the TrueType driver. The Infinality code */ - /* base was stripped to the bare minimum and all configurability */ - /* removed in the name of speed and simplicity. The configurability */ - /* was mainly aimed at legacy fonts like Arial, Times New Roman, or */ - /* Courier. Legacy fonts are fonts that modify vertical stems to */ - /* achieve clean black-and-white bitmaps. The new mode focuses on */ - /* applying a minimal set of rules to all fonts indiscriminately so */ - /* that modern and web fonts render well while legacy fonts render */ - /* okay. */ - /* */ - /* The corresponding interpreter version is v40. */ - /* */ - /* Value 3: */ - /* Compile both, making both v38 and v40 available (the latter is the */ - /* default). */ - /* */ - /* By undefining these, you get rendering behavior like on Windows */ - /* without ClearType, i.e., Windows XP without ClearType enabled and */ - /* Win9x (interpreter version v35). Or not, depending on how much */ - /* hinting blood and testing tears the font designer put into a given */ - /* font. If you define one or both subpixel hinting options, you can */ - /* switch between between v35 and the ones you define (using */ - /* `FT_Property_Set'). */ - /* */ - /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ - /* defined. */ - /* */ - /* [1] https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_SUBPIXEL_HINTING` if you want to compile + * subpixel hinting support into the TrueType driver. This modifies the + * TrueType hinting mechanism when anything but `FT_RENDER_MODE_MONO` is + * requested. + * + * In particular, it modifies the bytecode interpreter to interpret (or + * not) instructions in a certain way so that all TrueType fonts look like + * they do in a Windows ClearType (DirectWrite) environment. See [1] for a + * technical overview on what this means. See `ttinterp.h` for more + * details on the LEAN option. + * + * There are three possible values. + * + * Value 1: + * This value is associated with the 'Infinality' moniker, contributed by + * an individual nicknamed Infinality with the goal of making TrueType + * fonts render better than on Windows. A high amount of configurability + * and flexibility, down to rules for single glyphs in fonts, but also + * very slow. Its experimental and slow nature and the original + * developer losing interest meant that this option was never enabled in + * default builds. + * + * The corresponding interpreter version is v38. + * + * Value 2: + * The new default mode for the TrueType driver. The Infinality code + * base was stripped to the bare minimum and all configurability removed + * in the name of speed and simplicity. The configurability was mainly + * aimed at legacy fonts like 'Arial', 'Times New Roman', or 'Courier'. + * Legacy fonts are fonts that modify vertical stems to achieve clean + * black-and-white bitmaps. The new mode focuses on applying a minimal + * set of rules to all fonts indiscriminately so that modern and web + * fonts render well while legacy fonts render okay. + * + * The corresponding interpreter version is v40. + * + * Value 3: + * Compile both, making both v38 and v40 available (the latter is the + * default). + * + * By undefining these, you get rendering behavior like on Windows without + * ClearType, i.e., Windows XP without ClearType enabled and Win9x + * (interpreter version v35). Or not, depending on how much hinting blood + * and testing tears the font designer put into a given font. If you + * define one or both subpixel hinting options, you can switch between + * between v35 and the ones you define (using `FT_Property_Set`). + * + * This option requires `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` to be + * defined. + * + * [1] + * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx + */ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */ #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */ - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ - /* TrueType glyph loader to use Apple's definition of how to handle */ - /* component offsets in composite glyphs. */ - /* */ - /* Apple and MS disagree on the default behavior of component offsets */ - /* in composites. Apple says that they should be scaled by the scaling */ - /* factors in the transformation matrix (roughly, it's more complex) */ - /* while MS says they should not. OpenType defines two bits in the */ - /* composite flags array which can be used to disambiguate, but old */ - /* fonts will not have them. */ - /* */ - /* https://www.microsoft.com/typography/otspec/glyf.htm */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED` to compile the + * TrueType glyph loader to use Apple's definition of how to handle + * component offsets in composite glyphs. + * + * Apple and MS disagree on the default behavior of component offsets in + * composites. Apple says that they should be scaled by the scaling + * factors in the transformation matrix (roughly, it's more complex) while + * MS says they should not. OpenType defines two bits in the composite + * flags array which can be used to disambiguate, but old fonts will not + * have them. + * + * https://www.microsoft.com/typography/otspec/glyf.htm + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html + */ #undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ - /* support for Apple's distortable font technology (fvar, gvar, cvar, */ - /* and avar tables). This has many similarities to Type 1 Multiple */ - /* Masters support. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_GX_VAR_SUPPORT` if you want to include support + * for Apple's distortable font technology ('fvar', 'gvar', 'cvar', and + * 'avar' tables). Tagged 'Font Variations', this is now part of OpenType + * also. This has many similarities to Type~1 Multiple Masters support. + */ #define TT_CONFIG_OPTION_GX_VAR_SUPPORT - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ - /* an embedded `BDF ' table within SFNT-based bitmap formats. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an + * embedded 'BDF~' table within SFNT-based bitmap formats. + */ /* #define TT_CONFIG_OPTION_BDF */ - /*************************************************************************/ - /* */ - /* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */ - /* number of bytecode instructions executed for a single run of the */ - /* bytecode interpreter, needed to prevent infinite loops. You don't */ - /* want to change this except for very special situations (e.g., making */ - /* a library fuzzer spend less time to handle broken fonts). */ - /* */ - /* It is not expected that this value is ever modified by a configuring */ - /* script; instead, it gets surrounded with #ifndef ... #endif so that */ - /* the value can be set as a preprocessor option on the compiler's */ - /* command line. */ - /* */ + /************************************************************************** + * + * Option `TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES` controls the maximum + * number of bytecode instructions executed for a single run of the + * bytecode interpreter, needed to prevent infinite loops. You don't want + * to change this except for very special situations (e.g., making a + * library fuzzer spend less time to handle broken fonts). + * + * It is not expected that this value is ever modified by a configuring + * script; instead, it gets surrounded with `#ifndef ... #endif` so that + * the value can be set as a preprocessor option on the compiler's command + * line. + */ #ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES #define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L #endif @@ -726,59 +726,58 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ - /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ - /* required. */ - /* */ + /************************************************************************** + * + * `T1_MAX_DICT_DEPTH` is the maximum depth of nest dictionaries and arrays + * in the Type~1 stream (see `t1load.c`). A minimum of~4 is required. + */ #define T1_MAX_DICT_DEPTH 5 - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ + /************************************************************************** + * + * `T1_MAX_SUBRS_CALLS` details the maximum number of nested sub-routine + * calls during glyph loading. + */ #define T1_MAX_SUBRS_CALLS 16 - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ - /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ - /* */ + /************************************************************************** + * + * `T1_MAX_CHARSTRING_OPERANDS` is the charstring stack's capacity. A + * minimum of~16 is required. + * + * The Chinese font 'MingTiEG-Medium' (covering the CNS 11643 character + * set) needs 256. + */ #define T1_MAX_CHARSTRINGS_OPERANDS 256 - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ - /* files into an existing face. Note that if set, the T1 driver will be */ - /* unable to produce kerning distances. */ - /* */ + /************************************************************************** + * + * Define this configuration macro if you want to prevent the compilation + * of the 't1afm' module, which is in charge of reading Type~1 AFM files + * into an existing face. Note that if set, the Type~1 driver will be + * unable to produce kerning distances. + */ #undef T1_CONFIG_OPTION_NO_AFM - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of the Multiple Masters font support in the Type 1 */ - /* driver. */ - /* */ + /************************************************************************** + * + * Define this configuration macro if you want to prevent the compilation + * of the Multiple Masters font support in the Type~1 driver. + */ #undef T1_CONFIG_OPTION_NO_MM_SUPPORT - /*************************************************************************/ - /* */ - /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */ - /* engine gets compiled into FreeType. If defined, it is possible to */ - /* switch between the two engines using the `hinting-engine' property of */ - /* the type1 driver module. */ - /* */ + /************************************************************************** + * + * `T1_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe Type~1 + * engine gets compiled into FreeType. If defined, it is possible to + * switch between the two engines using the `hinting-engine` property of + * the 'type1' driver module. + */ /* #define T1_CONFIG_OPTION_OLD_ENGINE */ @@ -791,17 +790,16 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */ - /* possible to set up the default values of the four control points that */ - /* define the stem darkening behaviour of the (new) CFF engine. For */ - /* more details please read the documentation of the */ - /* `darkening-parameters' property (file `ftdriver.h'), which allows the */ - /* control at run-time. */ - /* */ - /* Do *not* undefine these macros! */ - /* */ + /************************************************************************** + * + * Using `CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4}` it is + * possible to set up the default values of the four control points that + * define the stem darkening behaviour of the (new) CFF engine. For more + * details please read the documentation of the `darkening-parameters` + * property (file `ftdriver.h`), which allows the control at run-time. + * + * Do **not** undefine these macros! + */ #define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 #define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 @@ -815,13 +813,13 @@ FT_BEGIN_HEADER #define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 - /*************************************************************************/ - /* */ - /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ - /* engine gets compiled into FreeType. If defined, it is possible to */ - /* switch between the two engines using the `hinting-engine' property of */ - /* the cff driver module. */ - /* */ + /************************************************************************** + * + * `CFF_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe CFF engine + * gets compiled into FreeType. If defined, it is possible to switch + * between the two engines using the `hinting-engine` property of the 'cff' + * driver module. + */ /* #define CFF_CONFIG_OPTION_OLD_ENGINE */ @@ -834,21 +832,21 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* There are many PCF fonts just called `Fixed' which look completely */ - /* different, and which have nothing to do with each other. When */ - /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */ - /* random, the style changes often if one changes the size and one */ - /* cannot select some fonts at all. This option makes the PCF module */ - /* prepend the foundry name (plus a space) to the family name. */ - /* */ - /* We also check whether we have `wide' characters; all put together, we */ - /* get family names like `Sony Fixed' or `Misc Fixed Wide'. */ - /* */ - /* If this option is activated, it can be controlled with the */ - /* `no-long-family-names' property of the pcf driver module. */ - /* */ + /************************************************************************** + * + * There are many PCF fonts just called 'Fixed' which look completely + * different, and which have nothing to do with each other. When selecting + * 'Fixed' in KDE or Gnome one gets results that appear rather random, the + * style changes often if one changes the size and one cannot select some + * fonts at all. This option makes the 'pcf' module prepend the foundry + * name (plus a space) to the family name. + * + * We also check whether we have 'wide' characters; all put together, we + * get family names like 'Sony Fixed' or 'Misc Fixed Wide'. + * + * If this option is activated, it can be controlled with the + * `no-long-family-names` property of the 'pcf' driver module. + */ /* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ @@ -861,69 +859,76 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ - /* support. */ - /* */ + /************************************************************************** + * + * Compile 'autofit' module with CJK (Chinese, Japanese, Korean) script + * support. + */ #define AF_CONFIG_OPTION_CJK - /*************************************************************************/ - /* */ - /* Compile autofit module with fallback Indic script support, covering */ - /* some scripts that the `latin' submodule of the autofit module doesn't */ - /* (yet) handle. */ - /* */ + + /************************************************************************** + * + * Compile 'autofit' module with fallback Indic script support, covering + * some scripts that the 'latin' submodule of the 'autofit' module doesn't + * (yet) handle. + */ #define AF_CONFIG_OPTION_INDIC - /*************************************************************************/ - /* */ - /* Compile autofit module with warp hinting. The idea of the warping */ - /* code is to slightly scale and shift a glyph within a single dimension */ - /* so that as much of its segments are aligned (more or less) on the */ - /* grid. To find out the optimal scaling and shifting value, various */ - /* parameter combinations are tried and scored. */ - /* */ - /* This experimental option is active only if the rendering mode is */ - /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */ - /* `warping' property of the auto-hinter (see file `ftdriver.h' for more */ - /* information; by default it is switched off). */ - /* */ + + /************************************************************************** + * + * Compile 'autofit' module with warp hinting. The idea of the warping + * code is to slightly scale and shift a glyph within a single dimension so + * that as much of its segments are aligned (more or less) on the grid. To + * find out the optimal scaling and shifting value, various parameter + * combinations are tried and scored. + * + * You can switch warping on and off with the `warping` property of the + * auto-hinter (see file `ftdriver.h` for more information; by default it + * is switched off). + * + * This experimental option is not active if the rendering mode is + * `FT_RENDER_MODE_LIGHT`. + */ #define AF_CONFIG_OPTION_USE_WARPER - /*************************************************************************/ - /* */ - /* Use TrueType-like size metrics for `light' auto-hinting. */ - /* */ - /* It is strongly recommended to avoid this option, which exists only to */ - /* help some legacy applications retain its appearance and behaviour */ - /* with respect to auto-hinted TrueType fonts. */ - /* */ - /* The very reason this option exists at all are GNU/Linux distributions */ - /* like Fedora that did not un-patch the following change (which was */ - /* present in FreeType between versions 2.4.6 and 2.7.1, inclusive). */ - /* */ - /* 2011-07-16 Steven Chu <steven.f.chu@gmail.com> */ - /* */ - /* [truetype] Fix metrics on size request for scalable fonts. */ - /* */ - /* This problematic commit is now reverted (more or less). */ - /* */ + + /************************************************************************** + * + * Use TrueType-like size metrics for 'light' auto-hinting. + * + * It is strongly recommended to avoid this option, which exists only to + * help some legacy applications retain its appearance and behaviour with + * respect to auto-hinted TrueType fonts. + * + * The very reason this option exists at all are GNU/Linux distributions + * like Fedora that did not un-patch the following change (which was + * present in FreeType between versions 2.4.6 and 2.7.1, inclusive). + * + * ``` + * 2011-07-16 Steven Chu <steven.f.chu@gmail.com> + * + * [truetype] Fix metrics on size request for scalable fonts. + * ``` + * + * This problematic commit is now reverted (more or less). + */ /* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */ /* */ /* - * This macro is obsolete. Support has been removed in FreeType - * version 2.5. + * This macro is obsolete. Support has been removed in FreeType version + * 2.5. */ /* #define FT_CONFIG_OPTION_OLD_INTERNALS */ /* - * This macro is defined if native TrueType hinting is requested by the - * definitions above. + * The next three macros are defined if native TrueType hinting is + * requested by the definitions above. Don't change this. */ #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER #define TT_USE_BYTECODE_INTERPRETER @@ -942,7 +947,7 @@ FT_BEGIN_HEADER /* * Check CFF darkening parameters. The checks are the same as in function - * `cff_property_set' in file `cffdrivr.c'. + * `cff_property_set` in file `cffdrivr.c`. */ #if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h index 42f9a06e439..438b6145d51 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/config/ftstdlib.h @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* ftstdlib.h */ -/* */ -/* ANSI-specific library and header configuration file (specification */ -/* only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to group all #includes to the ANSI C library that */ - /* FreeType normally requires. It also defines macros to rename the */ - /* standard functions within the FreeType source code. */ - /* */ - /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftstdlib.h + * + * ANSI-specific library and header configuration file (specification + * only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to group all `#includes` to the ANSI~C library that + * FreeType normally requires. It also defines macros to rename the + * standard functions within the FreeType source code. + * + * Load a file which defines `FTSTDLIB_H_` before this one to override it. + * + */ #ifndef FTSTDLIB_H_ @@ -37,23 +37,23 @@ #define ft_ptrdiff_t ptrdiff_t - /**********************************************************************/ - /* */ - /* integer limits */ - /* */ - /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ - /* of `int' and `long' in bytes at compile-time. So far, this works */ - /* for all platforms the library has been tested on. */ - /* */ - /* Note that on the extremely rare platforms that do not provide */ - /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ - /* old Crays where `int' is 36 bits), we do not make any guarantee */ - /* about the correct behaviour of FT2 with all fonts. */ - /* */ - /* In these case, `ftconfig.h' will refuse to compile anyway with a */ - /* message like `couldn't find 32-bit type' or something similar. */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * integer limits + * + * `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of + * `int` and `long` in bytes at compile-time. So far, this works for all + * platforms the library has been tested on. + * + * Note that on the extremely rare platforms that do not provide integer + * types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where + * `int` is 36~bits), we do not make any guarantee about the correct + * behaviour of FreeType~2 with all fonts. + * + * In these cases, `ftconfig.h` will refuse to compile anyway with a + * message like 'couldn't find 32-bit type' or something similar. + * + */ #include <limits.h> @@ -68,11 +68,11 @@ #define FT_ULONG_MAX ULONG_MAX - /**********************************************************************/ - /* */ - /* character and string processing */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * character and string processing + * + */ #include <string.h> @@ -92,11 +92,11 @@ #define ft_strstr strstr - /**********************************************************************/ - /* */ - /* file handling */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * file handling + * + */ #include <stdio.h> @@ -110,11 +110,11 @@ #define ft_sprintf sprintf - /**********************************************************************/ - /* */ - /* sorting */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * sorting + * + */ #include <stdlib.h> @@ -122,11 +122,11 @@ #define ft_qsort qsort - /**********************************************************************/ - /* */ - /* memory allocation */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * memory allocation + * + */ #define ft_scalloc calloc @@ -135,36 +135,36 @@ #define ft_srealloc realloc - /**********************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * miscellaneous + * + */ #define ft_strtol strtol #define ft_getenv getenv - /**********************************************************************/ - /* */ - /* execution control */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * execution control + * + */ #include <setjmp.h> -#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ - /* jmp_buf is defined as a macro */ - /* on certain platforms */ +#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ + /* `jmp_buf` is defined as a macro */ + /* on certain platforms */ #define ft_longjmp longjmp #define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ - /* the following is only used for debugging purposes, i.e., if */ - /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ + /* The following is only used for debugging purposes, i.e., if */ + /* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */ #include <stdarg.h> diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h index 96644046e45..2978f985034 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* freetype.h */ -/* */ -/* FreeType high-level API and common types (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * freetype.h + * + * FreeType high-level API and common types (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FREETYPE_H_ @@ -39,56 +39,55 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* header_inclusion */ - /* */ - /* <Title> */ - /* FreeType's header inclusion scheme */ - /* */ - /* <Abstract> */ - /* How client applications should include FreeType header files. */ - /* */ - /* <Description> */ - /* To be as flexible as possible (and for historical reasons), */ - /* FreeType uses a very special inclusion scheme to load header */ - /* files, for example */ - /* */ - /* { */ - /* #include <ft2build.h> */ - /* */ - /* #include FT_FREETYPE_H */ - /* #include FT_OUTLINE_H */ - /* } */ - /* */ - /* A compiler and its preprocessor only needs an include path to find */ - /* the file `ft2build.h'; the exact locations and names of the other */ - /* FreeType header files are hidden by preprocessor macro names, */ - /* loaded by `ft2build.h'. The API documentation always gives the */ - /* header macro name needed for a particular function. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * header_inclusion + * + * @title: + * FreeType's header inclusion scheme + * + * @abstract: + * How client applications should include FreeType header files. + * + * @description: + * To be as flexible as possible (and for historical reasons), FreeType + * uses a very special inclusion scheme to load header files, for example + * + * ``` + * #include <ft2build.h> + * + * #include FT_FREETYPE_H + * #include FT_OUTLINE_H + * ``` + * + * A compiler and its preprocessor only needs an include path to find the + * file `ft2build.h`; the exact locations and names of the other FreeType + * header files are hidden by @header_file_macros, loaded by + * `ft2build.h`. The API documentation always gives the header macro + * name needed for a particular function. + * + */ - /*************************************************************************/ - /* */ - /* <Section> */ - /* user_allocation */ - /* */ - /* <Title> */ - /* User allocation */ - /* */ - /* <Abstract> */ - /* How client applications should allocate FreeType data structures. */ - /* */ - /* <Description> */ - /* FreeType assumes that structures allocated by the user and passed */ - /* as arguments are zeroed out except for the actual data. In other */ - /* words, it is recommended to use `calloc' (or variants of it) */ - /* instead of `malloc' for allocation. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * user_allocation + * + * @title: + * User allocation + * + * @abstract: + * How client applications should allocate FreeType data structures. + * + * @description: + * FreeType assumes that structures allocated by the user and passed as + * arguments are zeroed out except for the actual data. In other words, + * it is recommended to use `calloc` (or variants of it) instead of + * `malloc` for allocation. + * + */ @@ -101,219 +100,219 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /* <Title> */ - /* Base Interface */ - /* */ - /* <Abstract> */ - /* The FreeType~2 base font interface. */ - /* */ - /* <Description> */ - /* This section describes the most important public high-level API */ - /* functions of FreeType~2. */ - /* */ - /* <Order> */ - /* FT_Library */ - /* FT_Face */ - /* FT_Size */ - /* FT_GlyphSlot */ - /* FT_CharMap */ - /* FT_Encoding */ - /* FT_ENC_TAG */ - /* */ - /* FT_FaceRec */ - /* */ - /* FT_FACE_FLAG_SCALABLE */ - /* FT_FACE_FLAG_FIXED_SIZES */ - /* FT_FACE_FLAG_FIXED_WIDTH */ - /* FT_FACE_FLAG_HORIZONTAL */ - /* FT_FACE_FLAG_VERTICAL */ - /* FT_FACE_FLAG_COLOR */ - /* FT_FACE_FLAG_SFNT */ - /* FT_FACE_FLAG_CID_KEYED */ - /* FT_FACE_FLAG_TRICKY */ - /* FT_FACE_FLAG_KERNING */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS */ - /* FT_FACE_FLAG_VARIATION */ - /* FT_FACE_FLAG_GLYPH_NAMES */ - /* FT_FACE_FLAG_EXTERNAL_STREAM */ - /* FT_FACE_FLAG_HINTER */ - /* */ - /* FT_HAS_HORIZONTAL */ - /* FT_HAS_VERTICAL */ - /* FT_HAS_KERNING */ - /* FT_HAS_FIXED_SIZES */ - /* FT_HAS_GLYPH_NAMES */ - /* FT_HAS_COLOR */ - /* FT_HAS_MULTIPLE_MASTERS */ - /* */ - /* FT_IS_SFNT */ - /* FT_IS_SCALABLE */ - /* FT_IS_FIXED_WIDTH */ - /* FT_IS_CID_KEYED */ - /* FT_IS_TRICKY */ - /* FT_IS_NAMED_INSTANCE */ - /* FT_IS_VARIATION */ - /* */ - /* FT_STYLE_FLAG_BOLD */ - /* FT_STYLE_FLAG_ITALIC */ - /* */ - /* FT_SizeRec */ - /* FT_Size_Metrics */ - /* */ - /* FT_GlyphSlotRec */ - /* FT_Glyph_Metrics */ - /* FT_SubGlyph */ - /* */ - /* FT_Bitmap_Size */ - /* */ - /* FT_Init_FreeType */ - /* FT_Done_FreeType */ - /* */ - /* FT_New_Face */ - /* FT_Done_Face */ - /* FT_Reference_Face */ - /* FT_New_Memory_Face */ - /* FT_Face_Properties */ - /* FT_Open_Face */ - /* FT_Open_Args */ - /* FT_Parameter */ - /* FT_Attach_File */ - /* FT_Attach_Stream */ - /* */ - /* FT_Set_Char_Size */ - /* FT_Set_Pixel_Sizes */ - /* FT_Request_Size */ - /* FT_Select_Size */ - /* FT_Size_Request_Type */ - /* FT_Size_RequestRec */ - /* FT_Size_Request */ - /* FT_Set_Transform */ - /* FT_Load_Glyph */ - /* FT_Get_Char_Index */ - /* FT_Get_First_Char */ - /* FT_Get_Next_Char */ - /* FT_Get_Name_Index */ - /* FT_Load_Char */ - /* */ - /* FT_OPEN_MEMORY */ - /* FT_OPEN_STREAM */ - /* FT_OPEN_PATHNAME */ - /* FT_OPEN_DRIVER */ - /* FT_OPEN_PARAMS */ - /* */ - /* FT_LOAD_DEFAULT */ - /* FT_LOAD_RENDER */ - /* FT_LOAD_MONOCHROME */ - /* FT_LOAD_LINEAR_DESIGN */ - /* FT_LOAD_NO_SCALE */ - /* FT_LOAD_NO_HINTING */ - /* FT_LOAD_NO_BITMAP */ - /* FT_LOAD_NO_AUTOHINT */ - /* FT_LOAD_COLOR */ - /* */ - /* FT_LOAD_VERTICAL_LAYOUT */ - /* FT_LOAD_IGNORE_TRANSFORM */ - /* FT_LOAD_FORCE_AUTOHINT */ - /* FT_LOAD_NO_RECURSE */ - /* FT_LOAD_PEDANTIC */ - /* */ - /* FT_LOAD_TARGET_NORMAL */ - /* FT_LOAD_TARGET_LIGHT */ - /* FT_LOAD_TARGET_MONO */ - /* FT_LOAD_TARGET_LCD */ - /* FT_LOAD_TARGET_LCD_V */ - /* */ - /* FT_LOAD_TARGET_MODE */ - /* */ - /* FT_Render_Glyph */ - /* FT_Render_Mode */ - /* FT_Get_Kerning */ - /* FT_Kerning_Mode */ - /* FT_Get_Track_Kerning */ - /* FT_Get_Glyph_Name */ - /* FT_Get_Postscript_Name */ - /* */ - /* FT_CharMapRec */ - /* FT_Select_Charmap */ - /* FT_Set_Charmap */ - /* FT_Get_Charmap_Index */ - /* */ - /* FT_Get_FSType_Flags */ - /* FT_Get_SubGlyph_Info */ - /* */ - /* FT_Face_Internal */ - /* FT_Size_Internal */ - /* FT_Slot_Internal */ - /* */ - /* FT_FACE_FLAG_XXX */ - /* FT_STYLE_FLAG_XXX */ - /* FT_OPEN_XXX */ - /* FT_LOAD_XXX */ - /* FT_LOAD_TARGET_XXX */ - /* FT_SUBGLYPH_FLAG_XXX */ - /* FT_FSTYPE_XXX */ - /* */ - /* FT_HAS_FAST_GLYPHS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * base_interface + * + * @title: + * Base Interface + * + * @abstract: + * The FreeType~2 base font interface. + * + * @description: + * This section describes the most important public high-level API + * functions of FreeType~2. + * + * @order: + * FT_Library + * FT_Face + * FT_Size + * FT_GlyphSlot + * FT_CharMap + * FT_Encoding + * FT_ENC_TAG + * + * FT_FaceRec + * + * FT_FACE_FLAG_SCALABLE + * FT_FACE_FLAG_FIXED_SIZES + * FT_FACE_FLAG_FIXED_WIDTH + * FT_FACE_FLAG_HORIZONTAL + * FT_FACE_FLAG_VERTICAL + * FT_FACE_FLAG_COLOR + * FT_FACE_FLAG_SFNT + * FT_FACE_FLAG_CID_KEYED + * FT_FACE_FLAG_TRICKY + * FT_FACE_FLAG_KERNING + * FT_FACE_FLAG_MULTIPLE_MASTERS + * FT_FACE_FLAG_VARIATION + * FT_FACE_FLAG_GLYPH_NAMES + * FT_FACE_FLAG_EXTERNAL_STREAM + * FT_FACE_FLAG_HINTER + * + * FT_HAS_HORIZONTAL + * FT_HAS_VERTICAL + * FT_HAS_KERNING + * FT_HAS_FIXED_SIZES + * FT_HAS_GLYPH_NAMES + * FT_HAS_COLOR + * FT_HAS_MULTIPLE_MASTERS + * + * FT_IS_SFNT + * FT_IS_SCALABLE + * FT_IS_FIXED_WIDTH + * FT_IS_CID_KEYED + * FT_IS_TRICKY + * FT_IS_NAMED_INSTANCE + * FT_IS_VARIATION + * + * FT_STYLE_FLAG_BOLD + * FT_STYLE_FLAG_ITALIC + * + * FT_SizeRec + * FT_Size_Metrics + * + * FT_GlyphSlotRec + * FT_Glyph_Metrics + * FT_SubGlyph + * + * FT_Bitmap_Size + * + * FT_Init_FreeType + * FT_Done_FreeType + * + * FT_New_Face + * FT_Done_Face + * FT_Reference_Face + * FT_New_Memory_Face + * FT_Face_Properties + * FT_Open_Face + * FT_Open_Args + * FT_Parameter + * FT_Attach_File + * FT_Attach_Stream + * + * FT_Set_Char_Size + * FT_Set_Pixel_Sizes + * FT_Request_Size + * FT_Select_Size + * FT_Size_Request_Type + * FT_Size_RequestRec + * FT_Size_Request + * FT_Set_Transform + * FT_Load_Glyph + * FT_Get_Char_Index + * FT_Get_First_Char + * FT_Get_Next_Char + * FT_Get_Name_Index + * FT_Load_Char + * + * FT_OPEN_MEMORY + * FT_OPEN_STREAM + * FT_OPEN_PATHNAME + * FT_OPEN_DRIVER + * FT_OPEN_PARAMS + * + * FT_LOAD_DEFAULT + * FT_LOAD_RENDER + * FT_LOAD_MONOCHROME + * FT_LOAD_LINEAR_DESIGN + * FT_LOAD_NO_SCALE + * FT_LOAD_NO_HINTING + * FT_LOAD_NO_BITMAP + * FT_LOAD_NO_AUTOHINT + * FT_LOAD_COLOR + * + * FT_LOAD_VERTICAL_LAYOUT + * FT_LOAD_IGNORE_TRANSFORM + * FT_LOAD_FORCE_AUTOHINT + * FT_LOAD_NO_RECURSE + * FT_LOAD_PEDANTIC + * + * FT_LOAD_TARGET_NORMAL + * FT_LOAD_TARGET_LIGHT + * FT_LOAD_TARGET_MONO + * FT_LOAD_TARGET_LCD + * FT_LOAD_TARGET_LCD_V + * + * FT_LOAD_TARGET_MODE + * + * FT_Render_Glyph + * FT_Render_Mode + * FT_Get_Kerning + * FT_Kerning_Mode + * FT_Get_Track_Kerning + * FT_Get_Glyph_Name + * FT_Get_Postscript_Name + * + * FT_CharMapRec + * FT_Select_Charmap + * FT_Set_Charmap + * FT_Get_Charmap_Index + * + * FT_Get_FSType_Flags + * FT_Get_SubGlyph_Info + * + * FT_Face_Internal + * FT_Size_Internal + * FT_Slot_Internal + * + * FT_FACE_FLAG_XXX + * FT_STYLE_FLAG_XXX + * FT_OPEN_XXX + * FT_LOAD_XXX + * FT_LOAD_TARGET_XXX + * FT_SUBGLYPH_FLAG_XXX + * FT_FSTYPE_XXX + * + * FT_HAS_FAST_GLYPHS + * + */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Glyph_Metrics */ - /* */ - /* <Description> */ - /* A structure to model the metrics of a single glyph. The values */ - /* are expressed in 26.6 fractional pixel format; if the flag */ - /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ - /* are expressed in font units instead. */ - /* */ - /* <Fields> */ - /* width :: */ - /* The glyph's width. */ - /* */ - /* height :: */ - /* The glyph's height. */ - /* */ - /* horiBearingX :: */ - /* Left side bearing for horizontal layout. */ - /* */ - /* horiBearingY :: */ - /* Top side bearing for horizontal layout. */ - /* */ - /* horiAdvance :: */ - /* Advance width for horizontal layout. */ - /* */ - /* vertBearingX :: */ - /* Left side bearing for vertical layout. */ - /* */ - /* vertBearingY :: */ - /* Top side bearing for vertical layout. Larger positive values */ - /* mean further below the vertical glyph origin. */ - /* */ - /* vertAdvance :: */ - /* Advance height for vertical layout. Positive values mean the */ - /* glyph has a positive advance downward. */ - /* */ - /* <Note> */ - /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ - /* dimensions of the hinted glyph (in case hinting is applicable). */ - /* */ - /* Stroking a glyph with an outside border does not increase */ - /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ - /* values to account for the added width and height. */ - /* */ - /* FreeType doesn't use the `VORG' table data for CFF fonts because */ - /* it doesn't have an interface to quickly retrieve the glyph height. */ - /* The y~coordinate of the vertical origin can be simply computed as */ - /* `vertBearingY + height' after loading a glyph. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Glyph_Metrics + * + * @description: + * A structure to model the metrics of a single glyph. The values are + * expressed in 26.6 fractional pixel format; if the flag + * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are + * expressed in font units instead. + * + * @fields: + * width :: + * The glyph's width. + * + * height :: + * The glyph's height. + * + * horiBearingX :: + * Left side bearing for horizontal layout. + * + * horiBearingY :: + * Top side bearing for horizontal layout. + * + * horiAdvance :: + * Advance width for horizontal layout. + * + * vertBearingX :: + * Left side bearing for vertical layout. + * + * vertBearingY :: + * Top side bearing for vertical layout. Larger positive values mean + * further below the vertical glyph origin. + * + * vertAdvance :: + * Advance height for vertical layout. Positive values mean the glyph + * has a positive advance downward. + * + * @note: + * If not disabled with @FT_LOAD_NO_HINTING, the values represent + * dimensions of the hinted glyph (in case hinting is applicable). + * + * Stroking a glyph with an outside border does not increase + * `horiAdvance` or `vertAdvance`; you have to manually adjust these + * values to account for the added width and height. + * + * FreeType doesn't use the 'VORG' table data for CFF fonts because it + * doesn't have an interface to quickly retrieve the glyph height. The + * y~coordinate of the vertical origin can be simply computed as + * `vertBearingY + height` after loading a glyph. + */ typedef struct FT_Glyph_Metrics_ { FT_Pos width; @@ -330,44 +329,45 @@ FT_BEGIN_HEADER } FT_Glyph_Metrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap_Size */ - /* */ - /* <Description> */ - /* This structure models the metrics of a bitmap strike (i.e., a set */ - /* of glyphs for a given point size and resolution) in a bitmap font. */ - /* It is used for the `available_sizes' field of @FT_Face. */ - /* */ - /* <Fields> */ - /* height :: The vertical distance, in pixels, between two */ - /* consecutive baselines. It is always positive. */ - /* */ - /* width :: The average width, in pixels, of all glyphs in the */ - /* strike. */ - /* */ - /* size :: The nominal size of the strike in 26.6 fractional */ - /* points. This field is not very useful. */ - /* */ - /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ - /* pixels. */ - /* */ - /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ - /* pixels. */ - /* */ - /* <Note> */ - /* Windows FNT: */ - /* The nominal size given in a FNT font is not reliable. If the */ - /* driver finds it incorrect, it sets `size' to some calculated */ - /* values, and `x_ppem' and `y_ppem' to the pixel width and height */ - /* given in the font, respectively. */ - /* */ - /* TrueType embedded bitmaps: */ - /* `size', `width', and `height' values are not contained in the */ - /* bitmap strike itself. They are computed from the global font */ - /* parameters. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Bitmap_Size + * + * @description: + * This structure models the metrics of a bitmap strike (i.e., a set of + * glyphs for a given point size and resolution) in a bitmap font. It is + * used for the `available_sizes` field of @FT_Face. + * + * @fields: + * height :: + * The vertical distance, in pixels, between two consecutive baselines. + * It is always positive. + * + * width :: + * The average width, in pixels, of all glyphs in the strike. + * + * size :: + * The nominal size of the strike in 26.6 fractional points. This + * field is not very useful. + * + * x_ppem :: + * The horizontal ppem (nominal width) in 26.6 fractional pixels. + * + * y_ppem :: + * The vertical ppem (nominal height) in 26.6 fractional pixels. + * + * @note: + * Windows FNT: + * The nominal size given in a FNT font is not reliable. If the driver + * finds it incorrect, it sets `size` to some calculated values, and + * `x_ppem` and `y_ppem` to the pixel width and height given in the + * font, respectively. + * + * TrueType embedded bitmaps: + * `size`, `width`, and `height` values are not contained in the bitmap + * strike itself. They are computed from the global font parameters. + */ typedef struct FT_Bitmap_Size_ { FT_Short height; @@ -389,225 +389,218 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Library */ - /* */ - /* <Description> */ - /* A handle to a FreeType library instance. Each `library' is */ - /* completely independent from the others; it is the `root' of a set */ - /* of objects like fonts, faces, sizes, etc. */ - /* */ - /* It also embeds a memory manager (see @FT_Memory), as well as a */ - /* scan-line converter object (see @FT_Raster). */ - /* */ - /* In multi-threaded applications it is easiest to use one */ - /* `FT_Library' object per thread. In case this is too cumbersome, */ - /* a single `FT_Library' object across threads is possible also */ - /* (since FreeType version 2.5.6), as long as a mutex lock is used */ - /* around @FT_New_Face and @FT_Done_Face. */ - /* */ - /* <Note> */ - /* Library objects are normally created by @FT_Init_FreeType, and */ - /* destroyed with @FT_Done_FreeType. If you need reference-counting */ - /* (cf. @FT_Reference_Library), use @FT_New_Library and */ - /* @FT_Done_Library. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Library + * + * @description: + * A handle to a FreeType library instance. Each 'library' is completely + * independent from the others; it is the 'root' of a set of objects like + * fonts, faces, sizes, etc. + * + * It also embeds a memory manager (see @FT_Memory), as well as a + * scan-line converter object (see @FT_Raster). + * + * [Since 2.5.6] In multi-threaded applications it is easiest to use one + * `FT_Library` object per thread. In case this is too cumbersome, a + * single `FT_Library` object across threads is possible also, as long as + * a mutex lock is used around @FT_New_Face and @FT_Done_Face. + * + * @note: + * Library objects are normally created by @FT_Init_FreeType, and + * destroyed with @FT_Done_FreeType. If you need reference-counting + * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library. + */ typedef struct FT_LibraryRec_ *FT_Library; - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * module_management + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Module */ - /* */ - /* <Description> */ - /* A handle to a given FreeType module object. A module can be a */ - /* font driver, a renderer, or anything else that provides services */ - /* to the former. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Module + * + * @description: + * A handle to a given FreeType module object. A module can be a font + * driver, a renderer, or anything else that provides services to the + * former. + */ typedef struct FT_ModuleRec_* FT_Module; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Driver */ - /* */ - /* <Description> */ - /* A handle to a given FreeType font driver object. A font driver */ - /* is a module capable of creating faces from font files. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Driver + * + * @description: + * A handle to a given FreeType font driver object. A font driver is a + * module capable of creating faces from font files. + */ typedef struct FT_DriverRec_* FT_Driver; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Renderer */ - /* */ - /* <Description> */ - /* A handle to a given FreeType renderer. A renderer is a module in */ - /* charge of converting a glyph's outline image to a bitmap. It */ - /* supports a single glyph image format, and one or more target */ - /* surface depths. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Renderer + * + * @description: + * A handle to a given FreeType renderer. A renderer is a module in + * charge of converting a glyph's outline image to a bitmap. It supports + * a single glyph image format, and one or more target surface depths. + */ typedef struct FT_RendererRec_* FT_Renderer; - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * base_interface + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face */ - /* */ - /* <Description> */ - /* A handle to a typographic face object. A face object models a */ - /* given typeface, in a given style. */ - /* */ - /* <Note> */ - /* A face object also owns a single @FT_GlyphSlot object, as well */ - /* as one or more @FT_Size objects. */ - /* */ - /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ - /* a given filepath or a custom input stream. */ - /* */ - /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ - /* */ - /* An `FT_Face' object can only be safely used from one thread at a */ - /* time. Similarly, creation and destruction of `FT_Face' with the */ - /* same @FT_Library object can only be done from one thread at a */ - /* time. On the other hand, functions like @FT_Load_Glyph and its */ - /* siblings are thread-safe and do not need the lock to be held as */ - /* long as the same `FT_Face' object is not used from multiple */ - /* threads at the same time. */ - /* */ - /* <Also> */ - /* See @FT_FaceRec for the publicly accessible fields of a given face */ - /* object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Face + * + * @description: + * A handle to a typographic face object. A face object models a given + * typeface, in a given style. + * + * @note: + * A face object also owns a single @FT_GlyphSlot object, as well as one + * or more @FT_Size objects. + * + * Use @FT_New_Face or @FT_Open_Face to create a new face object from a + * given filepath or a custom input stream. + * + * Use @FT_Done_Face to destroy it (along with its slot and sizes). + * + * An `FT_Face` object can only be safely used from one thread at a time. + * Similarly, creation and destruction of `FT_Face` with the same + * @FT_Library object can only be done from one thread at a time. On the + * other hand, functions like @FT_Load_Glyph and its siblings are + * thread-safe and do not need the lock to be held as long as the same + * `FT_Face` object is not used from multiple threads at the same time. + * + * @also: + * See @FT_FaceRec for the publicly accessible fields of a given face + * object. + */ typedef struct FT_FaceRec_* FT_Face; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size */ - /* */ - /* <Description> */ - /* A handle to an object that models a face scaled to a given */ - /* character size. */ - /* */ - /* <Note> */ - /* An @FT_Face has one _active_ @FT_Size object that is used by */ - /* functions like @FT_Load_Glyph to determine the scaling */ - /* transformation that in turn is used to load and hint glyphs and */ - /* metrics. */ - /* */ - /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ - /* @FT_Request_Size or even @FT_Select_Size to change the content */ - /* (i.e., the scaling values) of the active @FT_Size. */ - /* */ - /* You can use @FT_New_Size to create additional size objects for a */ - /* given @FT_Face, but they won't be used by other functions until */ - /* you activate it through @FT_Activate_Size. Only one size can be */ - /* activated at any given time per face. */ - /* */ - /* <Also> */ - /* See @FT_SizeRec for the publicly accessible fields of a given size */ - /* object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Size + * + * @description: + * A handle to an object that models a face scaled to a given character + * size. + * + * @note: + * An @FT_Face has one _active_ @FT_Size object that is used by functions + * like @FT_Load_Glyph to determine the scaling transformation that in + * turn is used to load and hint glyphs and metrics. + * + * You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size + * or even @FT_Select_Size to change the content (i.e., the scaling + * values) of the active @FT_Size. + * + * You can use @FT_New_Size to create additional size objects for a given + * @FT_Face, but they won't be used by other functions until you activate + * it through @FT_Activate_Size. Only one size can be activated at any + * given time per face. + * + * @also: + * See @FT_SizeRec for the publicly accessible fields of a given size + * object. + */ typedef struct FT_SizeRec_* FT_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a given `glyph slot'. A slot is a container that can */ - /* hold any of the glyphs contained in its parent face. */ - /* */ - /* In other words, each time you call @FT_Load_Glyph or */ - /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ - /* i.e., the glyph's metrics, its image (bitmap or outline), and */ - /* other control information. */ - /* */ - /* <Also> */ - /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ - /* */ + /************************************************************************** + * + * @type: + * FT_GlyphSlot + * + * @description: + * A handle to a given 'glyph slot'. A slot is a container that can hold + * any of the glyphs contained in its parent face. + * + * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char, + * the slot's content is erased by the new glyph data, i.e., the glyph's + * metrics, its image (bitmap or outline), and other control information. + * + * @also: + * See @FT_GlyphSlotRec for the publicly accessible glyph fields. + */ typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_CharMap */ - /* */ - /* <Description> */ - /* A handle to a character map (usually abbreviated to `charmap'). A */ - /* charmap is used to translate character codes in a given encoding */ - /* into glyph indexes for its parent's face. Some font formats may */ - /* provide several charmaps per font. */ - /* */ - /* Each face object owns zero or more charmaps, but only one of them */ - /* can be `active', providing the data used by @FT_Get_Char_Index or */ - /* @FT_Load_Char. */ - /* */ - /* The list of available charmaps in a face is available through the */ - /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ - /* */ - /* The currently active charmap is available as `face->charmap'. */ - /* You should call @FT_Set_Charmap to change it. */ - /* */ - /* <Note> */ - /* When a new face is created (either through @FT_New_Face or */ - /* @FT_Open_Face), the library looks for a Unicode charmap within */ - /* the list and automatically activates it. If there is no Unicode */ - /* charmap, FreeType doesn't set an `active' charmap. */ - /* */ - /* <Also> */ - /* See @FT_CharMapRec for the publicly accessible fields of a given */ - /* character map. */ - /* */ + /************************************************************************** + * + * @type: + * FT_CharMap + * + * @description: + * A handle to a character map (usually abbreviated to 'charmap'). A + * charmap is used to translate character codes in a given encoding into + * glyph indexes for its parent's face. Some font formats may provide + * several charmaps per font. + * + * Each face object owns zero or more charmaps, but only one of them can + * be 'active', providing the data used by @FT_Get_Char_Index or + * @FT_Load_Char. + * + * The list of available charmaps in a face is available through the + * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec. + * + * The currently active charmap is available as `face->charmap`. You + * should call @FT_Set_Charmap to change it. + * + * @note: + * When a new face is created (either through @FT_New_Face or + * @FT_Open_Face), the library looks for a Unicode charmap within the + * list and automatically activates it. If there is no Unicode charmap, + * FreeType doesn't set an 'active' charmap. + * + * @also: + * See @FT_CharMapRec for the publicly accessible fields of a given + * character map. + */ typedef struct FT_CharMapRec_* FT_CharMap; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_ENC_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags into an unsigned long. It is */ - /* used to define `encoding' identifiers (see @FT_Encoding). */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_ENC_TAG( value, a, b, c, d ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ + /************************************************************************** + * + * @macro: + * FT_ENC_TAG + * + * @description: + * This macro converts four-letter tags into an unsigned long. It is + * used to define 'encoding' identifiers (see @FT_Encoding). + * + * @note: + * Since many 16-bit compilers don't like 32-bit enumerations, you should + * redefine this macro in case of problems to something like this: + * + * ``` + * #define FT_ENC_TAG( value, a, b, c, d ) value + * ``` + * + * to get a simple enumeration without assigning special numbers. + */ #ifndef FT_ENC_TAG #define FT_ENC_TAG( value, a, b, c, d ) \ @@ -619,150 +612,147 @@ FT_BEGIN_HEADER #endif /* FT_ENC_TAG */ - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Encoding */ - /* */ - /* <Description> */ - /* An enumeration to specify character sets supported by charmaps. */ - /* Used in the @FT_Select_Charmap API function. */ - /* */ - /* <Note> */ - /* Despite the name, this enumeration lists specific character */ - /* repertories (i.e., charsets), and not text encoding methods (e.g., */ - /* UTF-8, UTF-16, etc.). */ - /* */ - /* Other encodings might be defined in the future. */ - /* */ - /* <Values> */ - /* FT_ENCODING_NONE :: */ - /* The encoding value~0 is reserved. */ - /* */ - /* FT_ENCODING_UNICODE :: */ - /* The Unicode character set. This value covers all versions of */ - /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */ - /* include a Unicode charmap, but not all of them. */ - /* */ - /* For example, if you want to access Unicode value U+1F028 (and */ - /* the font contains it), use value 0x1F028 as the input value for */ - /* @FT_Get_Char_Index. */ - /* */ - /* FT_ENCODING_MS_SYMBOL :: */ - /* Microsoft Symbol encoding, used to encode mathematical symbols */ - /* and wingdings. For more information, see */ - /* `https://www.microsoft.com/typography/otspec/recom.htm', */ - /* `http://www.kostis.net/charsets/symbol.htm', and */ - /* `http://www.kostis.net/charsets/wingding.htm'. */ - /* */ - /* This encoding uses character codes from the PUA (Private Unicode */ - /* Area) in the range U+F020-U+F0FF. */ - /* */ - /* FT_ENCODING_SJIS :: */ - /* Shift JIS encoding for Japanese. More info at */ - /* `https://en.wikipedia.org/wiki/Shift_JIS'. See note on */ - /* multi-byte encodings below. */ - /* */ - /* FT_ENCODING_PRC :: */ - /* Corresponds to encoding systems mainly for Simplified Chinese as */ - /* used in People's Republic of China (PRC). The encoding layout */ - /* is based on GB~2312 and its supersets GBK and GB~18030. */ - /* */ - /* FT_ENCODING_BIG5 :: */ - /* Corresponds to an encoding system for Traditional Chinese as */ - /* used in Taiwan and Hong Kong. */ - /* */ - /* FT_ENCODING_WANSUNG :: */ - /* Corresponds to the Korean encoding system known as Extended */ - /* Wansung (MS Windows code page 949). */ - /* For more information see */ - /* `https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */ - /* */ - /* FT_ENCODING_JOHAB :: */ - /* The Korean standard character set (KS~C 5601-1992), which */ - /* corresponds to MS Windows code page 1361. This character set */ - /* includes all possible Hangul character combinations. */ - /* */ - /* FT_ENCODING_ADOBE_LATIN_1 :: */ - /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ - /* PostScript font. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_STANDARD :: */ - /* Adobe Standard encoding, as found in Type~1, CFF, and */ - /* OpenType/CFF fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_EXPERT :: */ - /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */ - /* fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_CUSTOM :: */ - /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ - /* OpenType/CFF fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_APPLE_ROMAN :: */ - /* Apple roman encoding. Many TrueType and OpenType fonts contain */ - /* a charmap for this 8-bit encoding, since older versions of Mac */ - /* OS are able to use it. */ - /* */ - /* FT_ENCODING_OLD_LATIN_2 :: */ - /* This value is deprecated and was neither used nor reported by */ - /* FreeType. Don't use or test for it. */ - /* */ - /* FT_ENCODING_MS_SJIS :: */ - /* Same as FT_ENCODING_SJIS. Deprecated. */ - /* */ - /* FT_ENCODING_MS_GB2312 :: */ - /* Same as FT_ENCODING_PRC. Deprecated. */ - /* */ - /* FT_ENCODING_MS_BIG5 :: */ - /* Same as FT_ENCODING_BIG5. Deprecated. */ - /* */ - /* FT_ENCODING_MS_WANSUNG :: */ - /* Same as FT_ENCODING_WANSUNG. Deprecated. */ - /* */ - /* FT_ENCODING_MS_JOHAB :: */ - /* Same as FT_ENCODING_JOHAB. Deprecated. */ - /* */ - /* <Note> */ - /* By default, FreeType enables a Unicode charmap and tags it with */ - /* FT_ENCODING_UNICODE when it is either provided or can be generated */ - /* from PostScript glyph name dictionaries in the font file. */ - /* All other encodings are considered legacy and tagged only if */ - /* explicitly defined in the font file. Otherwise, FT_ENCODING_NONE */ - /* is used. */ - /* */ - /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ - /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ - /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ - /* which encoding is really present. If, for example, the */ - /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ - /* the font is encoded in KOI8-R. */ - /* */ - /* FT_ENCODING_NONE is always set (with a single exception) by the */ - /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ - /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ - /* which encoding is really present. For example, */ - /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ - /* Russian). */ - /* */ - /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ - /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */ - /* FT_ENCODING_APPLE_ROMAN). */ - /* */ - /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ - /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ - /* be needed to be able to distinguish Apple encoding variants. See */ - /* */ - /* https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ - /* */ - /* to get an idea how to do that. Basically, if the language ID */ - /* is~0, don't use it, otherwise subtract 1 from the language ID. */ - /* Then examine `encoding_id'. If, for example, `encoding_id' is */ - /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */ - /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ - /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */ - /* variant the Arabic encoding. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Encoding + * + * @description: + * An enumeration to specify character sets supported by charmaps. Used + * in the @FT_Select_Charmap API function. + * + * @note: + * Despite the name, this enumeration lists specific character + * repertories (i.e., charsets), and not text encoding methods (e.g., + * UTF-8, UTF-16, etc.). + * + * Other encodings might be defined in the future. + * + * @values: + * FT_ENCODING_NONE :: + * The encoding value~0 is reserved for all formats except BDF, PCF, + * and Windows FNT; see below for more information. + * + * FT_ENCODING_UNICODE :: + * The Unicode character set. This value covers all versions of the + * Unicode repertoire, including ASCII and Latin-1. Most fonts include + * a Unicode charmap, but not all of them. + * + * For example, if you want to access Unicode value U+1F028 (and the + * font contains it), use value 0x1F028 as the input value for + * @FT_Get_Char_Index. + * + * FT_ENCODING_MS_SYMBOL :: + * Microsoft Symbol encoding, used to encode mathematical symbols and + * wingdings. For more information, see + * 'https://www.microsoft.com/typography/otspec/recom.htm', + * 'http://www.kostis.net/charsets/symbol.htm', and + * 'http://www.kostis.net/charsets/wingding.htm'. + * + * This encoding uses character codes from the PUA (Private Unicode + * Area) in the range U+F020-U+F0FF. + * + * FT_ENCODING_SJIS :: + * Shift JIS encoding for Japanese. More info at + * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte + * encodings below. + * + * FT_ENCODING_PRC :: + * Corresponds to encoding systems mainly for Simplified Chinese as + * used in People's Republic of China (PRC). The encoding layout is + * based on GB~2312 and its supersets GBK and GB~18030. + * + * FT_ENCODING_BIG5 :: + * Corresponds to an encoding system for Traditional Chinese as used in + * Taiwan and Hong Kong. + * + * FT_ENCODING_WANSUNG :: + * Corresponds to the Korean encoding system known as Extended Wansung + * (MS Windows code page 949). For more information see + * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. + * + * FT_ENCODING_JOHAB :: + * The Korean standard character set (KS~C 5601-1992), which + * corresponds to MS Windows code page 1361. This character set + * includes all possible Hangul character combinations. + * + * FT_ENCODING_ADOBE_LATIN_1 :: + * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript + * font. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_STANDARD :: + * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF + * fonts. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_EXPERT :: + * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF + * fonts. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_CUSTOM :: + * Corresponds to a custom encoding, as found in Type~1, CFF, and + * OpenType/CFF fonts. It is limited to 256 character codes. + * + * FT_ENCODING_APPLE_ROMAN :: + * Apple roman encoding. Many TrueType and OpenType fonts contain a + * charmap for this 8-bit encoding, since older versions of Mac OS are + * able to use it. + * + * FT_ENCODING_OLD_LATIN_2 :: + * This value is deprecated and was neither used nor reported by + * FreeType. Don't use or test for it. + * + * FT_ENCODING_MS_SJIS :: + * Same as FT_ENCODING_SJIS. Deprecated. + * + * FT_ENCODING_MS_GB2312 :: + * Same as FT_ENCODING_PRC. Deprecated. + * + * FT_ENCODING_MS_BIG5 :: + * Same as FT_ENCODING_BIG5. Deprecated. + * + * FT_ENCODING_MS_WANSUNG :: + * Same as FT_ENCODING_WANSUNG. Deprecated. + * + * FT_ENCODING_MS_JOHAB :: + * Same as FT_ENCODING_JOHAB. Deprecated. + * + * @note: + * By default, FreeType enables a Unicode charmap and tags it with + * `FT_ENCODING_UNICODE` when it is either provided or can be generated + * from PostScript glyph name dictionaries in the font file. All other + * encodings are considered legacy and tagged only if explicitly defined + * in the font file. Otherwise, `FT_ENCODING_NONE` is used. + * + * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is + * neither Unicode nor ISO-8859-1 (otherwise it is set to + * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which + * encoding is really present. If, for example, the `cs_registry` field + * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in + * KOI8-R. + * + * `FT_ENCODING_NONE` is always set (with a single exception) by the + * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset` + * field of the @FT_WinFNT_HeaderRec structure to find out which encoding + * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means + * Windows code page 1251 (for Russian). + * + * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH + * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to + * `FT_ENCODING_APPLE_ROMAN`). + * + * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function + * @FT_Get_CMap_Language_ID to query the Mac language ID that may be + * needed to be able to distinguish Apple encoding variants. See + * + * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt + * + * to get an idea how to do that. Basically, if the language ID is~0, + * don't use it, otherwise subtract 1 from the language ID. Then examine + * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN` + * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the + * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with + * `TT_MAC_LANGID_FARSI` means the Farsi variant the Arabic encoding. + */ typedef enum FT_Encoding_ { FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), @@ -796,7 +786,7 @@ FT_BEGIN_HEADER } FT_Encoding; - /* these constants are deprecated; use the corresponding `FT_Encoding' */ + /* these constants are deprecated; use the corresponding `FT_Encoding` */ /* values instead */ #define ft_encoding_none FT_ENCODING_NONE #define ft_encoding_unicode FT_ENCODING_UNICODE @@ -815,29 +805,31 @@ FT_BEGIN_HEADER #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_CharMapRec */ - /* */ - /* <Description> */ - /* The base charmap structure. */ - /* */ - /* <Fields> */ - /* face :: A handle to the parent face object. */ - /* */ - /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ - /* this with @FT_Select_Charmap. */ - /* */ - /* platform_id :: An ID number describing the platform for the */ - /* following encoding ID. This comes directly from */ - /* the TrueType specification and gets emulated for */ - /* other formats. */ - /* */ - /* encoding_id :: A platform specific encoding number. This also */ - /* comes from the TrueType specification and gets */ - /* emulated similarly. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_CharMapRec + * + * @description: + * The base charmap structure. + * + * @fields: + * face :: + * A handle to the parent face object. + * + * encoding :: + * An @FT_Encoding tag identifying the charmap. Use this with + * @FT_Select_Charmap. + * + * platform_id :: + * An ID number describing the platform for the following encoding ID. + * This comes directly from the TrueType specification and gets + * emulated for other formats. + * + * encoding_id :: + * A platform-specific encoding number. This also comes from the + * TrueType specification and gets emulated similarly. + */ typedef struct FT_CharMapRec_ { FT_Face face; @@ -857,215 +849,195 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Face_InternalRec' structure that models */ - /* the private data of a given @FT_Face object. */ - /* */ - /* This structure might change between releases of FreeType~2 and is */ - /* not generally available to client applications. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Face_Internal + * + * @description: + * An opaque handle to an `FT_Face_InternalRec` structure that models the + * private data of a given @FT_Face object. + * + * This structure might change between releases of FreeType~2 and is not + * generally available to client applications. + */ typedef struct FT_Face_InternalRec_* FT_Face_Internal; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_FaceRec */ - /* */ - /* <Description> */ - /* FreeType root face class structure. A face object models a */ - /* typeface in a font file. */ - /* */ - /* <Fields> */ - /* num_faces :: The number of faces in the font file. Some */ - /* font formats can have multiple faces in */ - /* a single font file. */ - /* */ - /* face_index :: This field holds two different values. */ - /* Bits 0-15 are the index of the face in the */ - /* font file (starting with value~0). They */ - /* are set to~0 if there is only one face in */ - /* the font file. */ - /* */ - /* [Since 2.6.1] Bits 16-30 are relevant to GX */ - /* and OpenType variation fonts only, holding */ - /* the named instance index for the current */ - /* face index (starting with value~1; value~0 */ - /* indicates font access without a named */ - /* instance). For non-variation fonts, bits */ - /* 16-30 are ignored. If we have the third */ - /* named instance of face~4, say, `face_index' */ - /* is set to 0x00030004. */ - /* */ - /* Bit 31 is always zero (this is, */ - /* `face_index' is always a positive value). */ - /* */ - /* [Since 2.9] Changing the design coordinates */ - /* with @FT_Set_Var_Design_Coordinates or */ - /* @FT_Set_Var_Blend_Coordinates does not */ - /* influence the named instance index value */ - /* (only @FT_Set_Named_Instance does that). */ - /* */ - /* face_flags :: A set of bit flags that give important */ - /* information about the face; see */ - /* @FT_FACE_FLAG_XXX for the details. */ - /* */ - /* style_flags :: The lower 16~bits contain a set of bit */ - /* flags indicating the style of the face; see */ - /* @FT_STYLE_FLAG_XXX for the details. */ - /* */ - /* [Since 2.6.1] Bits 16-30 hold the number */ - /* of named instances available for the */ - /* current face if we have a GX or OpenType */ - /* variation (sub)font. Bit 31 is always zero */ - /* (this is, `style_flags' is always a */ - /* positive value). Note that a variation */ - /* font has always at least one named */ - /* instance, namely the default instance. */ - /* */ - /* num_glyphs :: The number of glyphs in the face. If the */ - /* face is scalable and has sbits (see */ - /* `num_fixed_sizes'), it is set to the number */ - /* of outline glyphs. */ - /* */ - /* For CID-keyed fonts (not in an SFNT */ - /* wrapper) this value gives the highest CID */ - /* used in the font. */ - /* */ - /* family_name :: The face's family name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's family (like `Times New */ - /* Roman', `Bodoni', `Garamond', etc). This */ - /* is a least common denominator used to list */ - /* fonts. Some formats (TrueType & OpenType) */ - /* provide localized and Unicode versions of */ - /* this string. Applications should use the */ - /* format specific interface to access them. */ - /* Can be NULL (e.g., in fonts embedded in a */ - /* PDF file). */ - /* */ - /* In case the font doesn't provide a specific */ - /* family name entry, FreeType tries to */ - /* synthesize one, deriving it from other name */ - /* entries. */ - /* */ - /* style_name :: The face's style name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's style (like `Italic', */ - /* `Bold', `Condensed', etc). Not all font */ - /* formats provide a style name, so this field */ - /* is optional, and can be set to NULL. As */ - /* for `family_name', some formats provide */ - /* localized and Unicode versions of this */ - /* string. Applications should use the format */ - /* specific interface to access them. */ - /* */ - /* num_fixed_sizes :: The number of bitmap strikes in the face. */ - /* Even if the face is scalable, there might */ - /* still be bitmap strikes, which are called */ - /* `sbits' in that case. */ - /* */ - /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ - /* strikes in the face. It is set to NULL if */ - /* there is no bitmap strike. */ - /* */ - /* Note that FreeType tries to sanitize the */ - /* strike data since they are sometimes sloppy */ - /* or incorrect, but this can easily fail. */ - /* */ - /* num_charmaps :: The number of charmaps in the face. */ - /* */ - /* charmaps :: An array of the charmaps of the face. */ - /* */ - /* generic :: A field reserved for client uses. See the */ - /* @FT_Generic type description. */ - /* */ - /* bbox :: The font bounding box. Coordinates are */ - /* expressed in font units (see */ - /* `units_per_EM'). The box is large enough */ - /* to contain any glyph from the font. Thus, */ - /* `bbox.yMax' can be seen as the `maximum */ - /* ascender', and `bbox.yMin' as the `minimum */ - /* descender'. Only relevant for scalable */ - /* formats. */ - /* */ - /* Note that the bounding box might be off by */ - /* (at least) one pixel for hinted fonts. See */ - /* @FT_Size_Metrics for further discussion. */ - /* */ - /* units_per_EM :: The number of font units per EM square for */ - /* this face. This is typically 2048 for */ - /* TrueType fonts, and 1000 for Type~1 fonts. */ - /* Only relevant for scalable formats. */ - /* */ - /* ascender :: The typographic ascender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMax'. Only relevant for scalable */ - /* formats. */ - /* */ - /* descender :: The typographic descender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMin'. Note that this field is */ - /* negative for values below the baseline. */ - /* Only relevant for scalable formats. */ - /* */ - /* height :: This value is the vertical distance */ - /* between two consecutive baselines, */ - /* expressed in font units. It is always */ - /* positive. Only relevant for scalable */ - /* formats. */ - /* */ - /* If you want the global glyph height, use */ - /* `ascender - descender'. */ - /* */ - /* max_advance_width :: The maximum advance width, in font units, */ - /* for all glyphs in this face. This can be */ - /* used to make word wrapping computations */ - /* faster. Only relevant for scalable */ - /* formats. */ - /* */ - /* max_advance_height :: The maximum advance height, in font units, */ - /* for all glyphs in this face. This is only */ - /* relevant for vertical layouts, and is set */ - /* to `height' for fonts that do not provide */ - /* vertical metrics. Only relevant for */ - /* scalable formats. */ - /* */ - /* underline_position :: The position, in font units, of the */ - /* underline line for this face. It is the */ - /* center of the underlining stem. Only */ - /* relevant for scalable formats. */ - /* */ - /* underline_thickness :: The thickness, in font units, of the */ - /* underline for this face. Only relevant for */ - /* scalable formats. */ - /* */ - /* glyph :: The face's associated glyph slot(s). */ - /* */ - /* size :: The current active size for this face. */ - /* */ - /* charmap :: The current active charmap for this face. */ - /* */ - /* <Note> */ - /* Fields may be changed after a call to @FT_Attach_File or */ - /* @FT_Attach_Stream. */ - /* */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `ascender', */ - /* `descender', `height', `underline_position', and */ - /* `underline_thickness'. */ - /* */ - /* Especially for TrueType fonts see also the documentation for */ - /* @FT_Size_Metrics. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_FaceRec + * + * @description: + * FreeType root face class structure. A face object models a typeface + * in a font file. + * + * @fields: + * num_faces :: + * The number of faces in the font file. Some font formats can have + * multiple faces in a single font file. + * + * face_index :: + * This field holds two different values. Bits 0-15 are the index of + * the face in the font file (starting with value~0). They are set + * to~0 if there is only one face in the font file. + * + * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation + * fonts only, holding the named instance index for the current face + * index (starting with value~1; value~0 indicates font access without + * a named instance). For non-variation fonts, bits 16-30 are ignored. + * If we have the third named instance of face~4, say, `face_index` is + * set to 0x00030004. + * + * Bit 31 is always zero (this is, `face_index` is always a positive + * value). + * + * [Since 2.9] Changing the design coordinates with + * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does + * not influence the named instance index value (only + * @FT_Set_Named_Instance does that). + * + * face_flags :: + * A set of bit flags that give important information about the face; + * see @FT_FACE_FLAG_XXX for the details. + * + * style_flags :: + * The lower 16~bits contain a set of bit flags indicating the style of + * the face; see @FT_STYLE_FLAG_XXX for the details. + * + * [Since 2.6.1] Bits 16-30 hold the number of named instances + * available for the current face if we have a GX or OpenType variation + * (sub)font. Bit 31 is always zero (this is, `style_flags` is always + * a positive value). Note that a variation font has always at least + * one named instance, namely the default instance. + * + * num_glyphs :: + * The number of glyphs in the face. If the face is scalable and has + * sbits (see `num_fixed_sizes`), it is set to the number of outline + * glyphs. + * + * For CID-keyed fonts (not in an SFNT wrapper) this value gives the + * highest CID used in the font. + * + * family_name :: + * The face's family name. This is an ASCII string, usually in + * English, that describes the typeface's family (like 'Times New + * Roman', 'Bodoni', 'Garamond', etc). This is a least common + * denominator used to list fonts. Some formats (TrueType & OpenType) + * provide localized and Unicode versions of this string. Applications + * should use the format-specific interface to access them. Can be + * `NULL` (e.g., in fonts embedded in a PDF file). + * + * In case the font doesn't provide a specific family name entry, + * FreeType tries to synthesize one, deriving it from other name + * entries. + * + * style_name :: + * The face's style name. This is an ASCII string, usually in English, + * that describes the typeface's style (like 'Italic', 'Bold', + * 'Condensed', etc). Not all font formats provide a style name, so + * this field is optional, and can be set to `NULL`. As for + * `family_name`, some formats provide localized and Unicode versions + * of this string. Applications should use the format-specific + * interface to access them. + * + * num_fixed_sizes :: + * The number of bitmap strikes in the face. Even if the face is + * scalable, there might still be bitmap strikes, which are called + * 'sbits' in that case. + * + * available_sizes :: + * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It + * is set to `NULL` if there is no bitmap strike. + * + * Note that FreeType tries to sanitize the strike data since they are + * sometimes sloppy or incorrect, but this can easily fail. + * + * num_charmaps :: + * The number of charmaps in the face. + * + * charmaps :: + * An array of the charmaps of the face. + * + * generic :: + * A field reserved for client uses. See the @FT_Generic type + * description. + * + * bbox :: + * The font bounding box. Coordinates are expressed in font units (see + * `units_per_EM`). The box is large enough to contain any glyph from + * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender', + * and `bbox.yMin` as the 'minimum descender'. Only relevant for + * scalable formats. + * + * Note that the bounding box might be off by (at least) one pixel for + * hinted fonts. See @FT_Size_Metrics for further discussion. + * + * units_per_EM :: + * The number of font units per EM square for this face. This is + * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only + * relevant for scalable formats. + * + * ascender :: + * The typographic ascender of the face, expressed in font units. For + * font formats not having this information, it is set to `bbox.yMax`. + * Only relevant for scalable formats. + * + * descender :: + * The typographic descender of the face, expressed in font units. For + * font formats not having this information, it is set to `bbox.yMin`. + * Note that this field is negative for values below the baseline. + * Only relevant for scalable formats. + * + * height :: + * This value is the vertical distance between two consecutive + * baselines, expressed in font units. It is always positive. Only + * relevant for scalable formats. + * + * If you want the global glyph height, use `ascender - descender`. + * + * max_advance_width :: + * The maximum advance width, in font units, for all glyphs in this + * face. This can be used to make word wrapping computations faster. + * Only relevant for scalable formats. + * + * max_advance_height :: + * The maximum advance height, in font units, for all glyphs in this + * face. This is only relevant for vertical layouts, and is set to + * `height` for fonts that do not provide vertical metrics. Only + * relevant for scalable formats. + * + * underline_position :: + * The position, in font units, of the underline line for this face. + * It is the center of the underlining stem. Only relevant for + * scalable formats. + * + * underline_thickness :: + * The thickness, in font units, of the underline for this face. Only + * relevant for scalable formats. + * + * glyph :: + * The face's associated glyph slot(s). + * + * size :: + * The current active size for this face. + * + * charmap :: + * The current active charmap for this face. + * + * @note: + * Fields may be changed after a call to @FT_Attach_File or + * @FT_Attach_Stream. + * + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `ascender`, `descender`, `height`, + * `underline_position`, and `underline_thickness`. + * + * Especially for TrueType fonts see also the documentation for + * @FT_Size_Metrics. + */ typedef struct FT_FaceRec_ { FT_Long num_faces; @@ -1087,7 +1059,7 @@ FT_BEGIN_HEADER FT_Generic generic; - /*# The following member variables (down to `underline_thickness') */ + /*# The following member variables (down to `underline_thickness`) */ /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ /*# for bitmap fonts. */ FT_BBox bbox; @@ -1125,117 +1097,116 @@ FT_BEGIN_HEADER } FT_FaceRec; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FACE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `face_flags' field of the */ - /* @FT_FaceRec structure. They inform client applications of */ - /* properties of the corresponding face. */ - /* */ - /* <Values> */ - /* FT_FACE_FLAG_SCALABLE :: */ - /* The face contains outline glyphs. Note that a face can contain */ - /* bitmap strikes also, i.e., a face can have both this flag and */ - /* @FT_FACE_FLAG_FIXED_SIZES set. */ - /* */ - /* FT_FACE_FLAG_FIXED_SIZES :: */ - /* The face contains bitmap strikes. See also the */ - /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ - /* */ - /* FT_FACE_FLAG_FIXED_WIDTH :: */ - /* The face contains fixed-width characters (like Courier, Lucida, */ - /* MonoType, etc.). */ - /* */ - /* FT_FACE_FLAG_SFNT :: */ - /* The face uses the SFNT storage scheme. For now, this means */ - /* TrueType and OpenType. */ - /* */ - /* FT_FACE_FLAG_HORIZONTAL :: */ - /* The face contains horizontal glyph metrics. This should be set */ - /* for all common formats. */ - /* */ - /* FT_FACE_FLAG_VERTICAL :: */ - /* The face contains vertical glyph metrics. This is only */ - /* available in some formats, not all of them. */ - /* */ - /* FT_FACE_FLAG_KERNING :: */ - /* The face contains kerning information. If set, the kerning */ - /* distance can be retrieved using the function @FT_Get_Kerning. */ - /* Otherwise the function always return the vector (0,0). Note */ - /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */ - /* table (as present in many OpenType fonts). */ - /* */ - /* FT_FACE_FLAG_FAST_GLYPHS :: */ - /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ - /* */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ - /* The face contains multiple masters and is capable of */ - /* interpolating between them. Supported formats are Adobe MM, */ - /* TrueType GX, and OpenType variation fonts. */ - /* */ - /* See section @multiple_masters for API details. */ - /* */ - /* FT_FACE_FLAG_GLYPH_NAMES :: */ - /* The face contains glyph names, which can be retrieved using */ - /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */ - /* broken glyph name tables. Use the function */ - /* @FT_Has_PS_Glyph_Names when needed. */ - /* */ - /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ - /* Used internally by FreeType to indicate that a face's stream was */ - /* provided by the client application and should not be destroyed */ - /* when @FT_Done_Face is called. Don't read or test this flag. */ - /* */ - /* FT_FACE_FLAG_HINTER :: */ - /* The font driver has a hinting machine of its own. For example, */ - /* with TrueType fonts, it makes sense to use data from the SFNT */ - /* `gasp' table only if the native TrueType hinting engine (with */ - /* the bytecode interpreter) is available and active. */ - /* */ - /* FT_FACE_FLAG_CID_KEYED :: */ - /* The face is CID-keyed. In that case, the face is not accessed */ - /* by glyph indices but by CID values. For subsetted CID-keyed */ - /* fonts this has the consequence that not all index values are a */ - /* valid argument to @FT_Load_Glyph. Only the CID values for which */ - /* corresponding glyphs in the subsetted font exist make */ - /* `FT_Load_Glyph' return successfully; in all other cases you get */ - /* an `FT_Err_Invalid_Argument' error. */ - /* */ - /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */ - /* all OpenType/CFF fonts) don't have this flag set since the */ - /* glyphs are accessed in the normal way (using contiguous */ - /* indices); the `CID-ness' isn't visible to the application. */ - /* */ - /* FT_FACE_FLAG_TRICKY :: */ - /* The face is `tricky', this is, it always needs the font format's */ - /* native hinting engine to get a reasonable result. A typical */ - /* example is the old Chinese font `mingli.ttf' (but not */ - /* `mingliu.ttc') that uses TrueType bytecode instructions to move */ - /* and scale all of its subglyphs. */ - /* */ - /* It is not possible to auto-hint such fonts using */ - /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ - /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ - /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ - /* probably never want this except for demonstration purposes. */ - /* */ - /* Currently, there are about a dozen TrueType fonts in the list of */ - /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ - /* */ - /* FT_FACE_FLAG_COLOR :: */ - /* [Since 2.5.1] The face has color glyph tables. To access color */ - /* glyphs use @FT_LOAD_COLOR. */ - /* */ - /* FT_FACE_FLAG_VARIATION :: */ - /* [Since 2.9] Set if the current face (or named instance) has been */ - /* altered with @FT_Set_MM_Design_Coordinates, */ - /* @FT_Set_Var_Design_Coordinates, or */ - /* @FT_Set_Var_Blend_Coordinates. This flag is unset by a call to */ - /* @FT_Set_Named_Instance. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_FACE_FLAG_XXX + * + * @description: + * A list of bit flags used in the `face_flags` field of the @FT_FaceRec + * structure. They inform client applications of properties of the + * corresponding face. + * + * @values: + * FT_FACE_FLAG_SCALABLE :: + * The face contains outline glyphs. Note that a face can contain + * bitmap strikes also, i.e., a face can have both this flag and + * @FT_FACE_FLAG_FIXED_SIZES set. + * + * FT_FACE_FLAG_FIXED_SIZES :: + * The face contains bitmap strikes. See also the `num_fixed_sizes` + * and `available_sizes` fields of @FT_FaceRec. + * + * FT_FACE_FLAG_FIXED_WIDTH :: + * The face contains fixed-width characters (like Courier, Lucida, + * MonoType, etc.). + * + * FT_FACE_FLAG_SFNT :: + * The face uses the SFNT storage scheme. For now, this means TrueType + * and OpenType. + * + * FT_FACE_FLAG_HORIZONTAL :: + * The face contains horizontal glyph metrics. This should be set for + * all common formats. + * + * FT_FACE_FLAG_VERTICAL :: + * The face contains vertical glyph metrics. This is only available in + * some formats, not all of them. + * + * FT_FACE_FLAG_KERNING :: + * The face contains kerning information. If set, the kerning distance + * can be retrieved using the function @FT_Get_Kerning. Otherwise the + * function always return the vector (0,0). Note that FreeType doesn't + * handle kerning data from the SFNT 'GPOS' table (as present in many + * OpenType fonts). + * + * FT_FACE_FLAG_FAST_GLYPHS :: + * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. + * + * FT_FACE_FLAG_MULTIPLE_MASTERS :: + * The face contains multiple masters and is capable of interpolating + * between them. Supported formats are Adobe MM, TrueType GX, and + * OpenType variation fonts. + * + * See section @multiple_masters for API details. + * + * FT_FACE_FLAG_GLYPH_NAMES :: + * The face contains glyph names, which can be retrieved using + * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken + * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when + * needed. + * + * FT_FACE_FLAG_EXTERNAL_STREAM :: + * Used internally by FreeType to indicate that a face's stream was + * provided by the client application and should not be destroyed when + * @FT_Done_Face is called. Don't read or test this flag. + * + * FT_FACE_FLAG_HINTER :: + * The font driver has a hinting machine of its own. For example, with + * TrueType fonts, it makes sense to use data from the SFNT 'gasp' + * table only if the native TrueType hinting engine (with the bytecode + * interpreter) is available and active. + * + * FT_FACE_FLAG_CID_KEYED :: + * The face is CID-keyed. In that case, the face is not accessed by + * glyph indices but by CID values. For subsetted CID-keyed fonts this + * has the consequence that not all index values are a valid argument + * to @FT_Load_Glyph. Only the CID values for which corresponding + * glyphs in the subsetted font exist make `FT_Load_Glyph` return + * successfully; in all other cases you get an + * `FT_Err_Invalid_Argument` error. + * + * Note that CID-keyed fonts that are in an SFNT wrapper (this is, all + * OpenType/CFF fonts) don't have this flag set since the glyphs are + * accessed in the normal way (using contiguous indices); the + * 'CID-ness' isn't visible to the application. + * + * FT_FACE_FLAG_TRICKY :: + * The face is 'tricky', this is, it always needs the font format's + * native hinting engine to get a reasonable result. A typical example + * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that + * uses TrueType bytecode instructions to move and scale all of its + * subglyphs. + * + * It is not possible to auto-hint such fonts using + * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING. + * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to + * really disable hinting; however, you probably never want this except + * for demonstration purposes. + * + * Currently, there are about a dozen TrueType fonts in the list of + * tricky fonts; they are hard-coded in file `ttobjs.c`. + * + * FT_FACE_FLAG_COLOR :: + * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR + * for more information. + * + * FT_FACE_FLAG_VARIATION :: + * [Since 2.9] Set if the current face (or named instance) has been + * altered with @FT_Set_MM_Design_Coordinates, + * @FT_Set_Var_Design_Coordinates, or @FT_Set_Var_Blend_Coordinates. + * This flag is unset by a call to @FT_Set_Named_Instance. + */ #define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) @@ -1254,14 +1225,14 @@ FT_BEGIN_HEADER #define FT_FACE_FLAG_VARIATION ( 1L << 15 ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_HORIZONTAL( face ) + * FT_HAS_HORIZONTAL * * @description: - * A macro that returns true whenever a face object contains - * horizontal metrics (this is true for all font formats though). + * A macro that returns true whenever a face object contains horizontal + * metrics (this is true for all font formats though). * * @also: * @FT_HAS_VERTICAL can be used to check for vertical metrics. @@ -1271,10 +1242,10 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_VERTICAL( face ) + * FT_HAS_VERTICAL * * @description: * A macro that returns true whenever a face object contains real @@ -1285,45 +1256,45 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_KERNING( face ) + * FT_HAS_KERNING * * @description: - * A macro that returns true whenever a face object contains kerning - * data that can be accessed with @FT_Get_Kerning. + * A macro that returns true whenever a face object contains kerning data + * that can be accessed with @FT_Get_Kerning. * */ #define FT_HAS_KERNING( face ) \ ( (face)->face_flags & FT_FACE_FLAG_KERNING ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_SCALABLE( face ) + * FT_IS_SCALABLE * * @description: * A macro that returns true whenever a face object contains a scalable - * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, - * and PFR font formats). + * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and + * PFR font formats). * */ #define FT_IS_SCALABLE( face ) \ ( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_SFNT( face ) + * FT_IS_SFNT * * @description: - * A macro that returns true whenever a face object contains a font - * whose format is based on the SFNT storage scheme. This usually - * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded - * bitmap fonts. + * A macro that returns true whenever a face object contains a font whose + * format is based on the SFNT storage scheme. This usually means: + * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap + * fonts. * * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and * @FT_TRUETYPE_TABLES_H are available. @@ -1333,14 +1304,14 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_SFNT ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_FIXED_WIDTH( face ) + * FT_IS_FIXED_WIDTH * * @description: * A macro that returns true whenever a face object contains a font face - * that contains fixed-width (or `monospace', `fixed-pitch', etc.) + * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.) * glyphs. * */ @@ -1348,25 +1319,25 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_FIXED_SIZES( face ) + * FT_HAS_FIXED_SIZES * * @description: * A macro that returns true whenever a face object contains some - * embedded bitmaps. See the `available_sizes' field of the - * @FT_FaceRec structure. + * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec + * structure. * */ #define FT_HAS_FIXED_SIZES( face ) \ ( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_FAST_GLYPHS( face ) + * FT_HAS_FAST_GLYPHS * * @description: * Deprecated. @@ -1375,10 +1346,10 @@ FT_BEGIN_HEADER #define FT_HAS_FAST_GLYPHS( face ) 0 - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_GLYPH_NAMES( face ) + * FT_HAS_GLYPH_NAMES * * @description: * A macro that returns true whenever a face object contains some glyph @@ -1389,10 +1360,10 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_MULTIPLE_MASTERS( face ) + * FT_HAS_MULTIPLE_MASTERS * * @description: * A macro that returns true whenever a face object contains some @@ -1404,10 +1375,10 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_NAMED_INSTANCE( face ) + * FT_IS_NAMED_INSTANCE * * @description: * A macro that returns true whenever a face object is a named instance @@ -1426,14 +1397,14 @@ FT_BEGIN_HEADER ( (face)->face_index & 0x7FFF0000L ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_VARIATION( face ) + * FT_IS_VARIATION * * @description: - * A macro that returns true whenever a face object has been altered - * by @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or + * A macro that returns true whenever a face object has been altered by + * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or * @FT_Set_Var_Blend_Coordinates. * * @since: @@ -1444,15 +1415,14 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_VARIATION ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_CID_KEYED( face ) + * FT_IS_CID_KEYED * * @description: * A macro that returns true whenever a face object contains a CID-keyed - * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more - * details. + * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details. * * If this macro is true, all functions defined in @FT_CID_H are * available. @@ -1462,13 +1432,13 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_TRICKY( face ) + * FT_IS_TRICKY * * @description: - * A macro that returns true whenever a face represents a `tricky' font. + * A macro that returns true whenever a face represents a 'tricky' font. * See the discussion of @FT_FACE_FLAG_TRICKY for more details. * */ @@ -1476,14 +1446,14 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_TRICKY ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_COLOR( face ) + * FT_HAS_COLOR * * @description: - * A macro that returns true whenever a face object contains - * tables for color glyphs. + * A macro that returns true whenever a face object contains tables for + * color glyphs. * * @since: * 2.5.1 @@ -1493,149 +1463,148 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_COLOR ) - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_STYLE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags to indicate the style of a given face. These */ - /* are used in the `style_flags' field of @FT_FaceRec. */ - /* */ - /* <Values> */ - /* FT_STYLE_FLAG_ITALIC :: */ - /* The face style is italic or oblique. */ - /* */ - /* FT_STYLE_FLAG_BOLD :: */ - /* The face is bold. */ - /* */ - /* <Note> */ - /* The style information as provided by FreeType is very basic. More */ - /* details are beyond the scope and should be done on a higher level */ - /* (for example, by analyzing various fields of the `OS/2' table in */ - /* SFNT based fonts). */ - /* */ + /************************************************************************** + * + * @enum: + * FT_STYLE_FLAG_XXX + * + * @description: + * A list of bit flags to indicate the style of a given face. These are + * used in the `style_flags` field of @FT_FaceRec. + * + * @values: + * FT_STYLE_FLAG_ITALIC :: + * The face style is italic or oblique. + * + * FT_STYLE_FLAG_BOLD :: + * The face is bold. + * + * @note: + * The style information as provided by FreeType is very basic. More + * details are beyond the scope and should be done on a higher level (for + * example, by analyzing various fields of the 'OS/2' table in SFNT based + * fonts). + */ #define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) #define FT_STYLE_FLAG_BOLD ( 1 << 1 ) - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ - /* model private data of a given @FT_Size object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Size_Internal + * + * @description: + * An opaque handle to an `FT_Size_InternalRec` structure, used to model + * private data of a given @FT_Size object. + */ typedef struct FT_Size_InternalRec_* FT_Size_Internal; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Metrics */ - /* */ - /* <Description> */ - /* The size metrics structure gives the metrics of a size object. */ - /* */ - /* <Fields> */ - /* x_ppem :: The width of the scaled EM square in pixels, hence */ - /* the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal width'. */ - /* */ - /* y_ppem :: The height of the scaled EM square in pixels, */ - /* hence the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal height'. */ - /* */ - /* x_scale :: A 16.16 fractional scaling value to convert */ - /* horizontal metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* y_scale :: A 16.16 fractional scaling value to convert */ - /* vertical metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* ascender :: The ascender in 26.6 fractional pixels, rounded up */ - /* to an integer value. See @FT_FaceRec for the */ - /* details. */ - /* */ - /* descender :: The descender in 26.6 fractional pixels, rounded */ - /* down to an integer value. See @FT_FaceRec for the */ - /* details. */ - /* */ - /* height :: The height in 26.6 fractional pixels, rounded to */ - /* an integer value. See @FT_FaceRec for the */ - /* details. */ - /* */ - /* max_advance :: The maximum advance width in 26.6 fractional */ - /* pixels, rounded to an integer value. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* <Note> */ - /* The scaling values, if relevant, are determined first during a */ - /* size changing operation. The remaining fields are then set by the */ - /* driver. For scalable formats, they are usually set to scaled */ - /* values of the corresponding fields in @FT_FaceRec. Some values */ - /* like ascender or descender are rounded for historical reasons; */ - /* more precise values (for outline fonts) can be derived by scaling */ - /* the corresponding @FT_FaceRec values manually, with code similar */ - /* to the following. */ - /* */ - /* { */ - /* scaled_ascender = FT_MulFix( face->ascender, */ - /* size_metrics->y_scale ); */ - /* } */ - /* */ - /* Note that due to glyph hinting and the selected rendering mode */ - /* these values are usually not exact; consequently, they must be */ - /* treated as unreliable with an error margin of at least one pixel! */ - /* */ - /* Indeed, the only way to get the exact metrics is to render _all_ */ - /* glyphs. As this would be a definite performance hit, it is up to */ - /* client applications to perform such computations. */ - /* */ - /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */ - /* */ - /* */ - /* *TrueType* *fonts* *with* *native* *bytecode* *hinting* */ - /* */ - /* All applications that handle TrueType fonts with native hinting */ - /* must be aware that TTFs expect different rounding of vertical font */ - /* dimensions. The application has to cater for this, especially if */ - /* it wants to rely on a TTF's vertical data (for example, to */ - /* properly align box characters vertically). */ - /* */ - /* Only the application knows _in_ _advance_ that it is going to use */ - /* native hinting for TTFs! FreeType, on the other hand, selects the */ - /* hinting mode not at the time of creating an @FT_Size object but */ - /* much later, namely while calling @FT_Load_Glyph. */ - /* */ - /* Here is some pseudo code that illustrates a possible solution. */ - /* */ - /* { */ - /* font_format = FT_Get_Font_Format( face ); */ - /* */ - /* if ( !strcmp( font_format, "TrueType" ) && */ - /* do_native_bytecode_hinting ) */ - /* { */ - /* ascender = ROUND( FT_MulFix( face->ascender, */ - /* size_metrics->y_scale ) ); */ - /* descender = ROUND( FT_MulFix( face->descender, */ - /* size_metrics->y_scale ) ); */ - /* } */ - /* else */ - /* { */ - /* ascender = size_metrics->ascender; */ - /* descender = size_metrics->descender; */ - /* } */ - /* */ - /* height = size_metrics->height; */ - /* max_advance = size_metrics->max_advance; */ - /* } */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Size_Metrics + * + * @description: + * The size metrics structure gives the metrics of a size object. + * + * @fields: + * x_ppem :: + * The width of the scaled EM square in pixels, hence the term 'ppem' + * (pixels per EM). It is also referred to as 'nominal width'. + * + * y_ppem :: + * The height of the scaled EM square in pixels, hence the term 'ppem' + * (pixels per EM). It is also referred to as 'nominal height'. + * + * x_scale :: + * A 16.16 fractional scaling value to convert horizontal metrics from + * font units to 26.6 fractional pixels. Only relevant for scalable + * font formats. + * + * y_scale :: + * A 16.16 fractional scaling value to convert vertical metrics from + * font units to 26.6 fractional pixels. Only relevant for scalable + * font formats. + * + * ascender :: + * The ascender in 26.6 fractional pixels, rounded up to an integer + * value. See @FT_FaceRec for the details. + * + * descender :: + * The descender in 26.6 fractional pixels, rounded down to an integer + * value. See @FT_FaceRec for the details. + * + * height :: + * The height in 26.6 fractional pixels, rounded to an integer value. + * See @FT_FaceRec for the details. + * + * max_advance :: + * The maximum advance width in 26.6 fractional pixels, rounded to an + * integer value. See @FT_FaceRec for the details. + * + * @note: + * The scaling values, if relevant, are determined first during a size + * changing operation. The remaining fields are then set by the driver. + * For scalable formats, they are usually set to scaled values of the + * corresponding fields in @FT_FaceRec. Some values like ascender or + * descender are rounded for historical reasons; more precise values (for + * outline fonts) can be derived by scaling the corresponding @FT_FaceRec + * values manually, with code similar to the following. + * + * ``` + * scaled_ascender = FT_MulFix( face->ascender, + * size_metrics->y_scale ); + * ``` + * + * Note that due to glyph hinting and the selected rendering mode these + * values are usually not exact; consequently, they must be treated as + * unreliable with an error margin of at least one pixel! + * + * Indeed, the only way to get the exact metrics is to render _all_ + * glyphs. As this would be a definite performance hit, it is up to + * client applications to perform such computations. + * + * The `FT_Size_Metrics` structure is valid for bitmap fonts also. + * + * + * **TrueType fonts with native bytecode hinting** + * + * All applications that handle TrueType fonts with native hinting must + * be aware that TTFs expect different rounding of vertical font + * dimensions. The application has to cater for this, especially if it + * wants to rely on a TTF's vertical data (for example, to properly align + * box characters vertically). + * + * Only the application knows _in advance_ that it is going to use native + * hinting for TTFs! FreeType, on the other hand, selects the hinting + * mode not at the time of creating an @FT_Size object but much later, + * namely while calling @FT_Load_Glyph. + * + * Here is some pseudo code that illustrates a possible solution. + * + * ``` + * font_format = FT_Get_Font_Format( face ); + * + * if ( !strcmp( font_format, "TrueType" ) && + * do_native_bytecode_hinting ) + * { + * ascender = ROUND( FT_MulFix( face->ascender, + * size_metrics->y_scale ) ); + * descender = ROUND( FT_MulFix( face->descender, + * size_metrics->y_scale ) ); + * } + * else + * { + * ascender = size_metrics->ascender; + * descender = size_metrics->descender; + * } + * + * height = size_metrics->height; + * max_advance = size_metrics->max_advance; + * ``` + */ typedef struct FT_Size_Metrics_ { FT_UShort x_ppem; /* horizontal pixels per EM */ @@ -1652,25 +1621,27 @@ FT_BEGIN_HEADER } FT_Size_Metrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SizeRec */ - /* */ - /* <Description> */ - /* FreeType root size class structure. A size object models a face */ - /* object at a given size. */ - /* */ - /* <Fields> */ - /* face :: Handle to the parent face object. */ - /* */ - /* generic :: A typeless pointer, unused by the FreeType library or */ - /* any of its drivers. It can be used by client */ - /* applications to link their own data to each size */ - /* object. */ - /* */ - /* metrics :: Metrics for this size object. This field is read-only. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_SizeRec + * + * @description: + * FreeType root size class structure. A size object models a face + * object at a given size. + * + * @fields: + * face :: + * Handle to the parent face object. + * + * generic :: + * A typeless pointer, unused by the FreeType library or any of its + * drivers. It can be used by client applications to link their own + * data to each size object. + * + * metrics :: + * Metrics for this size object. This field is read-only. + */ typedef struct FT_SizeRec_ { FT_Face face; /* parent face object */ @@ -1681,237 +1652,234 @@ FT_BEGIN_HEADER } FT_SizeRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SubGlyph */ - /* */ - /* <Description> */ - /* The subglyph structure is an internal object used to describe */ - /* subglyphs (for example, in the case of composites). */ - /* */ - /* <Note> */ - /* The subglyph implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - /* You can however retrieve subglyph information with */ - /* @FT_Get_SubGlyph_Info. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_SubGlyph + * + * @description: + * The subglyph structure is an internal object used to describe + * subglyphs (for example, in the case of composites). + * + * @note: + * The subglyph implementation is not part of the high-level API, hence + * the forward structure declaration. + * + * You can however retrieve subglyph information with + * @FT_Get_SubGlyph_Info. + */ typedef struct FT_SubGlyphRec_* FT_SubGlyph; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Slot_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ - /* model private data of a given @FT_GlyphSlot object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Slot_Internal + * + * @description: + * An opaque handle to an `FT_Slot_InternalRec` structure, used to model + * private data of a given @FT_GlyphSlot object. + */ typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphSlotRec */ - /* */ - /* <Description> */ - /* FreeType root glyph slot class structure. A glyph slot is a */ - /* container where individual glyphs can be loaded, be they in */ - /* outline or bitmap format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library instance */ - /* this slot belongs to. */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* next :: In some cases (like some font tools), several */ - /* glyph slots per face object can be a good */ - /* thing. As this is rare, the glyph slots are */ - /* listed through a direct, single-linked list */ - /* using its `next' field. */ - /* */ - /* generic :: A typeless pointer unused by the FreeType */ - /* library or any of its drivers. It can be */ - /* used by client applications to link their own */ - /* data to each glyph slot object. */ - /* */ - /* metrics :: The metrics of the last loaded glyph in the */ - /* slot. The returned values depend on the last */ - /* load flags (see the @FT_Load_Glyph API */ - /* function) and can be expressed either in 26.6 */ - /* fractional pixels or font units. */ - /* */ - /* Note that even when the glyph image is */ - /* transformed, the metrics are not. */ - /* */ - /* linearHoriAdvance :: The advance width of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* linearVertAdvance :: The advance height of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* advance :: This shorthand is, depending on */ - /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ - /* (hinted) advance width for the glyph, in 26.6 */ - /* fractional pixel format. As specified with */ - /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ - /* `horiAdvance' or the `vertAdvance' value of */ - /* `metrics' field. */ - /* */ - /* format :: This field indicates the format of the image */ - /* contained in the glyph slot. Typically */ - /* @FT_GLYPH_FORMAT_BITMAP, */ - /* @FT_GLYPH_FORMAT_OUTLINE, or */ - /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */ - /* are possible. */ - /* */ - /* bitmap :: This field is used as a bitmap descriptor. */ - /* Note that the address and content of the */ - /* bitmap buffer can change between calls of */ - /* @FT_Load_Glyph and a few other functions. */ - /* */ - /* bitmap_left :: The bitmap's left bearing expressed in */ - /* integer pixels. */ - /* */ - /* bitmap_top :: The bitmap's top bearing expressed in integer */ - /* pixels. This is the distance from the */ - /* baseline to the top-most glyph scanline, */ - /* upwards y~coordinates being *positive*. */ - /* */ - /* outline :: The outline descriptor for the current glyph */ - /* image if its format is */ - /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ - /* loaded, `outline' can be transformed, */ - /* distorted, emboldened, etc. However, it must */ - /* not be freed. */ - /* */ - /* num_subglyphs :: The number of subglyphs in a composite glyph. */ - /* This field is only valid for the composite */ - /* glyph format that should normally only be */ - /* loaded with the @FT_LOAD_NO_RECURSE flag. */ - /* */ - /* subglyphs :: An array of subglyph descriptors for */ - /* composite glyphs. There are `num_subglyphs' */ - /* elements in there. Currently internal to */ - /* FreeType. */ - /* */ - /* control_data :: Certain font drivers can also return the */ - /* control data for a given glyph image (e.g. */ - /* TrueType bytecode, Type~1 charstrings, etc.). */ - /* This field is a pointer to such data; it is */ - /* currently internal to FreeType. */ - /* */ - /* control_len :: This is the length in bytes of the control */ - /* data. Currently internal to FreeType. */ - /* */ - /* other :: Reserved. */ - /* */ - /* lsb_delta :: The difference between hinted and unhinted */ - /* left side bearing while auto-hinting is */ - /* active. Zero otherwise. */ - /* */ - /* rsb_delta :: The difference between hinted and unhinted */ - /* right side bearing while auto-hinting is */ - /* active. Zero otherwise. */ - /* */ - /* <Note> */ - /* If @FT_Load_Glyph is called with default flags (see */ - /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ - /* its native format (e.g., an outline glyph for TrueType and Type~1 */ - /* formats). [Since 2.9] The prospective bitmap metrics are */ - /* calculated according to @FT_LOAD_TARGET_XXX and other flags even */ - /* for the outline glyph, even if @FT_LOAD_RENDER is not set. */ - /* */ - /* This image can later be converted into a bitmap by calling */ - /* @FT_Render_Glyph. This function searches the current renderer for */ - /* the native image's format, then invokes it. */ - /* */ - /* The renderer is in charge of transforming the native image through */ - /* the slot's face transformation fields, then converting it into a */ - /* bitmap that is returned in `slot->bitmap'. */ - /* */ - /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ - /* to specify the position of the bitmap relative to the current pen */ - /* position (e.g., coordinates (0,0) on the baseline). Of course, */ - /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ - /* */ - /* Here is a small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta' to do fractional positioning of */ - /* glyphs: */ - /* */ - /* { */ - /* FT_GlyphSlot slot = face->glyph; */ - /* FT_Pos origin_x = 0; */ - /* */ - /* */ - /* for all glyphs do */ - /* <load glyph with `FT_Load_Glyph'> */ - /* */ - /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */ - /* */ - /* <save glyph image, or render glyph, or ...> */ - /* */ - /* <compute kern between current and next glyph */ - /* and add it to `origin_x'> */ - /* */ - /* origin_x += slot->advance.x; */ - /* origin_x += slot->rsb_delta - slot->lsb_delta; */ - /* endfor */ - /* } */ - /* */ - /* Here is another small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta' to improve integer positioning of */ - /* glyphs: */ - /* */ - /* { */ - /* FT_GlyphSlot slot = face->glyph; */ - /* FT_Pos origin_x = 0; */ - /* FT_Pos prev_rsb_delta = 0; */ - /* */ - /* */ - /* for all glyphs do */ - /* <compute kern between current and previous glyph */ - /* and add it to `origin_x'> */ - /* */ - /* <load glyph with `FT_Load_Glyph'> */ - /* */ - /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */ - /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */ - /* origin_x += 64; */ - /* */ - /* prev_rsb_delta = slot->rsb_delta; */ - /* */ - /* <save glyph image, or render glyph, or ...> */ - /* */ - /* origin_x += slot->advance.x; */ - /* endfor */ - /* } */ - /* */ - /* If you use strong auto-hinting, you *must* apply these delta */ - /* values! Otherwise you will experience far too large inter-glyph */ - /* spacing at small rendering sizes in most cases. Note that it */ - /* doesn't harm to use the above code for other hinting modes also, */ - /* since the delta values are zero then. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_GlyphSlotRec + * + * @description: + * FreeType root glyph slot class structure. A glyph slot is a container + * where individual glyphs can be loaded, be they in outline or bitmap + * format. + * + * @fields: + * library :: + * A handle to the FreeType library instance this slot belongs to. + * + * face :: + * A handle to the parent face object. + * + * next :: + * In some cases (like some font tools), several glyph slots per face + * object can be a good thing. As this is rare, the glyph slots are + * listed through a direct, single-linked list using its `next` field. + * + * glyph_index :: + * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph + * while initializing the glyph slot. + * + * generic :: + * A typeless pointer unused by the FreeType library or any of its + * drivers. It can be used by client applications to link their own + * data to each glyph slot object. + * + * metrics :: + * The metrics of the last loaded glyph in the slot. The returned + * values depend on the last load flags (see the @FT_Load_Glyph API + * function) and can be expressed either in 26.6 fractional pixels or + * font units. + * + * Note that even when the glyph image is transformed, the metrics are + * not. + * + * linearHoriAdvance :: + * The advance width of the unhinted glyph. Its value is expressed in + * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when + * loading the glyph. This field can be important to perform correct + * WYSIWYG layout. Only relevant for outline glyphs. + * + * linearVertAdvance :: + * The advance height of the unhinted glyph. Its value is expressed in + * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when + * loading the glyph. This field can be important to perform correct + * WYSIWYG layout. Only relevant for outline glyphs. + * + * advance :: + * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the + * transformed (hinted) advance width for the glyph, in 26.6 fractional + * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses + * either the `horiAdvance` or the `vertAdvance` value of `metrics` + * field. + * + * format :: + * This field indicates the format of the image contained in the glyph + * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE, + * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible. + * + * bitmap :: + * This field is used as a bitmap descriptor. Note that the address + * and content of the bitmap buffer can change between calls of + * @FT_Load_Glyph and a few other functions. + * + * bitmap_left :: + * The bitmap's left bearing expressed in integer pixels. + * + * bitmap_top :: + * The bitmap's top bearing expressed in integer pixels. This is the + * distance from the baseline to the top-most glyph scanline, upwards + * y~coordinates being **positive**. + * + * outline :: + * The outline descriptor for the current glyph image if its format is + * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be + * transformed, distorted, emboldened, etc. However, it must not be + * freed. + * + * num_subglyphs :: + * The number of subglyphs in a composite glyph. This field is only + * valid for the composite glyph format that should normally only be + * loaded with the @FT_LOAD_NO_RECURSE flag. + * + * subglyphs :: + * An array of subglyph descriptors for composite glyphs. There are + * `num_subglyphs` elements in there. Currently internal to FreeType. + * + * control_data :: + * Certain font drivers can also return the control data for a given + * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.). + * This field is a pointer to such data; it is currently internal to + * FreeType. + * + * control_len :: + * This is the length in bytes of the control data. Currently internal + * to FreeType. + * + * other :: + * Reserved. + * + * lsb_delta :: + * The difference between hinted and unhinted left side bearing while + * auto-hinting is active. Zero otherwise. + * + * rsb_delta :: + * The difference between hinted and unhinted right side bearing while + * auto-hinting is active. Zero otherwise. + * + * @note: + * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT) + * the glyph image is loaded in the glyph slot in its native format + * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9] + * The prospective bitmap metrics are calculated according to + * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even + * if @FT_LOAD_RENDER is not set. + * + * This image can later be converted into a bitmap by calling + * @FT_Render_Glyph. This function searches the current renderer for the + * native image's format, then invokes it. + * + * The renderer is in charge of transforming the native image through the + * slot's face transformation fields, then converting it into a bitmap + * that is returned in `slot->bitmap`. + * + * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to + * specify the position of the bitmap relative to the current pen + * position (e.g., coordinates (0,0) on the baseline). Of course, + * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP. + * + * Here is a small pseudo code fragment that shows how to use `lsb_delta` + * and `rsb_delta` to do fractional positioning of glyphs: + * + * ``` + * FT_GlyphSlot slot = face->glyph; + * FT_Pos origin_x = 0; + * + * + * for all glyphs do + * <load glyph with `FT_Load_Glyph'> + * + * FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); + * + * <save glyph image, or render glyph, or ...> + * + * <compute kern between current and next glyph + * and add it to `origin_x'> + * + * origin_x += slot->advance.x; + * origin_x += slot->lsb_delta - slot->rsb_delta; + * endfor + * ``` + * + * Here is another small pseudo code fragment that shows how to use + * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs: + * + * ``` + * FT_GlyphSlot slot = face->glyph; + * FT_Pos origin_x = 0; + * FT_Pos prev_rsb_delta = 0; + * + * + * for all glyphs do + * <compute kern between current and previous glyph + * and add it to `origin_x'> + * + * <load glyph with `FT_Load_Glyph'> + * + * if ( prev_rsb_delta - slot->lsb_delta > 32 ) + * origin_x -= 64; + * else if ( prev_rsb_delta - slot->lsb_delta < -31 ) + * origin_x += 64; + * + * prev_rsb_delta = slot->rsb_delta; + * + * <save glyph image, or render glyph, or ...> + * + * origin_x += slot->advance.x; + * endfor + * ``` + * + * If you use strong auto-hinting, you **must** apply these delta values! + * Otherwise you will experience far too large inter-glyph spacing at + * small rendering sizes in most cases. Note that it doesn't harm to use + * the above code for other hinting modes also, since the delta values + * are zero then. + */ typedef struct FT_GlyphSlotRec_ { FT_Library library; FT_Face face; FT_GlyphSlot next; - FT_UInt reserved; /* retained for binary compatibility */ + FT_UInt glyph_index; /* new in 2.10; was reserved previously */ FT_Generic generic; FT_Glyph_Metrics metrics; @@ -1952,86 +1920,92 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Init_FreeType */ - /* */ - /* <Description> */ - /* Initialize a new FreeType library object. The set of modules */ - /* that are registered by this function is determined at build time. */ - /* */ - /* <Output> */ - /* alibrary :: A handle to a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case you want to provide your own memory allocating routines, */ - /* use @FT_New_Library instead, followed by a call to */ - /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */ - /* and @FT_Set_Default_Properties. */ - /* */ - /* See the documentation of @FT_Library and @FT_Face for */ - /* multi-threading issues. */ - /* */ - /* If you need reference-counting (cf. @FT_Reference_Library), use */ - /* @FT_New_Library and @FT_Done_Library. */ - /* */ - /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ - /* set, this function reads the `FREETYPE_PROPERTIES' environment */ - /* variable to control driver properties. See section @properties */ - /* for more. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Init_FreeType + * + * @description: + * Initialize a new FreeType library object. The set of modules that are + * registered by this function is determined at build time. + * + * @output: + * alibrary :: + * A handle to a new library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * In case you want to provide your own memory allocating routines, use + * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules + * (or a series of calls to @FT_Add_Module) and + * @FT_Set_Default_Properties. + * + * See the documentation of @FT_Library and @FT_Face for multi-threading + * issues. + * + * If you need reference-counting (cf. @FT_Reference_Library), use + * @FT_New_Library and @FT_Done_Library. + * + * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is + * set, this function reads the `FREETYPE_PROPERTIES` environment + * variable to control driver properties. See section @properties for + * more. + */ FT_EXPORT( FT_Error ) FT_Init_FreeType( FT_Library *alibrary ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_FreeType */ - /* */ - /* <Description> */ - /* Destroy a given FreeType library object and all of its children, */ - /* including resources, drivers, faces, sizes, etc. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_FreeType + * + * @description: + * Destroy a given FreeType library object and all of its children, + * including resources, drivers, faces, sizes, etc. + * + * @input: + * library :: + * A handle to the target library object. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Done_FreeType( FT_Library library ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OPEN_XXX */ - /* */ - /* <Description> */ - /* A list of bit field constants used within the `flags' field of the */ - /* @FT_Open_Args structure. */ - /* */ - /* <Values> */ - /* FT_OPEN_MEMORY :: This is a memory-based stream. */ - /* */ - /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ - /* */ - /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ - /* name. */ - /* */ - /* FT_OPEN_DRIVER :: Use the `driver' field. */ - /* */ - /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ - /* */ - /* <Note> */ - /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ - /* flags are mutually exclusive. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_OPEN_XXX + * + * @description: + * A list of bit field constants used within the `flags` field of the + * @FT_Open_Args structure. + * + * @values: + * FT_OPEN_MEMORY :: + * This is a memory-based stream. + * + * FT_OPEN_STREAM :: + * Copy the stream from the `stream` field. + * + * FT_OPEN_PATHNAME :: + * Create a new input stream from a C~path name. + * + * FT_OPEN_DRIVER :: + * Use the `driver` field. + * + * FT_OPEN_PARAMS :: + * Use the `num_params` and `params` fields. + * + * @note: + * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags + * are mutually exclusive. + */ #define FT_OPEN_MEMORY 0x1 #define FT_OPEN_STREAM 0x2 #define FT_OPEN_PATHNAME 0x4 @@ -2039,7 +2013,7 @@ FT_BEGIN_HEADER #define FT_OPEN_PARAMS 0x10 - /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */ + /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */ /* values instead */ #define ft_open_memory FT_OPEN_MEMORY #define ft_open_stream FT_OPEN_STREAM @@ -2048,91 +2022,97 @@ FT_BEGIN_HEADER #define ft_open_params FT_OPEN_PARAMS - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Parameter */ - /* */ - /* <Description> */ - /* A simple structure to pass more or less generic parameters to */ - /* @FT_Open_Face and @FT_Face_Properties. */ - /* */ - /* <Fields> */ - /* tag :: A four-byte identification tag. */ - /* */ - /* data :: A pointer to the parameter data. */ - /* */ - /* <Note> */ - /* The ID and function of parameters are driver-specific. See */ - /* section @parameter_tags for more information. */ - /* */ - typedef struct FT_Parameter_ - { - FT_ULong tag; + /************************************************************************** + * + * @struct: + * FT_Parameter + * + * @description: + * A simple structure to pass more or less generic parameters to + * @FT_Open_Face and @FT_Face_Properties. + * + * @fields: + * tag :: + * A four-byte identification tag. + * + * data :: + * A pointer to the parameter data. + * + * @note: + * The ID and function of parameters are driver-specific. See section + * @parameter_tags for more information. + */ + typedef struct FT_Parameter_ + { + FT_ULong tag; FT_Pointer data; } FT_Parameter; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Open_Args */ - /* */ - /* <Description> */ - /* A structure to indicate how to open a new font file or stream. A */ - /* pointer to such a structure can be used as a parameter for the */ - /* functions @FT_Open_Face and @FT_Attach_Stream. */ - /* */ - /* <Fields> */ - /* flags :: A set of bit flags indicating how to use the */ - /* structure. */ - /* */ - /* memory_base :: The first byte of the file in memory. */ - /* */ - /* memory_size :: The size in bytes of the file in memory. */ - /* */ - /* pathname :: A pointer to an 8-bit file pathname. */ - /* */ - /* stream :: A handle to a source stream object. */ - /* */ - /* driver :: This field is exclusively used by @FT_Open_Face; */ - /* it simply specifies the font driver to use for */ - /* opening the face. If set to NULL, FreeType tries */ - /* to load the face with each one of the drivers in */ - /* its list. */ - /* */ - /* num_params :: The number of extra parameters. */ - /* */ - /* params :: Extra parameters passed to the font driver when */ - /* opening a new face. */ - /* */ - /* <Note> */ - /* The stream type is determined by the contents of `flags' that */ - /* are tested in the following order by @FT_Open_Face: */ - /* */ - /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */ - /* memory file of `memory_size' bytes, located at `memory_address'. */ - /* The data are not copied, and the client is responsible for */ - /* releasing and destroying them _after_ the corresponding call to */ - /* @FT_Done_Face. */ - /* */ - /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */ - /* custom input stream `stream' is used. */ - /* */ - /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */ - /* is a normal file and use `pathname' to open it. */ - /* */ - /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */ - /* open the file with the driver whose handler is in `driver'. */ - /* */ - /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */ - /* `num_params' and `params' is used. They are ignored otherwise. */ - /* */ - /* Ideally, both the `pathname' and `params' fields should be tagged */ - /* as `const'; this is missing for API backward compatibility. In */ - /* other words, applications should treat them as read-only. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Open_Args + * + * @description: + * A structure to indicate how to open a new font file or stream. A + * pointer to such a structure can be used as a parameter for the + * functions @FT_Open_Face and @FT_Attach_Stream. + * + * @fields: + * flags :: + * A set of bit flags indicating how to use the structure. + * + * memory_base :: + * The first byte of the file in memory. + * + * memory_size :: + * The size in bytes of the file in memory. + * + * pathname :: + * A pointer to an 8-bit file pathname. + * + * stream :: + * A handle to a source stream object. + * + * driver :: + * This field is exclusively used by @FT_Open_Face; it simply specifies + * the font driver to use for opening the face. If set to `NULL`, + * FreeType tries to load the face with each one of the drivers in its + * list. + * + * num_params :: + * The number of extra parameters. + * + * params :: + * Extra parameters passed to the font driver when opening a new face. + * + * @note: + * The stream type is determined by the contents of `flags` that are + * tested in the following order by @FT_Open_Face: + * + * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file + * of `memory_size` bytes, located at `memory_address`. The data are not + * copied, and the client is responsible for releasing and destroying + * them _after_ the corresponding call to @FT_Done_Face. + * + * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom + * input stream `stream` is used. + * + * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a + * normal file and use `pathname` to open it. + * + * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open + * the file with the driver whose handler is in `driver`. + * + * If the @FT_OPEN_PARAMS bit is set, the parameters given by + * `num_params` and `params` is used. They are ignored otherwise. + * + * Ideally, both the `pathname` and `params` fields should be tagged as + * 'const'; this is missing for API backward compatibility. In other + * words, applications should treat them as read-only. + */ typedef struct FT_Open_Args_ { FT_UInt flags; @@ -2147,34 +2127,37 @@ FT_BEGIN_HEADER } FT_Open_Args; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face */ - /* */ - /* <Description> */ - /* Call @FT_Open_Face to open a font by its pathname. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* pathname :: A path to the font file. */ - /* */ - /* face_index :: See @FT_Open_Face for a detailed description of this */ - /* parameter. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ - /* with its slot and sizes). */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face + * + * @description: + * Call @FT_Open_Face to open a font by its pathname. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * pathname :: + * A path to the font file. + * + * face_index :: + * See @FT_Open_Face for a detailed description of this parameter. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Use @FT_Done_Face to destroy the created @FT_Face object (along with + * its slot and sizes). + */ FT_EXPORT( FT_Error ) FT_New_Face( FT_Library library, const char* filepathname, @@ -2182,36 +2165,39 @@ FT_BEGIN_HEADER FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory_Face */ - /* */ - /* <Description> */ - /* Call @FT_Open_Face to open a font that has been loaded into */ - /* memory. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* file_base :: A pointer to the beginning of the font data. */ - /* */ - /* file_size :: The size of the memory chunk used by the font data. */ - /* */ - /* face_index :: See @FT_Open_Face for a detailed description of this */ - /* parameter. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You must not deallocate the memory before calling @FT_Done_Face. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Memory_Face + * + * @description: + * Call @FT_Open_Face to open a font that has been loaded into memory. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * file_base :: + * A pointer to the beginning of the font data. + * + * file_size :: + * The size of the memory chunk used by the font data. + * + * face_index :: + * See @FT_Open_Face for a detailed description of this parameter. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You must not deallocate the memory before calling @FT_Done_Face. + */ FT_EXPORT( FT_Error ) FT_New_Memory_Face( FT_Library library, const FT_Byte* file_base, @@ -2220,147 +2206,143 @@ FT_BEGIN_HEADER FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Open_Face */ - /* */ - /* <Description> */ - /* Create a face object from a given resource described by */ - /* @FT_Open_Args. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* args :: A pointer to an `FT_Open_Args' structure that must */ - /* be filled by the caller. */ - /* */ - /* face_index :: This field holds two different values. Bits 0-15 */ - /* are the index of the face in the font file (starting */ - /* with value~0). Set it to~0 if there is only one */ - /* face in the font file. */ - /* */ - /* [Since 2.6.1] Bits 16-30 are relevant to GX and */ - /* OpenType variation fonts only, specifying the named */ - /* instance index for the current face index (starting */ - /* with value~1; value~0 makes FreeType ignore named */ - /* instances). For non-variation fonts, bits 16-30 are */ - /* ignored. Assuming that you want to access the third */ - /* named instance in face~4, `face_index' should be set */ - /* to 0x00030004. If you want to access face~4 without */ - /* variation handling, simply set `face_index' to */ - /* value~4. */ - /* */ - /* `FT_Open_Face' and its siblings can be used to */ - /* quickly check whether the font format of a given */ - /* font resource is supported by FreeType. In general, */ - /* if the `face_index' argument is negative, the */ - /* function's return value is~0 if the font format is */ - /* recognized, or non-zero otherwise. The function */ - /* allocates a more or less empty face handle in */ - /* `*aface' (if `aface' isn't NULL); the only two */ - /* useful fields in this special case are */ - /* `face->num_faces' and `face->style_flags'. For any */ - /* negative value of `face_index', `face->num_faces' */ - /* gives the number of faces within the font file. For */ - /* the negative value `-(N+1)' (with `N' a non-negative */ - /* 16-bit value), bits 16-30 in `face->style_flags' */ - /* give the number of named instances in face `N' if we */ - /* have a variation font (or zero otherwise). After */ - /* examination, the returned @FT_Face structure should */ - /* be deallocated with a call to @FT_Done_Face. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object that can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Each new face object created with this function also owns a */ - /* default @FT_Size object, accessible as `face->size'. */ - /* */ - /* One @FT_Library instance can have multiple face objects, this is, */ - /* @FT_Open_Face and its siblings can be called multiple times using */ - /* the same `library' argument. */ - /* */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ - /* To loop over all faces, use code similar to the following snippet */ - /* (omitting the error handling). */ - /* */ - /* { */ - /* ... */ - /* FT_Face face; */ - /* FT_Long i, num_faces; */ - /* */ - /* */ - /* error = FT_Open_Face( library, args, -1, &face ); */ - /* if ( error ) { ... } */ - /* */ - /* num_faces = face->num_faces; */ - /* FT_Done_Face( face ); */ - /* */ - /* for ( i = 0; i < num_faces; i++ ) */ - /* { */ - /* ... */ - /* error = FT_Open_Face( library, args, i, &face ); */ - /* ... */ - /* FT_Done_Face( face ); */ - /* ... */ - /* } */ - /* } */ - /* */ - /* To loop over all valid values for `face_index', use something */ - /* similar to the following snippet, again without error handling. */ - /* The code accesses all faces immediately (thus only a single call */ - /* of `FT_Open_Face' within the do-loop), with and without named */ - /* instances. */ - /* */ - /* { */ - /* ... */ - /* FT_Face face; */ - /* */ - /* FT_Long num_faces = 0; */ - /* FT_Long num_instances = 0; */ - /* */ - /* FT_Long face_idx = 0; */ - /* FT_Long instance_idx = 0; */ - /* */ - /* */ - /* do */ - /* { */ - /* FT_Long id = ( instance_idx << 16 ) + face_idx; */ - /* */ - /* */ - /* error = FT_Open_Face( library, args, id, &face ); */ - /* if ( error ) { ... } */ - /* */ - /* num_faces = face->num_faces; */ - /* num_instances = face->style_flags >> 16; */ - /* */ - /* ... */ - /* */ - /* FT_Done_Face( face ); */ - /* */ - /* if ( instance_idx < num_instances ) */ - /* instance_idx++; */ - /* else */ - /* { */ - /* face_idx++; */ - /* instance_idx = 0; */ - /* } */ - /* */ - /* } while ( face_idx < num_faces ) */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_Open_Face + * + * @description: + * Create a face object from a given resource described by @FT_Open_Args. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * args :: + * A pointer to an `FT_Open_Args` structure that must be filled by the + * caller. + * + * face_index :: + * This field holds two different values. Bits 0-15 are the index of + * the face in the font file (starting with value~0). Set it to~0 if + * there is only one face in the font file. + * + * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation + * fonts only, specifying the named instance index for the current face + * index (starting with value~1; value~0 makes FreeType ignore named + * instances). For non-variation fonts, bits 16-30 are ignored. + * Assuming that you want to access the third named instance in face~4, + * `face_index` should be set to 0x00030004. If you want to access + * face~4 without variation handling, simply set `face_index` to + * value~4. + * + * `FT_Open_Face` and its siblings can be used to quickly check whether + * the font format of a given font resource is supported by FreeType. + * In general, if the `face_index` argument is negative, the function's + * return value is~0 if the font format is recognized, or non-zero + * otherwise. The function allocates a more or less empty face handle + * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in + * this special case are `face->num_faces` and `face->style_flags`. + * For any negative value of `face_index`, `face->num_faces` gives the + * number of faces within the font file. For the negative value + * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in + * `face->style_flags` give the number of named instances in face 'N' + * if we have a variation font (or zero otherwise). After examination, + * the returned @FT_Face structure should be deallocated with a call to + * @FT_Done_Face. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Unlike FreeType 1.x, this function automatically creates a glyph slot + * for the face object that can be accessed directly through + * `face->glyph`. + * + * Each new face object created with this function also owns a default + * @FT_Size object, accessible as `face->size`. + * + * One @FT_Library instance can have multiple face objects, this is, + * @FT_Open_Face and its siblings can be called multiple times using the + * same `library` argument. + * + * See the discussion of reference counters in the description of + * @FT_Reference_Face. + * + * @example: + * To loop over all faces, use code similar to the following snippet + * (omitting the error handling). + * + * ``` + * ... + * FT_Face face; + * FT_Long i, num_faces; + * + * + * error = FT_Open_Face( library, args, -1, &face ); + * if ( error ) { ... } + * + * num_faces = face->num_faces; + * FT_Done_Face( face ); + * + * for ( i = 0; i < num_faces; i++ ) + * { + * ... + * error = FT_Open_Face( library, args, i, &face ); + * ... + * FT_Done_Face( face ); + * ... + * } + * ``` + * + * To loop over all valid values for `face_index`, use something similar + * to the following snippet, again without error handling. The code + * accesses all faces immediately (thus only a single call of + * `FT_Open_Face` within the do-loop), with and without named instances. + * + * ``` + * ... + * FT_Face face; + * + * FT_Long num_faces = 0; + * FT_Long num_instances = 0; + * + * FT_Long face_idx = 0; + * FT_Long instance_idx = 0; + * + * + * do + * { + * FT_Long id = ( instance_idx << 16 ) + face_idx; + * + * + * error = FT_Open_Face( library, args, id, &face ); + * if ( error ) { ... } + * + * num_faces = face->num_faces; + * num_instances = face->style_flags >> 16; + * + * ... + * + * FT_Done_Face( face ); + * + * if ( instance_idx < num_instances ) + * instance_idx++; + * else + * { + * face_idx++; + * instance_idx = 0; + * } + * + * } while ( face_idx < num_faces ) + * ``` + */ FT_EXPORT( FT_Error ) FT_Open_Face( FT_Library library, const FT_Open_Args* args, @@ -2368,204 +2350,208 @@ FT_BEGIN_HEADER FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_File */ - /* */ - /* <Description> */ - /* Call @FT_Attach_Stream to attach a file. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* filepathname :: The pathname. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Attach_File + * + * @description: + * Call @FT_Attach_Stream to attach a file. + * + * @inout: + * face :: + * The target face object. + * + * @input: + * filepathname :: + * The pathname. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Attach_File( FT_Face face, const char* filepathname ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_Stream */ - /* */ - /* <Description> */ - /* `Attach' data to a face object. Normally, this is used to read */ - /* additional information for the face object. For example, you can */ - /* attach an AFM file that comes with a Type~1 font to get the */ - /* kerning values and other metrics. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* parameters :: A pointer to @FT_Open_Args that must be filled by */ - /* the caller. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The meaning of the `attach' (i.e., what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file or stream attachments. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Attach_Stream + * + * @description: + * 'Attach' data to a face object. Normally, this is used to read + * additional information for the face object. For example, you can + * attach an AFM file that comes with a Type~1 font to get the kerning + * values and other metrics. + * + * @inout: + * face :: + * The target face object. + * + * @input: + * parameters :: + * A pointer to @FT_Open_Args that must be filled by the caller. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The meaning of the 'attach' (i.e., what really happens when the new + * file is read) is not fixed by FreeType itself. It really depends on + * the font format (and thus the font driver). + * + * Client applications are expected to know what they are doing when + * invoking this function. Most drivers simply do not implement file or + * stream attachments. + */ FT_EXPORT( FT_Error ) FT_Attach_Stream( FT_Face face, FT_Open_Args* parameters ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Face */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Face structure */ - /* is created. This function increments the counter. @FT_Done_Face */ - /* then only destroys a face if the counter is~1, otherwise it simply */ - /* decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Face objects. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Reference_Face + * + * @description: + * A counter gets initialized to~1 at the time an @FT_Face structure is + * created. This function increments the counter. @FT_Done_Face then + * only destroys a face if the counter is~1, otherwise it simply + * decrements the counter. + * + * This function helps in managing life-cycles of structures that + * reference @FT_Face objects. + * + * @input: + * face :: + * A handle to a target face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.4.2 + */ FT_EXPORT( FT_Error ) FT_Reference_Face( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Face */ - /* */ - /* <Description> */ - /* Discard a given face object, as well as all of its child slots and */ - /* sizes. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Face + * + * @description: + * Discard a given face object, as well as all of its child slots and + * sizes. + * + * @input: + * face :: + * A handle to a target face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Face. + */ FT_EXPORT( FT_Error ) FT_Done_Face( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Size */ - /* */ - /* <Description> */ - /* Select a bitmap strike. To be more precise, this function sets */ - /* the scaling factors of the active @FT_Size object in a face so */ - /* that bitmaps from this particular strike are taken by */ - /* @FT_Load_Glyph and friends. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* strike_index :: The index of the bitmap strike in the */ - /* `available_sizes' field of @FT_FaceRec structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* For bitmaps embedded in outline fonts it is common that only a */ - /* subset of the available glyphs at a given ppem value is available. */ - /* FreeType silently uses outlines if there is no bitmap for a given */ - /* glyph index. */ - /* */ - /* For GX and OpenType variation fonts, a bitmap strike makes sense */ - /* only if the default instance is active (this is, no glyph */ - /* variation takes place); otherwise, FreeType simply ignores bitmap */ - /* strikes. The same is true for all named instances that are */ - /* different from the default instance. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Select_Size + * + * @description: + * Select a bitmap strike. To be more precise, this function sets the + * scaling factors of the active @FT_Size object in a face so that + * bitmaps from this particular strike are taken by @FT_Load_Glyph and + * friends. + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * strike_index :: + * The index of the bitmap strike in the `available_sizes` field of + * @FT_FaceRec structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * For bitmaps embedded in outline fonts it is common that only a subset + * of the available glyphs at a given ppem value is available. FreeType + * silently uses outlines if there is no bitmap for a given glyph index. + * + * For GX and OpenType variation fonts, a bitmap strike makes sense only + * if the default instance is active (this is, no glyph variation takes + * place); otherwise, FreeType simply ignores bitmap strikes. The same + * is true for all named instances that are different from the default + * instance. + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Select_Size( FT_Face face, FT_Int strike_index ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Size_Request_Type */ - /* */ - /* <Description> */ - /* An enumeration type that lists the supported size request types, */ - /* i.e., what input size (in font units) maps to the requested output */ - /* size (in pixels, as computed from the arguments of */ - /* @FT_Size_Request). */ - /* */ - /* <Values> */ - /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ - /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ - /* used to determine both scaling values. */ - /* */ - /* This is the standard scaling found in most applications. In */ - /* particular, use this size request type for TrueType fonts if */ - /* they provide optical scaling or something similar. Note, */ - /* however, that `units_per_EM' is a rather abstract value which */ - /* bears no relation to the actual size of the glyphs in a font. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ - /* The real dimension. The sum of the `ascender' and (minus of) */ - /* the `descender' fields of @FT_FaceRec is used to determine both */ - /* scaling values. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_BBOX :: */ - /* The font bounding box. The width and height of the `bbox' field */ - /* of @FT_FaceRec are used to determine the horizontal and vertical */ - /* scaling value, respectively. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_CELL :: */ - /* The `max_advance_width' field of @FT_FaceRec is used to */ - /* determine the horizontal scaling value; the vertical scaling */ - /* value is determined the same way as */ - /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ - /* values are set to the smaller one. This type is useful if you */ - /* want to specify the font size for, say, a window of a given */ - /* dimension and 80x24 cells. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_SCALES :: */ - /* Specify the scaling values directly. */ - /* */ - /* <Note> */ - /* The above descriptions only apply to scalable formats. For bitmap */ - /* formats, the behaviour is up to the driver. */ - /* */ - /* See the note section of @FT_Size_Metrics if you wonder how size */ - /* requesting relates to scaling values. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Size_Request_Type + * + * @description: + * An enumeration type that lists the supported size request types, i.e., + * what input size (in font units) maps to the requested output size (in + * pixels, as computed from the arguments of @FT_Size_Request). + * + * @values: + * FT_SIZE_REQUEST_TYPE_NOMINAL :: + * The nominal size. The `units_per_EM` field of @FT_FaceRec is used + * to determine both scaling values. + * + * This is the standard scaling found in most applications. In + * particular, use this size request type for TrueType fonts if they + * provide optical scaling or something similar. Note, however, that + * `units_per_EM` is a rather abstract value which bears no relation to + * the actual size of the glyphs in a font. + * + * FT_SIZE_REQUEST_TYPE_REAL_DIM :: + * The real dimension. The sum of the `ascender` and (minus of) the + * `descender` fields of @FT_FaceRec is used to determine both scaling + * values. + * + * FT_SIZE_REQUEST_TYPE_BBOX :: + * The font bounding box. The width and height of the `bbox` field of + * @FT_FaceRec are used to determine the horizontal and vertical + * scaling value, respectively. + * + * FT_SIZE_REQUEST_TYPE_CELL :: + * The `max_advance_width` field of @FT_FaceRec is used to determine + * the horizontal scaling value; the vertical scaling value is + * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does. + * Finally, both scaling values are set to the smaller one. This type + * is useful if you want to specify the font size for, say, a window of + * a given dimension and 80x24 cells. + * + * FT_SIZE_REQUEST_TYPE_SCALES :: + * Specify the scaling values directly. + * + * @note: + * The above descriptions only apply to scalable formats. For bitmap + * formats, the behaviour is up to the driver. + * + * See the note section of @FT_Size_Metrics if you wonder how size + * requesting relates to scaling values. + */ typedef enum FT_Size_Request_Type_ { FT_SIZE_REQUEST_TYPE_NOMINAL, @@ -2579,42 +2565,45 @@ FT_BEGIN_HEADER } FT_Size_Request_Type; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_RequestRec */ - /* */ - /* <Description> */ - /* A structure to model a size request. */ - /* */ - /* <Fields> */ - /* type :: See @FT_Size_Request_Type. */ - /* */ - /* width :: The desired width, given as a 26.6 fractional */ - /* point value (with 72pt = 1in). */ - /* */ - /* height :: The desired height, given as a 26.6 fractional */ - /* point value (with 72pt = 1in). */ - /* */ - /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */ - /* inch). If set to zero, `width' is treated as a */ - /* 26.6 fractional *pixel* value, which gets */ - /* internally rounded to an integer. */ - /* */ - /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */ - /* inch). If set to zero, `height' is treated as a */ - /* 26.6 fractional *pixel* value, which gets */ - /* internally rounded to an integer. */ - /* */ - /* <Note> */ - /* If `width' is zero, the horizontal scaling value is set equal */ - /* to the vertical scaling value, and vice versa. */ - /* */ - /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */ - /* interpreted directly as 16.16 fractional scaling values, without */ - /* any further modification, and both `horiResolution' and */ - /* `vertResolution' are ignored. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Size_RequestRec + * + * @description: + * A structure to model a size request. + * + * @fields: + * type :: + * See @FT_Size_Request_Type. + * + * width :: + * The desired width, given as a 26.6 fractional point value (with 72pt + * = 1in). + * + * height :: + * The desired height, given as a 26.6 fractional point value (with + * 72pt = 1in). + * + * horiResolution :: + * The horizontal resolution (dpi, i.e., pixels per inch). If set to + * zero, `width` is treated as a 26.6 fractional **pixel** value, which + * gets internally rounded to an integer. + * + * vertResolution :: + * The vertical resolution (dpi, i.e., pixels per inch). If set to + * zero, `height` is treated as a 26.6 fractional **pixel** value, + * which gets internally rounded to an integer. + * + * @note: + * If `width` is zero, the horizontal scaling value is set equal to the + * vertical scaling value, and vice versa. + * + * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are + * interpreted directly as 16.16 fractional scaling values, without any + * further modification, and both `horiResolution` and `vertResolution` + * are ignored. + */ typedef struct FT_Size_RequestRec_ { FT_Size_Request_Type type; @@ -2626,96 +2615,102 @@ FT_BEGIN_HEADER } FT_Size_RequestRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Request */ - /* */ - /* <Description> */ - /* A handle to a size request structure. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Size_Request + * + * @description: + * A handle to a size request structure. + */ typedef struct FT_Size_RequestRec_ *FT_Size_Request; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Request_Size */ - /* */ - /* <Description> */ - /* Resize the scale of the active @FT_Size object in a face. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* req :: A pointer to a @FT_Size_RequestRec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Although drivers may select the bitmap strike matching the */ - /* request, you should not rely on this if you intend to select a */ - /* particular bitmap strike. Use @FT_Select_Size instead in that */ - /* case. */ - /* */ - /* The relation between the requested size and the resulting glyph */ - /* size is dependent entirely on how the size is defined in the */ - /* source face. The font designer chooses the final size of each */ - /* glyph relative to this size. For more information refer to */ - /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */ - /* */ - /* Contrary to @FT_Set_Char_Size, this function doesn't have special */ - /* code to normalize zero-valued widths, heights, or resolutions */ - /* (which lead to errors in most cases). */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Request_Size + * + * @description: + * Resize the scale of the active @FT_Size object in a face. + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * req :: + * A pointer to a @FT_Size_RequestRec. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Although drivers may select the bitmap strike matching the request, + * you should not rely on this if you intend to select a particular + * bitmap strike. Use @FT_Select_Size instead in that case. + * + * The relation between the requested size and the resulting glyph size + * is dependent entirely on how the size is defined in the source face. + * The font designer chooses the final size of each glyph relative to + * this size. For more information refer to + * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. + * + * Contrary to @FT_Set_Char_Size, this function doesn't have special code + * to normalize zero-valued widths, heights, or resolutions (which lead + * to errors in most cases). + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Request_Size( FT_Face face, FT_Size_Request req ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Char_Size */ - /* */ - /* <Description> */ - /* Call @FT_Request_Size to request the nominal size (in points). */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* char_width :: The nominal width, in 26.6 fractional points. */ - /* */ - /* char_height :: The nominal height, in 26.6 fractional points. */ - /* */ - /* horz_resolution :: The horizontal resolution in dpi. */ - /* */ - /* vert_resolution :: The vertical resolution in dpi. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* While this function allows fractional points as input values, the */ - /* resulting ppem value for the given resolution is always rounded to */ - /* the nearest integer. */ - /* */ - /* If either the character width or height is zero, it is set equal */ - /* to the other value. */ - /* */ - /* If either the horizontal or vertical resolution is zero, it is set */ - /* equal to the other value. */ - /* */ - /* A character width or height smaller than 1pt is set to 1pt; if */ - /* both resolution values are zero, they are set to 72dpi. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Char_Size + * + * @description: + * Call @FT_Request_Size to request the nominal size (in points). + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * char_width :: + * The nominal width, in 26.6 fractional points. + * + * char_height :: + * The nominal height, in 26.6 fractional points. + * + * horz_resolution :: + * The horizontal resolution in dpi. + * + * vert_resolution :: + * The vertical resolution in dpi. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While this function allows fractional points as input values, the + * resulting ppem value for the given resolution is always rounded to the + * nearest integer. + * + * If either the character width or height is zero, it is set equal to + * the other value. + * + * If either the horizontal or vertical resolution is zero, it is set + * equal to the other value. + * + * A character width or height smaller than 1pt is set to 1pt; if both + * resolution values are zero, they are set to 72dpi. + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Set_Char_Size( FT_Face face, FT_F26Dot6 char_width, @@ -2724,134 +2719,138 @@ FT_BEGIN_HEADER FT_UInt vert_resolution ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Pixel_Sizes */ - /* */ - /* <Description> */ - /* Call @FT_Request_Size to request the nominal size (in pixels). */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* pixel_width :: The nominal width, in pixels. */ - /* */ - /* pixel_height :: The nominal height, in pixels. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should not rely on the resulting glyphs matching or being */ - /* constrained to this pixel size. Refer to @FT_Request_Size to */ - /* understand how requested sizes relate to actual sizes. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Pixel_Sizes + * + * @description: + * Call @FT_Request_Size to request the nominal size (in pixels). + * + * @inout: + * face :: + * A handle to the target face object. + * + * @input: + * pixel_width :: + * The nominal width, in pixels. + * + * pixel_height :: + * The nominal height, in pixels. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should not rely on the resulting glyphs matching or being + * constrained to this pixel size. Refer to @FT_Request_Size to + * understand how requested sizes relate to actual sizes. + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Glyph */ - /* */ - /* <Description> */ - /* Load a glyph into the glyph slot of a face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* glyph_index :: The index of the glyph in the font file. For */ - /* CID-keyed fonts (either in PS or in CFF format) */ - /* this argument specifies the CID value. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The loaded glyph may be transformed. See @FT_Set_Transform for */ - /* the details. */ - /* */ - /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ - /* returned for invalid CID values (this is, for CID values that */ - /* don't have a corresponding glyph in the font). See the discussion */ - /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ - /* */ - /* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */ - /* outline at EM size, then scale it manually and fill it as a */ - /* graphics operation. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Load_Glyph + * + * @description: + * Load a glyph into the glyph slot of a face object. + * + * @inout: + * face :: + * A handle to the target face object where the glyph is loaded. + * + * @input: + * glyph_index :: + * The index of the glyph in the font file. For CID-keyed fonts + * (either in PS or in CFF format) this argument specifies the CID + * value. + * + * load_flags :: + * A flag indicating what to load for this glyph. The @FT_LOAD_XXX + * constants can be used to control the glyph loading process (e.g., + * whether the outline should be scaled, whether to load bitmaps or + * not, whether to hint the outline, etc). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The loaded glyph may be transformed. See @FT_Set_Transform for the + * details. + * + * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned + * for invalid CID values (this is, for CID values that don't have a + * corresponding glyph in the font). See the discussion of the + * @FT_FACE_FLAG_CID_KEYED flag for more details. + * + * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline + * at EM size, then scale it manually and fill it as a graphics + * operation. + */ FT_EXPORT( FT_Error ) FT_Load_Glyph( FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Char */ - /* */ - /* <Description> */ - /* Load a glyph into the glyph slot of a face object, accessed by its */ - /* character code. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* char_code :: The glyph's character code, according to the */ - /* current charmap used in the face. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ - /* */ - /* Many fonts contain glyphs that can't be loaded by this function */ - /* since its glyph indices are not listed in any of the font's */ - /* charmaps. */ - /* */ - /* If no active cmap is set up (i.e., `face->charmap' is zero), the */ - /* call to @FT_Get_Char_Index is omitted, and the function behaves */ - /* identically to @FT_Load_Glyph. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Load_Char + * + * @description: + * Load a glyph into the glyph slot of a face object, accessed by its + * character code. + * + * @inout: + * face :: + * A handle to a target face object where the glyph is loaded. + * + * @input: + * char_code :: + * The glyph's character code, according to the current charmap used in + * the face. + * + * load_flags :: + * A flag indicating what to load for this glyph. The @FT_LOAD_XXX + * constants can be used to control the glyph loading process (e.g., + * whether the outline should be scaled, whether to load bitmaps or + * not, whether to hint the outline, etc). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. + * + * Many fonts contain glyphs that can't be loaded by this function since + * its glyph indices are not listed in any of the font's charmaps. + * + * If no active cmap is set up (i.e., `face->charmap` is zero), the call + * to @FT_Get_Char_Index is omitted, and the function behaves identically + * to @FT_Load_Glyph. + */ FT_EXPORT( FT_Error ) FT_Load_Char( FT_Face face, FT_ULong char_code, FT_Int32 load_flags ); - /************************************************************************* + /************************************************************************** * * @enum: * FT_LOAD_XXX * * @description: - * A list of bit field constants for @FT_Load_Glyph to indicate what - * kind of operations to perform during glyph loading. + * A list of bit field constants for @FT_Load_Glyph to indicate what kind + * of operations to perform during glyph loading. * * @values: * FT_LOAD_DEFAULT :: @@ -2859,15 +2858,14 @@ FT_BEGIN_HEADER * operation. In this case, the following happens: * * 1. FreeType looks for a bitmap for the glyph corresponding to the - * face's current size. If one is found, the function returns. - * The bitmap data can be accessed from the glyph slot (see note - * below). + * face's current size. If one is found, the function returns. The + * bitmap data can be accessed from the glyph slot (see note below). * * 2. If no embedded bitmap is searched for or found, FreeType looks - * for a scalable outline. If one is found, it is loaded from - * the font file, scaled to device pixels, then `hinted' to the - * pixel grid in order to optimize it. The outline data can be - * accessed from the glyph slot (see note below). + * for a scalable outline. If one is found, it is loaded from the font + * file, scaled to device pixels, then 'hinted' to the pixel grid in + * order to optimize it. The outline data can be accessed from the + * glyph slot (see note below). * * Note that by default the glyph loader doesn't render outlines into * bitmaps. The following flags are used to modify this default @@ -2879,14 +2877,14 @@ FT_BEGIN_HEADER * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and * unsets @FT_LOAD_RENDER. * - * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using - * FT_LOAD_NO_SCALE usually yields meaningless outlines because the + * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using + * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the * subglyphs must be scaled and positioned with hinting instructions. - * This can be solved by loading the font without FT_LOAD_NO_SCALE and - * setting the character size to `font->units_per_EM'. + * This can be solved by loading the font without `FT_LOAD_NO_SCALE` + * and setting the character size to `font->units_per_EM`. * * FT_LOAD_NO_HINTING :: - * Disable hinting. This generally generates `blurrier' bitmap glyphs + * Disable hinting. This generally generates 'blurrier' bitmap glyphs * when the glyph are rendered in any of the anti-aliased modes. See * also the note below. * @@ -2907,34 +2905,37 @@ FT_BEGIN_HEADER * * FT_LOAD_VERTICAL_LAYOUT :: * Load the glyph for vertical text layout. In particular, the - * `advance' value in the @FT_GlyphSlotRec structure is set to the - * `vertAdvance' value of the `metrics' field. + * `advance` value in the @FT_GlyphSlotRec structure is set to the + * `vertAdvance` value of the `metrics` field. * - * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use - * this flag currently. Reason is that in this case vertical metrics - * get synthesized, and those values are not always consistent across + * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this + * flag currently. Reason is that in this case vertical metrics get + * synthesized, and those values are not always consistent across * various font formats. * * FT_LOAD_FORCE_AUTOHINT :: - * Prefer the auto-hinter over the font's native hinter. See also - * the note below. + * Prefer the auto-hinter over the font's native hinter. See also the + * note below. * * FT_LOAD_PEDANTIC :: * Make the font driver perform pedantic verifications during glyph - * loading. This is mostly used to detect broken glyphs in fonts. - * By default, FreeType tries to handle broken fonts also. + * loading and hinting. This is mostly used to detect broken glyphs in + * fonts. By default, FreeType tries to handle broken fonts also. * * In particular, errors from the TrueType bytecode engine are not - * passed to the application if this flag is not set; this might - * result in partially hinted or distorted glyphs in case a glyph's - * bytecode is buggy. + * passed to the application if this flag is not set; this might result + * in partially hinted or distorted glyphs in case a glyph's bytecode + * is buggy. * * FT_LOAD_NO_RECURSE :: - * Don't load composite glyphs recursively. Instead, the font - * driver should set the `num_subglyph' and `subglyphs' values of - * the glyph slot accordingly, and set `glyph->format' to - * @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can - * then be accessed with @FT_Get_SubGlyph_Info. + * Don't load composite glyphs recursively. Instead, the font driver + * fills the `num_subglyph` and `subglyphs` values of the glyph slot; + * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The + * description of subglyphs can then be accessed with + * @FT_Get_SubGlyph_Info. + * + * Don't use this flag for retrieving metrics information since some + * font drivers only return rudimentary data. * * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. * @@ -2951,23 +2952,35 @@ FT_BEGIN_HEADER * monochrome-optimized hinting algorithm is used. * * FT_LOAD_LINEAR_DESIGN :: - * Keep `linearHoriAdvance' and `linearVertAdvance' fields of - * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for - * details. + * Keep `linearHoriAdvance` and `linearVertAdvance` fields of + * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details. * * FT_LOAD_NO_AUTOHINT :: * Disable the auto-hinter. See also the note below. * * FT_LOAD_COLOR :: + * Load colored glyphs. There are slight differences depending on the + * font format. + * * [Since 2.5] Load embedded color bitmap images. The resulting color - * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format. - * If the flag is not set and color bitmaps are found, they are - * converted to 256-level gray bitmaps transparently, using the - * @FT_PIXEL_MODE_GRAY format. + * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format, + * with pre-multiplied color channels. If the flag is not set and + * color bitmaps are found, they are converted to 256-level gray + * bitmaps, using the @FT_PIXEL_MODE_GRAY format. + * + * [Since 2.10, experimental] If the glyph index contains an entry in + * the face's 'COLR' table with a 'CPAL' palette table (as defined in + * the OpenType specification), make @FT_Render_Glyph provide a default + * blending of the color glyph layers associated with the glyph index, + * using the same bitmap format as embedded color bitmap images. This + * is mainly for convenience; for full control of color layers use + * @FT_Get_Color_Glyph_Layer and FreeType's color functions like + * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering + * so that the client application can handle blending by itself. * * FT_LOAD_COMPUTE_METRICS :: - * [Since 2.6.1] Compute glyph metrics from the glyph data, without - * the use of bundled metrics tables (for example, the `hdmx' table in + * [Since 2.6.1] Compute glyph metrics from the glyph data, without the + * use of bundled metrics tables (for example, the 'hdmx' table in * TrueType fonts). This flag is mainly used by font validating or * font editing applications, which need to ignore, verify, or edit * those tables. @@ -2976,9 +2989,9 @@ FT_BEGIN_HEADER * * FT_LOAD_BITMAP_METRICS_ONLY :: * [Since 2.7.1] Request loading of the metrics and bitmap image - * information of a (possibly embedded) bitmap glyph without - * allocating or copying the bitmap image data itself. No effect if - * the target glyph is not a bitmap image. + * information of a (possibly embedded) bitmap glyph without allocating + * or copying the bitmap image data itself. No effect if the target + * glyph is not a bitmap image. * * This flag unsets @FT_LOAD_RENDER. * @@ -2993,8 +3006,8 @@ FT_BEGIN_HEADER * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can * disable hinting by setting @FT_LOAD_NO_HINTING or change the * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set - * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be - * used at all. + * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used + * at all. * * See the description of @FT_FACE_FLAG_TRICKY for a special exception * (affecting only a handful of Asian fonts). @@ -3005,7 +3018,7 @@ FT_BEGIN_HEADER * Note that the auto-hinter needs a valid Unicode cmap (either a native * one or synthesized by FreeType) for producing correct results. If a * font provides an incorrect mapping (for example, assigning the - * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a + * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a * mathematical integral sign), the auto-hinter might produce useless * results. * @@ -3025,7 +3038,7 @@ FT_BEGIN_HEADER #define FT_LOAD_MONOCHROME ( 1L << 12 ) #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) #define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) - /* Bits 16-19 are used by `FT_LOAD_TARGET_' */ + /* Bits 16-19 are used by `FT_LOAD_TARGET_` */ #define FT_LOAD_COLOR ( 1L << 20 ) #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 ) @@ -3044,19 +3057,17 @@ FT_BEGIN_HEADER * * @description: * A list of values to select a specific hinting algorithm for the - * hinter. You should OR one of these values to your `load_flags' - * when calling @FT_Load_Glyph. + * hinter. You should OR one of these values to your `load_flags` when + * calling @FT_Load_Glyph. * - * Note that a font's native hinters may ignore the hinting algorithm - * you have specified (e.g., the TrueType bytecode interpreter). You - * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is - * used. + * Note that a font's native hinters may ignore the hinting algorithm you + * have specified (e.g., the TrueType bytecode interpreter). You can set + * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. * * @values: * FT_LOAD_TARGET_NORMAL :: * The default hinting algorithm, optimized for standard gray-level - * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO - * instead. + * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead. * * FT_LOAD_TARGET_LIGHT :: * A lighter hinting algorithm for gray-level modes. Many generated @@ -3069,13 +3080,13 @@ FT_BEGIN_HEADER * auto-hinter. * * Advance widths are rounded to integer values; however, using the - * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is + * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is * possible to get fractional advance widths for subpixel positioning * (which is recommended to use). * - * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active, - * TrueType-like metrics are used to make this mode behave similarly - * as in unpatched FreeType versions between 2.4.6 and 2.7.1 + * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is + * active, TrueType-like metrics are used to make this mode behave + * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1 * (inclusive). * * FT_LOAD_TARGET_MONO :: @@ -3083,6 +3094,12 @@ FT_BEGIN_HEADER * output. The result is probably unpleasant if the glyph is rendered * in non-monochrome modes. * + * Note that for outline fonts only the TrueType font driver has proper + * monochrome hinting support, provided the TTFs contain hints for B/W + * rendering (which most fonts no longer provide). If these conditions + * are not met it is very likely that you get ugly results at smaller + * sizes. + * * FT_LOAD_TARGET_LCD :: * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally * decimated LCD displays. @@ -3092,25 +3109,25 @@ FT_BEGIN_HEADER * decimated LCD displays. * * @note: - * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your - * `load_flags'. They can't be ORed. + * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your + * `load_flags`. They can't be ORed. * * If @FT_LOAD_RENDER is also set, the glyph is rendered in the * corresponding mode (i.e., the mode that matches the used algorithm - * best). An exception is FT_LOAD_TARGET_MONO since it implies + * best). An exception is `FT_LOAD_TARGET_MONO` since it implies * @FT_LOAD_MONOCHROME. * * You can use a hinting algorithm that doesn't correspond to the same - * rendering mode. As an example, it is possible to use the `light' + * rendering mode. As an example, it is possible to use the 'light' * hinting algorithm and have the results rendered in horizontal LCD * pixel mode, with code like * - * { - * FT_Load_Glyph( face, glyph_index, - * load_flags | FT_LOAD_TARGET_LIGHT ); + * ``` + * FT_Load_Glyph( face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT ); * - * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); - * } + * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * ``` * * In general, you should stick with one rendering mode. For example, * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO @@ -3142,98 +3159,98 @@ FT_BEGIN_HEADER #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Transform */ - /* */ - /* <Description> */ - /* Set the transformation that is applied to glyph images when they */ - /* are loaded into a glyph slot through @FT_Load_Glyph. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */ - /* for the identity matrix. */ - /* delta :: A pointer to the translation vector. Use NULL for the */ - /* null vector. */ - /* */ - /* <Note> */ - /* The transformation is only applied to scalable image formats after */ - /* the glyph has been loaded. It means that hinting is unaltered by */ - /* the transformation and is performed on the character size given in */ - /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Transform + * + * @description: + * Set the transformation that is applied to glyph images when they are + * loaded into a glyph slot through @FT_Load_Glyph. + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * matrix :: + * A pointer to the transformation's 2x2 matrix. Use `NULL` for the + * identity matrix. + * delta :: + * A pointer to the translation vector. Use `NULL` for the null vector. + * + * @note: + * The transformation is only applied to scalable image formats after the + * glyph has been loaded. It means that hinting is unaltered by the + * transformation and is performed on the character size given in the + * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. + * + * Note that this also transforms the `face.glyph.advance` field, but + * **not** the values in `face.glyph.metrics`. + */ FT_EXPORT( void ) FT_Set_Transform( FT_Face face, FT_Matrix* matrix, FT_Vector* delta ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Render_Mode */ - /* */ - /* <Description> */ - /* Render modes supported by FreeType~2. Each mode corresponds to a */ - /* specific type of scanline conversion performed on the outline. */ - /* */ - /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ - /* field in the @FT_GlyphSlotRec structure gives the format of the */ - /* returned bitmap. */ - /* */ - /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */ - /* indicating pixel coverage. Use linear alpha blending and gamma */ - /* correction to correctly render non-monochrome glyph bitmaps onto a */ - /* surface; see @FT_Render_Glyph. */ - /* */ - /* <Values> */ - /* FT_RENDER_MODE_NORMAL :: */ - /* Default render mode; it corresponds to 8-bit anti-aliased */ - /* bitmaps. */ - /* */ - /* FT_RENDER_MODE_LIGHT :: */ - /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ - /* defined as a separate value because render modes are also used */ - /* indirectly to define hinting algorithm selectors. See */ - /* @FT_LOAD_TARGET_XXX for details. */ - /* */ - /* FT_RENDER_MODE_MONO :: */ - /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ - /* opacity). */ - /* */ - /* FT_RENDER_MODE_LCD :: */ - /* This mode corresponds to horizontal RGB and BGR subpixel */ - /* displays like LCD screens. It produces 8-bit bitmaps that are */ - /* 3~times the width of the original glyph outline in pixels, and */ - /* which use the @FT_PIXEL_MODE_LCD mode. */ - /* */ - /* FT_RENDER_MODE_LCD_V :: */ - /* This mode corresponds to vertical RGB and BGR subpixel displays */ - /* (like PDA screens, rotated LCD displays, etc.). It produces */ - /* 8-bit bitmaps that are 3~times the height of the original */ - /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ - /* */ - /* <Note> */ - /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */ - /* `ftoption.h', which enables patented ClearType-style rendering, */ - /* the LCD-optimized glyph bitmaps should be filtered to reduce color */ - /* fringes inherent to this technology. You can either set up LCD */ - /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */ - /* or do the filtering yourself. The default FreeType LCD rendering */ - /* technology does not require filtering. */ - /* */ - /* The selected render mode only affects vector glyphs of a font. */ - /* Embedded bitmaps often have a different pixel mode like */ - /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ - /* them into 8-bit pixmaps. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Render_Mode + * + * @description: + * Render modes supported by FreeType~2. Each mode corresponds to a + * specific type of scanline conversion performed on the outline. + * + * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field + * in the @FT_GlyphSlotRec structure gives the format of the returned + * bitmap. + * + * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, + * indicating pixel coverage. Use linear alpha blending and gamma + * correction to correctly render non-monochrome glyph bitmaps onto a + * surface; see @FT_Render_Glyph. + * + * @values: + * FT_RENDER_MODE_NORMAL :: + * Default render mode; it corresponds to 8-bit anti-aliased bitmaps. + * + * FT_RENDER_MODE_LIGHT :: + * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as + * a separate value because render modes are also used indirectly to + * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for + * details. + * + * FT_RENDER_MODE_MONO :: + * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity). + * + * FT_RENDER_MODE_LCD :: + * This mode corresponds to horizontal RGB and BGR subpixel displays + * like LCD screens. It produces 8-bit bitmaps that are 3~times the + * width of the original glyph outline in pixels, and which use the + * @FT_PIXEL_MODE_LCD mode. + * + * FT_RENDER_MODE_LCD_V :: + * This mode corresponds to vertical RGB and BGR subpixel displays + * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit + * bitmaps that are 3~times the height of the original glyph outline in + * pixels and use the @FT_PIXEL_MODE_LCD_V mode. + * + * @note: + * Should you define `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` in your + * `ftoption.h`, which enables patented ClearType-style rendering, the + * LCD-optimized glyph bitmaps should be filtered to reduce color fringes + * inherent to this technology. You can either set up LCD filtering with + * @FT_Library_SetLcdFilter or @FT_Face_Properties, or do the filtering + * yourself. The default FreeType LCD rendering technology does not + * require filtering. + * + * The selected render mode only affects vector glyphs of a font. + * Embedded bitmaps often have a different pixel mode like + * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them + * into 8-bit pixmaps. + */ typedef enum FT_Render_Mode_ { FT_RENDER_MODE_NORMAL = 0, @@ -3248,147 +3265,149 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Render_Mode' values instead */ + /* `FT_Render_Mode` values instead */ #define ft_render_mode_normal FT_RENDER_MODE_NORMAL #define ft_render_mode_mono FT_RENDER_MODE_MONO - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Render_Glyph */ - /* */ - /* <Description> */ - /* Convert a given glyph image to a bitmap. It does so by inspecting */ - /* the glyph image format, finding the relevant renderer, and */ - /* invoking it. */ - /* */ - /* <InOut> */ - /* slot :: A handle to the glyph slot containing the image to */ - /* convert. */ - /* */ - /* <Input> */ - /* render_mode :: The render mode used to render the glyph image into */ - /* a bitmap. See @FT_Render_Mode for a list of */ - /* possible values. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */ - /* */ - /* When FreeType outputs a bitmap of a glyph, it really outputs an */ - /* alpha coverage map. If a pixel is completely covered by a */ - /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */ - /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */ - /* pixel is 100% black (or 0% bright). If a pixel is only 50% */ - /* covered (value 0x80), the pixel is made 50% black (50% bright or a */ - /* middle shade of grey). 0% covered means 0% black (100% bright or */ - /* white). */ - /* */ - /* On high-DPI screens like on smartphones and tablets, the pixels */ - /* are so small that their chance of being completely covered and */ - /* therefore completely black are fairly good. On the low-DPI */ - /* screens, however, the situation is different. The pixels are too */ - /* large for most of the details of a glyph and shades of gray are */ - /* the norm rather than the exception. */ - /* */ - /* This is relevant because all our screens have a second problem: */ - /* they are not linear. 1~+~1 is not~2. Twice the value does not */ - /* result in twice the brightness. When a pixel is only 50% covered, */ - /* the coverage map says 50% black, and this translates to a pixel */ - /* value of 128 when you use 8~bits per channel (0-255). However, */ - /* this does not translate to 50% brightness for that pixel on our */ - /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ - /* dwell longer in the darks and only a pixel value of about 186 */ - /* results in 50% brightness -- 128 ends up too dark on both bright */ - /* and dark backgrounds. The net result is that dark text looks */ - /* burnt-out, pixely and blotchy on bright background, bright text */ - /* too frail on dark backgrounds, and colored text on colored */ - /* background (for example, red on green) seems to have dark halos or */ - /* `dirt' around it. The situation is especially ugly for diagonal */ - /* stems like in `w' glyph shapes where the quality of FreeType's */ - /* anti-aliasing depends on the correct display of grays. On */ - /* high-DPI screens where smaller, fully black pixels reign supreme, */ - /* this doesn't matter, but on our low-DPI screens with all the gray */ - /* shades, it does. 0% and 100% brightness are the same things in */ - /* linear and non-linear space, just all the shades in-between */ - /* aren't. */ - /* */ - /* The blending function for placing text over a background is */ - /* */ - /* { */ - /* dst = alpha * src + (1 - alpha) * dst , */ - /* } */ - /* */ - /* which is known as the OVER operator. */ - /* */ - /* To correctly composite an antialiased pixel of a glyph onto a */ - /* surface, */ - /* */ - /* 1. take the foreground and background colors (e.g., in sRGB space) */ - /* and apply gamma to get them in a linear space, */ - /* */ - /* 2. use OVER to blend the two linear colors using the glyph pixel */ - /* as the alpha value (remember, the glyph bitmap is an alpha */ - /* coverage bitmap), and */ - /* */ - /* 3. apply inverse gamma to the blended pixel and write it back to */ - /* the image. */ - /* */ - /* Internal testing at Adobe found that a target inverse gamma of~1.8 */ - /* for step~3 gives good results across a wide range of displays with */ - /* an sRGB gamma curve or a similar one. */ - /* */ - /* This process can cost performance. There is an approximation that */ - /* does not need to know about the background color; see */ - /* https://bel.fi/alankila/lcd/ and */ - /* https://bel.fi/alankila/lcd/alpcor.html for details. */ - /* */ - /* *ATTENTION*: Linear blending is even more important when dealing */ - /* with subpixel-rendered glyphs to prevent color-fringing! A */ - /* subpixel-rendered glyph must first be filtered with a filter that */ - /* gives equal weight to the three color primaries and does not */ - /* exceed a sum of 0x100, see section @lcd_filtering. Then the */ - /* only difference to gray linear blending is that subpixel-rendered */ - /* linear blending is done 3~times per pixel: red foreground subpixel */ - /* to red background subpixel and so on for green and blue. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Render_Glyph + * + * @description: + * Convert a given glyph image to a bitmap. It does so by inspecting the + * glyph image format, finding the relevant renderer, and invoking it. + * + * @inout: + * slot :: + * A handle to the glyph slot containing the image to convert. + * + * @input: + * render_mode :: + * The render mode used to render the glyph image into a bitmap. See + * @FT_Render_Mode for a list of possible values. + * + * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph + * with flag @FT_LOAD_COLOR makes FT_Render_Glyph provide a default + * blending of colored glyph layers associated with the current glyph + * slot (provided the font contains such layers) instead of rendering + * the glyph slot's outline. This is an experimental feature; see + * @FT_LOAD_COLOR for more information. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * To get meaningful results, font scaling values must be set with + * functions like @FT_Set_Char_Size before calling `FT_Render_Glyph`. + * + * When FreeType outputs a bitmap of a glyph, it really outputs an alpha + * coverage map. If a pixel is completely covered by a filled-in + * outline, the bitmap contains 0xFF at that pixel, meaning that + * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100% + * black (or 0% bright). If a pixel is only 50% covered (value 0x80), + * the pixel is made 50% black (50% bright or a middle shade of grey). + * 0% covered means 0% black (100% bright or white). + * + * On high-DPI screens like on smartphones and tablets, the pixels are so + * small that their chance of being completely covered and therefore + * completely black are fairly good. On the low-DPI screens, however, + * the situation is different. The pixels are too large for most of the + * details of a glyph and shades of gray are the norm rather than the + * exception. + * + * This is relevant because all our screens have a second problem: they + * are not linear. 1~+~1 is not~2. Twice the value does not result in + * twice the brightness. When a pixel is only 50% covered, the coverage + * map says 50% black, and this translates to a pixel value of 128 when + * you use 8~bits per channel (0-255). However, this does not translate + * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens. + * Due to their non-linearity, they dwell longer in the darks and only a + * pixel value of about 186 results in 50% brightness -- 128 ends up too + * dark on both bright and dark backgrounds. The net result is that dark + * text looks burnt-out, pixely and blotchy on bright background, bright + * text too frail on dark backgrounds, and colored text on colored + * background (for example, red on green) seems to have dark halos or + * 'dirt' around it. The situation is especially ugly for diagonal stems + * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing + * depends on the correct display of grays. On high-DPI screens where + * smaller, fully black pixels reign supreme, this doesn't matter, but on + * our low-DPI screens with all the gray shades, it does. 0% and 100% + * brightness are the same things in linear and non-linear space, just + * all the shades in-between aren't. + * + * The blending function for placing text over a background is + * + * ``` + * dst = alpha * src + (1 - alpha) * dst , + * ``` + * + * which is known as the OVER operator. + * + * To correctly composite an antialiased pixel of a glyph onto a surface, + * + * 1. take the foreground and background colors (e.g., in sRGB space) + * and apply gamma to get them in a linear space, + * + * 2. use OVER to blend the two linear colors using the glyph pixel + * as the alpha value (remember, the glyph bitmap is an alpha coverage + * bitmap), and + * + * 3. apply inverse gamma to the blended pixel and write it back to + * the image. + * + * Internal testing at Adobe found that a target inverse gamma of~1.8 for + * step~3 gives good results across a wide range of displays with an sRGB + * gamma curve or a similar one. + * + * This process can cost performance. There is an approximation that + * does not need to know about the background color; see + * https://bel.fi/alankila/lcd/ and + * https://bel.fi/alankila/lcd/alpcor.html for details. + * + * **ATTENTION**: Linear blending is even more important when dealing + * with subpixel-rendered glyphs to prevent color-fringing! A + * subpixel-rendered glyph must first be filtered with a filter that + * gives equal weight to the three color primaries and does not exceed a + * sum of 0x100, see section @lcd_rendering. Then the only difference to + * gray linear blending is that subpixel-rendered linear blending is done + * 3~times per pixel: red foreground subpixel to red background subpixel + * and so on for green and blue. + */ FT_EXPORT( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot, FT_Render_Mode render_mode ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Kerning_Mode */ - /* */ - /* <Description> */ - /* An enumeration to specify the format of kerning values returned by */ - /* @FT_Get_Kerning. */ - /* */ - /* <Values> */ - /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ - /* 26.6 fractional pixels. */ - /* */ - /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ - /* 26.6 fractional pixels. */ - /* */ - /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ - /* units. */ - /* */ - /* <Note> */ - /* FT_KERNING_DEFAULT returns full pixel values; it also makes */ - /* FreeType heuristically scale down kerning distances at small ppem */ - /* values so that they don't become too big. */ - /* */ - /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */ - /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */ - /* convert font units to pixels. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Kerning_Mode + * + * @description: + * An enumeration to specify the format of kerning values returned by + * @FT_Get_Kerning. + * + * @values: + * FT_KERNING_DEFAULT :: + * Return grid-fitted kerning distances in 26.6 fractional pixels. + * + * FT_KERNING_UNFITTED :: + * Return un-grid-fitted kerning distances in 26.6 fractional pixels. + * + * FT_KERNING_UNSCALED :: + * Return the kerning vector in original font units. + * + * @note: + * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType + * heuristically scale down kerning distances at small ppem values so + * that they don't become too big. + * + * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current + * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to + * convert font units to pixels. + */ typedef enum FT_Kerning_Mode_ { FT_KERNING_DEFAULT = 0, @@ -3399,50 +3418,53 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Kerning_Mode' values instead */ + /* `FT_Kerning_Mode` values instead */ #define ft_kerning_default FT_KERNING_DEFAULT #define ft_kerning_unfitted FT_KERNING_UNFITTED #define ft_kerning_unscaled FT_KERNING_UNSCALED - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Kerning */ - /* */ - /* <Description> */ - /* Return the kerning vector between two glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* kern_mode :: See @FT_Kerning_Mode for more information. */ - /* Determines the scale and dimension of the returned */ - /* kerning vector. */ - /* */ - /* <Output> */ - /* akerning :: The kerning vector. This is either in font units, */ - /* fractional pixels (26.6 format), or pixels for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this method. Other layouts, or more sophisticated */ - /* kernings, are out of the scope of this API function -- they can be */ - /* implemented through format-specific interfaces. */ - /* */ - /* Kerning for OpenType fonts implemented in a `GPOS' table is not */ - /* supported; use @FT_HAS_KERNING to find out whether a font has data */ - /* that can be extracted with `FT_Get_Kerning'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Kerning + * + * @description: + * Return the kerning vector between two glyphs of the same face. + * + * @input: + * face :: + * A handle to a source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * kern_mode :: + * See @FT_Kerning_Mode for more information. Determines the scale and + * dimension of the returned kerning vector. + * + * @output: + * akerning :: + * The kerning vector. This is either in font units, fractional pixels + * (26.6 format), or pixels for scalable formats, and in pixels for + * fixed-sizes formats. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Only horizontal layouts (left-to-right & right-to-left) are supported + * by this method. Other layouts, or more sophisticated kernings, are + * out of the scope of this API function -- they can be implemented + * through format-specific interfaces. + * + * Kerning for OpenType fonts implemented in a 'GPOS' table is not + * supported; use @FT_HAS_KERNING to find out whether a font has data + * that can be extracted with `FT_Get_Kerning`. + */ FT_EXPORT( FT_Error ) FT_Get_Kerning( FT_Face face, FT_UInt left_glyph, @@ -3451,39 +3473,42 @@ FT_BEGIN_HEADER FT_Vector *akerning ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Track_Kerning */ - /* */ - /* <Description> */ - /* Return the track kerning for a given face object at a given size. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* point_size :: The point size in 16.16 fractional points. */ - /* */ - /* degree :: The degree of tightness. Increasingly negative */ - /* values represent tighter track kerning, while */ - /* increasingly positive values represent looser track */ - /* kerning. Value zero means no track kerning. */ - /* */ - /* <Output> */ - /* akerning :: The kerning in 16.16 fractional points, to be */ - /* uniformly applied between all glyphs. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Currently, only the Type~1 font driver supports track kerning, */ - /* using data from AFM files (if attached with @FT_Attach_File or */ - /* @FT_Attach_Stream). */ - /* */ - /* Only very few AFM files come with track kerning data; please refer */ - /* to Adobe's AFM specification for more details. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Track_Kerning + * + * @description: + * Return the track kerning for a given face object at a given size. + * + * @input: + * face :: + * A handle to a source face object. + * + * point_size :: + * The point size in 16.16 fractional points. + * + * degree :: + * The degree of tightness. Increasingly negative values represent + * tighter track kerning, while increasingly positive values represent + * looser track kerning. Value zero means no track kerning. + * + * @output: + * akerning :: + * The kerning in 16.16 fractional points, to be uniformly applied + * between all glyphs. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Currently, only the Type~1 font driver supports track kerning, using + * data from AFM files (if attached with @FT_Attach_File or + * @FT_Attach_Stream). + * + * Only very few AFM files come with track kerning data; please refer to + * Adobe's AFM specification for more details. + */ FT_EXPORT( FT_Error ) FT_Get_Track_Kerning( FT_Face face, FT_Fixed point_size, @@ -3491,45 +3516,46 @@ FT_BEGIN_HEADER FT_Fixed* akerning ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII name of a given glyph in a face. This only */ - /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* buffer_max :: The maximum number of bytes available in the */ - /* buffer. */ - /* */ - /* <Output> */ - /* buffer :: A pointer to a target buffer where the name is */ - /* copied to. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error is returned if the face doesn't provide glyph names or if */ - /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' is set to~0 to indicate an empty name. */ - /* */ - /* The glyph name is truncated to fit within the buffer if it is too */ - /* long. The returned string is always zero-terminated. */ - /* */ - /* Be aware that FreeType reorders glyph indices internally so that */ - /* glyph index~0 always corresponds to the `missing glyph' (called */ - /* `.notdef'). */ - /* */ - /* This function always returns an error if the config macro */ - /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Glyph_Name + * + * @description: + * Retrieve the ASCII name of a given glyph in a face. This only works + * for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. + * + * @input: + * face :: + * A handle to a source face object. + * + * glyph_index :: + * The glyph index. + * + * buffer_max :: + * The maximum number of bytes available in the buffer. + * + * @output: + * buffer :: + * A pointer to a target buffer where the name is copied to. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An error is returned if the face doesn't provide glyph names or if the + * glyph index is invalid. In all cases of failure, the first byte of + * `buffer` is set to~0 to indicate an empty name. + * + * The glyph name is truncated to fit within the buffer if it is too + * long. The returned string is always zero-terminated. + * + * Be aware that FreeType reorders glyph indices internally so that glyph + * index~0 always corresponds to the 'missing glyph' (called '.notdef'). + * + * This function always returns an error if the config macro + * `FT_CONFIG_OPTION_NO_GLYPH_NAMES` is not defined in `ftoption.h`. + */ FT_EXPORT( FT_Error ) FT_Get_Glyph_Name( FT_Face face, FT_UInt glyph_index, @@ -3537,107 +3563,109 @@ FT_BEGIN_HEADER FT_UInt buffer_max ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Postscript_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII PostScript name of a given face, if available. */ - /* This only works with PostScript, TrueType, and OpenType fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to the face's PostScript name. NULL if unavailable. */ - /* */ - /* <Note> */ - /* The returned pointer is owned by the face and is destroyed with */ - /* it. */ - /* */ - /* For variation fonts, this string changes if you select a different */ - /* instance, and you have to call `FT_Get_PostScript_Name' again to */ - /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */ - /* PostScript Names for Fonts Using OpenType Font Variations'. */ - /* */ - /* https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html */ - /* */ - /* [Since 2.9] Special PostScript names for named instances are only */ - /* returned if the named instance is set with @FT_Set_Named_Instance */ - /* (and the font has corresponding entries in its `fvar' table). If */ - /* @FT_IS_VARIATION returns true, the algorithmically derived */ - /* PostScript name is provided, not looking up special entries for */ - /* named instances. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Postscript_Name + * + * @description: + * Retrieve the ASCII PostScript name of a given face, if available. + * This only works with PostScript, TrueType, and OpenType fonts. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * A pointer to the face's PostScript name. `NULL` if unavailable. + * + * @note: + * The returned pointer is owned by the face and is destroyed with it. + * + * For variation fonts, this string changes if you select a different + * instance, and you have to call `FT_Get_PostScript_Name` again to + * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating + * PostScript Names for Fonts Using OpenType Font Variations'. + * + * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html + * + * [Since 2.9] Special PostScript names for named instances are only + * returned if the named instance is set with @FT_Set_Named_Instance (and + * the font has corresponding entries in its 'fvar' table). If + * @FT_IS_VARIATION returns true, the algorithmically derived PostScript + * name is provided, not looking up special entries for named instances. + */ FT_EXPORT( const char* ) FT_Get_Postscript_Name( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap by its encoding tag (as listed in */ - /* `freetype.h'). */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* encoding :: A handle to the selected encoding. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if no charmap in the face */ - /* corresponds to the encoding queried here. */ - /* */ - /* Because many fonts contain more than a single cmap for Unicode */ - /* encoding, this function has some special code to select the one */ - /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ - /* preferred to a UCS-2 cmap). It is thus preferable to */ - /* @FT_Set_Charmap in this case. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Select_Charmap + * + * @description: + * Select a given charmap by its encoding tag (as listed in + * `freetype.h`). + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * encoding :: + * A handle to the selected encoding. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function returns an error if no charmap in the face corresponds + * to the encoding queried here. + * + * Because many fonts contain more than a single cmap for Unicode + * encoding, this function has some special code to select the one that + * covers Unicode best ('best' in the sense that a UCS-4 cmap is + * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap + * in this case. + */ FT_EXPORT( FT_Error ) FT_Select_Charmap( FT_Face face, FT_Encoding encoding ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap for character code to glyph index mapping. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the selected charmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the `face->charmaps' */ - /* table). */ - /* */ - /* It also fails if an OpenType type~14 charmap is selected (which */ - /* doesn't map character codes to glyph indices at all). */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Charmap + * + * @description: + * Select a given charmap for character code to glyph index mapping. + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * charmap :: + * A handle to the selected charmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function returns an error if the charmap is not part of the face + * (i.e., if it is not listed in the `face->charmaps` table). + * + * It also fails if an OpenType type~14 charmap is selected (which + * doesn't map character codes to glyph indices at all). + */ FT_EXPORT( FT_Error ) FT_Set_Charmap( FT_Face face, FT_CharMap charmap ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Get_Charmap_Index @@ -3651,139 +3679,143 @@ FT_BEGIN_HEADER * * @return: * The index into the array of character maps within the face to which - * `charmap' belongs. If an error occurs, -1 is returned. + * `charmap` belongs. If an error occurs, -1 is returned. * */ FT_EXPORT( FT_Int ) FT_Get_Charmap_Index( FT_CharMap charmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Char_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code. This function */ - /* uses the currently selected charmap to do the mapping. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within the */ - /* file. This is done to ensure that value~0 always corresponds to */ - /* the `missing glyph'. If the first glyph is not named `.notdef', */ - /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ - /* the glyph ID~0 position, and whatever was there will be moved to */ - /* the position `.notdef' had. For Type~1 fonts, if there is no */ - /* `.notdef' glyph at all, then one will be created at index~0 and */ - /* whatever was there will be moved to the last index -- Type~42 */ - /* fonts are considered invalid under this condition. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Char_Index + * + * @description: + * Return the glyph index of a given character code. This function uses + * the currently selected charmap to do the mapping. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character code. + * + * @return: + * The glyph index. 0~means 'undefined character code'. + * + * @note: + * If you use FreeType to manipulate the contents of font files directly, + * be aware that the glyph index returned by this function doesn't always + * correspond to the internal indices used within the file. This is done + * to ensure that value~0 always corresponds to the 'missing glyph'. If + * the first glyph is not named '.notdef', then for Type~1 and Type~42 + * fonts, '.notdef' will be moved into the glyph ID~0 position, and + * whatever was there will be moved to the position '.notdef' had. For + * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be + * created at index~0 and whatever was there will be moved to the last + * index -- Type~42 fonts are considered invalid under this condition. + */ FT_EXPORT( FT_UInt ) FT_Get_Char_Index( FT_Face face, FT_ULong charcode ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_First_Char */ - /* */ - /* <Description> */ - /* Return the first character code in the current charmap of a given */ - /* face, together with its corresponding glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of first character code. 0~if charmap is */ - /* empty. */ - /* */ - /* <Return> */ - /* The charmap's first character code. */ - /* */ - /* <Note> */ - /* You should use this function together with @FT_Get_Next_Char to */ - /* parse all character codes available in a given charmap. The code */ - /* should look like this: */ - /* */ - /* { */ - /* FT_ULong charcode; */ - /* FT_UInt gindex; */ - /* */ - /* */ - /* charcode = FT_Get_First_Char( face, &gindex ); */ - /* while ( gindex != 0 ) */ - /* { */ - /* ... do something with (charcode,gindex) pair ... */ - /* */ - /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ - /* } */ - /* } */ - /* */ - /* Be aware that character codes can have values up to 0xFFFFFFFF; */ - /* this might happen for non-Unicode or malformed cmaps. However, */ - /* even with regular Unicode encoding, so-called `last resort fonts' */ - /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */ - /* normally have entries for all Unicode characters up to 0x1FFFFF, */ - /* which can cause *a lot* of iterations. */ - /* */ - /* Note that `*agindex' is set to~0 if the charmap is empty. The */ - /* result itself can be~0 in two cases: if the charmap is empty or */ - /* if the value~0 is the first valid character code. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_First_Char + * + * @description: + * Return the first character code in the current charmap of a given + * face, together with its corresponding glyph index. + * + * @input: + * face :: + * A handle to the source face object. + * + * @output: + * agindex :: + * Glyph index of first character code. 0~if charmap is empty. + * + * @return: + * The charmap's first character code. + * + * @note: + * You should use this function together with @FT_Get_Next_Char to parse + * all character codes available in a given charmap. The code should + * look like this: + * + * ``` + * FT_ULong charcode; + * FT_UInt gindex; + * + * + * charcode = FT_Get_First_Char( face, &gindex ); + * while ( gindex != 0 ) + * { + * ... do something with (charcode,gindex) pair ... + * + * charcode = FT_Get_Next_Char( face, charcode, &gindex ); + * } + * ``` + * + * Be aware that character codes can have values up to 0xFFFFFFFF; this + * might happen for non-Unicode or malformed cmaps. However, even with + * regular Unicode encoding, so-called 'last resort fonts' (using SFNT + * cmap format 13, see function @FT_Get_CMap_Format) normally have + * entries for all Unicode characters up to 0x1FFFFF, which can cause *a + * lot* of iterations. + * + * Note that `*agindex` is set to~0 if the charmap is empty. The result + * itself can be~0 in two cases: if the charmap is empty or if the + * value~0 is the first valid character code. + */ FT_EXPORT( FT_ULong ) FT_Get_First_Char( FT_Face face, FT_UInt *agindex ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Next_Char */ - /* */ - /* <Description> */ - /* Return the next character code in the current charmap of a given */ - /* face following the value `char_code', as well as the corresponding */ - /* glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* char_code :: The starting character code. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of next character code. 0~if charmap */ - /* is empty. */ - /* */ - /* <Return> */ - /* The charmap's next character code. */ - /* */ - /* <Note> */ - /* You should use this function with @FT_Get_First_Char to walk */ - /* over all character codes available in a given charmap. See the */ - /* note for that function for a simple code example. */ - /* */ - /* Note that `*agindex' is set to~0 when there are no more codes in */ - /* the charmap. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Next_Char + * + * @description: + * Return the next character code in the current charmap of a given face + * following the value `char_code`, as well as the corresponding glyph + * index. + * + * @input: + * face :: + * A handle to the source face object. + * + * char_code :: + * The starting character code. + * + * @output: + * agindex :: + * Glyph index of next character code. 0~if charmap is empty. + * + * @return: + * The charmap's next character code. + * + * @note: + * You should use this function with @FT_Get_First_Char to walk over all + * character codes available in a given charmap. See the note for that + * function for a simple code example. + * + * Note that `*agindex` is set to~0 when there are no more codes in the + * charmap. + */ FT_EXPORT( FT_ULong ) FT_Get_Next_Char( FT_Face face, FT_ULong char_code, FT_UInt *agindex ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Face_Properties @@ -3791,27 +3823,26 @@ FT_BEGIN_HEADER * @description: * Set or override certain (library or module-wide) properties on a * face-by-face basis. Useful for finer-grained control and avoiding - * locks on shared structures (threads can modify their own faces as - * they see fit). + * locks on shared structures (threads can modify their own faces as they + * see fit). * - * Contrary to @FT_Property_Set, this function uses @FT_Parameter so - * that you can pass multiple properties to the target face in one call. - * Note that only a subset of the available properties can be - * controlled. + * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that + * you can pass multiple properties to the target face in one call. Note + * that only a subset of the available properties can be controlled. * * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the - * property `no-stem-darkening' provided by the `autofit', `cff', - * `type1', and `t1cid' modules; see @no-stem-darkening). + * property `no-stem-darkening` provided by the 'autofit', 'cff', + * 'type1', and 't1cid' modules; see @no-stem-darkening). * * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding * to function @FT_Library_SetLcdFilterWeights). * * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID - * `random' operator, corresponding to the `random-seed' property - * provided by the `cff', `type1', and `t1cid' modules; see + * 'random' operator, corresponding to the `random-seed` property + * provided by the 'cff', 'type1', and 't1cid' modules; see * @random-seed). * - * Pass NULL as `data' in @FT_Parameter for a given tag to reset the + * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the * option and use the library or module default again. * * @input: @@ -3822,17 +3853,17 @@ FT_BEGIN_HEADER * The number of properties that follow. * * properties :: - * A handle to an @FT_Parameter array with `num_properties' elements. + * A handle to an @FT_Parameter array with `num_properties` elements. * * @return: * FreeType error code. 0~means success. * - * @note: - * Here an example that sets three properties. You must define - * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples + * @example: + * Here is an example that sets three properties. You must define + * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples * work. * - * { + * ``` * FT_Parameter property1; * FT_Bool darken_stems = 1; * @@ -3858,11 +3889,11 @@ FT_BEGIN_HEADER * property3.data = &random_seed; * * FT_Face_Properties( face, 3, properties ); - * } + * ``` * * The next example resets a single property to its default value. * - * { + * ``` * FT_Parameter property; * * @@ -3870,7 +3901,7 @@ FT_BEGIN_HEADER * property.data = NULL; * * FT_Face_Properties( face, 1, &property ); - * } + * ``` * * @since: * 2.8 @@ -3882,37 +3913,40 @@ FT_BEGIN_HEADER FT_Parameter* properties ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Name_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given glyph name. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* glyph_name :: The glyph name. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Name_Index + * + * @description: + * Return the glyph index of a given glyph name. + * + * @input: + * face :: + * A handle to the source face object. + * + * glyph_name :: + * The glyph name. + * + * @return: + * The glyph index. 0~means 'undefined character code'. + */ FT_EXPORT( FT_UInt ) FT_Get_Name_Index( FT_Face face, FT_String* glyph_name ); - /************************************************************************* + /************************************************************************** * - * @macro: + * @enum: * FT_SUBGLYPH_FLAG_XXX * * @description: - * A list of constants describing subglyphs. Please refer to the - * `glyf' table description in the OpenType specification for the - * meaning of the various flags (which get synthesized for - * non-OpenType subglyphs). + * A list of constants describing subglyphs. Please refer to the 'glyf' + * table description in the OpenType specification for the meaning of the + * various flags (which get synthesized for non-OpenType subglyphs). + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description * * @values: * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: @@ -3933,112 +3967,283 @@ FT_BEGIN_HEADER #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 - /************************************************************************* + /************************************************************************** + * + * @function: + * FT_Get_SubGlyph_Info + * + * @description: + * Retrieve a description of a given subglyph. Only use it if + * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned + * otherwise. + * + * @input: + * glyph :: + * The source glyph slot. + * + * sub_index :: + * The index of the subglyph. Must be less than + * `glyph->num_subglyphs`. + * + * @output: + * p_index :: + * The glyph index of the subglyph. + * + * p_flags :: + * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * + * p_arg1 :: + * The subglyph's first argument (if any). + * + * p_arg2 :: + * The subglyph's second argument (if any). + * + * p_transform :: + * The subglyph transformation (if any). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be + * interpreted depending on the flags returned in `*p_flags`. See the + * OpenType specification for details. + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description + * + */ + FT_EXPORT( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ); + + + /************************************************************************** + * + * @section: + * layer_management + * + * @title: + * Glyph Layer Management + * + * @abstract: + * Retrieving and manipulating OpenType's 'COLR' table data. + * + * @description: + * The functions described here allow access of colored glyph layer data + * in OpenType's 'COLR' tables. + */ + + + /************************************************************************** + * + * @struct: + * FT_LayerIterator + * + * @description: + * This iterator object is needed for @FT_Get_Color_Glyph_Layer. + * + * @fields: + * num_layers :: + * The number of glyph layers for the requested glyph index. Will be + * set by @FT_Get_Color_Glyph_Layer. + * + * layer :: + * The current layer. Will be set by @FT_Get_Color_Glyph_Layer. + * + * p :: + * An opaque pointer into 'COLR' table data. The caller must set this + * to `NULL` before the first call of @FT_Get_Color_Glyph_Layer. + */ + typedef struct FT_LayerIterator_ + { + FT_UInt num_layers; + FT_UInt layer; + FT_Byte* p; + + } FT_LayerIterator; + + + /************************************************************************** * - * @func: - * FT_Get_SubGlyph_Info + * @function: + * FT_Get_Color_Glyph_Layer * * @description: - * Retrieve a description of a given subglyph. Only use it if - * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is - * returned otherwise. + * This is an interface to the 'COLR' table in OpenType fonts to + * iteratively retrieve the colored glyph layers associated with the + * current glyph slot. * - * @input: - * glyph :: - * The source glyph slot. + * https://docs.microsoft.com/en-us/typography/opentype/spec/colr * - * sub_index :: - * The index of the subglyph. Must be less than - * `glyph->num_subglyphs'. + * The glyph layer data for a given glyph index, if present, provides an + * alternative, multi-colour glyph representation: Instead of rendering + * the outline or bitmap with the given glyph index, glyphs with the + * indices and colors returned by this function are rendered layer by + * layer. * - * @output: - * p_index :: - * The glyph index of the subglyph. + * The returned elements are ordered in the z~direction from bottom to + * top; the 'n'th element should be rendered with the associated palette + * color and blended on top of the already rendered layers (elements 0, + * 1, ..., n-1). * - * p_flags :: - * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * @input: + * face :: + * A handle to the parent face object. * - * p_arg1 :: - * The subglyph's first argument (if any). + * base_glyph :: + * The glyph index the colored glyph layers are associated with. * - * p_arg2 :: - * The subglyph's second argument (if any). + * @inout: + * iterator :: + * An @FT_LayerIterator object. For the first call you should set + * `iterator->p` to `NULL`. For all following calls, simply use the + * same object again. * - * p_transform :: - * The subglyph transformation (if any). + * @output: + * aglyph_index :: + * The glyph index of the current layer. + * + * acolor_index :: + * The color index into the font face's color palette of the current + * layer. The value 0xFFFF is special; it doesn't reference a palette + * entry but indicates that the text foreground color should be used + * instead (to be set up by the application outside of FreeType). + * + * The color palette can be retrieved with @FT_Palette_Select. * * @return: - * FreeType error code. 0~means success. + * Value~1 if everything is OK. If there are no more layers (or if there + * are no layers at all), value~0 gets returned. In case of an error, + * value~0 is returned also. * * @note: - * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be - * interpreted depending on the flags returned in `*p_flags'. See the - * OpenType specification for details. + * This function is necessary if you want to handle glyph layers by + * yourself. In particular, functions that operate with @FT_GlyphRec + * objects (like @FT_Get_Glyph or @FT_Glyph_To_Bitmap) don't have access + * to this information. + * + * Note that @FT_Render_Glyph is able to handle colored glyph layers + * automatically if the @FT_LOAD_COLOR flag is passed to a previous call + * to @FT_Load_Glyph. [This is an experimental feature.] + * + * @example: + * ``` + * FT_Color* palette; + * FT_LayerIterator iterator; + * + * FT_Bool have_layers; + * FT_UInt layer_glyph_index; + * FT_UInt layer_color_index; + * + * + * error = FT_Palette_Select( face, palette_index, &palette ); + * if ( error ) + * palette = NULL; * + * iterator.p = NULL; + * have_layers = FT_Get_Color_Glyph_Layer( face, + * glyph_index, + * &layer_glyph_index, + * &layer_color_index, + * &iterator ); + * + * if ( palette && have_layers ) + * { + * do + * { + * FT_Color layer_color; + * + * + * if ( layer_color_index == 0xFFFF ) + * layer_color = text_foreground_color; + * else + * layer_color = palette[layer_color_index]; + * + * // Load and render glyph `layer_glyph_index', then + * // blend resulting pixmap (using color `layer_color') + * // with previously created pixmaps. + * + * } while ( FT_Get_Color_Glyph_Layer( face, + * glyph_index, + * &layer_glyph_index, + * &layer_color_index, + * &iterator ) ); + * } + * ``` */ - FT_EXPORT( FT_Error ) - FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, - FT_UInt sub_index, - FT_Int *p_index, - FT_UInt *p_flags, - FT_Int *p_arg1, - FT_Int *p_arg2, - FT_Matrix *p_transform ); + FT_EXPORT( FT_Bool ) + FT_Get_Color_Glyph_Layer( FT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FSTYPE_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `fsType' field of the OS/2 table */ - /* in a TrueType or OpenType font and the `FSType' entry in a */ - /* PostScript font. These bit flags are returned by */ - /* @FT_Get_FSType_Flags; they inform client applications of embedding */ - /* and subsetting restrictions associated with a font. */ - /* */ - /* See */ - /* https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */ - /* for more details. */ - /* */ - /* <Values> */ - /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ - /* Fonts with no fsType bit set may be embedded and permanently */ - /* installed on the remote system by an application. */ - /* */ - /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ - /* Fonts that have only this bit set must not be modified, embedded */ - /* or exchanged in any manner without first obtaining permission of */ - /* the font software copyright owner. */ - /* */ - /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ - /* The font may be embedded and temporarily loaded on the remote */ - /* system. Documents containing Preview & Print fonts must be */ - /* opened `read-only'; no edits can be applied to the document. */ - /* */ - /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ - /* The font may be embedded but must only be installed temporarily */ - /* on other systems. In contrast to Preview & Print fonts, */ - /* documents containing editable fonts may be opened for reading, */ - /* editing is permitted, and changes may be saved. */ - /* */ - /* FT_FSTYPE_NO_SUBSETTING :: */ - /* The font may not be subsetted prior to embedding. */ - /* */ - /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ - /* Only bitmaps contained in the font may be embedded; no outline */ - /* data may be embedded. If there are no bitmaps available in the */ - /* font, then the font is unembeddable. */ - /* */ - /* <Note> */ - /* The flags are ORed together, thus more than a single value can be */ - /* returned. */ - /* */ - /* While the `fsType' flags can indicate that a font may be embedded, */ - /* a license with the font vendor may be separately required to use */ - /* the font in this way. */ - /* */ + /************************************************************************** + * + * @section: + * base_interface + * + */ + + /************************************************************************** + * + * @enum: + * FT_FSTYPE_XXX + * + * @description: + * A list of bit flags used in the `fsType` field of the OS/2 table in a + * TrueType or OpenType font and the `FSType` entry in a PostScript font. + * These bit flags are returned by @FT_Get_FSType_Flags; they inform + * client applications of embedding and subsetting restrictions + * associated with a font. + * + * See + * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf + * for more details. + * + * @values: + * FT_FSTYPE_INSTALLABLE_EMBEDDING :: + * Fonts with no fsType bit set may be embedded and permanently + * installed on the remote system by an application. + * + * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: + * Fonts that have only this bit set must not be modified, embedded or + * exchanged in any manner without first obtaining permission of the + * font software copyright owner. + * + * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: + * The font may be embedded and temporarily loaded on the remote + * system. Documents containing Preview & Print fonts must be opened + * 'read-only'; no edits can be applied to the document. + * + * FT_FSTYPE_EDITABLE_EMBEDDING :: + * The font may be embedded but must only be installed temporarily on + * other systems. In contrast to Preview & Print fonts, documents + * containing editable fonts may be opened for reading, editing is + * permitted, and changes may be saved. + * + * FT_FSTYPE_NO_SUBSETTING :: + * The font may not be subsetted prior to embedding. + * + * FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: + * Only bitmaps contained in the font may be embedded; no outline data + * may be embedded. If there are no bitmaps available in the font, + * then the font is unembeddable. + * + * @note: + * The flags are ORed together, thus more than a single value can be + * returned. + * + * While the `fsType` flags can indicate that a font may be embedded, a + * license with the font vendor may be separately required to use the + * font in this way. + */ #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 @@ -4047,548 +4252,563 @@ FT_BEGIN_HEADER #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_FSType_Flags */ - /* */ - /* <Description> */ - /* Return the `fsType' flags for a font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* The `fsType' flags, see @FT_FSTYPE_XXX. */ - /* */ - /* <Note> */ - /* Use this function rather than directly reading the `fs_type' field */ - /* in the @PS_FontInfoRec structure, which is only guaranteed to */ - /* return the correct results for Type~1 fonts. */ - /* */ - /* <Since> */ - /* 2.3.8 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_FSType_Flags + * + * @description: + * Return the `fsType` flags for a font. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * The `fsType` flags, see @FT_FSTYPE_XXX. + * + * @note: + * Use this function rather than directly reading the `fs_type` field in + * the @PS_FontInfoRec structure, which is only guaranteed to return the + * correct results for Type~1 fonts. + * + * @since: + * 2.3.8 + */ FT_EXPORT( FT_UShort ) FT_Get_FSType_Flags( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_variants */ - /* */ - /* <Title> */ - /* Unicode Variation Sequences */ - /* */ - /* <Abstract> */ - /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */ - /* using the SFNT cmap format~14. */ - /* */ - /* <Description> */ - /* Many characters, especially for CJK scripts, have variant forms. */ - /* They are a sort of grey area somewhere between being totally */ - /* irrelevant and semantically distinct; for this reason, the Unicode */ - /* consortium decided to introduce Variation Sequences (VS), */ - /* consisting of a Unicode base character and a variation selector */ - /* instead of further extending the already huge number of */ - /* characters. */ - /* */ - /* Unicode maintains two different sets, namely `Standardized */ - /* Variation Sequences' and registered `Ideographic Variation */ - /* Sequences' (IVS), collected in the `Ideographic Variation */ - /* Database' (IVD). */ - /* */ - /* https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */ - /* https://unicode.org/reports/tr37/ */ - /* https://unicode.org/ivd/ */ - /* */ - /* To date (January 2017), the character with the most ideographic */ - /* variations is U+9089, having 32 such IVS. */ - /* */ - /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */ - /* 256 generic Variation Selectors are encoded in the ranges */ - /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */ - /* Selectors from the range U+E0100-U+E01EF only. */ - /* */ - /* A VS consists of the base character value followed by a single */ - /* Variation Selector. For example, to get the first variation of */ - /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */ - /* */ - /* Adobe and MS decided to support both standardized and ideographic */ - /* VS with a new cmap subtable (format~14). It is an odd subtable */ - /* because it is not a mapping of input code points to glyphs, but */ - /* contains lists of all variations supported by the font. */ - /* */ - /* A variation may be either `default' or `non-default' for a given */ - /* font. A default variation is the one you will get for that code */ - /* point if you look it up in the standard Unicode cmap. A */ - /* non-default variation is a different glyph. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * glyph_variants + * + * @title: + * Unicode Variation Sequences + * + * @abstract: + * The FreeType~2 interface to Unicode Variation Sequences (UVS), using + * the SFNT cmap format~14. + * + * @description: + * Many characters, especially for CJK scripts, have variant forms. They + * are a sort of grey area somewhere between being totally irrelevant and + * semantically distinct; for this reason, the Unicode consortium decided + * to introduce Variation Sequences (VS), consisting of a Unicode base + * character and a variation selector instead of further extending the + * already huge number of characters. + * + * Unicode maintains two different sets, namely 'Standardized Variation + * Sequences' and registered 'Ideographic Variation Sequences' (IVS), + * collected in the 'Ideographic Variation Database' (IVD). + * + * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt + * https://unicode.org/reports/tr37/ https://unicode.org/ivd/ + * + * To date (January 2017), the character with the most ideographic + * variations is U+9089, having 32 such IVS. + * + * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256 + * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F + * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the + * range U+E0100-U+E01EF only. + * + * A VS consists of the base character value followed by a single + * Variation Selector. For example, to get the first variation of + * U+9089, you have to write the character sequence `U+9089 U+E0100`. + * + * Adobe and MS decided to support both standardized and ideographic VS + * with a new cmap subtable (format~14). It is an odd subtable because + * it is not a mapping of input code points to glyphs, but contains lists + * of all variations supported by the font. + * + * A variation may be either 'default' or 'non-default' for a given font. + * A default variation is the one you will get for that code point if you + * look it up in the standard Unicode cmap. A non-default variation is a + * different glyph. + * + */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIndex */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code as modified by */ - /* the variation selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character code point in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode code point of the variation selector. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means either `undefined character code', or */ - /* `undefined selector code', or `no variation selector cmap */ - /* subtable', or `current CharMap is not Unicode'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within */ - /* the file. This is done to ensure that value~0 always corresponds */ - /* to the `missing glyph'. */ - /* */ - /* This function is only meaningful if */ - /* a) the font has a variation selector cmap sub table, */ - /* and */ - /* b) the current charmap has a Unicode encoding. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetCharVariantIndex + * + * @description: + * Return the glyph index of a given character code as modified by the + * variation selector. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character code point in Unicode. + * + * variantSelector :: + * The Unicode code point of the variation selector. + * + * @return: + * The glyph index. 0~means either 'undefined character code', or + * 'undefined selector code', or 'no variation selector cmap subtable', + * or 'current CharMap is not Unicode'. + * + * @note: + * If you use FreeType to manipulate the contents of font files directly, + * be aware that the glyph index returned by this function doesn't always + * correspond to the internal indices used within the file. This is done + * to ensure that value~0 always corresponds to the 'missing glyph'. + * + * This function is only meaningful if + * a) the font has a variation selector cmap sub table, and + * b) the current charmap has a Unicode encoding. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt ) FT_Face_GetCharVariantIndex( FT_Face face, FT_ULong charcode, FT_ULong variantSelector ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIsDefault */ - /* */ - /* <Description> */ - /* Check whether this variation of this Unicode character is the one */ - /* to be found in the `cmap'. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode codepoint of the variation selector. */ - /* */ - /* <Return> */ - /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ - /* variation selector cmap, or -1 if it is not a variation. */ - /* */ - /* <Note> */ - /* This function is only meaningful if the font has a variation */ - /* selector cmap subtable. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetCharVariantIsDefault + * + * @description: + * Check whether this variation of this Unicode character is the one to + * be found in the charmap. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character codepoint in Unicode. + * + * variantSelector :: + * The Unicode codepoint of the variation selector. + * + * @return: + * 1~if found in the standard (Unicode) cmap, 0~if found in the variation + * selector cmap, or -1 if it is not a variation. + * + * @note: + * This function is only meaningful if the font has a variation selector + * cmap subtable. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_Int ) FT_Face_GetCharVariantIsDefault( FT_Face face, FT_ULong charcode, FT_ULong variantSelector ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantSelectors */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variation selectors found */ - /* in the font. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to an array of selector code points, or NULL if there is */ - /* no valid variation selector cmap subtable. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetVariantSelectors + * + * @description: + * Return a zero-terminated list of Unicode variation selectors found in + * the font. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * A pointer to an array of selector code points, or `NULL` if there is + * no valid variation selector cmap subtable. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt32* ) FT_Face_GetVariantSelectors( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantsOfChar */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variation selectors found */ - /* for the specified character code. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* <Return> */ - /* A pointer to an array of variation selector code points that are */ - /* active for the given character, or NULL if the corresponding list */ - /* is empty. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetVariantsOfChar + * + * @description: + * Return a zero-terminated list of Unicode variation selectors found for + * the specified character code. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character codepoint in Unicode. + * + * @return: + * A pointer to an array of variation selector code points that are + * active for the given character, or `NULL` if the corresponding list is + * empty. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt32* ) FT_Face_GetVariantsOfChar( FT_Face face, FT_ULong charcode ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharsOfVariant */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode character codes found for */ - /* the specified variation selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* variantSelector :: */ - /* The variation selector code point in Unicode. */ - /* */ - /* <Return> */ - /* A list of all the code points that are specified by this selector */ - /* (both default and non-default codes are returned) or NULL if there */ - /* is no valid cmap or the variation selector is invalid. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetCharsOfVariant + * + * @description: + * Return a zero-terminated list of Unicode character codes found for the + * specified variation selector. + * + * @input: + * face :: + * A handle to the source face object. + * + * variantSelector :: + * The variation selector code point in Unicode. + * + * @return: + * A list of all the code points that are specified by this selector + * (both default and non-default codes are returned) or `NULL` if there + * is no valid cmap or the variation selector is invalid. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt32* ) FT_Face_GetCharsOfVariant( FT_Face face, FT_ULong variantSelector ); - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /* <Title> */ - /* Computations */ - /* */ - /* <Abstract> */ - /* Crunching fixed numbers and vectors. */ - /* */ - /* <Description> */ - /* This section contains various functions used to perform */ - /* computations on 16.16 fixed-float numbers or 2d vectors. */ - /* */ - /* <Order> */ - /* FT_MulDiv */ - /* FT_MulFix */ - /* FT_DivFix */ - /* FT_RoundFix */ - /* FT_CeilFix */ - /* FT_FloorFix */ - /* FT_Vector_Transform */ - /* FT_Matrix_Multiply */ - /* FT_Matrix_Invert */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * computations + * + * @title: + * Computations + * + * @abstract: + * Crunching fixed numbers and vectors. + * + * @description: + * This section contains various functions used to perform computations + * on 16.16 fixed-float numbers or 2d vectors. + * + * **Attention**: Most arithmetic functions take `FT_Long` as arguments. + * For historical reasons, FreeType was designed under the assumption + * that `FT_Long` is a 32-bit integer; results can thus be undefined if + * the arguments don't fit into 32 bits. + * + * @order: + * FT_MulDiv + * FT_MulFix + * FT_DivFix + * FT_RoundFix + * FT_CeilFix + * FT_FloorFix + * FT_Vector_Transform + * FT_Matrix_Multiply + * FT_Matrix_Invert + * + */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv */ - /* */ - /* <Description> */ - /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */ - /* intermediate integer whenever necessary. */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* */ - /* b :: The second multiplier. */ - /* */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_MulDiv + * + * @description: + * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate + * integer whenever necessary. + * + * This function isn't necessarily as fast as some processor-specific + * operations, but is at least completely portable. + * + * @input: + * a :: + * The first multiplier. + * + * b :: + * The second multiplier. + * + * c :: + * The divisor. + * + * @return: + * The result of `(a*b)/c`. This function never traps when trying to + * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on + * the signs of `a` and `b`. + */ FT_EXPORT( FT_Long ) FT_MulDiv( FT_Long a, FT_Long b, FT_Long c ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulFix */ - /* */ - /* <Description> */ - /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */ - /* multiply a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* <Return> */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* <Note> */ - /* This function has been optimized for the case where the absolute */ - /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ - /* As this happens mainly when scaling from notional units to */ - /* fractional pixels in FreeType, it resulted in noticeable speed */ - /* improvements between versions 2.x and 1.x. */ - /* */ - /* As a conclusion, always try to place a 16.16 factor as the */ - /* _second_ argument of this function; this can make a great */ - /* difference. */ - /* */ + /************************************************************************** + * + * @function: + * FT_MulFix + * + * @description: + * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to + * multiply a given value by a 16.16 fixed-point factor. + * + * @input: + * a :: + * The first multiplier. + * + * b :: + * The second multiplier. Use a 16.16 factor here whenever possible + * (see note below). + * + * @return: + * The result of `(a*b)/0x10000`. + * + * @note: + * This function has been optimized for the case where the absolute value + * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this + * happens mainly when scaling from notional units to fractional pixels + * in FreeType, it resulted in noticeable speed improvements between + * versions 2.x and 1.x. + * + * As a conclusion, always try to place a 16.16 factor as the _second_ + * argument of this function; this can make a great difference. + */ FT_EXPORT( FT_Long ) FT_MulFix( FT_Long a, FT_Long b ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_DivFix */ - /* */ - /* <Description> */ - /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */ - /* divide a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The numerator. */ - /* */ - /* b :: The denominator. Use a 16.16 factor here. */ - /* */ - /* <Return> */ - /* The result of `(a*0x10000)/b'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_DivFix + * + * @description: + * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to + * divide a given value by a 16.16 fixed-point factor. + * + * @input: + * a :: + * The numerator. + * + * b :: + * The denominator. Use a 16.16 factor here. + * + * @return: + * The result of `(a*0x10000)/b`. + */ FT_EXPORT( FT_Long ) FT_DivFix( FT_Long a, FT_Long b ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_RoundFix */ - /* */ - /* <Description> */ - /* Round a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number to be rounded. */ - /* */ - /* <Return> */ - /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */ - /* from zero. */ - /* */ - /* <Note> */ - /* The function uses wrap-around arithmetic. */ - /* */ + /************************************************************************** + * + * @function: + * FT_RoundFix + * + * @description: + * Round a 16.16 fixed number. + * + * @input: + * a :: + * The number to be rounded. + * + * @return: + * `a` rounded to the nearest 16.16 fixed integer, halfway cases away + * from zero. + * + * @note: + * The function uses wrap-around arithmetic. + */ FT_EXPORT( FT_Fixed ) FT_RoundFix( FT_Fixed a ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_CeilFix */ - /* */ - /* <Description> */ - /* Compute the smallest following integer of a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the ceiling function is to be computed. */ - /* */ - /* <Return> */ - /* `a' rounded towards plus infinity. */ - /* */ - /* <Note> */ - /* The function uses wrap-around arithmetic. */ - /* */ + /************************************************************************** + * + * @function: + * FT_CeilFix + * + * @description: + * Compute the smallest following integer of a 16.16 fixed number. + * + * @input: + * a :: + * The number for which the ceiling function is to be computed. + * + * @return: + * `a` rounded towards plus infinity. + * + * @note: + * The function uses wrap-around arithmetic. + */ FT_EXPORT( FT_Fixed ) FT_CeilFix( FT_Fixed a ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_FloorFix */ - /* */ - /* <Description> */ - /* Compute the largest previous integer of a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the floor function is to be computed. */ - /* */ - /* <Return> */ - /* `a' rounded towards minus infinity. */ - /* */ + /************************************************************************** + * + * @function: + * FT_FloorFix + * + * @description: + * Compute the largest previous integer of a 16.16 fixed number. + * + * @input: + * a :: + * The number for which the floor function is to be computed. + * + * @return: + * `a` rounded towards minus infinity. + */ FT_EXPORT( FT_Fixed ) FT_FloorFix( FT_Fixed a ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Vector_Transform */ - /* */ - /* <Description> */ - /* Transform a single vector through a 2x2 matrix. */ - /* */ - /* <InOut> */ - /* vector :: The target vector to transform. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* <Note> */ - /* The result is undefined if either `vector' or `matrix' is invalid. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Vector_Transform + * + * @description: + * Transform a single vector through a 2x2 matrix. + * + * @inout: + * vector :: + * The target vector to transform. + * + * @input: + * matrix :: + * A pointer to the source 2x2 matrix. + * + * @note: + * The result is undefined if either `vector` or `matrix` is invalid. + */ FT_EXPORT( void ) - FT_Vector_Transform( FT_Vector* vec, + FT_Vector_Transform( FT_Vector* vector, const FT_Matrix* matrix ); - /*************************************************************************/ - /* */ - /* <Section> */ - /* version */ - /* */ - /* <Title> */ - /* FreeType Version */ - /* */ - /* <Abstract> */ - /* Functions and macros related to FreeType versions. */ - /* */ - /* <Description> */ - /* Note that those functions and macros are of limited use because */ - /* even a new release of FreeType with only documentation changes */ - /* increases the version number. */ - /* */ - /* <Order> */ - /* FT_Library_Version */ - /* */ - /* FREETYPE_MAJOR */ - /* FREETYPE_MINOR */ - /* FREETYPE_PATCH */ - /* */ - /* FT_Face_CheckTrueTypePatents */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* FREETYPE_XXX */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * version + * + * @title: + * FreeType Version + * + * @abstract: + * Functions and macros related to FreeType versions. + * + * @description: + * Note that those functions and macros are of limited use because even a + * new release of FreeType with only documentation changes increases the + * version number. + * + * @order: + * FT_Library_Version + * + * FREETYPE_MAJOR + * FREETYPE_MINOR + * FREETYPE_PATCH + * + * FT_Face_CheckTrueTypePatents + * FT_Face_SetUnpatentedHinting + * + */ - /************************************************************************* + /************************************************************************** * * @enum: * FREETYPE_XXX * * @description: - * These three macros identify the FreeType source code version. - * Use @FT_Library_Version to access them at runtime. + * These three macros identify the FreeType source code version. Use + * @FT_Library_Version to access them at runtime. * * @values: - * FREETYPE_MAJOR :: The major version number. - * FREETYPE_MINOR :: The minor version number. - * FREETYPE_PATCH :: The patch level. + * FREETYPE_MAJOR :: + * The major version number. + * FREETYPE_MINOR :: + * The minor version number. + * FREETYPE_PATCH :: + * The patch level. * * @note: - * The version number of FreeType if built as a dynamic link library - * with the `libtool' package is _not_ controlled by these three - * macros. + * The version number of FreeType if built as a dynamic link library with + * the 'libtool' package is _not_ controlled by these three macros. * */ #define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 9 -#define FREETYPE_PATCH 1 +#define FREETYPE_MINOR 10 +#define FREETYPE_PATCH 0 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Library_Version */ - /* */ - /* <Description> */ - /* Return the version of the FreeType library being used. This is */ - /* useful when dynamically linking to the library, since one cannot */ - /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ - /* @FREETYPE_PATCH. */ - /* */ - /* <Input> */ - /* library :: A source library handle. */ - /* */ - /* <Output> */ - /* amajor :: The major version number. */ - /* */ - /* aminor :: The minor version number. */ - /* */ - /* apatch :: The patch version number. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' argument is because */ - /* certain programs implement library initialization in a custom way */ - /* that doesn't use @FT_Init_FreeType. */ - /* */ - /* In such cases, the library version might not be available before */ - /* the library object has been created. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Library_Version + * + * @description: + * Return the version of the FreeType library being used. This is useful + * when dynamically linking to the library, since one cannot use the + * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH. + * + * @input: + * library :: + * A source library handle. + * + * @output: + * amajor :: + * The major version number. + * + * aminor :: + * The minor version number. + * + * apatch :: + * The patch version number. + * + * @note: + * The reason why this function takes a `library` argument is because + * certain programs implement library initialization in a custom way that + * doesn't use @FT_Init_FreeType. + * + * In such cases, the library version might not be available before the + * library object has been created. + */ FT_EXPORT( void ) FT_Library_Version( FT_Library library, FT_Int *amajor, @@ -4596,52 +4816,55 @@ FT_BEGIN_HEADER FT_Int *apatch ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_CheckTrueTypePatents */ - /* */ - /* <Description> */ - /* Deprecated, does nothing. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* <Return> */ - /* Always returns false. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_CheckTrueTypePatents + * + * @description: + * Deprecated, does nothing. + * + * @input: + * face :: + * A face handle. + * + * @return: + * Always returns false. + * + * @note: + * Since May 2010, TrueType hinting is no longer patented. + * + * @since: + * 2.3.5 + */ FT_EXPORT( FT_Bool ) FT_Face_CheckTrueTypePatents( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* <Description> */ - /* Deprecated, does nothing. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* value :: New boolean setting. */ - /* */ - /* <Return> */ - /* Always returns false. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_SetUnpatentedHinting + * + * @description: + * Deprecated, does nothing. + * + * @input: + * face :: + * A face handle. + * + * value :: + * New boolean setting. + * + * @return: + * Always returns false. + * + * @note: + * Since May 2010, TrueType hinting is no longer patented. + * + * @since: + * 2.3.5 + */ FT_EXPORT( FT_Bool ) FT_Face_SetUnpatentedHinting( FT_Face face, FT_Bool value ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h index f78e8b1a9d1..95c38f92bdd 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftadvanc.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftadvanc.h */ -/* */ -/* Quick computation of advance widths (specification only). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftadvanc.h + * + * Quick computation of advance widths (specification only). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTADVANC_H_ @@ -56,68 +56,67 @@ FT_BEGIN_HEADER */ - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_ADVANCE_FLAG_FAST_ONLY */ - /* */ - /* <Description> */ - /* A bit-flag to be OR-ed with the `flags' parameter of the */ - /* @FT_Get_Advance and @FT_Get_Advances functions. */ - /* */ - /* If set, it indicates that you want these functions to fail if the */ - /* corresponding hinting mode or font driver doesn't allow for very */ - /* quick advance computation. */ - /* */ - /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */ - /* or light-hinted can have their advance width computed very */ - /* quickly. */ - /* */ - /* Normal and bytecode hinted modes that require loading, scaling, */ - /* and hinting of the glyph outline, are extremely slow by */ - /* comparison. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_ADVANCE_FLAG_FAST_ONLY + * + * @description: + * A bit-flag to be OR-ed with the `flags` parameter of the + * @FT_Get_Advance and @FT_Get_Advances functions. + * + * If set, it indicates that you want these functions to fail if the + * corresponding hinting mode or font driver doesn't allow for very quick + * advance computation. + * + * Typically, glyphs that are either unscaled, unhinted, bitmapped, or + * light-hinted can have their advance width computed very quickly. + * + * Normal and bytecode hinted modes that require loading, scaling, and + * hinting of the glyph outline, are extremely slow by comparison. + */ #define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advance */ - /* */ - /* <Description> */ - /* Retrieve the advance value of a given glyph outline in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph, used to determine what kind */ - /* of advances you need. */ - /* <Output> */ - /* padvance :: The advance value. If scaling is performed (based on */ - /* the value of `load_flags'), the advance value is in */ - /* 16.16 format. Otherwise, it is in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */ - /* vertical advance corresponding to a vertical layout. */ - /* Otherwise, it is the horizontal advance in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* A scaled advance is returned in 16.16 format but isn't transformed */ - /* by the affine transformation specified by @FT_Set_Transform. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Advance + * + * @description: + * Retrieve the advance value of a given glyph outline in an @FT_Face. + * + * @input: + * face :: + * The source @FT_Face handle. + * + * gindex :: + * The glyph index. + * + * load_flags :: + * A set of bit flags similar to those used when calling + * @FT_Load_Glyph, used to determine what kind of advances you need. + * @output: + * padvance :: + * The advance value. If scaling is performed (based on the value of + * `load_flags`), the advance value is in 16.16 format. Otherwise, it + * is in font units. + * + * If @FT_LOAD_VERTICAL_LAYOUT is set, this is the vertical advance + * corresponding to a vertical layout. Otherwise, it is the horizontal + * advance in a horizontal layout. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if + * the corresponding font backend doesn't have a quick way to retrieve + * the advances. + * + * A scaled advance is returned in 16.16 format but isn't transformed by + * the affine transformation specified by @FT_Set_Transform. + */ FT_EXPORT( FT_Error ) FT_Get_Advance( FT_Face face, FT_UInt gindex, @@ -125,50 +124,52 @@ FT_BEGIN_HEADER FT_Fixed *padvance ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advances */ - /* */ - /* <Description> */ - /* Retrieve the advance values of several glyph outlines in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* start :: The first glyph index. */ - /* */ - /* count :: The number of advance values you want to retrieve. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph. */ - /* */ - /* <Output> */ - /* padvance :: The advance values. This array, to be provided by the */ - /* caller, must contain at least `count' elements. */ - /* */ - /* If scaling is performed (based on the value of */ - /* `load_flags'), the advance values are in 16.16 format. */ - /* Otherwise, they are in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */ - /* vertical advances corresponding to a vertical layout. */ - /* Otherwise, they are the horizontal advances in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* Scaled advances are returned in 16.16 format but aren't */ - /* transformed by the affine transformation specified by */ - /* @FT_Set_Transform. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Advances + * + * @description: + * Retrieve the advance values of several glyph outlines in an @FT_Face. + * + * @input: + * face :: + * The source @FT_Face handle. + * + * start :: + * The first glyph index. + * + * count :: + * The number of advance values you want to retrieve. + * + * load_flags :: + * A set of bit flags similar to those used when calling + * @FT_Load_Glyph. + * + * @output: + * padvance :: + * The advance values. This array, to be provided by the caller, must + * contain at least `count` elements. + * + * If scaling is performed (based on the value of `load_flags`), the + * advance values are in 16.16 format. Otherwise, they are in font + * units. + * + * If @FT_LOAD_VERTICAL_LAYOUT is set, these are the vertical advances + * corresponding to a vertical layout. Otherwise, they are the + * horizontal advances in a horizontal layout. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if + * the corresponding font backend doesn't have a quick way to retrieve + * the advances. + * + * Scaled advances are returned in 16.16 format but aren't transformed by + * the affine transformation specified by @FT_Set_Transform. + */ FT_EXPORT( FT_Error ) FT_Get_Advances( FT_Face face, FT_UInt start, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h index f9eb70b1373..22da70c0dc3 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbbox.h @@ -1,30 +1,30 @@ -/***************************************************************************/ -/* */ -/* ftbbox.h */ -/* */ -/* FreeType exact bbox computation (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /* It is separated from the rest of the engine for various technical */ - /* reasons. It may well be integrated in `ftoutln' later. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftbbox.h + * + * FreeType exact bbox computation (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component has a _single_ role: to compute exact outline bounding + * boxes. + * + * It is separated from the rest of the engine for various technical + * reasons. It may well be integrated in 'ftoutln' later. + * + */ #ifndef FTBBOX_H_ @@ -44,43 +44,44 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_BBox */ - /* */ - /* <Description> */ - /* Compute the exact bounding box of an outline. This is slower */ - /* than computing the control box. However, it uses an advanced */ - /* algorithm that returns _very_ quickly when the two boxes */ - /* coincide. Otherwise, the outline Bezier arcs are traversed to */ - /* extract their extrema. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline. */ - /* */ - /* <Output> */ - /* abbox :: The outline's exact bounding box. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ - /* reasonable values for the BBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the BBox, */ - /* which can be eventually converted back to font units. */ - /* */ + /************************************************************************** + * + * @section: + * outline_processing + * + */ + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_BBox + * + * @description: + * Compute the exact bounding box of an outline. This is slower than + * computing the control box. However, it uses an advanced algorithm + * that returns _very_ quickly when the two boxes coincide. Otherwise, + * the outline Bezier arcs are traversed to extract their extrema. + * + * @input: + * outline :: + * A pointer to the source outline. + * + * @output: + * abbox :: + * The outline's exact bounding box. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the font is tricky and the glyph has been loaded with + * @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get + * reasonable values for the BBox it is necessary to load the glyph at a + * large ppem value (so that the hinting instructions can properly shift + * and scale the subglyphs), then extracting the BBox, which can be + * eventually converted back to font units. + */ FT_EXPORT( FT_Error ) FT_Outline_Get_BBox( FT_Outline* outline, FT_BBox *abbox ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h index 1b6dea65863..1c46da5985d 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbdf.h */ -/* */ -/* FreeType API for accessing BDF-specific strings (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbdf.h + * + * FreeType API for accessing BDF-specific strings (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBDF_H_ @@ -32,25 +32,25 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* bdf_fonts */ - /* */ - /* <Title> */ - /* BDF and PCF Files */ - /* */ - /* <Abstract> */ - /* BDF and PCF specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions specific to BDF */ - /* and PCF fonts. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * bdf_fonts + * + * @title: + * BDF and PCF Files + * + * @abstract: + * BDF and PCF specific API. + * + * @description: + * This section contains the declaration of functions specific to BDF and + * PCF fonts. + * + */ - /********************************************************************** + /************************************************************************** * * @enum: * BDF_PropertyType @@ -81,40 +81,40 @@ FT_BEGIN_HEADER } BDF_PropertyType; - /********************************************************************** + /************************************************************************** * * @type: * BDF_Property * * @description: - * A handle to a @BDF_PropertyRec structure to model a given - * BDF/PCF property. + * A handle to a @BDF_PropertyRec structure to model a given BDF/PCF + * property. */ typedef struct BDF_PropertyRec_* BDF_Property; - /********************************************************************** - * - * @struct: - * BDF_PropertyRec - * - * @description: - * This structure models a given BDF/PCF property. - * - * @fields: - * type :: - * The property type. - * - * u.atom :: - * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be - * NULL, indicating an empty string. - * - * u.integer :: - * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. - * - * u.cardinal :: - * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. - */ + /************************************************************************** + * + * @struct: + * BDF_PropertyRec + * + * @description: + * This structure models a given BDF/PCF property. + * + * @fields: + * type :: + * The property type. + * + * u.atom :: + * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be + * `NULL`, indicating an empty string. + * + * u.integer :: + * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. + * + * u.cardinal :: + * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. + */ typedef struct BDF_PropertyRec_ { BDF_PropertyType type; @@ -128,73 +128,76 @@ FT_BEGIN_HEADER } BDF_PropertyRec; - /********************************************************************** - * - * @function: - * FT_Get_BDF_Charset_ID - * - * @description: - * Retrieve a BDF font character set identity, according to - * the BDF specification. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * acharset_encoding :: - * Charset encoding, as a C~string, owned by the face. - * - * acharset_registry :: - * Charset registry, as a C~string, owned by the face. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with BDF faces, returning an error otherwise. - */ + /************************************************************************** + * + * @function: + * FT_Get_BDF_Charset_ID + * + * @description: + * Retrieve a BDF font character set identity, according to the BDF + * specification. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * acharset_encoding :: + * Charset encoding, as a C~string, owned by the face. + * + * acharset_registry :: + * Charset registry, as a C~string, owned by the face. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with BDF faces, returning an error otherwise. + */ FT_EXPORT( FT_Error ) FT_Get_BDF_Charset_ID( FT_Face face, const char* *acharset_encoding, const char* *acharset_registry ); - /********************************************************************** - * - * @function: - * FT_Get_BDF_Property - * - * @description: - * Retrieve a BDF property from a BDF or PCF font file. - * - * @input: - * face :: A handle to the input face. - * - * name :: The property name. - * - * @output: - * aproperty :: The property. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function works with BDF _and_ PCF fonts. It returns an error - * otherwise. It also returns an error if the property is not in the - * font. - * - * A `property' is a either key-value pair within the STARTPROPERTIES - * ... ENDPROPERTIES block of a BDF font or a key-value pair from the - * `info->props' array within a `FontRec' structure of a PCF font. - * - * Integer properties are always stored as `signed' within PCF fonts; - * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value - * for BDF fonts only. - * - * In case of error, `aproperty->type' is always set to - * @BDF_PROPERTY_TYPE_NONE. - */ + /************************************************************************** + * + * @function: + * FT_Get_BDF_Property + * + * @description: + * Retrieve a BDF property from a BDF or PCF font file. + * + * @input: + * face :: + * A handle to the input face. + * + * name :: + * The property name. + * + * @output: + * aproperty :: + * The property. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function works with BDF _and_ PCF fonts. It returns an error + * otherwise. It also returns an error if the property is not in the + * font. + * + * A 'property' is a either key-value pair within the STARTPROPERTIES + * ... ENDPROPERTIES block of a BDF font or a key-value pair from the + * `info->props` array within a `FontRec` structure of a PCF font. + * + * Integer properties are always stored as 'signed' within PCF fonts; + * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value + * for BDF fonts only. + * + * In case of error, `aproperty->type` is always set to + * @BDF_PROPERTY_TYPE_NONE. + */ FT_EXPORT( FT_Error ) FT_Get_BDF_Property( FT_Face face, const char* prop_name, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h index a43187cad47..a6acdb96909 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftbitmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbitmap.h */ -/* */ -/* FreeType utility functions for bitmaps (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbitmap.h + * + * FreeType utility functions for bitmaps (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBITMAP_H_ @@ -22,6 +22,7 @@ #include <ft2build.h> #include FT_FREETYPE_H +#include FT_COLOR_H #ifdef FREETYPE_H #error "freetype.h of FreeType 1 has been loaded!" @@ -33,39 +34,46 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* bitmap_handling */ - /* */ - /* <Title> */ - /* Bitmap Handling */ - /* */ - /* <Abstract> */ - /* Handling FT_Bitmap objects. */ - /* */ - /* <Description> */ - /* This section contains functions for handling @FT_Bitmap objects. */ - /* Note that none of the functions changes the bitmap's `flow' (as */ - /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Init */ - /* */ - /* <Description> */ - /* Initialize a pointer to an @FT_Bitmap structure. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the bitmap structure. */ - /* */ - /* <Note> */ - /* A deprecated name for the same function is `FT_Bitmap_New'. */ - /* */ + /************************************************************************** + * + * @section: + * bitmap_handling + * + * @title: + * Bitmap Handling + * + * @abstract: + * Handling FT_Bitmap objects. + * + * @description: + * This section contains functions for handling @FT_Bitmap objects, + * automatically adjusting the target's bitmap buffer size as needed. + * + * Note that none of the functions changes the bitmap's 'flow' (as + * indicated by the sign of the `pitch` field in @FT_Bitmap). + * + * To set the flow, assign an appropriate positive or negative value to + * the `pitch` field of the target @FT_Bitmap object after calling + * @FT_Bitmap_Init but before calling any of the other functions + * described here. + */ + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Init + * + * @description: + * Initialize a pointer to an @FT_Bitmap structure. + * + * @inout: + * abitmap :: + * A pointer to the bitmap structure. + * + * @note: + * A deprecated name for the same function is `FT_Bitmap_New`. + */ FT_EXPORT( void ) FT_Bitmap_Init( FT_Bitmap *abitmap ); @@ -75,66 +83,77 @@ FT_BEGIN_HEADER FT_Bitmap_New( FT_Bitmap *abitmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Copy */ - /* */ - /* <Description> */ - /* Copy a bitmap into another one. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: A handle to the source bitmap. */ - /* */ - /* <Output> */ - /* target :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Copy + * + * @description: + * Copy a bitmap into another one. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * A handle to the source bitmap. + * + * @output: + * target :: + * A handle to the target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + */ FT_EXPORT( FT_Error ) FT_Bitmap_Copy( FT_Library library, const FT_Bitmap *source, FT_Bitmap *target ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Embolden */ - /* */ - /* <Description> */ - /* Embolden a bitmap. The new bitmap will be about `xStrength' */ - /* pixels wider and `yStrength' pixels higher. The left and bottom */ - /* borders are kept unchanged. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* xStrength :: How strong the glyph is emboldened horizontally. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* yStrength :: How strong the glyph is emboldened vertically. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* <InOut> */ - /* bitmap :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The current implementation restricts `xStrength' to be less than */ - /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ - /* */ - /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ - /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ - /* */ - /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */ - /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Embolden + * + * @description: + * Embolden a bitmap. The new bitmap will be about `xStrength` pixels + * wider and `yStrength` pixels higher. The left and bottom borders are + * kept unchanged. + * + * @input: + * library :: + * A handle to a library object. + * + * xStrength :: + * How strong the glyph is emboldened horizontally. Expressed in 26.6 + * pixel format. + * + * yStrength :: + * How strong the glyph is emboldened vertically. Expressed in 26.6 + * pixel format. + * + * @inout: + * bitmap :: + * A handle to the target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The current implementation restricts `xStrength` to be less than or + * equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. + * + * If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you + * should call @FT_GlyphSlot_Own_Bitmap on the slot first. + * + * Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are + * converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). + */ FT_EXPORT( FT_Error ) FT_Bitmap_Embolden( FT_Library library, FT_Bitmap* bitmap, @@ -142,39 +161,46 @@ FT_BEGIN_HEADER FT_Pos yStrength ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Convert */ - /* */ - /* <Description> */ - /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */ - /* to a bitmap object with depth 8bpp, making the number of used */ - /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: The source bitmap. */ - /* */ - /* alignment :: The pitch of the bitmap is a multiple of this */ - /* parameter. Common values are 1, 2, or 4. */ - /* */ - /* <Output> */ - /* target :: The target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* It is possible to call @FT_Bitmap_Convert multiple times without */ - /* calling @FT_Bitmap_Done (the memory is simply reallocated). */ - /* */ - /* Use @FT_Bitmap_Done to finally remove the bitmap object. */ - /* */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Convert + * + * @description: + * Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to + * a bitmap object with depth 8bpp, making the number of used bytes per + * line (a.k.a. the 'pitch') a multiple of `alignment`. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * The source bitmap. + * + * alignment :: + * The pitch of the bitmap is a multiple of this argument. Common + * values are 1, 2, or 4. + * + * @output: + * target :: + * The target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * It is possible to call @FT_Bitmap_Convert multiple times without + * calling @FT_Bitmap_Done (the memory is simply reallocated). + * + * Use @FT_Bitmap_Done to finally remove the bitmap object. + * + * The `library` argument is taken to have access to FreeType's memory + * handling functions. + * + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + */ FT_EXPORT( FT_Error ) FT_Bitmap_Convert( FT_Library library, const FT_Bitmap *source, @@ -182,48 +208,112 @@ FT_BEGIN_HEADER FT_Int alignment ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GlyphSlot_Own_Bitmap */ - /* */ - /* <Description> */ - /* Make sure that a glyph slot owns `slot->bitmap'. */ - /* */ - /* <Input> */ - /* slot :: The glyph slot. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function is to be used in combination with */ - /* @FT_Bitmap_Embolden. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Blend + * + * @description: + * Blend a bitmap onto another bitmap, using a given color. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * The source bitmap, which can have any @FT_Pixel_Mode format. + * + * source_offset :: + * The offset vector to the upper left corner of the source bitmap in + * 26.6 pixel format. It should represent an integer offset; the + * function will set the lowest six bits to zero to enforce that. + * + * color :: + * The color used to draw `source` onto `target`. + * + * @inout: + * target :: + * A handle to an `FT_Bitmap` object. It should be either initialized + * as empty with a call to @FT_Bitmap_Init, or it should be of type + * @FT_PIXEL_MODE_BGRA. + * + * atarget_offset :: + * The offset vector to the upper left corner of the target bitmap in + * 26.6 pixel format. It should represent an integer offset; the + * function will set the lowest six bits to zero to enforce that. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function doesn't perform clipping. + * + * The bitmap in `target` gets allocated or reallocated as needed; the + * vector `atarget_offset` is updated accordingly. + * + * In case of allocation or reallocation, the bitmap's pitch is set to + * `4 * width`. Both `source` and `target` must have the same bitmap + * flow (as indicated by the sign of the `pitch` field). + * + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Blend( FT_Library library, + const FT_Bitmap* source, + const FT_Vector source_offset, + FT_Bitmap* target, + FT_Vector *atarget_offset, + FT_Color color ); + + + /************************************************************************** + * + * @function: + * FT_GlyphSlot_Own_Bitmap + * + * @description: + * Make sure that a glyph slot owns `slot->bitmap`. + * + * @input: + * slot :: + * The glyph slot. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function is to be used in combination with @FT_Bitmap_Embolden. + */ FT_EXPORT( FT_Error ) FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Done */ - /* */ - /* <Description> */ - /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* bitmap :: The bitmap object to be freed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Done + * + * @description: + * Destroy a bitmap object initialized with @FT_Bitmap_Init. + * + * @input: + * library :: + * A handle to a library object. + * + * bitmap :: + * The bitmap object to be freed. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `library` argument is taken to have access to FreeType's memory + * handling functions. + */ FT_EXPORT( FT_Error ) FT_Bitmap_Done( FT_Library library, FT_Bitmap *bitmap ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftchapters.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftchapters.h index 51257bb7ca8..2ee26973e46 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftchapters.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftchapters.h @@ -1,139 +1,145 @@ -/***************************************************************************/ -/* */ -/* This file defines the structure of the FreeType reference. */ -/* It is used by the python script that generates the HTML files. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* general_remarks */ -/* */ -/* <Title> */ -/* General Remarks */ -/* */ -/* <Sections> */ -/* header_inclusion */ -/* user_allocation */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* core_api */ -/* */ -/* <Title> */ -/* Core API */ -/* */ -/* <Sections> */ -/* version */ -/* basic_types */ -/* base_interface */ -/* glyph_variants */ -/* glyph_management */ -/* mac_specific */ -/* sizes_management */ -/* header_file_macros */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* format_specific */ -/* */ -/* <Title> */ -/* Format-Specific API */ -/* */ -/* <Sections> */ -/* multiple_masters */ -/* truetype_tables */ -/* type1_tables */ -/* sfnt_names */ -/* bdf_fonts */ -/* cid_fonts */ -/* pfr_fonts */ -/* winfnt_fonts */ -/* font_formats */ -/* gasp_table */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* module_specific */ -/* */ -/* <Title> */ -/* Controlling FreeType Modules */ -/* */ -/* <Sections> */ -/* auto_hinter */ -/* cff_driver */ -/* t1_cid_driver */ -/* tt_driver */ -/* pcf_driver */ -/* properties */ -/* parameter_tags */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* cache_subsystem */ -/* */ -/* <Title> */ -/* Cache Sub-System */ -/* */ -/* <Sections> */ -/* cache_subsystem */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* support_api */ -/* */ -/* <Title> */ -/* Support API */ -/* */ -/* <Sections> */ -/* computations */ -/* list_processing */ -/* outline_processing */ -/* quick_advance */ -/* bitmap_handling */ -/* raster */ -/* glyph_stroker */ -/* system_interface */ -/* module_management */ -/* gzip */ -/* lzw */ -/* bzip2 */ -/* lcd_filtering */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* error_codes */ -/* */ -/* <Title> */ -/* Error Codes */ -/* */ -/* <Sections> */ -/* error_enumerations */ -/* error_code_values */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * This file defines the structure of the FreeType reference. + * It is used by the python script that generates the HTML files. + * + */ + + + /************************************************************************** + * + * @chapter: + * general_remarks + * + * @title: + * General Remarks + * + * @sections: + * header_inclusion + * user_allocation + * + */ + + + /************************************************************************** + * + * @chapter: + * core_api + * + * @title: + * Core API + * + * @sections: + * version + * basic_types + * base_interface + * glyph_variants + * color_management + * layer_management + * glyph_management + * mac_specific + * sizes_management + * header_file_macros + * + */ + + + /************************************************************************** + * + * @chapter: + * format_specific + * + * @title: + * Format-Specific API + * + * @sections: + * multiple_masters + * truetype_tables + * type1_tables + * sfnt_names + * bdf_fonts + * cid_fonts + * pfr_fonts + * winfnt_fonts + * font_formats + * gasp_table + * + */ + + + /************************************************************************** + * + * @chapter: + * module_specific + * + * @title: + * Controlling FreeType Modules + * + * @sections: + * auto_hinter + * cff_driver + * t1_cid_driver + * tt_driver + * pcf_driver + * properties + * parameter_tags + * lcd_rendering + * + */ + + + /************************************************************************** + * + * @chapter: + * cache_subsystem + * + * @title: + * Cache Sub-System + * + * @sections: + * cache_subsystem + * + */ + + + /************************************************************************** + * + * @chapter: + * support_api + * + * @title: + * Support API + * + * @sections: + * computations + * list_processing + * outline_processing + * quick_advance + * bitmap_handling + * raster + * glyph_stroker + * system_interface + * module_management + * gzip + * lzw + * bzip2 + * + */ + + + /************************************************************************** + * + * @chapter: + * error_codes + * + * @title: + * Error Codes + * + * @sections: + * error_enumerations + * error_code_values + * + */ + + +/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h index 5e9100a67cb..8eafc1c78fd 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcid.h */ -/* */ -/* FreeType API for accessing CID font information (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* Dereg Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcid.h + * + * FreeType API for accessing CID font information (specification). + * + * Copyright (C) 2007-2019 by + * Dereg Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCID_H_ @@ -32,25 +32,25 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* cid_fonts */ - /* */ - /* <Title> */ - /* CID Fonts */ - /* */ - /* <Abstract> */ - /* CID-keyed font specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of CID-keyed font specific */ - /* functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * cid_fonts + * + * @title: + * CID Fonts + * + * @abstract: + * CID-keyed font-specific API. + * + * @description: + * This section contains the declaration of CID-keyed font-specific + * functions. + * + */ - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_CID_Registry_Ordering_Supplement @@ -61,17 +61,17 @@ FT_BEGIN_HEADER * * @input: * face :: - * A handle to the input face. + * A handle to the input face. * * @output: * registry :: - * The registry, as a C~string, owned by the face. + * The registry, as a C~string, owned by the face. * * ordering :: - * The ordering, as a C~string, owned by the face. + * The ordering, as a C~string, owned by the face. * * supplement :: - * The supplement. + * The supplement. * * @return: * FreeType error code. 0~means success. @@ -90,30 +90,30 @@ FT_BEGIN_HEADER FT_Int *supplement ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_CID_Is_Internally_CID_Keyed * * @description: - * Retrieve the type of the input face, CID keyed or not. In - * contrast to the @FT_IS_CID_KEYED macro this function returns - * successfully also for CID-keyed fonts in an SFNT wrapper. + * Retrieve the type of the input face, CID keyed or not. In contrast + * to the @FT_IS_CID_KEYED macro this function returns successfully also + * for CID-keyed fonts in an SFNT wrapper. * * @input: * face :: - * A handle to the input face. + * A handle to the input face. * * @output: * is_cid :: - * The type of the face as an @FT_Bool. + * The type of the face as an @FT_Bool. * * @return: * FreeType error code. 0~means success. * * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. + * This function only works with CID faces and OpenType fonts, returning + * an error otherwise. * * @since: * 2.3.9 @@ -123,7 +123,7 @@ FT_BEGIN_HEADER FT_Bool *is_cid ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_CID_From_Glyph_Index @@ -133,21 +133,21 @@ FT_BEGIN_HEADER * * @input: * face :: - * A handle to the input face. + * A handle to the input face. * * glyph_index :: - * The input glyph index. + * The input glyph index. * * @output: * cid :: - * The CID as an @FT_UInt. + * The CID as an @FT_UInt. * * @return: * FreeType error code. 0~means success. * * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. + * This function only works with CID faces and OpenType fonts, returning + * an error otherwise. * * @since: * 2.3.9 diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h new file mode 100644 index 00000000000..cf180219532 --- /dev/null +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftcolor.h @@ -0,0 +1,311 @@ +/**************************************************************************** + * + * ftcolor.h + * + * FreeType's glyph color management (specification). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTCOLOR_H_ +#define FTCOLOR_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * color_management + * + * @title: + * Glyph Color Management + * + * @abstract: + * Retrieving and manipulating OpenType's 'CPAL' table data. + * + * @description: + * The functions described here allow access and manipulation of color + * palette entries in OpenType's 'CPAL' tables. + */ + + + /************************************************************************** + * + * @struct: + * FT_Color + * + * @description: + * This structure models a BGRA color value of a 'CPAL' palette entry. + * + * The used color space is sRGB; the colors are not pre-multiplied, and + * alpha values must be explicitly set. + * + * @fields: + * blue :: + * Blue value. + * + * green :: + * Green value. + * + * red :: + * Red value. + * + * alpha :: + * Alpha value, giving the red, green, and blue color's opacity. + * + * @since: + * 2.10 + */ + typedef struct FT_Color_ + { + FT_Byte blue; + FT_Byte green; + FT_Byte red; + FT_Byte alpha; + + } FT_Color; + + + /************************************************************************** + * + * @enum: + * FT_PALETTE_XXX + * + * @description: + * A list of bit field constants used in the `palette_flags` array of the + * @FT_Palette_Data structure to indicate for which background a palette + * with a given index is usable. + * + * @values: + * FT_PALETTE_FOR_LIGHT_BACKGROUND :: + * The palette is appropriate to use when displaying the font on a + * light background such as white. + * + * FT_PALETTE_FOR_DARK_BACKGROUND :: + * The palette is appropriate to use when displaying the font on a dark + * background such as black. + * + * @since: + * 2.10 + */ +#define FT_PALETTE_FOR_LIGHT_BACKGROUND 0x01 +#define FT_PALETTE_FOR_DARK_BACKGROUND 0x02 + + + /************************************************************************** + * + * @struct: + * FT_Palette_Data + * + * @description: + * This structure holds the data of the 'CPAL' table. + * + * @fields: + * num_palettes :: + * The number of palettes. + * + * palette_name_ids :: + * A read-only array of palette name IDs with `num_palettes` elements, + * corresponding to entries like 'dark' or 'light' in the font's 'name' + * table. + * + * An empty name ID in the 'CPAL' table gets represented as value + * 0xFFFF. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * palette_flags :: + * A read-only array of palette flags with `num_palettes` elements. + * Possible values are an ORed combination of + * @FT_PALETTE_FOR_LIGHT_BACKGROUND and + * @FT_PALETTE_FOR_DARK_BACKGROUND. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * num_palette_entries :: + * The number of entries in a single palette. All palettes have the + * same size. + * + * palette_entry_name_ids :: + * A read-only array of palette entry name IDs with + * `num_palette_entries`. In each palette, entries with the same index + * have the same function. For example, index~0 might correspond to + * string 'outline' in the font's 'name' table to indicate that this + * palette entry is used for outlines, index~1 might correspond to + * 'fill' to indicate the filling color palette entry, etc. + * + * An empty entry name ID in the 'CPAL' table gets represented as value + * 0xFFFF. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * @note: + * Use function @FT_Get_Sfnt_Name to map name IDs and entry name IDs to + * name strings. + * + * @since: + * 2.10 + */ + typedef struct FT_Palette_Data_ { + FT_UShort num_palettes; + const FT_UShort* palette_name_ids; + const FT_UShort* palette_flags; + + FT_UShort num_palette_entries; + const FT_UShort* palette_entry_name_ids; + + } FT_Palette_Data; + + + /************************************************************************** + * + * @function: + * FT_Palette_Data_Get + * + * @description: + * Retrieve the face's color palette data. + * + * @input: + * face :: + * The source face handle. + * + * @output: + * apalette :: + * A pointer to an @FT_Palette_Data structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * All arrays in the returned @FT_Palette_Data structure are read-only. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Data_Get( FT_Face face, + FT_Palette_Data *apalette ); + + + /************************************************************************** + * + * @function: + * FT_Palette_Select + * + * @description: + * This function has two purposes. + * + * (1) It activates a palette for rendering color glyphs, and + * + * (2) it retrieves all (unmodified) color entries of this palette. This + * function returns a read-write array, which means that a calling + * application can modify the palette entries on demand. + * + * A corollary of (2) is that calling the function, then modifying some + * values, then calling the function again with the same arguments resets + * all color entries to the original 'CPAL' values; all user modifications + * are lost. + * + * @input: + * face :: + * The source face handle. + * + * palette_index :: + * The palette index. + * + * @output: + * apalette :: + * An array of color entries for a palette with index `palette_index`, + * having `num_palette_entries` elements (as found in the + * `FT_Palette_Data` structure). If `apalette` is set to `NULL`, no + * array gets returned (and no color entries can be modified). + * + * In case the font doesn't support color palettes, `NULL` is returned. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The array pointed to by `apalette_entries` is owned and managed by + * FreeType. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Select( FT_Face face, + FT_UShort palette_index, + FT_Color* *apalette ); + + + /************************************************************************** + * + * @function: + * FT_Palette_Set_Foreground_Color + * + * @description: + * 'COLR' uses palette index 0xFFFF to indicate a 'text foreground + * color'. This function sets this value. + * + * @input: + * face :: + * The source face handle. + * + * foreground_color :: + * An `FT_Color` structure to define the text foreground color. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If this function isn't called, the text foreground color is set to + * white opaque (BGRA value 0xFFFFFFFF) if + * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette, + * and black opaque (BGRA value 0x000000FF) otherwise, including the case + * that no palette types are available in the 'CPAL' table. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Set_Foreground_Color( FT_Face face, + FT_Color foreground_color ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCOLOR_H_ */ + + +/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h index 0a90e2941f5..497bde9f6ed 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftdriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftdriver.h */ -/* */ -/* FreeType API for controlling driver modules (specification only). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdriver.h + * + * FreeType API for controlling driver modules (specification only). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTDRIVER_H_ @@ -50,8 +50,8 @@ FT_BEGIN_HEADER * @FT_Property_Get. The following lists the available properties * together with the necessary macros and structures. * - * Note that the auto-hinter's module name is `autofitter' for - * historical reasons. + * Note that the auto-hinter's module name is 'autofitter' for historical + * reasons. * * Available properties are @increase-x-height, @no-stem-darkening * (experimental), @darkening-parameters (experimental), @warping @@ -74,18 +74,18 @@ FT_BEGIN_HEADER * Controlling the CFF driver module. * * @description: - * While FreeType's CFF driver doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and + * While FreeType's CFF driver doesn't expose API functions by itself, it + * is possible to control its behaviour with @FT_Property_Set and * @FT_Property_Get. * - * The CFF driver's module name is `cff'. + * The CFF driver's module name is 'cff'. * * Available properties are @hinting-engine, @no-stem-darkening, * @darkening-parameters, and @random-seed, as documented in the * @properties section. * * - * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine* + * **Hinting and antialiasing principles of the new engine** * * The rasterizer is positioning horizontal features (e.g., ascender * height & x-height, or crossbars) on the pixel grid and minimizing the @@ -93,35 +93,34 @@ FT_BEGIN_HEADER * features (vertical stems) on the pixel grid without hinting, thus * representing the stem position and weight accurately. Sometimes the * vertical stems may be only partially black. In this context, - * `antialiasing' means that stems are not positioned exactly on pixel + * 'antialiasing' means that stems are not positioned exactly on pixel * borders, causing a fuzzy appearance. * * There are two principles behind this approach. * - * 1) No hinting in the horizontal direction: Unlike `superhinted' + * 1) No hinting in the horizontal direction: Unlike 'superhinted' * TrueType, which changes glyph widths to accommodate regular - * inter-glyph spacing, Adobe's approach is `faithful to the design' in - * representing both the glyph width and the inter-glyph spacing - * designed for the font. This makes the screen display as close as it - * can be to the result one would get with infinite resolution, while - * preserving what is considered the key characteristics of each glyph. - * Note that the distances between unhinted and grid-fitted positions at - * small sizes are comparable to kerning values and thus would be - * noticeable (and distracting) while reading if hinting were applied. + * inter-glyph spacing, Adobe's approach is 'faithful to the design' in + * representing both the glyph width and the inter-glyph spacing designed + * for the font. This makes the screen display as close as it can be to + * the result one would get with infinite resolution, while preserving + * what is considered the key characteristics of each glyph. Note that + * the distances between unhinted and grid-fitted positions at small + * sizes are comparable to kerning values and thus would be noticeable + * (and distracting) while reading if hinting were applied. * * One of the reasons to not hint horizontally is antialiasing for LCD - * screens: The pixel geometry of modern displays supplies three - * vertical subpixels as the eye moves horizontally across each visible - * pixel. On devices where we can be certain this characteristic is - * present a rasterizer can take advantage of the subpixels to add - * increments of weight. In Western writing systems this turns out to - * be the more critical direction anyway; the weights and spacing of - * vertical stems (see above) are central to Armenian, Cyrillic, Greek, - * and Latin type designs. Even when the rasterizer uses greyscale - * antialiasing instead of color (a necessary compromise when one - * doesn't know the screen characteristics), the unhinted vertical - * features preserve the design's weight and spacing much better than - * aliased type would. + * screens: The pixel geometry of modern displays supplies three vertical + * subpixels as the eye moves horizontally across each visible pixel. On + * devices where we can be certain this characteristic is present a + * rasterizer can take advantage of the subpixels to add increments of + * weight. In Western writing systems this turns out to be the more + * critical direction anyway; the weights and spacing of vertical stems + * (see above) are central to Armenian, Cyrillic, Greek, and Latin type + * designs. Even when the rasterizer uses greyscale antialiasing instead + * of color (a necessary compromise when one doesn't know the screen + * characteristics), the unhinted vertical features preserve the design's + * weight and spacing much better than aliased type would. * * 2) Alignment in the vertical direction: Weights and spacing along the * y~axis are less critical; what is much more important is the visual @@ -132,16 +131,16 @@ FT_BEGIN_HEADER * * On the technical side, horizontal alignment zones for ascender, * x-height, and other important height values (traditionally called - * `blue zones') as defined in the font are positioned independently, - * each being rounded to the nearest pixel edge, taking care of - * overshoot suppression at small sizes, stem darkening, and scaling. + * 'blue zones') as defined in the font are positioned independently, + * each being rounded to the nearest pixel edge, taking care of overshoot + * suppression at small sizes, stem darkening, and scaling. * * Hstems (this is, hint values defined in the font to help align * horizontal features) that fall within a blue zone are said to be - * `captured' and are aligned to that zone. Uncaptured stems are moved + * 'captured' and are aligned to that zone. Uncaptured stems are moved * in one of four ways, top edge up or down, bottom edge up or down. - * Unless there are conflicting hstems, the smallest movement is taken - * to minimize distortion. + * Unless there are conflicting hstems, the smallest movement is taken to + * minimize distortion. * */ @@ -158,13 +157,13 @@ FT_BEGIN_HEADER * Controlling the PCF driver module. * * @description: - * While FreeType's PCF driver doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and + * While FreeType's PCF driver doesn't expose API functions by itself, it + * is possible to control its behaviour with @FT_Property_Set and * @FT_Property_Get. Right now, there is a single property * @no-long-family-names available if FreeType is compiled with * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES. * - * The PCF driver's module name is `pcf'. + * The PCF driver's module name is 'pcf'. * */ @@ -187,15 +186,15 @@ FT_BEGIN_HEADER * Behind the scenes, both drivers use the Adobe CFF engine for hinting; * however, the used properties must be specified separately. * - * The Type~1 driver's module name is `type1'; the CID driver's module - * name is `t1cid'. + * The Type~1 driver's module name is 'type1'; the CID driver's module + * name is 't1cid'. * * Available properties are @hinting-engine, @no-stem-darkening, * @darkening-parameters, and @random-seed, as documented in the * @properties section. * - * Please see the @cff_driver section for more details on the new - * hinting engine. + * Please see the @cff_driver section for more details on the new hinting + * engine. * */ @@ -217,7 +216,7 @@ FT_BEGIN_HEADER * and @FT_Property_Get. The following lists the available properties * together with the necessary macros and structures. * - * The TrueType driver's module name is `truetype'. + * The TrueType driver's module name is 'truetype'. * * A single property @interpreter-version is available, as documented in * the @properties section. @@ -225,36 +224,36 @@ FT_BEGIN_HEADER * We start with a list of definitions, kindly provided by Greg * Hitchcock. * - * _Bi-Level_ _Rendering_ + * _Bi-Level Rendering_ * * Monochromatic rendering, exclusively used in the early days of * TrueType by both Apple and Microsoft. Microsoft's GDI interface * supported hinting of the right-side bearing point, such that the * advance width could be non-linear. Most often this was done to * achieve some level of glyph symmetry. To enable reasonable - * performance (e.g., not having to run hinting on all glyphs just to - * get the widths) there was a bit in the head table indicating if the - * side bearing was hinted, and additional tables, `hdmx' and `LTSH', to - * cache hinting widths across multiple sizes and device aspect ratios. + * performance (e.g., not having to run hinting on all glyphs just to get + * the widths) there was a bit in the head table indicating if the side + * bearing was hinted, and additional tables, 'hdmx' and 'LTSH', to cache + * hinting widths across multiple sizes and device aspect ratios. * - * _Font_ _Smoothing_ + * _Font Smoothing_ * * Microsoft's GDI implementation of anti-aliasing. Not traditional * anti-aliasing as the outlines were hinted before the sampling. The * widths matched the bi-level rendering. * - * _ClearType_ _Rendering_ + * _ClearType Rendering_ * * Technique that uses physical subpixels to improve rendering on LCD * (and other) displays. Because of the higher resolution, many methods - * of improving symmetry in glyphs through hinting the right-side - * bearing were no longer necessary. This lead to what GDI calls - * `natural widths' ClearType, see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting + * of improving symmetry in glyphs through hinting the right-side bearing + * were no longer necessary. This lead to what GDI calls 'natural + * widths' ClearType, see + * http://rastertragedy.com/RTRCh4.htm#Sec21. Since hinting * has extra resolution, most non-linearity went away, but it is still * possible for hints to change the advance widths in this mode. * - * _ClearType_ _Compatible_ _Widths_ + * _ClearType Compatible Widths_ * * One of the earliest challenges with ClearType was allowing the * implementation in GDI to be selected without requiring all UI and @@ -263,41 +262,41 @@ FT_BEGIN_HEADER * to determine the width in bi-level rendering, and then re-run in * ClearType, with the difference in widths being absorbed in the font * hints for ClearType (mostly in the white space of hints); see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by + * http://rastertragedy.com/RTRCh4.htm#Sec20. Somewhat by * definition, compatible width ClearType allows for non-linear widths, * but only when the bi-level version has non-linear widths. * - * _ClearType_ _Subpixel_ _Positioning_ + * _ClearType Subpixel Positioning_ * * One of the nice benefits of ClearType is the ability to more crisply * display fractional widths; unfortunately, the GDI model of integer * bitmaps did not support this. However, the WPF and Direct Write - * frameworks do support fractional widths. DWrite calls this `natural - * mode', not to be confused with GDI's `natural widths'. Subpixel + * frameworks do support fractional widths. DWrite calls this 'natural + * mode', not to be confused with GDI's 'natural widths'. Subpixel * positioning, in the current implementation of Direct Write, * unfortunately does not support hinted advance widths, see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the + * http://rastertragedy.com/RTRCh4.htm#Sec22. Note that the * TrueType interpreter fully allows the advance width to be adjusted in * this mode, just the DWrite client will ignore those changes. * - * _ClearType_ _Backward_ _Compatibility_ + * _ClearType Backward Compatibility_ * * This is a set of exceptions made in the TrueType interpreter to * minimize hinting techniques that were problematic with the extra * resolution of ClearType; see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and + * http://rastertragedy.com/RTRCh4.htm#Sec1 and * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. - * This technique is not to be confused with ClearType compatible - * widths. ClearType backward compatibility has no direct impact on - * changing advance widths, but there might be an indirect impact on - * disabling some deltas. This could be worked around in backward - * compatibility mode. + * This technique is not to be confused with ClearType compatible widths. + * ClearType backward compatibility has no direct impact on changing + * advance widths, but there might be an indirect impact on disabling + * some deltas. This could be worked around in backward compatibility + * mode. * - * _Native_ _ClearType_ _Mode_ + * _Native ClearType Mode_ * - * (Not to be confused with `natural widths'.) This mode removes all - * the exceptions in the TrueType interpreter when running with - * ClearType. Any issues on widths would still apply, though. + * (Not to be confused with 'natural widths'.) This mode removes all the + * exceptions in the TrueType interpreter when running with ClearType. + * Any issues on widths would still apply, though. * */ @@ -328,8 +327,8 @@ FT_BEGIN_HEADER * FT_HINTING_XXX * * @description: - * A list of constants used for the @hinting-engine property to - * select the hinting engine for CFF, Type~1, and CID fonts. + * A list of constants used for the @hinting-engine property to select + * the hinting engine for CFF, Type~1, and CID fonts. * * @values: * FT_HINTING_FREETYPE :: @@ -356,45 +355,46 @@ FT_BEGIN_HEADER * hinting-engine * * @description: - * Thanks to Adobe, which contributed a new hinting (and parsing) - * engine, an application can select between `freetype' and `adobe' if - * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration - * macro isn't defined, `hinting-engine' does nothing. + * Thanks to Adobe, which contributed a new hinting (and parsing) engine, + * an application can select between 'freetype' and 'adobe' if compiled + * with `CFF_CONFIG_OPTION_OLD_ENGINE`. If this configuration macro + * isn't defined, 'hinting-engine' does nothing. * * The same holds for the Type~1 and CID modules if compiled with - * T1_CONFIG_OPTION_OLD_ENGINE. + * `T1_CONFIG_OPTION_OLD_ENGINE`. * - * For the `cff' module, the default engine is `freetype' if - * CFF_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' otherwise. + * For the 'cff' module, the default engine is 'freetype' if + * `CFF_CONFIG_OPTION_OLD_ENGINE` is defined, and 'adobe' otherwise. * - * For both the `type1' and `t1cid' modules, the default engine is - * `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' + * For both the 'type1' and 't1cid' modules, the default engine is + * 'freetype' if `T1_CONFIG_OPTION_OLD_ENGINE` is defined, and 'adobe' * otherwise. * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 'adobe' or 'freetype'). + * + * @example: * The following example code demonstrates how to select Adobe's hinting - * engine for the `cff' module (omitting the error handling). + * engine for the 'cff' module (omitting the error handling). * - * { + * ``` * FT_Library library; - * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; + * FT_UInt hinting_engine = FT_HINTING_ADOBE; * * * FT_Init_FreeType( &library ); * * FT_Property_Set( library, "cff", * "hinting-engine", &hinting_engine ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values `adobe' or `freetype'). + * ``` * * @since: - * 2.4.12 (for `cff' module) + * 2.4.12 (for 'cff' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -405,10 +405,10 @@ FT_BEGIN_HEADER * no-stem-darkening * * @description: - * All glyphs that pass through the auto-hinter will be emboldened - * unless this property is set to TRUE. The same is true for the CFF, - * Type~1, and CID font modules if the `Adobe' engine is selected (which - * is the default). + * All glyphs that pass through the auto-hinter will be emboldened unless + * this property is set to TRUE. The same is true for the CFF, Type~1, + * and CID font modules if the 'Adobe' engine is selected (which is the + * default). * * Stem darkening emboldens glyphs at smaller sizes to make them more * readable on common low-DPI screens when using linear alpha blending @@ -419,30 +419,38 @@ FT_BEGIN_HEADER * Gamma correction essentially lightens fonts since shades of grey are * shifted to higher pixel values (=~higher brightness) to match the * original intention to the reality of our screens. The side-effect is - * that glyphs `thin out'. Mac OS~X and Adobe's proprietary font + * that glyphs 'thin out'. Mac OS~X and Adobe's proprietary font * rendering library implement a counter-measure: stem darkening at * smaller sizes where shades of gray dominate. By emboldening a glyph * slightly in relation to its pixel size, individual pixels get higher - * coverage of filled-in outlines and are therefore `blacker'. This - * counteracts the `thinning out' of glyphs, making text remain readable + * coverage of filled-in outlines and are therefore 'blacker'. This + * counteracts the 'thinning out' of glyphs, making text remain readable * at smaller sizes. * * By default, the Adobe engines for CFF, Type~1, and CID fonts darken * stems at smaller sizes, regardless of hinting, to enhance contrast. * Setting this property, stem darkening gets switched off. * - * For the auto-hinter, stem-darkening is experimental currently and - * thus switched off by default (this is, `no-stem-darkening' is set to - * TRUE by default). Total consistency with the CFF driver is not - * achieved right now because the emboldening method differs and glyphs - * must be scaled down on the Y-axis to keep outline points inside their + * For the auto-hinter, stem-darkening is experimental currently and thus + * switched off by default (this is, `no-stem-darkening` is set to TRUE + * by default). Total consistency with the CFF driver is not achieved + * right now because the emboldening method differs and glyphs must be + * scaled down on the Y-axis to keep outline points inside their * precomputed blue zones. The smaller the size (especially 9ppem and * down), the higher the loss of emboldening versus the CFF driver. * - * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is - * set. + * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). It + * can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_STEM_DARKENING. * - * { + * @example: + * ``` * FT_Library library; * FT_Bool no_stem_darkening = TRUE; * @@ -451,22 +459,14 @@ FT_BEGIN_HEADER * * FT_Property_Set( library, "cff", * "no-stem-darkening", &no_stem_darkening ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values 1 and 0 for `on' and `off', respectively). - * It can also be set per face using @FT_Face_Properties with - * @FT_PARAM_TAG_STEM_DARKENING. + * ``` * * @since: - * 2.4.12 (for `cff' module) + * 2.4.12 (for 'cff' module) * - * 2.6.2 (for `autofitter' module) + * 2.6.2 (for 'autofitter' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -478,43 +478,29 @@ FT_BEGIN_HEADER * * @description: * By default, the Adobe hinting engine, as used by the CFF, Type~1, and - * CID font drivers, darkens stems as follows (if the - * `no-stem-darkening' property isn't set): + * CID font drivers, darkens stems as follows (if the `no-stem-darkening` + * property isn't set): * - * { + * ``` * stem width <= 0.5px: darkening amount = 0.4px * stem width = 1px: darkening amount = 0.275px * stem width = 1.667px: darkening amount = 0.275px * stem width >= 2.333px: darkening amount = 0px - * } + * ``` * * and piecewise linear in-between. At configuration time, these four * control points can be set with the macro - * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'; the CFF, Type~1, and CID + * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS`; the CFF, Type~1, and CID * drivers share these values. At runtime, the control points can be - * changed using the `darkening-parameters' property, as the following - * example demonstrates for the Type~1 driver. - * - * { - * FT_Library library; - * FT_Int darken_params[8] = { 500, 300, // x1, y1 - * 1000, 200, // x2, y2 - * 1500, 100, // x3, y3 - * 2000, 0 }; // x4, y4 - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "type1", - * "darkening-parameters", darken_params ); - * } + * changed using the `darkening-parameters` property (see the example + * below that demonstrates this for the Type~1 driver). * * The x~values give the stem width, and the y~values the darkening * amount. The unit is 1000th of pixels. All coordinate values must be - * positive; the x~values must be monotonically increasing; the - * y~values must be monotonically decreasing and smaller than or - * equal to 500 (corresponding to half a pixel); the slope of each - * linear piece must be shallower than -1 (e.g., -.4). + * positive; the x~values must be monotonically increasing; the y~values + * must be monotonically decreasing and smaller than or equal to 500 + * (corresponding to half a pixel); the slope of each linear piece must + * be shallower than -1 (e.g., -.4). * * The auto-hinter provides this property, too, as an experimental * feature. See @no-stem-darkening for more. @@ -522,21 +508,36 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * - * This property can be set via the `FREETYPE_PROPERTIES' environment + * This property can be set via the `FREETYPE_PROPERTIES` environment * variable, using eight comma-separated integers without spaces. Here - * the above example, using `\' to break the line for readability. + * the above example, using `\` to break the line for readability. * - * { + * ``` * FREETYPE_PROPERTIES=\ * type1:darkening-parameters=500,300,1000,200,1500,100,2000,0 - * } + * ``` + * + * @example: + * ``` + * FT_Library library; + * FT_Int darken_params[8] = { 500, 300, // x1, y1 + * 1000, 200, // x2, y2 + * 1500, 100, // x3, y3 + * 2000, 0 }; // x4, y4 + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "type1", + * "darkening-parameters", darken_params ); + * ``` * * @since: - * 2.5.1 (for `cff' module) + * 2.5.1 (for 'cff' module) * - * 2.6.2 (for `autofitter' module) + * 2.6.2 (for 'autofitter' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -547,29 +548,29 @@ FT_BEGIN_HEADER * random-seed * * @description: - * By default, the seed value for the CFF `random' operator and the - * similar `0 28 callothersubr pop' command for the Type~1 and CID + * By default, the seed value for the CFF 'random' operator and the + * similar '0 28 callothersubr pop' command for the Type~1 and CID * drivers is set to a random value. However, mainly for debugging - * purposes, it is often necessary to use a known value as a seed so - * that the pseudo-random number sequences generated by `random' are + * purposes, it is often necessary to use a known value as a seed so that + * the pseudo-random number sequences generated by 'random' are * repeatable. * - * The `random-seed' property does that. Its argument is a signed 32bit + * The `random-seed` property does that. Its argument is a signed 32bit * integer; if the value is zero or negative, the seed given by the - * `intitialRandomSeed' private DICT operator in a CFF file gets used - * (or a default value if there is no such operator). If the value is - * positive, use it instead of `initialRandomSeed', which is - * consequently ignored. + * `intitialRandomSeed` private DICT operator in a CFF file gets used (or + * a default value if there is no such operator). If the value is + * positive, use it instead of `initialRandomSeed`, which is consequently + * ignored. * * @note: - * This property can be set via the `FREETYPE_PROPERTIES' environment + * This property can be set via the `FREETYPE_PROPERTIES` environment * variable. It can also be set per face using @FT_Face_Properties with * @FT_PARAM_TAG_RANDOM_SEED. * * @since: - * 2.8 (for `cff' module) + * 2.8 (for 'cff' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -580,21 +581,28 @@ FT_BEGIN_HEADER * no-long-family-names * * @description: - * If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling + * If `PCF_CONFIG_OPTION_LONG_FAMILY_NAMES` is active while compiling * FreeType, the PCF driver constructs long family names. * - * There are many PCF fonts just called `Fixed' which look completely + * There are many PCF fonts just called 'Fixed' which look completely * different, and which have nothing to do with each other. When - * selecting `Fixed' in KDE or Gnome one gets results that appear rather - * random, the style changes often if one changes the size and one - * cannot select some fonts at all. The improve this situation, the PCF - * module prepends the foundry name (plus a space) to the family name. - * It also checks whether there are `wide' characters; all put together, - * family names like `Sony Fixed' or `Misc Fixed Wide' are constructed. + * selecting 'Fixed' in KDE or Gnome one gets results that appear rather + * random, the style changes often if one changes the size and one cannot + * select some fonts at all. The improve this situation, the PCF module + * prepends the foundry name (plus a space) to the family name. It also + * checks whether there are 'wide' characters; all put together, family + * names like 'Sony Fixed' or 'Misc Fixed Wide' are constructed. + * + * If `no-long-family-names` is set, this feature gets switched off. * - * If `no-long-family-names' is set, this feature gets switched off. + * @note: + * This property can be used with @FT_Property_Get also. * - * { + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). + * + * @example: + * ``` * FT_Library library; * FT_Bool no_long_family_names = TRUE; * @@ -604,13 +612,7 @@ FT_BEGIN_HEADER * FT_Property_Set( library, "pcf", * "no-long-family-names", * &no_long_family_names ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values 1 and 0 for `on' and `off', respectively). + * ``` * * @since: * 2.8 @@ -626,8 +628,8 @@ FT_BEGIN_HEADER * A list of constants used for the @interpreter-version property to * select the hinting engine for Truetype fonts. * - * The numeric value in the constant names represents the version - * number as returned by the `GETINFO' bytecode instruction. + * The numeric value in the constant names represents the version number + * as returned by the 'GETINFO' bytecode instruction. * * @values: * TT_INTERPRETER_VERSION_35 :: @@ -638,38 +640,37 @@ FT_BEGIN_HEADER * Version~38 corresponds to MS rasterizer v.1.9; it is roughly * equivalent to the hinting provided by DirectWrite ClearType (as can * be found, for example, in the Internet Explorer~9 running on - * Windows~7). It is used in FreeType to select the `Infinality' - * subpixel hinting code. The code may be removed in a future - * version. + * Windows~7). It is used in FreeType to select the 'Infinality' + * subpixel hinting code. The code may be removed in a future version. * * TT_INTERPRETER_VERSION_40 :: * Version~40 corresponds to MS rasterizer v.2.1; it is roughly * equivalent to the hinting provided by DirectWrite ClearType (as can * be found, for example, in Microsoft's Edge Browser on Windows~10). - * It is used in FreeType to select the `minimal' subpixel hinting + * It is used in FreeType to select the 'minimal' subpixel hinting * code, a stripped-down and higher performance version of the - * `Infinality' code. + * 'Infinality' code. * * @note: - * This property controls the behaviour of the bytecode interpreter - * and thus how outlines get hinted. It does *not* control how glyph - * get rasterized! In particular, it does not control subpixel color + * This property controls the behaviour of the bytecode interpreter and + * thus how outlines get hinted. It does **not** control how glyph get + * rasterized! In particular, it does not control subpixel color * filtering. * * If FreeType has not been compiled with the configuration option - * TT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes - * an `FT_Err_Unimplemented_Feature' error. + * `TT_CONFIG_OPTION_SUBPIXEL_HINTING`, selecting version~38 or~40 causes + * an `FT_Err_Unimplemented_Feature` error. * - * Depending on the graphics framework, Microsoft uses different - * bytecode and rendering engines. As a consequence, the version - * numbers returned by a call to the `GETINFO' bytecode instruction are - * more convoluted than desired. + * Depending on the graphics framework, Microsoft uses different bytecode + * and rendering engines. As a consequence, the version numbers returned + * by a call to the 'GETINFO' bytecode instruction are more convoluted + * than desired. * - * Here are two tables that try to shed some light on the possible - * values for the MS rasterizer engine, together with the additional - * features introduced by it. + * Here are two tables that try to shed some light on the possible values + * for the MS rasterizer engine, together with the additional features + * introduced by it. * - * { + * ``` * GETINFO framework version feature * ------------------------------------------------------------------- * 3 GDI (Win 3.1), v1.0 16-bit, first version @@ -692,15 +693,15 @@ FT_BEGIN_HEADER * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag * DWrite (Win 8) in GETINFO opcode, * Gray ClearType - * } + * ``` * - * The `version' field gives a rough orientation only, since some + * The 'version' field gives a rough orientation only, since some * applications provided certain features much earlier (as an example, * Microsoft Reader used subpixel and Y-direction ClearType already in * Windows 2000). Similarly, updates to a given framework might include * improved hinting support. * - * { + * ``` * version sampling rendering comment * x y x y * -------------------------------------------------------------- @@ -710,38 +711,38 @@ FT_BEGIN_HEADER * v1.9 high high color-filter gray Color ClearType * v2.1 high normal gray B/W Gray ClearType * v2.1 high high gray gray Gray ClearType - * } + * ``` * * Color and Gray ClearType are the two available variants of - * `Y-direction ClearType', meaning grayscale rasterization along the + * 'Y-direction ClearType', meaning grayscale rasterization along the * Y-direction; the name used in the TrueType specification for this - * feature is `symmetric smoothing'. `Classic ClearType' is the - * original algorithm used before introducing a modified version in - * Win~XP. Another name for v1.6's grayscale rendering is `font - * smoothing', and `Color ClearType' is sometimes also called `DWrite - * ClearType'. To differentiate between today's Color ClearType and the - * earlier ClearType variant with B/W rendering along the vertical axis, - * the latter is sometimes called `GDI ClearType'. - * - * `Normal' and `high' sampling describe the (virtual) resolution to - * access the rasterized outline after the hinting process. `Normal' + * feature is 'symmetric smoothing'. 'Classic ClearType' is the original + * algorithm used before introducing a modified version in Win~XP. + * Another name for v1.6's grayscale rendering is 'font smoothing', and + * 'Color ClearType' is sometimes also called 'DWrite ClearType'. To + * differentiate between today's Color ClearType and the earlier + * ClearType variant with B/W rendering along the vertical axis, the + * latter is sometimes called 'GDI ClearType'. + * + * 'Normal' and 'high' sampling describe the (virtual) resolution to + * access the rasterized outline after the hinting process. 'Normal' * means 1 sample per grid line (i.e., B/W). In the current Microsoft - * implementation, `high' means an extra virtual resolution of 16x16 (or - * 16x1) grid lines per pixel for bytecode instructions like `MIRP'. + * implementation, 'high' means an extra virtual resolution of 16x16 (or + * 16x1) grid lines per pixel for bytecode instructions like 'MIRP'. * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid * lines for color filtering if Color ClearType is activated. * - * Note that `Gray ClearType' is essentially the same as v1.6's - * grayscale rendering. However, the GETINFO instruction handles it - * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1 - * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing), - * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for - * the version~1 gasp table exclusively (like Color ClearType), while - * v1.6 only respects the values of version~0 (bits 0 and~1). + * Note that 'Gray ClearType' is essentially the same as v1.6's grayscale + * rendering. However, the GETINFO instruction handles it differently: + * v1.6 returns bit~12 (hinting for grayscale), while v2.1 returns + * bits~13 (hinting for ClearType), 18 (symmetrical smoothing), and~19 + * (Gray ClearType). Also, this mode respects bits 2 and~3 for the + * version~1 gasp table exclusively (like Color ClearType), while v1.6 + * only respects the values of version~0 (bits 0 and~1). * - * Keep in mind that the features of the above interpreter versions - * might not map exactly to FreeType features or behavior because it is - * a fundamentally different library with different internals. + * Keep in mind that the features of the above interpreter versions might + * not map exactly to FreeType features or behavior because it is a + * fundamentally different library with different internals. * */ #define TT_INTERPRETER_VERSION_35 35 @@ -755,33 +756,40 @@ FT_BEGIN_HEADER * interpreter-version * * @description: - * Currently, three versions are available, two representing the - * bytecode interpreter with subpixel hinting support (old `Infinality' - * code and new stripped-down and higher performance `minimal' code) and - * one without, respectively. The default is subpixel support if - * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel support - * otherwise (since it isn't available then). + * Currently, three versions are available, two representing the bytecode + * interpreter with subpixel hinting support (old 'Infinality' code and + * new stripped-down and higher performance 'minimal' code) and one + * without, respectively. The default is subpixel support if + * `TT_CONFIG_OPTION_SUBPIXEL_HINTING` is defined, and no subpixel + * support otherwise (since it isn't available then). * * If subpixel hinting is on, many TrueType bytecode instructions behave - * differently compared to B/W or grayscale rendering (except if `native + * differently compared to B/W or grayscale rendering (except if 'native * ClearType' is selected by the font). Microsoft's main idea is to * render at a much increased horizontal resolution, then sampling down * the created output to subpixel precision. However, many older fonts - * are not suited to this and must be specially taken care of by - * applying (hardcoded) tweaks in Microsoft's interpreter. + * are not suited to this and must be specially taken care of by applying + * (hardcoded) tweaks in Microsoft's interpreter. * * Details on subpixel hinting and some of the necessary tweaks can be * found in Greg Hitchcock's whitepaper at - * `https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. - * Note that FreeType currently doesn't really `subpixel hint' (6x1, 6x2, + * 'https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. + * Note that FreeType currently doesn't really 'subpixel hint' (6x1, 6x2, * or 6x5 supersampling) like discussed in the paper. Depending on the * chosen interpreter, it simply ignores instructions on vertical stems * to arrive at very similar results. * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values '35', '38', or '40'). + * + * @example: * The following example code demonstrates how to deactivate subpixel * hinting (omitting the error handling). * - * { + * ``` * FT_Library library; * FT_Face face; * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35; @@ -792,13 +800,7 @@ FT_BEGIN_HEADER * FT_Property_Set( library, "truetype", * "interpreter-version", * &interpreter_version ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values `35', `38', or `40'). + * ``` * * @since: * 2.5 @@ -811,7 +813,7 @@ FT_BEGIN_HEADER * glyph-to-script-map * * @description: - * *Experimental* *only* + * **Experimental only** * * The auto-hinter provides various script modules to hint glyphs. * Examples of supported scripts are Latin or CJK. Before a glyph is @@ -819,25 +821,26 @@ FT_BEGIN_HEADER * the script is then determined based on Unicode character ranges, see * below. * - * OpenType fonts, however, often provide much more glyphs than - * character codes (small caps, superscripts, ligatures, swashes, etc.), - * to be controlled by so-called `features'. Handling OpenType features - * can be quite complicated and thus needs a separate library on top of + * OpenType fonts, however, often provide much more glyphs than character + * codes (small caps, superscripts, ligatures, swashes, etc.), to be + * controlled by so-called 'features'. Handling OpenType features can be + * quite complicated and thus needs a separate library on top of * FreeType. * * The mapping between glyph indices and scripts (in the auto-hinter - * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an - * array with `num_glyphs' elements, as found in the font's @FT_Face - * structure. The `glyph-to-script-map' property returns a pointer to - * this array, which can be modified as needed. Note that the - * modification should happen before the first glyph gets processed by - * the auto-hinter so that the global analysis of the font shapes - * actually uses the modified mapping. - * - * The following example code demonstrates how to access it (omitting - * the error handling). - * - * { + * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an array + * with `num_glyphs` elements, as found in the font's @FT_Face structure. + * The `glyph-to-script-map` property returns a pointer to this array, + * which can be modified as needed. Note that the modification should + * happen before the first glyph gets processed by the auto-hinter so + * that the global analysis of the font shapes actually uses the modified + * mapping. + * + * @example: + * The following example code demonstrates how to access it (omitting the + * error handling). + * + * ``` * FT_Library library; * FT_Face face; * FT_Prop_GlyphToScriptMap prop; @@ -854,7 +857,7 @@ FT_BEGIN_HEADER * // adjust `prop.map' as needed right here * * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); - * } + * ``` * * @since: * 2.4.11 @@ -868,7 +871,7 @@ FT_BEGIN_HEADER * FT_AUTOHINTER_SCRIPT_XXX * * @description: - * *Experimental* *only* + * **Experimental only** * * A list of constants used for the @glyph-to-script-map property to * specify the script submodule the auto-hinter should use for hinting a @@ -879,14 +882,14 @@ FT_BEGIN_HEADER * Don't auto-hint this glyph. * * FT_AUTOHINTER_SCRIPT_LATIN :: - * Apply the latin auto-hinter. For the auto-hinter, `latin' is a - * very broad term, including Cyrillic and Greek also since characters - * from those scripts share the same design constraints. + * Apply the latin auto-hinter. For the auto-hinter, 'latin' is a very + * broad term, including Cyrillic and Greek also since characters from + * those scripts share the same design constraints. * * By default, characters from the following Unicode ranges are * assigned to this submodule. * - * { + * ``` * U+0020 - U+007F // Basic Latin (no control characters) * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) * U+0100 - U+017F // Latin Extended-A @@ -915,7 +918,7 @@ FT_BEGIN_HEADER * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement - * } + * ``` * * FT_AUTOHINTER_SCRIPT_CJK :: * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old @@ -924,7 +927,7 @@ FT_BEGIN_HEADER * By default, characters from the following Unicode ranges are * assigned to this submodule. * - * { + * ``` * U+1100 - U+11FF // Hangul Jamo * U+2E80 - U+2EFF // CJK Radicals Supplement * U+2F00 - U+2FDF // Kangxi Radicals @@ -957,7 +960,7 @@ FT_BEGIN_HEADER * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement - * } + * ``` * * FT_AUTOHINTER_SCRIPT_INDIC :: * Apply the indic auto-hinter, covering all major scripts from the @@ -967,7 +970,7 @@ FT_BEGIN_HEADER * By default, characters from the following Unicode ranges are * assigned to this submodule. * - * { + * ``` * U+0900 - U+0DFF // Indic Range * U+0F00 - U+0FFF // Tibetan * U+1900 - U+194F // Limbu @@ -975,7 +978,7 @@ FT_BEGIN_HEADER * U+A800 - U+A82F // Syloti Nagri * U+ABC0 - U+ABFF // Meetei Mayek * U+11800 - U+118DF // Sharada - * } + * ``` * * Note that currently Indic support is rudimentary only, missing blue * zone support. @@ -996,7 +999,7 @@ FT_BEGIN_HEADER * FT_Prop_GlyphToScriptMap * * @description: - * *Experimental* *only* + * **Experimental only** * * The data exchange structure for the @glyph-to-script-map property. * @@ -1018,36 +1021,36 @@ FT_BEGIN_HEADER * fallback-script * * @description: - * *Experimental* *only* - * - * If no auto-hinter script module can be assigned to a glyph, a - * fallback script gets assigned to it (see also the - * @glyph-to-script-map property). By default, this is - * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, - * this fallback value can be changed. - * - * { - * FT_Library library; - * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); + * **Experimental only** * - * FT_Property_Set( library, "autofitter", - * "fallback-script", &fallback_script ); - * } + * If no auto-hinter script module can be assigned to a glyph, a fallback + * script gets assigned to it (see also the @glyph-to-script-map + * property). By default, this is @FT_AUTOHINTER_SCRIPT_CJK. Using the + * `fallback-script` property, this fallback value can be changed. * * @note: * This property can be used with @FT_Property_Get also. * * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * fallback script value gets triggered either by setting or reading a + * creation of the glyph-to-script map that eventually uses the fallback + * script value gets triggered either by setting or reading a * face-specific property like @glyph-to-script-map, or by auto-hinting * any glyph from that face. In particular, if you have already created * an @FT_Face structure but not loaded any glyph (using the * auto-hinter), a change of the fallback script will affect this face. * + * @example: + * ``` + * FT_Library library; + * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "fallback-script", &fallback_script ); + * ``` + * * @since: * 2.4.11 * @@ -1060,42 +1063,43 @@ FT_BEGIN_HEADER * default-script * * @description: - * *Experimental* *only* + * **Experimental only** * - * If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make - * the HarfBuzz library access OpenType features for getting better - * glyph coverages, this property sets the (auto-fitter) script to be - * used for the default (OpenType) script data of a font's GSUB table. - * Features for the default script are intended for all scripts not - * explicitly handled in GSUB; an example is a `dlig' feature, - * containing the combination of the characters `T', `E', and `L' to - * form a `TEL' ligature. + * If FreeType gets compiled with `FT_CONFIG_OPTION_USE_HARFBUZZ` to make + * the HarfBuzz library access OpenType features for getting better glyph + * coverages, this property sets the (auto-fitter) script to be used for + * the default (OpenType) script data of a font's GSUB table. Features + * for the default script are intended for all scripts not explicitly + * handled in GSUB; an example is a 'dlig' feature, containing the + * combination of the characters 'T', 'E', and 'L' to form a 'TEL' + * ligature. * * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the - * `default-script' property, this default value can be changed. - * - * { - * FT_Library library; - * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "default-script", &default_script ); - * } + * `default-script` property, this default value can be changed. * * @note: * This property can be used with @FT_Property_Get also. * * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * default script value gets triggered either by setting or reading a + * creation of the glyph-to-script map that eventually uses the default + * script value gets triggered either by setting or reading a * face-specific property like @glyph-to-script-map, or by auto-hinting * any glyph from that face. In particular, if you have already created * an @FT_Face structure but not loaded any glyph (using the * auto-hinter), a change of the default script will affect this face. * + * @example: + * ``` + * FT_Library library; + * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "default-script", &default_script ); + * ``` + * * @since: * 2.5.3 * @@ -1108,13 +1112,20 @@ FT_BEGIN_HEADER * increase-x-height * * @description: - * For ppem values in the range 6~<= ppem <= `increase-x-height', round - * up the font's x~height much more often than normally. If the value - * is set to~0, which is the default, this feature is switched off. Use + * For ppem values in the range 6~<= ppem <= `increase-x-height`, round + * up the font's x~height much more often than normally. If the value is + * set to~0, which is the default, this feature is switched off. Use * this property to improve the legibility of small font sizes if * necessary. * - * { + * @note: + * This property can be used with @FT_Property_Get also. + * + * Set this value right after calling @FT_Set_Char_Size, but before + * loading any glyph (using the auto-hinter). + * + * @example: + * ``` * FT_Library library; * FT_Face face; * FT_Prop_IncreaseXHeight prop; @@ -1129,13 +1140,7 @@ FT_BEGIN_HEADER * * FT_Property_Set( library, "autofitter", * "increase-x-height", &prop ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * Set this value right after calling @FT_Set_Char_Size, but before - * loading any glyph (using the auto-hinter). + * ``` * * @since: * 2.4.11 @@ -1166,46 +1171,48 @@ FT_BEGIN_HEADER * warping * * @description: - * *Experimental* *only* + * **Experimental only** * - * If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to + * If FreeType gets compiled with option `AF_CONFIG_OPTION_USE_WARPER` to * activate the warp hinting code in the auto-hinter, this property * switches warping on and off. * - * Warping only works in `normal' auto-hinting mode replacing it. - * The idea of the code is to slightly scale and shift a glyph along - * the non-hinted dimension (which is usually the horizontal axis) so - * that as much of its segments are aligned (more or less) to the grid. - * To find out a glyph's optimal scaling and shifting value, various - * parameter combinations are tried and scored. + * Warping only works in 'normal' auto-hinting mode replacing it. The + * idea of the code is to slightly scale and shift a glyph along the + * non-hinted dimension (which is usually the horizontal axis) so that as + * much of its segments are aligned (more or less) to the grid. To find + * out a glyph's optimal scaling and shifting value, various parameter + * combinations are tried and scored. * - * By default, warping is off. The example below shows how to switch on - * warping (omitting the error handling). - * - * { - * FT_Library library; - * FT_Bool warping = 1; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "warping", &warping ); - * } + * By default, warping is off. * * @note: * This property can be used with @FT_Property_Get also. * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values 1 and 0 for `on' and `off', respectively). + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). * * The warping code can also change advance widths. Have a look at the - * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure + * `lsb_delta` and `rsb_delta` fields in the @FT_GlyphSlotRec structure * for details on improving inter-glyph distances while rendering. * * Since warping is a global property of the auto-hinter it is best to * change its value before rendering any face. Otherwise, you should - * reload all faces that get auto-hinted in `normal' hinting mode. + * reload all faces that get auto-hinted in 'normal' hinting mode. + * + * @example: + * This example shows how to switch on warping (omitting the error + * handling). + * + * ``` + * FT_Library library; + * FT_Bool warping = 1; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", "warping", &warping ); + * ``` * * @since: * 2.6 diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h index 8ffd346ca8f..9bc7dc65e32 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrdef.h @@ -1,58 +1,57 @@ -/***************************************************************************/ -/* */ -/* fterrdef.h */ -/* */ -/* FreeType error codes (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fterrdef.h + * + * FreeType error codes (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ - /*************************************************************************/ - /* */ - /* <Section> */ - /* error_code_values */ - /* */ - /* <Title> */ - /* Error Code Values */ - /* */ - /* <Abstract> */ - /* All possible error codes returned by FreeType functions. */ - /* */ - /* <Description> */ - /* The list below is taken verbatim from the file `fterrdef.h' */ - /* (loaded automatically by including `FT_FREETYPE_H'). The first */ - /* argument of the `FT_ERROR_DEF_' macro is the error label; by */ - /* default, the prefix `FT_Err_' gets added so that you get error */ - /* names like `FT_Err_Cannot_Open_Resource'. The second argument is */ - /* the error code, and the last argument an error string, which is not */ - /* used by FreeType. */ - /* */ - /* Within your application you should *only* use error names and */ - /* *never* its numeric values! The latter might (and actually do) */ - /* change in forthcoming FreeType versions. */ - /* */ - /* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */ - /* See the `Error Enumerations' subsection how to automatically */ - /* generate a list of error strings. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * error_code_values + * + * @title: + * Error Code Values + * + * @abstract: + * All possible error codes returned by FreeType functions. + * + * @description: + * The list below is taken verbatim from the file `fterrdef.h` (loaded + * automatically by including `FT_FREETYPE_H`). The first argument of the + * `FT_ERROR_DEF_` macro is the error label; by default, the prefix + * `FT_Err_` gets added so that you get error names like + * `FT_Err_Cannot_Open_Resource`. The second argument is the error code, + * and the last argument an error string, which is not used by FreeType. + * + * Within your application you should **only** use error names and + * **never** its numeric values! The latter might (and actually do) + * change in forthcoming FreeType versions. + * + * Macro `FT_NOERRORDEF_` defines `FT_Err_Ok`, which is always zero. See + * the 'Error Enumerations' subsection how to automatically generate a + * list of error strings. + * + */ - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Err_XXX */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @enum: + * FT_Err_XXX + * + */ /* generic errors */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h index f6ee5c24e28..58f5a3ead12 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/fterrors.h @@ -1,110 +1,120 @@ -/***************************************************************************/ -/* */ -/* fterrors.h */ -/* */ -/* FreeType error code handling (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* error_enumerations */ - /* */ - /* <Title> */ - /* Error Enumerations */ - /* */ - /* <Abstract> */ - /* How to handle errors and error strings. */ - /* */ - /* <Description> */ - /* The header file `fterrors.h' (which is automatically included by */ - /* `freetype.h' defines the handling of FreeType's enumeration */ - /* constants. It can also be used to generate error message strings */ - /* with a small macro trick explained below. */ - /* */ - /* *Error* *Formats* */ - /* */ - /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ - /* defined in `ftoption.h' in order to make the higher byte indicate */ - /* the module where the error has happened (this is not compatible */ - /* with standard builds of FreeType~2, however). See the file */ - /* `ftmoderr.h' for more details. */ - /* */ - /* *Error* *Message* *Strings* */ - /* */ - /* Error definitions are set up with special macros that allow client */ - /* applications to build a table of error message strings. The */ - /* strings are not included in a normal build of FreeType~2 to save */ - /* space (most client applications do not use them). */ - /* */ - /* To do so, you have to define the following macros before including */ - /* this file. */ - /* */ - /* { */ - /* FT_ERROR_START_LIST */ - /* } */ - /* */ - /* This macro is called before anything else to define the start of */ - /* the error list. It is followed by several FT_ERROR_DEF calls. */ - /* */ - /* { */ - /* FT_ERROR_DEF( e, v, s ) */ - /* } */ - /* */ - /* This macro is called to define one single error. `e' is the error */ - /* code identifier (e.g., `Invalid_Argument'), `v' is the error's */ - /* numerical value, and `s' is the corresponding error string. */ - /* */ - /* { */ - /* FT_ERROR_END_LIST */ - /* } */ - /* */ - /* This macro ends the list. */ - /* */ - /* Additionally, you have to undefine `FTERRORS_H_' before #including */ - /* this file. */ - /* */ - /* Here is a simple example. */ - /* */ - /* { */ - /* #undef FTERRORS_H_ */ - /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ - /* #define FT_ERROR_START_LIST { */ - /* #define FT_ERROR_END_LIST { 0, NULL } }; */ - /* */ - /* const struct */ - /* { */ - /* int err_code; */ - /* const char* err_msg; */ - /* } ft_errors[] = */ - /* */ - /* #include FT_ERRORS_H */ - /* } */ - /* */ - /* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */ - /* `FT_NOERRORDEF'; it is always zero. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * fterrors.h + * + * FreeType error code handling (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * @section: + * error_enumerations + * + * @title: + * Error Enumerations + * + * @abstract: + * How to handle errors and error strings. + * + * @description: + * The header file `fterrors.h` (which is automatically included by + * `freetype.h` defines the handling of FreeType's enumeration + * constants. It can also be used to generate error message strings + * with a small macro trick explained below. + * + * **Error Formats** + * + * The configuration macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` can be + * defined in `ftoption.h` in order to make the higher byte indicate the + * module where the error has happened (this is not compatible with + * standard builds of FreeType~2, however). See the file `ftmoderr.h` + * for more details. + * + * **Error Message Strings** + * + * Error definitions are set up with special macros that allow client + * applications to build a table of error message strings. The strings + * are not included in a normal build of FreeType~2 to save space (most + * client applications do not use them). + * + * To do so, you have to define the following macros before including + * this file. + * + * ``` + * FT_ERROR_START_LIST + * ``` + * + * This macro is called before anything else to define the start of the + * error list. It is followed by several `FT_ERROR_DEF` calls. + * + * ``` + * FT_ERROR_DEF( e, v, s ) + * ``` + * + * This macro is called to define one single error. 'e' is the error + * code identifier (e.g., `Invalid_Argument`), 'v' is the error's + * numerical value, and 's' is the corresponding error string. + * + * ``` + * FT_ERROR_END_LIST + * ``` + * + * This macro ends the list. + * + * Additionally, you have to undefine `FTERRORS_H_` before #including + * this file. + * + * Here is a simple example. + * + * ``` + * #undef FTERRORS_H_ + * #define FT_ERRORDEF( e, v, s ) { e, s }, + * #define FT_ERROR_START_LIST { + * #define FT_ERROR_END_LIST { 0, NULL } }; + * + * const struct + * { + * int err_code; + * const char* err_msg; + * } ft_errors[] = + * + * #include FT_ERRORS_H + * ``` + * + * An alternative to using an array is a switch statement. + * + * ``` + * #undef FTERRORS_H_ + * #define FT_ERROR_START_LIST switch ( error_code ) { + * #define FT_ERRORDEF( e, v, s ) case v: return s; + * #define FT_ERROR_END_LIST } + * ``` + * + * If you use `FT_CONFIG_OPTION_USE_MODULE_ERRORS`, `error_code` should + * be replaced with `FT_ERROR_BASE(error_code)` in the last example. + */ /* */ - /* In previous FreeType versions we used `__FTERRORS_H__'. However, */ + /* In previous FreeType versions we used `__FTERRORS_H__`. However, */ /* using two successive underscores in a non-system symbol name */ /* violates the C (and C++) standard, so it was changed to the */ /* current form. In spite of this, we have to make */ /* */ + /* ``` */ /* #undefine __FTERRORS_H__ */ + /* ``` */ /* */ /* work for backward compatibility. */ /* */ @@ -130,7 +140,7 @@ /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ - /* By default, we use `FT_Err_'. */ + /* By default, we use `FT_Err_`. */ /* */ #ifndef FT_ERR_PREFIX #define FT_ERR_PREFIX FT_Err_ @@ -158,6 +168,8 @@ /* */ #ifndef FT_ERRORDEF +#define FT_INCLUDE_ERR_PROTOS + #define FT_ERRORDEF( e, v, s ) e = v, #define FT_ERROR_START_LIST enum { #define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; @@ -220,6 +232,53 @@ #undef FT_ERR_PREFIX #endif + /* FT_INCLUDE_ERR_PROTOS: Control if function prototypes should be */ + /* included with `#include FT_ERRORS_H'. This is */ + /* only true where `FT_ERRORDEF` is undefined. */ + /* FT_ERR_PROTOS_DEFINED: Actual multiple-inclusion protection of */ + /* `fterrors.h`. */ +#ifdef FT_INCLUDE_ERR_PROTOS +#undef FT_INCLUDE_ERR_PROTOS + +#ifndef FT_ERR_PROTOS_DEFINED +#define FT_ERR_PROTOS_DEFINED + + + /************************************************************************** + * + * @function: + * FT_Error_String + * + * @description: + * Retrieve the description of a valid FreeType error code. + * + * @input: + * error_code :: + * A valid FreeType error code. + * + * @return: + * A C~string or `NULL`, if any error occurred. + * + * @note: + * FreeType has to be compiled with `FT_CONFIG_OPTION_ERROR_STRINGS` or + * `FT_DEBUG_LEVEL_ERROR` to get meaningful descriptions. + * 'error_string' will be `NULL` otherwise. + * + * Module identification will be ignored: + * + * ```c + * strcmp( FT_Error_String( FT_Err_Unknown_File_Format ), + * FT_Error_String( BDF_Err_Unknown_File_Format ) ) == 0; + * ``` + */ + FT_EXPORT( const char* ) + FT_Error_String( FT_Error error_code ); + + +#endif /* FT_ERR_PROTOS_DEFINED */ + +#endif /* FT_INCLUDE_ERR_PROTOS */ + #endif /* !(FTERRORS_H_ && __FTERRORS_H__) */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h index cc86efac23b..aae0b132649 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftfntfmt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftfntfmt.h */ -/* */ -/* Support functions for font formats. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftfntfmt.h + * + * Support functions for font formats. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTFNTFMT_H_ @@ -32,49 +32,48 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* font_formats */ - /* */ - /* <Title> */ - /* Font Formats */ - /* */ - /* <Abstract> */ - /* Getting the font format. */ - /* */ - /* <Description> */ - /* The single function in this section can be used to get the font */ - /* format. Note that this information is not needed normally; */ - /* however, there are special cases (like in PDF devices) where it is */ - /* important to differentiate, in spite of FreeType's uniform API. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Font_Format */ - /* */ - /* <Description> */ - /* Return a string describing the format of a given face. Possible */ - /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ - /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ - /* */ - /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ - /* */ - /* <Input> */ - /* face :: */ - /* Input face handle. */ - /* */ - /* <Return> */ - /* Font format string. NULL in case of error. */ - /* */ - /* <Note> */ - /* A deprecated name for the same function is */ - /* `FT_Get_X11_Font_Format'. */ - /* */ + /************************************************************************** + * + * @section: + * font_formats + * + * @title: + * Font Formats + * + * @abstract: + * Getting the font format. + * + * @description: + * The single function in this section can be used to get the font format. + * Note that this information is not needed normally; however, there are + * special cases (like in PDF devices) where it is important to + * differentiate, in spite of FreeType's uniform API. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Get_Font_Format + * + * @description: + * Return a string describing the format of a given face. Possible values + * are 'TrueType', 'Type~1', 'BDF', 'PCF', 'Type~42', 'CID~Type~1', 'CFF', + * 'PFR', and 'Windows~FNT'. + * + * The return value is suitable to be used as an X11 FONT_PROPERTY. + * + * @input: + * face :: + * Input face handle. + * + * @return: + * Font format string. `NULL` in case of error. + * + * @note: + * A deprecated name for the same function is `FT_Get_X11_Font_Format`. + */ FT_EXPORT( const char* ) FT_Get_Font_Format( FT_Face face ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h index fc1248ff489..24673d8ce16 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgasp.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgasp.h */ -/* */ -/* Access of TrueType's `gasp' table (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgasp.h + * + * Access of TrueType's 'gasp' table (specification). + * + * Copyright (C) 2007-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGASP_H_ @@ -32,7 +32,7 @@ FT_BEGIN_HEADER - /*************************************************************************** + /************************************************************************** * * @section: * gasp_table @@ -41,16 +41,16 @@ FT_BEGIN_HEADER * Gasp Table * * @abstract: - * Retrieving TrueType `gasp' table entries. + * Retrieving TrueType 'gasp' table entries. * * @description: * The function @FT_Get_Gasp can be used to query a TrueType or OpenType - * font for specific entries in its `gasp' table, if any. This is - * mainly useful when implementing native TrueType hinting with the - * bytecode interpreter to duplicate the Windows text rendering results. + * font for specific entries in its 'gasp' table, if any. This is mainly + * useful when implementing native TrueType hinting with the bytecode + * interpreter to duplicate the Windows text rendering results. */ - /************************************************************************* + /************************************************************************** * * @enum: * FT_GASP_XXX @@ -66,7 +66,7 @@ FT_BEGIN_HEADER * * FT_GASP_DO_GRIDFIT :: * Grid-fitting and hinting should be performed at the specified ppem. - * This *really* means TrueType bytecode interpretation. If this bit + * This **really** means TrueType bytecode interpretation. If this bit * is not set, no hinting gets applied. * * FT_GASP_DO_GRAY :: @@ -80,13 +80,13 @@ FT_BEGIN_HEADER * Grid-fitting must be used with ClearType's symmetric smoothing. * * @note: - * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be + * The bit-flags `FT_GASP_DO_GRIDFIT` and `FT_GASP_DO_GRAY` are to be * used for standard font rasterization only. Independently of that, - * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to - * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and - * `FT_GASP_DO_GRAY' are consequently ignored). + * `FT_GASP_SYMMETRIC_SMOOTHING` and `FT_GASP_SYMMETRIC_GRIDFIT` are to + * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT` and + * `FT_GASP_DO_GRAY` are consequently ignored). * - * `ClearType' is Microsoft's implementation of LCD rendering, partly + * 'ClearType' is Microsoft's implementation of LCD rendering, partly * protected by patents. * * @since: @@ -99,29 +99,31 @@ FT_BEGIN_HEADER #define FT_GASP_SYMMETRIC_SMOOTHING 0x08 - /************************************************************************* + /************************************************************************** * - * @func: + * @function: * FT_Get_Gasp * * @description: * For a TrueType or OpenType font file, return the rasterizer behaviour - * flags from the font's `gasp' table corresponding to a given - * character pixel size. + * flags from the font's 'gasp' table corresponding to a given character + * pixel size. * * @input: - * face :: The source face handle. + * face :: + * The source face handle. * - * ppem :: The vertical character pixel size. + * ppem :: + * The vertical character pixel size. * * @return: * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no - * `gasp' table in the face. + * 'gasp' table in the face. * * @note: * If you want to use the MM functionality of OpenType variation fonts * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this - * function *after* setting an instance since the return values can + * function **after** setting an instance since the return values can * change. * * @since: diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h index 5f3fc009cd4..4067c2e62fa 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftglyph.h @@ -1,32 +1,32 @@ -/***************************************************************************/ -/* */ -/* ftglyph.h */ -/* */ -/* FreeType convenience functions to handle glyphs (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftglyph.h + * + * FreeType convenience functions to handle glyphs (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file contains the definition of several convenience functions that + * can be used by client applications to easily retrieve glyph bitmaps and + * outlines from a given face. + * + * These functions should be optional if you are writing a font server or + * text layout engine on top of FreeType. However, they are pretty handy + * for many other simple uses of the library. + * + */ #ifndef FTGLYPH_H_ @@ -46,65 +46,70 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_management */ - /* */ - /* <Title> */ - /* Glyph Management */ - /* */ - /* <Abstract> */ - /* Generic interface to manage individual glyph data. */ - /* */ - /* <Description> */ - /* This section contains definitions used to manage glyph data */ - /* through generic FT_Glyph objects. Each of them can contain a */ - /* bitmap, a vector outline, or even images in other formats. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * glyph_management + * + * @title: + * Glyph Management + * + * @abstract: + * Generic interface to manage individual glyph data. + * + * @description: + * This section contains definitions used to manage glyph data through + * generic @FT_Glyph objects. Each of them can contain a bitmap, + * a vector outline, or even images in other formats. These objects are + * detached from @FT_Face, contrary to @FT_GlyphSlot. + * + */ /* forward declaration to a private type */ typedef struct FT_Glyph_Class_ FT_Glyph_Class; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Glyph */ - /* */ - /* <Description> */ - /* Handle to an object used to model generic glyph images. It is a */ - /* pointer to the @FT_GlyphRec structure and can contain a glyph */ - /* bitmap or pointer. */ - /* */ - /* <Note> */ - /* Glyph objects are not owned by the library. You must thus release */ - /* them manually (through @FT_Done_Glyph) _before_ calling */ - /* @FT_Done_FreeType. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Glyph + * + * @description: + * Handle to an object used to model generic glyph images. It is a + * pointer to the @FT_GlyphRec structure and can contain a glyph bitmap + * or pointer. + * + * @note: + * Glyph objects are not owned by the library. You must thus release + * them manually (through @FT_Done_Glyph) _before_ calling + * @FT_Done_FreeType. + */ typedef struct FT_GlyphRec_* FT_Glyph; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphRec */ - /* */ - /* <Description> */ - /* The root glyph structure contains a given glyph image plus its */ - /* advance width in 16.16 fixed-point format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library object. */ - /* */ - /* clazz :: A pointer to the glyph's class. Private. */ - /* */ - /* format :: The format of the glyph's image. */ - /* */ - /* advance :: A 16.16 vector that gives the glyph's advance width. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_GlyphRec + * + * @description: + * The root glyph structure contains a given glyph image plus its advance + * width in 16.16 fixed-point format. + * + * @fields: + * library :: + * A handle to the FreeType library object. + * + * clazz :: + * A pointer to the glyph's class. Private. + * + * format :: + * The format of the glyph's image. + * + * advance :: + * A 16.16 vector that gives the glyph's advance width. + */ typedef struct FT_GlyphRec_ { FT_Library library; @@ -115,48 +120,51 @@ FT_BEGIN_HEADER } FT_GlyphRec; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_BitmapGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model a bitmap glyph image. This is */ - /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ - /* */ + /************************************************************************** + * + * @type: + * FT_BitmapGlyph + * + * @description: + * A handle to an object used to model a bitmap glyph image. This is a + * sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. + */ typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BitmapGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for bitmap glyph images. This really is a */ - /* `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* left :: The left-side bearing, i.e., the horizontal distance */ - /* from the current pen position to the left border of the */ - /* glyph bitmap. */ - /* */ - /* top :: The top-side bearing, i.e., the vertical distance from */ - /* the current pen position to the top border of the glyph */ - /* bitmap. This distance is positive for upwards~y! */ - /* */ - /* bitmap :: A descriptor for the bitmap. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ - /* the bitmap's contents easily. */ - /* */ - /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ - /* and is thus created and destroyed with it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_BitmapGlyphRec + * + * @description: + * A structure used for bitmap glyph images. This really is a + * 'sub-class' of @FT_GlyphRec. + * + * @fields: + * root :: + * The root @FT_Glyph fields. + * + * left :: + * The left-side bearing, i.e., the horizontal distance from the + * current pen position to the left border of the glyph bitmap. + * + * top :: + * The top-side bearing, i.e., the vertical distance from the current + * pen position to the top border of the glyph bitmap. This distance + * is positive for upwards~y! + * + * bitmap :: + * A descriptor for the bitmap. + * + * @note: + * You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have + * `glyph->format == FT_GLYPH_FORMAT_BITMAP`. This lets you access the + * bitmap's contents easily. + * + * The corresponding pixel buffer is always owned by @FT_BitmapGlyph and + * is thus created and destroyed with it. + */ typedef struct FT_BitmapGlyphRec_ { FT_GlyphRec root; @@ -167,44 +175,46 @@ FT_BEGIN_HEADER } FT_BitmapGlyphRec; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_OutlineGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model an outline glyph image. This */ - /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ - /* */ + /************************************************************************** + * + * @type: + * FT_OutlineGlyph + * + * @description: + * A handle to an object used to model an outline glyph image. This is a + * sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. + */ typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_OutlineGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for outline (vectorial) glyph images. This */ - /* really is a `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* outline :: A descriptor for the outline. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ - /* the outline's content easily. */ - /* */ - /* As the outline is extracted from a glyph slot, its coordinates are */ - /* expressed normally in 26.6 pixels, unless the flag */ - /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ - /* */ - /* The outline's tables are always owned by the object and are */ - /* destroyed with it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_OutlineGlyphRec + * + * @description: + * A structure used for outline (vectorial) glyph images. This really is + * a 'sub-class' of @FT_GlyphRec. + * + * @fields: + * root :: + * The root @FT_Glyph fields. + * + * outline :: + * A descriptor for the outline. + * + * @note: + * You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have + * `glyph->format == FT_GLYPH_FORMAT_OUTLINE`. This lets you access the + * outline's content easily. + * + * As the outline is extracted from a glyph slot, its coordinates are + * expressed normally in 26.6 pixels, unless the flag @FT_LOAD_NO_SCALE + * was used in @FT_Load_Glyph() or @FT_Load_Char(). + * + * The outline's tables are always owned by the object and are destroyed + * with it. + */ typedef struct FT_OutlineGlyphRec_ { FT_GlyphRec root; @@ -213,113 +223,150 @@ FT_BEGIN_HEADER } FT_OutlineGlyphRec; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph */ - /* */ - /* <Description> */ - /* A function used to extract a glyph image from a slot. Note that */ - /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* slot :: A handle to the source glyph slot. */ - /* */ - /* <Output> */ - /* aglyph :: A handle to the glyph object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16 */ - /* fixed-point numbers, `slot->advance.x' and `slot->advance.y' */ - /* (which are in 26.6 fixed-point format) must be in the range */ - /* ]-32768;32768[. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Glyph + * + * @description: + * A function used to create a new empty glyph image. Note that the + * created @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * library :: + * A handle to the FreeType library object. + * + * format :: + * The format of the glyph's image. + * + * @output: + * aglyph :: + * A handle to the glyph object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_New_Glyph( FT_Library library, + FT_Glyph_Format format, + FT_Glyph *aglyph ); + + + /************************************************************************** + * + * @function: + * FT_Get_Glyph + * + * @description: + * A function used to extract a glyph image from a slot. Note that the + * created @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * slot :: + * A handle to the source glyph slot. + * + * @output: + * aglyph :: + * A handle to the glyph object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Because `*aglyph->advance.x` and `*aglyph->advance.y` are 16.16 + * fixed-point numbers, `slot->advance.x` and `slot->advance.y` (which + * are in 26.6 fixed-point format) must be in the range ]-32768;32768[. + */ FT_EXPORT( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot, FT_Glyph *aglyph ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Copy */ - /* */ - /* <Description> */ - /* A function used to copy a glyph image. Note that the created */ - /* @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* source :: A handle to the source glyph object. */ - /* */ - /* <Output> */ - /* target :: A handle to the target glyph object. 0~in case of */ - /* error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_Copy + * + * @description: + * A function used to copy a glyph image. Note that the created + * @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * source :: + * A handle to the source glyph object. + * + * @output: + * target :: + * A handle to the target glyph object. 0~in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Glyph_Copy( FT_Glyph source, FT_Glyph *target ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Transform */ - /* */ - /* <Description> */ - /* Transform a glyph image if its format is scalable. */ - /* */ - /* <InOut> */ - /* glyph :: A handle to the target glyph object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to a 2x2 matrix to apply. */ - /* */ - /* delta :: A pointer to a 2d vector to apply. Coordinates are */ - /* expressed in 1/64th of a pixel. */ - /* */ - /* <Return> */ - /* FreeType error code (if not 0, the glyph format is not scalable). */ - /* */ - /* <Note> */ - /* The 2x2 transformation matrix is also applied to the glyph's */ - /* advance vector. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_Transform + * + * @description: + * Transform a glyph image if its format is scalable. + * + * @inout: + * glyph :: + * A handle to the target glyph object. + * + * @input: + * matrix :: + * A pointer to a 2x2 matrix to apply. + * + * delta :: + * A pointer to a 2d vector to apply. Coordinates are expressed in + * 1/64th of a pixel. + * + * @return: + * FreeType error code (if not 0, the glyph format is not scalable). + * + * @note: + * The 2x2 transformation matrix is also applied to the glyph's advance + * vector. + */ FT_EXPORT( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph, FT_Matrix* matrix, FT_Vector* delta ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_BBox_Mode */ - /* */ - /* <Description> */ - /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ - /* */ - /* <Values> */ - /* FT_GLYPH_BBOX_UNSCALED :: */ - /* Return unscaled font units. */ - /* */ - /* FT_GLYPH_BBOX_SUBPIXELS :: */ - /* Return unfitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_GRIDFIT :: */ - /* Return grid-fitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_TRUNCATE :: */ - /* Return coordinates in integer pixels. */ - /* */ - /* FT_GLYPH_BBOX_PIXELS :: */ - /* Return grid-fitted pixel coordinates. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Glyph_BBox_Mode + * + * @description: + * The mode how the values of @FT_Glyph_Get_CBox are returned. + * + * @values: + * FT_GLYPH_BBOX_UNSCALED :: + * Return unscaled font units. + * + * FT_GLYPH_BBOX_SUBPIXELS :: + * Return unfitted 26.6 coordinates. + * + * FT_GLYPH_BBOX_GRIDFIT :: + * Return grid-fitted 26.6 coordinates. + * + * FT_GLYPH_BBOX_TRUNCATE :: + * Return coordinates in integer pixels. + * + * FT_GLYPH_BBOX_PIXELS :: + * Return grid-fitted pixel coordinates. + */ typedef enum FT_Glyph_BBox_Mode_ { FT_GLYPH_BBOX_UNSCALED = 0, @@ -332,7 +379,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Glyph_BBox_Mode' values instead */ + /* `FT_Glyph_BBox_Mode` values instead */ #define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED #define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS #define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT @@ -340,187 +387,188 @@ FT_BEGIN_HEADER #define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Get_CBox */ - /* */ - /* <Description> */ - /* Return a glyph's `control box'. The control box encloses all the */ - /* outline's points, including Bezier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bezier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the source glyph object. */ - /* */ - /* mode :: The mode that indicates how to interpret the returned */ - /* bounding box values. */ - /* */ - /* <Output> */ - /* acbox :: The glyph coordinate bounding box. Coordinates are */ - /* expressed in 1/64th of pixels if it is grid-fitted. */ - /* */ - /* <Note> */ - /* Coordinates are relative to the glyph origin, using the y~upwards */ - /* convention. */ - /* */ - /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ - /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ - /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ - /* is another name for this constant. */ - /* */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ - /* reasonable values for the CBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the CBox, */ - /* which can be eventually converted back to font units. */ - /* */ - /* Note that the maximum coordinates are exclusive, which means that */ - /* one can compute the width and height of the glyph image (be it in */ - /* integer or 26.6 pixels) as: */ - /* */ - /* { */ - /* width = bbox.xMax - bbox.xMin; */ - /* height = bbox.yMax - bbox.yMin; */ - /* } */ - /* */ - /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ - /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ - /* which corresponds to: */ - /* */ - /* { */ - /* bbox.xMin = FLOOR(bbox.xMin); */ - /* bbox.yMin = FLOOR(bbox.yMin); */ - /* bbox.xMax = CEILING(bbox.xMax); */ - /* bbox.yMax = CEILING(bbox.yMax); */ - /* } */ - /* */ - /* To get the bbox in pixel coordinates, set `bbox_mode' to */ - /* @FT_GLYPH_BBOX_TRUNCATE. */ - /* */ - /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ - /* to @FT_GLYPH_BBOX_PIXELS. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_Get_CBox + * + * @description: + * Return a glyph's 'control box'. The control box encloses all the + * outline's points, including Bezier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline that + * contains Bezier outside arcs). + * + * Computing the control box is very fast, while getting the bounding box + * can take much more time as it needs to walk over all segments and arcs + * in the outline. To get the latter, you can use the 'ftbbox' + * component, which is dedicated to this single task. + * + * @input: + * glyph :: + * A handle to the source glyph object. + * + * mode :: + * The mode that indicates how to interpret the returned bounding box + * values. + * + * @output: + * acbox :: + * The glyph coordinate bounding box. Coordinates are expressed in + * 1/64th of pixels if it is grid-fitted. + * + * @note: + * Coordinates are relative to the glyph origin, using the y~upwards + * convention. + * + * If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode` must + * be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6 + * pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS is another name for + * this constant. + * + * If the font is tricky and the glyph has been loaded with + * @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get + * reasonable values for the CBox it is necessary to load the glyph at a + * large ppem value (so that the hinting instructions can properly shift + * and scale the subglyphs), then extracting the CBox, which can be + * eventually converted back to font units. + * + * Note that the maximum coordinates are exclusive, which means that one + * can compute the width and height of the glyph image (be it in integer + * or 26.6 pixels) as: + * + * ``` + * width = bbox.xMax - bbox.xMin; + * height = bbox.yMax - bbox.yMin; + * ``` + * + * Note also that for 26.6 coordinates, if `bbox_mode` is set to + * @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, + * which corresponds to: + * + * ``` + * bbox.xMin = FLOOR(bbox.xMin); + * bbox.yMin = FLOOR(bbox.yMin); + * bbox.xMax = CEILING(bbox.xMax); + * bbox.yMax = CEILING(bbox.yMax); + * ``` + * + * To get the bbox in pixel coordinates, set `bbox_mode` to + * @FT_GLYPH_BBOX_TRUNCATE. + * + * To get the bbox in grid-fitted pixel coordinates, set `bbox_mode` to + * @FT_GLYPH_BBOX_PIXELS. + */ FT_EXPORT( void ) FT_Glyph_Get_CBox( FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_To_Bitmap */ - /* */ - /* <Description> */ - /* Convert a given glyph object to a bitmap glyph object. */ - /* */ - /* <InOut> */ - /* the_glyph :: A pointer to a handle to the target glyph. */ - /* */ - /* <Input> */ - /* render_mode :: An enumeration that describes how the data is */ - /* rendered. */ - /* */ - /* origin :: A pointer to a vector used to translate the glyph */ - /* image before rendering. Can be~0 (if no */ - /* translation). The origin is expressed in */ - /* 26.6 pixels. */ - /* */ - /* destroy :: A boolean that indicates that the original glyph */ - /* image should be destroyed by this function. It is */ - /* never destroyed in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does nothing if the glyph format isn't scalable. */ - /* */ - /* The glyph image is translated with the `origin' vector before */ - /* rendering. */ - /* */ - /* The first parameter is a pointer to an @FT_Glyph handle, that will */ - /* be _replaced_ by this function (with newly allocated data). */ - /* Typically, you would use (omitting error handling): */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyph; */ - /* FT_BitmapGlyph glyph_bitmap; */ - /* */ - /* */ - /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); */ - /* */ - /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ - /* */ - /* // convert to a bitmap (default render mode + destroying old) */ - /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ - /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ - /* 0, 1 ); */ - /* if ( error ) // `glyph' unchanged */ - /* ... */ - /* } */ - /* */ - /* // access bitmap content by typecasting */ - /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ - /* */ - /* // do funny stuff with it, like blitting/drawing */ - /* ... */ - /* */ - /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ - /* } */ - /* */ - /* */ - /* Here another example, again without error handling: */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyphs[MAX_GLYPHS] */ - /* */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ - /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* { */ - /* FT_Glyph bitmap = glyphs[idx]; */ - /* */ - /* */ - /* ... */ - /* */ - /* // after this call, `bitmap' no longer points into */ - /* // the `glyphs' array (and the old value isn't destroyed) */ - /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ - /* */ - /* ... */ - /* */ - /* FT_Done_Glyph( bitmap ); */ - /* } */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* FT_Done_Glyph( glyphs[idx] ); */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_To_Bitmap + * + * @description: + * Convert a given glyph object to a bitmap glyph object. + * + * @inout: + * the_glyph :: + * A pointer to a handle to the target glyph. + * + * @input: + * render_mode :: + * An enumeration that describes how the data is rendered. + * + * origin :: + * A pointer to a vector used to translate the glyph image before + * rendering. Can be~0 (if no translation). The origin is expressed + * in 26.6 pixels. + * + * destroy :: + * A boolean that indicates that the original glyph image should be + * destroyed by this function. It is never destroyed in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does nothing if the glyph format isn't scalable. + * + * The glyph image is translated with the `origin` vector before + * rendering. + * + * The first parameter is a pointer to an @FT_Glyph handle, that will be + * _replaced_ by this function (with newly allocated data). Typically, + * you would use (omitting error handling): + * + * ``` + * FT_Glyph glyph; + * FT_BitmapGlyph glyph_bitmap; + * + * + * // load glyph + * error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); + * + * // extract glyph image + * error = FT_Get_Glyph( face->glyph, &glyph ); + * + * // convert to a bitmap (default render mode + destroying old) + * if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) + * { + * error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, + * 0, 1 ); + * if ( error ) // `glyph' unchanged + * ... + * } + * + * // access bitmap content by typecasting + * glyph_bitmap = (FT_BitmapGlyph)glyph; + * + * // do funny stuff with it, like blitting/drawing + * ... + * + * // discard glyph image (bitmap or not) + * FT_Done_Glyph( glyph ); + * ``` + * + * Here is another example, again without error handling: + * + * ``` + * FT_Glyph glyphs[MAX_GLYPHS] + * + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || + * FT_Get_Glyph ( face->glyph, &glyphs[idx] ); + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * { + * FT_Glyph bitmap = glyphs[idx]; + * + * + * ... + * + * // after this call, `bitmap' no longer points into + * // the `glyphs' array (and the old value isn't destroyed) + * FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); + * + * ... + * + * FT_Done_Glyph( bitmap ); + * } + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * FT_Done_Glyph( glyphs[idx] ); + * ``` + */ FT_EXPORT( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, FT_Render_Mode render_mode, @@ -528,17 +576,18 @@ FT_BEGIN_HEADER FT_Bool destroy ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Glyph */ - /* */ - /* <Description> */ - /* Destroy a given glyph. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the target glyph object. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Glyph + * + * @description: + * Destroy a given glyph. + * + * @input: + * glyph :: + * A handle to the target glyph object. + */ FT_EXPORT( void ) FT_Done_Glyph( FT_Glyph glyph ); @@ -547,54 +596,56 @@ FT_BEGIN_HEADER /* other helpful functions */ - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Multiply */ - /* */ - /* <Description> */ - /* Perform the matrix operation `b = a*b'. */ - /* */ - /* <Input> */ - /* a :: A pointer to matrix `a'. */ - /* */ - /* <InOut> */ - /* b :: A pointer to matrix `b'. */ - /* */ - /* <Note> */ - /* The result is undefined if either `a' or `b' is zero. */ - /* */ - /* Since the function uses wrap-around arithmetic, results become */ - /* meaningless if the arguments are very large. */ - /* */ + /************************************************************************** + * + * @section: + * computations + * + */ + + + /************************************************************************** + * + * @function: + * FT_Matrix_Multiply + * + * @description: + * Perform the matrix operation `b = a*b`. + * + * @input: + * a :: + * A pointer to matrix `a`. + * + * @inout: + * b :: + * A pointer to matrix `b`. + * + * @note: + * The result is undefined if either `a` or `b` is zero. + * + * Since the function uses wrap-around arithmetic, results become + * meaningless if the arguments are very large. + */ FT_EXPORT( void ) FT_Matrix_Multiply( const FT_Matrix* a, FT_Matrix* b ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Invert */ - /* */ - /* <Description> */ - /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ - /* */ - /* <InOut> */ - /* matrix :: A pointer to the target matrix. Remains untouched in */ - /* case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Matrix_Invert + * + * @description: + * Invert a 2x2 matrix. Return an error if it can't be inverted. + * + * @inout: + * matrix :: + * A pointer to the target matrix. Remains untouched in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h index db033da0ed2..418c61228ea 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftgzip.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgzip.h */ -/* */ -/* Gzip-compressed stream support. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgzip.h + * + * Gzip-compressed stream support. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGZIP_H_ @@ -31,108 +31,108 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* gzip */ - /* */ - /* <Title> */ - /* GZIP Streams */ - /* */ - /* <Abstract> */ - /* Using gzip-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Gzip-specific functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************ - * - * @function: - * FT_Stream_OpenGzip - * - * @description: - * Open a new stream to parse gzip-compressed font files. This is - * mainly used to support the compressed `*.pcf.gz' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, gzip compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a gzipped stream from - * it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - */ + /************************************************************************** + * + * @section: + * gzip + * + * @title: + * GZIP Streams + * + * @abstract: + * Using gzip-compressed font files. + * + * @description: + * This section contains the declaration of Gzip-specific functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Stream_OpenGzip + * + * @description: + * Open a new stream to parse gzip-compressed font files. This is mainly + * used to support the compressed `*.pcf.gz` fonts that come with + * XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, gzip compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a gzipped stream from it + * and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with zlib support. + */ FT_EXPORT( FT_Error ) FT_Stream_OpenGzip( FT_Stream stream, FT_Stream source ); - /************************************************************************ - * - * @function: - * FT_Gzip_Uncompress - * - * @description: - * Decompress a zipped input buffer into an output buffer. This function - * is modeled after zlib's `uncompress' function. - * - * @input: - * memory :: - * A FreeType memory handle. - * - * input :: - * The input buffer. - * - * input_len :: - * The length of the input buffer. - * - * @output: - * output:: - * The output buffer. - * - * @inout: - * output_len :: - * Before calling the function, this is the total size of the output - * buffer, which must be large enough to hold the entire uncompressed - * data (so the size of the uncompressed data must be known in - * advance). After calling the function, `output_len' is the size of - * the used data in `output'. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - * - * @since: - * 2.5.1 - */ + /************************************************************************** + * + * @function: + * FT_Gzip_Uncompress + * + * @description: + * Decompress a zipped input buffer into an output buffer. This function + * is modeled after zlib's `uncompress` function. + * + * @input: + * memory :: + * A FreeType memory handle. + * + * input :: + * The input buffer. + * + * input_len :: + * The length of the input buffer. + * + * @output: + * output :: + * The output buffer. + * + * @inout: + * output_len :: + * Before calling the function, this is the total size of the output + * buffer, which must be large enough to hold the entire uncompressed + * data (so the size of the uncompressed data must be known in + * advance). After calling the function, `output_len` is the size of + * the used data in `output`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with zlib support. + * + * @since: + * 2.5.1 + */ FT_EXPORT( FT_Error ) FT_Gzip_Uncompress( FT_Memory memory, FT_Byte* output, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h index 79ede1959d7..d640b0b0aa9 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftimage.h */ -/* */ -/* FreeType glyph image formats and default raster interface */ -/* (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Note: A `raster' is simply a scan-line converter, used to render */ - /* FT_Outlines into FT_Bitmaps. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftimage.h + * + * FreeType glyph image formats and default raster interface + * (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Note: A 'raster' is simply a scan-line converter, used to render + * FT_Outlines into FT_Bitmaps. + * + */ #ifndef FTIMAGE_H_ @@ -37,40 +37,42 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pos */ - /* */ - /* <Description> */ - /* The type FT_Pos is used to store vectorial coordinates. Depending */ - /* on the context, these can represent distances in integer font */ - /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ - /* */ + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @type: + * FT_Pos + * + * @description: + * The type FT_Pos is used to store vectorial coordinates. Depending on + * the context, these can represent distances in integer font units, or + * 16.16, or 26.6 fixed-point pixel coordinates. + */ typedef signed long FT_Pos; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Vector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector; coordinates are of */ - /* the FT_Pos type. */ - /* */ - /* <Fields> */ - /* x :: The horizontal coordinate. */ - /* y :: The vertical coordinate. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Vector + * + * @description: + * A simple structure used to store a 2D vector; coordinates are of the + * FT_Pos type. + * + * @fields: + * x :: + * The horizontal coordinate. + * y :: + * The vertical coordinate. + */ typedef struct FT_Vector_ { FT_Pos x; @@ -79,39 +81,41 @@ FT_BEGIN_HEADER } FT_Vector; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BBox */ - /* */ - /* <Description> */ - /* A structure used to hold an outline's bounding box, i.e., the */ - /* coordinates of its extrema in the horizontal and vertical */ - /* directions. */ - /* */ - /* <Fields> */ - /* xMin :: The horizontal minimum (left-most). */ - /* */ - /* yMin :: The vertical minimum (bottom-most). */ - /* */ - /* xMax :: The horizontal maximum (right-most). */ - /* */ - /* yMax :: The vertical maximum (top-most). */ - /* */ - /* <Note> */ - /* The bounding box is specified with the coordinates of the lower */ - /* left and the upper right corner. In PostScript, those values are */ - /* often called (llx,lly) and (urx,ury), respectively. */ - /* */ - /* If `yMin' is negative, this value gives the glyph's descender. */ - /* Otherwise, the glyph doesn't descend below the baseline. */ - /* Similarly, if `ymax' is positive, this value gives the glyph's */ - /* ascender. */ - /* */ - /* `xMin' gives the horizontal distance from the glyph's origin to */ - /* the left edge of the glyph's bounding box. If `xMin' is negative, */ - /* the glyph extends to the left of the origin. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_BBox + * + * @description: + * A structure used to hold an outline's bounding box, i.e., the + * coordinates of its extrema in the horizontal and vertical directions. + * + * @fields: + * xMin :: + * The horizontal minimum (left-most). + * + * yMin :: + * The vertical minimum (bottom-most). + * + * xMax :: + * The horizontal maximum (right-most). + * + * yMax :: + * The vertical maximum (top-most). + * + * @note: + * The bounding box is specified with the coordinates of the lower left + * and the upper right corner. In PostScript, those values are often + * called (llx,lly) and (urx,ury), respectively. + * + * If `yMin` is negative, this value gives the glyph's descender. + * Otherwise, the glyph doesn't descend below the baseline. Similarly, + * if `ymax` is positive, this value gives the glyph's ascender. + * + * `xMin` gives the horizontal distance from the glyph's origin to the + * left edge of the glyph's bounding box. If `xMin` is negative, the + * glyph extends to the left of the origin. + */ typedef struct FT_BBox_ { FT_Pos xMin, yMin; @@ -120,63 +124,60 @@ FT_BEGIN_HEADER } FT_BBox; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Pixel_Mode */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of pixels in a */ - /* given bitmap. Note that additional formats may be added in the */ - /* future. */ - /* */ - /* <Values> */ - /* FT_PIXEL_MODE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_PIXEL_MODE_MONO :: */ - /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */ - /* are stored in most-significant order (MSB), which means that */ - /* the left-most pixel in a byte has value 128. */ - /* */ - /* FT_PIXEL_MODE_GRAY :: */ - /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ - /* images. Each pixel is stored in one byte. Note that the number */ - /* of `gray' levels is stored in the `num_grays' field of the */ - /* @FT_Bitmap structure (it generally is 256). */ - /* */ - /* FT_PIXEL_MODE_GRAY2 :: */ - /* A 2-bit per pixel bitmap, used to represent embedded */ - /* anti-aliased bitmaps in font files according to the OpenType */ - /* specification. We haven't found a single font using this */ - /* format, however. */ - /* */ - /* FT_PIXEL_MODE_GRAY4 :: */ - /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ - /* bitmaps in font files according to the OpenType specification. */ - /* We haven't found a single font using this format, however. */ - /* */ - /* FT_PIXEL_MODE_LCD :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on LCD displays; the bitmap is three times */ - /* wider than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD. */ - /* */ - /* FT_PIXEL_MODE_LCD_V :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on rotated LCD displays; the bitmap is three */ - /* times taller than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD_V. */ - /* */ - /* FT_PIXEL_MODE_BGRA :: */ - /* [Since 2.5] An image with four 8-bit channels per pixel, */ - /* representing a color image (such as emoticons) with alpha */ - /* channel. For each pixel, the format is BGRA, which means, the */ - /* blue channel comes first in memory. The color channels are */ - /* pre-multiplied and in the sRGB colorspace. For example, full */ - /* red at half-translucent opacity will be represented as */ - /* `00,00,80,80', not `00,00,FF,80'. See also @FT_LOAD_COLOR. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Pixel_Mode + * + * @description: + * An enumeration type used to describe the format of pixels in a given + * bitmap. Note that additional formats may be added in the future. + * + * @values: + * FT_PIXEL_MODE_NONE :: + * Value~0 is reserved. + * + * FT_PIXEL_MODE_MONO :: + * A monochrome bitmap, using 1~bit per pixel. Note that pixels are + * stored in most-significant order (MSB), which means that the + * left-most pixel in a byte has value 128. + * + * FT_PIXEL_MODE_GRAY :: + * An 8-bit bitmap, generally used to represent anti-aliased glyph + * images. Each pixel is stored in one byte. Note that the number of + * 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap + * structure (it generally is 256). + * + * FT_PIXEL_MODE_GRAY2 :: + * A 2-bit per pixel bitmap, used to represent embedded anti-aliased + * bitmaps in font files according to the OpenType specification. We + * haven't found a single font using this format, however. + * + * FT_PIXEL_MODE_GRAY4 :: + * A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps + * in font files according to the OpenType specification. We haven't + * found a single font using this format, however. + * + * FT_PIXEL_MODE_LCD :: + * An 8-bit bitmap, representing RGB or BGR decimated glyph images used + * for display on LCD displays; the bitmap is three times wider than + * the original glyph image. See also @FT_RENDER_MODE_LCD. + * + * FT_PIXEL_MODE_LCD_V :: + * An 8-bit bitmap, representing RGB or BGR decimated glyph images used + * for display on rotated LCD displays; the bitmap is three times + * taller than the original glyph image. See also + * @FT_RENDER_MODE_LCD_V. + * + * FT_PIXEL_MODE_BGRA :: + * [Since 2.5] An image with four 8-bit channels per pixel, + * representing a color image (such as emoticons) with alpha channel. + * For each pixel, the format is BGRA, which means, the blue channel + * comes first in memory. The color channels are pre-multiplied and in + * the sRGB colorspace. For example, full red at half-translucent + * opacity will be represented as '00,00,80,80', not '00,00,FF,80'. + * See also @FT_LOAD_COLOR. + */ typedef enum FT_Pixel_Mode_ { FT_PIXEL_MODE_NONE = 0, @@ -193,7 +194,7 @@ FT_BEGIN_HEADER } FT_Pixel_Mode; - /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */ + /* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */ /* values instead. */ #define ft_pixel_mode_none FT_PIXEL_MODE_NONE #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO @@ -202,62 +203,61 @@ FT_BEGIN_HEADER #define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap */ - /* */ - /* <Description> */ - /* A structure used to describe a bitmap or pixmap to the raster. */ - /* Note that we now manage pixmaps of various depths through the */ - /* `pixel_mode' field. */ - /* */ - /* <Fields> */ - /* rows :: The number of bitmap rows. */ - /* */ - /* width :: The number of pixels in bitmap row. */ - /* */ - /* pitch :: The pitch's absolute value is the number of bytes */ - /* taken by one bitmap row, including padding. */ - /* However, the pitch is positive when the bitmap has */ - /* a `down' flow, and negative when it has an `up' */ - /* flow. In all cases, the pitch is an offset to add */ - /* to a bitmap pointer in order to go down one row. */ - /* */ - /* Note that `padding' means the alignment of a */ - /* bitmap to a byte border, and FreeType functions */ - /* normally align to the smallest possible integer */ - /* value. */ - /* */ - /* For the B/W rasterizer, `pitch' is always an even */ - /* number. */ - /* */ - /* To change the pitch of a bitmap (say, to make it a */ - /* multiple of 4), use @FT_Bitmap_Convert. */ - /* Alternatively, you might use callback functions to */ - /* directly render to the application's surface; see */ - /* the file `example2.cpp' in the tutorial for a */ - /* demonstration. */ - /* */ - /* buffer :: A typeless pointer to the bitmap buffer. This */ - /* value should be aligned on 32-bit boundaries in */ - /* most cases. */ - /* */ - /* num_grays :: This field is only used with */ - /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ - /* levels used in the bitmap. */ - /* */ - /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ - /* See @FT_Pixel_Mode for possible values. */ - /* */ - /* palette_mode :: This field is intended for paletted pixel modes; */ - /* it indicates how the palette is stored. Not */ - /* used currently. */ - /* */ - /* palette :: A typeless pointer to the bitmap palette; this */ - /* field is intended for paletted pixel modes. Not */ - /* used currently. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Bitmap + * + * @description: + * A structure used to describe a bitmap or pixmap to the raster. Note + * that we now manage pixmaps of various depths through the `pixel_mode` + * field. + * + * @fields: + * rows :: + * The number of bitmap rows. + * + * width :: + * The number of pixels in bitmap row. + * + * pitch :: + * The pitch's absolute value is the number of bytes taken by one + * bitmap row, including padding. However, the pitch is positive when + * the bitmap has a 'down' flow, and negative when it has an 'up' flow. + * In all cases, the pitch is an offset to add to a bitmap pointer in + * order to go down one row. + * + * Note that 'padding' means the alignment of a bitmap to a byte + * border, and FreeType functions normally align to the smallest + * possible integer value. + * + * For the B/W rasterizer, `pitch` is always an even number. + * + * To change the pitch of a bitmap (say, to make it a multiple of 4), + * use @FT_Bitmap_Convert. Alternatively, you might use callback + * functions to directly render to the application's surface; see the + * file `example2.cpp` in the tutorial for a demonstration. + * + * buffer :: + * A typeless pointer to the bitmap buffer. This value should be + * aligned on 32-bit boundaries in most cases. + * + * num_grays :: + * This field is only used with @FT_PIXEL_MODE_GRAY; it gives the + * number of gray levels used in the bitmap. + * + * pixel_mode :: + * The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode + * for possible values. + * + * palette_mode :: + * This field is intended for paletted pixel modes; it indicates how + * the palette is stored. Not used currently. + * + * palette :: + * A typeless pointer to the bitmap palette; this field is intended for + * paletted pixel modes. Not used currently. + */ typedef struct FT_Bitmap_ { unsigned int rows; @@ -272,65 +272,68 @@ FT_BEGIN_HEADER } FT_Bitmap; - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline */ - /* */ - /* <Description> */ - /* This structure is used to describe an outline to the scan-line */ - /* converter. */ - /* */ - /* <Fields> */ - /* n_contours :: The number of contours in the outline. */ - /* */ - /* n_points :: The number of points in the outline. */ - /* */ - /* points :: A pointer to an array of `n_points' @FT_Vector */ - /* elements, giving the outline's point coordinates. */ - /* */ - /* tags :: A pointer to an array of `n_points' chars, giving */ - /* each outline point's type. */ - /* */ - /* If bit~0 is unset, the point is `off' the curve, */ - /* i.e., a Bezier control point, while it is `on' if */ - /* set. */ - /* */ - /* Bit~1 is meaningful for `off' points only. If set, */ - /* it indicates a third-order Bezier arc control point; */ - /* and a second-order control point if unset. */ - /* */ - /* If bit~2 is set, bits 5-7 contain the drop-out mode */ - /* (as defined in the OpenType specification; the value */ - /* is the same as the argument to the SCANMODE */ - /* instruction). */ - /* */ - /* Bits 3 and~4 are reserved for internal purposes. */ - /* */ - /* contours :: An array of `n_contours' shorts, giving the end */ - /* point of each contour within the outline. For */ - /* example, the first contour is defined by the points */ - /* `0' to `contours[0]', the second one is defined by */ - /* the points `contours[0]+1' to `contours[1]', etc. */ - /* */ - /* flags :: A set of bit flags used to characterize the outline */ - /* and give hints to the scan-converter and hinter on */ - /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */ - /* */ - /* <Note> */ - /* The B/W rasterizer only checks bit~2 in the `tags' array for the */ - /* first point of each contour. The drop-out mode as given with */ - /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */ - /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */ - /* */ + /************************************************************************** + * + * @section: + * outline_processing + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Outline + * + * @description: + * This structure is used to describe an outline to the scan-line + * converter. + * + * @fields: + * n_contours :: + * The number of contours in the outline. + * + * n_points :: + * The number of points in the outline. + * + * points :: + * A pointer to an array of `n_points` @FT_Vector elements, giving the + * outline's point coordinates. + * + * tags :: + * A pointer to an array of `n_points` chars, giving each outline + * point's type. + * + * If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier + * control point, while it is 'on' if set. + * + * Bit~1 is meaningful for 'off' points only. If set, it indicates a + * third-order Bezier arc control point; and a second-order control + * point if unset. + * + * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in + * the OpenType specification; the value is the same as the argument to + * the 'SCANMODE' instruction). + * + * Bits 3 and~4 are reserved for internal purposes. + * + * contours :: + * An array of `n_contours` shorts, giving the end point of each + * contour within the outline. For example, the first contour is + * defined by the points '0' to `contours[0]`, the second one is + * defined by the points `contours[0]+1` to `contours[1]`, etc. + * + * flags :: + * A set of bit flags used to characterize the outline and give hints + * to the scan-converter and hinter on how to convert/grid-fit it. See + * @FT_OUTLINE_XXX. + * + * @note: + * The B/W rasterizer only checks bit~2 in the `tags` array for the first + * point of each contour. The drop-out mode as given with + * @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and + * @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden. + */ typedef struct FT_Outline_ { short n_contours; /* number of contours in glyph */ @@ -352,78 +355,76 @@ FT_BEGIN_HEADER #define FT_OUTLINE_POINTS_MAX SHRT_MAX - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OUTLINE_XXX */ - /* */ - /* <Description> */ - /* A list of bit-field constants use for the flags in an outline's */ - /* `flags' field. */ - /* */ - /* <Values> */ - /* FT_OUTLINE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_OUTLINE_OWNER :: */ - /* If set, this flag indicates that the outline's field arrays */ - /* (i.e., `points', `flags', and `contours') are `owned' by the */ - /* outline object, and should thus be freed when it is destroyed. */ - /* */ - /* FT_OUTLINE_EVEN_ODD_FILL :: */ - /* By default, outlines are filled using the non-zero winding rule. */ - /* If set to 1, the outline will be filled using the even-odd fill */ - /* rule (only works with the smooth rasterizer). */ - /* */ - /* FT_OUTLINE_REVERSE_FILL :: */ - /* By default, outside contours of an outline are oriented in */ - /* clock-wise direction, as defined in the TrueType specification. */ - /* This flag is set if the outline uses the opposite direction */ - /* (typically for Type~1 fonts). This flag is ignored by the scan */ - /* converter. */ - /* */ - /* FT_OUTLINE_IGNORE_DROPOUTS :: */ - /* By default, the scan converter will try to detect drop-outs in */ - /* an outline and correct the glyph bitmap to ensure consistent */ - /* shape continuity. If set, this flag hints the scan-line */ - /* converter to ignore such cases. See below for more information. */ - /* */ - /* FT_OUTLINE_SMART_DROPOUTS :: */ - /* Select smart dropout control. If unset, use simple dropout */ - /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */ - /* below for more information. */ - /* */ - /* FT_OUTLINE_INCLUDE_STUBS :: */ - /* If set, turn pixels on for `stubs', otherwise exclude them. */ - /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */ - /* more information. */ - /* */ - /* FT_OUTLINE_HIGH_PRECISION :: */ - /* This flag indicates that the scan-line converter should try to */ - /* convert this outline to bitmaps with the highest possible */ - /* quality. It is typically set for small character sizes. Note */ - /* that this is only a hint that might be completely ignored by a */ - /* given scan-converter. */ - /* */ - /* FT_OUTLINE_SINGLE_PASS :: */ - /* This flag is set to force a given scan-converter to only use a */ - /* single pass over the outline to render a bitmap glyph image. */ - /* Normally, it is set for very large character sizes. It is only */ - /* a hint that might be completely ignored by a given */ - /* scan-converter. */ - /* */ - /* <Note> */ - /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */ - /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */ - /* rasterizer. */ - /* */ - /* There exists a second mechanism to pass the drop-out mode to the */ - /* B/W rasterizer; see the `tags' field in @FT_Outline. */ - /* */ - /* Please refer to the description of the `SCANTYPE' instruction in */ - /* the OpenType specification (in file `ttinst1.doc') how simple */ - /* drop-outs, smart drop-outs, and stubs are defined. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_OUTLINE_XXX + * + * @description: + * A list of bit-field constants used for the flags in an outline's + * `flags` field. + * + * @values: + * FT_OUTLINE_NONE :: + * Value~0 is reserved. + * + * FT_OUTLINE_OWNER :: + * If set, this flag indicates that the outline's field arrays (i.e., + * `points`, `flags`, and `contours`) are 'owned' by the outline + * object, and should thus be freed when it is destroyed. + * + * FT_OUTLINE_EVEN_ODD_FILL :: + * By default, outlines are filled using the non-zero winding rule. If + * set to 1, the outline will be filled using the even-odd fill rule + * (only works with the smooth rasterizer). + * + * FT_OUTLINE_REVERSE_FILL :: + * By default, outside contours of an outline are oriented in + * clock-wise direction, as defined in the TrueType specification. + * This flag is set if the outline uses the opposite direction + * (typically for Type~1 fonts). This flag is ignored by the scan + * converter. + * + * FT_OUTLINE_IGNORE_DROPOUTS :: + * By default, the scan converter will try to detect drop-outs in an + * outline and correct the glyph bitmap to ensure consistent shape + * continuity. If set, this flag hints the scan-line converter to + * ignore such cases. See below for more information. + * + * FT_OUTLINE_SMART_DROPOUTS :: + * Select smart dropout control. If unset, use simple dropout control. + * Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more + * information. + * + * FT_OUTLINE_INCLUDE_STUBS :: + * If set, turn pixels on for 'stubs', otherwise exclude them. Ignored + * if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more + * information. + * + * FT_OUTLINE_HIGH_PRECISION :: + * This flag indicates that the scan-line converter should try to + * convert this outline to bitmaps with the highest possible quality. + * It is typically set for small character sizes. Note that this is + * only a hint that might be completely ignored by a given + * scan-converter. + * + * FT_OUTLINE_SINGLE_PASS :: + * This flag is set to force a given scan-converter to only use a + * single pass over the outline to render a bitmap glyph image. + * Normally, it is set for very large character sizes. It is only a + * hint that might be completely ignored by a given scan-converter. + * + * @note: + * The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and + * @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer. + * + * There exists a second mechanism to pass the drop-out mode to the B/W + * rasterizer; see the `tags` field in @FT_Outline. + * + * Please refer to the description of the 'SCANTYPE' instruction in the + * OpenType specification (in file `ttinst1.doc`) how simple drop-outs, + * smart drop-outs, and stubs are defined. + */ #define FT_OUTLINE_NONE 0x0 #define FT_OUTLINE_OWNER 0x1 #define FT_OUTLINE_EVEN_ODD_FILL 0x2 @@ -437,7 +438,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_OUTLINE_XXX' values instead */ + /* `FT_OUTLINE_XXX` values instead */ #define ft_outline_none FT_OUTLINE_NONE #define ft_outline_owner FT_OUTLINE_OWNER #define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL @@ -448,20 +449,25 @@ FT_BEGIN_HEADER /* */ -#define FT_CURVE_TAG( flag ) ( flag & 3 ) +#define FT_CURVE_TAG( flag ) ( flag & 0x03 ) -#define FT_CURVE_TAG_ON 1 -#define FT_CURVE_TAG_CONIC 0 -#define FT_CURVE_TAG_CUBIC 2 + /* see the `tags` field in `FT_Outline` for a description of the values */ +#define FT_CURVE_TAG_ON 0x01 +#define FT_CURVE_TAG_CONIC 0x00 +#define FT_CURVE_TAG_CUBIC 0x02 -#define FT_CURVE_TAG_HAS_SCANMODE 4 +#define FT_CURVE_TAG_HAS_SCANMODE 0x04 -#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ -#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_X 0x08 /* reserved for TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_Y 0x10 /* reserved for TrueType hinter */ #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ FT_CURVE_TAG_TOUCH_Y ) + /* values 0x20, 0x40, and 0x80 are reserved */ + + /* these constants are deprecated; use the corresponding */ + /* `FT_CURVE_TAG_XXX` values instead */ #define FT_Curve_Tag_On FT_CURVE_TAG_ON #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC #define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC @@ -469,26 +475,28 @@ FT_BEGIN_HEADER #define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_MoveToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `move */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `move to' is emitted to start a new contour in an outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `move to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_MoveToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'move to' + * function during outline walking/decomposition. + * + * A 'move to' is emitted to start a new contour in an outline. + * + * @input: + * to :: + * A pointer to the target point of the 'move to'. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_MoveToFunc)( const FT_Vector* to, void* user ); @@ -496,26 +504,28 @@ FT_BEGIN_HEADER #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_LineToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `line */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `line to' is emitted to indicate a segment in the outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `line to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_LineToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'line to' + * function during outline walking/decomposition. + * + * A 'line to' is emitted to indicate a segment in the outline. + * + * @input: + * to :: + * A pointer to the target point of the 'line to'. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_LineToFunc)( const FT_Vector* to, void* user ); @@ -523,30 +533,33 @@ FT_BEGIN_HEADER #define FT_Outline_LineTo_Func FT_Outline_LineToFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_ConicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `conic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `conic to' is emitted to indicate a second-order Bezier arc in */ - /* the outline. */ - /* */ - /* <Input> */ - /* control :: An intermediate control point between the last position */ - /* and the new target in `to'. */ - /* */ - /* to :: A pointer to the target end point of the conic arc. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_ConicToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'conic to' + * function during outline walking or decomposition. + * + * A 'conic to' is emitted to indicate a second-order Bezier arc in the + * outline. + * + * @input: + * control :: + * An intermediate control point between the last position and the new + * target in `to`. + * + * to :: + * A pointer to the target end point of the conic arc. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_ConicToFunc)( const FT_Vector* control, const FT_Vector* to, @@ -555,30 +568,34 @@ FT_BEGIN_HEADER #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_CubicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `cubic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ - /* */ - /* <Input> */ - /* control1 :: A pointer to the first Bezier control point. */ - /* */ - /* control2 :: A pointer to the second Bezier control point. */ - /* */ - /* to :: A pointer to the target end point. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_CubicToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'cubic to' + * function during outline walking or decomposition. + * + * A 'cubic to' is emitted to indicate a third-order Bezier arc. + * + * @input: + * control1 :: + * A pointer to the first Bezier control point. + * + * control2 :: + * A pointer to the second Bezier control point. + * + * to :: + * A pointer to the target end point. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_CubicToFunc)( const FT_Vector* control1, const FT_Vector* control2, @@ -588,43 +605,49 @@ FT_BEGIN_HEADER #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline_Funcs */ - /* */ - /* <Description> */ - /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Beziers. */ - /* */ - /* <Fields> */ - /* move_to :: The `move to' emitter. */ - /* */ - /* line_to :: The segment emitter. */ - /* */ - /* conic_to :: The second-order Bezier arc emitter. */ - /* */ - /* cubic_to :: The third-order Bezier arc emitter. */ - /* */ - /* shift :: The shift that is applied to coordinates before they */ - /* are sent to the emitter. */ - /* */ - /* delta :: The delta that is applied to coordinates before they */ - /* are sent to the emitter, but after the shift. */ - /* */ - /* <Note> */ - /* The point coordinates sent to the emitters are the transformed */ - /* version of the original coordinates (this is important for high */ - /* accuracy during scan-conversion). The transformation is simple: */ - /* */ - /* { */ - /* x' = (x << shift) - delta */ - /* y' = (y << shift) - delta */ - /* } */ - /* */ - /* Set the values of `shift' and `delta' to~0 to get the original */ - /* point coordinates. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Outline_Funcs + * + * @description: + * A structure to hold various function pointers used during outline + * decomposition in order to emit segments, conic, and cubic Beziers. + * + * @fields: + * move_to :: + * The 'move to' emitter. + * + * line_to :: + * The segment emitter. + * + * conic_to :: + * The second-order Bezier arc emitter. + * + * cubic_to :: + * The third-order Bezier arc emitter. + * + * shift :: + * The shift that is applied to coordinates before they are sent to the + * emitter. + * + * delta :: + * The delta that is applied to coordinates before they are sent to the + * emitter, but after the shift. + * + * @note: + * The point coordinates sent to the emitters are the transformed version + * of the original coordinates (this is important for high accuracy + * during scan-conversion). The transformation is simple: + * + * ``` + * x' = (x << shift) - delta + * y' = (y << shift) - delta + * ``` + * + * Set the values of `shift` and `delta` to~0 to get the original point + * coordinates. + */ typedef struct FT_Outline_Funcs_ { FT_Outline_MoveToFunc move_to; @@ -638,33 +661,32 @@ FT_BEGIN_HEADER } FT_Outline_Funcs; - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_IMAGE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags to an unsigned long type. */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @macro: + * FT_IMAGE_TAG + * + * @description: + * This macro converts four-letter tags to an unsigned long type. + * + * @note: + * Since many 16-bit compilers don't like 32-bit enumerations, you should + * redefine this macro in case of problems to something like this: + * + * ``` + * #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value + * ``` + * + * to get a simple enumeration without assigning special numbers. + */ #ifndef FT_IMAGE_TAG #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ value = ( ( (unsigned long)_x1 << 24 ) | \ @@ -674,44 +696,43 @@ FT_BEGIN_HEADER #endif /* FT_IMAGE_TAG */ - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_Format */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of a given glyph */ - /* image. Note that this version of FreeType only supports two image */ - /* formats, even though future font drivers will be able to register */ - /* their own format. */ - /* */ - /* <Values> */ - /* FT_GLYPH_FORMAT_NONE :: */ - /* The value~0 is reserved. */ - /* */ - /* FT_GLYPH_FORMAT_COMPOSITE :: */ - /* The glyph image is a composite of several other images. This */ - /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */ - /* report compound glyphs (like accented characters). */ - /* */ - /* FT_GLYPH_FORMAT_BITMAP :: */ - /* The glyph image is a bitmap, and can be described as an */ - /* @FT_Bitmap. You generally need to access the `bitmap' field of */ - /* the @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_OUTLINE :: */ - /* The glyph image is a vectorial outline made of line segments */ - /* and Bezier arcs; it can be described as an @FT_Outline; you */ - /* generally want to access the `outline' field of the */ - /* @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_PLOTTER :: */ - /* The glyph image is a vectorial path with no inside and outside */ - /* contours. Some Type~1 fonts, like those in the Hershey family, */ - /* contain glyphs in this format. These are described as */ - /* @FT_Outline, but FreeType isn't currently capable of rendering */ - /* them correctly. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Glyph_Format + * + * @description: + * An enumeration type used to describe the format of a given glyph + * image. Note that this version of FreeType only supports two image + * formats, even though future font drivers will be able to register + * their own format. + * + * @values: + * FT_GLYPH_FORMAT_NONE :: + * The value~0 is reserved. + * + * FT_GLYPH_FORMAT_COMPOSITE :: + * The glyph image is a composite of several other images. This format + * is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report + * compound glyphs (like accented characters). + * + * FT_GLYPH_FORMAT_BITMAP :: + * The glyph image is a bitmap, and can be described as an @FT_Bitmap. + * You generally need to access the `bitmap` field of the + * @FT_GlyphSlotRec structure to read it. + * + * FT_GLYPH_FORMAT_OUTLINE :: + * The glyph image is a vectorial outline made of line segments and + * Bezier arcs; it can be described as an @FT_Outline; you generally + * want to access the `outline` field of the @FT_GlyphSlotRec structure + * to read it. + * + * FT_GLYPH_FORMAT_PLOTTER :: + * The glyph image is a vectorial path with no inside and outside + * contours. Some Type~1 fonts, like those in the Hershey family, + * contain glyphs in this format. These are described as @FT_Outline, + * but FreeType isn't currently capable of rendering them correctly. + */ typedef enum FT_Glyph_Format_ { FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), @@ -725,7 +746,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Glyph_Format' values instead. */ + /* `FT_Glyph_Format` values instead. */ #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP @@ -744,87 +765,89 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* A raster is a scan converter, in charge of rendering an outline into */ - /* a bitmap. This section contains the public API for rasters. */ - /* */ - /* Note that in FreeType 2, all rasters are now encapsulated within */ - /* specific modules called `renderers'. See `ftrender.h' for more */ - /* details on renderers. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* raster */ - /* */ - /* <Title> */ - /* Scanline Converter */ - /* */ - /* <Abstract> */ - /* How vectorial outlines are converted into bitmaps and pixmaps. */ - /* */ - /* <Description> */ - /* This section contains technical definitions. */ - /* */ - /* <Order> */ - /* FT_Raster */ - /* FT_Span */ - /* FT_SpanFunc */ - /* */ - /* FT_Raster_Params */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* FT_Raster_NewFunc */ - /* FT_Raster_DoneFunc */ - /* FT_Raster_ResetFunc */ - /* FT_Raster_SetModeFunc */ - /* FT_Raster_RenderFunc */ - /* FT_Raster_Funcs */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Raster */ - /* */ - /* <Description> */ - /* An opaque handle (pointer) to a raster object. Each object can be */ - /* used independently to convert an outline into a bitmap or pixmap. */ - /* */ + /************************************************************************** + * + * A raster is a scan converter, in charge of rendering an outline into a + * bitmap. This section contains the public API for rasters. + * + * Note that in FreeType 2, all rasters are now encapsulated within + * specific modules called 'renderers'. See `ftrender.h` for more details + * on renderers. + * + */ + + + /************************************************************************** + * + * @section: + * raster + * + * @title: + * Scanline Converter + * + * @abstract: + * How vectorial outlines are converted into bitmaps and pixmaps. + * + * @description: + * This section contains technical definitions. + * + * @order: + * FT_Raster + * FT_Span + * FT_SpanFunc + * + * FT_Raster_Params + * FT_RASTER_FLAG_XXX + * + * FT_Raster_NewFunc + * FT_Raster_DoneFunc + * FT_Raster_ResetFunc + * FT_Raster_SetModeFunc + * FT_Raster_RenderFunc + * FT_Raster_Funcs + * + */ + + + /************************************************************************** + * + * @type: + * FT_Raster + * + * @description: + * An opaque handle (pointer) to a raster object. Each object can be + * used independently to convert an outline into a bitmap or pixmap. + */ typedef struct FT_RasterRec_* FT_Raster; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Span */ - /* */ - /* <Description> */ - /* A structure used to model a single span of gray pixels when */ - /* rendering an anti-aliased bitmap. */ - /* */ - /* <Fields> */ - /* x :: The span's horizontal start position. */ - /* */ - /* len :: The span's length in pixels. */ - /* */ - /* coverage :: The span color/coverage, ranging from 0 (background) */ - /* to 255 (foreground). */ - /* */ - /* <Note> */ - /* This structure is used by the span drawing callback type named */ - /* @FT_SpanFunc that takes the y~coordinate of the span as a */ - /* parameter. */ - /* */ - /* The coverage value is always between 0 and 255. If you want less */ - /* gray values, the callback function has to reduce them. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Span + * + * @description: + * A structure used to model a single span of gray pixels when rendering + * an anti-aliased bitmap. + * + * @fields: + * x :: + * The span's horizontal start position. + * + * len :: + * The span's length in pixels. + * + * coverage :: + * The span color/coverage, ranging from 0 (background) to 255 + * (foreground). + * + * @note: + * This structure is used by the span drawing callback type named + * @FT_SpanFunc that takes the y~coordinate of the span as a parameter. + * + * The coverage value is always between 0 and 255. If you want less gray + * values, the callback function has to reduce them. + */ typedef struct FT_Span_ { short x; @@ -834,32 +857,36 @@ FT_BEGIN_HEADER } FT_Span; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_SpanFunc */ - /* */ - /* <Description> */ - /* A function used as a call-back by the anti-aliased renderer in */ - /* order to let client applications draw themselves the gray pixel */ - /* spans on each scan line. */ - /* */ - /* <Input> */ - /* y :: The scanline's y~coordinate. */ - /* */ - /* count :: The number of spans to draw on this scanline. */ - /* */ - /* spans :: A table of `count' spans to draw on the scanline. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* <Note> */ - /* This callback allows client applications to directly render the */ - /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ - /* */ - /* This can be used to write anti-aliased outlines directly to a */ - /* given background bitmap, and even perform translucency. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_SpanFunc + * + * @description: + * A function used as a call-back by the anti-aliased renderer in order + * to let client applications draw themselves the gray pixel spans on + * each scan line. + * + * @input: + * y :: + * The scanline's y~coordinate. + * + * count :: + * The number of spans to draw on this scanline. + * + * spans :: + * A table of `count` spans to draw on the scanline. + * + * user :: + * User-supplied data that is passed to the callback. + * + * @note: + * This callback allows client applications to directly render the gray + * spans of the anti-aliased bitmap to any kind of surfaces. + * + * This can be used to write anti-aliased outlines directly to a given + * background bitmap, and even perform translucency. + */ typedef void (*FT_SpanFunc)( int y, int count, @@ -869,131 +896,131 @@ FT_BEGIN_HEADER #define FT_Raster_Span_Func FT_SpanFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitTest_Func */ - /* */ - /* <Description> */ - /* Deprecated, unimplemented. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_BitTest_Func + * + * @description: + * Deprecated, unimplemented. + */ typedef int (*FT_Raster_BitTest_Func)( int y, int x, void* user ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitSet_Func */ - /* */ - /* <Description> */ - /* Deprecated, unimplemented. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_BitSet_Func + * + * @description: + * Deprecated, unimplemented. + */ typedef void (*FT_Raster_BitSet_Func)( int y, int x, void* user ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flag constants as used in the `flags' field of a */ - /* @FT_Raster_Params structure. */ - /* */ - /* <Values> */ - /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ - /* */ - /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ - /* anti-aliased glyph image should be */ - /* generated. Otherwise, it will be */ - /* monochrome (1-bit). */ - /* */ - /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ - /* rendering. In this mode, client */ - /* applications must provide their own span */ - /* callback. This lets them directly */ - /* draw or compose over an existing bitmap. */ - /* If this bit is not set, the target */ - /* pixmap's buffer _must_ be zeroed before */ - /* rendering. */ - /* */ - /* Direct rendering is only possible with */ - /* anti-aliased glyphs. */ - /* */ - /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ - /* rendering mode. If set, the output will */ - /* be clipped to a box specified in the */ - /* `clip_box' field of the */ - /* @FT_Raster_Params structure. */ - /* */ - /* Note that by default, the glyph bitmap */ - /* is clipped to the target pixmap, except */ - /* in direct rendering mode where all spans */ - /* are generated if no clipping box is set. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_RASTER_FLAG_XXX + * + * @description: + * A list of bit flag constants as used in the `flags` field of a + * @FT_Raster_Params structure. + * + * @values: + * FT_RASTER_FLAG_DEFAULT :: + * This value is 0. + * + * FT_RASTER_FLAG_AA :: + * This flag is set to indicate that an anti-aliased glyph image should + * be generated. Otherwise, it will be monochrome (1-bit). + * + * FT_RASTER_FLAG_DIRECT :: + * This flag is set to indicate direct rendering. In this mode, client + * applications must provide their own span callback. This lets them + * directly draw or compose over an existing bitmap. If this bit is + * not set, the target pixmap's buffer _must_ be zeroed before + * rendering. + * + * Direct rendering is only possible with anti-aliased glyphs. + * + * FT_RASTER_FLAG_CLIP :: + * This flag is only used in direct rendering mode. If set, the output + * will be clipped to a box specified in the `clip_box` field of the + * @FT_Raster_Params structure. + * + * Note that by default, the glyph bitmap is clipped to the target + * pixmap, except in direct rendering mode where all spans are + * generated if no clipping box is set. + */ #define FT_RASTER_FLAG_DEFAULT 0x0 #define FT_RASTER_FLAG_AA 0x1 #define FT_RASTER_FLAG_DIRECT 0x2 #define FT_RASTER_FLAG_CLIP 0x4 /* these constants are deprecated; use the corresponding */ - /* `FT_RASTER_FLAG_XXX' values instead */ + /* `FT_RASTER_FLAG_XXX` values instead */ #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT #define ft_raster_flag_aa FT_RASTER_FLAG_AA #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Params */ - /* */ - /* <Description> */ - /* A structure to hold the arguments used by a raster's render */ - /* function. */ - /* */ - /* <Fields> */ - /* target :: The target bitmap. */ - /* */ - /* source :: A pointer to the source glyph image (e.g., an */ - /* @FT_Outline). */ - /* */ - /* flags :: The rendering flags. */ - /* */ - /* gray_spans :: The gray span drawing callback. */ - /* */ - /* black_spans :: Unused. */ - /* */ - /* bit_test :: Unused. */ - /* */ - /* bit_set :: Unused. */ - /* */ - /* user :: User-supplied data that is passed to each drawing */ - /* callback. */ - /* */ - /* clip_box :: An optional clipping box. It is only used in */ - /* direct rendering mode. Note that coordinates here */ - /* should be expressed in _integer_ pixels (and not in */ - /* 26.6 fixed-point units). */ - /* */ - /* <Note> */ - /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ - /* bit flag is set in the `flags' field, otherwise a monochrome */ - /* bitmap is generated. */ - /* */ - /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ - /* raster will call the `gray_spans' callback to draw gray pixel */ - /* spans. This allows direct composition over a pre-existing bitmap */ - /* through user-provided callbacks to perform the span drawing and */ - /* composition. Not supported by the monochrome rasterizer. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Raster_Params + * + * @description: + * A structure to hold the arguments used by a raster's render function. + * + * @fields: + * target :: + * The target bitmap. + * + * source :: + * A pointer to the source glyph image (e.g., an @FT_Outline). + * + * flags :: + * The rendering flags. + * + * gray_spans :: + * The gray span drawing callback. + * + * black_spans :: + * Unused. + * + * bit_test :: + * Unused. + * + * bit_set :: + * Unused. + * + * user :: + * User-supplied data that is passed to each drawing callback. + * + * clip_box :: + * An optional clipping box. It is only used in direct rendering mode. + * Note that coordinates here should be expressed in _integer_ pixels + * (and not in 26.6 fixed-point units). + * + * @note: + * An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA bit + * flag is set in the `flags` field, otherwise a monochrome bitmap is + * generated. + * + * If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags`, the raster + * will call the `gray_spans` callback to draw gray pixel spans. This + * allows direct composition over a pre-existing bitmap through + * user-provided callbacks to perform the span drawing and composition. + * Not supported by the monochrome rasterizer. + */ typedef struct FT_Raster_Params_ { const FT_Bitmap* target; @@ -1009,30 +1036,32 @@ FT_BEGIN_HEADER } FT_Raster_Params; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_NewFunc */ - /* */ - /* <Description> */ - /* A function used to create a new raster object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory allocator. */ - /* */ - /* <Output> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `memory' parameter is a typeless pointer in order to avoid */ - /* un-wanted dependencies on the rest of the FreeType code. In */ - /* practice, it is an @FT_Memory object, i.e., a handle to the */ - /* standard FreeType memory allocator. However, this field can be */ - /* completely ignored by a given raster implementation. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_NewFunc + * + * @description: + * A function used to create a new raster object. + * + * @input: + * memory :: + * A handle to the memory allocator. + * + * @output: + * raster :: + * A handle to the new raster object. + * + * @return: + * Error code. 0~means success. + * + * @note: + * The `memory` parameter is a typeless pointer in order to avoid + * un-wanted dependencies on the rest of the FreeType code. In practice, + * it is an @FT_Memory object, i.e., a handle to the standard FreeType + * memory allocator. However, this field can be completely ignored by a + * given raster implementation. + */ typedef int (*FT_Raster_NewFunc)( void* memory, FT_Raster* raster ); @@ -1040,49 +1069,52 @@ FT_BEGIN_HEADER #define FT_Raster_New_Func FT_Raster_NewFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_DoneFunc */ - /* */ - /* <Description> */ - /* A function used to destroy a given raster object. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_DoneFunc + * + * @description: + * A function used to destroy a given raster object. + * + * @input: + * raster :: + * A handle to the raster object. + */ typedef void (*FT_Raster_DoneFunc)( FT_Raster raster ); #define FT_Raster_Done_Func FT_Raster_DoneFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_ResetFunc */ - /* */ - /* <Description> */ - /* FreeType used to provide an area of memory called the `render */ - /* pool' available to all registered rasterizers. This was not */ - /* thread safe, however, and now FreeType never allocates this pool. */ - /* */ - /* This function is called after a new raster object is created. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* pool_base :: Previously, the address in memory of the render pool. */ - /* Set this to NULL. */ - /* */ - /* pool_size :: Previously, the size in bytes of the render pool. */ - /* Set this to 0. */ - /* */ - /* <Note> */ - /* Rasterizers should rely on dynamic or stack allocation if they */ - /* want to (a handle to the memory allocator is passed to the */ - /* rasterizer constructor). */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_ResetFunc + * + * @description: + * FreeType used to provide an area of memory called the 'render pool' + * available to all registered rasterizers. This was not thread safe, + * however, and now FreeType never allocates this pool. + * + * This function is called after a new raster object is created. + * + * @input: + * raster :: + * A handle to the new raster object. + * + * pool_base :: + * Previously, the address in memory of the render pool. Set this to + * `NULL`. + * + * pool_size :: + * Previously, the size in bytes of the render pool. Set this to 0. + * + * @note: + * Rasterizers should rely on dynamic or stack allocation if they want to + * (a handle to the memory allocator is passed to the rasterizer + * constructor). + */ typedef void (*FT_Raster_ResetFunc)( FT_Raster raster, unsigned char* pool_base, @@ -1091,24 +1123,26 @@ FT_BEGIN_HEADER #define FT_Raster_Reset_Func FT_Raster_ResetFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_SetModeFunc */ - /* */ - /* <Description> */ - /* This function is a generic facility to change modes or attributes */ - /* in a given raster. This can be used for debugging purposes, or */ - /* simply to allow implementation-specific `features' in a given */ - /* raster module. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* mode :: A 4-byte tag used to name the mode or property. */ - /* */ - /* args :: A pointer to the new mode/property to use. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_SetModeFunc + * + * @description: + * This function is a generic facility to change modes or attributes in a + * given raster. This can be used for debugging purposes, or simply to + * allow implementation-specific 'features' in a given raster module. + * + * @input: + * raster :: + * A handle to the new raster object. + * + * mode :: + * A 4-byte tag used to name the mode or property. + * + * args :: + * A pointer to the new mode/property to use. + */ typedef int (*FT_Raster_SetModeFunc)( FT_Raster raster, unsigned long mode, @@ -1117,40 +1151,36 @@ FT_BEGIN_HEADER #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_RenderFunc */ - /* */ - /* <Description> */ - /* Invoke a given raster to scan-convert a given glyph image into a */ - /* target bitmap. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* store the rendering parameters. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The exact format of the source image depends on the raster's glyph */ - /* format defined in its @FT_Raster_Funcs structure. It can be an */ - /* @FT_Outline or anything else in order to support a large array of */ - /* glyph formats. */ - /* */ - /* Note also that the render function can fail and return a */ - /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ - /* not support direct composition. */ - /* */ - /* XXX: For now, the standard raster doesn't support direct */ - /* composition but this should change for the final release (see */ - /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ - /* for examples of distinct implementations that support direct */ - /* composition). */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_RenderFunc + * + * @description: + * Invoke a given raster to scan-convert a given glyph image into a + * target bitmap. + * + * @input: + * raster :: + * A handle to the raster object. + * + * params :: + * A pointer to an @FT_Raster_Params structure used to store the + * rendering parameters. + * + * @return: + * Error code. 0~means success. + * + * @note: + * The exact format of the source image depends on the raster's glyph + * format defined in its @FT_Raster_Funcs structure. It can be an + * @FT_Outline or anything else in order to support a large array of + * glyph formats. + * + * Note also that the render function can fail and return a + * `FT_Err_Unimplemented_Feature` error code if the raster used does not + * support direct composition. + */ typedef int (*FT_Raster_RenderFunc)( FT_Raster raster, const FT_Raster_Params* params ); @@ -1158,25 +1188,30 @@ FT_BEGIN_HEADER #define FT_Raster_Render_Func FT_Raster_RenderFunc - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Funcs */ - /* */ - /* <Description> */ - /* A structure used to describe a given raster class to the library. */ - /* */ - /* <Fields> */ - /* glyph_format :: The supported glyph format for this raster. */ - /* */ - /* raster_new :: The raster constructor. */ - /* */ - /* raster_reset :: Used to reset the render pool within the raster. */ - /* */ - /* raster_render :: A function to render a glyph into a given bitmap. */ - /* */ - /* raster_done :: The raster destructor. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Raster_Funcs + * + * @description: + * A structure used to describe a given raster class to the library. + * + * @fields: + * glyph_format :: + * The supported glyph format for this raster. + * + * raster_new :: + * The raster constructor. + * + * raster_reset :: + * Used to reset the render pool within the raster. + * + * raster_render :: + * A function to render a glyph into a given bitmap. + * + * raster_done :: + * The raster destructor. + */ typedef struct FT_Raster_Funcs_ { FT_Glyph_Format glyph_format; diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h index 44619f941e7..a4db02b585b 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftincrem.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftincrem.h */ -/* */ -/* FreeType incremental loading (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftincrem.h + * + * FreeType incremental loading (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTINCREM_H_ @@ -32,7 +32,7 @@ FT_BEGIN_HEADER - /*************************************************************************** + /************************************************************************** * * @section: * incremental @@ -45,7 +45,7 @@ FT_BEGIN_HEADER * * @description: * This section contains various functions used to perform so-called - * `incremental' glyph loading. This is a mode where all glyphs loaded + * 'incremental' glyph loading. This is a mode where all glyphs loaded * from a given @FT_Face are provided by the client application. * * Apart from that, all other tables are loaded normally from the font @@ -60,23 +60,24 @@ FT_BEGIN_HEADER */ - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental * * @description: * An opaque type describing a user-provided object used to implement - * `incremental' glyph loading within FreeType. This is used to support - * embedded fonts in certain environments (e.g., PostScript interpreters), - * where the glyph data isn't in the font file, or must be overridden by - * different values. + * 'incremental' glyph loading within FreeType. This is used to support + * embedded fonts in certain environments (e.g., PostScript + * interpreters), where the glyph data isn't in the font file, or must be + * overridden by different values. * * @note: - * It is up to client applications to create and implement @FT_Incremental - * objects, as long as they provide implementations for the methods - * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc - * and @FT_Incremental_GetGlyphMetricsFunc. + * It is up to client applications to create and implement + * @FT_Incremental objects, as long as they provide implementations for + * the methods @FT_Incremental_GetGlyphDataFunc, + * @FT_Incremental_FreeGlyphDataFunc and + * @FT_Incremental_GetGlyphMetricsFunc. * * See the description of @FT_Incremental_InterfaceRec to understand how * to use incremental objects with FreeType. @@ -85,14 +86,14 @@ FT_BEGIN_HEADER typedef struct FT_IncrementalRec_* FT_Incremental; - /*************************************************************************** + /************************************************************************** * * @struct: * FT_Incremental_MetricsRec * * @description: - * A small structure used to contain the basic glyph metrics returned - * by the @FT_Incremental_GetGlyphMetricsFunc method. + * A small structure used to contain the basic glyph metrics returned by + * the @FT_Incremental_GetGlyphMetricsFunc method. * * @fields: * bearing_x :: @@ -109,7 +110,7 @@ FT_BEGIN_HEADER * * @note: * These correspond to horizontal or vertical metrics depending on the - * value of the `vertical' argument to the function + * value of the `vertical` argument to the function * @FT_Incremental_GetGlyphMetricsFunc. * */ @@ -123,7 +124,7 @@ FT_BEGIN_HEADER } FT_Incremental_MetricsRec; - /*************************************************************************** + /************************************************************************** * * @struct: * FT_Incremental_Metrics @@ -135,7 +136,7 @@ FT_BEGIN_HEADER typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_GetGlyphDataFunc @@ -147,8 +148,8 @@ FT_BEGIN_HEADER * * Note that the format of the glyph's data bytes depends on the font * file format. For TrueType, it must correspond to the raw bytes within - * the `glyf' table. For PostScript formats, it must correspond to the - * *unencrypted* charstring bytes, without any `lenIV' header. It is + * the 'glyf' table. For PostScript formats, it must correspond to the + * **unencrypted** charstring bytes, without any `lenIV` header. It is * undefined for any other format. * * @input: @@ -169,8 +170,8 @@ FT_BEGIN_HEADER * * @note: * If this function returns successfully the method - * @FT_Incremental_FreeGlyphDataFunc will be called later to release - * the data bytes. + * @FT_Incremental_FreeGlyphDataFunc will be called later to release the + * data bytes. * * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for * compound glyphs. @@ -182,7 +183,7 @@ FT_BEGIN_HEADER FT_Data* adata ); - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_FreeGlyphDataFunc @@ -206,7 +207,7 @@ FT_BEGIN_HEADER FT_Data* data ); - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_GetGlyphMetricsFunc @@ -214,8 +215,8 @@ FT_BEGIN_HEADER * @description: * A function used to retrieve the basic metrics of a given glyph index * before accessing its data. This is necessary because, in certain - * formats like TrueType, the metrics are stored in a different place from - * the glyph images proper. + * formats like TrueType, the metrics are stored in a different place + * from the glyph images proper. * * @input: * incremental :: @@ -229,9 +230,9 @@ FT_BEGIN_HEADER * If true, return vertical metrics. * * ametrics :: - * This parameter is used for both input and output. - * The original glyph metrics, if any, in font units. If metrics are - * not available all the values must be set to zero. + * This parameter is used for both input and output. The original + * glyph metrics, if any, in font units. If metrics are not available + * all the values must be set to zero. * * @output: * ametrics :: @@ -252,8 +253,8 @@ FT_BEGIN_HEADER * FT_Incremental_FuncsRec * * @description: - * A table of functions for accessing fonts that load data - * incrementally. Used in @FT_Incremental_InterfaceRec. + * A table of functions for accessing fonts that load data incrementally. + * Used in @FT_Incremental_InterfaceRec. * * @fields: * get_glyph_data :: @@ -263,8 +264,8 @@ FT_BEGIN_HEADER * The function to release glyph data. Must not be null. * * get_glyph_metrics :: - * The function to get glyph metrics. May be null if the font does - * not provide overriding glyph metrics. + * The function to get glyph metrics. May be null if the font does not + * provide overriding glyph metrics. * */ typedef struct FT_Incremental_FuncsRec_ @@ -276,7 +277,7 @@ FT_BEGIN_HEADER } FT_Incremental_FuncsRec; - /*************************************************************************** + /************************************************************************** * * @struct: * FT_Incremental_InterfaceRec @@ -286,30 +287,30 @@ FT_BEGIN_HEADER * wants to support incremental glyph loading. You should use it with * @FT_PARAM_TAG_INCREMENTAL as in the following example: * - * { - * FT_Incremental_InterfaceRec inc_int; - * FT_Parameter parameter; - * FT_Open_Args open_args; + * ``` + * FT_Incremental_InterfaceRec inc_int; + * FT_Parameter parameter; + * FT_Open_Args open_args; * * - * // set up incremental descriptor - * inc_int.funcs = my_funcs; - * inc_int.object = my_object; + * // set up incremental descriptor + * inc_int.funcs = my_funcs; + * inc_int.object = my_object; * - * // set up optional parameter - * parameter.tag = FT_PARAM_TAG_INCREMENTAL; - * parameter.data = &inc_int; + * // set up optional parameter + * parameter.tag = FT_PARAM_TAG_INCREMENTAL; + * parameter.data = &inc_int; * - * // set up FT_Open_Args structure - * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; - * open_args.pathname = my_font_pathname; - * open_args.num_params = 1; - * open_args.params = ¶meter; // we use one optional argument + * // set up FT_Open_Args structure + * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; + * open_args.pathname = my_font_pathname; + * open_args.num_params = 1; + * open_args.params = ¶meter; // we use one optional argument * - * // open the font - * error = FT_Open_Face( library, &open_args, index, &face ); - * ... - * } + * // open the font + * error = FT_Open_Face( library, &open_args, index, &face ); + * ... + * ``` * */ typedef struct FT_Incremental_InterfaceRec_ @@ -320,7 +321,7 @@ FT_BEGIN_HEADER } FT_Incremental_InterfaceRec; - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_Interface diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h index 2a27196cbb8..79b3e0cc11e 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftlcdfil.h */ -/* */ -/* FreeType API for color filtering of subpixel bitmap glyphs */ -/* (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftlcdfil.h + * + * FreeType API for color filtering of subpixel bitmap glyphs + * (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTLCDFIL_H_ @@ -33,105 +33,98 @@ FT_BEGIN_HEADER - /*************************************************************************** + /************************************************************************** * * @section: - * lcd_filtering + * lcd_rendering * * @title: - * LCD Filtering + * Subpixel Rendering * * @abstract: - * Reduce color fringes of subpixel-rendered bitmaps. + * API to control subpixel rendering. * * @description: - * Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your - * `ftoption.h', which enables patented ClearType-style rendering, - * the LCD-optimized glyph bitmaps should be filtered to reduce color - * fringes inherent to this technology. The default FreeType LCD - * rendering uses different technology, and API described below, - * although available, does nothing. + * FreeType provides two alternative subpixel rendering technologies. + * Should you define `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` in your + * `ftoption.h` file, this enables patented ClearType-style rendering. + * Otherwise, Harmony LCD rendering is enabled. These technologies are + * controlled differently and API described below, although always + * available, performs its function when appropriate method is enabled + * and does nothing otherwise. * * ClearType-style LCD rendering exploits the color-striped structure of * LCD pixels, increasing the available resolution in the direction of - * the stripe (usually horizontal RGB) by a factor of~3. Since these - * subpixels are color pixels, using them unfiltered creates severe - * color fringes. Use the @FT_Library_SetLcdFilter API to specify a - * low-pass filter, which is then applied to subpixel-rendered bitmaps - * generated through @FT_Render_Glyph. The filter sacrifices some of - * the higher resolution to reduce color fringes, making the glyph image - * slightly blurrier. Positional improvements will remain. - * - * A filter should have two properties: - * - * 1) It should be normalized, meaning the sum of the 5~components - * should be 256 (0x100). It is possible to go above or under this - * target sum, however: going under means tossing out contrast, going - * over means invoking clamping and thereby non-linearities that - * increase contrast somewhat at the expense of greater distortion - * and color-fringing. Contrast is better enhanced through stem - * darkening. - * - * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}' - * where a~+ b~=~c. It distributes the computed coverage for one - * subpixel to all subpixels equally, sacrificing some won resolution - * but drastically reducing color-fringing. Positioning improvements - * remain! Note that color-fringing can only really be minimized - * when using a color-balanced filter and alpha-blending the glyph - * onto a surface in linear space; see @FT_Render_Glyph. - * - * Regarding the form, a filter can be a `boxy' filter or a `beveled' - * filter. Boxy filters are sharper but are less forgiving of non-ideal - * gamma curves of a screen (viewing angles!), beveled filters are - * fuzzier but more tolerant. - * - * Examples: - * - * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor - * normalized. - * - * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not - * normalized. - * - * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not - * balanced. - * - * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not - * balanced. - * - * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost - * balanced. - * - * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost - * balanced. - * - * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, - * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output - * of @FT_Outline_Render and @FT_Outline_Get_Bitmap. - * - * If this feature is activated, the dimensions of LCD glyph bitmaps are - * either wider or taller than the dimensions of the corresponding - * outline with regard to the pixel grid. For example, for - * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and - * 3~subpixels to the right. The bitmap offset values are adjusted - * accordingly, so clients shouldn't need to modify their layout and - * glyph positioning code when enabling the filter. - * - * It is important to understand that linear alpha blending and gamma - * correction is critical for correctly rendering glyphs onto surfaces - * without artifacts and even more critical when subpixel rendering is - * involved. - * - * Each of the 3~alpha values (subpixels) is independently used to blend - * one color channel. That is, red alpha blends the red channel of the - * text color with the red channel of the background pixel. The - * distribution of density values by the color-balanced filter assumes - * alpha blending is done in linear space; only then color artifacts - * cancel out. + * the stripe (usually horizontal RGB) by a factor of~3. Using the + * subpixels coverages unfiltered can create severe color fringes + * especially when rendering thin features. Indeed, to produce + * black-on-white text, the nearby color subpixels must be dimmed + * equally. + * + * A good 5-tap FIR filter should be applied to subpixel coverages + * regardless of pixel boundaries and should have these properties: + * + * 1. It should be symmetrical, like {~a, b, c, b, a~}, to avoid + * any shifts in appearance. + * + * 2. It should be color-balanced, meaning a~+ b~=~c, to reduce color + * fringes by distributing the computed coverage for one subpixel to + * all subpixels equally. + * + * 3. It should be normalized, meaning 2a~+ 2b~+ c~=~1.0 to maintain + * overall brightness. + * + * Boxy 3-tap filter {0, 1/3, 1/3, 1/3, 0} is sharper but is less + * forgiving of non-ideal gamma curves of a screen (and viewing angles), + * beveled filters are fuzzier but more tolerant. + * + * Use the @FT_Library_SetLcdFilter or @FT_Library_SetLcdFilterWeights + * API to specify a low-pass filter, which is then applied to + * subpixel-rendered bitmaps generated through @FT_Render_Glyph. + * + * Harmony LCD rendering is suitable to panels with any regular subpixel + * structure, not just monitors with 3 color striped subpixels, as long + * as the color subpixels have fixed positions relative to the pixel + * center. In this case, each color channel is then rendered separately + * after shifting the outline opposite to the subpixel shift so that the + * coverage maps are aligned. This method is immune to color fringes + * because the shifts do not change integral coverage. + * + * The subpixel geometry must be specified by xy-coordinates for each + * subpixel. By convention they may come in the RGB order: {{-1/3, 0}, + * {0, 0}, {1/3, 0}} for standard RGB striped panel or {{-1/6, 1/4}, + * {-1/6, -1/4}, {1/3, 0}} for a certain PenTile panel. + * + * Use the @FT_Library_SetLcdGeometry API to specify subpixel positions. + * If one follows the RGB order convention, the same order applies to the + * resulting @FT_PIXEL_MODE_LCD and @FT_PIXEL_MODE_LCD_V bitmaps. Note, + * however, that the coordinate frame for the latter must be rotated + * clockwise. Harmony with default LCD geometry is equivalent to + * ClearType with light filter. + * + * As a result of ClearType filtering or Harmony rendering, the + * dimensions of LCD bitmaps can be either wider or taller than the + * dimensions of the corresponding outline with regard to the pixel grid. + * For example, for @FT_RENDER_MODE_LCD, the filter adds 2~subpixels to + * the left, and 2~subpixels to the right. The bitmap offset values are + * adjusted accordingly, so clients shouldn't need to modify their layout + * and glyph positioning code when enabling the filter. + * + * The ClearType and Harmony rendering is applicable to glyph bitmaps + * rendered through @FT_Render_Glyph, @FT_Load_Glyph, @FT_Load_Char, and + * @FT_Glyph_To_Bitmap, when @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V + * is specified. This API does not control @FT_Outline_Render and + * @FT_Outline_Get_Bitmap. + * + * The described algorithms can completely remove color artefacts when + * combined with gamma-corrected alpha blending in linear space. Each of + * the 3~alpha values (subpixels) must by independently used to blend one + * color channel. That is, red alpha blends the red channel of the text + * color with the red channel of the background pixel. */ - /**************************************************************************** + /************************************************************************** * * @enum: * FT_LcdFilter @@ -145,47 +138,25 @@ FT_BEGIN_HEADER * results in sometimes severe color fringes. * * FT_LCD_FILTER_DEFAULT :: - * The default filter reduces color fringes considerably, at the cost - * of a slight blurriness in the output. - * - * It is a beveled, normalized, and color-balanced five-tap filter - * that is more forgiving to screens with non-ideal gamma curves and - * viewing angles. Note that while color-fringing is reduced, it can - * only be minimized by using linear alpha blending and gamma - * correction to render glyphs onto surfaces. The default filter - * weights are [0x08 0x4D 0x56 0x4D 0x08]. + * This is a beveled, normalized, and color-balanced five-tap filter + * with weights of [0x08 0x4D 0x56 0x4D 0x08] in 1/256th units. * * FT_LCD_FILTER_LIGHT :: - * The light filter is a variant that is sharper at the cost of - * slightly more color fringes than the default one. - * - * It is a boxy, normalized, and color-balanced three-tap filter that - * is less forgiving to screens with non-ideal gamma curves and - * viewing angles. This filter works best when the rendering system - * uses linear alpha blending and gamma correction to render glyphs - * onto surfaces. The light filter weights are - * [0x00 0x55 0x56 0x55 0x00]. + * this is a boxy, normalized, and color-balanced three-tap filter with + * weights of [0x00 0x55 0x56 0x55 0x00] in 1/256th units. * * FT_LCD_FILTER_LEGACY :: + * FT_LCD_FILTER_LEGACY1 :: * This filter corresponds to the original libXft color filter. It * provides high contrast output but can exhibit really bad color * fringes if glyphs are not extremely well hinted to the pixel grid. - * In other words, it only works well if the TrueType bytecode - * interpreter is enabled *and* high-quality hinted fonts are used. - * * This filter is only provided for comparison purposes, and might be - * disabled or stay unsupported in the future. - * - * FT_LCD_FILTER_LEGACY1 :: - * For historical reasons, the FontConfig library returns a different - * enumeration value for legacy LCD filtering. To make code work that - * (incorrectly) forwards FontConfig's enumeration value to - * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest - * to have another enumeration value, which is completely equal to - * `FT_LCD_FILTER_LEGACY'. + * disabled or stay unsupported in the future. The second value is + * provided for compatibility with FontConfig, which historically used + * different enumeration, sometimes incorrectly forwarded to FreeType. * * @since: - * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2) + * 2.3.0 (`FT_LCD_FILTER_LEGACY1` since 2.6.2) */ typedef enum FT_LcdFilter_ { @@ -202,7 +173,7 @@ FT_BEGIN_HEADER /************************************************************************** * - * @func: + * @function: * FT_Library_SetLcdFilter * * @description: @@ -218,20 +189,20 @@ FT_BEGIN_HEADER * The filter type. * * You can use @FT_LCD_FILTER_NONE here to disable this feature, or - * @FT_LCD_FILTER_DEFAULT to use a default filter that should work - * well on most LCD screens. + * @FT_LCD_FILTER_DEFAULT to use a default filter that should work well + * on most LCD screens. * * @return: * FreeType error code. 0~means success. * * @note: * This feature is always disabled by default. Clients must make an - * explicit call to this function with a `filter' value other than + * explicit call to this function with a `filter` value other than * @FT_LCD_FILTER_NONE in order to enable it. * - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * Due to **PATENTS** covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature` if the + * configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is not * defined in your build of the library, which should correspond to all * default builds of FreeType. * @@ -245,7 +216,7 @@ FT_BEGIN_HEADER /************************************************************************** * - * @func: + * @function: * FT_Library_SetLcdFilterWeights * * @description: @@ -258,15 +229,15 @@ FT_BEGIN_HEADER * * weights :: * A pointer to an array; the function copies the first five bytes and - * uses them to specify the filter weights. + * uses them to specify the filter weights in 1/256th units. * * @return: * FreeType error code. 0~means success. * * @note: - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * Due to **PATENTS** covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature` if the + * configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is not * defined in your build of the library, which should correspond to all * default builds of FreeType. * @@ -281,7 +252,8 @@ FT_BEGIN_HEADER unsigned char *weights ); - /* + /************************************************************************** + * * @type: * FT_LcdFiveTapFilter * @@ -298,6 +270,53 @@ FT_BEGIN_HEADER typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS]; + /************************************************************************** + * + * @function: + * FT_Library_SetLcdGeometry + * + * @description: + * This function can be used to modify default positions of color + * subpixels, which controls Harmony LCD rendering. + * + * @input: + * library :: + * A handle to the target library instance. + * + * sub :: + * A pointer to an array of 3 vectors in 26.6 fractional pixel format; + * the function modifies the default values, see the note below. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Subpixel geometry examples: + * + * - {{-21, 0}, {0, 0}, {21, 0}} is the default, corresponding to 3 color + * stripes shifted by a third of a pixel. This could be an RGB panel. + * + * - {{21, 0}, {0, 0}, {-21, 0}} looks the same as the default but can + * specify a BGR panel instead, while keeping the bitmap in the same + * RGB888 format. + * + * - {{0, 21}, {0, 0}, {0, -21}} is the vertical RGB, but the bitmap + * stays RGB888 as a result. + * + * - {{-11, 16}, {-11, -16}, {22, 0}} is a certain PenTile arrangement. + * + * This function does nothing and returns `FT_Err_Unimplemented_Feature` + * in the context of ClearType-style subpixel rendering when + * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is defined in your build of the + * library. + * + * @since: + * 2.10.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector sub[3] ); + /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h index 117473b96a2..4782892d1a7 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftlist.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftlist.h */ -/* */ -/* Generic list support for FreeType (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype.h'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftlist.h + * + * Generic list support for FreeType (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file implements functions relative to list processing. Its data + * structures are defined in `freetype.h`. + * + */ #ifndef FTLIST_H_ @@ -41,224 +41,245 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /* <Title> */ - /* List Processing */ - /* */ - /* <Abstract> */ - /* Simple management of lists. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to list */ - /* processing using doubly-linked nodes. */ - /* */ - /* <Order> */ - /* FT_List */ - /* FT_ListNode */ - /* FT_ListRec */ - /* FT_ListNodeRec */ - /* */ - /* FT_List_Add */ - /* FT_List_Insert */ - /* FT_List_Find */ - /* FT_List_Remove */ - /* FT_List_Up */ - /* FT_List_Iterate */ - /* FT_List_Iterator */ - /* FT_List_Finalize */ - /* FT_List_Destructor */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Find */ - /* */ - /* <Description> */ - /* Find the list node for a given listed object. */ - /* */ - /* <Input> */ - /* list :: A pointer to the parent list. */ - /* data :: The address of the listed object. */ - /* */ - /* <Return> */ - /* List node. NULL if it wasn't found. */ - /* */ + /************************************************************************** + * + * @section: + * list_processing + * + * @title: + * List Processing + * + * @abstract: + * Simple management of lists. + * + * @description: + * This section contains various definitions related to list processing + * using doubly-linked nodes. + * + * @order: + * FT_List + * FT_ListNode + * FT_ListRec + * FT_ListNodeRec + * + * FT_List_Add + * FT_List_Insert + * FT_List_Find + * FT_List_Remove + * FT_List_Up + * FT_List_Iterate + * FT_List_Iterator + * FT_List_Finalize + * FT_List_Destructor + * + */ + + + /************************************************************************** + * + * @function: + * FT_List_Find + * + * @description: + * Find the list node for a given listed object. + * + * @input: + * list :: + * A pointer to the parent list. + * data :: + * The address of the listed object. + * + * @return: + * List node. `NULL` if it wasn't found. + */ FT_EXPORT( FT_ListNode ) FT_List_Find( FT_List list, void* data ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Add */ - /* */ - /* <Description> */ - /* Append an element to the end of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to append. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Add + * + * @description: + * Append an element to the end of a list. + * + * @inout: + * list :: + * A pointer to the parent list. + * node :: + * The node to append. + */ FT_EXPORT( void ) FT_List_Add( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Insert */ - /* */ - /* <Description> */ - /* Insert an element at the head of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to parent list. */ - /* node :: The node to insert. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Insert + * + * @description: + * Insert an element at the head of a list. + * + * @inout: + * list :: + * A pointer to parent list. + * node :: + * The node to insert. + */ FT_EXPORT( void ) FT_List_Insert( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Remove */ - /* */ - /* <Description> */ - /* Remove a node from a list. This function doesn't check whether */ - /* the node is in the list! */ - /* */ - /* <Input> */ - /* node :: The node to remove. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Remove + * + * @description: + * Remove a node from a list. This function doesn't check whether the + * node is in the list! + * + * @input: + * node :: + * The node to remove. + * + * @inout: + * list :: + * A pointer to the parent list. + */ FT_EXPORT( void ) FT_List_Remove( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Up */ - /* */ - /* <Description> */ - /* Move a node to the head/top of a list. Used to maintain LRU */ - /* lists. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to move. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Up + * + * @description: + * Move a node to the head/top of a list. Used to maintain LRU lists. + * + * @inout: + * list :: + * A pointer to the parent list. + * node :: + * The node to move. + */ FT_EXPORT( void ) FT_List_Up( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Iterator */ - /* */ - /* <Description> */ - /* An FT_List iterator function that is called during a list parse */ - /* by @FT_List_Iterate. */ - /* */ - /* <Input> */ - /* node :: The current iteration list node. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. */ - /* Can be used to point to the iteration's state. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_List_Iterator + * + * @description: + * An FT_List iterator function that is called during a list parse by + * @FT_List_Iterate. + * + * @input: + * node :: + * The current iteration list node. + * + * user :: + * A typeless pointer passed to @FT_List_Iterate. Can be used to point + * to the iteration's state. + */ typedef FT_Error (*FT_List_Iterator)( FT_ListNode node, void* user ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Iterate */ - /* */ - /* <Description> */ - /* Parse a list and calls a given iterator function on each element. */ - /* Note that parsing is stopped as soon as one of the iterator calls */ - /* returns a non-zero value. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* iterator :: An iterator function, called on each node of the list. */ - /* user :: A user-supplied field that is passed as the second */ - /* argument to the iterator. */ - /* */ - /* <Return> */ - /* The result (a FreeType error code) of the last iterator call. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Iterate + * + * @description: + * Parse a list and calls a given iterator function on each element. + * Note that parsing is stopped as soon as one of the iterator calls + * returns a non-zero value. + * + * @input: + * list :: + * A handle to the list. + * iterator :: + * An iterator function, called on each node of the list. + * user :: + * A user-supplied field that is passed as the second argument to the + * iterator. + * + * @return: + * The result (a FreeType error code) of the last iterator call. + */ FT_EXPORT( FT_Error ) FT_List_Iterate( FT_List list, FT_List_Iterator iterator, void* user ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Destructor */ - /* */ - /* <Description> */ - /* An @FT_List iterator function that is called during a list */ - /* finalization by @FT_List_Finalize to destroy all elements in a */ - /* given list. */ - /* */ - /* <Input> */ - /* system :: The current system object. */ - /* */ - /* data :: The current object to destroy. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ - /* be used to point to the iteration's state. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_List_Destructor + * + * @description: + * An @FT_List iterator function that is called during a list + * finalization by @FT_List_Finalize to destroy all elements in a given + * list. + * + * @input: + * system :: + * The current system object. + * + * data :: + * The current object to destroy. + * + * user :: + * A typeless pointer passed to @FT_List_Iterate. It can be used to + * point to the iteration's state. + */ typedef void (*FT_List_Destructor)( FT_Memory memory, void* data, void* user ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Finalize */ - /* */ - /* <Description> */ - /* Destroy all elements in the list as well as the list itself. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* */ - /* destroy :: A list destructor that will be applied to each element */ - /* of the list. Set this to NULL if not needed. */ - /* */ - /* memory :: The current memory object that handles deallocation. */ - /* */ - /* user :: A user-supplied field that is passed as the last */ - /* argument to the destructor. */ - /* */ - /* <Note> */ - /* This function expects that all nodes added by @FT_List_Add or */ - /* @FT_List_Insert have been dynamically allocated. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Finalize + * + * @description: + * Destroy all elements in the list as well as the list itself. + * + * @input: + * list :: + * A handle to the list. + * + * destroy :: + * A list destructor that will be applied to each element of the list. + * Set this to `NULL` if not needed. + * + * memory :: + * The current memory object that handles deallocation. + * + * user :: + * A user-supplied field that is passed as the last argument to the + * destructor. + * + * @note: + * This function expects that all nodes added by @FT_List_Add or + * @FT_List_Insert have been dynamically allocated. + */ FT_EXPORT( void ) FT_List_Finalize( FT_List list, FT_List_Destructor destroy, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h index c1e497ca2db..92b9f3dc0fa 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmac.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftmac.h */ -/* */ -/* Additional Mac-specific API. */ -/* */ -/* Copyright 1996-2018 by */ -/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmac.h + * + * Additional Mac-specific API. + * + * Copyright (C) 1996-2019 by + * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ -/***************************************************************************/ -/* */ -/* NOTE: Include this file after FT_FREETYPE_H and after any */ -/* Mac-specific headers (because this header uses Mac types such as */ -/* Handle, FSSpec, FSRef, etc.) */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * NOTE: Include this file after `FT_FREETYPE_H` and after any + * Mac-specific headers (because this header uses Mac types such as + * 'Handle', 'FSSpec', 'FSRef', etc.) + * + */ #ifndef FTMAC_H_ @@ -47,56 +47,59 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* <Section> */ - /* mac_specific */ - /* */ - /* <Title> */ - /* Mac Specific Interface */ - /* */ - /* <Abstract> */ - /* Only available on the Macintosh. */ - /* */ - /* <Description> */ - /* The following definitions are only available if FreeType is */ - /* compiled on a Macintosh. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * mac_specific + * + * @title: + * Mac Specific Interface + * + * @abstract: + * Only available on the Macintosh. + * + * @description: + * The following definitions are only available if FreeType is compiled + * on a Macintosh. + * + */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FOND */ - /* */ - /* <Description> */ - /* Create a new face object from a FOND resource. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* fond :: A FOND resource. */ - /* */ - /* face_index :: Only supported for the -1 `sanity check' special */ - /* case. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Notes> */ - /* This function can be used to create @FT_Face objects from fonts */ - /* that are installed in the system as follows. */ - /* */ - /* { */ - /* fond = GetResource( 'FOND', fontName ); */ - /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face_From_FOND + * + * @description: + * Create a new face object from a FOND resource. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * fond :: + * A FOND resource. + * + * face_index :: + * Only supported for the -1 'sanity check' special case. + * + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @example: + * This function can be used to create @FT_Face objects from fonts that + * are installed in the system as follows. + * + * ``` + * fond = GetResource( 'FOND', fontName ); + * error = FT_New_Face_From_FOND( library, fond, 0, &face ); + * ``` + */ FT_EXPORT( FT_Error ) FT_New_Face_From_FOND( FT_Library library, Handle fond, @@ -105,28 +108,28 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font (e.g., Times New Roman */ - /* Bold). */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_GetFile_From_Mac_Name + * + * @description: + * Return an FSSpec for the disk file containing the named font. + * + * @input: + * fontName :: + * Mac OS name of the font (e.g., Times New Roman Bold). + * + * @output: + * pathSpec :: + * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face_From_FSSpec. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_GetFile_From_Mac_Name( const char* fontName, FSSpec* pathSpec, @@ -134,27 +137,28 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_GetFile_From_Mac_ATS_Name + * + * @description: + * Return an FSSpec for the disk file containing the named font. + * + * @input: + * fontName :: + * Mac OS name of the font in ATS framework. + * + * @output: + * pathSpec :: + * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face_From_FSSpec. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_GetFile_From_Mac_ATS_Name( const char* fontName, FSSpec* pathSpec, @@ -162,30 +166,33 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFilePath_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return a pathname of the disk file and face index for given font */ - /* name that is handled by ATS framework. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* path :: Buffer to store pathname of the file. For passing */ - /* to @FT_New_Face. The client must allocate this */ - /* buffer before calling this function. */ - /* */ - /* maxPathSize :: Lengths of the buffer `path' that client allocated. */ - /* */ - /* face_index :: Index of the face. For passing to @FT_New_Face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_GetFilePath_From_Mac_ATS_Name + * + * @description: + * Return a pathname of the disk file and face index for given font name + * that is handled by ATS framework. + * + * @input: + * fontName :: + * Mac OS name of the font in ATS framework. + * + * @output: + * path :: + * Buffer to store pathname of the file. For passing to @FT_New_Face. + * The client must allocate this buffer before calling this function. + * + * maxPathSize :: + * Lengths of the buffer `path` that client allocated. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, UInt8* path, @@ -194,33 +201,37 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSSpec */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSSpec to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSSpec to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ - /* it accepts an FSSpec instead of a path. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face_From_FSSpec + * + * @description: + * Create a new face object from a given resource and typeface index + * using an FSSpec to the font file. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * spec :: + * FSSpec to the font file. + * + * face_index :: + * The index of the face within the resource. The first face has + * index~0. + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * @FT_New_Face_From_FSSpec is identical to @FT_New_Face except it + * accepts an FSSpec instead of a path. + */ FT_EXPORT( FT_Error ) FT_New_Face_From_FSSpec( FT_Library library, const FSSpec *spec, @@ -229,33 +240,37 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSRef */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSRef to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSRef to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ - /* it accepts an FSRef instead of a path. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face_From_FSRef + * + * @description: + * Create a new face object from a given resource and typeface index + * using an FSRef to the font file. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * spec :: + * FSRef to the font file. + * + * face_index :: + * The index of the face within the resource. The first face has + * index~0. + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * @FT_New_Face_From_FSRef is identical to @FT_New_Face except it accepts + * an FSRef instead of a path. + */ FT_EXPORT( FT_Error ) FT_New_Face_From_FSRef( FT_Library library, const FSRef *ref, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h index 9948102c14f..f2e16b64087 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmm.h */ -/* */ -/* FreeType Multiple Master font interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmm.h + * + * FreeType Multiple Master font interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTMM_H_ @@ -27,49 +27,52 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* multiple_masters */ - /* */ - /* <Title> */ - /* Multiple Masters */ - /* */ - /* <Abstract> */ - /* How to manage Multiple Masters fonts. */ - /* */ - /* <Description> */ - /* The following types and functions are used to manage Multiple */ - /* Master fonts, i.e., the selection of specific design instances by */ - /* setting design axis coordinates. */ - /* */ - /* Besides Adobe MM fonts, the interface supports Apple's TrueType GX */ - /* and OpenType variation fonts. Some of the routines only work with */ - /* Adobe MM fonts, others will work with all three types. They are */ - /* similar enough that a consistent interface makes sense. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Axis */ - /* */ - /* <Description> */ - /* A structure to model a given axis in design space for Multiple */ - /* Masters fonts. */ - /* */ - /* This structure can't be used for TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ + /************************************************************************** + * + * @section: + * multiple_masters + * + * @title: + * Multiple Masters + * + * @abstract: + * How to manage Multiple Masters fonts. + * + * @description: + * The following types and functions are used to manage Multiple Master + * fonts, i.e., the selection of specific design instances by setting + * design axis coordinates. + * + * Besides Adobe MM fonts, the interface supports Apple's TrueType GX and + * OpenType variation fonts. Some of the routines only work with Adobe + * MM fonts, others will work with all three types. They are similar + * enough that a consistent interface makes sense. + * + */ + + + /************************************************************************** + * + * @struct: + * FT_MM_Axis + * + * @description: + * A structure to model a given axis in design space for Multiple Masters + * fonts. + * + * This structure can't be used for TrueType GX or OpenType variation + * fonts. + * + * @fields: + * name :: + * The axis's name. + * + * minimum :: + * The axis's minimum design coordinate. + * + * maximum :: + * The axis's maximum design coordinate. + */ typedef struct FT_MM_Axis_ { FT_String* name; @@ -79,28 +82,29 @@ FT_BEGIN_HEADER } FT_MM_Axis; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Multi_Master */ - /* */ - /* <Description> */ - /* A structure to model the axes and space of a Multiple Masters */ - /* font. */ - /* */ - /* This structure can't be used for TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <Fields> */ - /* num_axis :: Number of axes. Cannot exceed~4. */ - /* */ - /* num_designs :: Number of designs; should be normally 2^num_axis */ - /* even though the Type~1 specification strangely */ - /* allows for intermediate designs to be present. */ - /* This number cannot exceed~16. */ - /* */ - /* axis :: A table of axis descriptors. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Multi_Master + * + * @description: + * A structure to model the axes and space of a Multiple Masters font. + * + * This structure can't be used for TrueType GX or OpenType variation + * fonts. + * + * @fields: + * num_axis :: + * Number of axes. Cannot exceed~4. + * + * num_designs :: + * Number of designs; should be normally 2^num_axis even though the + * Type~1 specification strangely allows for intermediate designs to be + * present. This number cannot exceed~16. + * + * axis :: + * A table of axis descriptors. + */ typedef struct FT_Multi_Master_ { FT_UInt num_axis; @@ -110,42 +114,45 @@ FT_BEGIN_HEADER } FT_Multi_Master; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Axis */ - /* */ - /* <Description> */ - /* A structure to model a given axis in design space for Multiple */ - /* Masters, TrueType GX, and OpenType variation fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* Not always meaningful for TrueType GX or OpenType */ - /* variation fonts. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* def :: The axis's default design coordinate. */ - /* FreeType computes meaningful default values for Adobe */ - /* MM fonts. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - /* tag :: The axis's tag (the equivalent to `name' for TrueType */ - /* GX and OpenType variation fonts). FreeType provides */ - /* default values for Adobe MM fonts if possible. */ - /* */ - /* strid :: The axis name entry in the font's `name' table. This */ - /* is another (and often better) version of the `name' */ - /* field for TrueType GX or OpenType variation fonts. Not */ - /* meaningful for Adobe MM fonts. */ - /* */ - /* <Note> */ - /* The fields `minimum', `def', and `maximum' are 16.16 fractional */ - /* values for TrueType GX and OpenType variation fonts. For Adobe MM */ - /* fonts, the values are integers. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Var_Axis + * + * @description: + * A structure to model a given axis in design space for Multiple + * Masters, TrueType GX, and OpenType variation fonts. + * + * @fields: + * name :: + * The axis's name. Not always meaningful for TrueType GX or OpenType + * variation fonts. + * + * minimum :: + * The axis's minimum design coordinate. + * + * def :: + * The axis's default design coordinate. FreeType computes meaningful + * default values for Adobe MM fonts. + * + * maximum :: + * The axis's maximum design coordinate. + * + * tag :: + * The axis's tag (the equivalent to 'name' for TrueType GX and + * OpenType variation fonts). FreeType provides default values for + * Adobe MM fonts if possible. + * + * strid :: + * The axis name entry in the font's 'name' table. This is another + * (and often better) version of the 'name' field for TrueType GX or + * OpenType variation fonts. Not meaningful for Adobe MM fonts. + * + * @note: + * The fields `minimum`, `def`, and `maximum` are 16.16 fractional values + * for TrueType GX and OpenType variation fonts. For Adobe MM fonts, the + * values are integers. + */ typedef struct FT_Var_Axis_ { FT_String* name; @@ -160,27 +167,29 @@ FT_BEGIN_HEADER } FT_Var_Axis; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Named_Style */ - /* */ - /* <Description> */ - /* A structure to model a named instance in a TrueType GX or OpenType */ - /* variation font. */ - /* */ - /* This structure can't be used for Adobe MM fonts. */ - /* */ - /* <Fields> */ - /* coords :: The design coordinates for this instance. */ - /* This is an array with one entry for each axis. */ - /* */ - /* strid :: The entry in `name' table identifying this instance. */ - /* */ - /* psid :: The entry in `name' table identifying a PostScript name */ - /* for this instance. Value 0xFFFF indicates a missing */ - /* entry. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Var_Named_Style + * + * @description: + * A structure to model a named instance in a TrueType GX or OpenType + * variation font. + * + * This structure can't be used for Adobe MM fonts. + * + * @fields: + * coords :: + * The design coordinates for this instance. This is an array with one + * entry for each axis. + * + * strid :: + * The entry in 'name' table identifying this instance. + * + * psid :: + * The entry in 'name' table identifying a PostScript name for this + * instance. Value 0xFFFF indicates a missing entry. + */ typedef struct FT_Var_Named_Style_ { FT_Fixed* coords; @@ -190,50 +199,47 @@ FT_BEGIN_HEADER } FT_Var_Named_Style; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Var */ - /* */ - /* <Description> */ - /* A structure to model the axes and space of an Adobe MM, TrueType */ - /* GX, or OpenType variation font. */ - /* */ - /* Some fields are specific to one format and not to the others. */ - /* */ - /* <Fields> */ - /* num_axis :: The number of axes. The maximum value is~4 for */ - /* Adobe MM fonts; no limit in TrueType GX or */ - /* OpenType variation fonts. */ - /* */ - /* num_designs :: The number of designs; should be normally */ - /* 2^num_axis for Adobe MM fonts. Not meaningful */ - /* for TrueType GX or OpenType variation fonts */ - /* (where every glyph could have a different */ - /* number of designs). */ - /* */ - /* num_namedstyles :: The number of named styles; a `named style' is */ - /* a tuple of design coordinates that has a string */ - /* ID (in the `name' table) associated with it. */ - /* The font can tell the user that, for example, */ - /* [Weight=1.5,Width=1.1] is `Bold'. Another name */ - /* for `named style' is `named instance'. */ - /* */ - /* For Adobe Multiple Masters fonts, this value is */ - /* always zero because the format does not support */ - /* named styles. */ - /* */ - /* axis :: An axis descriptor table. */ - /* TrueType GX and OpenType variation fonts */ - /* contain slightly more data than Adobe MM fonts. */ - /* Memory management of this pointer is done */ - /* internally by FreeType. */ - /* */ - /* namedstyle :: A named style (instance) table. */ - /* Only meaningful for TrueType GX and OpenType */ - /* variation fonts. Memory management of this */ - /* pointer is done internally by FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_MM_Var + * + * @description: + * A structure to model the axes and space of an Adobe MM, TrueType GX, + * or OpenType variation font. + * + * Some fields are specific to one format and not to the others. + * + * @fields: + * num_axis :: + * The number of axes. The maximum value is~4 for Adobe MM fonts; no + * limit in TrueType GX or OpenType variation fonts. + * + * num_designs :: + * The number of designs; should be normally 2^num_axis for Adobe MM + * fonts. Not meaningful for TrueType GX or OpenType variation fonts + * (where every glyph could have a different number of designs). + * + * num_namedstyles :: + * The number of named styles; a 'named style' is a tuple of design + * coordinates that has a string ID (in the 'name' table) associated + * with it. The font can tell the user that, for example, + * [Weight=1.5,Width=1.1] is 'Bold'. Another name for 'named style' is + * 'named instance'. + * + * For Adobe Multiple Masters fonts, this value is always zero because + * the format does not support named styles. + * + * axis :: + * An axis descriptor table. TrueType GX and OpenType variation fonts + * contain slightly more data than Adobe MM fonts. Memory management + * of this pointer is done internally by FreeType. + * + * namedstyle :: + * A named style (instance) table. Only meaningful for TrueType GX and + * OpenType variation fonts. Memory management of this pointer is done + * internally by FreeType. + */ typedef struct FT_MM_Var_ { FT_UInt num_axis; @@ -245,384 +251,493 @@ FT_BEGIN_HEADER } FT_MM_Var; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Multi_Master */ - /* */ - /* <Description> */ - /* Retrieve a variation descriptor of a given Adobe MM font. */ - /* */ - /* This function can't be used with TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The Multiple Masters descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Multi_Master + * + * @description: + * Retrieve a variation descriptor of a given Adobe MM font. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * amaster :: + * The Multiple Masters descriptor. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Get_Multi_Master( FT_Face face, FT_Multi_Master *amaster ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_MM_Var */ - /* */ - /* <Description> */ - /* Retrieve a variation descriptor for a given font. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The variation descriptor. */ - /* Allocates a data structure, which the user must */ - /* deallocate with a call to @FT_Done_MM_Var after use. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_MM_Var + * + * @description: + * Retrieve a variation descriptor for a given font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * amaster :: + * The variation descriptor. Allocates a data structure, which the + * user must deallocate with a call to @FT_Done_MM_Var after use. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Get_MM_Var( FT_Face face, FT_MM_Var* *amaster ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_MM_Var */ - /* */ - /* <Description> */ - /* Free the memory allocated by @FT_Get_MM_Var. */ - /* */ - /* <Input> */ - /* library :: A handle of the face's parent library object that was */ - /* used in the call to @FT_Get_MM_Var to create `amaster'. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_MM_Var + * + * @description: + * Free the memory allocated by @FT_Get_MM_Var. + * + * @input: + * library :: + * A handle of the face's parent library object that was used in the + * call to @FT_Get_MM_Var to create `amaster`. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Done_MM_Var( FT_Library library, FT_MM_Var *amaster ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Design_Coordinates */ - /* */ - /* <Description> */ - /* For Adobe MM fonts, choose an interpolated font design through */ - /* design coordinates. */ - /* */ - /* This function can't be used with TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* [Since 2.8.1] To reset all axes to the default values, call the */ - /* function with `num_coords' set to zero and `coords' set to NULL. */ - /* */ - /* [Since 2.9] If `num_coords' is larger than zero, this function */ - /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ - /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ - /* is zero, this bit flag gets unset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_MM_Design_Coordinates + * + * @description: + * For Adobe MM fonts, choose an interpolated font design through design + * coordinates. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * An array of design coordinates. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ FT_EXPORT( FT_Error ) FT_Set_MM_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Long* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Design_Coordinates */ - /* */ - /* <Description> */ - /* Choose an interpolated font design through design coordinates. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* [Since 2.8.1] To reset all axes to the default values, call the */ - /* function with `num_coords' set to zero and `coords' set to NULL. */ - /* [Since 2.9] `Default values' means the currently selected named */ - /* instance (or the base font if no named instance is selected). */ - /* */ - /* [Since 2.9] If `num_coords' is larger than zero, this function */ - /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ - /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ - /* is zero, this bit flag gets unset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Var_Design_Coordinates + * + * @description: + * Choose an interpolated font design through design coordinates. + * + * This function works with all supported variation formats. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * An array of design coordinates. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * [Since 2.9] 'Default values' means the currently selected named + * instance (or the base font if no named instance is selected). + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ FT_EXPORT( FT_Error ) FT_Set_Var_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Var_Design_Coordinates */ - /* */ - /* <Description> */ - /* Get the design coordinates of the currently selected interpolated */ - /* font. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* num_coords :: The number of design coordinates to retrieve. If it */ - /* is larger than the number of axes, set the excess */ - /* values to~0. */ - /* */ - /* <Output> */ - /* coords :: The design coordinates array. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.7.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Var_Design_Coordinates + * + * @description: + * Get the design coordinates of the currently selected interpolated + * font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of design coordinates to retrieve. If it is larger than + * the number of axes, set the excess values to~0. + * + * @output: + * coords :: + * The design coordinates array. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.7.1 + */ FT_EXPORT( FT_Error ) FT_Get_Var_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Blend_Coordinates */ - /* */ - /* <Description> */ - /* Choose an interpolated font design through normalized blend */ - /* coordinates. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: The design coordinates array (each element must be */ - /* between 0 and 1.0 for Adobe MM fonts, and between */ - /* -1.0 and 1.0 for TrueType GX and OpenType variation */ - /* fonts). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* [Since 2.8.1] To reset all axes to the default values, call the */ - /* function with `num_coords' set to zero and `coords' set to NULL. */ - /* [Since 2.9] `Default values' means the currently selected named */ - /* instance (or the base font if no named instance is selected). */ - /* */ - /* [Since 2.9] If `num_coords' is larger than zero, this function */ - /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ - /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ - /* is zero, this bit flag gets unset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_MM_Blend_Coordinates + * + * @description: + * Choose an interpolated font design through normalized blend + * coordinates. + * + * This function works with all supported variation formats. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * The design coordinates array (each element must be between 0 and 1.0 + * for Adobe MM fonts, and between -1.0 and 1.0 for TrueType GX and + * OpenType variation fonts). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * [Since 2.9] 'Default values' means the currently selected named + * instance (or the base font if no named instance is selected). + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ FT_EXPORT( FT_Error ) FT_Set_MM_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_MM_Blend_Coordinates */ - /* */ - /* <Description> */ - /* Get the normalized blend coordinates of the currently selected */ - /* interpolated font. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* num_coords :: The number of normalized blend coordinates to */ - /* retrieve. If it is larger than the number of axes, */ - /* set the excess values to~0.5 for Adobe MM fonts, and */ - /* to~0 for TrueType GX and OpenType variation fonts. */ - /* */ - /* <Output> */ - /* coords :: The normalized blend coordinates array. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.7.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_MM_Blend_Coordinates + * + * @description: + * Get the normalized blend coordinates of the currently selected + * interpolated font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of normalized blend coordinates to retrieve. If it is + * larger than the number of axes, set the excess values to~0.5 for + * Adobe MM fonts, and to~0 for TrueType GX and OpenType variation + * fonts. + * + * @output: + * coords :: + * The normalized blend coordinates array. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.7.1 + */ FT_EXPORT( FT_Error ) FT_Get_MM_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Blend_Coordinates */ - /* */ - /* <Description> */ - /* This is another name of @FT_Set_MM_Blend_Coordinates. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Var_Blend_Coordinates + * + * @description: + * This is another name of @FT_Set_MM_Blend_Coordinates. + */ FT_EXPORT( FT_Error ) FT_Set_Var_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Var_Blend_Coordinates */ - /* */ - /* <Description> */ - /* This is another name of @FT_Get_MM_Blend_Coordinates. */ - /* */ - /* <Since> */ - /* 2.7.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Var_Blend_Coordinates + * + * @description: + * This is another name of @FT_Get_MM_Blend_Coordinates. + * + * @since: + * 2.7.1 + */ FT_EXPORT( FT_Error ) FT_Get_Var_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_VAR_AXIS_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the return value of */ - /* @FT_Get_Var_Axis_Flags. */ - /* */ - /* <Values> */ - /* FT_VAR_AXIS_FLAG_HIDDEN :: */ - /* The variation axis should not be exposed to user interfaces. */ - /* */ - /* <Since> */ - /* 2.8.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_MM_WeightVector + * + * @description: + * For Adobe MM fonts, choose an interpolated font design by directly + * setting the weight vector. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * len :: + * The length of the weight vector array. If it is larger than the + * number of designs, the extra values are ignored. If it is less than + * the number of designs, the remaining values are set to zero. + * + * weightvector :: + * An array representing the weight vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Adobe Multiple Master fonts limit the number of designs, and thus the + * length of the weight vector to~16. + * + * If `len` is zero and `weightvector` is `NULL`, the weight vector array + * is reset to the default values. + * + * The Adobe documentation also states that the values in the + * WeightVector array must total 1.0 +/-~0.001. In practice this does + * not seem to be enforced, so is not enforced here, either. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Set_MM_WeightVector( FT_Face face, + FT_UInt len, + FT_Fixed* weightvector ); + + + /************************************************************************** + * + * @function: + * FT_Get_MM_WeightVector + * + * @description: + * For Adobe MM fonts, retrieve the current weight vector of the font. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * len :: + * A pointer to the size of the array to be filled. If the size of the + * array is less than the number of designs, `FT_Err_Invalid_Argument` + * is returned, and `len` is set to the required size (the number of + * designs). If the size of the array is greater than the number of + * designs, the remaining entries are set to~0. On successful + * completion, `len` is set to the number of designs (i.e., the number + * of values written to the array). + * + * @output: + * weightvector :: + * An array to be filled. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Adobe Multiple Master fonts limit the number of designs, and thus the + * length of the WeightVector to~16. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Get_MM_WeightVector( FT_Face face, + FT_UInt* len, + FT_Fixed* weightvector ); + + + /************************************************************************** + * + * @enum: + * FT_VAR_AXIS_FLAG_XXX + * + * @description: + * A list of bit flags used in the return value of + * @FT_Get_Var_Axis_Flags. + * + * @values: + * FT_VAR_AXIS_FLAG_HIDDEN :: + * The variation axis should not be exposed to user interfaces. + * + * @since: + * 2.8.1 + */ #define FT_VAR_AXIS_FLAG_HIDDEN 1 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Var_Axis_Flags */ - /* */ - /* <Description> */ - /* Get the `flags' field of an OpenType Variation Axis Record. */ - /* */ - /* Not meaningful for Adobe MM fonts (`*flags' is always zero). */ - /* */ - /* <Input> */ - /* master :: The variation descriptor. */ - /* */ - /* axis_index :: The index of the requested variation axis. */ - /* */ - /* <Output> */ - /* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */ - /* possible values. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.8.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Var_Axis_Flags + * + * @description: + * Get the 'flags' field of an OpenType Variation Axis Record. + * + * Not meaningful for Adobe MM fonts (`*flags` is always zero). + * + * @input: + * master :: + * The variation descriptor. + * + * axis_index :: + * The index of the requested variation axis. + * + * @output: + * flags :: + * The 'flags' field. See @FT_VAR_AXIS_FLAG_XXX for possible values. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.8.1 + */ FT_EXPORT( FT_Error ) FT_Get_Var_Axis_Flags( FT_MM_Var* master, FT_UInt axis_index, FT_UInt* flags ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Named_Instance */ - /* */ - /* <Description> */ - /* Set or change the current named instance. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* instance_index :: The index of the requested instance, starting */ - /* with value 1. If set to value 0, FreeType */ - /* switches to font access without a named */ - /* instance. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The function uses the value of `instance_index' to set bits 16-30 */ - /* of the face's `face_index' field. It also resets any variation */ - /* applied to the font, and the @FT_FACE_FLAG_VARIATION bit of the */ - /* face's `face_flags' field gets reset to zero (i.e., */ - /* @FT_IS_VARIATION will return false). */ - /* */ - /* For Adobe MM fonts (which don't have named instances) this */ - /* function simply resets the current face to the default instance. */ - /* */ - /* <Since> */ - /* 2.9 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Named_Instance + * + * @description: + * Set or change the current named instance. + * + * @input: + * face :: + * A handle to the source face. + * + * instance_index :: + * The index of the requested instance, starting with value 1. If set + * to value 0, FreeType switches to font access without a named + * instance. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The function uses the value of `instance_index` to set bits 16-30 of + * the face's `face_index` field. It also resets any variation applied + * to the font, and the @FT_FACE_FLAG_VARIATION bit of the face's + * `face_flags` field gets reset to zero (i.e., @FT_IS_VARIATION will + * return false). + * + * For Adobe MM fonts (which don't have named instances) this function + * simply resets the current face to the default instance. + * + * @since: + * 2.9 + */ FT_EXPORT( FT_Error ) FT_Set_Named_Instance( FT_Face face, FT_UInt instance_index ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h index a6eb876ebe3..88488bfe89c 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmodapi.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmodapi.h */ -/* */ -/* FreeType modules public interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmodapi.h + * + * FreeType modules public interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTMODAPI_H_ @@ -33,77 +33,77 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /* <Title> */ - /* Module Management */ - /* */ - /* <Abstract> */ - /* How to add, upgrade, remove, and control modules from FreeType. */ - /* */ - /* <Description> */ - /* The definitions below are used to manage modules within FreeType. */ - /* Modules can be added, upgraded, and removed at runtime. */ - /* Additionally, some module properties can be controlled also. */ - /* */ - /* Here is a list of possible values of the `module_name' field in */ - /* the @FT_Module_Class structure. */ - /* */ - /* { */ - /* autofitter */ - /* bdf */ - /* cff */ - /* gxvalid */ - /* otvalid */ - /* pcf */ - /* pfr */ - /* psaux */ - /* pshinter */ - /* psnames */ - /* raster1 */ - /* sfnt */ - /* smooth, smooth-lcd, smooth-lcdv */ - /* truetype */ - /* type1 */ - /* type42 */ - /* t1cid */ - /* winfonts */ - /* } */ - /* */ - /* Note that the FreeType Cache sub-system is not a FreeType module. */ - /* */ - /* <Order> */ - /* FT_Module */ - /* FT_Module_Constructor */ - /* FT_Module_Destructor */ - /* FT_Module_Requester */ - /* FT_Module_Class */ - /* */ - /* FT_Add_Module */ - /* FT_Get_Module */ - /* FT_Remove_Module */ - /* FT_Add_Default_Modules */ - /* */ - /* FT_Property_Set */ - /* FT_Property_Get */ - /* FT_Set_Default_Properties */ - /* */ - /* FT_New_Library */ - /* FT_Done_Library */ - /* FT_Reference_Library */ - /* */ - /* FT_Renderer */ - /* FT_Renderer_Class */ - /* */ - /* FT_Get_Renderer */ - /* FT_Set_Renderer */ - /* */ - /* FT_Set_Debug_Hook */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * module_management + * + * @title: + * Module Management + * + * @abstract: + * How to add, upgrade, remove, and control modules from FreeType. + * + * @description: + * The definitions below are used to manage modules within FreeType. + * Modules can be added, upgraded, and removed at runtime. Additionally, + * some module properties can be controlled also. + * + * Here is a list of possible values of the `module_name` field in the + * @FT_Module_Class structure. + * + * ``` + * autofitter + * bdf + * cff + * gxvalid + * otvalid + * pcf + * pfr + * psaux + * pshinter + * psnames + * raster1 + * sfnt + * smooth, smooth-lcd, smooth-lcdv + * truetype + * type1 + * type42 + * t1cid + * winfonts + * ``` + * + * Note that the FreeType Cache sub-system is not a FreeType module. + * + * @order: + * FT_Module + * FT_Module_Constructor + * FT_Module_Destructor + * FT_Module_Requester + * FT_Module_Class + * + * FT_Add_Module + * FT_Get_Module + * FT_Remove_Module + * FT_Add_Default_Modules + * + * FT_Property_Set + * FT_Property_Get + * FT_Set_Default_Properties + * + * FT_New_Library + * FT_Done_Library + * FT_Reference_Library + * + * FT_Renderer + * FT_Renderer_Class + * + * FT_Get_Renderer + * FT_Set_Renderer + * + * FT_Set_Debug_Hook + * + */ /* module bit flags */ @@ -137,83 +137,99 @@ FT_BEGIN_HEADER typedef FT_Pointer FT_Module_Interface; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Constructor */ - /* */ - /* <Description> */ - /* A function used to initialize (not create) a new module object. */ - /* */ - /* <Input> */ - /* module :: The module to initialize. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Module_Constructor + * + * @description: + * A function used to initialize (not create) a new module object. + * + * @input: + * module :: + * The module to initialize. + */ typedef FT_Error (*FT_Module_Constructor)( FT_Module module ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destructor */ - /* */ - /* <Description> */ - /* A function used to finalize (not destroy) a given module object. */ - /* */ - /* <Input> */ - /* module :: The module to finalize. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Module_Destructor + * + * @description: + * A function used to finalize (not destroy) a given module object. + * + * @input: + * module :: + * The module to finalize. + */ typedef void (*FT_Module_Destructor)( FT_Module module ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Requester */ - /* */ - /* <Description> */ - /* A function used to query a given module for a specific interface. */ - /* */ - /* <Input> */ - /* module :: The module to be searched. */ - /* */ - /* name :: The name of the interface in the module. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Module_Requester + * + * @description: + * A function used to query a given module for a specific interface. + * + * @input: + * module :: + * The module to be searched. + * + * name :: + * The name of the interface in the module. + */ typedef FT_Module_Interface (*FT_Module_Requester)( FT_Module module, const char* name ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Module_Class */ - /* */ - /* <Description> */ - /* The module class descriptor. */ - /* */ - /* <Fields> */ - /* module_flags :: Bit flags describing the module. */ - /* */ - /* module_size :: The size of one module object/instance in */ - /* bytes. */ - /* */ - /* module_name :: The name of the module. */ - /* */ - /* module_version :: The version, as a 16.16 fixed number */ - /* (major.minor). */ - /* */ - /* module_requires :: The version of FreeType this module requires, */ - /* as a 16.16 fixed number (major.minor). Starts */ - /* at version 2.0, i.e., 0x20000. */ - /* */ - /* module_init :: The initializing function. */ - /* */ - /* module_done :: The finalizing function. */ - /* */ - /* get_interface :: The interface requesting function. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Module_Class + * + * @description: + * The module class descriptor. While being a public structure necessary + * for FreeType's module bookkeeping, most of the fields are essentially + * internal, not to be used directly by an application. + * + * @fields: + * module_flags :: + * Bit flags describing the module. + * + * module_size :: + * The size of one module object/instance in bytes. + * + * module_name :: + * The name of the module. + * + * module_version :: + * The version, as a 16.16 fixed number (major.minor). + * + * module_requires :: + * The version of FreeType this module requires, as a 16.16 fixed + * number (major.minor). Starts at version 2.0, i.e., 0x20000. + * + * module_interface :: + * A typeless pointer to a structure (which varies between different + * modules) that holds the module's interface functions. This is + * essentially what `get_interface` returns. + * + * module_init :: + * The initializing function. + * + * module_done :: + * The finalizing function. + * + * get_interface :: + * The interface requesting function. + */ typedef struct FT_Module_Class_ { FT_ULong module_flags; @@ -231,83 +247,89 @@ FT_BEGIN_HEADER } FT_Module_Class; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Module */ - /* */ - /* <Description> */ - /* Add a new module to a given library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* clazz :: A pointer to class descriptor for the module. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Add_Module + * + * @description: + * Add a new module to a given library instance. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * clazz :: + * A pointer to class descriptor for the module. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An error will be returned if a module already exists by that name, or + * if the module requires a version of FreeType that is too great. + */ FT_EXPORT( FT_Error ) FT_Add_Module( FT_Library library, const FT_Module_Class* clazz ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module */ - /* */ - /* <Description> */ - /* Find a module by its name. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module handle. 0~if none was found. */ - /* */ - /* <Note> */ - /* FreeType's internal modules aren't documented very well, and you */ - /* should look up the source code for details. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Module + * + * @description: + * Find a module by its name. + * + * @input: + * library :: + * A handle to the library object. + * + * module_name :: + * The module's name (as an ASCII string). + * + * @return: + * A module handle. 0~if none was found. + * + * @note: + * FreeType's internal modules aren't documented very well, and you + * should look up the source code for details. + */ FT_EXPORT( FT_Module ) FT_Get_Module( FT_Library library, const char* module_name ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Remove_Module */ - /* */ - /* <Description> */ - /* Remove a given module from a library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to a library object. */ - /* */ - /* <Input> */ - /* module :: A handle to a module object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The module object is destroyed by the function in case of success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Remove_Module + * + * @description: + * Remove a given module from a library instance. + * + * @inout: + * library :: + * A handle to a library object. + * + * @input: + * module :: + * A handle to a module object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The module object is destroyed by the function in case of success. + */ FT_EXPORT( FT_Error ) FT_Remove_Module( FT_Library library, FT_Module module ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Property_Set @@ -317,53 +339,51 @@ FT_BEGIN_HEADER * * @input: * library :: - * A handle to the library the module is part of. + * A handle to the library the module is part of. * * module_name :: - * The module name. + * The module name. * * property_name :: - * The property name. Properties are described in section - * @properties. + * The property name. Properties are described in section + * @properties. * - * Note that only a few modules have properties. + * Note that only a few modules have properties. * * value :: - * A generic pointer to a variable or structure that gives the new - * value of the property. The exact definition of `value' is - * dependent on the property; see section @properties. + * A generic pointer to a variable or structure that gives the new + * value of the property. The exact definition of `value` is + * dependent on the property; see section @properties. * * @return: * FreeType error code. 0~means success. * * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a + * If `module_name` isn't a valid module name, or `property_name` + * doesn't specify a valid property, or if `value` doesn't represent a * valid value for the given property, an error is returned. * - * The following example sets property `bar' (a simple integer) in - * module `foo' to value~1. + * The following example sets property 'bar' (a simple integer) in + * module 'foo' to value~1. * - * { + * ``` * FT_UInt bar; * * * bar = 1; * FT_Property_Set( library, "foo", "bar", &bar ); - * } + * ``` * * Note that the FreeType Cache sub-system doesn't recognize module * property changes. To avoid glyph lookup confusion within the cache - * you should call @FTC_Manager_Reset to completely flush the cache if - * a module property gets changed after @FTC_Manager_New has been - * called. + * you should call @FTC_Manager_Reset to completely flush the cache if a + * module property gets changed after @FTC_Manager_New has been called. * - * It is not possible to set properties of the FreeType Cache - * sub-system itself with FT_Property_Set; use @FTC_Property_Set - * instead. + * It is not possible to set properties of the FreeType Cache sub-system + * itself with FT_Property_Set; use @FTC_Property_Set instead. * - * @since: - * 2.4.11 + * @since: + * 2.4.11 * */ FT_EXPORT( FT_Error ) @@ -373,7 +393,7 @@ FT_BEGIN_HEADER const void* value ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Property_Get @@ -383,32 +403,32 @@ FT_BEGIN_HEADER * * @input: * library :: - * A handle to the library the module is part of. + * A handle to the library the module is part of. * * module_name :: - * The module name. + * The module name. * * property_name :: - * The property name. Properties are described in section - * @properties. + * The property name. Properties are described in section + * @properties. * * @inout: * value :: - * A generic pointer to a variable or structure that gives the - * value of the property. The exact definition of `value' is - * dependent on the property; see section @properties. + * A generic pointer to a variable or structure that gives the value + * of the property. The exact definition of `value` is dependent on + * the property; see section @properties. * * @return: * FreeType error code. 0~means success. * * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a + * If `module_name` isn't a valid module name, or `property_name` + * doesn't specify a valid property, or if `value` doesn't represent a * valid value for the given property, an error is returned. * - * The following example gets property `baz' (a range) in module `foo'. + * The following example gets property 'baz' (a range) in module 'foo'. * - * { + * ``` * typedef range_ * { * FT_Int32 min; @@ -420,13 +440,13 @@ FT_BEGIN_HEADER * * * FT_Property_Get( library, "foo", "baz", &baz ); - * } + * ``` * * It is not possible to retrieve properties of the FreeType Cache * sub-system with FT_Property_Get; use @FTC_Property_Get instead. * - * @since: - * 2.4.11 + * @since: + * 2.4.11 * */ FT_EXPORT( FT_Error ) @@ -436,189 +456,243 @@ FT_BEGIN_HEADER void* value ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Default_Properties */ - /* */ - /* <Description> */ - /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ - /* set, this function reads the `FREETYPE_PROPERTIES' environment */ - /* variable to control driver properties. See section @properties */ - /* for more. */ - /* */ - /* If the compilation option is not set, this function does nothing. */ - /* */ - /* `FREETYPE_PROPERTIES' has the following syntax form (broken here */ - /* into multiple lines for better readability). */ - /* */ - /* { */ - /* <optional whitespace> */ - /* <module-name1> ':' */ - /* <property-name1> '=' <property-value1> */ - /* <whitespace> */ - /* <module-name2> ':' */ - /* <property-name2> '=' <property-value2> */ - /* ... */ - /* } */ - /* */ - /* Example: */ - /* */ - /* { */ - /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ - /* cff:no-stem-darkening=1 \ */ - /* autofitter:warping=1 */ - /* } */ - /* */ - /* <InOut> */ - /* library :: A handle to a new library object. */ - /* */ - /* <Since> */ - /* 2.8 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Default_Properties + * + * @description: + * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is + * set, this function reads the `FREETYPE_PROPERTIES` environment + * variable to control driver properties. See section @properties for + * more. + * + * If the compilation option is not set, this function does nothing. + * + * `FREETYPE_PROPERTIES` has the following syntax form (broken here into + * multiple lines for better readability). + * + * ``` + * <optional whitespace> + * <module-name1> ':' + * <property-name1> '=' <property-value1> + * <whitespace> + * <module-name2> ':' + * <property-name2> '=' <property-value2> + * ... + * ``` + * + * Example: + * + * ``` + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=1 \ + * autofitter:warping=1 + * ``` + * + * @inout: + * library :: + * A handle to a new library object. + * + * @since: + * 2.8 + */ FT_EXPORT( void ) FT_Set_Default_Properties( FT_Library library ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Library */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Library */ - /* structure is created. This function increments the counter. */ - /* @FT_Done_Library then only destroys a library if the counter is~1, */ - /* otherwise it simply decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Library objects. */ - /* */ - /* <Input> */ - /* library :: A handle to a target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Reference_Library + * + * @description: + * A counter gets initialized to~1 at the time an @FT_Library structure + * is created. This function increments the counter. @FT_Done_Library + * then only destroys a library if the counter is~1, otherwise it simply + * decrements the counter. + * + * This function helps in managing life-cycles of structures that + * reference @FT_Library objects. + * + * @input: + * library :: + * A handle to a target library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.4.2 + */ FT_EXPORT( FT_Error ) FT_Reference_Library( FT_Library library ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Library */ - /* */ - /* <Description> */ - /* This function is used to create a new FreeType library instance */ - /* from a given memory object. It is thus possible to use libraries */ - /* with distinct memory allocators within the same program. Note, */ - /* however, that the used @FT_Memory structure is expected to remain */ - /* valid for the life of the @FT_Library object. */ - /* */ - /* Normally, you would call this function (followed by a call to */ - /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, */ - /* and a call to @FT_Set_Default_Properties) instead of */ - /* @FT_Init_FreeType to initialize the FreeType library. */ - /* */ - /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ - /* library instance. */ - /* */ - /* <Input> */ - /* memory :: A handle to the original memory object. */ - /* */ - /* <Output> */ - /* alibrary :: A pointer to handle of a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Library + * + * @description: + * This function is used to create a new FreeType library instance from a + * given memory object. It is thus possible to use libraries with + * distinct memory allocators within the same program. Note, however, + * that the used @FT_Memory structure is expected to remain valid for the + * life of the @FT_Library object. + * + * Normally, you would call this function (followed by a call to + * @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, and a + * call to @FT_Set_Default_Properties) instead of @FT_Init_FreeType to + * initialize the FreeType library. + * + * Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a library + * instance. + * + * @input: + * memory :: + * A handle to the original memory object. + * + * @output: + * alibrary :: + * A pointer to handle of a new library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Library. + */ FT_EXPORT( FT_Error ) FT_New_Library( FT_Memory memory, FT_Library *alibrary ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Library */ - /* */ - /* <Description> */ - /* Discard a given library object. This closes all drivers and */ - /* discards all resource objects. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Library + * + * @description: + * Discard a given library object. This closes all drivers and discards + * all resource objects. + * + * @input: + * library :: + * A handle to the target library. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Library. + */ FT_EXPORT( FT_Error ) FT_Done_Library( FT_Library library ); - /* */ + /************************************************************************** + * + * @functype: + * FT_DebugHook_Func + * + * @description: + * A drop-in replacement (or rather a wrapper) for the bytecode or + * charstring interpreter's main loop function. + * + * Its job is essentially + * + * - to activate debug mode to enforce single-stepping, + * + * - to call the main loop function to interpret the next opcode, and + * + * - to show the changed context to the user. + * + * An example for such a main loop function is `TT_RunIns` (declared in + * FreeType's internal header file `src/truetype/ttinterp.h`). + * + * Have a look at the source code of the `ttdebug` FreeType demo program + * for an example of a drop-in replacement. + * + * @inout: + * arg :: + * A typeless pointer, to be cast to the main loop function's data + * structure (which depends on the font module). For TrueType fonts + * it is bytecode interpreter's execution context, `TT_ExecContext`, + * which is declared in FreeType's internal header file `tttypes.h`. + */ typedef void (*FT_DebugHook_Func)( void* arg ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Debug_Hook */ - /* */ - /* <Description> */ - /* Set a debug hook function for debugging the interpreter of a font */ - /* format. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in `ftobjs.h', e.g., */ - /* `FT_DEBUG_HOOK_TRUETYPE'. */ - /* */ - /* debug_hook :: The function used to debug the interpreter. */ - /* */ - /* <Note> */ - /* Currently, four debug hook slots are available, but only two (for */ - /* the TrueType and the Type~1 interpreter) are defined. */ - /* */ - /* Since the internal headers of FreeType are no longer installed, */ - /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ - /* This is a bug and will be fixed in a forthcoming release. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_DEBUG_HOOK_XXX + * + * @description: + * A list of named debug hook indices. + * + * @values: + * FT_DEBUG_HOOK_TRUETYPE:: + * This hook index identifies the TrueType bytecode debugger. + */ +#define FT_DEBUG_HOOK_TRUETYPE 0 + + + /************************************************************************** + * + * @function: + * FT_Set_Debug_Hook + * + * @description: + * Set a debug hook function for debugging the interpreter of a font + * format. + * + * While this is a public API function, an application needs access to + * FreeType's internal header files to do something useful. + * + * Have a look at the source code of the `ttdebug` FreeType demo program + * for an example of its usage. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * hook_index :: + * The index of the debug hook. You should use defined enumeration + * macros like @FT_DEBUG_HOOK_TRUETYPE. + * + * debug_hook :: + * The function used to debug the interpreter. + * + * @note: + * Currently, four debug hook slots are available, but only one (for the + * TrueType interpreter) is defined. + */ FT_EXPORT( void ) FT_Set_Debug_Hook( FT_Library library, FT_UInt hook_index, FT_DebugHook_Func debug_hook ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Default_Modules */ - /* */ - /* <Description> */ - /* Add the set of default drivers to a given library object. */ - /* This is only useful when you create a library object with */ - /* @FT_New_Library (usually to plug a custom memory manager). */ - /* */ - /* <InOut> */ - /* library :: A handle to a new library object. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Add_Default_Modules + * + * @description: + * Add the set of default drivers to a given library object. This is + * only useful when you create a library object with @FT_New_Library + * (usually to plug a custom memory manager). + * + * @inout: + * library :: + * A handle to a new library object. + */ FT_EXPORT( void ) FT_Add_Default_Modules( FT_Library library ); @@ -644,28 +718,28 @@ FT_BEGIN_HEADER /************************************************************************** * - * @enum: - * FT_TrueTypeEngineType + * @enum: + * FT_TrueTypeEngineType * - * @description: - * A list of values describing which kind of TrueType bytecode - * engine is implemented in a given FT_Library instance. It is used - * by the @FT_Get_TrueType_Engine_Type function. + * @description: + * A list of values describing which kind of TrueType bytecode engine is + * implemented in a given FT_Library instance. It is used by the + * @FT_Get_TrueType_Engine_Type function. * - * @values: - * FT_TRUETYPE_ENGINE_TYPE_NONE :: - * The library doesn't implement any kind of bytecode interpreter. + * @values: + * FT_TRUETYPE_ENGINE_TYPE_NONE :: + * The library doesn't implement any kind of bytecode interpreter. * - * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: - * Deprecated and removed. + * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: + * Deprecated and removed. * - * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: - * The library implements a bytecode interpreter that covers - * the full instruction set of the TrueType virtual machine (this - * was governed by patents until May 2010, hence the name). + * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: + * The library implements a bytecode interpreter that covers the full + * instruction set of the TrueType virtual machine (this was governed + * by patents until May 2010, hence the name). * - * @since: - * 2.2 + * @since: + * 2.2 * */ typedef enum FT_TrueTypeEngineType_ @@ -679,22 +753,22 @@ FT_BEGIN_HEADER /************************************************************************** * - * @func: - * FT_Get_TrueType_Engine_Type + * @function: + * FT_Get_TrueType_Engine_Type * - * @description: - * Return an @FT_TrueTypeEngineType value to indicate which level of - * the TrueType virtual machine a given library instance supports. + * @description: + * Return an @FT_TrueTypeEngineType value to indicate which level of the + * TrueType virtual machine a given library instance supports. * - * @input: - * library :: - * A library instance. + * @input: + * library :: + * A library instance. * - * @return: - * A value indicating which level is supported. + * @return: + * A value indicating which level is supported. * - * @since: - * 2.2 + * @since: + * 2.2 * */ FT_EXPORT( FT_TrueTypeEngineType ) diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h index e0fc1312bd4..e16993572c8 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftmoderr.h @@ -1,94 +1,103 @@ -/***************************************************************************/ -/* */ -/* ftmoderr.h */ -/* */ -/* FreeType module error offsets (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the FreeType module error codes. */ - /* */ - /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */ - /* set, the lower byte of an error value identifies the error code as */ - /* usual. In addition, the higher byte identifies the module. For */ - /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */ - /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */ - /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */ - /* */ - /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */ - /* including the high byte. */ - /* */ - /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */ - /* an error value is set to zero. */ - /* */ - /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ - /* provides some macros in `fttypes.h'. */ - /* */ - /* FT_ERR( err ) */ - /* Add current error module prefix (as defined with the */ - /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ - /* the line */ - /* */ - /* error = FT_ERR( Invalid_Outline ); */ - /* */ - /* expands to */ - /* */ - /* error = BDF_Err_Invalid_Outline; */ - /* */ - /* For simplicity, you can always use `FT_Err_Ok' directly instead */ - /* of `FT_ERR( Ok )'. */ - /* */ - /* FT_ERR_EQ( errcode, err ) */ - /* FT_ERR_NEQ( errcode, err ) */ - /* Compare error code `errcode' with the error `err' for equality */ - /* and inequality, respectively. Example: */ - /* */ - /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ - /* ... */ - /* */ - /* Using this macro you don't have to think about error prefixes. */ - /* Of course, if module errors are not active, the above example is */ - /* the same as */ - /* */ - /* if ( error == FT_Err_Invalid_Outline ) */ - /* ... */ - /* */ - /* FT_ERROR_BASE( errcode ) */ - /* FT_ERROR_MODULE( errcode ) */ - /* Get base error and module error code, respectively. */ - /* */ - /* */ - /* It can also be used to create a module error message table easily */ - /* with something like */ - /* */ - /* { */ - /* #undef FTMODERR_H_ */ - /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ - /* #define FT_MODERR_START_LIST { */ - /* #define FT_MODERR_END_LIST { 0, 0 } }; */ - /* */ - /* const struct */ - /* { */ - /* int mod_err_offset; */ - /* const char* mod_err_msg */ - /* } ft_mod_errors[] = */ - /* */ - /* #include FT_MODULE_ERRORS_H */ - /* } */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftmoderr.h + * + * FreeType module error offsets (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the FreeType module error codes. + * + * If the macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` in `ftoption.h` is + * set, the lower byte of an error value identifies the error code as + * usual. In addition, the higher byte identifies the module. For + * example, the error `FT_Err_Invalid_File_Format` has value 0x0003, the + * error `TT_Err_Invalid_File_Format` has value 0x1303, the error + * `T1_Err_Invalid_File_Format` has value 0x1403, etc. + * + * Note that `FT_Err_Ok`, `TT_Err_Ok`, etc. are always equal to zero, + * including the high byte. + * + * If `FT_CONFIG_OPTION_USE_MODULE_ERRORS` isn't set, the higher byte of an + * error value is set to zero. + * + * To hide the various `XXX_Err_` prefixes in the source code, FreeType + * provides some macros in `fttypes.h`. + * + * FT_ERR( err ) + * + * Add current error module prefix (as defined with the `FT_ERR_PREFIX` + * macro) to `err`. For example, in the BDF module the line + * + * ``` + * error = FT_ERR( Invalid_Outline ); + * ``` + * + * expands to + * + * ``` + * error = BDF_Err_Invalid_Outline; + * ``` + * + * For simplicity, you can always use `FT_Err_Ok` directly instead of + * `FT_ERR( Ok )`. + * + * FT_ERR_EQ( errcode, err ) + * FT_ERR_NEQ( errcode, err ) + * + * Compare error code `errcode` with the error `err` for equality and + * inequality, respectively. Example: + * + * ``` + * if ( FT_ERR_EQ( error, Invalid_Outline ) ) + * ... + * ``` + * + * Using this macro you don't have to think about error prefixes. Of + * course, if module errors are not active, the above example is the + * same as + * + * ``` + * if ( error == FT_Err_Invalid_Outline ) + * ... + * ``` + * + * FT_ERROR_BASE( errcode ) + * FT_ERROR_MODULE( errcode ) + * + * Get base error and module error code, respectively. + * + * It can also be used to create a module error message table easily with + * something like + * + * ``` + * #undef FTMODERR_H_ + * #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, + * #define FT_MODERR_START_LIST { + * #define FT_MODERR_END_LIST { 0, 0 } }; + * + * const struct + * { + * int mod_err_offset; + * const char* mod_err_msg + * } ft_mod_errors[] = + * + * #include FT_MODULE_ERRORS_H + * ``` + * + */ #ifndef FTMODERR_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h index 89389a49b7c..75c3d015968 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftoutln.h */ -/* */ -/* Support for the FT_Outline type used to store glyph shapes of */ -/* most scalable font formats (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftoutln.h + * + * Support for the FT_Outline type used to store glyph shapes of + * most scalable font formats (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTOUTLN_H_ @@ -34,127 +34,131 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /* <Title> */ - /* Outline Processing */ - /* */ - /* <Abstract> */ - /* Functions to create, transform, and render vectorial glyph images. */ - /* */ - /* <Description> */ - /* This section contains routines used to create and destroy scalable */ - /* glyph images known as `outlines'. These can also be measured, */ - /* transformed, and converted into bitmaps and pixmaps. */ - /* */ - /* <Order> */ - /* FT_Outline */ - /* FT_Outline_New */ - /* FT_Outline_Done */ - /* FT_Outline_Copy */ - /* FT_Outline_Translate */ - /* FT_Outline_Transform */ - /* FT_Outline_Embolden */ - /* FT_Outline_EmboldenXY */ - /* FT_Outline_Reverse */ - /* FT_Outline_Check */ - /* */ - /* FT_Outline_Get_CBox */ - /* FT_Outline_Get_BBox */ - /* */ - /* FT_Outline_Get_Bitmap */ - /* FT_Outline_Render */ - /* FT_Outline_Decompose */ - /* FT_Outline_Funcs */ - /* FT_Outline_MoveToFunc */ - /* FT_Outline_LineToFunc */ - /* FT_Outline_ConicToFunc */ - /* FT_Outline_CubicToFunc */ - /* */ - /* FT_Orientation */ - /* FT_Outline_Get_Orientation */ - /* */ - /* FT_OUTLINE_XXX */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Decompose */ - /* */ - /* <Description> */ - /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bezier arcs. This function also emits `move to' */ - /* operations to indicate the start of new contours in the outline. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source target. */ - /* */ - /* func_interface :: A table of `emitters', i.e., function pointers */ - /* called during decomposition to indicate path */ - /* operations. */ - /* */ - /* <InOut> */ - /* user :: A typeless pointer that is passed to each */ - /* emitter during the decomposition. It can be */ - /* used to store the state during the */ - /* decomposition. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* A contour that contains a single point only is represented by a */ - /* `move to' operation followed by `line to' to the same point. In */ - /* most cases, it is best to filter this out before using the */ - /* outline for stroking purposes (otherwise it would result in a */ - /* visible dot when round caps are used). */ - /* */ - /* Similarly, the function returns success for an empty outline also */ - /* (doing nothing, this is, not calling any emitter); if necessary, */ - /* you should filter this out, too. */ - /* */ + /************************************************************************** + * + * @section: + * outline_processing + * + * @title: + * Outline Processing + * + * @abstract: + * Functions to create, transform, and render vectorial glyph images. + * + * @description: + * This section contains routines used to create and destroy scalable + * glyph images known as 'outlines'. These can also be measured, + * transformed, and converted into bitmaps and pixmaps. + * + * @order: + * FT_Outline + * FT_Outline_New + * FT_Outline_Done + * FT_Outline_Copy + * FT_Outline_Translate + * FT_Outline_Transform + * FT_Outline_Embolden + * FT_Outline_EmboldenXY + * FT_Outline_Reverse + * FT_Outline_Check + * + * FT_Outline_Get_CBox + * FT_Outline_Get_BBox + * + * FT_Outline_Get_Bitmap + * FT_Outline_Render + * FT_Outline_Decompose + * FT_Outline_Funcs + * FT_Outline_MoveToFunc + * FT_Outline_LineToFunc + * FT_Outline_ConicToFunc + * FT_Outline_CubicToFunc + * + * FT_Orientation + * FT_Outline_Get_Orientation + * + * FT_OUTLINE_XXX + * + */ + + + /************************************************************************** + * + * @function: + * FT_Outline_Decompose + * + * @description: + * Walk over an outline's structure to decompose it into individual + * segments and Bezier arcs. This function also emits 'move to' + * operations to indicate the start of new contours in the outline. + * + * @input: + * outline :: + * A pointer to the source target. + * + * func_interface :: + * A table of 'emitters', i.e., function pointers called during + * decomposition to indicate path operations. + * + * @inout: + * user :: + * A typeless pointer that is passed to each emitter during the + * decomposition. It can be used to store the state during the + * decomposition. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * A contour that contains a single point only is represented by a 'move + * to' operation followed by 'line to' to the same point. In most cases, + * it is best to filter this out before using the outline for stroking + * purposes (otherwise it would result in a visible dot when round caps + * are used). + * + * Similarly, the function returns success for an empty outline also + * (doing nothing, this is, not calling any emitter); if necessary, you + * should filter this out, too. + */ FT_EXPORT( FT_Error ) FT_Outline_Decompose( FT_Outline* outline, const FT_Outline_Funcs* func_interface, void* user ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_New */ - /* */ - /* <Description> */ - /* Create a new outline of a given size. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object from where the */ - /* outline is allocated. Note however that the new */ - /* outline will *not* necessarily be *freed*, when */ - /* destroying the library, by @FT_Done_FreeType. */ - /* */ - /* numPoints :: The maximum number of points within the outline. */ - /* Must be smaller than or equal to 0xFFFF (65535). */ - /* */ - /* numContours :: The maximum number of contours within the outline. */ - /* This value must be in the range 0 to `numPoints'. */ - /* */ - /* <Output> */ - /* anoutline :: A handle to the new outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' parameter is simply */ - /* to use the library's memory allocator. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_New + * + * @description: + * Create a new outline of a given size. + * + * @input: + * library :: + * A handle to the library object from where the outline is allocated. + * Note however that the new outline will **not** necessarily be + * **freed**, when destroying the library, by @FT_Done_FreeType. + * + * numPoints :: + * The maximum number of points within the outline. Must be smaller + * than or equal to 0xFFFF (65535). + * + * numContours :: + * The maximum number of contours within the outline. This value must + * be in the range 0 to `numPoints`. + * + * @output: + * anoutline :: + * A handle to the new outline. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The reason why this function takes a `library` parameter is simply to + * use the library's memory allocator. + */ FT_EXPORT( FT_Error ) FT_Outline_New( FT_Library library, FT_UInt numPoints, @@ -162,372 +166,378 @@ FT_BEGIN_HEADER FT_Outline *anoutline ); - FT_EXPORT( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Done */ - /* */ - /* <Description> */ - /* Destroy an outline created with @FT_Outline_New. */ - /* */ - /* <Input> */ - /* library :: A handle of the library object used to allocate the */ - /* outline. */ - /* */ - /* outline :: A pointer to the outline object to be discarded. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the outline's `owner' field is not set, only the outline */ - /* descriptor will be released. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Done + * + * @description: + * Destroy an outline created with @FT_Outline_New. + * + * @input: + * library :: + * A handle of the library object used to allocate the outline. + * + * outline :: + * A pointer to the outline object to be discarded. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the outline's 'owner' field is not set, only the outline descriptor + * will be released. + */ FT_EXPORT( FT_Error ) FT_Outline_Done( FT_Library library, FT_Outline* outline ); - FT_EXPORT( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Check */ - /* */ - /* <Description> */ - /* Check the contents of an outline descriptor. */ - /* */ - /* <Input> */ - /* outline :: A handle to a source outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An empty outline, or an outline with a single point only is also */ - /* valid. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Check + * + * @description: + * Check the contents of an outline descriptor. + * + * @input: + * outline :: + * A handle to a source outline. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An empty outline, or an outline with a single point only is also + * valid. + */ FT_EXPORT( FT_Error ) FT_Outline_Check( FT_Outline* outline ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_CBox */ - /* */ - /* <Description> */ - /* Return an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bezier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bezier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <Output> */ - /* acbox :: The outline's control box. */ - /* */ - /* <Note> */ - /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Get_CBox + * + * @description: + * Return an outline's 'control box'. The control box encloses all the + * outline's points, including Bezier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline that + * contains Bezier outside arcs). + * + * Computing the control box is very fast, while getting the bounding box + * can take much more time as it needs to walk over all segments and arcs + * in the outline. To get the latter, you can use the 'ftbbox' + * component, which is dedicated to this single task. + * + * @input: + * outline :: + * A pointer to the source outline descriptor. + * + * @output: + * acbox :: + * The outline's control box. + * + * @note: + * See @FT_Glyph_Get_CBox for a discussion of tricky fonts. + */ FT_EXPORT( void ) FT_Outline_Get_CBox( const FT_Outline* outline, FT_BBox *acbox ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Translate */ - /* */ - /* <Description> */ - /* Apply a simple translation to the points of an outline. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* xOffset :: The horizontal offset. */ - /* */ - /* yOffset :: The vertical offset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Translate + * + * @description: + * Apply a simple translation to the points of an outline. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @input: + * xOffset :: + * The horizontal offset. + * + * yOffset :: + * The vertical offset. + */ FT_EXPORT( void ) FT_Outline_Translate( const FT_Outline* outline, FT_Pos xOffset, FT_Pos yOffset ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Copy */ - /* */ - /* <Description> */ - /* Copy an outline into another one. Both objects must have the */ - /* same sizes (number of points & number of contours) when this */ - /* function is called. */ - /* */ - /* <Input> */ - /* source :: A handle to the source outline. */ - /* */ - /* <Output> */ - /* target :: A handle to the target outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Copy + * + * @description: + * Copy an outline into another one. Both objects must have the same + * sizes (number of points & number of contours) when this function is + * called. + * + * @input: + * source :: + * A handle to the source outline. + * + * @output: + * target :: + * A handle to the target outline. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Outline_Copy( const FT_Outline* source, FT_Outline *target ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Transform */ - /* */ - /* <Description> */ - /* Apply a simple 2x2 matrix to all of an outline's points. Useful */ - /* for applying rotations, slanting, flipping, etc. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation matrix. */ - /* */ - /* <Note> */ - /* You can use @FT_Outline_Translate if you need to translate the */ - /* outline's points. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Transform + * + * @description: + * Apply a simple 2x2 matrix to all of an outline's points. Useful for + * applying rotations, slanting, flipping, etc. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @input: + * matrix :: + * A pointer to the transformation matrix. + * + * @note: + * You can use @FT_Outline_Translate if you need to translate the + * outline's points. + */ FT_EXPORT( void ) FT_Outline_Transform( const FT_Outline* outline, const FT_Matrix* matrix ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Embolden */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be at most 4~times */ - /* `strength' pixels wider and higher. You may think of the left and */ - /* bottom borders as unchanged. */ - /* */ - /* Negative `strength' values to reduce the outline thickness are */ - /* possible also. */ - /* */ - /* <InOut> */ - /* outline :: A handle to the target outline. */ - /* */ - /* <Input> */ - /* strength :: How strong the glyph is emboldened. Expressed in */ - /* 26.6 pixel format. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The used algorithm to increase or decrease the thickness of the */ - /* glyph doesn't change the number of points; this means that certain */ - /* situations like acute angles or intersections are sometimes */ - /* handled incorrectly. */ - /* */ - /* If you need `better' metrics values you should call */ - /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */ - /* */ - /* Example call: */ - /* */ - /* { */ - /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ - /* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */ - /* FT_Outline_Embolden( &face->glyph->outline, strength ); */ - /* } */ - /* */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Embolden + * + * @description: + * Embolden an outline. The new outline will be at most 4~times + * `strength` pixels wider and higher. You may think of the left and + * bottom borders as unchanged. + * + * Negative `strength` values to reduce the outline thickness are + * possible also. + * + * @inout: + * outline :: + * A handle to the target outline. + * + * @input: + * strength :: + * How strong the glyph is emboldened. Expressed in 26.6 pixel format. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The used algorithm to increase or decrease the thickness of the glyph + * doesn't change the number of points; this means that certain + * situations like acute angles or intersections are sometimes handled + * incorrectly. + * + * If you need 'better' metrics values you should call + * @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. + * + * To get meaningful results, font scaling values must be set with + * functions like @FT_Set_Char_Size before calling FT_Render_Glyph. + * + * @example: + * ``` + * FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); + * + * if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) + * FT_Outline_Embolden( &face->glyph->outline, strength ); + * ``` + * + */ FT_EXPORT( FT_Error ) FT_Outline_Embolden( FT_Outline* outline, FT_Pos strength ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_EmboldenXY */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be `xstrength' pixels */ - /* wider and `ystrength' pixels higher. Otherwise, it is similar to */ - /* @FT_Outline_Embolden, which uses the same strength in both */ - /* directions. */ - /* */ - /* <Since> */ - /* 2.4.10 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_EmboldenXY + * + * @description: + * Embolden an outline. The new outline will be `xstrength` pixels wider + * and `ystrength` pixels higher. Otherwise, it is similar to + * @FT_Outline_Embolden, which uses the same strength in both directions. + * + * @since: + * 2.4.10 + */ FT_EXPORT( FT_Error ) FT_Outline_EmboldenXY( FT_Outline* outline, FT_Pos xstrength, FT_Pos ystrength ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Reverse */ - /* */ - /* <Description> */ - /* Reverse the drawing direction of an outline. This is used to */ - /* ensure consistent fill conventions for mirrored glyphs. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Note> */ - /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ - /* the outline's `flags' field. */ - /* */ - /* It shouldn't be used by a normal client application, unless it */ - /* knows what it is doing. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Reverse + * + * @description: + * Reverse the drawing direction of an outline. This is used to ensure + * consistent fill conventions for mirrored glyphs. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @note: + * This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the + * outline's `flags` field. + * + * It shouldn't be used by a normal client application, unless it knows + * what it is doing. + */ FT_EXPORT( void ) FT_Outline_Reverse( FT_Outline* outline ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_Bitmap */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap. The outline's image is simply */ - /* OR-ed to the target bitmap. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the target bitmap descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does NOT CREATE the bitmap, it only renders an */ - /* outline image within the one you pass to it! Consequently, the */ - /* various fields in `abitmap' should be set accordingly. */ - /* */ - /* It will use the raster corresponding to the default glyph format. */ - /* */ - /* The value of the `num_grays' field in `abitmap' is ignored. If */ - /* you select the gray-level rasterizer, and you want less than 256 */ - /* gray levels, you have to use @FT_Outline_Render directly. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Get_Bitmap + * + * @description: + * Render an outline within a bitmap. The outline's image is simply + * OR-ed to the target bitmap. + * + * @input: + * library :: + * A handle to a FreeType library object. + * + * outline :: + * A pointer to the source outline descriptor. + * + * @inout: + * abitmap :: + * A pointer to the target bitmap descriptor. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does **not create** the bitmap, it only renders an + * outline image within the one you pass to it! Consequently, the + * various fields in `abitmap` should be set accordingly. + * + * It will use the raster corresponding to the default glyph format. + * + * The value of the `num_grays` field in `abitmap` is ignored. If you + * select the gray-level rasterizer, and you want less than 256 gray + * levels, you have to use @FT_Outline_Render directly. + */ FT_EXPORT( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library, FT_Outline* outline, const FT_Bitmap *abitmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Render */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap using the current scan-convert. */ - /* This function uses an @FT_Raster_Params structure as an argument, */ - /* allowing advanced features like direct composition, translucency, */ - /* etc. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* describe the rendering operation. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should know what you are doing and how @FT_Raster_Params works */ - /* to use this function. */ - /* */ - /* The field `params.source' will be set to `outline' before the scan */ - /* converter is called, which means that the value you give to it is */ - /* actually ignored. */ - /* */ - /* The gray-level rasterizer always uses 256 gray levels. If you */ - /* want less gray levels, you have to provide your own span callback. */ - /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ - /* @FT_Raster_Params structure for more details. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Render + * + * @description: + * Render an outline within a bitmap using the current scan-convert. + * This function uses an @FT_Raster_Params structure as an argument, + * allowing advanced features like direct composition, translucency, etc. + * + * @input: + * library :: + * A handle to a FreeType library object. + * + * outline :: + * A pointer to the source outline descriptor. + * + * @inout: + * params :: + * A pointer to an @FT_Raster_Params structure used to describe the + * rendering operation. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should know what you are doing and how @FT_Raster_Params works to + * use this function. + * + * The field `params.source` will be set to `outline` before the scan + * converter is called, which means that the value you give to it is + * actually ignored. + * + * The gray-level rasterizer always uses 256 gray levels. If you want + * less gray levels, you have to provide your own span callback. See the + * @FT_RASTER_FLAG_DIRECT value of the `flags` field in the + * @FT_Raster_Params structure for more details. + */ FT_EXPORT( FT_Error ) FT_Outline_Render( FT_Library library, FT_Outline* outline, FT_Raster_Params* params ); - /************************************************************************** - * - * @enum: - * FT_Orientation - * - * @description: - * A list of values used to describe an outline's contour orientation. - * - * The TrueType and PostScript specifications use different conventions - * to determine whether outline contours should be filled or unfilled. - * - * @values: - * FT_ORIENTATION_TRUETYPE :: - * According to the TrueType specification, clockwise contours must - * be filled, and counter-clockwise ones must be unfilled. - * - * FT_ORIENTATION_POSTSCRIPT :: - * According to the PostScript specification, counter-clockwise contours - * must be filled, and clockwise ones must be unfilled. - * - * FT_ORIENTATION_FILL_RIGHT :: - * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to - * remember that in TrueType, everything that is to the right of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_FILL_LEFT :: - * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to - * remember that in PostScript, everything that is to the left of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_NONE :: - * The orientation cannot be determined. That is, different parts of - * the glyph have different orientation. - * - */ + /************************************************************************** + * + * @enum: + * FT_Orientation + * + * @description: + * A list of values used to describe an outline's contour orientation. + * + * The TrueType and PostScript specifications use different conventions + * to determine whether outline contours should be filled or unfilled. + * + * @values: + * FT_ORIENTATION_TRUETYPE :: + * According to the TrueType specification, clockwise contours must be + * filled, and counter-clockwise ones must be unfilled. + * + * FT_ORIENTATION_POSTSCRIPT :: + * According to the PostScript specification, counter-clockwise + * contours must be filled, and clockwise ones must be unfilled. + * + * FT_ORIENTATION_FILL_RIGHT :: + * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to + * remember that in TrueType, everything that is to the right of the + * drawing direction of a contour must be filled. + * + * FT_ORIENTATION_FILL_LEFT :: + * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to + * remember that in PostScript, everything that is to the left of the + * drawing direction of a contour must be filled. + * + * FT_ORIENTATION_NONE :: + * The orientation cannot be determined. That is, different parts of + * the glyph have different orientation. + * + */ typedef enum FT_Orientation_ { FT_ORIENTATION_TRUETYPE = 0, @@ -539,33 +549,34 @@ FT_BEGIN_HEADER } FT_Orientation; - /************************************************************************** - * - * @function: - * FT_Outline_Get_Orientation - * - * @description: - * This function analyzes a glyph outline and tries to compute its - * fill orientation (see @FT_Orientation). This is done by integrating - * the total area covered by the outline. The positive integral - * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT - * is returned. The negative integral corresponds to the counter-clockwise - * orientation and @FT_ORIENTATION_TRUETYPE is returned. - * - * Note that this will return @FT_ORIENTATION_TRUETYPE for empty - * outlines. - * - * @input: - * outline :: - * A handle to the source outline. - * - * @return: - * The orientation. - * - */ + /************************************************************************** + * + * @function: + * FT_Outline_Get_Orientation + * + * @description: + * This function analyzes a glyph outline and tries to compute its fill + * orientation (see @FT_Orientation). This is done by integrating the + * total area covered by the outline. The positive integral corresponds + * to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is + * returned. The negative integral corresponds to the counter-clockwise + * orientation and @FT_ORIENTATION_TRUETYPE is returned. + * + * Note that this will return @FT_ORIENTATION_TRUETYPE for empty + * outlines. + * + * @input: + * outline :: + * A handle to the source outline. + * + * @return: + * The orientation. + * + */ FT_EXPORT( FT_Orientation ) FT_Outline_Get_Orientation( FT_Outline* outline ); + /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h index 5a9006c505d..c374ee2f2ff 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftparams.h */ -/* */ -/* FreeType API for possible FT_Parameter tags (specification only). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftparams.h + * + * FreeType API for possible FT_Parameter tags (specification only). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTPARAMS_H_ @@ -51,16 +51,16 @@ FT_BEGIN_HEADER */ - /*************************************************************************** + /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY * * @description: * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic - * family names in the `name' table (introduced in OpenType version - * 1.4). Use this for backward compatibility with legacy systems that - * have a four-faces-per-family restriction. + * family names in the 'name' table (introduced in OpenType version 1.4). + * Use this for backward compatibility with legacy systems that have a + * four-faces-per-family restriction. * * @since: * 2.8 @@ -75,14 +75,14 @@ FT_BEGIN_HEADER FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY - /*************************************************************************** + /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY * * @description: * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic - * subfamily names in the `name' table (introduced in OpenType version + * subfamily names in the 'name' table (introduced in OpenType version * 1.4). Use this for backward compatibility with legacy systems that * have a four-faces-per-family restriction. * @@ -99,9 +99,9 @@ FT_BEGIN_HEADER FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY - /*************************************************************************** + /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_INCREMENTAL * * @description: @@ -115,14 +115,14 @@ FT_BEGIN_HEADER /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_LCD_FILTER_WEIGHTS * * @description: * An @FT_Parameter tag to be used with @FT_Face_Properties. The * corresponding argument specifies the five LCD filter weights for a - * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding - * the global default values or the values set up with + * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding the + * global default values or the values set up with * @FT_Library_SetLcdFilterWeights. * * @since: @@ -135,14 +135,13 @@ FT_BEGIN_HEADER /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_RANDOM_SEED * * @description: * An @FT_Parameter tag to be used with @FT_Face_Properties. The * corresponding 32bit signed integer argument overrides the font - * driver's random seed value with a face-specific one; see - * @random-seed. + * driver's random seed value with a face-specific one; see @random-seed. * * @since: * 2.8 @@ -154,7 +153,7 @@ FT_BEGIN_HEADER /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_STEM_DARKENING * * @description: @@ -163,10 +162,10 @@ FT_BEGIN_HEADER * darkening, overriding the global default values or the values set up * with @FT_Property_Set (see @no-stem-darkening). * - * This is a passive setting that only takes effect if the font driver - * or autohinter honors it, which the CFF, Type~1, and CID drivers - * always do, but the autohinter only in `light' hinting mode (as of - * version 2.9). + * This is a passive setting that only takes effect if the font driver or + * autohinter honors it, which the CFF, Type~1, and CID drivers always + * do, but the autohinter only in 'light' hinting mode (as of version + * 2.9). * * @since: * 2.8 @@ -176,19 +175,19 @@ FT_BEGIN_HEADER FT_MAKE_TAG( 'd', 'a', 'r', 'k' ) - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_UNPATENTED_HINTING - * - * @description: - * Deprecated, no effect. - * - * Previously: A constant used as the tag of an @FT_Parameter structure to - * indicate that unpatented methods only should be used by the TrueType - * bytecode interpreter for a typeface opened by @FT_Open_Face. - * - */ + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_UNPATENTED_HINTING + * + * @description: + * Deprecated, no effect. + * + * Previously: A constant used as the tag of an @FT_Parameter structure + * to indicate that unpatented methods only should be used by the + * TrueType bytecode interpreter for a typeface opened by @FT_Open_Face. + * + */ #define FT_PARAM_TAG_UNPATENTED_HINTING \ FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h index fa8ad22b987..a01c774272e 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftrender.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftrender.h */ -/* */ -/* FreeType renderer modules public interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrender.h + * + * FreeType renderer modules public interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTRENDER_H_ @@ -28,12 +28,12 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * module_management + * + */ /* create a new glyph object */ @@ -116,32 +116,38 @@ FT_BEGIN_HEADER #define FTRenderer_setMode FT_Renderer_SetModeFunc - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Renderer_Class */ - /* */ - /* <Description> */ - /* The renderer module class descriptor. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Module_Class fields. */ - /* */ - /* glyph_format :: The glyph image format this renderer handles. */ - /* */ - /* render_glyph :: A method used to render the image that is in a */ - /* given glyph slot into a bitmap. */ - /* */ - /* transform_glyph :: A method used to transform the image that is in */ - /* a given glyph slot. */ - /* */ - /* get_glyph_cbox :: A method used to access the glyph's cbox. */ - /* */ - /* set_mode :: A method used to pass additional parameters. */ - /* */ - /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ - /* This is a pointer to its raster's class. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Renderer_Class + * + * @description: + * The renderer module class descriptor. + * + * @fields: + * root :: + * The root @FT_Module_Class fields. + * + * glyph_format :: + * The glyph image format this renderer handles. + * + * render_glyph :: + * A method used to render the image that is in a given glyph slot into + * a bitmap. + * + * transform_glyph :: + * A method used to transform the image that is in a given glyph slot. + * + * get_glyph_cbox :: + * A method used to access the glyph's cbox. + * + * set_mode :: + * A method used to pass additional parameters. + * + * raster_class :: + * For @FT_GLYPH_FORMAT_OUTLINE renderers only. This is a pointer to + * its raster's class. + */ typedef struct FT_Renderer_Class_ { FT_Module_Class root; @@ -158,64 +164,70 @@ FT_BEGIN_HEADER } FT_Renderer_Class; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Renderer */ - /* */ - /* <Description> */ - /* Retrieve the current renderer for a given glyph format. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* format :: The glyph format. */ - /* */ - /* <Return> */ - /* A renderer handle. 0~if none found. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ - /* renderer by its name, use @FT_Get_Module. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Renderer + * + * @description: + * Retrieve the current renderer for a given glyph format. + * + * @input: + * library :: + * A handle to the library object. + * + * format :: + * The glyph format. + * + * @return: + * A renderer handle. 0~if none found. + * + * @note: + * An error will be returned if a module already exists by that name, or + * if the module requires a version of FreeType that is too great. + * + * To add a new renderer, simply use @FT_Add_Module. To retrieve a + * renderer by its name, use @FT_Get_Module. + */ FT_EXPORT( FT_Renderer ) FT_Get_Renderer( FT_Library library, FT_Glyph_Format format ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Renderer */ - /* */ - /* <Description> */ - /* Set the current renderer to use, and set additional mode. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* renderer :: A handle to the renderer object. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* parameters :: Additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case of success, the renderer will be used to convert glyph */ - /* images in the renderer's known format into bitmaps. */ - /* */ - /* This doesn't change the current renderer for other formats. */ - /* */ - /* Currently, no FreeType renderer module uses `parameters'; you */ - /* should thus always pass NULL as the value. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Renderer + * + * @description: + * Set the current renderer to use, and set additional mode. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * renderer :: + * A handle to the renderer object. + * + * num_params :: + * The number of additional parameters. + * + * parameters :: + * Additional parameters. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * In case of success, the renderer will be used to convert glyph images + * in the renderer's known format into bitmaps. + * + * This doesn't change the current renderer for other formats. + * + * Currently, no FreeType renderer module uses `parameters`; you should + * thus always pass `NULL` as the value. + */ FT_EXPORT( FT_Error ) FT_Set_Renderer( FT_Library library, FT_Renderer renderer, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h index 72cb08bf2a7..6c63cef2bfa 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsizes.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftsizes.h */ -/* */ -/* FreeType size objects management (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Typical application would normally not need to use these functions. */ - /* However, they have been placed in a public API for the rare cases */ - /* where they are needed. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftsizes.h + * + * FreeType size objects management (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * Typical application would normally not need to use these functions. + * However, they have been placed in a public API for the rare cases where + * they are needed. + * + */ #ifndef FTSIZES_H_ @@ -42,109 +42,110 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* sizes_management */ - /* */ - /* <Title> */ - /* Size Management */ - /* */ - /* <Abstract> */ - /* Managing multiple sizes per face. */ - /* */ - /* <Description> */ - /* When creating a new face object (e.g., with @FT_New_Face), an */ - /* @FT_Size object is automatically created and used to store all */ - /* pixel-size dependent information, available in the `face->size' */ - /* field. */ - /* */ - /* It is however possible to create more sizes for a given face, */ - /* mostly in order to manage several character pixel sizes of the */ - /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ - /* */ - /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ - /* modify the contents of the current `active' size; you thus need */ - /* to use @FT_Activate_Size to change it. */ - /* */ - /* 99% of applications won't need the functions provided here, */ - /* especially if they use the caching sub-system, so be cautious */ - /* when using these. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Size */ - /* */ - /* <Description> */ - /* Create a new size object from a given face object. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* asize :: A handle to a new size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You need to call @FT_Activate_Size in order to select the new size */ - /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ - /* @FT_Load_Glyph, @FT_Load_Char, etc. */ - /* */ + /************************************************************************** + * + * @section: + * sizes_management + * + * @title: + * Size Management + * + * @abstract: + * Managing multiple sizes per face. + * + * @description: + * When creating a new face object (e.g., with @FT_New_Face), an @FT_Size + * object is automatically created and used to store all pixel-size + * dependent information, available in the `face->size` field. + * + * It is however possible to create more sizes for a given face, mostly + * in order to manage several character pixel sizes of the same font + * family and style. See @FT_New_Size and @FT_Done_Size. + * + * Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only modify the + * contents of the current 'active' size; you thus need to use + * @FT_Activate_Size to change it. + * + * 99% of applications won't need the functions provided here, especially + * if they use the caching sub-system, so be cautious when using these. + * + */ + + + /************************************************************************** + * + * @function: + * FT_New_Size + * + * @description: + * Create a new size object from a given face object. + * + * @input: + * face :: + * A handle to a parent face object. + * + * @output: + * asize :: + * A handle to a new size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You need to call @FT_Activate_Size in order to select the new size for + * upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, + * @FT_Load_Glyph, @FT_Load_Char, etc. + */ FT_EXPORT( FT_Error ) FT_New_Size( FT_Face face, FT_Size* size ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Size */ - /* */ - /* <Description> */ - /* Discard a given size object. Note that @FT_Done_Face */ - /* automatically discards all size objects allocated with */ - /* @FT_New_Size. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Size + * + * @description: + * Discard a given size object. Note that @FT_Done_Face automatically + * discards all size objects allocated with @FT_New_Size. + * + * @input: + * size :: + * A handle to a target size object. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Done_Size( FT_Size size ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Activate_Size */ - /* */ - /* <Description> */ - /* Even though it is possible to create several size objects for a */ - /* given face (see @FT_New_Size for details), functions like */ - /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ - /* activated last to determine the `current character pixel size'. */ - /* */ - /* This function can be used to `activate' a previously created size */ - /* object. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If `face' is the size's parent face object, this function changes */ - /* the value of `face->size' to the input size handle. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Activate_Size + * + * @description: + * Even though it is possible to create several size objects for a given + * face (see @FT_New_Size for details), functions like @FT_Load_Glyph or + * @FT_Load_Char only use the one that has been activated last to + * determine the 'current character pixel size'. + * + * This function can be used to 'activate' a previously created size + * object. + * + * @input: + * size :: + * A handle to a target size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `face` is the size's parent face object, this function changes the + * value of `face->size` to the input size handle. + */ FT_EXPORT( FT_Error ) FT_Activate_Size( FT_Size size ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h index 8eb8d70ff7f..4d43602a424 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsnames.h @@ -1,22 +1,22 @@ -/***************************************************************************/ -/* */ -/* ftsnames.h */ -/* */ -/* Simple interface to access SFNT `name' tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (specification). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsnames.h + * + * Simple interface to access SFNT 'name' tables (which are used + * to hold font names, copyright info, notices, etc.) (specification). + * + * This is _not_ used to retrieve glyph names! + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSNAMES_H_ @@ -37,72 +37,74 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* sfnt_names */ - /* */ - /* <Title> */ - /* SFNT Names */ - /* */ - /* <Abstract> */ - /* Access the names embedded in TrueType and OpenType files. */ - /* */ - /* <Description> */ - /* The TrueType and OpenType specifications allow the inclusion of */ - /* a special names table (`name') in font files. This table contains */ - /* textual (and internationalized) information regarding the font, */ - /* like family name, copyright, version, etc. */ - /* */ - /* The definitions below are used to access them if available. */ - /* */ - /* Note that this has nothing to do with glyph names! */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SfntName */ - /* */ - /* <Description> */ - /* A structure used to model an SFNT `name' table entry. */ - /* */ - /* <Fields> */ - /* platform_id :: The platform ID for `string'. */ - /* See @TT_PLATFORM_XXX for possible values. */ - /* */ - /* encoding_id :: The encoding ID for `string'. */ - /* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ - /* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */ - /* for possible values. */ - /* */ - /* language_id :: The language ID for `string'. */ - /* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */ - /* possible values. */ - /* */ - /* Registered OpenType values for `language_id' are */ - /* always smaller than 0x8000; values equal or larger */ - /* than 0x8000 usually indicate a language tag string */ - /* (introduced in OpenType version 1.6). Use function */ - /* @FT_Get_Sfnt_LangTag with `language_id' as its */ - /* argument to retrieve the associated language tag. */ - /* */ - /* name_id :: An identifier for `string'. */ - /* See @TT_NAME_ID_XXX for possible values. */ - /* */ - /* string :: The `name' string. Note that its format differs */ - /* depending on the (platform,encoding) pair, being */ - /* either a string of bytes (without a terminating */ - /* NULL byte) or containing UTF-16BE entities. */ - /* */ - /* string_len :: The length of `string' in bytes. */ - /* */ - /* <Note> */ - /* Please refer to the TrueType or OpenType specification for more */ - /* details. */ - /* */ + /************************************************************************** + * + * @section: + * sfnt_names + * + * @title: + * SFNT Names + * + * @abstract: + * Access the names embedded in TrueType and OpenType files. + * + * @description: + * The TrueType and OpenType specifications allow the inclusion of a + * special names table ('name') in font files. This table contains + * textual (and internationalized) information regarding the font, like + * family name, copyright, version, etc. + * + * The definitions below are used to access them if available. + * + * Note that this has nothing to do with glyph names! + * + */ + + + /************************************************************************** + * + * @struct: + * FT_SfntName + * + * @description: + * A structure used to model an SFNT 'name' table entry. + * + * @fields: + * platform_id :: + * The platform ID for `string`. See @TT_PLATFORM_XXX for possible + * values. + * + * encoding_id :: + * The encoding ID for `string`. See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, + * @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX for possible + * values. + * + * language_id :: + * The language ID for `string`. See @TT_MAC_LANGID_XXX and + * @TT_MS_LANGID_XXX for possible values. + * + * Registered OpenType values for `language_id` are always smaller than + * 0x8000; values equal or larger than 0x8000 usually indicate a + * language tag string (introduced in OpenType version 1.6). Use + * function @FT_Get_Sfnt_LangTag with `language_id` as its argument to + * retrieve the associated language tag. + * + * name_id :: + * An identifier for `string`. See @TT_NAME_ID_XXX for possible + * values. + * + * string :: + * The 'name' string. Note that its format differs depending on the + * (platform,encoding) pair, being either a string of bytes (without a + * terminating `NULL` byte) or containing UTF-16BE entities. + * + * string_len :: + * The length of `string` in bytes. + * + * @note: + * Please refer to the TrueType or OpenType specification for more + * details. + */ typedef struct FT_SfntName_ { FT_UShort platform_id; @@ -116,83 +118,95 @@ FT_BEGIN_HEADER } FT_SfntName; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name_Count */ - /* */ - /* <Description> */ - /* Retrieve the number of name strings in the SFNT `name' table. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Return> */ - /* The number of strings in the `name' table. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Name_Count + * + * @description: + * Retrieve the number of name strings in the SFNT 'name' table. + * + * @input: + * face :: + * A handle to the source face. + * + * @return: + * The number of strings in the 'name' table. + * + * @note: + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + */ FT_EXPORT( FT_UInt ) FT_Get_Sfnt_Name_Count( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name */ - /* */ - /* <Description> */ - /* Retrieve a string of the SFNT `name' table for a given index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* idx :: The index of the `name' string. */ - /* */ - /* <Output> */ - /* aname :: The indexed @FT_SfntName structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `string' array returned in the `aname' structure is not */ - /* null-terminated. Note that you don't have to deallocate `string' */ - /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ - /* */ - /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ - /* `name' table entries, then do a loop until you get the right */ - /* platform, encoding, and name ID. */ - /* */ - /* `name' table format~1 entries can use language tags also, see */ - /* @FT_Get_Sfnt_LangTag. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Name + * + * @description: + * Retrieve a string of the SFNT 'name' table for a given index. + * + * @input: + * face :: + * A handle to the source face. + * + * idx :: + * The index of the 'name' string. + * + * @output: + * aname :: + * The indexed @FT_SfntName structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `string` array returned in the `aname` structure is not + * null-terminated. Note that you don't have to deallocate `string` by + * yourself; FreeType takes care of it if you call @FT_Done_Face. + * + * Use @FT_Get_Sfnt_Name_Count to get the total number of available + * 'name' table entries, then do a loop until you get the right platform, + * encoding, and name ID. + * + * 'name' table format~1 entries can use language tags also, see + * @FT_Get_Sfnt_LangTag. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + */ FT_EXPORT( FT_Error ) FT_Get_Sfnt_Name( FT_Face face, FT_UInt idx, FT_SfntName *aname ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SfntLangTag */ - /* */ - /* <Description> */ - /* A structure to model a language tag entry from an SFNT `name' */ - /* table. */ - /* */ - /* <Fields> */ - /* string :: The language tag string, encoded in UTF-16BE */ - /* (without trailing NULL bytes). */ - /* */ - /* string_len :: The length of `string' in *bytes*. */ - /* */ - /* <Note> */ - /* Please refer to the TrueType or OpenType specification for more */ - /* details. */ - /* */ - /* <Since> */ - /* 2.8 */ - /* */ + /************************************************************************** + * + * @struct: + * FT_SfntLangTag + * + * @description: + * A structure to model a language tag entry from an SFNT 'name' table. + * + * @fields: + * string :: + * The language tag string, encoded in UTF-16BE (without trailing + * `NULL` bytes). + * + * string_len :: + * The length of `string` in **bytes**. + * + * @note: + * Please refer to the TrueType or OpenType specification for more + * details. + * + * @since: + * 2.8 + */ typedef struct FT_SfntLangTag_ { FT_Byte* string; /* this string is *not* null-terminated! */ @@ -201,41 +215,47 @@ FT_BEGIN_HEADER } FT_SfntLangTag; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_LangTag */ - /* */ - /* <Description> */ - /* Retrieve the language tag associated with a language ID of an SFNT */ - /* `name' table entry. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */ - /* This is always a value larger than 0x8000. */ - /* */ - /* <Output> */ - /* alangTag :: The language tag associated with the `name' table */ - /* entry's language ID. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `string' array returned in the `alangTag' structure is not */ - /* null-terminated. Note that you don't have to deallocate `string' */ - /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ - /* */ - /* Only `name' table format~1 supports language tags. For format~0 */ - /* tables, this function always returns FT_Err_Invalid_Table. For */ - /* invalid format~1 language ID values, FT_Err_Invalid_Argument is */ - /* returned. */ - /* */ - /* <Since> */ - /* 2.8 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_LangTag + * + * @description: + * Retrieve the language tag associated with a language ID of an SFNT + * 'name' table entry. + * + * @input: + * face :: + * A handle to the source face. + * + * langID :: + * The language ID, as returned by @FT_Get_Sfnt_Name. This is always a + * value larger than 0x8000. + * + * @output: + * alangTag :: + * The language tag associated with the 'name' table entry's language + * ID. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `string` array returned in the `alangTag` structure is not + * null-terminated. Note that you don't have to deallocate `string` by + * yourself; FreeType takes care of it if you call @FT_Done_Face. + * + * Only 'name' table format~1 supports language tags. For format~0 + * tables, this function always returns FT_Err_Invalid_Table. For + * invalid format~1 language ID values, FT_Err_Invalid_Argument is + * returned. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + * + * @since: + * 2.8 + */ FT_EXPORT( FT_Error ) FT_Get_Sfnt_LangTag( FT_Face face, FT_UInt langID, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h index 44b6fbe19ff..7265c9e4b6e 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftstroke.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstroke.h */ -/* */ -/* FreeType path stroker (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstroke.h + * + * FreeType path stroker (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSTROKE_H_ @@ -27,116 +27,113 @@ FT_BEGIN_HEADER - /************************************************************************ - * - * @section: - * glyph_stroker - * - * @title: - * Glyph Stroker - * - * @abstract: - * Generating bordered and stroked glyphs. - * - * @description: - * This component generates stroked outlines of a given vectorial - * glyph. It also allows you to retrieve the `outside' and/or the - * `inside' borders of the stroke. - * - * This can be useful to generate `bordered' glyph, i.e., glyphs - * displayed with a coloured (and anti-aliased) border around their - * shape. - * - * @order: - * FT_Stroker - * - * FT_Stroker_LineJoin - * FT_Stroker_LineCap - * FT_StrokerBorder - * - * FT_Outline_GetInsideBorder - * FT_Outline_GetOutsideBorder - * - * FT_Glyph_Stroke - * FT_Glyph_StrokeBorder - * - * FT_Stroker_New - * FT_Stroker_Set - * FT_Stroker_Rewind - * FT_Stroker_ParseOutline - * FT_Stroker_Done - * - * FT_Stroker_BeginSubPath - * FT_Stroker_EndSubPath - * - * FT_Stroker_LineTo - * FT_Stroker_ConicTo - * FT_Stroker_CubicTo - * - * FT_Stroker_GetBorderCounts - * FT_Stroker_ExportBorder - * FT_Stroker_GetCounts - * FT_Stroker_Export - * - */ - - - /************************************************************** - * - * @type: - * FT_Stroker - * - * @description: - * Opaque handle to a path stroker object. - */ + /************************************************************************** + * + * @section: + * glyph_stroker + * + * @title: + * Glyph Stroker + * + * @abstract: + * Generating bordered and stroked glyphs. + * + * @description: + * This component generates stroked outlines of a given vectorial glyph. + * It also allows you to retrieve the 'outside' and/or the 'inside' + * borders of the stroke. + * + * This can be useful to generate 'bordered' glyph, i.e., glyphs + * displayed with a coloured (and anti-aliased) border around their + * shape. + * + * @order: + * FT_Stroker + * + * FT_Stroker_LineJoin + * FT_Stroker_LineCap + * FT_StrokerBorder + * + * FT_Outline_GetInsideBorder + * FT_Outline_GetOutsideBorder + * + * FT_Glyph_Stroke + * FT_Glyph_StrokeBorder + * + * FT_Stroker_New + * FT_Stroker_Set + * FT_Stroker_Rewind + * FT_Stroker_ParseOutline + * FT_Stroker_Done + * + * FT_Stroker_BeginSubPath + * FT_Stroker_EndSubPath + * + * FT_Stroker_LineTo + * FT_Stroker_ConicTo + * FT_Stroker_CubicTo + * + * FT_Stroker_GetBorderCounts + * FT_Stroker_ExportBorder + * FT_Stroker_GetCounts + * FT_Stroker_Export + * + */ + + + /************************************************************************** + * + * @type: + * FT_Stroker + * + * @description: + * Opaque handle to a path stroker object. + */ typedef struct FT_StrokerRec_* FT_Stroker; - /************************************************************** + /************************************************************************** * * @enum: * FT_Stroker_LineJoin * * @description: - * These values determine how two joining lines are rendered - * in a stroker. + * These values determine how two joining lines are rendered in a + * stroker. * * @values: * FT_STROKER_LINEJOIN_ROUND :: - * Used to render rounded line joins. Circular arcs are used - * to join two lines smoothly. + * Used to render rounded line joins. Circular arcs are used to join + * two lines smoothly. * * FT_STROKER_LINEJOIN_BEVEL :: - * Used to render beveled line joins. The outer corner of - * the joined lines is filled by enclosing the triangular - * region of the corner with a straight line between the - * outer corners of each stroke. + * Used to render beveled line joins. The outer corner of the joined + * lines is filled by enclosing the triangular region of the corner + * with a straight line between the outer corners of each stroke. * * FT_STROKER_LINEJOIN_MITER_FIXED :: - * Used to render mitered line joins, with fixed bevels if the - * miter limit is exceeded. The outer edges of the strokes - * for the two segments are extended until they meet at an - * angle. If the segments meet at too sharp an angle (such - * that the miter would extend from the intersection of the - * segments a distance greater than the product of the miter - * limit value and the border radius), then a bevel join (see - * above) is used instead. This prevents long spikes being - * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter - * line join as used in PostScript and PDF. + * Used to render mitered line joins, with fixed bevels if the miter + * limit is exceeded. The outer edges of the strokes for the two + * segments are extended until they meet at an angle. If the segments + * meet at too sharp an angle (such that the miter would extend from + * the intersection of the segments a distance greater than the product + * of the miter limit value and the border radius), then a bevel join + * (see above) is used instead. This prevents long spikes being + * created. `FT_STROKER_LINEJOIN_MITER_FIXED` generates a miter line + * join as used in PostScript and PDF. * * FT_STROKER_LINEJOIN_MITER_VARIABLE :: * FT_STROKER_LINEJOIN_MITER :: - * Used to render mitered line joins, with variable bevels if - * the miter limit is exceeded. The intersection of the - * strokes is clipped at a line perpendicular to the bisector - * of the angle between the strokes, at the distance from the - * intersection of the segments equal to the product of the - * miter limit value and the border radius. This prevents - * long spikes being created. - * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line - * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias - * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for - * backward compatibility. + * Used to render mitered line joins, with variable bevels if the miter + * limit is exceeded. The intersection of the strokes is clipped at a + * line perpendicular to the bisector of the angle between the strokes, + * at the distance from the intersection of the segments equal to the + * product of the miter limit value and the border radius. This + * prevents long spikes being created. + * `FT_STROKER_LINEJOIN_MITER_VARIABLE` generates a mitered line join + * as used in XPS. `FT_STROKER_LINEJOIN_MITER` is an alias for + * `FT_STROKER_LINEJOIN_MITER_VARIABLE`, retained for backward + * compatibility. */ typedef enum FT_Stroker_LineJoin_ { @@ -149,27 +146,25 @@ FT_BEGIN_HEADER } FT_Stroker_LineJoin; - /************************************************************** + /************************************************************************** * * @enum: * FT_Stroker_LineCap * * @description: - * These values determine how the end of opened sub-paths are - * rendered in a stroke. + * These values determine how the end of opened sub-paths are rendered in + * a stroke. * * @values: * FT_STROKER_LINECAP_BUTT :: - * The end of lines is rendered as a full stop on the last - * point itself. + * The end of lines is rendered as a full stop on the last point + * itself. * * FT_STROKER_LINECAP_ROUND :: - * The end of lines is rendered as a half-circle around the - * last point. + * The end of lines is rendered as a half-circle around the last point. * * FT_STROKER_LINECAP_SQUARE :: - * The end of lines is rendered as a square around the - * last point. + * The end of lines is rendered as a square around the last point. */ typedef enum FT_Stroker_LineCap_ { @@ -180,14 +175,14 @@ FT_BEGIN_HEADER } FT_Stroker_LineCap; - /************************************************************** + /************************************************************************** * * @enum: * FT_StrokerBorder * * @description: - * These values are used to select a given stroke border - * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. + * These values are used to select a given stroke border in + * @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. * * @values: * FT_STROKER_BORDER_LEFT :: @@ -197,9 +192,9 @@ FT_BEGIN_HEADER * Select the right border, relative to the drawing direction. * * @note: - * Applications are generally interested in the `inside' and `outside' + * Applications are generally interested in the 'inside' and 'outside' * borders. However, there is no direct mapping between these and the - * `left' and `right' ones, since this really depends on the glyph's + * 'left' and 'right' ones, since this really depends on the glyph's * drawing orientation, which varies between font formats. * * You can however use @FT_Outline_GetInsideBorder and @@ -213,14 +208,14 @@ FT_BEGIN_HEADER } FT_StrokerBorder; - /************************************************************** + /************************************************************************** * * @function: * FT_Outline_GetInsideBorder * * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `inside' borders of a given outline. + * Retrieve the @FT_StrokerBorder value corresponding to the 'inside' + * borders of a given outline. * * @input: * outline :: @@ -234,14 +229,14 @@ FT_BEGIN_HEADER FT_Outline_GetInsideBorder( FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Outline_GetOutsideBorder * * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `outside' borders of a given outline. + * Retrieve the @FT_StrokerBorder value corresponding to the 'outside' + * borders of a given outline. * * @input: * outline :: @@ -255,7 +250,7 @@ FT_BEGIN_HEADER FT_Outline_GetOutsideBorder( FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_New @@ -269,7 +264,7 @@ FT_BEGIN_HEADER * * @output: * astroker :: - * A new stroker object handle. NULL in case of error. + * A new stroker object handle. `NULL` in case of error. * * @return: * FreeType error code. 0~means success. @@ -279,7 +274,7 @@ FT_BEGIN_HEADER FT_Stroker *astroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Set @@ -301,13 +296,12 @@ FT_BEGIN_HEADER * The line join style. * * miter_limit :: - * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and - * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, - * expressed as 16.16 fixed-point value. + * The miter limit for the `FT_STROKER_LINEJOIN_MITER_FIXED` and + * `FT_STROKER_LINEJOIN_MITER_VARIABLE` line join styles, expressed as + * 16.16 fixed-point value. * * @note: - * The radius is expressed in the same units as the outline - * coordinates. + * The radius is expressed in the same units as the outline coordinates. * * This function calls @FT_Stroker_Rewind automatically. */ @@ -319,16 +313,15 @@ FT_BEGIN_HEADER FT_Fixed miter_limit ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Rewind * * @description: - * Reset a stroker object without changing its attributes. - * You should call this function before beginning a new - * series of calls to @FT_Stroker_BeginSubPath or - * @FT_Stroker_EndSubPath. + * Reset a stroker object without changing its attributes. You should + * call this function before beginning a new series of calls to + * @FT_Stroker_BeginSubPath or @FT_Stroker_EndSubPath. * * @input: * stroker :: @@ -338,15 +331,15 @@ FT_BEGIN_HEADER FT_Stroker_Rewind( FT_Stroker stroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_ParseOutline * * @description: - * A convenience function used to parse a whole outline with - * the stroker. The resulting outline(s) can be retrieved - * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export. + * A convenience function used to parse a whole outline with the stroker. + * The resulting outline(s) can be retrieved later by functions like + * @FT_Stroker_GetCounts and @FT_Stroker_Export. * * @input: * stroker :: @@ -356,18 +349,18 @@ FT_BEGIN_HEADER * The source outline. * * opened :: - * A boolean. If~1, the outline is treated as an open path instead - * of a closed one. + * A boolean. If~1, the outline is treated as an open path instead of + * a closed one. * * @return: * FreeType error code. 0~means success. * * @note: - * If `opened' is~0 (the default), the outline is treated as a closed - * path, and the stroker generates two distinct `border' outlines. + * If `opened` is~0 (the default), the outline is treated as a closed + * path, and the stroker generates two distinct 'border' outlines. * - * If `opened' is~1, the outline is processed as an open path, and the - * stroker generates a single `stroke' outline. + * If `opened` is~1, the outline is processed as an open path, and the + * stroker generates a single 'stroke' outline. * * This function calls @FT_Stroker_Rewind automatically. */ @@ -377,7 +370,7 @@ FT_BEGIN_HEADER FT_Bool opened ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_BeginSubPath @@ -399,8 +392,8 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * This function is useful when you need to stroke a path that is - * not stored as an @FT_Outline object. + * This function is useful when you need to stroke a path that is not + * stored as an @FT_Outline object. */ FT_EXPORT( FT_Error ) FT_Stroker_BeginSubPath( FT_Stroker stroker, @@ -408,7 +401,7 @@ FT_BEGIN_HEADER FT_Bool open ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_EndSubPath @@ -424,22 +417,22 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * You should call this function after @FT_Stroker_BeginSubPath. - * If the subpath was not `opened', this function `draws' a - * single line segment to the start position when needed. + * You should call this function after @FT_Stroker_BeginSubPath. If the + * subpath was not 'opened', this function 'draws' a single line segment + * to the start position when needed. */ FT_EXPORT( FT_Error ) FT_Stroker_EndSubPath( FT_Stroker stroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_LineTo * * @description: - * `Draw' a single line segment in the stroker's current sub-path, - * from the last position. + * 'Draw' a single line segment in the stroker's current sub-path, from + * the last position. * * @input: * stroker :: @@ -460,13 +453,13 @@ FT_BEGIN_HEADER FT_Vector* to ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_ConicTo * * @description: - * `Draw' a single quadratic Bezier in the stroker's current sub-path, + * 'Draw' a single quadratic Bezier in the stroker's current sub-path, * from the last position. * * @input: @@ -492,14 +485,14 @@ FT_BEGIN_HEADER FT_Vector* to ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_CubicTo * * @description: - * `Draw' a single cubic Bezier in the stroker's current sub-path, - * from the last position. + * 'Draw' a single cubic Bezier in the stroker's current sub-path, from + * the last position. * * @input: * stroker :: @@ -528,16 +521,16 @@ FT_BEGIN_HEADER FT_Vector* to ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_GetBorderCounts * * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export one of the `border' or `stroke' - * outlines generated by the stroker. + * Call this function once you have finished parsing your paths with the + * stroker. It returns the number of points and contours necessary to + * export one of the 'border' or 'stroke' outlines generated by the + * stroker. * * @input: * stroker :: @@ -557,15 +550,15 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. + * When an outline, or a sub-path, is 'closed', the stroker generates two + * independent 'border' outlines, named 'left' and 'right'. * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. + * When the outline, or a sub-path, is 'opened', the stroker merges the + * 'border' outlines with caps. The 'left' border receives all points, + * while the 'right' border becomes empty. * - * Use the function @FT_Stroker_GetCounts instead if you want to - * retrieve the counts associated to both borders. + * Use the function @FT_Stroker_GetCounts instead if you want to retrieve + * the counts associated to both borders. */ FT_EXPORT( FT_Error ) FT_Stroker_GetBorderCounts( FT_Stroker stroker, @@ -574,19 +567,17 @@ FT_BEGIN_HEADER FT_UInt *anum_contours ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_ExportBorder * * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export the corresponding border to your own @FT_Outline - * structure. + * Call this function after @FT_Stroker_GetBorderCounts to export the + * corresponding border to your own @FT_Outline structure. * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. + * Note that this function appends the border points and contours to your + * outline, but does not try to resize its arrays. * * @input: * stroker :: @@ -599,19 +590,19 @@ FT_BEGIN_HEADER * The target outline handle. * * @note: - * Always call this function after @FT_Stroker_GetBorderCounts to - * get sure that there is enough room in your @FT_Outline object to - * receive all new data. + * Always call this function after @FT_Stroker_GetBorderCounts to get + * sure that there is enough room in your @FT_Outline object to receive + * all new data. * - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. + * When an outline, or a sub-path, is 'closed', the stroker generates two + * independent 'border' outlines, named 'left' and 'right'. * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. + * When the outline, or a sub-path, is 'opened', the stroker merges the + * 'border' outlines with caps. The 'left' border receives all points, + * while the 'right' border becomes empty. * - * Use the function @FT_Stroker_Export instead if you want to - * retrieve all borders at once. + * Use the function @FT_Stroker_Export instead if you want to retrieve + * all borders at once. */ FT_EXPORT( void ) FT_Stroker_ExportBorder( FT_Stroker stroker, @@ -619,16 +610,15 @@ FT_BEGIN_HEADER FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_GetCounts * * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export all points/borders from the stroked - * outline/path. + * Call this function once you have finished parsing your paths with the + * stroker. It returns the number of points and contours necessary to + * export all points/borders from the stroked outline/path. * * @input: * stroker :: @@ -650,18 +640,17 @@ FT_BEGIN_HEADER FT_UInt *anum_contours ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Export * * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export all borders to your own @FT_Outline structure. + * Call this function after @FT_Stroker_GetBorderCounts to export all + * borders to your own @FT_Outline structure. * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. + * Note that this function appends the border points and contours to your + * outline, but does not try to resize its arrays. * * @input: * stroker :: @@ -675,7 +664,7 @@ FT_BEGIN_HEADER FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Done @@ -685,13 +674,13 @@ FT_BEGIN_HEADER * * @input: * stroker :: - * A stroker handle. Can be NULL. + * A stroker handle. Can be `NULL`. */ FT_EXPORT( void ) FT_Stroker_Done( FT_Stroker stroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Glyph_Stroke @@ -708,8 +697,7 @@ FT_BEGIN_HEADER * A stroker handle. * * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. + * A Boolean. If~1, the source glyph object is destroyed on success. * * @return: * FreeType error code. 0~means success. @@ -719,8 +707,8 @@ FT_BEGIN_HEADER * * Adding stroke may yield a significantly wider and taller glyph * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. + * may need to manually adjust horizontal and vertical advance amounts to + * account for this added size. */ FT_EXPORT( FT_Error ) FT_Glyph_Stroke( FT_Glyph *pglyph, @@ -728,14 +716,14 @@ FT_BEGIN_HEADER FT_Bool destroy ); - /************************************************************** + /************************************************************************** * * @function: * FT_Glyph_StrokeBorder * * @description: - * Stroke a given outline glyph object with a given stroker, but - * only return either its inside or outside border. + * Stroke a given outline glyph object with a given stroker, but only + * return either its inside or outside border. * * @inout: * pglyph :: @@ -746,12 +734,11 @@ FT_BEGIN_HEADER * A stroker handle. * * inside :: - * A Boolean. If~1, return the inside border, otherwise - * the outside border. + * A Boolean. If~1, return the inside border, otherwise the outside + * border. * * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. + * A Boolean. If~1, the source glyph object is destroyed on success. * * @return: * FreeType error code. 0~means success. @@ -761,8 +748,8 @@ FT_BEGIN_HEADER * * Adding stroke may yield a significantly wider and taller glyph * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. + * may need to manually adjust horizontal and vertical advance amounts to + * account for this added size. */ FT_EXPORT( FT_Error ) FT_Glyph_StrokeBorder( FT_Glyph *pglyph, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h index ff9fb43d964..8754f97ceef 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsynth.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftsynth.h */ -/* */ -/* FreeType synthesizing code for emboldening and slanting */ -/* (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsynth.h + * + * FreeType synthesizing code for emboldening and slanting + * (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /*************************************************************************/ @@ -35,7 +35,7 @@ /* Main reason for not lifting the functions in this module to a */ - /* `standard' API is that the used parameters for emboldening and */ + /* 'standard' API is that the used parameters for emboldening and */ /* slanting are not configurable. Consider the functions as a */ /* code resource that should be copied into the application and */ /* adapted to the particular needs. */ @@ -57,7 +57,7 @@ FT_BEGIN_HEADER - /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ + /* Embolden a glyph by a 'reasonable' value (which is highly a matter of */ /* taste). This function is actually a convenience function, providing */ /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h index f6b1629ef23..889a6ba1726 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ftsystem.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsystem.h */ -/* */ -/* FreeType low-level system interface definition (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsystem.h + * + * FreeType low-level system interface definition (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSYSTEM_H_ @@ -26,34 +26,33 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* system_interface */ - /* */ - /* <Title> */ - /* System Interface */ - /* */ - /* <Abstract> */ - /* How FreeType manages memory and i/o. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to memory */ - /* management and i/o access. You need to understand this */ - /* information if you want to use a custom memory manager or you own */ - /* i/o streams. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * system_interface + * + * @title: + * System Interface + * + * @abstract: + * How FreeType manages memory and i/o. + * + * @description: + * This section contains various definitions related to memory management + * and i/o access. You need to understand this information if you want to + * use a custom memory manager or you own i/o streams. + * + */ - /*************************************************************************/ - /* */ - /* M E M O R Y M A N A G E M E N T */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * M E M O R Y M A N A G E M E N T + * + */ - /************************************************************************* + /************************************************************************** * * @type: * FT_Memory @@ -66,13 +65,13 @@ FT_BEGIN_HEADER typedef struct FT_MemoryRec_* FT_Memory; - /************************************************************************* + /************************************************************************** * * @functype: * FT_Alloc_Func * * @description: - * A function used to allocate `size' bytes from `memory'. + * A function used to allocate `size` bytes from `memory`. * * @input: * memory :: @@ -90,7 +89,7 @@ FT_BEGIN_HEADER long size ); - /************************************************************************* + /************************************************************************** * * @functype: * FT_Free_Func @@ -111,7 +110,7 @@ FT_BEGIN_HEADER void* block ); - /************************************************************************* + /************************************************************************** * * @functype: * FT_Realloc_Func @@ -146,7 +145,7 @@ FT_BEGIN_HEADER void* block ); - /************************************************************************* + /************************************************************************** * * @struct: * FT_MemoryRec @@ -177,14 +176,14 @@ FT_BEGIN_HEADER }; - /*************************************************************************/ - /* */ - /* I / O M A N A G E M E N T */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * I / O M A N A G E M E N T + * + */ - /************************************************************************* + /************************************************************************** * * @type: * FT_Stream @@ -193,21 +192,21 @@ FT_BEGIN_HEADER * A handle to an input stream. * * @also: - * See @FT_StreamRec for the publicly accessible fields of a given - * stream object. + * See @FT_StreamRec for the publicly accessible fields of a given stream + * object. * */ typedef struct FT_StreamRec_* FT_Stream; - /************************************************************************* + /************************************************************************** * * @struct: * FT_StreamDesc * * @description: * A union type used to store either a long or a pointer. This is used - * to store a file descriptor or a `FILE*' in an input stream. + * to store a file descriptor or a `FILE*` in an input stream. * */ typedef union FT_StreamDesc_ @@ -218,7 +217,7 @@ FT_BEGIN_HEADER } FT_StreamDesc; - /************************************************************************* + /************************************************************************** * * @functype: * FT_Stream_IoFunc @@ -243,9 +242,8 @@ FT_BEGIN_HEADER * The number of bytes effectively read by the stream. * * @note: - * This function might be called to perform a seek or skip operation - * with a `count' of~0. A non-zero return value then indicates an - * error. + * This function might be called to perform a seek or skip operation with + * a `count` of~0. A non-zero return value then indicates an error. * */ typedef unsigned long @@ -255,7 +253,7 @@ FT_BEGIN_HEADER unsigned long count ); - /************************************************************************* + /************************************************************************** * * @functype: * FT_Stream_CloseFunc @@ -265,14 +263,14 @@ FT_BEGIN_HEADER * * @input: * stream :: - * A handle to the target stream. + * A handle to the target stream. * */ typedef void (*FT_Stream_CloseFunc)( FT_Stream stream ); - /************************************************************************* + /************************************************************************** * * @struct: * FT_StreamRec @@ -283,7 +281,7 @@ FT_BEGIN_HEADER * @input: * base :: * For memory-based streams, this is the address of the first stream - * byte in memory. This field should always be set to NULL for + * byte in memory. This field should always be set to `NULL` for * disk-based streams. * * size :: @@ -299,7 +297,7 @@ FT_BEGIN_HEADER * * descriptor :: * This field is a union that can hold an integer or a pointer. It is - * used by stream implementations to store file descriptors or `FILE*' + * used by stream implementations to store file descriptors or `FILE*` * pointers. * * pathname :: @@ -314,13 +312,13 @@ FT_BEGIN_HEADER * The stream's close function. * * memory :: - * The memory manager to use to preload frames. This is set - * internally by FreeType and shouldn't be touched by stream - * implementations. + * The memory manager to use to preload frames. This is set internally + * by FreeType and shouldn't be touched by stream implementations. * * cursor :: * This field is set and used internally by FreeType when parsing - * frames. + * frames. In particular, the `FT_GET_XXX` macros use this instead of + * the `pos` field. * * limit :: * This field is set and used internally by FreeType when parsing diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h index 2e3f3f1f737..37e1412fdfb 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/fttrigon.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttrigon.h */ -/* */ -/* FreeType trigonometric functions (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttrigon.h + * + * FreeType trigonometric functions (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTTRIGON_H_ @@ -31,15 +31,15 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * computations + * + */ - /************************************************************************* + /************************************************************************** * * @type: * FT_Angle @@ -52,7 +52,7 @@ FT_BEGIN_HEADER typedef FT_Fixed FT_Angle; - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_PI @@ -64,7 +64,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_PI ( 180L << 16 ) - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_2PI @@ -76,7 +76,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_PI2 @@ -88,7 +88,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_PI4 @@ -100,7 +100,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) - /************************************************************************* + /************************************************************************** * * @function: * FT_Sin @@ -124,7 +124,7 @@ FT_BEGIN_HEADER FT_Sin( FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Cos @@ -148,7 +148,7 @@ FT_BEGIN_HEADER FT_Cos( FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Tan @@ -168,14 +168,14 @@ FT_BEGIN_HEADER FT_Tan( FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Atan2 * * @description: - * Return the arc-tangent corresponding to a given vector (x,y) in - * the 2d plane. + * Return the arc-tangent corresponding to a given vector (x,y) in the 2d + * plane. * * @input: * x :: @@ -193,7 +193,7 @@ FT_BEGIN_HEADER FT_Fixed y ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Angle_Diff @@ -210,7 +210,7 @@ FT_BEGIN_HEADER * Second angle. * * @return: - * Constrained value of `value2-value1'. + * Constrained value of `angle2-angle1`. * */ FT_EXPORT( FT_Angle ) @@ -218,15 +218,15 @@ FT_BEGIN_HEADER FT_Angle angle2 ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Unit * * @description: * Return the unit vector corresponding to a given angle. After the - * call, the value of `vec.x' will be `cos(angle)', and the value of - * `vec.y' will be `sin(angle)'. + * call, the value of `vec.x` will be `cos(angle)`, and the value of + * `vec.y` will be `sin(angle)`. * * This function is useful to retrieve both the sinus and cosinus of a * given angle quickly. @@ -245,7 +245,7 @@ FT_BEGIN_HEADER FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Rotate @@ -267,7 +267,7 @@ FT_BEGIN_HEADER FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Length @@ -288,7 +288,7 @@ FT_BEGIN_HEADER FT_Vector_Length( FT_Vector* vec ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Polarize @@ -314,7 +314,7 @@ FT_BEGIN_HEADER FT_Angle *angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_From_Polar diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h index f638c2e54fd..10571505a58 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/fttypes.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttypes.h */ -/* */ -/* FreeType simple types definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttypes.h + * + * FreeType simple types definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTTYPES_H_ @@ -31,326 +31,327 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /* <Title> */ - /* Basic Data Types */ - /* */ - /* <Abstract> */ - /* The basic data types defined by the library. */ - /* */ - /* <Description> */ - /* This section contains the basic data types defined by FreeType~2, */ - /* ranging from simple scalar types to bitmap descriptors. More */ - /* font-specific structures are defined in a different section. */ - /* */ - /* <Order> */ - /* FT_Byte */ - /* FT_Bytes */ - /* FT_Char */ - /* FT_Int */ - /* FT_UInt */ - /* FT_Int16 */ - /* FT_UInt16 */ - /* FT_Int32 */ - /* FT_UInt32 */ - /* FT_Int64 */ - /* FT_UInt64 */ - /* FT_Short */ - /* FT_UShort */ - /* FT_Long */ - /* FT_ULong */ - /* FT_Bool */ - /* FT_Offset */ - /* FT_PtrDist */ - /* FT_String */ - /* FT_Tag */ - /* FT_Error */ - /* FT_Fixed */ - /* FT_Pointer */ - /* FT_Pos */ - /* FT_Vector */ - /* FT_BBox */ - /* FT_Matrix */ - /* FT_FWord */ - /* FT_UFWord */ - /* FT_F2Dot14 */ - /* FT_UnitVector */ - /* FT_F26Dot6 */ - /* FT_Data */ - /* */ - /* FT_MAKE_TAG */ - /* */ - /* FT_Generic */ - /* FT_Generic_Finalizer */ - /* */ - /* FT_Bitmap */ - /* FT_Pixel_Mode */ - /* FT_Palette_Mode */ - /* FT_Glyph_Format */ - /* FT_IMAGE_TAG */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bool */ - /* */ - /* <Description> */ - /* A typedef of unsigned char, used for simple booleans. As usual, */ - /* values 1 and~0 represent true and false, respectively. */ - /* */ + /************************************************************************** + * + * @section: + * basic_types + * + * @title: + * Basic Data Types + * + * @abstract: + * The basic data types defined by the library. + * + * @description: + * This section contains the basic data types defined by FreeType~2, + * ranging from simple scalar types to bitmap descriptors. More + * font-specific structures are defined in a different section. + * + * @order: + * FT_Byte + * FT_Bytes + * FT_Char + * FT_Int + * FT_UInt + * FT_Int16 + * FT_UInt16 + * FT_Int32 + * FT_UInt32 + * FT_Int64 + * FT_UInt64 + * FT_Short + * FT_UShort + * FT_Long + * FT_ULong + * FT_Bool + * FT_Offset + * FT_PtrDist + * FT_String + * FT_Tag + * FT_Error + * FT_Fixed + * FT_Pointer + * FT_Pos + * FT_Vector + * FT_BBox + * FT_Matrix + * FT_FWord + * FT_UFWord + * FT_F2Dot14 + * FT_UnitVector + * FT_F26Dot6 + * FT_Data + * + * FT_MAKE_TAG + * + * FT_Generic + * FT_Generic_Finalizer + * + * FT_Bitmap + * FT_Pixel_Mode + * FT_Palette_Mode + * FT_Glyph_Format + * FT_IMAGE_TAG + * + */ + + + /************************************************************************** + * + * @type: + * FT_Bool + * + * @description: + * A typedef of unsigned char, used for simple booleans. As usual, + * values 1 and~0 represent true and false, respectively. + */ typedef unsigned char FT_Bool; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_FWord */ - /* */ - /* <Description> */ - /* A signed 16-bit integer used to store a distance in original font */ - /* units. */ - /* */ + /************************************************************************** + * + * @type: + * FT_FWord + * + * @description: + * A signed 16-bit integer used to store a distance in original font + * units. + */ typedef signed short FT_FWord; /* distance in FUnits */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UFWord */ - /* */ - /* <Description> */ - /* An unsigned 16-bit integer used to store a distance in original */ - /* font units. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UFWord + * + * @description: + * An unsigned 16-bit integer used to store a distance in original font + * units. + */ typedef unsigned short FT_UFWord; /* unsigned distance */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Char */ - /* */ - /* <Description> */ - /* A simple typedef for the _signed_ char type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Char + * + * @description: + * A simple typedef for the _signed_ char type. + */ typedef signed char FT_Char; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Byte */ - /* */ - /* <Description> */ - /* A simple typedef for the _unsigned_ char type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Byte + * + * @description: + * A simple typedef for the _unsigned_ char type. + */ typedef unsigned char FT_Byte; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bytes */ - /* */ - /* <Description> */ - /* A typedef for constant memory areas. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Bytes + * + * @description: + * A typedef for constant memory areas. + */ typedef const FT_Byte* FT_Bytes; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Tag */ - /* */ - /* <Description> */ - /* A typedef for 32-bit tags (as used in the SFNT format). */ - /* */ + /************************************************************************** + * + * @type: + * FT_Tag + * + * @description: + * A typedef for 32-bit tags (as used in the SFNT format). + */ typedef FT_UInt32 FT_Tag; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_String */ - /* */ - /* <Description> */ - /* A simple typedef for the char type, usually used for strings. */ - /* */ + /************************************************************************** + * + * @type: + * FT_String + * + * @description: + * A simple typedef for the char type, usually used for strings. + */ typedef char FT_String; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Short */ - /* */ - /* <Description> */ - /* A typedef for signed short. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Short + * + * @description: + * A typedef for signed short. + */ typedef signed short FT_Short; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UShort */ - /* */ - /* <Description> */ - /* A typedef for unsigned short. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UShort + * + * @description: + * A typedef for unsigned short. + */ typedef unsigned short FT_UShort; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Int */ - /* */ - /* <Description> */ - /* A typedef for the int type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int + * + * @description: + * A typedef for the int type. + */ typedef signed int FT_Int; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UInt */ - /* */ - /* <Description> */ - /* A typedef for the unsigned int type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt + * + * @description: + * A typedef for the unsigned int type. + */ typedef unsigned int FT_UInt; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Long */ - /* */ - /* <Description> */ - /* A typedef for signed long. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Long + * + * @description: + * A typedef for signed long. + */ typedef signed long FT_Long; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ULong */ - /* */ - /* <Description> */ - /* A typedef for unsigned long. */ - /* */ + /************************************************************************** + * + * @type: + * FT_ULong + * + * @description: + * A typedef for unsigned long. + */ typedef unsigned long FT_ULong; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F2Dot14 */ - /* */ - /* <Description> */ - /* A signed 2.14 fixed-point type used for unit vectors. */ - /* */ + /************************************************************************** + * + * @type: + * FT_F2Dot14 + * + * @description: + * A signed 2.14 fixed-point type used for unit vectors. + */ typedef signed short FT_F2Dot14; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F26Dot6 */ - /* */ - /* <Description> */ - /* A signed 26.6 fixed-point type used for vectorial pixel */ - /* coordinates. */ - /* */ + /************************************************************************** + * + * @type: + * FT_F26Dot6 + * + * @description: + * A signed 26.6 fixed-point type used for vectorial pixel coordinates. + */ typedef signed long FT_F26Dot6; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Fixed */ - /* */ - /* <Description> */ - /* This type is used to store 16.16 fixed-point values, like scaling */ - /* values or matrix coefficients. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Fixed + * + * @description: + * This type is used to store 16.16 fixed-point values, like scaling + * values or matrix coefficients. + */ typedef signed long FT_Fixed; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Error */ - /* */ - /* <Description> */ - /* The FreeType error code type. A value of~0 is always interpreted */ - /* as a successful operation. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Error + * + * @description: + * The FreeType error code type. A value of~0 is always interpreted as a + * successful operation. + */ typedef int FT_Error; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pointer */ - /* */ - /* <Description> */ - /* A simple typedef for a typeless pointer. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Pointer + * + * @description: + * A simple typedef for a typeless pointer. + */ typedef void* FT_Pointer; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Offset */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */ - /* _unsigned_ integer type used to express a file size or position, */ - /* or a memory block size. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Offset + * + * @description: + * This is equivalent to the ANSI~C `size_t` type, i.e., the largest + * _unsigned_ integer type used to express a file size or position, or a + * memory block size. + */ typedef size_t FT_Offset; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_PtrDist */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */ - /* largest _signed_ integer type used to express the distance */ - /* between two pointers. */ - /* */ + /************************************************************************** + * + * @type: + * FT_PtrDist + * + * @description: + * This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest + * _signed_ integer type used to express the distance between two + * pointers. + */ typedef ft_ptrdiff_t FT_PtrDist; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_UnitVector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector unit vector. Uses */ - /* FT_F2Dot14 types. */ - /* */ - /* <Fields> */ - /* x :: Horizontal coordinate. */ - /* */ - /* y :: Vertical coordinate. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_UnitVector + * + * @description: + * A simple structure used to store a 2D vector unit vector. Uses + * FT_F2Dot14 types. + * + * @fields: + * x :: + * Horizontal coordinate. + * + * y :: + * Vertical coordinate. + */ typedef struct FT_UnitVector_ { FT_F2Dot14 x; @@ -359,29 +360,33 @@ FT_BEGIN_HEADER } FT_UnitVector; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Matrix */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2x2 matrix. Coefficients are */ - /* in 16.16 fixed-point format. The computation performed is: */ - /* */ - /* { */ - /* x' = x*xx + y*xy */ - /* y' = x*yx + y*yy */ - /* } */ - /* */ - /* <Fields> */ - /* xx :: Matrix coefficient. */ - /* */ - /* xy :: Matrix coefficient. */ - /* */ - /* yx :: Matrix coefficient. */ - /* */ - /* yy :: Matrix coefficient. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Matrix + * + * @description: + * A simple structure used to store a 2x2 matrix. Coefficients are in + * 16.16 fixed-point format. The computation performed is: + * + * ``` + * x' = x*xx + y*xy + * y' = x*yx + y*yy + * ``` + * + * @fields: + * xx :: + * Matrix coefficient. + * + * xy :: + * Matrix coefficient. + * + * yx :: + * Matrix coefficient. + * + * yy :: + * Matrix coefficient. + */ typedef struct FT_Matrix_ { FT_Fixed xx, xy; @@ -390,19 +395,21 @@ FT_BEGIN_HEADER } FT_Matrix; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Data */ - /* */ - /* <Description> */ - /* Read-only binary data represented as a pointer and a length. */ - /* */ - /* <Fields> */ - /* pointer :: The data. */ - /* */ - /* length :: The length of the data in bytes. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Data + * + * @description: + * Read-only binary data represented as a pointer and a length. + * + * @fields: + * pointer :: + * The data. + * + * length :: + * The length of the data in bytes. + */ typedef struct FT_Data_ { const FT_Byte* pointer; @@ -411,51 +418,52 @@ FT_BEGIN_HEADER } FT_Data; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Generic_Finalizer */ - /* */ - /* <Description> */ - /* Describe a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the @FT_Generic type for */ - /* details of usage. */ - /* */ - /* <Input> */ - /* The address of the FreeType object that is under finalization. */ - /* Its client data is accessed through its `generic' field. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Generic_Finalizer + * + * @description: + * Describe a function used to destroy the 'client' data of any FreeType + * object. See the description of the @FT_Generic type for details of + * usage. + * + * @input: + * The address of the FreeType object that is under finalization. Its + * client data is accessed through its `generic` field. + */ typedef void (*FT_Generic_Finalizer)( void* object ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Generic */ - /* */ - /* <Description> */ - /* Client applications often need to associate their own data to a */ - /* variety of FreeType core objects. For example, a text layout API */ - /* might want to associate a glyph cache to a given size object. */ - /* */ - /* Some FreeType object contains a `generic' field, of type */ - /* FT_Generic, which usage is left to client applications and font */ - /* servers. */ - /* */ - /* It can be used to store a pointer to client-specific data, as well */ - /* as the address of a `finalizer' function, which will be called by */ - /* FreeType when the object is destroyed (for example, the previous */ - /* client example would put the address of the glyph cache destructor */ - /* in the `finalizer' field). */ - /* */ - /* <Fields> */ - /* data :: A typeless pointer to any client-specified data. This */ - /* field is completely ignored by the FreeType library. */ - /* */ - /* finalizer :: A pointer to a `generic finalizer' function, which */ - /* will be called when the object is destroyed. If this */ - /* field is set to NULL, no code will be called. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Generic + * + * @description: + * Client applications often need to associate their own data to a + * variety of FreeType core objects. For example, a text layout API + * might want to associate a glyph cache to a given size object. + * + * Some FreeType object contains a `generic` field, of type `FT_Generic`, + * which usage is left to client applications and font servers. + * + * It can be used to store a pointer to client-specific data, as well as + * the address of a 'finalizer' function, which will be called by + * FreeType when the object is destroyed (for example, the previous + * client example would put the address of the glyph cache destructor in + * the `finalizer` field). + * + * @fields: + * data :: + * A typeless pointer to any client-specified data. This field is + * completely ignored by the FreeType library. + * + * finalizer :: + * A pointer to a 'generic finalizer' function, which will be called + * when the object is destroyed. If this field is set to `NULL`, no + * code will be called. + */ typedef struct FT_Generic_ { void* data; @@ -464,19 +472,19 @@ FT_BEGIN_HEADER } FT_Generic; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_MAKE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags that are used to label */ - /* TrueType tables into an unsigned long, to be used within FreeType. */ - /* */ - /* <Note> */ - /* The produced values *must* be 32-bit integers. Don't redefine */ - /* this macro. */ - /* */ + /************************************************************************** + * + * @macro: + * FT_MAKE_TAG + * + * @description: + * This macro converts four-letter tags that are used to label TrueType + * tables into an unsigned long, to be used within FreeType. + * + * @note: + * The produced values **must** be 32-bit integers. Don't redefine this + * macro. + */ #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ (FT_Tag) \ ( ( (FT_ULong)_x1 << 24 ) | \ @@ -494,53 +502,56 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * list_processing + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ListNode */ - /* */ - /* <Description> */ - /* Many elements and objects in FreeType are listed through an */ - /* @FT_List record (see @FT_ListRec). As its name suggests, an */ - /* FT_ListNode is a handle to a single list element. */ - /* */ + /************************************************************************** + * + * @type: + * FT_ListNode + * + * @description: + * Many elements and objects in FreeType are listed through an @FT_List + * record (see @FT_ListRec). As its name suggests, an FT_ListNode is a + * handle to a single list element. + */ typedef struct FT_ListNodeRec_* FT_ListNode; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_List */ - /* */ - /* <Description> */ - /* A handle to a list record (see @FT_ListRec). */ - /* */ + /************************************************************************** + * + * @type: + * FT_List + * + * @description: + * A handle to a list record (see @FT_ListRec). + */ typedef struct FT_ListRec_* FT_List; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListNodeRec */ - /* */ - /* <Description> */ - /* A structure used to hold a single list element. */ - /* */ - /* <Fields> */ - /* prev :: The previous element in the list. NULL if first. */ - /* */ - /* next :: The next element in the list. NULL if last. */ - /* */ - /* data :: A typeless pointer to the listed object. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_ListNodeRec + * + * @description: + * A structure used to hold a single list element. + * + * @fields: + * prev :: + * The previous element in the list. `NULL` if first. + * + * next :: + * The next element in the list. `NULL` if last. + * + * data :: + * A typeless pointer to the listed object. + */ typedef struct FT_ListNodeRec_ { FT_ListNode prev; @@ -550,20 +561,22 @@ FT_BEGIN_HEADER } FT_ListNodeRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListRec */ - /* */ - /* <Description> */ - /* A structure used to hold a simple doubly-linked list. These are */ - /* used in many parts of FreeType. */ - /* */ - /* <Fields> */ - /* head :: The head (first element) of doubly-linked list. */ - /* */ - /* tail :: The tail (last element) of doubly-linked list. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_ListRec + * + * @description: + * A structure used to hold a simple doubly-linked list. These are used + * in many parts of FreeType. + * + * @fields: + * head :: + * The head (first element) of doubly-linked list. + * + * tail :: + * The tail (last element) of doubly-linked list. + */ typedef struct FT_ListRec_ { FT_ListNode head; @@ -575,13 +588,13 @@ FT_BEGIN_HEADER #define FT_IS_EMPTY( list ) ( (list).head == 0 ) -#define FT_BOOL( x ) ( (FT_Bool)( x ) ) +#define FT_BOOL( x ) ( (FT_Bool)( (x) != 0 ) ) /* concatenate C tokens */ #define FT_ERR_XCAT( x, y ) x ## y #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) - /* see `ftmoderr.h' for descriptions of the following macros */ + /* see `ftmoderr.h` for descriptions of the following macros */ #define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h index f4d308f68c2..f64c28bb2ca 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/autohint.h @@ -1,73 +1,73 @@ -/***************************************************************************/ -/* */ -/* autohint.h */ -/* */ -/* High-level `autohint' module-specific interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The auto-hinter is used to load and automatically hint glyphs if a */ - /* format-specific hinter isn't available. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * autohint.h + * + * High-level 'autohint' module-specific interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * The auto-hinter is used to load and automatically hint glyphs if a + * format-specific hinter isn't available. + * + */ #ifndef AUTOHINT_H_ #define AUTOHINT_H_ - /*************************************************************************/ - /* */ - /* A small technical note regarding automatic hinting in order to */ - /* clarify this module interface. */ - /* */ - /* An automatic hinter might compute two kinds of data for a given face: */ - /* */ - /* - global hints: Usually some metrics that describe global properties */ - /* of the face. It is computed by scanning more or less */ - /* aggressively the glyphs in the face, and thus can be */ - /* very slow to compute (even if the size of global */ - /* hints is really small). */ - /* */ - /* - glyph hints: These describe some important features of the glyph */ - /* outline, as well as how to align them. They are */ - /* generally much faster to compute than global hints. */ - /* */ - /* The current FreeType auto-hinter does a pretty good job while */ - /* performing fast computations for both global and glyph hints. */ - /* However, we might be interested in introducing more complex and */ - /* powerful algorithms in the future, like the one described in the John */ - /* D. Hobby paper, which unfortunately requires a lot more horsepower. */ - /* */ - /* Because a sufficiently sophisticated font management system would */ - /* typically implement an LRU cache of opened face objects to reduce */ - /* memory usage, it is a good idea to be able to avoid recomputing */ - /* global hints every time the same face is re-opened. */ - /* */ - /* We thus provide the ability to cache global hints outside of the face */ - /* object, in order to speed up font re-opening time. Of course, this */ - /* feature is purely optional, so most client programs won't even notice */ - /* it. */ - /* */ - /* I initially thought that it would be a good idea to cache the glyph */ - /* hints too. However, my general idea now is that if you really need */ - /* to cache these too, you are simply in need of a new font format, */ - /* where all this information could be stored within the font file and */ - /* decoded on the fly. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * A small technical note regarding automatic hinting in order to clarify + * this module interface. + * + * An automatic hinter might compute two kinds of data for a given face: + * + * - global hints: Usually some metrics that describe global properties + * of the face. It is computed by scanning more or less + * aggressively the glyphs in the face, and thus can be + * very slow to compute (even if the size of global hints + * is really small). + * + * - glyph hints: These describe some important features of the glyph + * outline, as well as how to align them. They are + * generally much faster to compute than global hints. + * + * The current FreeType auto-hinter does a pretty good job while performing + * fast computations for both global and glyph hints. However, we might be + * interested in introducing more complex and powerful algorithms in the + * future, like the one described in the John D. Hobby paper, which + * unfortunately requires a lot more horsepower. + * + * Because a sufficiently sophisticated font management system would + * typically implement an LRU cache of opened face objects to reduce memory + * usage, it is a good idea to be able to avoid recomputing global hints + * every time the same face is re-opened. + * + * We thus provide the ability to cache global hints outside of the face + * object, in order to speed up font re-opening time. Of course, this + * feature is purely optional, so most client programs won't even notice + * it. + * + * I initially thought that it would be a good idea to cache the glyph + * hints too. However, my general idea now is that if you really need to + * cache these too, you are simply in need of a new font format, where all + * this information could be stored within the font file and decoded on the + * fly. + * + */ #include <ft2build.h> @@ -80,27 +80,31 @@ FT_BEGIN_HEADER typedef struct FT_AutoHinterRec_ *FT_AutoHinter; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalGetFunc */ - /* */ - /* <Description> */ - /* Retrieve the global hints computed for a given face object. The */ - /* resulting data is dissociated from the face and will survive a */ - /* call to FT_Done_Face(). It must be discarded through the API */ - /* FT_AutoHinter_GlobalDoneFunc(). */ - /* */ - /* <Input> */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* global_hints :: A typeless pointer to the global hints. */ - /* */ - /* global_len :: The size in bytes of the global hints. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalGetFunc + * + * @description: + * Retrieve the global hints computed for a given face object. The + * resulting data is dissociated from the face and will survive a call to + * FT_Done_Face(). It must be discarded through the API + * FT_AutoHinter_GlobalDoneFunc(). + * + * @input: + * hinter :: + * A handle to the source auto-hinter. + * + * face :: + * A handle to the source face object. + * + * @output: + * global_hints :: + * A typeless pointer to the global hints. + * + * global_len :: + * The size in bytes of the global hints. + */ typedef void (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter, FT_Face face, @@ -108,69 +112,76 @@ FT_BEGIN_HEADER long* global_len ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalDoneFunc */ - /* */ - /* <Description> */ - /* Discard the global hints retrieved through */ - /* FT_AutoHinter_GlobalGetFunc(). This is the only way these hints */ - /* are freed from memory. */ - /* */ - /* <Input> */ - /* hinter :: A handle to the auto-hinter module. */ - /* */ - /* global :: A pointer to retrieved global hints to discard. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalDoneFunc + * + * @description: + * Discard the global hints retrieved through + * FT_AutoHinter_GlobalGetFunc(). This is the only way these hints are + * freed from memory. + * + * @input: + * hinter :: + * A handle to the auto-hinter module. + * + * global :: + * A pointer to retrieved global hints to discard. + */ typedef void (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter, void* global ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalResetFunc */ - /* */ - /* <Description> */ - /* This function is used to recompute the global metrics in a given */ - /* font. This is useful when global font data changes (e.g. Multiple */ - /* Masters fonts where blend coordinates change). */ - /* */ - /* <Input> */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the face. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalResetFunc + * + * @description: + * This function is used to recompute the global metrics in a given font. + * This is useful when global font data changes (e.g. Multiple Masters + * fonts where blend coordinates change). + * + * @input: + * hinter :: + * A handle to the source auto-hinter. + * + * face :: + * A handle to the face. + */ typedef void (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter, FT_Face face ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlyphLoadFunc */ - /* */ - /* <Description> */ - /* This function is used to load, scale, and automatically hint a */ - /* glyph from a given face. */ - /* */ - /* <Input> */ - /* face :: A handle to the face. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* load_flags :: The load flags. */ - /* */ - /* <Note> */ - /* This function is capable of loading composite glyphs by hinting */ - /* each sub-glyph independently (which improves quality). */ - /* */ - /* It will call the font driver with @FT_Load_Glyph, with */ - /* @FT_LOAD_NO_SCALE set. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlyphLoadFunc + * + * @description: + * This function is used to load, scale, and automatically hint a glyph + * from a given face. + * + * @input: + * face :: + * A handle to the face. + * + * glyph_index :: + * The glyph index. + * + * load_flags :: + * The load flags. + * + * @note: + * This function is capable of loading composite glyphs by hinting each + * sub-glyph independently (which improves quality). + * + * It will call the font driver with @FT_Load_Glyph, with + * @FT_LOAD_NO_SCALE set. + */ typedef FT_Error (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter, FT_GlyphSlot slot, @@ -179,14 +190,14 @@ FT_BEGIN_HEADER FT_Int32 load_flags ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_AutoHinter_InterfaceRec */ - /* */ - /* <Description> */ - /* The auto-hinter module's interface. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_AutoHinter_InterfaceRec + * + * @description: + * The auto-hinter module's interface. + */ typedef struct FT_AutoHinter_InterfaceRec_ { FT_AutoHinter_GlobalResetFunc reset_face; @@ -197,8 +208,6 @@ FT_BEGIN_HEADER } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_AUTOHINTER_INTERFACE( \ class_, \ reset_face_, \ @@ -214,27 +223,6 @@ FT_BEGIN_HEADER load_glyph_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_AUTOHINTER_INTERFACE( \ - class_, \ - reset_face_, \ - get_global_hints_, \ - done_global_hints_, \ - load_glyph_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_AutoHinter_InterfaceRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->reset_face = reset_face_; \ - clazz->get_global_hints = get_global_hints_; \ - clazz->done_global_hints = done_global_hints_; \ - clazz->load_glyph = load_glyph_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h index 57e7591d41a..b26893eab3b 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cffotypes.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffotypes.h */ -/* */ -/* Basic OpenType/CFF object type definitions (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffotypes.h + * + * Basic OpenType/CFF object type definitions (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFOTYPES_H_ @@ -33,14 +33,14 @@ FT_BEGIN_HEADER typedef TT_Face CFF_Face; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Size */ - /* */ - /* <Description> */ - /* A handle to an OpenType size object. */ - /* */ + /************************************************************************** + * + * @type: + * CFF_Size + * + * @description: + * A handle to an OpenType size object. + */ typedef struct CFF_SizeRec_ { FT_SizeRec root; @@ -49,14 +49,14 @@ FT_BEGIN_HEADER } CFF_SizeRec, *CFF_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to an OpenType glyph slot object. */ - /* */ + /************************************************************************** + * + * @type: + * CFF_GlyphSlot + * + * @description: + * A handle to an OpenType glyph slot object. + */ typedef struct CFF_GlyphSlotRec_ { FT_GlyphSlotRec root; @@ -70,14 +70,14 @@ FT_BEGIN_HEADER } CFF_GlyphSlotRec, *CFF_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Internal */ - /* */ - /* <Description> */ - /* The interface to the `internal' field of `FT_Size'. */ - /* */ + /************************************************************************** + * + * @type: + * CFF_Internal + * + * @description: + * The interface to the 'internal' field of `FT_Size`. + */ typedef struct CFF_InternalRec_ { PSH_Globals topfont; @@ -86,10 +86,10 @@ FT_BEGIN_HEADER } CFF_InternalRec, *CFF_Internal; - /*************************************************************************/ - /* */ - /* Subglyph transformation record. */ - /* */ + /************************************************************************** + * + * Subglyph transformation record. + */ typedef struct CFF_Transform_ { FT_Fixed xx, xy; /* transformation matrix coefficients */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h index 7c07e1a3768..2fc905ec795 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* cfftypes.h */ -/* */ -/* Basic OpenType/CFF type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cfftypes.h + * + * Basic OpenType/CFF type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFTYPES_H_ @@ -33,34 +33,39 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CFF_IndexRec */ - /* */ - /* <Description> */ - /* A structure used to model a CFF Index table. */ - /* */ - /* <Fields> */ - /* stream :: The source input stream. */ - /* */ - /* start :: The position of the first index byte in the */ - /* input stream. */ - /* */ - /* count :: The number of elements in the index. */ - /* */ - /* off_size :: The size in bytes of object offsets in index. */ - /* */ - /* data_offset :: The position of first data byte in the index's */ - /* bytes. */ - /* */ - /* data_size :: The size of the data table in this index. */ - /* */ - /* offsets :: A table of element offsets in the index. Must be */ - /* loaded explicitly. */ - /* */ - /* bytes :: If the index is loaded in memory, its bytes. */ - /* */ + /************************************************************************** + * + * @struct: + * CFF_IndexRec + * + * @description: + * A structure used to model a CFF Index table. + * + * @fields: + * stream :: + * The source input stream. + * + * start :: + * The position of the first index byte in the input stream. + * + * count :: + * The number of elements in the index. + * + * off_size :: + * The size in bytes of object offsets in index. + * + * data_offset :: + * The position of first data byte in the index's bytes. + * + * data_size :: + * The size of the data table in this index. + * + * offsets :: + * A table of element offsets in the index. Must be loaded explicitly. + * + * bytes :: + * If the index is loaded in memory, its bytes. + */ typedef struct CFF_IndexRec_ { FT_Stream stream; diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h index 818a812359d..2986ec359b1 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftcalc.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcalc.h */ -/* */ -/* Arithmetic computations (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcalc.h + * + * Arithmetic computations (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCALC_H_ @@ -27,11 +27,11 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * FT_MulDiv() and FT_MulFix() are declared in freetype.h. + * + */ #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER /* Provide assembler fragments for performance-critical functions. */ @@ -246,29 +246,32 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv_No_Round */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation `(a*b)/c' */ - /* (without rounding) with maximum accuracy (it uses a 64-bit */ - /* intermediate integer whenever necessary). */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_MulDiv_No_Round + * + * @description: + * A very simple function used to perform the computation '(a*b)/c' + * (without rounding) with maximum accuracy (it uses a 64-bit + * intermediate integer whenever necessary). + * + * This function isn't necessarily as fast as some processor-specific + * operations, but is at least completely portable. + * + * @input: + * a :: + * The first multiplier. + * b :: + * The second multiplier. + * c :: + * The divisor. + * + * @return: + * The result of '(a*b)/c'. This function never traps when trying to + * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on + * the signs of 'a' and 'b'. + */ FT_BASE( FT_Long ) FT_MulDiv_No_Round( FT_Long a, FT_Long b, @@ -276,12 +279,11 @@ FT_BEGIN_HEADER /* - * A variant of FT_Matrix_Multiply which scales its result afterwards. - * The idea is that both `a' and `b' are scaled by factors of 10 so that - * the values are as precise as possible to get a correct result during - * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of - * `a' and `b', respectively, then the scaling factor of the result is - * `sa*sb'. + * A variant of FT_Matrix_Multiply which scales its result afterwards. The + * idea is that both `a' and `b' are scaled by factors of 10 so that the + * values are as precise as possible to get a correct result during the + * 64bit multiplication. Let `sa' and `sb' be the scaling factors of `a' + * and `b', respectively, then the scaling factor of the result is `sa*sb'. */ FT_BASE( void ) FT_Matrix_Multiply_Scaled( const FT_Matrix* a, @@ -290,8 +292,23 @@ FT_BEGIN_HEADER /* - * A variant of FT_Vector_Transform. See comments for - * FT_Matrix_Multiply_Scaled. + * Check a matrix. If the transformation would lead to extreme shear or + * extreme scaling, for example, return 0. If everything is OK, return 1. + * + * Based on geometric considerations we use the following inequality to + * identify a degenerate matrix. + * + * 50 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2 + * + * Value 50 is heuristic. + */ + FT_BASE( FT_Bool ) + FT_Matrix_Check( const FT_Matrix* matrix ); + + + /* + * A variant of FT_Vector_Transform. See comments for + * FT_Matrix_Multiply_Scaled. */ FT_BASE( void ) FT_Vector_Transform_Scaled( FT_Vector* vector, @@ -300,22 +317,22 @@ FT_BEGIN_HEADER /* - * This function normalizes a vector and returns its original length. - * The normalized vector is a 16.16 fixed-point unit vector with length - * close to 0x10000. The accuracy of the returned length is limited to - * 16 bits also. The function utilizes quick inverse square root - * approximation without divisions and square roots relying on Newton's - * iterations instead. + * This function normalizes a vector and returns its original length. The + * normalized vector is a 16.16 fixed-point unit vector with length close + * to 0x10000. The accuracy of the returned length is limited to 16 bits + * also. The function utilizes quick inverse square root approximation + * without divisions and square roots relying on Newton's iterations + * instead. */ FT_BASE( FT_UInt32 ) FT_Vector_NormLen( FT_Vector* vector ); /* - * Return -1, 0, or +1, depending on the orientation of a given corner. - * We use the Cartesian coordinate system, with positive vertical values - * going upwards. The function returns +1 if the corner turns to the - * left, -1 to the right, and 0 for undecidable cases. + * Return -1, 0, or +1, depending on the orientation of a given corner. We + * use the Cartesian coordinate system, with positive vertical values going + * upwards. The function returns +1 if the corner turns to the left, -1 to + * the right, and 0 for undecidable cases. */ FT_BASE( FT_Int ) ft_corner_orientation( FT_Pos in_x, @@ -325,9 +342,9 @@ FT_BEGIN_HEADER /* - * Return TRUE if a corner is flat or nearly flat. This is equivalent to - * saying that the corner point is close to its neighbors, or inside an - * ellipse defined by the neighbor focal points to be more precise. + * Return TRUE if a corner is flat or nearly flat. This is equivalent to + * saying that the corner point is close to its neighbors, or inside an + * ellipse defined by the neighbor focal points to be more precise. */ FT_BASE( FT_Int ) ft_corner_is_flat( FT_Pos in_x, @@ -337,10 +354,11 @@ FT_BEGIN_HEADER /* - * Return the most significant bit index. + * Return the most significant bit index. */ #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER + #if defined( __GNUC__ ) && \ ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) ) @@ -352,9 +370,34 @@ FT_BEGIN_HEADER #define FT_MSB( x ) ( 31 - __builtin_clzl( x ) ) +#endif /* __GNUC__ */ + + +#elif defined( _MSC_VER ) && ( _MSC_VER >= 1400 ) + +#if FT_SIZEOF_INT == 4 + +#include <intrin.h> + + static __inline FT_Int32 + FT_MSB_i386( FT_UInt32 x ) + { + unsigned long where; + + + /* not available in older VC versions */ + _BitScanReverse( &where, x ); + + return (FT_Int32)where; + } + +#define FT_MSB( x ) ( FT_MSB_i386( x ) ) + #endif -#endif /* __GNUC__ */ +#endif /* _MSC_VER */ + + #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ #ifndef FT_MSB @@ -366,8 +409,8 @@ FT_BEGIN_HEADER /* - * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses - * two fixed-point arguments instead. + * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses + * two fixed-point arguments instead. */ FT_BASE( FT_Fixed ) FT_Hypot( FT_Fixed x, @@ -376,23 +419,24 @@ FT_BEGIN_HEADER #if 0 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_SqrtFixed */ - /* */ - /* <Description> */ - /* Computes the square root of a 16.16 fixed-point value. */ - /* */ - /* <Input> */ - /* x :: The value to compute the root for. */ - /* */ - /* <Return> */ - /* The result of `sqrt(x)'. */ - /* */ - /* <Note> */ - /* This function is not very fast. */ - /* */ + /************************************************************************** + * + * @function: + * FT_SqrtFixed + * + * @description: + * Computes the square root of a 16.16 fixed-point value. + * + * @input: + * x :: + * The value to compute the root for. + * + * @return: + * The result of 'sqrt(x)'. + * + * @note: + * This function is not very fast. + */ FT_BASE( FT_Int32 ) FT_SqrtFixed( FT_Int32 x ); @@ -409,14 +453,23 @@ FT_BEGIN_HEADER : ( -( ( 32 - (x) ) & -64 ) ) ) /* - * The following macros have two purposes. + * The following macros have two purposes. * - * . Tag places where overflow is expected and harmless. + * - Tag places where overflow is expected and harmless. * - * . Avoid run-time sanitizer errors. + * - Avoid run-time sanitizer errors. * - * Use with care! + * Use with care! */ +#define ADD_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) ) +#define SUB_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) ) +#define MUL_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) ) +#define NEG_INT( a ) \ + (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) ) + #define ADD_LONG( a, b ) \ (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) ) #define SUB_LONG( a, b ) \ @@ -435,6 +488,19 @@ FT_BEGIN_HEADER #define NEG_INT32( a ) \ (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) ) +#ifdef FT_LONG64 + +#define ADD_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) ) +#define SUB_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) ) +#define MUL_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) ) +#define NEG_INT64( a ) \ + (FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) ) + +#endif /* FT_LONG64 */ + FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h index 292a4eedb8b..54a9673afa4 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdebug.h @@ -1,24 +1,24 @@ -/***************************************************************************/ -/* */ -/* ftdebug.h */ -/* */ -/* Debugging and logging component (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* */ -/* IMPORTANT: A description of FreeType's debugging support can be */ -/* found in `docs/DEBUG.TXT'. Read it if you need to use or */ -/* understand this code. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdebug.h + * + * Debugging and logging component (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * IMPORTANT: A description of FreeType's debugging support can be + * found in 'docs/DEBUG.TXT'. Read it if you need to use or + * understand this code. + * + */ #ifndef FTDEBUG_H_ @@ -42,12 +42,12 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* Define the trace enums as well as the trace levels array when they */ - /* are needed. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the trace enums as well as the trace levels array when they are + * needed. + * + */ #ifdef FT_DEBUG_LEVEL_TRACE @@ -62,32 +62,37 @@ FT_BEGIN_HEADER } FT_Trace; - /* defining the array of trace levels, provided by `src/base/ftdebug.c' */ - extern int ft_trace_levels[trace_count]; + /* a pointer to the array of trace levels, */ + /* provided by `src/base/ftdebug.c' */ + extern int* ft_trace_levels; #undef FT_TRACE_DEF #endif /* FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* Define the FT_TRACE macro */ - /* */ - /* IMPORTANT! */ - /* */ - /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */ - /* value before using any TRACE macro. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the FT_TRACE macro + * + * IMPORTANT! + * + * Each component must define the macro FT_COMPONENT to a valid FT_Trace + * value before using any TRACE macro. + * + */ #ifdef FT_DEBUG_LEVEL_TRACE -#define FT_TRACE( level, varformat ) \ - do \ - { \ - if ( ft_trace_levels[FT_COMPONENT] >= level ) \ - FT_Message varformat; \ + /* we need two macros here to make cpp expand `FT_COMPONENT' */ +#define FT_TRACE_COMP( x ) FT_TRACE_COMP_( x ) +#define FT_TRACE_COMP_( x ) trace_ ## x + +#define FT_TRACE( level, varformat ) \ + do \ + { \ + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \ + FT_Message varformat; \ } while ( 0 ) #else /* !FT_DEBUG_LEVEL_TRACE */ @@ -97,62 +102,85 @@ FT_BEGIN_HEADER #endif /* !FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Trace_Get_Count */ - /* */ - /* <Description> */ - /* Return the number of available trace components. */ - /* */ - /* <Return> */ - /* The number of trace components. 0 if FreeType 2 is not built with */ - /* FT_DEBUG_LEVEL_TRACE definition. */ - /* */ - /* <Note> */ - /* This function may be useful if you want to access elements of */ - /* the internal `ft_trace_levels' array by an index. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Trace_Get_Count + * + * @description: + * Return the number of available trace components. + * + * @return: + * The number of trace components. 0 if FreeType 2 is not built with + * FT_DEBUG_LEVEL_TRACE definition. + * + * @note: + * This function may be useful if you want to access elements of the + * internal trace levels array by an index. + */ FT_BASE( FT_Int ) FT_Trace_Get_Count( void ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Trace_Get_Name */ - /* */ - /* <Description> */ - /* Return the name of a trace component. */ - /* */ - /* <Input> */ - /* The index of the trace component. */ - /* */ - /* <Return> */ - /* The name of the trace component. This is a statically allocated */ - /* C string, so do not free it after use. NULL if FreeType 2 is not */ - /* built with FT_DEBUG_LEVEL_TRACE definition. */ - /* */ - /* <Note> */ - /* Use @FT_Trace_Get_Count to get the number of available trace */ - /* components. */ - /* */ - /* This function may be useful if you want to control FreeType 2's */ - /* debug level in your application. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Trace_Get_Name + * + * @description: + * Return the name of a trace component. + * + * @input: + * The index of the trace component. + * + * @return: + * The name of the trace component. This is a statically allocated + * C~string, so do not free it after use. `NULL` if FreeType is not + * built with FT_DEBUG_LEVEL_TRACE definition. + * + * @note: + * Use @FT_Trace_Get_Count to get the number of available trace + * components. + */ FT_BASE( const char* ) FT_Trace_Get_Name( FT_Int idx ); - /*************************************************************************/ - /* */ - /* You need two opening and closing parentheses! */ - /* */ - /* Example: FT_TRACE0(( "Value is %i", foo )) */ - /* */ - /* Output of the FT_TRACEX macros is sent to stderr. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @function: + * FT_Trace_Disable + * + * @description: + * Switch off tracing temporarily. It can be activated again with + * @FT_Trace_Enable. + */ + FT_BASE( void ) + FT_Trace_Disable( void ); + + + /************************************************************************** + * + * @function: + * FT_Trace_Enable + * + * @description: + * Activate tracing. Use it after tracing has been switched off with + * @FT_Trace_Disable. + */ + FT_BASE( void ) + FT_Trace_Enable( void ); + + + /************************************************************************** + * + * You need two opening and closing parentheses! + * + * Example: FT_TRACE0(( "Value is %i", foo )) + * + * Output of the FT_TRACEX macros is sent to stderr. + * + */ #define FT_TRACE0( varformat ) FT_TRACE( 0, varformat ) #define FT_TRACE1( varformat ) FT_TRACE( 1, varformat ) @@ -164,13 +192,13 @@ FT_BEGIN_HEADER #define FT_TRACE7( varformat ) FT_TRACE( 7, varformat ) - /*************************************************************************/ - /* */ - /* Define the FT_ERROR macro. */ - /* */ - /* Output of this macro is sent to stderr. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the FT_ERROR macro. + * + * Output of this macro is sent to stderr. + * + */ #ifdef FT_DEBUG_LEVEL_ERROR @@ -183,12 +211,12 @@ FT_BEGIN_HEADER #endif /* !FT_DEBUG_LEVEL_ERROR */ - /*************************************************************************/ - /* */ - /* Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw' */ - /* makes it possible to easily set a breakpoint at this function. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw` makes + * it possible to easily set a breakpoint at this function. + * + */ #ifdef FT_DEBUG_LEVEL_ERROR @@ -215,11 +243,11 @@ FT_BEGIN_HEADER #endif /* !FT_DEBUG_LEVEL_ERROR */ - /*************************************************************************/ - /* */ - /* Define `FT_Message' and `FT_Panic' when needed. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define `FT_Message` and `FT_Panic` when needed. + * + */ #ifdef FT_DEBUG_LEVEL_ERROR diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h index 58dd35a9337..09e846e1c79 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftdrv.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftdrv.h */ -/* */ -/* FreeType internal font driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdrv.h + * + * FreeType internal font driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTDRV_H_ @@ -87,73 +87,80 @@ FT_BEGIN_HEADER FT_Fixed* advances ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Driver_ClassRec */ - /* */ - /* <Description> */ - /* The font driver class. This structure mostly contains pointers to */ - /* driver methods. */ - /* */ - /* <Fields> */ - /* root :: The parent module. */ - /* */ - /* face_object_size :: The size of a face object in bytes. */ - /* */ - /* size_object_size :: The size of a size object in bytes. */ - /* */ - /* slot_object_size :: The size of a glyph object in bytes. */ - /* */ - /* init_face :: The format-specific face constructor. */ - /* */ - /* done_face :: The format-specific face destructor. */ - /* */ - /* init_size :: The format-specific size constructor. */ - /* */ - /* done_size :: The format-specific size destructor. */ - /* */ - /* init_slot :: The format-specific slot constructor. */ - /* */ - /* done_slot :: The format-specific slot destructor. */ - /* */ - /* */ - /* load_glyph :: A function handle to load a glyph to a slot. */ - /* This field is mandatory! */ - /* */ - /* get_kerning :: A function handle to return the unscaled */ - /* kerning for a given pair of glyphs. Can be */ - /* set to 0 if the format doesn't support */ - /* kerning. */ - /* */ - /* attach_file :: This function handle is used to read */ - /* additional data for a face from another */ - /* file/stream. For example, this can be used to */ - /* add data from AFM or PFM files on a Type 1 */ - /* face, or a CIDMap on a CID-keyed face. */ - /* */ - /* get_advances :: A function handle used to return advance */ - /* widths of `count' glyphs (in font units), */ - /* starting at `first'. The `vertical' flag must */ - /* be set to get vertical advance heights. The */ - /* `advances' buffer is caller-allocated. */ - /* The idea of this function is to be able to */ - /* perform device-independent text layout without */ - /* loading a single glyph image. */ - /* */ - /* request_size :: A handle to a function used to request the new */ - /* character size. Can be set to 0 if the */ - /* scaling done in the base layer suffices. */ - /* */ - /* select_size :: A handle to a function used to select a new */ - /* fixed size. It is used only if */ - /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ - /* to 0 if the scaling done in the base layer */ - /* suffices. */ - /* <Note> */ - /* Most function pointers, with the exception of `load_glyph', can be */ - /* set to 0 to indicate a default behaviour. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Driver_ClassRec + * + * @description: + * The font driver class. This structure mostly contains pointers to + * driver methods. + * + * @fields: + * root :: + * The parent module. + * + * face_object_size :: + * The size of a face object in bytes. + * + * size_object_size :: + * The size of a size object in bytes. + * + * slot_object_size :: + * The size of a glyph object in bytes. + * + * init_face :: + * The format-specific face constructor. + * + * done_face :: + * The format-specific face destructor. + * + * init_size :: + * The format-specific size constructor. + * + * done_size :: + * The format-specific size destructor. + * + * init_slot :: + * The format-specific slot constructor. + * + * done_slot :: + * The format-specific slot destructor. + * + * + * load_glyph :: + * A function handle to load a glyph to a slot. This field is + * mandatory! + * + * get_kerning :: + * A function handle to return the unscaled kerning for a given pair of + * glyphs. Can be set to 0 if the format doesn't support kerning. + * + * attach_file :: + * This function handle is used to read additional data for a face from + * another file/stream. For example, this can be used to add data from + * AFM or PFM files on a Type 1 face, or a CIDMap on a CID-keyed face. + * + * get_advances :: + * A function handle used to return advance widths of 'count' glyphs + * (in font units), starting at 'first'. The 'vertical' flag must be + * set to get vertical advance heights. The 'advances' buffer is + * caller-allocated. The idea of this function is to be able to + * perform device-independent text layout without loading a single + * glyph image. + * + * request_size :: + * A handle to a function used to request the new character size. Can + * be set to 0 if the scaling done in the base layer suffices. + * + * select_size :: + * A handle to a function used to select a new fixed size. It is used + * only if @FT_FACE_FLAG_FIXED_SIZES is set. Can be set to 0 if the + * scaling done in the base layer suffices. + * @note: + * Most function pointers, with the exception of `load_glyph`, can be set + * to 0 to indicate a default behaviour. + */ typedef struct FT_Driver_ClassRec_ { FT_Module_Class root; @@ -184,45 +191,28 @@ FT_BEGIN_HEADER } FT_Driver_ClassRec, *FT_Driver_Class; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_DRIVER */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of an FT_Driver_ClassRec */ - /* struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_DRIVER */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Driver_ClassRec struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */ - /* called with a pointer where the allocated structure is returned. */ - /* And when it is no longer needed a `destroy' function needs to be */ - /* called to release that allocation. */ - /* */ - /* `ftinit.c' (ft_create_default_module_classes) already contains a */ - /* mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by driver definition calling `FT_DEFINE_DRIVER' in following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro is */ - /* used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DECLARE_DRIVER + * + * @description: + * Used to create a forward declaration of an FT_Driver_ClassRec struct + * instance. + * + * @macro: + * FT_DEFINE_DRIVER + * + * @description: + * Used to initialize an instance of FT_Driver_ClassRec struct. + * + * `ftinit.c` (ft_create_default_module_classes) already contains a + * mechanism to call these functions for the default modules described in + * `ftmodule.h`. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DECLARE_DRIVER( class_ ) \ FT_CALLBACK_TABLE \ const FT_Driver_ClassRec class_; @@ -289,108 +279,6 @@ FT_BEGIN_HEADER select_size_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ ) - -#define FT_DEFINE_DRIVER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - face_object_size_, \ - size_object_size_, \ - slot_object_size_, \ - init_face_, \ - done_face_, \ - init_size_, \ - done_size_, \ - init_slot_, \ - done_slot_, \ - load_glyph_, \ - get_kerning_, \ - attach_file_, \ - get_advances_, \ - request_size_, \ - select_size_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( dclazz ) \ - FT_FREE( dclazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Driver_Class clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - clazz->face_object_size = face_object_size_; \ - clazz->size_object_size = size_object_size_; \ - clazz->slot_object_size = slot_object_size_; \ - \ - clazz->init_face = init_face_; \ - clazz->done_face = done_face_; \ - \ - clazz->init_size = init_size_; \ - clazz->done_size = done_size_; \ - \ - clazz->init_slot = init_slot_; \ - clazz->done_slot = done_slot_; \ - \ - clazz->load_glyph = load_glyph_; \ - \ - clazz->get_kerning = get_kerning_; \ - clazz->attach_file = attach_file_; \ - clazz->get_advances = get_advances_; \ - \ - clazz->request_size = request_size_; \ - clazz->select_size = select_size_; \ - \ - *output_class = (FT_Module_Class*)clazz; \ - \ - return FT_Err_Ok; \ - } - - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h index a002fdbfca3..770871d81be 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftgloadr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgloadr.h */ -/* */ -/* The FreeType glyph loader (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgloadr.h + * + * The FreeType glyph loader (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGLOADR_H_ @@ -27,15 +27,15 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphLoader */ - /* */ - /* <Description> */ - /* The glyph loader is an internal object used to load several glyphs */ - /* together (for example, in the case of composites). */ - /* */ + /************************************************************************** + * + * @struct: + * FT_GlyphLoader + * + * @description: + * The glyph loader is an internal object used to load several glyphs + * together (for example, in the case of composites). + */ typedef struct FT_SubGlyphRec_ { FT_Int index; @@ -138,11 +138,6 @@ FT_BEGIN_HEADER FT_BASE( void ) FT_GlyphLoader_Add( FT_GlyphLoader loader ); - /* copy points from one glyph loader to another */ - FT_BASE( FT_Error ) - FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, - FT_GlyphLoader source ); - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h index f22f9d5d390..249188040b3 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fthash.h @@ -1,10 +1,10 @@ -/***************************************************************************/ -/* */ -/* fthash.h */ -/* */ -/* Hashing functions (specification). */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fthash.h + * + * Hashing functions (specification). + * + */ /* * Copyright 2000 Computing Research Labs, New Mexico State University @@ -30,13 +30,13 @@ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /*************************************************************************/ - /* */ - /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ - /* */ - /* taken from Mark Leisher's xmbdfed package */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 + * + * taken from Mark Leisher's xmbdfed package + * + */ #ifndef FTHASH_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h index 054eaec31f7..78bd3bc229f 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftmemory.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmemory.h */ -/* */ -/* The FreeType memory management macros (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmemory.h + * + * The FreeType memory management macros (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTMEMORY_H_ @@ -28,16 +28,16 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_SET_ERROR */ - /* */ - /* <Description> */ - /* This macro is used to set an implicit `error' variable to a given */ - /* expression's value (usually a function call), and convert it to a */ - /* boolean which is set whenever the value is != 0. */ - /* */ + /************************************************************************** + * + * @macro: + * FT_SET_ERROR + * + * @description: + * This macro is used to set an implicit 'error' variable to a given + * expression's value (usually a function call), and convert it to a + * boolean which is set whenever the value is != 0. + */ #undef FT_SET_ERROR #define FT_SET_ERROR( expression ) \ ( ( error = (expression) ) != 0 ) @@ -58,9 +58,9 @@ FT_BEGIN_HEADER /* - * C++ refuses to handle statements like p = (void*)anything, with `p' a - * typed pointer. Since we don't have a `typeof' operator in standard - * C++, we have to use a template to emulate it. + * C++ refuses to handle statements like p = (void*)anything, with `p' a + * typed pointer. Since we don't have a `typeof' operator in standard C++, + * we have to use a template to emulate it. */ #ifdef __cplusplus @@ -107,8 +107,8 @@ extern "C++" /* - * The allocation functions return a pointer, and the error code - * is written to through the `p_error' parameter. + * The allocation functions return a pointer, and the error code is written + * to through the `p_error' parameter. */ /* The `q' variants of the functions below (`q' for `quick') don't fill */ @@ -253,20 +253,19 @@ extern "C++" /* - * Return the maximum number of addressable elements in an array. - * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid - * any problems. + * Return the maximum number of addressable elements in an array. We limit + * ourselves to INT_MAX, rather than UINT_MAX, to avoid any problems. */ #define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) ) #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) - /*************************************************************************/ - /* */ - /* The following functions macros expect that their pointer argument is */ - /* _typed_ in order to automatically compute array element sizes. */ - /* */ + /************************************************************************** + * + * The following functions macros expect that their pointer argument is + * _typed_ in order to automatically compute array element sizes. + */ #define FT_MEM_NEW_ARRAY( ptr, count ) \ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h index 1c3c6ad4563..f3a41b35aba 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* ftobjs.h */ -/* */ -/* The FreeType private base classes (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of all internal FreeType classes. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftobjs.h + * + * The FreeType private base classes (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file contains the definition of all internal FreeType classes. + * + */ #ifndef FTOBJS_H_ @@ -35,7 +35,6 @@ #include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_AUTOHINT_H #include FT_INTERNAL_SERVICE_H -#include FT_INTERNAL_PIC_H #include FT_INTERNAL_CALC_H #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -46,10 +45,10 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* Some generic definitions. */ - /* */ + /************************************************************************** + * + * Some generic definitions. + */ #ifndef TRUE #define TRUE 1 #endif @@ -63,20 +62,20 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* The min and max functions missing in C. As usual, be careful not to */ - /* write things like FT_MIN( a++, b++ ) to avoid side effects. */ - /* */ + /************************************************************************** + * + * The min and max functions missing in C. As usual, be careful not to + * write things like FT_MIN( a++, b++ ) to avoid side effects. + */ #define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) ) #define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) ) #define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) ) /* - * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' - * algorithm. We use alpha = 1, beta = 3/8, giving us results with a - * largest error less than 7% compared to the exact value. + * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' algorithm. + * We use alpha = 1, beta = 3/8, giving us results with a largest error + * less than 7% compared to the exact value. */ #define FT_HYPOT( x, y ) \ ( x = FT_ABS( x ), \ @@ -111,9 +110,8 @@ FT_BEGIN_HEADER /* - * character classification functions -- since these are used to parse - * font files, we must not use those in <ctypes.h> which are - * locale-dependent + * character classification functions -- since these are used to parse font + * files, we must not use those in <ctypes.h> which are locale-dependent */ #define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U ) @@ -187,7 +185,7 @@ FT_BEGIN_HEADER FT_UInt32 char_code, FT_UInt32 variant_selector ); - typedef FT_Bool + typedef FT_Int (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap, FT_UInt32 char_code, FT_UInt32 variant_selector ); @@ -228,8 +226,6 @@ FT_BEGIN_HEADER } FT_CMap_ClassRec; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DECLARE_CMAP_CLASS( class_ ) \ FT_CALLBACK_TABLE const FT_CMap_ClassRec class_; @@ -260,45 +256,6 @@ FT_BEGIN_HEADER variantchar_list_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_CMAP_CLASS( class_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_CMap_ClassRec* clazz ); - -#define FT_DEFINE_CMAP_CLASS( \ - class_, \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_CMap_ClassRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->size = size_; \ - clazz->init = init_; \ - clazz->done = done_; \ - clazz->char_index = char_index_; \ - clazz->char_next = char_next_; \ - clazz->char_var_index = char_var_index_; \ - clazz->char_var_default = char_var_default_; \ - clazz->variant_list = variant_list_; \ - clazz->charvariant_list = charvariant_list_; \ - clazz->variantchar_list = variantchar_list_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* create a new charmap and add it to charmap->face */ FT_BASE( FT_Error ) @@ -312,11 +269,11 @@ FT_BEGIN_HEADER FT_CMap_Done( FT_CMap cmap ); - /* adds LCD padding to Min and Max boundaries */ + /* add LCD padding to CBox */ FT_BASE( void ) - ft_lcd_padding( FT_Pos* Min, - FT_Pos* Max, - FT_GlyphSlot slot ); + ft_lcd_padding( FT_BBox* cbox, + FT_GlyphSlot slot, + FT_Render_Mode mode ); #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING @@ -333,74 +290,72 @@ FT_BEGIN_HEADER #endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Face_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_Face */ - /* object. These fields may change between different releases of */ - /* FreeType. */ - /* */ - /* <Fields> */ - /* max_points :: */ - /* The maximum number of points used to store the vectorial outline */ - /* of any glyph in this face. If this value cannot be known in */ - /* advance, or if the face isn't scalable, this should be set to 0. */ - /* Only relevant for scalable formats. */ - /* */ - /* max_contours :: */ - /* The maximum number of contours used to store the vectorial */ - /* outline of any glyph in this face. If this value cannot be */ - /* known in advance, or if the face isn't scalable, this should be */ - /* set to 0. Only relevant for scalable formats. */ - /* */ - /* transform_matrix :: */ - /* A 2x2 matrix of 16.16 coefficients used to transform glyph */ - /* outlines after they are loaded from the font. Only used by the */ - /* convenience functions. */ - /* */ - /* transform_delta :: */ - /* A translation vector used to transform glyph outlines after they */ - /* are loaded from the font. Only used by the convenience */ - /* functions. */ - /* */ - /* transform_flags :: */ - /* Some flags used to classify the transform. Only used by the */ - /* convenience functions. */ - /* */ - /* services :: */ - /* A cache for frequently used services. It should be only */ - /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */ - /* */ - /* incremental_interface :: */ - /* If non-null, the interface through which glyph data and metrics */ - /* are loaded incrementally for faces that do not provide all of */ - /* this data when first opened. This field exists only if */ - /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ - /* */ - /* no_stem_darkening :: */ - /* Overrides the module-level default, see @stem-darkening[cff], */ - /* for example. FALSE and TRUE toggle stem darkening on and off, */ - /* respectively, value~-1 means to use the module/driver default. */ - /* */ - /* random_seed :: */ - /* If positive, override the seed value for the CFF `random' */ - /* operator. Value~0 means to use the font's value. Value~-1 */ - /* means to use the CFF driver's default. */ - /* */ - /* lcd_weights :: */ - /* lcd_filter_func :: */ - /* If subpixel rendering is activated, the LCD filtering weights */ - /* and callback function. */ - /* */ - /* refcount :: */ - /* A counter initialized to~1 at the time an @FT_Face structure is */ - /* created. @FT_Reference_Face increments this counter, and */ - /* @FT_Done_Face only destroys a face if the counter is~1, */ - /* otherwise it simply decrements it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Face_InternalRec + * + * @description: + * This structure contains the internal fields of each FT_Face object. + * These fields may change between different releases of FreeType. + * + * @fields: + * max_points :: + * The maximum number of points used to store the vectorial outline of + * any glyph in this face. If this value cannot be known in advance, + * or if the face isn't scalable, this should be set to 0. Only + * relevant for scalable formats. + * + * max_contours :: + * The maximum number of contours used to store the vectorial outline + * of any glyph in this face. If this value cannot be known in + * advance, or if the face isn't scalable, this should be set to 0. + * Only relevant for scalable formats. + * + * transform_matrix :: + * A 2x2 matrix of 16.16 coefficients used to transform glyph outlines + * after they are loaded from the font. Only used by the convenience + * functions. + * + * transform_delta :: + * A translation vector used to transform glyph outlines after they are + * loaded from the font. Only used by the convenience functions. + * + * transform_flags :: + * Some flags used to classify the transform. Only used by the + * convenience functions. + * + * services :: + * A cache for frequently used services. It should be only accessed + * with the macro `FT_FACE_LOOKUP_SERVICE`. + * + * incremental_interface :: + * If non-null, the interface through which glyph data and metrics are + * loaded incrementally for faces that do not provide all of this data + * when first opened. This field exists only if + * @FT_CONFIG_OPTION_INCREMENTAL is defined. + * + * no_stem_darkening :: + * Overrides the module-level default, see @stem-darkening[cff], for + * example. FALSE and TRUE toggle stem darkening on and off, + * respectively, value~-1 means to use the module/driver default. + * + * random_seed :: + * If positive, override the seed value for the CFF 'random' operator. + * Value~0 means to use the font's value. Value~-1 means to use the + * CFF driver's default. + * + * lcd_weights :: + * lcd_filter_func :: + * These fields specify the LCD filtering weights and callback function + * for ClearType-style subpixel rendering. + * + * refcount :: + * A counter initialized to~1 at the time an @FT_Face structure is + * created. @FT_Reference_Face increments this counter, and + * @FT_Done_Face only destroys a face if the counter is~1, otherwise it + * simply decrements it. + */ typedef struct FT_Face_InternalRec_ { FT_Matrix transform_matrix; @@ -426,39 +381,44 @@ FT_BEGIN_HEADER } FT_Face_InternalRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Slot_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_GlyphSlot */ - /* object. These fields may change between different releases of */ - /* FreeType. */ - /* */ - /* <Fields> */ - /* loader :: The glyph loader object used to load outlines */ - /* into the glyph slot. */ - /* */ - /* flags :: Possible values are zero or */ - /* FT_GLYPH_OWN_BITMAP. The latter indicates */ - /* that the FT_GlyphSlot structure owns the */ - /* bitmap buffer. */ - /* */ - /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */ - /* must be transformed through a specific */ - /* font transformation. This is _not_ the same */ - /* as the face transform set through */ - /* FT_Set_Transform(). */ - /* */ - /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */ - /* transformation, if necessary. */ - /* */ - /* glyph_delta :: The 2d translation vector corresponding to */ - /* the glyph transformation, if necessary. */ - /* */ - /* glyph_hints :: Format-specific glyph hints management. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Slot_InternalRec + * + * @description: + * This structure contains the internal fields of each FT_GlyphSlot + * object. These fields may change between different releases of + * FreeType. + * + * @fields: + * loader :: + * The glyph loader object used to load outlines into the glyph slot. + * + * flags :: + * Possible values are zero or FT_GLYPH_OWN_BITMAP. The latter + * indicates that the FT_GlyphSlot structure owns the bitmap buffer. + * + * glyph_transformed :: + * Boolean. Set to TRUE when the loaded glyph must be transformed + * through a specific font transformation. This is _not_ the same as + * the face transform set through FT_Set_Transform(). + * + * glyph_matrix :: + * The 2x2 matrix corresponding to the glyph transformation, if + * necessary. + * + * glyph_delta :: + * The 2d translation vector corresponding to the glyph transformation, + * if necessary. + * + * glyph_hints :: + * Format-specific glyph hints management. + * + * load_flags :: + * The load flags passed as an argument to @FT_Load_Glyph while + * initializing the glyph slot. + */ #define FT_GLYPH_OWN_BITMAP 0x1U @@ -471,26 +431,30 @@ FT_BEGIN_HEADER FT_Vector glyph_delta; void* glyph_hints; + FT_Int32 load_flags; + } FT_GlyphSlot_InternalRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_Size */ - /* object. */ - /* */ - /* <Fields> */ - /* module_data :: Data specific to a driver module. */ - /* */ - /* autohint_mode :: The used auto-hinting mode. */ - /* */ - /* autohint_metrics :: Metrics used by the auto-hinter. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @struct: + * FT_Size_InternalRec + * + * @description: + * This structure contains the internal fields of each FT_Size object. + * + * @fields: + * module_data :: + * Data specific to a driver module. + * + * autohint_mode :: + * The used auto-hinting mode. + * + * autohint_metrics :: + * Metrics used by the auto-hinter. + * + */ typedef struct FT_Size_InternalRec_ { @@ -515,21 +479,24 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ModuleRec */ - /* */ - /* <Description> */ - /* A module object instance. */ - /* */ - /* <Fields> */ - /* clazz :: A pointer to the module's class. */ - /* */ - /* library :: A handle to the parent library object. */ - /* */ - /* memory :: A handle to the memory manager. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_ModuleRec + * + * @description: + * A module object instance. + * + * @fields: + * clazz :: + * A pointer to the module's class. + * + * library :: + * A handle to the parent library object. + * + * memory :: + * A handle to the memory manager. + */ typedef struct FT_ModuleRec_ { FT_Module_Class* clazz; @@ -572,27 +539,29 @@ FT_BEGIN_HEADER FT_MODULE_DRIVER_HINTS_LIGHTLY ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module_Interface */ - /* */ - /* <Description> */ - /* Finds a module and returns its specific interface as a typeless */ - /* pointer. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module-specific interface if available, 0 otherwise. */ - /* */ - /* <Note> */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for, and what its interface is :-) */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Module_Interface + * + * @description: + * Finds a module and returns its specific interface as a typeless + * pointer. + * + * @input: + * library :: + * A handle to the library object. + * + * module_name :: + * The module's name (as an ASCII string). + * + * @return: + * A module-specific interface if available, 0 otherwise. + * + * @note: + * You should better be familiar with FreeType internals to know which + * module to look for, and what its interface is :-) + */ FT_BASE( const void* ) FT_Get_Module_Interface( FT_Library library, const char* mod_name ); @@ -643,44 +612,46 @@ FT_BEGIN_HEADER #define FT_FACE_SIZE( x ) FT_FACE( x )->size - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_GlyphSlot */ - /* */ - /* <Description> */ - /* It is sometimes useful to have more than one glyph slot for a */ - /* given face object. This function is used to create additional */ - /* slots. All of them are automatically discarded when the face is */ - /* destroyed. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* aslot :: A handle to a new glyph slot object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_GlyphSlot + * + * @description: + * It is sometimes useful to have more than one glyph slot for a given + * face object. This function is used to create additional slots. All + * of them are automatically discarded when the face is destroyed. + * + * @input: + * face :: + * A handle to a parent face object. + * + * @output: + * aslot :: + * A handle to a new glyph slot object. + * + * @return: + * FreeType error code. 0 means success. + */ FT_BASE( FT_Error ) FT_New_GlyphSlot( FT_Face face, FT_GlyphSlot *aslot ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_GlyphSlot */ - /* */ - /* <Description> */ - /* Destroys a given glyph slot. Remember however that all slots are */ - /* automatically destroyed with its parent. Using this function is */ - /* not always mandatory. */ - /* */ - /* <Input> */ - /* slot :: A handle to a target glyph slot. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_GlyphSlot + * + * @description: + * Destroys a given glyph slot. Remember however that all slots are + * automatically destroyed with its parent. Using this function is not + * always mandatory. + * + * @input: + * slot :: + * A handle to a target glyph slot. + */ FT_BASE( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot ); @@ -730,8 +701,9 @@ FT_BEGIN_HEADER ft_glyphslot_free_bitmap( FT_GlyphSlot slot ); - /* Preset bitmap metrics of an outline glyphslot prior to rendering. */ - FT_BASE( void ) + /* Preset bitmap metrics of an outline glyphslot prior to rendering */ + /* and check whether the truncated bbox is too large for rendering. */ + FT_BASE( FT_Bool ) ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ); @@ -802,28 +774,30 @@ FT_BEGIN_HEADER #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_DriverRec */ - /* */ - /* <Description> */ - /* The root font driver class. A font driver is responsible for */ - /* managing and loading font files of a given format. */ - /* */ - /* <Fields> */ - /* root :: Contains the fields of the root module class. */ - /* */ - /* clazz :: A pointer to the font driver's class. Note that */ - /* this is NOT root.clazz. `class' wasn't used */ - /* as it is a reserved word in C++. */ - /* */ - /* faces_list :: The list of faces currently opened by this */ - /* driver. */ - /* */ - /* glyph_loader :: Unused. Used to be glyph loader for all faces */ - /* managed by this driver. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_DriverRec + * + * @description: + * The root font driver class. A font driver is responsible for managing + * and loading font files of a given format. + * + * @fields: + * root :: + * Contains the fields of the root module class. + * + * clazz :: + * A pointer to the font driver's class. Note that this is NOT + * root.clazz. 'class' wasn't used as it is a reserved word in C++. + * + * faces_list :: + * The list of faces currently opened by this driver. + * + * glyph_loader :: + * Unused. Used to be glyph loader for all faces managed by this + * driver. + */ typedef struct FT_DriverRec_ { FT_ModuleRec root; @@ -847,72 +821,77 @@ FT_BEGIN_HEADER /*************************************************************************/ - /* This hook is used by the TrueType debugger. It must be set to an */ - /* alternate truetype bytecode interpreter function. */ -#define FT_DEBUG_HOOK_TRUETYPE 0 - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_LibraryRec */ - /* */ - /* <Description> */ - /* The FreeType library class. This is the root of all FreeType */ - /* data. Use FT_New_Library() to create a library object, and */ - /* FT_Done_Library() to discard it and all child objects. */ - /* */ - /* <Fields> */ - /* memory :: The library's memory object. Manages memory */ - /* allocation. */ - /* */ - /* version_major :: The major version number of the library. */ - /* */ - /* version_minor :: The minor version number of the library. */ - /* */ - /* version_patch :: The current patch level of the library. */ - /* */ - /* num_modules :: The number of modules currently registered */ - /* within this library. This is set to 0 for new */ - /* libraries. New modules are added through the */ - /* FT_Add_Module() API function. */ - /* */ - /* modules :: A table used to store handles to the currently */ - /* registered modules. Note that each font driver */ - /* contains a list of its opened faces. */ - /* */ - /* renderers :: The list of renderers currently registered */ - /* within the library. */ - /* */ - /* cur_renderer :: The current outline renderer. This is a */ - /* shortcut used to avoid parsing the list on */ - /* each call to FT_Outline_Render(). It is a */ - /* handle to the current renderer for the */ - /* FT_GLYPH_FORMAT_OUTLINE format. */ - /* */ - /* auto_hinter :: The auto-hinter module interface. */ - /* */ - /* debug_hooks :: An array of four function pointers that allow */ - /* debuggers to hook into a font format's */ - /* interpreter. Currently, only the TrueType */ - /* bytecode debugger uses this. */ - /* */ - /* lcd_weights :: If subpixel rendering is activated, the LCD */ - /* filter weights, if any. */ - /* */ - /* lcd_filter_func :: If subpixel rendering is activated, the LCD */ - /* filtering callback function. */ - /* */ - /* pic_container :: Contains global structs and tables, instead */ - /* of defining them globally. */ - /* */ - /* refcount :: A counter initialized to~1 at the time an */ - /* @FT_Library structure is created. */ - /* @FT_Reference_Library increments this counter, */ - /* and @FT_Done_Library only destroys a library */ - /* if the counter is~1, otherwise it simply */ - /* decrements it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_LibraryRec + * + * @description: + * The FreeType library class. This is the root of all FreeType data. + * Use FT_New_Library() to create a library object, and FT_Done_Library() + * to discard it and all child objects. + * + * @fields: + * memory :: + * The library's memory object. Manages memory allocation. + * + * version_major :: + * The major version number of the library. + * + * version_minor :: + * The minor version number of the library. + * + * version_patch :: + * The current patch level of the library. + * + * num_modules :: + * The number of modules currently registered within this library. + * This is set to 0 for new libraries. New modules are added through + * the FT_Add_Module() API function. + * + * modules :: + * A table used to store handles to the currently registered + * modules. Note that each font driver contains a list of its opened + * faces. + * + * renderers :: + * The list of renderers currently registered within the library. + * + * cur_renderer :: + * The current outline renderer. This is a shortcut used to avoid + * parsing the list on each call to FT_Outline_Render(). It is a + * handle to the current renderer for the FT_GLYPH_FORMAT_OUTLINE + * format. + * + * auto_hinter :: + * The auto-hinter module interface. + * + * debug_hooks :: + * An array of four function pointers that allow debuggers to hook into + * a font format's interpreter. Currently, only the TrueType bytecode + * debugger uses this. + * + * lcd_weights :: + * The LCD filter weights for ClearType-style subpixel rendering. + * + * lcd_filter_func :: + * The LCD filtering callback function for for ClearType-style subpixel + * rendering. + * + * lcd_geometry :: + * This array specifies LCD subpixel geometry and controls Harmony LCD + * rendering technique, alternative to ClearType. + * + * pic_container :: + * Contains global structs and tables, instead of defining them + * globally. + * + * refcount :: + * A counter initialized to~1 at the time an @FT_Library structure is + * created. @FT_Reference_Library increments this counter, and + * @FT_Done_Library only destroys a library if the counter is~1, + * otherwise it simply decrements it. + */ typedef struct FT_LibraryRec_ { FT_Memory memory; /* library's memory manager */ @@ -933,10 +912,8 @@ FT_BEGIN_HEADER #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ -#endif - -#ifdef FT_CONFIG_OPTION_PIC - FT_PIC_Container pic_container; +#else + FT_Vector lcd_geometry[3]; /* RGB subpixel positions */ #endif FT_Int refcount; @@ -970,32 +947,33 @@ FT_BEGIN_HEADER #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory */ - /* */ - /* <Description> */ - /* Creates a new memory object. */ - /* */ - /* <Return> */ - /* A pointer to the new memory object. 0 in case of error. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Memory + * + * @description: + * Creates a new memory object. + * + * @return: + * A pointer to the new memory object. 0 in case of error. + */ FT_BASE( FT_Memory ) FT_New_Memory( void ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Memory */ - /* */ - /* <Description> */ - /* Discards memory manager. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Memory + * + * @description: + * Discards memory manager. + * + * @input: + * memory :: + * A handle to the memory manager. + */ FT_BASE( void ) FT_Done_Memory( FT_Memory memory ); @@ -1013,37 +991,16 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** P I C S U P P O R T ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* PIC support macros for ftimage.h */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_OUTLINE_FUNCS */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Outline_Funcs struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ - /* to be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DEFINE_OUTLINE_FUNCS + * + * @description: + * Used to initialize an instance of FT_Outline_Funcs struct. The struct + * will be allocated in the global scope (or the scope where the macro is + * used). + */ #define FT_DEFINE_OUTLINE_FUNCS( \ class_, \ move_to_, \ @@ -1062,47 +1019,17 @@ FT_BEGIN_HEADER delta_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_OUTLINE_FUNCS( \ - class_, \ - move_to_, \ - line_to_, \ - conic_to_, \ - cubic_to_, \ - shift_, \ - delta_ ) \ - static FT_Error \ - Init_Class_ ## class_( FT_Outline_Funcs* clazz ) \ - { \ - clazz->move_to = move_to_; \ - clazz->line_to = line_to_; \ - clazz->conic_to = conic_to_; \ - clazz->cubic_to = cubic_to_; \ - clazz->shift = shift_; \ - clazz->delta = delta_; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_RASTER_FUNCS */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Raster_Funcs struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ - /* to be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC + /************************************************************************** + * + * @macro: + * FT_DEFINE_RASTER_FUNCS + * + * @description: + * Used to initialize an instance of FT_Raster_Funcs struct. The struct + * will be allocated in the global scope (or the scope where the macro is + * used). + */ #define FT_DEFINE_RASTER_FUNCS( \ class_, \ glyph_format_, \ @@ -1121,48 +1048,17 @@ FT_BEGIN_HEADER raster_done_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_RASTER_FUNCS( \ - class_, \ - glyph_format_, \ - raster_new_, \ - raster_reset_, \ - raster_set_mode_, \ - raster_render_, \ - raster_done_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Raster_Funcs* clazz ) \ - { \ - clazz->glyph_format = glyph_format_; \ - clazz->raster_new = raster_new_; \ - clazz->raster_reset = raster_reset_; \ - clazz->raster_set_mode = raster_set_mode_; \ - clazz->raster_render = raster_render_; \ - clazz->raster_done = raster_done_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* PIC support macros for ftrender.h */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_GLYPH */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Glyph_Class struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ - /* to be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DEFINE_GLYPH + * + * @description: + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DEFINE_GLYPH( \ class_, \ size_, \ @@ -1186,73 +1082,25 @@ FT_BEGIN_HEADER prepare_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_GLYPH( \ - class_, \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Glyph_Class* clazz ) \ - { \ - clazz->glyph_size = size_; \ - clazz->glyph_format = format_; \ - clazz->glyph_init = init_; \ - clazz->glyph_done = done_; \ - clazz->glyph_copy = copy_; \ - clazz->glyph_transform = transform_; \ - clazz->glyph_bbox = bbox_; \ - clazz->glyph_prepare = prepare_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_RENDERER */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of a */ - /* FT_Renderer_Class struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_RENDERER */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Renderer_Class struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function will */ - /* need to be called with a pointer where the allocated structure is */ - /* returned. And when it is no longer needed a `destroy' function */ - /* needs to be called to release that allocation. */ - /* `ftinit.c' (ft_create_default_module_classes) already contains */ - /* a mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by the renderer definition calling `FT_DEFINE_RENDERER' in the */ - /* following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC + /************************************************************************** + * + * @macro: + * FT_DECLARE_RENDERER + * + * @description: + * Used to create a forward declaration of a FT_Renderer_Class struct + * instance. + * + * @macro: + * FT_DEFINE_RENDERER + * + * @description: + * Used to initialize an instance of FT_Renderer_Class struct. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DECLARE_RENDERER( class_ ) \ FT_EXPORT_VAR( const FT_Renderer_Class ) class_; @@ -1295,176 +1143,33 @@ FT_BEGIN_HEADER raster_class_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_RENDERER( class_ ) FT_DECLARE_MODULE( class_ ) - -#define FT_DEFINE_RENDERER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - glyph_format_, \ - render_glyph_, \ - transform_glyph_, \ - get_glyph_cbox_, \ - set_mode_, \ - raster_class_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \ - FT_Memory memory = library->memory; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( rclazz ) \ - FT_FREE( rclazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Renderer_Class* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - clazz->glyph_format = glyph_format_; \ - \ - clazz->render_glyph = render_glyph_; \ - clazz->transform_glyph = transform_glyph_; \ - clazz->get_glyph_cbox = get_glyph_cbox_; \ - clazz->set_mode = set_mode_; \ - \ - clazz->raster_class = raster_class_; \ - \ - *output_class = (FT_Module_Class*)clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /* PIC support macros for ftmodapi.h **/ - - -#ifdef FT_CONFIG_OPTION_PIC - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Creator */ - /* */ - /* <Description> */ - /* A function used to create (allocate) a new module class object. */ - /* The object's members are initialized, but the module itself is */ - /* not. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* output_class :: Initialized with the newly allocated class. */ - /* */ - typedef FT_Error - (*FT_Module_Creator)( FT_Memory memory, - FT_Module_Class** output_class ); - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destroyer */ - /* */ - /* <Description> */ - /* A function used to destroy (deallocate) a module class object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* clazz :: Module class to destroy. */ - /* */ - typedef void - (*FT_Module_Destroyer)( FT_Memory memory, - FT_Module_Class* clazz ); - -#endif - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_MODULE */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of a */ - /* FT_Module_Class struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_MODULE */ - /* */ - /* <Description> */ - /* Used to initialize an instance of an FT_Module_Class struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs */ - /* to be called with a pointer where the allocated structure is */ - /* returned. And when it is no longer needed a `destroy' function */ - /* needs to be called to release that allocation. */ - /* `ftinit.c' (ft_create_default_module_classes) already contains */ - /* a mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by the module definition calling `FT_DEFINE_MODULE' in the */ - /* following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ - /* <Macro> */ - /* FT_DEFINE_ROOT_MODULE */ - /* */ - /* <Description> */ - /* Used to initialize an instance of an FT_Module_Class struct inside */ - /* another struct that contains it or in a function that initializes */ - /* that containing struct. */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC + /************************************************************************** + * + * @macro: + * FT_DECLARE_MODULE + * + * @description: + * Used to create a forward declaration of a FT_Module_Class struct + * instance. + * + * @macro: + * FT_DEFINE_MODULE + * + * @description: + * Used to initialize an instance of an FT_Module_Class struct. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + * + * @macro: + * FT_DEFINE_ROOT_MODULE + * + * @description: + * Used to initialize an instance of an FT_Module_Class struct inside + * another struct that contains it or in a function that initializes that + * containing struct. + */ #define FT_DECLARE_MODULE( class_ ) \ FT_CALLBACK_TABLE \ const FT_Module_Class class_; @@ -1523,100 +1228,6 @@ FT_BEGIN_HEADER }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_MODULE( class_ ) \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ); \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ); - -#define FT_DEFINE_ROOT_MODULE( \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - clazz->root.module_flags = flags_; \ - clazz->root.module_size = size_; \ - clazz->root.module_name = name_; \ - clazz->root.module_version = version_; \ - clazz->root.module_requires = requires_; \ - \ - clazz->root.module_interface = interface_; \ - \ - clazz->root.module_init = init_; \ - clazz->root.module_done = done_; \ - clazz->root.get_interface = get_interface_; - -#define FT_DEFINE_MODULE( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Memory memory = library->memory; \ - FT_Module_Class* clazz = NULL; \ - FT_Error error; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - clazz->module_flags = flags_; \ - clazz->module_size = size_; \ - clazz->module_name = name_; \ - clazz->module_version = version_; \ - clazz->module_requires = requires_; \ - \ - clazz->module_interface = interface_; \ - \ - clazz->module_init = init_; \ - clazz->module_done = done_; \ - clazz->get_interface = get_interface_; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - FT_END_HEADER #endif /* FTOBJS_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpic.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpic.h deleted file mode 100644 index 5214f059891..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpic.h +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpic.h */ -/* */ -/* The FreeType position independent code services (declaration). */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Modules that ordinarily have const global data that need address */ - /* can instead define pointers here. */ - /* */ - /*************************************************************************/ - - -#ifndef FTPIC_H_ -#define FTPIC_H_ - - -FT_BEGIN_HEADER - -#ifdef FT_CONFIG_OPTION_PIC - - typedef struct FT_PIC_Container_ - { - /* pic containers for base */ - void* base; - - /* pic containers for modules */ - void* autofit; - void* cff; - void* pshinter; - void* psnames; - void* raster; - void* sfnt; - void* smooth; - void* truetype; - - } FT_PIC_Container; - - - /* Initialize the various function tables, structs, etc. */ - /* stored in the container. */ - FT_BASE( FT_Error ) - ft_pic_container_init( FT_Library library ); - - - /* Destroy the contents of the container. */ - FT_BASE( void ) - ft_pic_container_destroy( FT_Library library ); - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -FT_END_HEADER - -#endif /* FTPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h index abbb62862b3..574837f6d40 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftpsprop.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftpsprop.h */ -/* */ -/* Get and set properties of PostScript drivers (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpsprop.h + * + * Get and set properties of PostScript drivers (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTPSPROP_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h index 1aca48a0e7b..75b3e531bb9 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftrfork.h @@ -1,24 +1,24 @@ -/***************************************************************************/ -/* */ -/* ftrfork.h */ -/* */ -/* Embedded resource forks accessor (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* Development of the code in this file is support of */ -/* Information-technology Promotion Agency, Japan. */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrfork.h + * + * Embedded resource forks accessor (specification). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO and Redhat K.K. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * Development of the code in this file is support of + * Information-technology Promotion Agency, Japan. + */ #ifndef FTRFORK_H_ @@ -72,85 +72,65 @@ FT_BEGIN_HEADER } FT_RFork_Rule; /* For fast translation between rule index and rule type, - * the macros FT_RFORK_xxx should be kept consistent with - * the raccess_guess_funcs table + * the macros FT_RFORK_xxx should be kept consistent with the + * raccess_guess_funcs table */ typedef struct ft_raccess_guess_rec_ { ft_raccess_guess_func func; FT_RFork_Rule type; } ft_raccess_guess_rec; -#ifndef FT_CONFIG_OPTION_PIC - /* this array is a storage in non-PIC mode, so ; is needed in END */ #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ static const type name[] = { #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ { raccess_guess_ ## func_suffix, \ FT_RFork_Rule_ ## type_suffix }, + /* this array is a storage, thus a final `;' is needed */ #define CONST_FT_RFORK_RULE_ARRAY_END }; -#else /* FT_CONFIG_OPTION_PIC */ - - /* this array is a function in PIC mode, so no ; is needed in END */ -#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ - void \ - FT_Init_Table_ ## name( type* storage ) \ - { \ - type* local = storage; \ - \ - \ - int i = 0; -#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ - local[i].func = raccess_guess_ ## func_suffix; \ - local[i].type = FT_RFork_Rule_ ## type_suffix; \ - i++; -#define CONST_FT_RFORK_RULE_ARRAY_END } - -#endif /* FT_CONFIG_OPTION_PIC */ - #endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Guess */ - /* */ - /* <Description> */ - /* Guess a file name and offset where the actual resource fork is */ - /* stored. The macro FT_RACCESS_N_RULES holds the number of */ - /* guessing rules; the guessed result for the Nth rule is */ - /* represented as a triplet: a new file name (new_names[N]), a file */ - /* offset (offsets[N]), and an error code (errors[N]). */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* base_name :: */ - /* The (base) file name of the resource fork used for some */ - /* guessing rules. */ - /* */ - /* <Output> */ - /* new_names :: */ - /* An array of guessed file names in which the resource forks may */ - /* exist. If `new_names[N]' is NULL, the guessed file name is */ - /* equal to `base_name'. */ - /* */ - /* offsets :: */ - /* An array of guessed file offsets. `offsets[N]' holds the file */ - /* offset of the possible start of the resource fork in file */ - /* `new_names[N]'. */ - /* */ - /* errors :: */ - /* An array of FreeType error codes. `errors[N]' is the error */ - /* code of Nth guessing rule function. If `errors[N]' is not */ - /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Raccess_Guess + * + * @description: + * Guess a file name and offset where the actual resource fork is stored. + * The macro FT_RACCESS_N_RULES holds the number of guessing rules; the + * guessed result for the Nth rule is represented as a triplet: a new + * file name (new_names[N]), a file offset (offsets[N]), and an error + * code (errors[N]). + * + * @input: + * library :: + * A FreeType library instance. + * + * stream :: + * A file stream containing the resource fork. + * + * base_name :: + * The (base) file name of the resource fork used for some guessing + * rules. + * + * @output: + * new_names :: + * An array of guessed file names in which the resource forks may + * exist. If 'new_names[N]' is `NULL`, the guessed file name is equal + * to `base_name`. + * + * offsets :: + * An array of guessed file offsets. 'offsets[N]' holds the file + * offset of the possible start of the resource fork in file + * 'new_names[N]'. + * + * errors :: + * An array of FreeType error codes. 'errors[N]' is the error code of + * Nth guessing rule function. If 'errors[N]' is not FT_Err_Ok, + * 'new_names[N]' and 'offsets[N]' are meaningless. + */ FT_BASE( void ) FT_Raccess_Guess( FT_Library library, FT_Stream stream, @@ -160,37 +140,37 @@ FT_BEGIN_HEADER FT_Error* errors ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Get_HeaderInfo */ - /* */ - /* <Description> */ - /* Get the information from the header of resource fork. The */ - /* information includes the file offset where the resource map */ - /* starts, and the file offset where the resource data starts. */ - /* `FT_Raccess_Get_DataOffsets' requires these two data. */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* rfork_offset :: */ - /* The file offset where the resource fork starts. */ - /* */ - /* <Output> */ - /* map_offset :: */ - /* The file offset where the resource map starts. */ - /* */ - /* rdata_pos :: */ - /* The file offset where the resource data starts. */ - /* */ - /* <Return> */ - /* FreeType error code. FT_Err_Ok means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Raccess_Get_HeaderInfo + * + * @description: + * Get the information from the header of resource fork. The information + * includes the file offset where the resource map starts, and the file + * offset where the resource data starts. `FT_Raccess_Get_DataOffsets` + * requires these two data. + * + * @input: + * library :: + * A FreeType library instance. + * + * stream :: + * A file stream containing the resource fork. + * + * rfork_offset :: + * The file offset where the resource fork starts. + * + * @output: + * map_offset :: + * The file offset where the resource map starts. + * + * rdata_pos :: + * The file offset where the resource data starts. + * + * @return: + * FreeType error code. FT_Err_Ok means success. + */ FT_BASE( FT_Error ) FT_Raccess_Get_HeaderInfo( FT_Library library, FT_Stream stream, @@ -199,55 +179,54 @@ FT_BEGIN_HEADER FT_Long *rdata_pos ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Get_DataOffsets */ - /* */ - /* <Description> */ - /* Get the data offsets for a tag in a resource fork. Offsets are */ - /* stored in an array because, in some cases, resources in a resource */ - /* fork have the same tag. */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* map_offset :: */ - /* The file offset where the resource map starts. */ - /* */ - /* rdata_pos :: */ - /* The file offset where the resource data starts. */ - /* */ - /* tag :: */ - /* The resource tag. */ - /* */ - /* sort_by_res_id :: */ - /* A Boolean to sort the fragmented resource by their ids. */ - /* The fragmented resources for `POST' resource should be sorted */ - /* to restore Type1 font properly. For `sfnt' resources, sorting */ - /* may induce a different order of the faces in comparison to that */ - /* by QuickDraw API. */ - /* */ - /* <Output> */ - /* offsets :: */ - /* The stream offsets for the resource data specified by `tag'. */ - /* This array is allocated by the function, so you have to call */ - /* @ft_mem_free after use. */ - /* */ - /* count :: */ - /* The length of offsets array. */ - /* */ - /* <Return> */ - /* FreeType error code. FT_Err_Ok means success. */ - /* */ - /* <Note> */ - /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */ - /* value for `map_offset' and `rdata_pos'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Raccess_Get_DataOffsets + * + * @description: + * Get the data offsets for a tag in a resource fork. Offsets are stored + * in an array because, in some cases, resources in a resource fork have + * the same tag. + * + * @input: + * library :: + * A FreeType library instance. + * + * stream :: + * A file stream containing the resource fork. + * + * map_offset :: + * The file offset where the resource map starts. + * + * rdata_pos :: + * The file offset where the resource data starts. + * + * tag :: + * The resource tag. + * + * sort_by_res_id :: + * A Boolean to sort the fragmented resource by their ids. The + * fragmented resources for 'POST' resource should be sorted to restore + * Type1 font properly. For 'sfnt' resources, sorting may induce a + * different order of the faces in comparison to that by QuickDraw API. + * + * @output: + * offsets :: + * The stream offsets for the resource data specified by 'tag'. This + * array is allocated by the function, so you have to call @ft_mem_free + * after use. + * + * count :: + * The length of offsets array. + * + * @return: + * FreeType error code. FT_Err_Ok means success. + * + * @note: + * Normally you should use `FT_Raccess_Get_HeaderInfo` to get the value + * for `map_offset` and `rdata_pos`. + */ FT_BASE( FT_Error ) FT_Raccess_Get_DataOffsets( FT_Library library, FT_Stream stream, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h index e01c1679b51..8836cf3f18d 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftserv.h @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* ftserv.h */ -/* */ -/* The FreeType services (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Each module can export one or more `services'. Each service is */ - /* identified by a constant string and modeled by a pointer; the latter */ - /* generally corresponds to a structure containing function pointers. */ - /* */ - /* Note that a service's data cannot be a mere function pointer because */ - /* in C it is possible that function pointers might be implemented */ - /* differently than data pointers (e.g. 48 bits instead of 32). */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftserv.h + * + * The FreeType services (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Each module can export one or more 'services'. Each service is + * identified by a constant string and modeled by a pointer; the latter + * generally corresponds to a structure containing function pointers. + * + * Note that a service's data cannot be a mere function pointer because in + * C it is possible that function pointers might be implemented differently + * than data pointers (e.g. 48 bits instead of 32). + * + */ #ifndef FTSERV_H_ @@ -34,7 +34,8 @@ FT_BEGIN_HEADER - /* + /************************************************************************** + * * @macro: * FT_FACE_FIND_SERVICE * @@ -46,15 +47,15 @@ FT_BEGIN_HEADER * The source face handle. * * id :: - * A string describing the service as defined in the service's - * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It is automatically prefixed with - * `FT_SERVICE_ID_'. + * A string describing the service as defined in the service's header + * files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to + * 'multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_`. * * @output: * ptr :: - * A variable that receives the service pointer. Will be NULL - * if not found. + * A variable that receives the service pointer. Will be `NULL` if not + * found. */ #ifdef __cplusplus @@ -85,7 +86,8 @@ FT_BEGIN_HEADER #endif /* !C++ */ - /* + /************************************************************************** + * * @macro: * FT_FACE_FIND_GLOBAL_SERVICE * @@ -97,15 +99,15 @@ FT_BEGIN_HEADER * The source face handle. * * id :: - * A string describing the service as defined in the service's - * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It is automatically prefixed with - * `FT_SERVICE_ID_'. + * A string describing the service as defined in the service's header + * files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to + * 'multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_`. * * @output: * ptr :: - * A variable that receives the service pointer. Will be NULL - * if not found. + * A variable that receives the service pointer. Will be `NULL` if not + * found. */ #ifdef __cplusplus @@ -144,8 +146,8 @@ FT_BEGIN_HEADER /*************************************************************************/ /* - * The following structure is used to _describe_ a given service - * to the library. This is useful to build simple static service lists. + * The following structure is used to _describe_ a given service to the + * library. This is useful to build simple static service lists. */ typedef struct FT_ServiceDescRec_ { @@ -157,35 +159,26 @@ FT_BEGIN_HEADER typedef const FT_ServiceDescRec* FT_ServiceDesc; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_SERVICEDESCREC1 */ - /* FT_DEFINE_SERVICEDESCREC2 */ - /* FT_DEFINE_SERVICEDESCREC3 */ - /* FT_DEFINE_SERVICEDESCREC4 */ - /* FT_DEFINE_SERVICEDESCREC5 */ - /* FT_DEFINE_SERVICEDESCREC6 */ - /* FT_DEFINE_SERVICEDESCREC7 */ - /* FT_DEFINE_SERVICEDESCREC8 */ - /* */ - /* <Description> */ - /* Used to initialize an array of FT_ServiceDescRec structures. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs to */ - /* be called with a pointer to return an allocated array. As soon as */ - /* it is no longer needed, a `destroy' function needs to be called to */ - /* release that allocation. */ - /* */ - /* These functions should be manually called from the `pic_init' and */ - /* `pic_free' functions of your module (see FT_DEFINE_MODULE). */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the array will be */ - /* allocated in the global scope (or the scope where the macro is */ - /* used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DEFINE_SERVICEDESCREC1 + * FT_DEFINE_SERVICEDESCREC2 + * FT_DEFINE_SERVICEDESCREC3 + * FT_DEFINE_SERVICEDESCREC4 + * FT_DEFINE_SERVICEDESCREC5 + * FT_DEFINE_SERVICEDESCREC6 + * FT_DEFINE_SERVICEDESCREC7 + * FT_DEFINE_SERVICEDESCREC8 + * FT_DEFINE_SERVICEDESCREC9 + * FT_DEFINE_SERVICEDESCREC10 + * + * @description: + * Used to initialize an array of FT_ServiceDescRec structures. + * + * The array will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DEFINE_SERVICEDESCREC1( class_, \ serv_id_1, serv_data_1 ) \ static const FT_ServiceDescRec class_[] = \ @@ -356,504 +349,15 @@ FT_BEGIN_HEADER { NULL, NULL } \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICEDESCREC1( class_, \ - serv_id_1, serv_data_1 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 2 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = NULL; \ - clazz[1].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC2( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 3 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = NULL; \ - clazz[2].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC3( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 4 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = NULL; \ - clazz[3].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC4( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 5 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = NULL; \ - clazz[4].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC5( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 6 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = NULL; \ - clazz[5].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC6( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 7 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = NULL; \ - clazz[6].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC7( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 8 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = NULL; \ - clazz[7].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC8( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7, \ - serv_id_8, serv_data_8 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 9 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = serv_id_8; \ - clazz[7].serv_data = serv_data_8; \ - clazz[8].serv_id = NULL; \ - clazz[8].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC9( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7, \ - serv_id_8, serv_data_8, \ - serv_id_9, serv_data_9 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 10 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = serv_id_8; \ - clazz[7].serv_data = serv_data_8; \ - clazz[8].serv_id = serv_id_9; \ - clazz[8].serv_data = serv_data_9; \ - clazz[9].serv_id = NULL; \ - clazz[9].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC10( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7, \ - serv_id_8, serv_data_8, \ - serv_id_9, serv_data_9, \ - serv_id_10, serv_data_10 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 11 ) ) \ - return error; \ - \ - clazz[ 0].serv_id = serv_id_1; \ - clazz[ 0].serv_data = serv_data_1; \ - clazz[ 1].serv_id = serv_id_2; \ - clazz[ 1].serv_data = serv_data_2; \ - clazz[ 2].serv_id = serv_id_3; \ - clazz[ 2].serv_data = serv_data_3; \ - clazz[ 3].serv_id = serv_id_4; \ - clazz[ 3].serv_data = serv_data_4; \ - clazz[ 4].serv_id = serv_id_5; \ - clazz[ 4].serv_data = serv_data_5; \ - clazz[ 5].serv_id = serv_id_6; \ - clazz[ 5].serv_data = serv_data_6; \ - clazz[ 6].serv_id = serv_id_7; \ - clazz[ 6].serv_data = serv_data_7; \ - clazz[ 7].serv_id = serv_id_8; \ - clazz[ 7].serv_data = serv_data_8; \ - clazz[ 8].serv_id = serv_id_9; \ - clazz[ 8].serv_data = serv_data_9; \ - clazz[ 9].serv_id = serv_id_10; \ - clazz[ 9].serv_data = serv_data_10; \ - clazz[10].serv_id = NULL; \ - clazz[10].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* - * Parse a list of FT_ServiceDescRec descriptors and look for - * a specific service by ID. Note that the last element in the - * array must be { NULL, NULL }, and that the function should - * return NULL if the service isn't available. + * Parse a list of FT_ServiceDescRec descriptors and look for a specific + * service by ID. Note that the last element in the array must be { NULL, + * NULL }, and that the function should return NULL if the service isn't + * available. * - * This function can be used by modules to implement their - * `get_service' method. + * This function can be used by modules to implement their `get_service' + * method. */ FT_BASE( FT_Pointer ) ft_service_list_lookup( FT_ServiceDesc service_descriptors, @@ -869,16 +373,16 @@ FT_BEGIN_HEADER /*************************************************************************/ /* - * This structure is used to store a cache for several frequently used - * services. It is the type of `face->internal->services'. You - * should only use FT_FACE_LOOKUP_SERVICE to access it. + * This structure is used to store a cache for several frequently used + * services. It is the type of `face->internal->services'. You should + * only use FT_FACE_LOOKUP_SERVICE to access it. * - * All fields should have the type FT_Pointer to relax compilation - * dependencies. We assume the developer isn't completely stupid. + * All fields should have the type FT_Pointer to relax compilation + * dependencies. We assume the developer isn't completely stupid. * - * Each field must be named `service_XXXX' where `XXX' corresponds to - * the correct FT_SERVICE_ID_XXXX macro. See the definition of - * FT_FACE_LOOKUP_SERVICE below how this is implemented. + * Each field must be named `service_XXXX' where `XXX' corresponds to the + * correct FT_SERVICE_ID_XXXX macro. See the definition of + * FT_FACE_LOOKUP_SERVICE below how this is implemented. * */ typedef struct FT_ServiceCacheRec_ @@ -894,14 +398,15 @@ FT_BEGIN_HEADER /* - * A magic number used within the services cache. + * A magic number used within the services cache. */ /* ensure that value `1' has the same width as a pointer */ #define FT_SERVICE_UNAVAILABLE ((FT_Pointer)~(FT_PtrDist)1) - /* + /************************************************************************** + * * @macro: * FT_FACE_LOOKUP_SERVICE * @@ -910,7 +415,7 @@ FT_BEGIN_HEADER * using its cache. * * @input: - * face:: + * face :: * The source face handle containing the cache. * * field :: @@ -921,7 +426,7 @@ FT_BEGIN_HEADER * * @output: * ptr :: - * A variable receiving the service data. NULL if not available. + * A variable receiving the service data. `NULL` if not available. */ #ifdef __cplusplus @@ -969,7 +474,7 @@ FT_BEGIN_HEADER #endif /* !C++ */ /* - * A macro used to define new service structure types. + * A macro used to define new service structure types. */ #define FT_DEFINE_SERVICE( name ) \ @@ -982,7 +487,7 @@ FT_BEGIN_HEADER /* */ /* - * The header files containing the services. + * The header files containing the services. */ #define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h> diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h index f90002fe774..e4dca0b0a5d 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftstream.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstream.h */ -/* */ -/* Stream handling (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstream.h + * + * Stream handling (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSTREAM_H_ @@ -96,13 +96,13 @@ FT_BEGIN_HEADER /* The structure type must be set in the FT_STRUCTURE macro before */ /* calling the FT_FRAME_START() macro. */ /* */ -#define FT_FIELD_SIZE( f ) \ +#define FT_FIELD_SIZE( f ) \ (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) -#define FT_FIELD_SIZE_DELTA( f ) \ +#define FT_FIELD_SIZE_DELTA( f ) \ (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) -#define FT_FIELD_OFFSET( f ) \ +#define FT_FIELD_OFFSET( f ) \ (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) #define FT_FRAME_FIELD( frame_op, field ) \ @@ -147,11 +147,11 @@ FT_BEGIN_HEADER #define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } - /*************************************************************************/ - /* */ - /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ - /* type `char*' or equivalent (1-byte elements). */ - /* */ + /************************************************************************** + * + * Integer extraction macros -- the 'buffer' parameter must ALWAYS be of + * type 'char*' or equivalent (1-byte elements). + */ #define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) @@ -165,6 +165,10 @@ FT_BEGIN_HEADER #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) + /* + * `FT_PEEK_XXX' are generic macros to get data from a buffer position. No + * safety checks are performed. + */ #define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \ FT_BYTE_U16( p, 1, 0 ) ) @@ -213,7 +217,10 @@ FT_BEGIN_HEADER FT_BYTE_U32( p, 1, 8 ) | \ FT_BYTE_U32( p, 0, 0 ) ) - + /* + * `FT_NEXT_XXX' are generic macros to get data from a buffer position + * which is then increased appropriately. No safety checks are performed. + */ #define FT_NEXT_CHAR( buffer ) \ ( (signed char)*buffer++ ) @@ -258,10 +265,14 @@ FT_BEGIN_HEADER ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) - /*************************************************************************/ - /* */ - /* Each GET_xxxx() macro uses an implicit `stream' variable. */ - /* */ + /************************************************************************** + * + * The `FT_GET_XXX` macros use an implicit 'stream' variable. + * + * Note that a call to `FT_STREAM_SEEK` or `FT_STREAM_POS` has **no** + * effect on `FT_GET_XXX`! They operate on `stream->pos`, while + * `FT_GET_XXX` use `stream->cursor`. + */ #if 0 #define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor ) @@ -299,10 +310,18 @@ FT_BEGIN_HEADER #define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong ) #endif + #define FT_READ_MACRO( func, type, var ) \ ( var = (type)func( stream, &error ), \ error != FT_Err_Ok ) + /* + * The `FT_READ_XXX' macros use implicit `stream' and `error' variables. + * + * `FT_READ_XXX' can be controlled with `FT_STREAM_SEEK' and + * `FT_STREAM_POS'. They use the full machinery to check whether a read is + * valid. + */ #define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) #define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) #define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var ) @@ -387,12 +406,14 @@ FT_BEGIN_HEADER /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ /* error if the frame could not be read/accessed. The caller can use */ - /* the FT_Stream_Get_XXX functions to retrieve frame data without */ + /* the `FT_Stream_GetXXX' functions to retrieve frame data without */ /* error checks. */ /* */ - /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ + /* You must _always_ call `FT_Stream_ExitFrame' once you have entered */ /* a stream frame! */ /* */ + /* Nested frames are not permitted. */ + /* */ FT_BASE( FT_Error ) FT_Stream_EnterFrame( FT_Stream stream, FT_ULong count ); @@ -401,25 +422,29 @@ FT_BEGIN_HEADER FT_BASE( void ) FT_Stream_ExitFrame( FT_Stream stream ); + /* Extract a stream frame. If the stream is disk-based, a heap block */ /* is allocated and the frame bytes are read into it. If the stream */ - /* is memory-based, this function simply set a pointer to the data. */ + /* is memory-based, this function simply sets a pointer to the data. */ /* */ /* Useful to optimize access to memory-based streams transparently. */ /* */ - /* All extracted frames must be `freed' with a call to the function */ - /* FT_Stream_ReleaseFrame(). */ + /* `FT_Stream_GetXXX' functions can't be used. */ + /* */ + /* An extracted frame must be `freed' with a call to the function */ + /* `FT_Stream_ReleaseFrame'. */ /* */ FT_BASE( FT_Error ) FT_Stream_ExtractFrame( FT_Stream stream, FT_ULong count, FT_Byte** pbytes ); - /* release an extract frame (see FT_Stream_ExtractFrame) */ + /* release an extract frame (see `FT_Stream_ExtractFrame') */ FT_BASE( void ) FT_Stream_ReleaseFrame( FT_Stream stream, FT_Byte** pbytes ); + /* read a byte from an entered frame */ FT_BASE( FT_Char ) FT_Stream_GetChar( FT_Stream stream ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h index 8092e41fd73..8089babfb6c 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/fttrace.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttrace.h */ -/* */ -/* Tracing handling (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttrace.h + * + * Tracing handling (specification only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* definitions of trace levels for FreeType 2 */ @@ -23,23 +23,24 @@ FT_TRACE_DEF( any ) /* base components */ FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */ +FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ +FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */ -FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ +FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */ FT_TRACE_DEF( list ) /* list management (ftlist.c) */ -FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ -FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ -FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ +FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ -FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ -FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ +FT_TRACE_DEF( bitmap ) /* bitmap manipulation (ftbitmap.c) */ +FT_TRACE_DEF( checksum ) /* bitmap checksum (ftobjs.c) */ FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ +FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */ FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ +FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ +FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ -FT_TRACE_DEF( bitmap ) /* bitmap checksum (ftobjs.c) */ -FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */ /* Cache sub-system */ FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ @@ -47,21 +48,23 @@ FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ /* SFNT driver components */ FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */ FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ +FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ +FT_TRACE_DEF( ttcolr ) /* glyph layer table (ttcolr.c) */ +FT_TRACE_DEF( ttcpal ) /* color palette table (ttcpal.c) */ FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ -FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ /* TrueType driver components */ FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */ +FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */ FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */ FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */ -FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ /* Type 1 driver components */ FT_TRACE_DEF( t1afm ) @@ -72,14 +75,14 @@ FT_TRACE_DEF( t1objs ) FT_TRACE_DEF( t1parse ) /* PostScript helper module `psaux' */ -FT_TRACE_DEF( t1decode ) FT_TRACE_DEF( cffdecode ) -FT_TRACE_DEF( psobjs ) FT_TRACE_DEF( psconv ) +FT_TRACE_DEF( psobjs ) +FT_TRACE_DEF( t1decode ) /* PostScript hinting module `pshinter' */ -FT_TRACE_DEF( pshrec ) FT_TRACE_DEF( pshalgo ) +FT_TRACE_DEF( pshrec ) /* Type 2 driver components */ FT_TRACE_DEF( cffdriver ) @@ -117,7 +120,6 @@ FT_TRACE_DEF( bdflib ) FT_TRACE_DEF( pfr ) /* OpenType validation components */ -FT_TRACE_DEF( otvmodule ) FT_TRACE_DEF( otvcommon ) FT_TRACE_DEF( otvbase ) FT_TRACE_DEF( otvgdef ) @@ -125,29 +127,30 @@ FT_TRACE_DEF( otvgpos ) FT_TRACE_DEF( otvgsub ) FT_TRACE_DEF( otvjstf ) FT_TRACE_DEF( otvmath ) +FT_TRACE_DEF( otvmodule ) /* TrueTypeGX/AAT validation components */ -FT_TRACE_DEF( gxvmodule ) +FT_TRACE_DEF( gxvbsln ) FT_TRACE_DEF( gxvcommon ) FT_TRACE_DEF( gxvfeat ) -FT_TRACE_DEF( gxvmort ) -FT_TRACE_DEF( gxvmorx ) -FT_TRACE_DEF( gxvbsln ) FT_TRACE_DEF( gxvjust ) FT_TRACE_DEF( gxvkern ) +FT_TRACE_DEF( gxvmodule ) +FT_TRACE_DEF( gxvmort ) +FT_TRACE_DEF( gxvmorx ) +FT_TRACE_DEF( gxvlcar ) FT_TRACE_DEF( gxvopbd ) -FT_TRACE_DEF( gxvtrak ) FT_TRACE_DEF( gxvprop ) -FT_TRACE_DEF( gxvlcar ) +FT_TRACE_DEF( gxvtrak ) /* autofit components */ -FT_TRACE_DEF( afmodule ) -FT_TRACE_DEF( afhints ) FT_TRACE_DEF( afcjk ) +FT_TRACE_DEF( afglobal ) +FT_TRACE_DEF( afhints ) +FT_TRACE_DEF( afmodule ) FT_TRACE_DEF( aflatin ) FT_TRACE_DEF( aflatin2 ) -FT_TRACE_DEF( afwarp ) FT_TRACE_DEF( afshaper ) -FT_TRACE_DEF( afglobal ) +FT_TRACE_DEF( afwarp ) /* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h index cad47a556d3..38aa06cc4e9 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftvalid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftvalid.h */ -/* */ -/* FreeType validation support (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftvalid.h + * + * FreeType validation support (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTVALID_H_ @@ -42,31 +42,31 @@ FT_BEGIN_HEADER typedef struct FT_ValidatorRec_ volatile* FT_Validator; - /*************************************************************************/ - /* */ - /* There are three distinct validation levels defined here: */ - /* */ - /* FT_VALIDATE_DEFAULT :: */ - /* A table that passes this validation level can be used reliably by */ - /* FreeType. It generally means that all offsets have been checked to */ - /* prevent out-of-bound reads, that array counts are correct, etc. */ - /* */ - /* FT_VALIDATE_TIGHT :: */ - /* A table that passes this validation level can be used reliably and */ - /* doesn't contain invalid data. For example, a charmap table that */ - /* returns invalid glyph indices will not pass, even though it can */ - /* be used with FreeType in default mode (the library will simply */ - /* return an error later when trying to load the glyph). */ - /* */ - /* It also checks that fields which must be a multiple of 2, 4, or 8, */ - /* don't have incorrect values, etc. */ - /* */ - /* FT_VALIDATE_PARANOID :: */ - /* Only for font debugging. Checks that a table follows the */ - /* specification by 100%. Very few fonts will be able to pass this */ - /* level anyway but it can be useful for certain tools like font */ - /* editors/converters. */ - /* */ + /************************************************************************** + * + * There are three distinct validation levels defined here: + * + * FT_VALIDATE_DEFAULT :: + * A table that passes this validation level can be used reliably by + * FreeType. It generally means that all offsets have been checked to + * prevent out-of-bound reads, that array counts are correct, etc. + * + * FT_VALIDATE_TIGHT :: + * A table that passes this validation level can be used reliably and + * doesn't contain invalid data. For example, a charmap table that + * returns invalid glyph indices will not pass, even though it can be + * used with FreeType in default mode (the library will simply return an + * error later when trying to load the glyph). + * + * It also checks that fields which must be a multiple of 2, 4, or 8, + * don't have incorrect values, etc. + * + * FT_VALIDATE_PARANOID :: + * Only for font debugging. Checks that a table follows the + * specification by 100%. Very few fonts will be able to pass this level + * anyway but it can be useful for certain tools like font + * editors/converters. + */ typedef enum FT_ValidationLevel_ { FT_VALIDATE_DEFAULT = 0, diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/internal.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/internal.h index 8f546e443ba..173d8ad906d 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/internal.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/internal.h @@ -1,31 +1,30 @@ -/***************************************************************************/ -/* */ -/* internal.h */ -/* */ -/* Internal header files (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * internal.h + * + * Internal header files (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ - /*************************************************************************/ - /* */ - /* This file is automatically included by `ft2build.h'. */ - /* Do not include it manually! */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is automatically included by `ft2build.h`. Do not include it + * manually! + * + */ #define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h> -#define FT_INTERNAL_PIC_H <freetype/internal/ftpic.h> #define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h> #define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h> #define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h> diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h index f77380d25ff..3ab01c3e688 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/psaux.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* psaux.h */ -/* */ -/* Auxiliary functions and data structures related to PostScript fonts */ -/* (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psaux.h + * + * Auxiliary functions and data structures related to PostScript fonts + * (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSAUX_H_ @@ -35,10 +35,10 @@ FT_BEGIN_HEADER - /***********************************************************************/ - /* */ - /* PostScript modules driver class. */ - /* */ + /************************************************************************** + * + * PostScript modules driver class. + */ typedef struct PS_DriverRec_ { FT_DriverRec root; @@ -64,23 +64,27 @@ FT_BEGIN_HEADER typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Table_FuncsRec */ - /* */ - /* <Description> */ - /* A set of function pointers to manage PS_Table objects. */ - /* */ - /* <Fields> */ - /* table_init :: Used to initialize a table. */ - /* */ - /* table_done :: Finalizes resp. destroy a given table. */ - /* */ - /* table_add :: Adds a new object to a table. */ - /* */ - /* table_release :: Releases table data, then finalizes it. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_Table_FuncsRec + * + * @description: + * A set of function pointers to manage PS_Table objects. + * + * @fields: + * table_init :: + * Used to initialize a table. + * + * table_done :: + * Finalizes resp. destroy a given table. + * + * table_add :: + * Adds a new object to a table. + * + * table_release :: + * Releases table data, then finalizes it. + */ typedef struct PS_Table_FuncsRec_ { FT_Error @@ -103,41 +107,47 @@ FT_BEGIN_HEADER } PS_Table_FuncsRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_TableRec */ - /* */ - /* <Description> */ - /* A PS_Table is a simple object used to store an array of objects in */ - /* a single memory block. */ - /* */ - /* <Fields> */ - /* block :: The address in memory of the growheap's block. This */ - /* can change between two object adds, due to */ - /* reallocation. */ - /* */ - /* cursor :: The current top of the grow heap within its block. */ - /* */ - /* capacity :: The current size of the heap block. Increments by */ - /* 1kByte chunks. */ - /* */ - /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */ - /* been allocated. */ - /* */ - /* max_elems :: The maximum number of elements in table. */ - /* */ - /* num_elems :: The current number of elements in table. */ - /* */ - /* elements :: A table of element addresses within the block. */ - /* */ - /* lengths :: A table of element sizes within the block. */ - /* */ - /* memory :: The object used for memory operations */ - /* (alloc/realloc). */ - /* */ - /* funcs :: A table of method pointers for this object. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_TableRec + * + * @description: + * A PS_Table is a simple object used to store an array of objects in a + * single memory block. + * + * @fields: + * block :: + * The address in memory of the growheap's block. This can change + * between two object adds, due to reallocation. + * + * cursor :: + * The current top of the grow heap within its block. + * + * capacity :: + * The current size of the heap block. Increments by 1kByte chunks. + * + * init :: + * Set to 0xDEADBEEF if 'elements' and 'lengths' have been allocated. + * + * max_elems :: + * The maximum number of elements in table. + * + * num_elems :: + * The current number of elements in table. + * + * elements :: + * A table of element addresses within the block. + * + * lengths :: + * A table of element sizes within the block. + * + * memory :: + * The object used for memory operations (alloc/realloc). + * + * funcs :: + * A table of method pointers for this object. + */ typedef struct PS_TableRec_ { FT_Byte* block; /* current memory block */ @@ -425,27 +435,33 @@ FT_BEGIN_HEADER } PS_Parser_FuncsRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_ParserRec */ - /* */ - /* <Description> */ - /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ - /* */ - /* <Fields> */ - /* cursor :: The current position in the text. */ - /* */ - /* base :: Start of the processed text. */ - /* */ - /* limit :: End of the processed text. */ - /* */ - /* error :: The last error returned. */ - /* */ - /* memory :: The object used for memory operations (alloc/realloc). */ - /* */ - /* funcs :: A table of functions for the parser. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_ParserRec + * + * @description: + * A PS_Parser is an object used to parse a Type 1 font very quickly. + * + * @fields: + * cursor :: + * The current position in the text. + * + * base :: + * Start of the processed text. + * + * limit :: + * End of the processed text. + * + * error :: + * The last error returned. + * + * memory :: + * The object used for memory operations (alloc/realloc). + * + * funcs :: + * A table of functions for the parser. + */ typedef struct PS_ParserRec_ { FT_Byte* cursor; @@ -484,51 +500,67 @@ FT_BEGIN_HEADER } PS_Builder_FuncsRec; - /*************************************************************************/ - /* */ - /* <Structure> */ - /* PS_Builder */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: XXX */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* path_begun :: A flag which indicates that a new path has begun. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* is_t1 :: Set if current font type is Type 1. */ - /* */ - /* funcs :: An array of function pointers for the builder. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_Builder + * + * @description: + * A structure used during glyph loading to store its outline. + * + * @fields: + * memory :: + * The current memory object. + * + * face :: + * The current face object. + * + * glyph :: + * The current glyph slot. + * + * loader :: + * XXX + * + * base :: + * The base glyph outline. + * + * current :: + * The current glyph outline. + * + * pos_x :: + * The horizontal translation (if composite glyph). + * + * pos_y :: + * The vertical translation (if composite glyph). + * + * left_bearing :: + * The left side bearing point. + * + * advance :: + * The horizontal advance vector. + * + * bbox :: + * Unused. + * + * path_begun :: + * A flag which indicates that a new path has begun. + * + * load_points :: + * If this flag is not set, no points are loaded. + * + * no_recurse :: + * Set but not used. + * + * metrics_only :: + * A boolean indicating that we only want to compute the metrics of a + * given glyph, not load all of its points. + * + * is_t1 :: + * Set if current font type is Type 1. + * + * funcs :: + * An array of function pointers for the builder. + */ struct PS_Builder_ { FT_Memory memory; @@ -729,54 +761,70 @@ FT_BEGIN_HEADER } T1_ParseState; - /*************************************************************************/ - /* */ - /* <Structure> */ - /* T1_BuilderRec */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: XXX */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* max_points :: maximum points in builder outline */ - /* */ - /* max_contours :: Maximum number of contours in builder outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* parse_state :: An enumeration which controls the charstring */ - /* parsing state. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* funcs :: An array of function pointers for the builder. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_BuilderRec + * + * @description: + * A structure used during glyph loading to store its outline. + * + * @fields: + * memory :: + * The current memory object. + * + * face :: + * The current face object. + * + * glyph :: + * The current glyph slot. + * + * loader :: + * XXX + * + * base :: + * The base glyph outline. + * + * current :: + * The current glyph outline. + * + * max_points :: + * maximum points in builder outline + * + * max_contours :: + * Maximum number of contours in builder outline. + * + * pos_x :: + * The horizontal translation (if composite glyph). + * + * pos_y :: + * The vertical translation (if composite glyph). + * + * left_bearing :: + * The left side bearing point. + * + * advance :: + * The horizontal advance vector. + * + * bbox :: + * Unused. + * + * parse_state :: + * An enumeration which controls the charstring parsing state. + * + * load_points :: + * If this flag is not set, no points are loaded. + * + * no_recurse :: + * Set but not used. + * + * metrics_only :: + * A boolean indicating that we only want to compute the metrics of a + * given glyph, not load all of its points. + * + * funcs :: + * An array of function pointers for the builder. + */ typedef struct T1_BuilderRec_ { FT_Memory memory; @@ -817,19 +865,19 @@ FT_BEGIN_HEADER #if 0 - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ + /************************************************************************** + * + * T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine + * calls during glyph loading. + */ #define T1_MAX_SUBRS_CALLS 8 - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ + /************************************************************************** + * + * T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A + * minimum of 16 is required. + */ #define T1_MAX_CHARSTRINGS_OPERANDS 32 #endif /* 0 */ @@ -993,53 +1041,70 @@ FT_BEGIN_HEADER } CFF_Builder_FuncsRec; - /*************************************************************************/ - /* */ - /* <Structure> */ - /* CFF_Builder */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: The current glyph loader. */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* path_begun :: A flag which indicates that a new path has begun. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* hints_funcs :: Auxiliary pointer for hinting. */ - /* */ - /* hints_globals :: Auxiliary pointer for hinting. */ - /* */ - /* funcs :: A table of method pointers for this object. */ - /* */ + /************************************************************************** + * + * @struct: + * CFF_Builder + * + * @description: + * A structure used during glyph loading to store its outline. + * + * @fields: + * memory :: + * The current memory object. + * + * face :: + * The current face object. + * + * glyph :: + * The current glyph slot. + * + * loader :: + * The current glyph loader. + * + * base :: + * The base glyph outline. + * + * current :: + * The current glyph outline. + * + * pos_x :: + * The horizontal translation (if composite glyph). + * + * pos_y :: + * The vertical translation (if composite glyph). + * + * left_bearing :: + * The left side bearing point. + * + * advance :: + * The horizontal advance vector. + * + * bbox :: + * Unused. + * + * path_begun :: + * A flag which indicates that a new path has begun. + * + * load_points :: + * If this flag is not set, no points are loaded. + * + * no_recurse :: + * Set but not used. + * + * metrics_only :: + * A boolean indicating that we only want to compute the metrics of a + * given glyph, not load all of its points. + * + * hints_funcs :: + * Auxiliary pointer for hinting. + * + * hints_globals :: + * Auxiliary pointer for hinting. + * + * funcs :: + * A table of method pointers for this object. + */ struct CFF_Builder_ { FT_Memory memory; @@ -1211,25 +1276,27 @@ FT_BEGIN_HEADER typedef struct AFM_StreamRec_* AFM_Stream; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AFM_ParserRec */ - /* */ - /* <Description> */ - /* An AFM_Parser is a parser for the AFM files. */ - /* */ - /* <Fields> */ - /* memory :: The object used for memory operations (alloc and */ - /* realloc). */ - /* */ - /* stream :: This is an opaque object. */ - /* */ - /* FontInfo :: The result will be stored here. */ - /* */ - /* get_index :: A user provided function to get a glyph index by its */ - /* name. */ - /* */ + /************************************************************************** + * + * @struct: + * AFM_ParserRec + * + * @description: + * An AFM_Parser is a parser for the AFM files. + * + * @fields: + * memory :: + * The object used for memory operations (alloc and realloc). + * + * stream :: + * This is an opaque object. + * + * FontInfo :: + * The result will be stored here. + * + * get_index :: + * A user provided function to get a glyph index by its name. + */ typedef struct AFM_ParserRec_ { FT_Memory memory; diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h index d29314ec2ef..699acea6f52 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/pshints.h @@ -1,21 +1,21 @@ -/***************************************************************************/ -/* */ -/* pshints.h */ -/* */ -/* Interface to Postscript-specific (Type 1 and Type 2) hints */ -/* recorders (specification only). These are used to support native */ -/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshints.h + * + * Interface to Postscript-specific (Type 1 and Type 2) hints + * recorders (specification only). These are used to support native + * T1/T2 hints in the 'type1', 'cid', and 'cff' font drivers. + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHINTS_H_ @@ -73,7 +73,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /************************************************************************* + /************************************************************************** * * @type: * T1_Hints @@ -86,16 +86,16 @@ FT_BEGIN_HEADER * @T1_Hints_FuncsRec structure. Recording glyph hints is normally * achieved through the following scheme: * - * - Open a new hint recording session by calling the `open' method. + * - Open a new hint recording session by calling the 'open' method. * This rewinds the recorder and prepare it for new input. * * - For each hint found in the glyph charstring, call the corresponding - * method (`stem', `stem3', or `reset'). Note that these functions do + * method ('stem', 'stem3', or 'reset'). Note that these functions do * not return an error code. * - * - Close the recording session by calling the `close' method. It - * returns an error code if the hints were invalid or something - * strange happened (e.g., memory shortage). + * - Close the recording session by calling the 'close' method. It + * returns an error code if the hints were invalid or something strange + * happened (e.g., memory shortage). * * The hints accumulated in the object can later be used by the * PostScript hinter. @@ -104,7 +104,7 @@ FT_BEGIN_HEADER typedef struct T1_HintsRec_* T1_Hints; - /************************************************************************* + /************************************************************************** * * @type: * T1_Hints_Funcs @@ -117,7 +117,7 @@ FT_BEGIN_HEADER typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs; - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_OpenFunc @@ -139,14 +139,14 @@ FT_BEGIN_HEADER (*T1_Hints_OpenFunc)( T1_Hints hints ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_SetStemFunc * * @description: * A method of the @T1_Hints class used to record a new horizontal or - * vertical stem. This corresponds to the Type 1 `hstem' and `vstem' + * vertical stem. This corresponds to the Type 1 'hstem' and 'vstem' * operators. * * @input: @@ -164,15 +164,15 @@ FT_BEGIN_HEADER * Use vertical coordinates (y) for horizontal stems (dim=0). Use * horizontal coordinates (x) for vertical stems (dim=1). * - * `coords[0]' is the absolute stem position (lowest coordinate); - * `coords[1]' is the length. + * 'coords[0]' is the absolute stem position (lowest coordinate); + * 'coords[1]' is the length. * * The length can be negative, in which case it must be either -20 or - * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * -21. It is interpreted as a 'ghost' stem, according to the Type 1 * specification. * - * If the length is -21 (corresponding to a bottom ghost stem), then - * the real stem position is `coords[0]+coords[1]'. + * If the length is -21 (corresponding to a bottom ghost stem), then the + * real stem position is 'coords[0]+coords[1]'. * */ typedef void @@ -181,7 +181,7 @@ FT_BEGIN_HEADER FT_Fixed* coords ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_SetStem3Func @@ -215,7 +215,7 @@ FT_BEGIN_HEADER FT_Fixed* coords ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_ResetFunc @@ -238,7 +238,7 @@ FT_BEGIN_HEADER FT_UInt end_point ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_CloseFunc @@ -267,7 +267,7 @@ FT_BEGIN_HEADER FT_UInt end_point ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_ApplyFunc @@ -297,7 +297,7 @@ FT_BEGIN_HEADER * On input, all points within the outline are in font coordinates. On * output, they are in 1/64th of pixels. * - * The scaling transformation is taken from the `globals' object which + * The scaling transformation is taken from the 'globals' object which * must correspond to the same font as the glyph. * */ @@ -308,7 +308,7 @@ FT_BEGIN_HEADER FT_Render_Mode hint_mode ); - /************************************************************************* + /************************************************************************** * * @struct: * T1_Hints_FuncsRec @@ -360,7 +360,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /************************************************************************* + /************************************************************************** * * @type: * T2_Hints @@ -373,16 +373,16 @@ FT_BEGIN_HEADER * @T2_Hints_FuncsRec structure. Recording glyph hints is normally * achieved through the following scheme: * - * - Open a new hint recording session by calling the `open' method. + * - Open a new hint recording session by calling the 'open' method. * This rewinds the recorder and prepare it for new input. * * - For each hint found in the glyph charstring, call the corresponding - * method (`stems', `hintmask', `counters'). Note that these - * functions do not return an error code. + * method ('stems', 'hintmask', 'counters'). Note that these functions + * do not return an error code. * - * - Close the recording session by calling the `close' method. It - * returns an error code if the hints were invalid or something - * strange happened (e.g., memory shortage). + * - Close the recording session by calling the 'close' method. It + * returns an error code if the hints were invalid or something strange + * happened (e.g., memory shortage). * * The hints accumulated in the object can later be used by the * Postscript hinter. @@ -391,7 +391,7 @@ FT_BEGIN_HEADER typedef struct T2_HintsRec_* T2_Hints; - /************************************************************************* + /************************************************************************** * * @type: * T2_Hints_Funcs @@ -404,7 +404,7 @@ FT_BEGIN_HEADER typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs; - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_OpenFunc @@ -426,7 +426,7 @@ FT_BEGIN_HEADER (*T2_Hints_OpenFunc)( T2_Hints hints ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_StemsFunc @@ -434,7 +434,7 @@ FT_BEGIN_HEADER * @description: * A method of the @T2_Hints class used to set the table of stems in * either the vertical or horizontal dimension. Equivalent to the - * `hstem', `vstem', `hstemhm', and `vstemhm' Type 2 operators. + * 'hstem', 'vstem', 'hstemhm', and 'vstemhm' Type 2 operators. * * @input: * hints :: @@ -447,18 +447,18 @@ FT_BEGIN_HEADER * The number of stems. * * coords :: - * An array of `count' (position,length) pairs in 16.16 format. + * An array of 'count' (position,length) pairs in 16.16 format. * * @note: * Use vertical coordinates (y) for horizontal stems (dim=0). Use * horizontal coordinates (x) for vertical stems (dim=1). * - * There are `2*count' elements in the `coords' array. Each even - * element is an absolute position in font units, each odd element is a - * length in font units. + * There are '2*count' elements in the 'coords' array. Each even element + * is an absolute position in font units, each odd element is a length in + * font units. * - * A length can be negative, in which case it must be either -20 or - * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * A length can be negative, in which case it must be either -20 or -21. + * It is interpreted as a 'ghost' stem, according to the Type 1 * specification. * */ @@ -469,22 +469,22 @@ FT_BEGIN_HEADER FT_Fixed* coordinates ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_MaskFunc * * @description: * A method of the @T2_Hints class used to set a given hintmask (this - * corresponds to the `hintmask' Type 2 operator). + * corresponds to the 'hintmask' Type 2 operator). * * @input: * hints :: * A handle to the Type 2 hints recorder. * * end_point :: - * The glyph index of the last point to which the previously defined - * or activated hints apply. + * The glyph index of the last point to which the previously defined or + * activated hints apply. * * bit_count :: * The number of bits in the hint mask. @@ -494,13 +494,13 @@ FT_BEGIN_HEADER * * @note: * If the hintmask starts the charstring (before any glyph point - * definition), the value of `end_point' should be 0. + * definition), the value of `end_point` should be 0. * - * `bit_count' is the number of meaningful bits in the `bytes' array; it + * `bit_count` is the number of meaningful bits in the 'bytes' array; it * must be equal to the total number of hints defined so far (i.e., * horizontal+verticals). * - * The `bytes' array can come directly from the Type 2 charstring and + * The 'bytes' array can come directly from the Type 2 charstring and * respects the same format. * */ @@ -511,14 +511,14 @@ FT_BEGIN_HEADER const FT_Byte* bytes ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_CounterFunc * * @description: - * A method of the @T2_Hints class used to set a given counter mask - * (this corresponds to the `hintmask' Type 2 operator). + * A method of the @T2_Hints class used to set a given counter mask (this + * corresponds to the 'hintmask' Type 2 operator). * * @input: * hints :: @@ -536,13 +536,13 @@ FT_BEGIN_HEADER * * @note: * If the hintmask starts the charstring (before any glyph point - * definition), the value of `end_point' should be 0. + * definition), the value of `end_point` should be 0. * - * `bit_count' is the number of meaningful bits in the `bytes' array; it + * `bit_count` is the number of meaningful bits in the 'bytes' array; it * must be equal to the total number of hints defined so far (i.e., * horizontal+verticals). * - * The `bytes' array can come directly from the Type 2 charstring and + * The 'bytes' array can come directly from the Type 2 charstring and * respects the same format. * */ @@ -552,7 +552,7 @@ FT_BEGIN_HEADER const FT_Byte* bytes ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_CloseFunc @@ -581,15 +581,14 @@ FT_BEGIN_HEADER FT_UInt end_point ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_ApplyFunc * * @description: * A method of the @T2_Hints class used to apply hints to the - * corresponding glyph outline. Must be called after the `close' - * method. + * corresponding glyph outline. Must be called after the 'close' method. * * @input: * hints :: @@ -611,7 +610,7 @@ FT_BEGIN_HEADER * On input, all points within the outline are in font coordinates. On * output, they are in 1/64th of pixels. * - * The scaling transformation is taken from the `globals' object which + * The scaling transformation is taken from the 'globals' object which * must correspond to the same font than the glyph. * */ @@ -622,7 +621,7 @@ FT_BEGIN_HEADER FT_Render_Mode hint_mode ); - /************************************************************************* + /************************************************************************** * * @struct: * T2_Hints_FuncsRec @@ -680,8 +679,6 @@ FT_BEGIN_HEADER typedef PSHinter_Interface* PSHinter_Service; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_PSHINTER_INTERFACE( \ class_, \ get_globals_funcs_, \ @@ -694,25 +691,6 @@ FT_BEGIN_HEADER get_t2_funcs_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_PSHINTER_INTERFACE( \ - class_, \ - get_globals_funcs_, \ - get_t1_funcs_, \ - get_t2_funcs_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - PSHinter_Interface* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_globals_funcs = get_globals_funcs_; \ - clazz->get_t1_funcs = get_t1_funcs_; \ - clazz->get_t2_funcs = get_t2_funcs_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h index 4a9ec200755..e4786ed0383 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svbdf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svbdf.h */ -/* */ -/* The FreeType BDF services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svbdf.h + * + * The FreeType BDF services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVBDF_H_ @@ -46,8 +46,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_BDFRec( class_, \ get_charset_id_, \ get_property_ ) \ @@ -56,20 +54,6 @@ FT_BEGIN_HEADER get_charset_id_, get_property_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_BDFRec( class_, \ - get_charset_id_, \ - get_property_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_BDFRec* clazz ) \ - { \ - clazz->get_charset_id = get_charset_id_; \ - clazz->get_property = get_property_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h index db623e68405..6c621732da2 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcfftl.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svcfftl.h */ -/* */ -/* The FreeType CFF tables loader service (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svcfftl.h + * + * The FreeType CFF tables loader service (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVCFFTL_H_ @@ -65,8 +65,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_CFFLOADREC( class_, \ get_standard_encoding_, \ load_private_dict_, \ @@ -82,26 +80,6 @@ FT_BEGIN_HEADER blend_build_vector_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \ - get_standard_encoding_, \ - load_private_dict_, \ - fd_select_get_, \ - blend_check_vector_, \ - blend_build_vector_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_CFFLoadRec* clazz ) \ - { \ - clazz->get_standard_encoding = get_standard_encoding_; \ - clazz->load_private_dict = load_private_dict_; \ - clazz->fd_select_get = fd_select_get_; \ - clazz->blend_check_vector = blend_check_vector_; \ - clazz->blend_build_vector = blend_build_vector_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h index cb59ac6a295..555a5af5b9b 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svcid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svcid.h */ -/* */ -/* The FreeType CID font services (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* Derek Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svcid.h + * + * The FreeType CID font services (specification). + * + * Copyright (C) 2007-2019 by + * Derek Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVCID_H_ @@ -48,8 +48,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_CIDREC( class_, \ get_ros_, \ get_is_cid_, \ @@ -59,25 +57,6 @@ FT_BEGIN_HEADER get_ros_, get_is_cid_, get_cid_from_glyph_index_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_CIDREC( class_, \ - get_ros_, \ - get_is_cid_, \ - get_cid_from_glyph_index_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_CIDRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_ros = get_ros_; \ - clazz->get_is_cid = get_is_cid_; \ - clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h index 3b732be1a17..6f4285ea8c3 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svfntfmt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svfntfmt.h */ -/* */ -/* The FreeType font format service (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svfntfmt.h + * + * The FreeType font format service (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVFNTFMT_H_ @@ -26,9 +26,9 @@ FT_BEGIN_HEADER /* - * A trivial service used to return the name of a face's font driver, - * according to the XFree86 nomenclature. Note that the service data - * is a simple constant string pointer. + * A trivial service used to return the name of a face's font driver, + * according to the XFree86 nomenclature. Note that the service data is a + * simple constant string pointer. */ #define FT_SERVICE_ID_FONT_FORMAT "font-format" diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h index f1a68e31107..ca8edf0eb55 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgldict.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svgldict.h */ -/* */ -/* The FreeType glyph dictionary services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svgldict.h + * + * The FreeType glyph dictionary services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVGLDICT_H_ @@ -26,8 +26,8 @@ FT_BEGIN_HEADER /* - * A service used to retrieve glyph names, as well as to find the - * index of a given glyph name in a font. + * A service used to retrieve glyph names, as well as to find the index of + * a given glyph name in a font. * */ @@ -52,8 +52,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ get_name_, \ name_index_ ) \ @@ -62,23 +60,6 @@ FT_BEGIN_HEADER get_name_, name_index_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ - get_name_, \ - name_index_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_GlyphDictRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_name = get_name_; \ - clazz->name_index = name_index_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h index ed79ebeaa8e..0bb76f31441 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svgxval.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* svgxval.h */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svgxval.h + * + * FreeType API for validating TrueTypeGX/AAT tables (specification). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef SVGXVAL_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h index c7e8f6ef275..f992a327c1a 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svkern.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svkern.h */ -/* */ -/* The FreeType Kerning service (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svkern.h + * + * The FreeType Kerning service (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVKERN_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h index abaacddbbe7..d688bc7c601 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmetric.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svmetric.h */ -/* */ -/* The FreeType services for metrics variations (specification). */ -/* */ -/* Copyright 2016-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svmetric.h + * + * The FreeType services for metrics variations (specification). + * + * Copyright (C) 2016-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVMETRIC_H_ @@ -26,7 +26,7 @@ FT_BEGIN_HEADER /* - * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables. + * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables. * */ @@ -93,8 +93,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ hadvance_adjust_, \ lsb_adjust_, \ @@ -116,32 +114,6 @@ FT_BEGIN_HEADER metrics_adjust_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ - hadvance_adjust_, \ - lsb_adjust_, \ - rsb_adjust_, \ - vadvance_adjust_, \ - tsb_adjust_, \ - bsb_adjust_, \ - vorg_adjust_, \ - metrics_adjust_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_MetricsVariationsRec* clazz ) \ - { \ - clazz->hadvance_adjust = hadvance_adjust_; \ - clazz->lsb_adjust = lsb_adjust_; \ - clazz->rsb_adjust = rsb_adjust_; \ - clazz->vadvance_adjust = vadvance_adjust_; \ - clazz->tsb_adjust = tsb_adjust_; \ - clazz->bsb_adjust = bsb_adjust_; \ - clazz->vorg_adjust = vorg_adjust_; \ - clazz->metrics_adjust = metrics_adjust_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h index bcbb38e2ce2..3652f2050a0 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svmm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svmm.h */ -/* */ -/* The FreeType Multiple Masters and GX var services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svmm.h + * + * The FreeType Multiple Masters and GX var services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVMM_H_ @@ -26,9 +26,9 @@ FT_BEGIN_HEADER /* - * A service used to manage multiple-masters data in a given face. + * A service used to manage multiple-masters data in a given face. * - * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). + * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). * */ @@ -86,81 +86,65 @@ FT_BEGIN_HEADER typedef void (*FT_Done_Blend_Func)( FT_Face ); + typedef FT_Error + (*FT_Set_MM_WeightVector_Func)( FT_Face face, + FT_UInt len, + FT_Fixed* weight_vector ); + + typedef FT_Error + (*FT_Get_MM_WeightVector_Func)( FT_Face face, + FT_UInt* len, + FT_Fixed* weight_vector ); + FT_DEFINE_SERVICE( MultiMasters ) { - FT_Get_MM_Func get_mm; - FT_Set_MM_Design_Func set_mm_design; - FT_Set_MM_Blend_Func set_mm_blend; - FT_Get_MM_Blend_Func get_mm_blend; - FT_Get_MM_Var_Func get_mm_var; - FT_Set_Var_Design_Func set_var_design; - FT_Get_Var_Design_Func get_var_design; - FT_Set_Instance_Func set_instance; + FT_Get_MM_Func get_mm; + FT_Set_MM_Design_Func set_mm_design; + FT_Set_MM_Blend_Func set_mm_blend; + FT_Get_MM_Blend_Func get_mm_blend; + FT_Get_MM_Var_Func get_mm_var; + FT_Set_Var_Design_Func set_var_design; + FT_Get_Var_Design_Func get_var_design; + FT_Set_Instance_Func set_instance; + FT_Set_MM_WeightVector_Func set_mm_weightvector; + FT_Get_MM_WeightVector_Func get_mm_weightvector; /* for internal use; only needed for code sharing between modules */ - FT_Get_Var_Blend_Func get_var_blend; - FT_Done_Blend_Func done_blend; + FT_Get_Var_Blend_Func get_var_blend; + FT_Done_Blend_Func done_blend; }; -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_blend_, \ - get_mm_var_, \ - set_var_design_, \ - get_var_design_, \ - set_instance_, \ - get_var_blend_, \ - done_blend_ ) \ - static const FT_Service_MultiMastersRec class_ = \ - { \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_blend_, \ - get_mm_var_, \ - set_var_design_, \ - get_var_design_, \ - set_instance_, \ - get_var_blend_, \ - done_blend_ \ +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + set_weightvector_, \ + get_weightvector_, \ + get_var_blend_, \ + done_blend_ ) \ + static const FT_Service_MultiMastersRec class_ = \ + { \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + set_weightvector_, \ + get_weightvector_, \ + get_var_blend_, \ + done_blend_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_blend_, \ - get_mm_var_, \ - set_var_design_, \ - get_var_design_, \ - set_instance_, \ - get_var_blend_, \ - done_blend_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ - { \ - clazz->get_mm = get_mm_; \ - clazz->set_mm_design = set_mm_design_; \ - clazz->set_mm_blend = set_mm_blend_; \ - clazz->get_mm_blend = get_mm_blend_; \ - clazz->get_mm_var = get_mm_var_; \ - clazz->set_var_design = set_var_design_; \ - clazz->get_var_design = get_var_design_; \ - clazz->set_instance = set_instance_; \ - clazz->get_var_blend = get_var_blend_; \ - clazz->done_blend = done_blend_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h index 31294296a6d..cab4c6efbb1 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svotval.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svotval.h */ -/* */ -/* The FreeType OpenType validation service (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svotval.h + * + * The FreeType OpenType validation service (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVOTVAL_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h index e65d57e91ba..fd01d614ddd 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpfr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpfr.h */ -/* */ -/* Internal PFR service functions (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpfr.h + * + * Internal PFR service functions (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPFR_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h index 4a49d8b0532..18e3843cbe7 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpostnm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpostnm.h */ -/* */ -/* The FreeType PostScript name services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpostnm.h + * + * The FreeType PostScript name services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPOSTNM_H_ @@ -25,13 +25,13 @@ FT_BEGIN_HEADER /* - * A trivial service used to retrieve the PostScript name of a given - * font when available. The `get_name' field should never be NULL. + * A trivial service used to retrieve the PostScript name of a given font + * when available. The `get_name' field should never be `NULL`. * - * The corresponding function can return NULL to indicate that the - * PostScript name is not available. + * The corresponding function can return `NULL` to indicate that the + * PostScript name is not available. * - * The name is owned by the face and will be destroyed with it. + * The name is owned by the face and will be destroyed with it. */ #define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" @@ -47,28 +47,12 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ static const FT_Service_PsFontNameRec class_ = \ { \ get_ps_font_name_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsFontNameRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_ps_font_name = get_ps_font_name_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h index adc0bcf4398..e48d0151ec0 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svprop.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svprop.h */ -/* */ -/* The FreeType property service (specification). */ -/* */ -/* Copyright 2012-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svprop.h + * + * The FreeType property service (specification). + * + * Copyright (C) 2012-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPROP_H_ @@ -45,8 +45,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ set_property_, \ get_property_ ) \ @@ -56,20 +54,6 @@ FT_BEGIN_HEADER get_property_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ - set_property_, \ - get_property_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_PropertiesRec* clazz ) \ - { \ - clazz->set_property = set_property_; \ - clazz->get_property = get_property_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h index 5589575b92a..dfac3bafa98 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpscmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpscmap.h */ -/* */ -/* The FreeType PostScript charmap service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpscmap.h + * + * The FreeType PostScript charmap service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPSCMAP_H_ @@ -29,27 +29,26 @@ FT_BEGIN_HEADER /* - * Adobe glyph name to unicode value. + * Adobe glyph name to unicode value. */ typedef FT_UInt32 (*PS_Unicode_ValueFunc)( const char* glyph_name ); /* - * Macintosh name id to glyph name. NULL if invalid index. + * Macintosh name id to glyph name. `NULL` if invalid index. */ typedef const char* (*PS_Macintosh_NameFunc)( FT_UInt name_index ); /* - * Adobe standard string ID to glyph name. NULL if invalid index. + * Adobe standard string ID to glyph name. `NULL` if invalid index. */ typedef const char* (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index ); /* - * Simple unicode -> glyph index charmap built from font glyph names - * table. + * Simple unicode -> glyph index charmap built from font glyph names table. */ typedef struct PS_UniMap_ { @@ -71,16 +70,16 @@ FT_BEGIN_HEADER /* - * A function which returns a glyph name for a given index. Returns - * NULL if invalid index. + * A function which returns a glyph name for a given index. Returns + * `NULL` if invalid index. */ typedef const char* (*PS_GetGlyphNameFunc)( FT_Pointer data, FT_UInt string_index ); /* - * A function used to release the glyph name returned by - * PS_GetGlyphNameFunc, when needed + * A function used to release the glyph name returned by + * PS_GetGlyphNameFunc, when needed */ typedef void (*PS_FreeGlyphNameFunc)( FT_Pointer data, @@ -118,8 +117,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ unicode_value_, \ unicodes_init_, \ @@ -136,35 +133,6 @@ FT_BEGIN_HEADER adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ - unicode_value_, \ - unicodes_init_, \ - unicodes_char_index_, \ - unicodes_char_next_, \ - macintosh_name_, \ - adobe_std_strings_, \ - adobe_std_encoding_, \ - adobe_expert_encoding_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsCMapsRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->unicode_value = unicode_value_; \ - clazz->unicodes_init = unicodes_init_; \ - clazz->unicodes_char_index = unicodes_char_index_; \ - clazz->unicodes_char_next = unicodes_char_next_; \ - clazz->macintosh_name = macintosh_name_; \ - clazz->adobe_std_strings = adobe_std_strings_; \ - clazz->adobe_std_encoding = adobe_std_encoding_; \ - clazz->adobe_expert_encoding = adobe_expert_encoding_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h index 408f406dfa2..fb4e0e3fa9f 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svpsinfo.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpsinfo.h */ -/* */ -/* The FreeType PostScript info service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpsinfo.h + * + * The FreeType PostScript info service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPSINFO_H_ @@ -62,8 +62,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PSINFOREC( class_, \ get_font_info_, \ ps_get_font_extra_, \ @@ -76,29 +74,6 @@ FT_BEGIN_HEADER get_font_private_, get_font_value_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSINFOREC( class_, \ - get_font_info_, \ - ps_get_font_extra_, \ - has_glyph_names_, \ - get_font_private_, \ - get_font_value_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsInfoRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->ps_get_font_info = get_font_info_; \ - clazz->ps_get_font_extra = ps_get_font_extra_; \ - clazz->ps_has_glyph_names = has_glyph_names_; \ - clazz->ps_get_font_private = get_font_private_; \ - clazz->ps_get_font_value = get_font_value_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h index e8b37bc47f8..464aa209f7f 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svsfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svsfnt.h */ -/* */ -/* The FreeType SFNT table loading service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svsfnt.h + * + * The FreeType SFNT table loading service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVSFNT_H_ @@ -27,7 +27,7 @@ FT_BEGIN_HEADER /* - * SFNT table loading service. + * SFNT table loading service. */ #define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" @@ -70,27 +70,12 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ static const FT_Service_SFNT_TableRec class_ = \ { \ load_, get_, info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_SFNT_TableRec* clazz ) \ - { \ - clazz->load_table = load_; \ - clazz->get_table = get_; \ - clazz->table_info = info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h index cd0e6fda6f9..0fcb81371d6 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttcmap.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* svttcmap.h */ -/* */ -/* The FreeType TrueType/sfnt cmap extra information service. */ -/* */ -/* Copyright 2003-2018 by */ -/* Masatake YAMATO, Redhat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svttcmap.h + * + * The FreeType TrueType/sfnt cmap extra information service. + * + * Copyright (C) 2003-2019 by + * Masatake YAMATO, Redhat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* Development of this service is support of Information-technology Promotion Agency, Japan. */ @@ -32,29 +32,28 @@ FT_BEGIN_HEADER #define FT_SERVICE_ID_TT_CMAP "tt-cmaps" - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_CMapInfo */ - /* */ - /* <Description> */ - /* A structure used to store TrueType/sfnt specific cmap information */ - /* which is not covered by the generic @FT_CharMap structure. This */ - /* structure can be accessed with the @FT_Get_TT_CMap_Info function. */ - /* */ - /* <Fields> */ - /* language :: */ - /* The language ID used in Mac fonts. Definitions of values are in */ - /* `ttnameid.h'. */ - /* */ - /* format :: */ - /* The cmap format. OpenType 1.6 defines the formats 0 (byte */ - /* encoding table), 2~(high-byte mapping through table), 4~(segment */ - /* mapping to delta values), 6~(trimmed table mapping), 8~(mixed */ - /* 16-bit and 32-bit coverage), 10~(trimmed array), 12~(segmented */ - /* coverage), 13~(last resort font), and 14 (Unicode Variation */ - /* Sequences). */ - /* */ + /************************************************************************** + * + * @struct: + * TT_CMapInfo + * + * @description: + * A structure used to store TrueType/sfnt specific cmap information + * which is not covered by the generic @FT_CharMap structure. This + * structure can be accessed with the @FT_Get_TT_CMap_Info function. + * + * @fields: + * language :: + * The language ID used in Mac fonts. Definitions of values are in + * `ttnameid.h`. + * + * format :: + * The cmap format. OpenType 1.6 defines the formats 0 (byte encoding + * table), 2~(high-byte mapping through table), 4~(segment mapping to + * delta values), 6~(trimmed table mapping), 8~(mixed 16-bit and 32-bit + * coverage), 10~(trimmed array), 12~(segmented coverage), 13~(last + * resort font), and 14 (Unicode Variation Sequences). + */ typedef struct TT_CMapInfo_ { FT_ULong language; @@ -73,7 +72,6 @@ FT_BEGIN_HEADER TT_CMap_Info_GetFunc get_cmap_info; }; -#ifndef FT_CONFIG_OPTION_PIC #define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ static const FT_Service_TTCMapsRec class_ = \ @@ -81,20 +79,6 @@ FT_BEGIN_HEADER get_cmap_info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_TTCMapsRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_cmap_info = get_cmap_info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h index 92e3c541f53..a852f5c6fb6 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svtteng.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svtteng.h */ -/* */ -/* The FreeType TrueType engine query service (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svtteng.h + * + * The FreeType TrueType engine query service (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVTTENG_H_ @@ -27,7 +27,7 @@ FT_BEGIN_HEADER /* - * SFNT table loading service. + * SFNT table loading service. */ #define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h index 16fac1ca18b..c8798771fbb 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svttglyf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svttglyf.h */ -/* */ -/* The FreeType TrueType glyph service. */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svttglyf.h + * + * The FreeType TrueType glyph service. + * + * Copyright (C) 2007-2019 by + * David Turner. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVTTGLYF_H_ #define SVTTGLYF_H_ @@ -39,25 +39,12 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ static const FT_Service_TTGlyfRec class_ = \ { \ get_location_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_TTGlyfRec* clazz ) \ - { \ - clazz->get_location = get_location_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h index 80d481cbd11..38ee0209657 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/services/svwinfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svwinfnt.h */ -/* */ -/* The FreeType Windows FNT/FONT service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svwinfnt.h + * + * The FreeType Windows FNT/FONT service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVWINFNT_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h index fb1e327aeb0..225f40df6eb 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/sfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfnt.h */ -/* */ -/* High-level `sfnt' driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfnt.h + * + * High-level 'sfnt' driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SFNT_H_ @@ -28,43 +28,46 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Init_Face_Func */ - /* */ - /* <Description> */ - /* First part of the SFNT face object initialization. This finds */ - /* the face in a SFNT file or collection, and load its format tag in */ - /* face->format_tag. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection, in bits 0-15. The numbered instance */ - /* index~+~1 of a GX (sub)font, if applicable, in bits */ - /* 16-30. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ - /* This function recognizes fonts embedded in a `TrueType */ - /* collection'. */ - /* */ - /* Once the format tag has been validated by the font driver, it */ - /* should then call the TT_Load_Face_Func() callback to read the rest */ - /* of the SFNT tables in the object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Init_Face_Func + * + * @description: + * First part of the SFNT face object initialization. This finds the + * face in a SFNT file or collection, and load its format tag in + * face->format_tag. + * + * @input: + * stream :: + * The input stream. + * + * face :: + * A handle to the target face object. + * + * face_index :: + * The index of the TrueType font, if we are opening a collection, in + * bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if + * applicable, in bits 16-30. + * + * num_params :: + * The number of additional parameters. + * + * params :: + * Optional additional parameters. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The stream cursor must be at the font file's origin. + * + * This function recognizes fonts embedded in a 'TrueType collection'. + * + * Once the format tag has been validated by the font driver, it should + * then call the TT_Load_Face_Func() callback to read the rest of the + * SFNT tables in the object. + */ typedef FT_Error (*TT_Init_Face_Func)( FT_Stream stream, TT_Face face, @@ -73,36 +76,40 @@ FT_BEGIN_HEADER FT_Parameter* params ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Face_Func */ - /* */ - /* <Description> */ - /* Second part of the SFNT face object initialization. This loads */ - /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */ - /* face object. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection, in bits 0-15. The numbered instance */ - /* index~+~1 of a GX (sub)font, if applicable, in bits */ - /* 16-30. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function must be called after TT_Init_Face_Func(). */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Face_Func + * + * @description: + * Second part of the SFNT face object initialization. This loads the + * common SFNT tables (head, OS/2, maxp, metrics, etc.) in the face + * object. + * + * @input: + * stream :: + * The input stream. + * + * face :: + * A handle to the target face object. + * + * face_index :: + * The index of the TrueType font, if we are opening a collection, in + * bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if + * applicable, in bits 16-30. + * + * num_params :: + * The number of additional parameters. + * + * params :: + * Optional additional parameters. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function must be called after TT_Init_Face_Func(). + */ typedef FT_Error (*TT_Load_Face_Func)( FT_Stream stream, TT_Face face, @@ -111,64 +118,64 @@ FT_BEGIN_HEADER FT_Parameter* params ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Done_Face_Func */ - /* */ - /* <Description> */ - /* A callback used to delete the common SFNT data from a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Note> */ - /* This function does NOT destroy the face object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Done_Face_Func + * + * @description: + * A callback used to delete the common SFNT data from a face. + * + * @input: + * face :: + * A handle to the target face object. + * + * @note: + * This function does NOT destroy the face object. + */ typedef void (*TT_Done_Face_Func)( TT_Face face ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Any_Func */ - /* */ - /* <Description> */ - /* Load any font table into client memory. */ - /* */ - /* <Input> */ - /* face :: The face object to look for. */ - /* */ - /* tag :: The tag of table to load. Use the value 0 if you want */ - /* to access the whole font file, else set this parameter */ - /* to a valid TrueType table tag that you can forge with */ - /* the MAKE_TT_TAG macro. */ - /* */ - /* offset :: The starting offset in the table (or the file if */ - /* tag == 0). */ - /* */ - /* length :: The address of the decision variable: */ - /* */ - /* If length == NULL: */ - /* Loads the whole table. Returns an error if */ - /* `offset' == 0! */ - /* */ - /* If *length == 0: */ - /* Exits immediately; returning the length of the given */ - /* table or of the font file, depending on the value of */ - /* `tag'. */ - /* */ - /* If *length != 0: */ - /* Loads the next `length' bytes of table or font, */ - /* starting at offset `offset' (in table or font too). */ - /* */ - /* <Output> */ - /* buffer :: The address of target buffer. */ - /* */ - /* <Return> */ - /* TrueType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Any_Func + * + * @description: + * Load any font table into client memory. + * + * @input: + * face :: + * The face object to look for. + * + * tag :: + * The tag of table to load. Use the value 0 if you want to access the + * whole font file, else set this parameter to a valid TrueType table + * tag that you can forge with the MAKE_TT_TAG macro. + * + * offset :: + * The starting offset in the table (or the file if tag == 0). + * + * length :: + * The address of the decision variable: + * + * If `length == NULL`: Loads the whole table. Returns an error if + * 'offset' == 0! + * + * If `*length == 0`: Exits immediately; returning the length of the + * given table or of the font file, depending on the value of 'tag'. + * + * If `*length != 0`: Loads the next 'length' bytes of table or font, + * starting at offset 'offset' (in table or font too). + * + * @output: + * buffer :: + * The address of target buffer. + * + * @return: + * TrueType error code. 0 means success. + */ typedef FT_Error (*TT_Load_Any_Func)( TT_Face face, FT_ULong tag, @@ -177,34 +184,39 @@ FT_BEGIN_HEADER FT_ULong* length ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Find_SBit_Image_Func */ - /* */ - /* <Description> */ - /* Check whether an embedded bitmap (an `sbit') exists for a given */ - /* glyph, at a given strike. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* strike_index :: The current strike index. */ - /* */ - /* <Output> */ - /* arange :: The SBit range containing the glyph index. */ - /* */ - /* astrike :: The SBit strike containing the glyph index. */ - /* */ - /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns */ - /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */ - /* glyph. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Find_SBit_Image_Func + * + * @description: + * Check whether an embedded bitmap (an 'sbit') exists for a given glyph, + * at a given strike. + * + * @input: + * face :: + * The target face object. + * + * glyph_index :: + * The glyph index. + * + * strike_index :: + * The current strike index. + * + * @output: + * arange :: + * The SBit range containing the glyph index. + * + * astrike :: + * The SBit strike containing the glyph index. + * + * aglyph_offset :: + * The offset of the glyph data in 'EBDT' table. + * + * @return: + * FreeType error code. 0 means success. Returns + * SFNT_Err_Invalid_Argument if no sbit exists for the requested glyph. + */ typedef FT_Error (*TT_Find_SBit_Image_Func)( TT_Face face, FT_UInt glyph_index, @@ -214,78 +226,81 @@ FT_BEGIN_HEADER FT_ULong *aglyph_offset ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_SBit_Metrics_Func */ - /* */ - /* <Description> */ - /* Get the big metrics for a given embedded bitmap. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* range :: The SBit range containing the glyph. */ - /* */ - /* <Output> */ - /* big_metrics :: A big SBit metrics structure for the glyph. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be positioned at the glyph's offset within */ - /* the `EBDT' table before the call. */ - /* */ - /* If the image format uses variable metrics, the stream cursor is */ - /* positioned just after the metrics header in the `EBDT' table on */ - /* function exit. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_SBit_Metrics_Func + * + * @description: + * Get the big metrics for a given embedded bitmap. + * + * @input: + * stream :: + * The input stream. + * + * range :: + * The SBit range containing the glyph. + * + * @output: + * big_metrics :: + * A big SBit metrics structure for the glyph. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The stream cursor must be positioned at the glyph's offset within the + * 'EBDT' table before the call. + * + * If the image format uses variable metrics, the stream cursor is + * positioned just after the metrics header in the 'EBDT' table on + * function exit. + */ typedef FT_Error (*TT_Load_SBit_Metrics_Func)( FT_Stream stream, TT_SBit_Range range, TT_SBit_Metrics metrics ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_SBit_Image_Func */ - /* */ - /* <Description> */ - /* Load a given glyph sbit image from the font resource. This also */ - /* returns its metrics. */ - /* */ - /* <Input> */ - /* face :: */ - /* The target face object. */ - /* */ - /* strike_index :: */ - /* The strike index. */ - /* */ - /* glyph_index :: */ - /* The current glyph index. */ - /* */ - /* load_flags :: */ - /* The current load flags. */ - /* */ - /* stream :: */ - /* The input stream. */ - /* */ - /* <Output> */ - /* amap :: */ - /* The target pixmap. */ - /* */ - /* ametrics :: */ - /* A big sbit metrics structure for the glyph image. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* glyph sbit exists for the index. */ - /* */ - /* <Note> */ - /* The `map.buffer' field is always freed before the glyph is loaded. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_SBit_Image_Func + * + * @description: + * Load a given glyph sbit image from the font resource. This also + * returns its metrics. + * + * @input: + * face :: + * The target face object. + * + * strike_index :: + * The strike index. + * + * glyph_index :: + * The current glyph index. + * + * load_flags :: + * The current load flags. + * + * stream :: + * The input stream. + * + * @output: + * amap :: + * The target pixmap. + * + * ametrics :: + * A big sbit metrics structure for the glyph image. + * + * @return: + * FreeType error code. 0 means success. Returns an error if no glyph + * sbit exists for the index. + * + * @note: + * The `map.buffer` field is always freed before the glyph is loaded. + */ typedef FT_Error (*TT_Load_SBit_Image_Func)( TT_Face face, FT_ULong strike_index, @@ -296,130 +311,144 @@ FT_BEGIN_HEADER TT_SBit_MetricsRec *ametrics ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Set_SBit_Strike_Func */ - /* */ - /* <Description> */ - /* Select an sbit strike for a given size request. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* req :: The size request. */ - /* */ - /* <Output> */ - /* astrike_index :: The index of the sbit strike. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* sbit strike exists for the selected ppem values. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Set_SBit_Strike_Func + * + * @description: + * Select an sbit strike for a given size request. + * + * @input: + * face :: + * The target face object. + * + * req :: + * The size request. + * + * @output: + * astrike_index :: + * The index of the sbit strike. + * + * @return: + * FreeType error code. 0 means success. Returns an error if no sbit + * strike exists for the selected ppem values. + */ typedef FT_Error (*TT_Set_SBit_Strike_Func)( TT_Face face, FT_Size_Request req, FT_ULong* astrike_index ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Strike_Metrics_Func */ - /* */ - /* <Description> */ - /* Load the metrics of a given strike. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* strike_index :: The strike index. */ - /* */ - /* <Output> */ - /* metrics :: the metrics of the strike. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* such sbit strike exists. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Strike_Metrics_Func + * + * @description: + * Load the metrics of a given strike. + * + * @input: + * face :: + * The target face object. + * + * strike_index :: + * The strike index. + * + * @output: + * metrics :: + * the metrics of the strike. + * + * @return: + * FreeType error code. 0 means success. Returns an error if no such + * sbit strike exists. + */ typedef FT_Error (*TT_Load_Strike_Metrics_Func)( TT_Face face, FT_ULong strike_index, FT_Size_Metrics* metrics ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_PS_Name_Func */ - /* */ - /* <Description> */ - /* Get the PostScript glyph name of a glyph. */ - /* */ - /* <Input> */ - /* idx :: The glyph index. */ - /* */ - /* PSname :: The address of a string pointer. Will be NULL in case */ - /* of error, otherwise it is a pointer to the glyph name. */ - /* */ - /* You must not modify the returned string! */ - /* */ - /* <Output> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Get_PS_Name_Func + * + * @description: + * Get the PostScript glyph name of a glyph. + * + * @input: + * idx :: + * The glyph index. + * + * PSname :: + * The address of a string pointer. Will be `NULL` in case of error, + * otherwise it is a pointer to the glyph name. + * + * You must not modify the returned string! + * + * @output: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Get_PS_Name_Func)( TT_Face face, FT_UInt idx, FT_String** PSname ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Metrics_Func */ - /* */ - /* <Description> */ - /* Load a metrics table, which is a table with a horizontal and a */ - /* vertical version. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load the vertical one. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Metrics_Func + * + * @description: + * Load a metrics table, which is a table with a horizontal and a + * vertical version. + * + * @input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * vertical :: + * A boolean flag. If set, load the vertical one. + * + * @return: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Load_Metrics_Func)( TT_Face face, FT_Stream stream, FT_Bool vertical ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Metrics_Func */ - /* */ - /* <Description> */ - /* Load the horizontal or vertical header in a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* abearing :: The horizontal (or vertical) bearing. Set to zero in */ - /* case of error. */ - /* */ - /* aadvance :: The horizontal (or vertical) advance. Set to zero in */ - /* case of error. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Get_Metrics_Func + * + * @description: + * Load the horizontal or vertical header in a face object. + * + * @input: + * face :: + * A handle to the target face object. + * + * vertical :: + * A boolean flag. If set, load vertical metrics. + * + * gindex :: + * The glyph index. + * + * @output: + * abearing :: + * The horizontal (or vertical) bearing. Set to zero in case of error. + * + * aadvance :: + * The horizontal (or vertical) advance. Set to zero in case of error. + */ typedef void (*TT_Get_Metrics_Func)( TT_Face face, FT_Bool vertical, @@ -428,57 +457,168 @@ FT_BEGIN_HEADER FT_UShort* aadvance ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Name_Func */ - /* */ - /* <Description> */ - /* From the `name' table, return a given ENGLISH name record in */ - /* ASCII. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* nameid :: The name id of the name record to return. */ - /* */ - /* <InOut> */ - /* name :: The address of an allocated string pointer. NULL if */ - /* no name is present. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Set_Palette_Func + * + * @description: + * Load the colors into `face->palette` for a given palette index. + * + * @input: + * face :: + * The target face object. + * + * idx :: + * The palette index. + * + * @return: + * FreeType error code. 0 means success. + */ + typedef FT_Error + (*TT_Set_Palette_Func)( TT_Face face, + FT_UInt idx ); + + + /************************************************************************** + * + * @functype: + * TT_Get_Colr_Layer_Func + * + * @description: + * Iteratively get the color layer data of a given glyph index. + * + * @input: + * face :: + * The target face object. + * + * base_glyph :: + * The glyph index the colored glyph layers are associated with. + * + * @inout: + * iterator :: + * An @FT_LayerIterator object. For the first call you should set + * `iterator->p` to `NULL`. For all following calls, simply use the + * same object again. + * + * @output: + * aglyph_index :: + * The glyph index of the current layer. + * + * acolor_index :: + * The color index into the font face's color palette of the current + * layer. The value 0xFFFF is special; it doesn't reference a palette + * entry but indicates that the text foreground color should be used + * instead (to be set up by the application outside of FreeType). + * + * @return: + * Value~1 if everything is OK. If there are no more layers (or if there + * are no layers at all), value~0 gets returned. In case of an error, + * value~0 is returned also. + */ + typedef FT_Bool + (*TT_Get_Colr_Layer_Func)( TT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); + + + /************************************************************************** + * + * @functype: + * TT_Blend_Colr_Func + * + * @description: + * Blend the bitmap in `new_glyph` into `base_glyph` using the color + * specified by `color_index`. If `color_index` is 0xFFFF, use + * `face->foreground_color` if `face->have_foreground_color` is set. + * Otherwise check `face->palette_data.palette_flags`: If present and + * @FT_PALETTE_FOR_DARK_BACKGROUND is set, use BGRA value 0xFFFFFFFF + * (white opaque). Otherwise use BGRA value 0x000000FF (black opaque). + * + * @input: + * face :: + * The target face object. + * + * color_index :: + * Color index from the COLR table. + * + * base_glyph :: + * Slot for bitmap to be merged into. The underlying bitmap may get + * reallocated. + * + * new_glyph :: + * Slot to be incooperated into `base_glyph`. + * + * @return: + * FreeType error code. 0 means success. Returns an error if + * color_index is invalid or reallocation fails. + */ + typedef FT_Error + (*TT_Blend_Colr_Func)( TT_Face face, + FT_UInt color_index, + FT_GlyphSlot base_glyph, + FT_GlyphSlot new_glyph ); + + + /************************************************************************** + * + * @functype: + * TT_Get_Name_Func + * + * @description: + * From the 'name' table, return a given ENGLISH name record in ASCII. + * + * @input: + * face :: + * A handle to the source face object. + * + * nameid :: + * The name id of the name record to return. + * + * @inout: + * name :: + * The address of an allocated string pointer. `NULL` if no name is + * present. + * + * @return: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Get_Name_Func)( TT_Face face, FT_UShort nameid, FT_String** name ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Name_ID_Func */ - /* */ - /* <Description> */ - /* Search whether an ENGLISH version for a given name ID is in the */ - /* `name' table. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* nameid :: The name id of the name record to return. */ - /* */ - /* <Out> */ - /* win :: If non-negative, an index into the `name' table with */ - /* the corresponding (3,1) or (3,0) Windows entry. */ - /* */ - /* apple :: If non-negative, an index into the `name' table with */ - /* the corresponding (1,0) Apple entry. */ - /* */ - /* <Return> */ - /* 1 if there is either a win or apple entry (or both), 0 otheriwse. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Get_Name_ID_Func + * + * @description: + * Search whether an ENGLISH version for a given name ID is in the 'name' + * table. + * + * @input: + * face :: + * A handle to the source face object. + * + * nameid :: + * The name id of the name record to return. + * + * @output: + * win :: + * If non-negative, an index into the 'name' table with the + * corresponding (3,1) or (3,0) Windows entry. + * + * apple :: + * If non-negative, an index into the 'name' table with the + * corresponding (1,0) Apple entry. + * + * @return: + * 1 if there is either a win or apple entry (or both), 0 otheriwse. + */ typedef FT_Bool (*TT_Get_Name_ID_Func)( TT_Face face, FT_UShort nameid, @@ -486,42 +626,45 @@ FT_BEGIN_HEADER FT_Int *apple ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Table_Func */ - /* */ - /* <Description> */ - /* Load a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The function uses `face->goto_table' to seek the stream to the */ - /* start of the table, except while loading the font directory. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Table_Func + * + * @description: + * Load a given TrueType table. + * + * @input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The function uses `face->goto_table` to seek the stream to the start + * of the table, except while loading the font directory. + */ typedef FT_Error (*TT_Load_Table_Func)( TT_Face face, FT_Stream stream ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Free_Table_Func */ - /* */ - /* <Description> */ - /* Free a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Free_Table_Func + * + * @description: + * Free a given TrueType table. + * + * @input: + * face :: + * A handle to the target face object. + */ typedef void (*TT_Free_Table_Func)( TT_Face face ); @@ -534,9 +677,14 @@ FT_BEGIN_HEADER * Return the horizontal kerning value between two glyphs. * * @input: - * face :: A handle to the source face object. - * left_glyph :: The left glyph index. - * right_glyph :: The right glyph index. + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The left glyph index. + * + * right_glyph :: + * The right glyph index. * * @return: * The kerning value in font units. @@ -547,18 +695,18 @@ FT_BEGIN_HEADER FT_UInt right_glyph ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* SFNT_Interface */ - /* */ - /* <Description> */ - /* This structure holds pointers to the functions used to load and */ - /* free the basic tables that are required in a `sfnt' font file. */ - /* */ - /* <Fields> */ - /* Check the various xxx_Func() descriptions for details. */ - /* */ + /************************************************************************** + * + * @struct: + * SFNT_Interface + * + * @description: + * This structure holds pointers to the functions used to load and free + * the basic tables that are required in a 'sfnt' font file. + * + * @fields: + * Check the various xxx_Func() descriptions for details. + */ typedef struct SFNT_Interface_ { TT_Loader_GotoTableFunc goto_table; @@ -616,6 +764,14 @@ FT_BEGIN_HEADER TT_Set_SBit_Strike_Func set_sbit_strike; TT_Load_Strike_Metrics_Func load_strike_metrics; + TT_Load_Table_Func load_cpal; + TT_Load_Table_Func load_colr; + TT_Free_Table_Func free_cpal; + TT_Free_Table_Func free_colr; + TT_Set_Palette_Func set_palette; + TT_Get_Colr_Layer_Func get_colr_layer; + TT_Blend_Colr_Func colr_blend; + TT_Get_Metrics_Func get_metrics; TT_Get_Name_Func get_name; @@ -627,7 +783,6 @@ FT_BEGIN_HEADER /* transitional */ typedef SFNT_Interface* SFNT_Service; -#ifndef FT_CONFIG_OPTION_PIC #define FT_DEFINE_SFNT_INTERFACE( \ class_, \ @@ -659,6 +814,13 @@ FT_BEGIN_HEADER free_eblc_, \ set_sbit_strike_, \ load_strike_metrics_, \ + load_cpal_, \ + load_colr_, \ + free_cpal_, \ + free_colr_, \ + set_palette_, \ + get_colr_layer_, \ + colr_blend_, \ get_metrics_, \ get_name_, \ get_name_id_ ) \ @@ -692,89 +854,18 @@ FT_BEGIN_HEADER free_eblc_, \ set_sbit_strike_, \ load_strike_metrics_, \ + load_cpal_, \ + load_colr_, \ + free_cpal_, \ + free_colr_, \ + set_palette_, \ + get_colr_layer_, \ + colr_blend_, \ get_metrics_, \ get_name_, \ get_name_id_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_INTERNAL( a, a_ ) \ - clazz->a = a_; - -#define FT_DEFINE_SFNT_INTERFACE( \ - class_, \ - goto_table_, \ - init_face_, \ - load_face_, \ - done_face_, \ - get_interface_, \ - load_any_, \ - load_head_, \ - load_hhea_, \ - load_cmap_, \ - load_maxp_, \ - load_os2_, \ - load_post_, \ - load_name_, \ - free_name_, \ - load_kern_, \ - load_gasp_, \ - load_pclt_, \ - load_bhed_, \ - load_sbit_image_, \ - get_psname_, \ - free_psnames_, \ - get_kerning_, \ - load_font_dir_, \ - load_hmtx_, \ - load_eblc_, \ - free_eblc_, \ - set_sbit_strike_, \ - load_strike_metrics_, \ - get_metrics_, \ - get_name_, \ - get_name_id_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - SFNT_Interface* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->goto_table = goto_table_; \ - clazz->init_face = init_face_; \ - clazz->load_face = load_face_; \ - clazz->done_face = done_face_; \ - clazz->get_interface = get_interface_; \ - clazz->load_any = load_any_; \ - clazz->load_head = load_head_; \ - clazz->load_hhea = load_hhea_; \ - clazz->load_cmap = load_cmap_; \ - clazz->load_maxp = load_maxp_; \ - clazz->load_os2 = load_os2_; \ - clazz->load_post = load_post_; \ - clazz->load_name = load_name_; \ - clazz->free_name = free_name_; \ - clazz->load_kern = load_kern_; \ - clazz->load_gasp = load_gasp_; \ - clazz->load_pclt = load_pclt_; \ - clazz->load_bhed = load_bhed_; \ - clazz->load_sbit_image = load_sbit_image_; \ - clazz->get_psname = get_psname_; \ - clazz->free_psnames = free_psnames_; \ - clazz->get_kerning = get_kerning_; \ - clazz->load_font_dir = load_font_dir_; \ - clazz->load_hmtx = load_hmtx_; \ - clazz->load_eblc = load_eblc_; \ - clazz->free_eblc = free_eblc_; \ - clazz->set_sbit_strike = set_sbit_strike_; \ - clazz->load_strike_metrics = load_strike_metrics_; \ - clazz->get_metrics = get_metrics_; \ - clazz->get_name = get_name_; \ - clazz->get_name_id = get_name_id_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h index 2118e336749..e197a1afca3 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/t1types.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* t1types.h */ -/* */ -/* Basic Type1/Type2 type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1types.h + * + * Basic Type1/Type2 type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1TYPES_H_ @@ -45,28 +45,31 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_EncodingRec */ - /* */ - /* <Description> */ - /* A structure modeling a custom encoding. */ - /* */ - /* <Fields> */ - /* num_chars :: The number of character codes in the encoding. */ - /* Usually 256. */ - /* */ - /* code_first :: The lowest valid character code in the encoding. */ - /* */ - /* code_last :: The highest valid character code in the encoding */ - /* + 1. When equal to code_first there are no valid */ - /* character codes. */ - /* */ - /* char_index :: An array of corresponding glyph indices. */ - /* */ - /* char_name :: An array of corresponding glyph names. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_EncodingRec + * + * @description: + * A structure modeling a custom encoding. + * + * @fields: + * num_chars :: + * The number of character codes in the encoding. Usually 256. + * + * code_first :: + * The lowest valid character code in the encoding. + * + * code_last :: + * The highest valid character code in the encoding + 1. When equal to + * code_first there are no valid character codes. + * + * char_index :: + * An array of corresponding glyph indices. + * + * char_name :: + * An array of corresponding glyph names. + */ typedef struct T1_EncodingRecRec_ { FT_Int num_chars; diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h index 10dd336a899..5e9f40ec3f7 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/internal/tttypes.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* tttypes.h */ -/* */ -/* Basic SFNT/TrueType type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * tttypes.h + * + * Basic SFNT/TrueType type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTTYPES_H_ @@ -24,6 +24,7 @@ #include <ft2build.h> #include FT_TRUETYPE_TABLES_H #include FT_INTERNAL_OBJECTS_H +#include FT_COLOR_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H @@ -46,27 +47,30 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TTC_HeaderRec */ - /* */ - /* <Description> */ - /* TrueType collection header. This table contains the offsets of */ - /* the font headers of each distinct TrueType face in the file. */ - /* */ - /* <Fields> */ - /* tag :: Must be `ttc ' to indicate a TrueType collection. */ - /* */ - /* version :: The version number. */ - /* */ - /* count :: The number of faces in the collection. The */ - /* specification says this should be an unsigned long, but */ - /* we use a signed long since we need the value -1 for */ - /* specific purposes. */ - /* */ - /* offsets :: The offsets of the font headers, one per face. */ - /* */ + /************************************************************************** + * + * @struct: + * TTC_HeaderRec + * + * @description: + * TrueType collection header. This table contains the offsets of the + * font headers of each distinct TrueType face in the file. + * + * @fields: + * tag :: + * Must be 'ttc~' to indicate a TrueType collection. + * + * version :: + * The version number. + * + * count :: + * The number of faces in the collection. The specification says this + * should be an unsigned long, but we use a signed long since we need + * the value -1 for specific purposes. + * + * offsets :: + * The offsets of the font headers, one per face. + */ typedef struct TTC_HeaderRec_ { FT_ULong tag; @@ -77,25 +81,30 @@ FT_BEGIN_HEADER } TTC_HeaderRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* SFNT_HeaderRec */ - /* */ - /* <Description> */ - /* SFNT file format header. */ - /* */ - /* <Fields> */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of tables in file. */ - /* */ - /* search_range :: Must be `16 * (max power of 2 <= num_tables)'. */ - /* */ - /* entry_selector :: Must be log2 of `search_range / 16'. */ - /* */ - /* range_shift :: Must be `num_tables * 16 - search_range'. */ - /* */ + /************************************************************************** + * + * @struct: + * SFNT_HeaderRec + * + * @description: + * SFNT file format header. + * + * @fields: + * format_tag :: + * The font format tag. + * + * num_tables :: + * The number of tables in file. + * + * search_range :: + * Must be '16 * (max power of 2 <= num_tables)'. + * + * entry_selector :: + * Must be log2 of 'search_range / 16'. + * + * range_shift :: + * Must be 'num_tables * 16 - search_range'. + */ typedef struct SFNT_HeaderRec_ { FT_ULong format_tag; @@ -109,24 +118,28 @@ FT_BEGIN_HEADER } SFNT_HeaderRec, *SFNT_Header; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_TableRec */ - /* */ - /* <Description> */ - /* This structure describes a given table of a TrueType font. */ - /* */ - /* <Fields> */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* Offset :: The offset of the table from the start of the TrueType */ - /* font in its resource. */ - /* */ - /* Length :: The table length (in bytes). */ - /* */ + /************************************************************************** + * + * @struct: + * TT_TableRec + * + * @description: + * This structure describes a given table of a TrueType font. + * + * @fields: + * Tag :: + * A four-bytes tag describing the table. + * + * CheckSum :: + * The table checksum. This value can be ignored. + * + * Offset :: + * The offset of the table from the start of the TrueType font in its + * resource. + * + * Length :: + * The table length (in bytes). + */ typedef struct TT_TableRec_ { FT_ULong Tag; /* table type */ @@ -137,19 +150,19 @@ FT_BEGIN_HEADER } TT_TableRec, *TT_Table; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* WOFF_HeaderRec */ - /* */ - /* <Description> */ - /* WOFF file format header. */ - /* */ - /* <Fields> */ - /* See */ - /* */ - /* https://www.w3.org/TR/WOFF/#WOFFHeader */ - /* */ + /************************************************************************** + * + * @struct: + * WOFF_HeaderRec + * + * @description: + * WOFF file format header. + * + * @fields: + * See + * + * https://www.w3.org/TR/WOFF/#WOFFHeader + */ typedef struct WOFF_HeaderRec_ { FT_ULong signature; @@ -169,30 +182,36 @@ FT_BEGIN_HEADER } WOFF_HeaderRec, *WOFF_Header; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* WOFF_TableRec */ - /* */ - /* <Description> */ - /* This structure describes a given table of a WOFF font. */ - /* */ - /* <Fields> */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* Offset :: The offset of the table from the start of the WOFF */ - /* font in its resource. */ - /* */ - /* CompLength :: Compressed table length (in bytes). */ - /* */ - /* OrigLength :: Uncompressed table length (in bytes). */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* OrigOffset :: The uncompressed table file offset. This value gets */ - /* computed while constructing the (uncompressed) SFNT */ - /* header. It is not contained in the WOFF file. */ - /* */ + /************************************************************************** + * + * @struct: + * WOFF_TableRec + * + * @description: + * This structure describes a given table of a WOFF font. + * + * @fields: + * Tag :: + * A four-bytes tag describing the table. + * + * Offset :: + * The offset of the table from the start of the WOFF font in its + * resource. + * + * CompLength :: + * Compressed table length (in bytes). + * + * OrigLength :: + * Uncompressed table length (in bytes). + * + * CheckSum :: + * The table checksum. This value can be ignored. + * + * OrigOffset :: + * The uncompressed table file offset. This value gets computed while + * constructing the (uncompressed) SFNT header. It is not contained in + * the WOFF file. + */ typedef struct WOFF_TableRec_ { FT_ULong Tag; /* table ID */ @@ -206,20 +225,22 @@ FT_BEGIN_HEADER } WOFF_TableRec, *WOFF_Table; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_LongMetricsRec */ - /* */ - /* <Description> */ - /* A structure modeling the long metrics of the `hmtx' and `vmtx' */ - /* TrueType tables. The values are expressed in font units. */ - /* */ - /* <Fields> */ - /* advance :: The advance width or height for the glyph. */ - /* */ - /* bearing :: The left-side or top-side bearing for the glyph. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_LongMetricsRec + * + * @description: + * A structure modeling the long metrics of the 'hmtx' and 'vmtx' + * TrueType tables. The values are expressed in font units. + * + * @fields: + * advance :: + * The advance width or height for the glyph. + * + * bearing :: + * The left-side or top-side bearing for the glyph. + */ typedef struct TT_LongMetricsRec_ { FT_UShort advance; @@ -228,45 +249,51 @@ FT_BEGIN_HEADER } TT_LongMetricsRec, *TT_LongMetrics; - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_ShortMetrics */ - /* */ - /* <Description> */ - /* A simple type to model the short metrics of the `hmtx' and `vmtx' */ - /* tables. */ - /* */ + /************************************************************************** + * + * @type: + * TT_ShortMetrics + * + * @description: + * A simple type to model the short metrics of the 'hmtx' and 'vmtx' + * tables. + */ typedef FT_Short TT_ShortMetrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_NameRec */ - /* */ - /* <Description> */ - /* A structure modeling TrueType name records. Name records are used */ - /* to store important strings like family name, style name, */ - /* copyright, etc. in _localized_ versions (i.e., language, encoding, */ - /* etc). */ - /* */ - /* <Fields> */ - /* platformID :: The ID of the name's encoding platform. */ - /* */ - /* encodingID :: The platform-specific ID for the name's encoding. */ - /* */ - /* languageID :: The platform-specific ID for the name's language. */ - /* */ - /* nameID :: The ID specifying what kind of name this is. */ - /* */ - /* stringLength :: The length of the string in bytes. */ - /* */ - /* stringOffset :: The offset to the string in the `name' table. */ - /* */ - /* string :: A pointer to the string's bytes. Note that these */ - /* are usually UTF-16 encoded characters. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_NameRec + * + * @description: + * A structure modeling TrueType name records. Name records are used to + * store important strings like family name, style name, copyright, + * etc. in _localized_ versions (i.e., language, encoding, etc). + * + * @fields: + * platformID :: + * The ID of the name's encoding platform. + * + * encodingID :: + * The platform-specific ID for the name's encoding. + * + * languageID :: + * The platform-specific ID for the name's language. + * + * nameID :: + * The ID specifying what kind of name this is. + * + * stringLength :: + * The length of the string in bytes. + * + * stringOffset :: + * The offset to the string in the 'name' table. + * + * string :: + * A pointer to the string's bytes. Note that these are usually UTF-16 + * encoded characters. + */ typedef struct TT_NameRec_ { FT_UShort platformID; @@ -284,23 +311,26 @@ FT_BEGIN_HEADER } TT_NameRec, *TT_Name; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_LangTagRec */ - /* */ - /* <Description> */ - /* A structure modeling language tag records in SFNT `name' tables, */ - /* introduced in OpenType version 1.6. */ - /* */ - /* <Fields> */ - /* stringLength :: The length of the string in bytes. */ - /* */ - /* stringOffset :: The offset to the string in the `name' table. */ - /* */ - /* string :: A pointer to the string's bytes. Note that these */ - /* are UTF-16BE encoded characters. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_LangTagRec + * + * @description: + * A structure modeling language tag records in SFNT 'name' tables, + * introduced in OpenType version 1.6. + * + * @fields: + * stringLength :: + * The length of the string in bytes. + * + * stringOffset :: + * The offset to the string in the 'name' table. + * + * string :: + * A pointer to the string's bytes. Note that these are UTF-16BE + * encoded characters. + */ typedef struct TT_LangTagRec_ { FT_UShort stringLength; @@ -314,30 +344,36 @@ FT_BEGIN_HEADER } TT_LangTagRec, *TT_LangTag; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_NameTableRec */ - /* */ - /* <Description> */ - /* A structure modeling the TrueType name table. */ - /* */ - /* <Fields> */ - /* format :: The format of the name table. */ - /* */ - /* numNameRecords :: The number of names in table. */ - /* */ - /* storageOffset :: The offset of the name table in the `name' */ - /* TrueType table. */ - /* */ - /* names :: An array of name records. */ - /* */ - /* numLangTagRecords :: The number of language tags in table. */ - /* */ - /* langTags :: An array of language tag records. */ - /* */ - /* stream :: The file's input stream. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_NameTableRec + * + * @description: + * A structure modeling the TrueType name table. + * + * @fields: + * format :: + * The format of the name table. + * + * numNameRecords :: + * The number of names in table. + * + * storageOffset :: + * The offset of the name table in the 'name' TrueType table. + * + * names :: + * An array of name records. + * + * numLangTagRecords :: + * The number of language tags in table. + * + * langTags :: + * An array of language tag records. + * + * stream :: + * The file's input stream. + */ typedef struct TT_NameTableRec_ { FT_UShort format; @@ -364,21 +400,23 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GaspRangeRec */ - /* */ - /* <Description> */ - /* A tiny structure used to model a gasp range according to the */ - /* TrueType specification. */ - /* */ - /* <Fields> */ - /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */ - /* */ - /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */ - /* modes to be used. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_GaspRangeRec + * + * @description: + * A tiny structure used to model a gasp range according to the TrueType + * specification. + * + * @fields: + * maxPPEM :: + * The maximum ppem value to which `gaspFlag` applies. + * + * gaspFlag :: + * A flag describing the grid-fitting and anti-aliasing modes to be + * used. + */ typedef struct TT_GaspRangeRec_ { FT_UShort maxPPEM; @@ -391,22 +429,25 @@ FT_BEGIN_HEADER #define TT_GASP_DOGRAY 0x02 - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GaspRec */ - /* */ - /* <Description> */ - /* A structure modeling the TrueType `gasp' table used to specify */ - /* grid-fitting and anti-aliasing behaviour. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numRanges :: The number of gasp ranges in table. */ - /* */ - /* gaspRanges :: An array of gasp ranges. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_GaspRec + * + * @description: + * A structure modeling the TrueType 'gasp' table used to specify + * grid-fitting and anti-aliasing behaviour. + * + * @fields: + * version :: + * The version number. + * + * numRanges :: + * The number of gasp ranges in table. + * + * gaspRanges :: + * An array of gasp ranges. + */ typedef struct TT_Gasp_ { FT_UShort version; @@ -429,33 +470,41 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_MetricsRec */ - /* */ - /* <Description> */ - /* A structure used to hold the big metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or `bloc' (Apple) table. */ - /* */ - /* <Fields> */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* horiBearingX :: The horizontal left bearing. */ - /* */ - /* horiBearingY :: The horizontal top bearing. */ - /* */ - /* horiAdvance :: The horizontal advance. */ - /* */ - /* vertBearingX :: The vertical left bearing. */ - /* */ - /* vertBearingY :: The vertical top bearing. */ - /* */ - /* vertAdvance :: The vertical advance. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_MetricsRec + * + * @description: + * A structure used to hold the big metrics of a given glyph bitmap in a + * TrueType or OpenType font. These are usually found in the 'EBDT' + * (Microsoft) or 'bloc' (Apple) table. + * + * @fields: + * height :: + * The glyph height in pixels. + * + * width :: + * The glyph width in pixels. + * + * horiBearingX :: + * The horizontal left bearing. + * + * horiBearingY :: + * The horizontal top bearing. + * + * horiAdvance :: + * The horizontal advance. + * + * vertBearingX :: + * The vertical left bearing. + * + * vertBearingY :: + * The vertical top bearing. + * + * vertAdvance :: + * The vertical advance. + */ typedef struct TT_SBit_MetricsRec_ { FT_UShort height; @@ -472,27 +521,32 @@ FT_BEGIN_HEADER } TT_SBit_MetricsRec, *TT_SBit_Metrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_SmallMetricsRec */ - /* */ - /* <Description> */ - /* A structure used to hold the small metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */ - /* */ - /* <Fields> */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* bearingX :: The left-side bearing. */ - /* */ - /* bearingY :: The top-side bearing. */ - /* */ - /* advance :: The advance width or height. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_SmallMetricsRec + * + * @description: + * A structure used to hold the small metrics of a given glyph bitmap in + * a TrueType or OpenType font. These are usually found in the 'EBDT' + * (Microsoft) or the 'bdat' (Apple) table. + * + * @fields: + * height :: + * The glyph height in pixels. + * + * width :: + * The glyph width in pixels. + * + * bearingX :: + * The left-side bearing. + * + * bearingY :: + * The top-side bearing. + * + * advance :: + * The advance width or height. + */ typedef struct TT_SBit_Small_Metrics_ { FT_Byte height; @@ -505,57 +559,60 @@ FT_BEGIN_HEADER } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_LineMetricsRec */ - /* */ - /* <Description> */ - /* A structure used to describe the text line metrics of a given */ - /* bitmap strike, for either a horizontal or vertical layout. */ - /* */ - /* <Fields> */ - /* ascender :: The ascender in pixels. */ - /* */ - /* descender :: The descender in pixels. */ - /* */ - /* max_width :: The maximum glyph width in pixels. */ - /* */ - /* caret_slope_enumerator :: Rise of the caret slope, typically set */ - /* to 1 for non-italic fonts. */ - /* */ - /* caret_slope_denominator :: Rise of the caret slope, typically set */ - /* to 0 for non-italic fonts. */ - /* */ - /* caret_offset :: Offset in pixels to move the caret for */ - /* proper positioning. */ - /* */ - /* min_origin_SB :: Minimum of horiBearingX (resp. */ - /* vertBearingY). */ - /* min_advance_SB :: Minimum of */ - /* */ - /* horizontal advance - */ - /* ( horiBearingX + width ) */ - /* */ - /* resp. */ - /* */ - /* vertical advance - */ - /* ( vertBearingY + height ) */ - /* */ - /* max_before_BL :: Maximum of horiBearingY (resp. */ - /* vertBearingY). */ - /* */ - /* min_after_BL :: Minimum of */ - /* */ - /* horiBearingY - height */ - /* */ - /* resp. */ - /* */ - /* vertBearingX - width */ - /* */ - /* pads :: Unused (to make the size of the record */ - /* a multiple of 32 bits. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_LineMetricsRec + * + * @description: + * A structure used to describe the text line metrics of a given bitmap + * strike, for either a horizontal or vertical layout. + * + * @fields: + * ascender :: + * The ascender in pixels. + * + * descender :: + * The descender in pixels. + * + * max_width :: + * The maximum glyph width in pixels. + * + * caret_slope_enumerator :: + * Rise of the caret slope, typically set to 1 for non-italic fonts. + * + * caret_slope_denominator :: + * Rise of the caret slope, typically set to 0 for non-italic fonts. + * + * caret_offset :: + * Offset in pixels to move the caret for proper positioning. + * + * min_origin_SB :: + * Minimum of horiBearingX (resp. vertBearingY). + * min_advance_SB :: + * Minimum of + * + * horizontal advance - ( horiBearingX + width ) + * + * resp. + * + * vertical advance - ( vertBearingY + height ) + * + * max_before_BL :: + * Maximum of horiBearingY (resp. vertBearingY). + * + * min_after_BL :: + * Minimum of + * + * horiBearingY - height + * + * resp. + * + * vertBearingX - width + * + * pads :: + * Unused (to make the size of the record a multiple of 32 bits. + */ typedef struct TT_SBit_LineMetricsRec_ { FT_Char ascender; @@ -573,43 +630,53 @@ FT_BEGIN_HEADER } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_RangeRec */ - /* */ - /* <Description> */ - /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* <Fields> */ - /* first_glyph :: The first glyph index in the range. */ - /* */ - /* last_glyph :: The last glyph index in the range. */ - /* */ - /* index_format :: The format of index table. Valid values are 1 */ - /* to 5. */ - /* */ - /* image_format :: The format of `EBDT' image data. */ - /* */ - /* image_offset :: The offset to image data in `EBDT'. */ - /* */ - /* image_size :: For index formats 2 and 5. This is the size in */ - /* bytes of each glyph bitmap. */ - /* */ - /* big_metrics :: For index formats 2 and 5. This is the big */ - /* metrics for each glyph bitmap. */ - /* */ - /* num_glyphs :: For index formats 4 and 5. This is the number of */ - /* glyphs in the code array. */ - /* */ - /* glyph_offsets :: For index formats 1 and 3. */ - /* */ - /* glyph_codes :: For index formats 4 and 5. */ - /* */ - /* table_offset :: The offset of the index table in the `EBLC' */ - /* table. Only used during strike loading. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_RangeRec + * + * @description: + * A TrueType/OpenType subIndexTable as defined in the 'EBLC' (Microsoft) + * or 'bloc' (Apple) tables. + * + * @fields: + * first_glyph :: + * The first glyph index in the range. + * + * last_glyph :: + * The last glyph index in the range. + * + * index_format :: + * The format of index table. Valid values are 1 to 5. + * + * image_format :: + * The format of 'EBDT' image data. + * + * image_offset :: + * The offset to image data in 'EBDT'. + * + * image_size :: + * For index formats 2 and 5. This is the size in bytes of each glyph + * bitmap. + * + * big_metrics :: + * For index formats 2 and 5. This is the big metrics for each glyph + * bitmap. + * + * num_glyphs :: + * For index formats 4 and 5. This is the number of glyphs in the code + * array. + * + * glyph_offsets :: + * For index formats 1 and 3. + * + * glyph_codes :: + * For index formats 4 and 5. + * + * table_offset :: + * The offset of the index table in the 'EBLC' table. Only used during + * strike loading. + */ typedef struct TT_SBit_RangeRec_ { FT_UShort first_glyph; @@ -631,47 +698,55 @@ FT_BEGIN_HEADER } TT_SBit_RangeRec, *TT_SBit_Range; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_StrikeRec */ - /* */ - /* <Description> */ - /* A structure used describe a given bitmap strike in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* <Fields> */ - /* num_index_ranges :: The number of index ranges. */ - /* */ - /* index_ranges :: An array of glyph index ranges. */ - /* */ - /* color_ref :: Unused. `color_ref' is put in for future */ - /* enhancements, but these fields are already */ - /* in use by other platforms (e.g. Newton). */ - /* For details, please see */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */ - /* */ - /* hori :: The line metrics for horizontal layouts. */ - /* */ - /* vert :: The line metrics for vertical layouts. */ - /* */ - /* start_glyph :: The lowest glyph index for this strike. */ - /* */ - /* end_glyph :: The highest glyph index for this strike. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */ - /* and 8. */ - /* */ - /* flags :: Is this a vertical or horizontal strike? For */ - /* details, please see */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_StrikeRec + * + * @description: + * A structure used describe a given bitmap strike in the 'EBLC' + * (Microsoft) or 'bloc' (Apple) tables. + * + * @fields: + * num_index_ranges :: + * The number of index ranges. + * + * index_ranges :: + * An array of glyph index ranges. + * + * color_ref :: + * Unused. `color_ref` is put in for future enhancements, but these + * fields are already in use by other platforms (e.g. Newton). For + * details, please see + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html + * + * hori :: + * The line metrics for horizontal layouts. + * + * vert :: + * The line metrics for vertical layouts. + * + * start_glyph :: + * The lowest glyph index for this strike. + * + * end_glyph :: + * The highest glyph index for this strike. + * + * x_ppem :: + * The number of horizontal pixels per EM. + * + * y_ppem :: + * The number of vertical pixels per EM. + * + * bit_depth :: + * The bit depth. Valid values are 1, 2, 4, and 8. + * + * flags :: + * Is this a vertical or horizontal strike? For details, please see + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html + */ typedef struct TT_SBit_StrikeRec_ { FT_Int num_ranges; @@ -695,21 +770,24 @@ FT_BEGIN_HEADER } TT_SBit_StrikeRec, *TT_SBit_Strike; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_ComponentRec */ - /* */ - /* <Description> */ - /* A simple structure to describe a compound sbit element. */ - /* */ - /* <Fields> */ - /* glyph_code :: The element's glyph index. */ - /* */ - /* x_offset :: The element's left bearing. */ - /* */ - /* y_offset :: The element's top bearing. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_ComponentRec + * + * @description: + * A simple structure to describe a compound sbit element. + * + * @fields: + * glyph_code :: + * The element's glyph index. + * + * x_offset :: + * The element's left bearing. + * + * y_offset :: + * The element's top bearing. + */ typedef struct TT_SBit_ComponentRec_ { FT_UShort glyph_code; @@ -719,28 +797,34 @@ FT_BEGIN_HEADER } TT_SBit_ComponentRec, *TT_SBit_Component; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_ScaleRec */ - /* */ - /* <Description> */ - /* A structure used describe a given bitmap scaling table, as defined */ - /* in the `EBSC' table. */ - /* */ - /* <Fields> */ - /* hori :: The horizontal line metrics. */ - /* */ - /* vert :: The vertical line metrics. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* x_ppem_substitute :: Substitution x_ppem value. */ - /* */ - /* y_ppem_substitute :: Substitution y_ppem value. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_ScaleRec + * + * @description: + * A structure used describe a given bitmap scaling table, as defined in + * the 'EBSC' table. + * + * @fields: + * hori :: + * The horizontal line metrics. + * + * vert :: + * The vertical line metrics. + * + * x_ppem :: + * The number of horizontal pixels per EM. + * + * y_ppem :: + * The number of vertical pixels per EM. + * + * x_ppem_substitute :: + * Substitution x_ppem value. + * + * y_ppem_substitute :: + * Substitution y_ppem value. + */ typedef struct TT_SBit_ScaleRec_ { TT_SBit_LineMetricsRec hori; @@ -768,24 +852,28 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_20Rec */ - /* */ - /* <Description> */ - /* Postscript names sub-table, format 2.0. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* <Fields> */ - /* num_glyphs :: The number of named glyphs in the table. */ - /* */ - /* num_names :: The number of PS names stored in the table. */ - /* */ - /* glyph_indices :: The indices of the glyphs in the names arrays. */ - /* */ - /* glyph_names :: The PS names not in Mac Encoding. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Post_20Rec + * + * @description: + * Postscript names sub-table, format 2.0. Stores the PS name of each + * glyph in the font face. + * + * @fields: + * num_glyphs :: + * The number of named glyphs in the table. + * + * num_names :: + * The number of PS names stored in the table. + * + * glyph_indices :: + * The indices of the glyphs in the names arrays. + * + * glyph_names :: + * The PS names not in Mac Encoding. + */ typedef struct TT_Post_20Rec_ { FT_UShort num_glyphs; @@ -796,21 +884,22 @@ FT_BEGIN_HEADER } TT_Post_20Rec, *TT_Post_20; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_25Rec */ - /* */ - /* <Description> */ - /* Postscript names sub-table, format 2.5. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* <Fields> */ - /* num_glyphs :: The number of glyphs in the table. */ - /* */ - /* offsets :: An array of signed offsets in a normal Mac */ - /* Postscript name encoding. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Post_25Rec + * + * @description: + * Postscript names sub-table, format 2.5. Stores the PS name of each + * glyph in the font face. + * + * @fields: + * num_glyphs :: + * The number of glyphs in the table. + * + * offsets :: + * An array of signed offsets in a normal Mac Postscript name encoding. + */ typedef struct TT_Post_25_ { FT_UShort num_glyphs; @@ -819,21 +908,24 @@ FT_BEGIN_HEADER } TT_Post_25Rec, *TT_Post_25; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_NamesRec */ - /* */ - /* <Description> */ - /* Postscript names table, either format 2.0 or 2.5. */ - /* */ - /* <Fields> */ - /* loaded :: A flag to indicate whether the PS names are loaded. */ - /* */ - /* format_20 :: The sub-table used for format 2.0. */ - /* */ - /* format_25 :: The sub-table used for format 2.5. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Post_NamesRec + * + * @description: + * Postscript names table, either format 2.0 or 2.5. + * + * @fields: + * loaded :: + * A flag to indicate whether the PS names are loaded. + * + * format_20 :: + * The sub-table used for format 2.0. + * + * format_25 :: + * The sub-table used for format 2.5. + */ typedef struct TT_Post_NamesRec_ { FT_Bool loaded; @@ -879,25 +971,25 @@ FT_BEGIN_HEADER /* * These types are used to support a `BDF ' table that isn't part of the - * official TrueType specification. It is mainly used in SFNT-based - * bitmap fonts that were generated from a set of BDF fonts. + * official TrueType specification. It is mainly used in SFNT-based bitmap + * fonts that were generated from a set of BDF fonts. * * The format of the table is as follows. * - * USHORT version `BDF ' table version number, should be 0x0001. - * USHORT strikeCount Number of strikes (bitmap sizes) in this table. - * ULONG stringTable Offset (from start of BDF table) to string + * USHORT version `BDF ' table version number, should be 0x0001. USHORT + * strikeCount Number of strikes (bitmap sizes) in this table. ULONG + * stringTable Offset (from start of BDF table) to string * table. * * This is followed by an array of `strikeCount' descriptors, having the * following format. * - * USHORT ppem Vertical pixels per EM for this strike. - * USHORT numItems Number of items for this strike (properties and + * USHORT ppem Vertical pixels per EM for this strike. USHORT numItems + * Number of items for this strike (properties and * atoms). Maximum is 255. * - * This array in turn is followed by `strikeCount' value sets. Each - * `value set' is an array of `numItems' items with the following format. + * This array in turn is followed by `strikeCount' value sets. Each `value + * set' is an array of `numItems' items with the following format. * * ULONG item_name Offset in string table to item name. * USHORT item_type The item type. Possible values are @@ -945,31 +1037,30 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* This structure/class is defined here because it is common to the */ - /* following formats: TTF, OpenType-TT, and OpenType-CFF. */ - /* */ - /* Note, however, that the classes TT_Size and TT_GlyphSlot are not */ - /* shared between font drivers, and are thus defined in `ttobjs.h'. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This structure/class is defined here because it is common to the + * following formats: TTF, OpenType-TT, and OpenType-CFF. + * + * Note, however, that the classes TT_Size and TT_GlyphSlot are not shared + * between font drivers, and are thus defined in `ttobjs.h`. + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Face */ - /* */ - /* <Description> */ - /* A handle to a TrueType face/font object. A TT_Face encapsulates */ - /* the resolution and scaling independent parts of a TrueType font */ - /* resource. */ - /* */ - /* <Note> */ - /* The TT_Face structure is also used as a `parent class' for the */ - /* OpenType-CFF class (T2_Face). */ - /* */ + /************************************************************************** + * + * @type: + * TT_Face + * + * @description: + * A handle to a TrueType face/font object. A TT_Face encapsulates the + * resolution and scaling independent parts of a TrueType font resource. + * + * @note: + * The TT_Face structure is also used as a 'parent class' for the + * OpenType-CFF class (T2_Face). + */ typedef struct TT_FaceRec_* TT_Face; @@ -981,31 +1072,34 @@ FT_BEGIN_HEADER typedef struct TT_LoaderRec_* TT_Loader; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_GotoTableFunc */ - /* */ - /* <Description> */ - /* Seeks a stream to the start of a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* tag :: A 4-byte tag used to name the table. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Output> */ - /* length :: The length of the table in bytes. Set to 0 if not */ - /* needed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_GotoTableFunc + * + * @description: + * Seeks a stream to the start of a given TrueType table. + * + * @input: + * face :: + * A handle to the target face object. + * + * tag :: + * A 4-byte tag used to name the table. + * + * stream :: + * The input stream. + * + * @output: + * length :: + * The length of the table in bytes. Set to 0 if not needed. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The stream cursor must be at the font file's origin. + */ typedef FT_Error (*TT_Loader_GotoTableFunc)( TT_Face face, FT_ULong tag, @@ -1013,34 +1107,36 @@ FT_BEGIN_HEADER FT_ULong* length ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_StartGlyphFunc */ - /* */ - /* <Description> */ - /* Seeks a stream to the start of a given glyph element, and opens a */ - /* frame for it. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* glyph index :: The index of the glyph to access. */ - /* */ - /* offset :: The offset of the glyph according to the */ - /* `locations' table. */ - /* */ - /* byte_count :: The size of the frame in bytes. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function is normally equivalent to FT_STREAM_SEEK(offset) */ - /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */ - /* but alternative formats (e.g. compressed ones) might use something */ - /* different. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_StartGlyphFunc + * + * @description: + * Seeks a stream to the start of a given glyph element, and opens a + * frame for it. + * + * @input: + * loader :: + * The current TrueType glyph loader object. + * + * glyph index :: The index of the glyph to access. + * + * offset :: + * The offset of the glyph according to the 'locations' table. + * + * byte_count :: + * The size of the frame in bytes. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function is normally equivalent to FT_STREAM_SEEK(offset) + * followed by FT_FRAME_ENTER(byte_count) with the loader's stream, but + * alternative formats (e.g. compressed ones) might use something + * different. + */ typedef FT_Error (*TT_Loader_StartGlyphFunc)( TT_Loader loader, FT_UInt glyph_index, @@ -1048,36 +1144,38 @@ FT_BEGIN_HEADER FT_UInt byte_count ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_ReadGlyphFunc */ - /* */ - /* <Description> */ - /* Reads one glyph element (its header, a simple glyph, or a */ - /* composite) from the loader's current stream frame. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_ReadGlyphFunc + * + * @description: + * Reads one glyph element (its header, a simple glyph, or a composite) + * from the loader's current stream frame. + * + * @input: + * loader :: + * The current TrueType glyph loader object. + * + * @return: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Loader_ReadGlyphFunc)( TT_Loader loader ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_EndGlyphFunc */ - /* */ - /* <Description> */ - /* Closes the current loader stream frame for the glyph. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_EndGlyphFunc + * + * @description: + * Closes the current loader stream frame for the glyph. + * + * @input: + * loader :: + * The current TrueType glyph loader object. + */ typedef void (*TT_Loader_EndGlyphFunc)( TT_Loader loader ); @@ -1124,270 +1222,317 @@ FT_BEGIN_HEADER #define TT_FACE_FLAG_VAR_MVAR ( 1 << 8 ) - /*************************************************************************/ - /* */ - /* TrueType Face Type */ - /* */ - /* <Struct> */ - /* TT_Face */ - /* */ - /* <Description> */ - /* The TrueType face class. These objects model the resolution and */ - /* point-size independent data found in a TrueType font file. */ - /* */ - /* <Fields> */ - /* root :: The base FT_Face structure, managed by the */ - /* base layer. */ - /* */ - /* ttc_header :: The TrueType collection header, used when */ - /* the file is a `ttc' rather than a `ttf'. */ - /* For ordinary font files, the field */ - /* `ttc_header.count' is set to 0. */ - /* */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of TrueType tables in this font */ - /* file. */ - /* */ - /* dir_tables :: The directory of TrueType tables for this */ - /* font file. */ - /* */ - /* header :: The font's font header (`head' table). */ - /* Read on font opening. */ - /* */ - /* horizontal :: The font's horizontal header (`hhea' */ - /* table). This field also contains the */ - /* associated horizontal metrics table */ - /* (`hmtx'). */ - /* */ - /* max_profile :: The font's maximum profile table. Read on */ - /* font opening. Note that some maximum */ - /* values cannot be taken directly from this */ - /* table. We thus define additional fields */ - /* below to hold the computed maxima. */ - /* */ - /* vertical_info :: A boolean which is set when the font file */ - /* contains vertical metrics. If not, the */ - /* value of the `vertical' field is */ - /* undefined. */ - /* */ - /* vertical :: The font's vertical header (`vhea' table). */ - /* This field also contains the associated */ - /* vertical metrics table (`vmtx'), if found. */ - /* IMPORTANT: The contents of this field is */ - /* undefined if the `vertical_info' field is */ - /* unset. */ - /* */ - /* num_names :: The number of name records within this */ - /* TrueType font. */ - /* */ - /* name_table :: The table of name records (`name'). */ - /* */ - /* os2 :: The font's OS/2 table (`OS/2'). */ - /* */ - /* postscript :: The font's PostScript table (`post' */ - /* table). The PostScript glyph names are */ - /* not loaded by the driver on face opening. */ - /* See the `ttpost' module for more details. */ - /* */ - /* cmap_table :: Address of the face's `cmap' SFNT table */ - /* in memory (it's an extracted frame). */ - /* */ - /* cmap_size :: The size in bytes of the `cmap_table' */ - /* described above. */ - /* */ - /* goto_table :: A function called by each TrueType table */ - /* loader to position a stream's cursor to */ - /* the start of a given table according to */ - /* its tag. It defaults to TT_Goto_Face but */ - /* can be different for strange formats (e.g. */ - /* Type 42). */ - /* */ - /* access_glyph_frame :: A function used to access the frame of a */ - /* given glyph within the face's font file. */ - /* */ - /* forget_glyph_frame :: A function used to forget the frame of a */ - /* given glyph when all data has been loaded. */ - /* */ - /* read_glyph_header :: A function used to read a glyph header. */ - /* It must be called between an `access' and */ - /* `forget'. */ - /* */ - /* read_simple_glyph :: A function used to read a simple glyph. */ - /* It must be called after the header was */ - /* read, and before the `forget'. */ - /* */ - /* read_composite_glyph :: A function used to read a composite glyph. */ - /* It must be called after the header was */ - /* read, and before the `forget'. */ - /* */ - /* sfnt :: A pointer to the SFNT service. */ - /* */ - /* psnames :: A pointer to the PostScript names service. */ - /* */ - /* mm :: A pointer to the Multiple Masters service. */ - /* */ - /* var :: A pointer to the Metrics Variations */ - /* service. */ - /* */ - /* hdmx :: The face's horizontal device metrics */ - /* (`hdmx' table). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* gasp :: The grid-fitting and scaling properties */ - /* table (`gasp'). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* pclt :: The `pclt' SFNT table. */ - /* */ - /* num_sbit_scales :: The number of sbit scales for this font. */ - /* */ - /* sbit_scales :: Array of sbit scales embedded in this */ - /* font. This table is optional in a */ - /* TrueType/OpenType font. */ - /* */ - /* postscript_names :: A table used to store the Postscript names */ - /* of the glyphs for this font. See the */ - /* file `ttconfig.h' for comments on the */ - /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */ - /* */ - /* font_program_size :: Size in bytecodes of the face's font */ - /* program. 0 if none defined. Ignored for */ - /* Type 2 fonts. */ - /* */ - /* font_program :: The face's font program (bytecode stream) */ - /* executed at load time, also used during */ - /* glyph rendering. Comes from the `fpgm' */ - /* table. Ignored for Type 2 font fonts. */ - /* */ - /* cvt_program_size :: The size in bytecodes of the face's cvt */ - /* program. Ignored for Type 2 fonts. */ - /* */ - /* cvt_program :: The face's cvt program (bytecode stream) */ - /* executed each time an instance/size is */ - /* changed/reset. Comes from the `prep' */ - /* table. Ignored for Type 2 fonts. */ - /* */ - /* cvt_size :: Size of the control value table (in */ - /* entries). Ignored for Type 2 fonts. */ - /* */ - /* cvt :: The face's original control value table. */ - /* Coordinates are expressed in unscaled font */ - /* units. Comes from the `cvt ' table. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* interpreter :: A pointer to the TrueType bytecode */ - /* interpreters field is also used to hook */ - /* the debugger in `ttdebug'. */ - /* */ - /* extra :: Reserved for third-party font drivers. */ - /* */ - /* postscript_name :: The PS name of the font. Used by the */ - /* postscript name service. */ - /* */ - /* glyf_len :: The length of the `glyf' table. Needed */ - /* for malformed `loca' tables. */ - /* */ - /* glyf_offset :: The file offset of the `glyf' table. */ - /* */ - /* is_cff2 :: Set if the font format is CFF2. */ - /* */ - /* doblend :: A boolean which is set if the font should */ - /* be blended (this is for GX var). */ - /* */ - /* blend :: Contains the data needed to control GX */ - /* variation tables (rather like Multiple */ - /* Master data). */ - /* */ - /* variation_support :: Flags that indicate which OpenType */ - /* functionality related to font variation */ - /* support is present, valid, and usable. */ - /* For example, TT_FACE_FLAG_VAR_FVAR is only */ - /* set if we have at least one design axis. */ - /* */ - /* var_postscript_prefix :: */ - /* The PostScript name prefix needed for */ - /* constructing a variation font instance's */ - /* PS name . */ - /* */ - /* var_postscript_prefix_len :: */ - /* The length of the `var_postscript_prefix' */ - /* string. */ - /* */ - /* horz_metrics_size :: The size of the `hmtx' table. */ - /* */ - /* vert_metrics_size :: The size of the `vmtx' table. */ - /* */ - /* num_locations :: The number of glyph locations in this */ - /* TrueType file. This should be */ - /* identical to the number of glyphs. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* glyph_locations :: An array of longs. These are offsets to */ - /* glyph data within the `glyf' table. */ - /* Ignored for Type 2 font faces. */ - /* */ - /* hdmx_table :: A pointer to the `hdmx' table. */ - /* */ - /* hdmx_table_size :: The size of the `hdmx' table. */ - /* */ - /* hdmx_record_count :: The number of hdmx records. */ - /* */ - /* hdmx_record_size :: The size of a single hdmx record. */ - /* */ - /* hdmx_record_sizes :: An array holding the ppem sizes available */ - /* in the `hdmx' table. */ - /* */ - /* sbit_table :: A pointer to the font's embedded bitmap */ - /* location table. */ - /* */ - /* sbit_table_size :: The size of `sbit_table'. */ - /* */ - /* sbit_table_type :: The sbit table type (CBLC, sbix, etc.). */ - /* */ - /* sbit_num_strikes :: The number of sbit strikes exposed by */ - /* FreeType's API, omitting invalid strikes. */ - /* */ - /* sbit_strike_map :: A mapping between the strike indices */ - /* exposed by the API and the indices used in */ - /* the font's sbit table. */ - /* */ - /* kern_table :: A pointer to the `kern' table. */ - /* */ - /* kern_table_size :: The size of the `kern' table. */ - /* */ - /* num_kern_tables :: The number of supported kern subtables */ - /* (up to 32; FreeType recognizes only */ - /* horizontal ones with format 0). */ - /* */ - /* kern_avail_bits :: The availability status of kern subtables; */ - /* if bit n is set, table n is available. */ - /* */ - /* kern_order_bits :: The sortedness status of kern subtables; */ - /* if bit n is set, table n is sorted. */ - /* */ - /* bdf :: Data related to an SFNT font's `bdf' */ - /* table; see `tttypes.h'. */ - /* */ - /* horz_metrics_offset :: The file offset of the `hmtx' table. */ - /* */ - /* vert_metrics_offset :: The file offset of the `vmtx' table. */ - /* */ - /* sph_found_func_flags :: Flags identifying special bytecode */ - /* functions (used by the v38 implementation */ - /* of the bytecode interpreter). */ - /* */ - /* sph_compatibility_mode :: */ - /* This flag is set if we are in ClearType */ - /* backward compatibility mode (used by the */ - /* v38 implementation of the bytecode */ - /* interpreter). */ - /* */ - /* ebdt_start :: The file offset of the sbit data table */ - /* (CBDT, bdat, etc.). */ - /* */ - /* ebdt_size :: The size of the sbit data table. */ - /* */ + /************************************************************************** + * + * TrueType Face Type + * + * @struct: + * TT_Face + * + * @description: + * The TrueType face class. These objects model the resolution and + * point-size independent data found in a TrueType font file. + * + * @fields: + * root :: + * The base FT_Face structure, managed by the base layer. + * + * ttc_header :: + * The TrueType collection header, used when the file is a 'ttc' rather + * than a 'ttf'. For ordinary font files, the field `ttc_header.count` + * is set to 0. + * + * format_tag :: + * The font format tag. + * + * num_tables :: + * The number of TrueType tables in this font file. + * + * dir_tables :: + * The directory of TrueType tables for this font file. + * + * header :: + * The font's font header ('head' table). Read on font opening. + * + * horizontal :: + * The font's horizontal header ('hhea' table). This field also + * contains the associated horizontal metrics table ('hmtx'). + * + * max_profile :: + * The font's maximum profile table. Read on font opening. Note that + * some maximum values cannot be taken directly from this table. We + * thus define additional fields below to hold the computed maxima. + * + * vertical_info :: + * A boolean which is set when the font file contains vertical metrics. + * If not, the value of the 'vertical' field is undefined. + * + * vertical :: + * The font's vertical header ('vhea' table). This field also contains + * the associated vertical metrics table ('vmtx'), if found. + * IMPORTANT: The contents of this field is undefined if the + * `vertical_info` field is unset. + * + * num_names :: + * The number of name records within this TrueType font. + * + * name_table :: + * The table of name records ('name'). + * + * os2 :: + * The font's OS/2 table ('OS/2'). + * + * postscript :: + * The font's PostScript table ('post' table). The PostScript glyph + * names are not loaded by the driver on face opening. See the + * 'ttpost' module for more details. + * + * cmap_table :: + * Address of the face's 'cmap' SFNT table in memory (it's an extracted + * frame). + * + * cmap_size :: + * The size in bytes of the `cmap_table` described above. + * + * goto_table :: + * A function called by each TrueType table loader to position a + * stream's cursor to the start of a given table according to its tag. + * It defaults to TT_Goto_Face but can be different for strange formats + * (e.g. Type 42). + * + * access_glyph_frame :: + * A function used to access the frame of a given glyph within the + * face's font file. + * + * forget_glyph_frame :: + * A function used to forget the frame of a given glyph when all data + * has been loaded. + * + * read_glyph_header :: + * A function used to read a glyph header. It must be called between + * an 'access' and 'forget'. + * + * read_simple_glyph :: + * A function used to read a simple glyph. It must be called after the + * header was read, and before the 'forget'. + * + * read_composite_glyph :: + * A function used to read a composite glyph. It must be called after + * the header was read, and before the 'forget'. + * + * sfnt :: + * A pointer to the SFNT service. + * + * psnames :: + * A pointer to the PostScript names service. + * + * mm :: + * A pointer to the Multiple Masters service. + * + * var :: + * A pointer to the Metrics Variations service. + * + * hdmx :: + * The face's horizontal device metrics ('hdmx' table). This table is + * optional in TrueType/OpenType fonts. + * + * gasp :: + * The grid-fitting and scaling properties table ('gasp'). This table + * is optional in TrueType/OpenType fonts. + * + * pclt :: + * The 'pclt' SFNT table. + * + * num_sbit_scales :: + * The number of sbit scales for this font. + * + * sbit_scales :: + * Array of sbit scales embedded in this font. This table is optional + * in a TrueType/OpenType font. + * + * postscript_names :: + * A table used to store the Postscript names of the glyphs for this + * font. See the file `ttconfig.h` for comments on the + * TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. + * + * palette_data :: + * Some fields from the 'CPAL' table that are directly indexed. + * + * palette_index :: + * The current palette index, as set by @FT_Palette_Select. + * + * palette :: + * An array containing the current palette's colors. + * + * have_foreground_color :: + * There was a call to @FT_Palette_Set_Foreground_Color. + * + * foreground_color :: + * The current foreground color corresponding to 'CPAL' color index + * 0xFFFF. Only valid if `have_foreground_color` is set. + * + * font_program_size :: + * Size in bytecodes of the face's font program. 0 if none defined. + * Ignored for Type 2 fonts. + * + * font_program :: + * The face's font program (bytecode stream) executed at load time, + * also used during glyph rendering. Comes from the 'fpgm' table. + * Ignored for Type 2 font fonts. + * + * cvt_program_size :: + * The size in bytecodes of the face's cvt program. Ignored for Type 2 + * fonts. + * + * cvt_program :: + * The face's cvt program (bytecode stream) executed each time an + * instance/size is changed/reset. Comes from the 'prep' table. + * Ignored for Type 2 fonts. + * + * cvt_size :: + * Size of the control value table (in entries). Ignored for Type 2 + * fonts. + * + * cvt :: + * The face's original control value table. Coordinates are expressed + * in unscaled font units. Comes from the 'cvt~' table. Ignored for + * Type 2 fonts. + * + * interpreter :: + * A pointer to the TrueType bytecode interpreters field is also used + * to hook the debugger in 'ttdebug'. + * + * extra :: + * Reserved for third-party font drivers. + * + * postscript_name :: + * The PS name of the font. Used by the postscript name service. + * + * glyf_len :: + * The length of the 'glyf' table. Needed for malformed 'loca' tables. + * + * glyf_offset :: + * The file offset of the 'glyf' table. + * + * is_cff2 :: + * Set if the font format is CFF2. + * + * doblend :: + * A boolean which is set if the font should be blended (this is for GX + * var). + * + * blend :: + * Contains the data needed to control GX variation tables (rather like + * Multiple Master data). + * + * variation_support :: + * Flags that indicate which OpenType functionality related to font + * variation support is present, valid, and usable. For example, + * TT_FACE_FLAG_VAR_FVAR is only set if we have at least one design + * axis. + * + * var_postscript_prefix :: + * The PostScript name prefix needed for constructing a variation font + * instance's PS name . + * + * var_postscript_prefix_len :: + * The length of the `var_postscript_prefix` string. + * + * horz_metrics_size :: + * The size of the 'hmtx' table. + * + * vert_metrics_size :: + * The size of the 'vmtx' table. + * + * num_locations :: + * The number of glyph locations in this TrueType file. This should be + * identical to the number of glyphs. Ignored for Type 2 fonts. + * + * glyph_locations :: + * An array of longs. These are offsets to glyph data within the + * 'glyf' table. Ignored for Type 2 font faces. + * + * hdmx_table :: + * A pointer to the 'hdmx' table. + * + * hdmx_table_size :: + * The size of the 'hdmx' table. + * + * hdmx_record_count :: + * The number of hdmx records. + * + * hdmx_record_size :: + * The size of a single hdmx record. + * + * hdmx_record_sizes :: + * An array holding the ppem sizes available in the 'hdmx' table. + * + * sbit_table :: + * A pointer to the font's embedded bitmap location table. + * + * sbit_table_size :: + * The size of `sbit_table`. + * + * sbit_table_type :: + * The sbit table type (CBLC, sbix, etc.). + * + * sbit_num_strikes :: + * The number of sbit strikes exposed by FreeType's API, omitting + * invalid strikes. + * + * sbit_strike_map :: + * A mapping between the strike indices exposed by the API and the + * indices used in the font's sbit table. + * + * cpal :: + * A pointer to data related to the 'CPAL' table. `NULL` if the table + * is not available. + * + * colr :: + * A pointer to data related to the 'COLR' table. `NULL` if the table + * is not available. + * + * kern_table :: + * A pointer to the 'kern' table. + * + * kern_table_size :: + * The size of the 'kern' table. + * + * num_kern_tables :: + * The number of supported kern subtables (up to 32; FreeType + * recognizes only horizontal ones with format 0). + * + * kern_avail_bits :: + * The availability status of kern subtables; if bit n is set, table n + * is available. + * + * kern_order_bits :: + * The sortedness status of kern subtables; if bit n is set, table n is + * sorted. + * + * bdf :: + * Data related to an SFNT font's 'bdf' table; see `tttypes.h`. + * + * horz_metrics_offset :: + * The file offset of the 'hmtx' table. + * + * vert_metrics_offset :: + * The file offset of the 'vmtx' table. + * + * sph_found_func_flags :: + * Flags identifying special bytecode functions (used by the v38 + * implementation of the bytecode interpreter). + * + * sph_compatibility_mode :: + * This flag is set if we are in ClearType backward compatibility mode + * (used by the v38 implementation of the bytecode interpreter). + * + * ebdt_start :: + * The file offset of the sbit data table (CBDT, bdat, etc.). + * + * ebdt_size :: + * The size of the sbit data table. + */ typedef struct TT_FaceRec_ { FT_FaceRec root; @@ -1445,11 +1590,11 @@ FT_BEGIN_HEADER void* psaux; - /***********************************************************************/ - /* */ - /* Optional TrueType/OpenType tables */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * Optional TrueType/OpenType tables + * + */ /* grid-fitting and scaling table */ TT_GaspRec gasp; /* the `gasp' table */ @@ -1464,12 +1609,19 @@ FT_BEGIN_HEADER /* postscript names table */ TT_Post_NamesRec postscript_names; + /* glyph colors */ + FT_Palette_Data palette_data; /* since 2.10 */ + FT_UShort palette_index; + FT_Color* palette; + FT_Bool have_foreground_color; + FT_Color foreground_color; + - /***********************************************************************/ - /* */ - /* TrueType-specific fields (ignored by the CFF driver) */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * TrueType-specific fields (ignored by the CFF driver) + * + */ /* the font program, if any */ FT_ULong font_program_size; @@ -1488,12 +1640,12 @@ FT_BEGIN_HEADER TT_Interpreter interpreter; - /***********************************************************************/ - /* */ - /* Other tables or fields. This is used by derivative formats like */ - /* OpenType. */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * Other tables or fields. This is used by derivative formats like + * OpenType. + * + */ FT_Generic extra; @@ -1562,40 +1714,53 @@ FT_BEGIN_HEADER FT_ULong ebdt_size; #endif + /* since 2.10 */ + void* cpal; + void* colr; + } TT_FaceRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GlyphZoneRec */ - /* */ - /* <Description> */ - /* A glyph zone is used to load, scale and hint glyph outline */ - /* coordinates. */ - /* */ - /* <Fields> */ - /* memory :: A handle to the memory manager. */ - /* */ - /* max_points :: The maximum size in points of the zone. */ - /* */ - /* max_contours :: Max size in links contours of the zone. */ - /* */ - /* n_points :: The current number of points in the zone. */ - /* */ - /* n_contours :: The current number of contours in the zone. */ - /* */ - /* org :: The original glyph coordinates (font */ - /* units/scaled). */ - /* */ - /* cur :: The current glyph coordinates (scaled/hinted). */ - /* */ - /* tags :: The point control tags. */ - /* */ - /* contours :: The contours end points. */ - /* */ - /* first_point :: Offset of the current subglyph's first point. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_GlyphZoneRec + * + * @description: + * A glyph zone is used to load, scale and hint glyph outline + * coordinates. + * + * @fields: + * memory :: + * A handle to the memory manager. + * + * max_points :: + * The maximum size in points of the zone. + * + * max_contours :: + * Max size in links contours of the zone. + * + * n_points :: + * The current number of points in the zone. + * + * n_contours :: + * The current number of contours in the zone. + * + * org :: + * The original glyph coordinates (font units/scaled). + * + * cur :: + * The current glyph coordinates (scaled/hinted). + * + * tags :: + * The point control tags. + * + * contours :: + * The contours end points. + * + * first_point :: + * Offset of the current subglyph's first point. + */ typedef struct TT_GlyphZoneRec_ { FT_Memory memory; @@ -1620,14 +1785,14 @@ FT_BEGIN_HEADER typedef struct TT_ExecContextRec_* TT_ExecContext; - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Size */ - /* */ - /* <Description> */ - /* A handle to a TrueType size object. */ - /* */ + /************************************************************************** + * + * @type: + * TT_Size + * + * @description: + * A handle to a TrueType size object. + */ typedef struct TT_SizeRec_* TT_Size; diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h index 3503c2616bd..645e6457201 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* t1tables.h */ -/* */ -/* Basic Type 1/Type 2 tables definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1tables.h + * + * Basic Type 1/Type 2 tables definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1TABLES_H_ @@ -34,58 +34,58 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* type1_tables */ - /* */ - /* <Title> */ - /* Type 1 Tables */ - /* */ - /* <Abstract> */ - /* Type~1 (PostScript) specific font tables. */ - /* */ - /* <Description> */ - /* This section contains the definition of Type 1-specific tables, */ - /* including structures related to other PostScript font formats. */ - /* */ - /* <Order> */ - /* PS_FontInfoRec */ - /* PS_FontInfo */ - /* PS_PrivateRec */ - /* PS_Private */ - /* */ - /* CID_FaceDictRec */ - /* CID_FaceDict */ - /* CID_FaceInfoRec */ - /* CID_FaceInfo */ - /* */ - /* FT_Has_PS_Glyph_Names */ - /* FT_Get_PS_Font_Info */ - /* FT_Get_PS_Font_Private */ - /* FT_Get_PS_Font_Value */ - /* */ - /* T1_Blend_Flags */ - /* T1_EncodingType */ - /* PS_Dict_Keys */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * type1_tables + * + * @title: + * Type 1 Tables + * + * @abstract: + * Type~1-specific font tables. + * + * @description: + * This section contains the definition of Type~1-specific tables, + * including structures related to other PostScript font formats. + * + * @order: + * PS_FontInfoRec + * PS_FontInfo + * PS_PrivateRec + * PS_Private + * + * CID_FaceDictRec + * CID_FaceDict + * CID_FaceInfoRec + * CID_FaceInfo + * + * FT_Has_PS_Glyph_Names + * FT_Get_PS_Font_Info + * FT_Get_PS_Font_Private + * FT_Get_PS_Font_Value + * + * T1_Blend_Flags + * T1_EncodingType + * PS_Dict_Keys + * + */ /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ /* structures in order to support Multiple Master fonts. */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfoRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* FontInfo dictionary. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_FontInfoRec + * + * @description: + * A structure used to model a Type~1 or Type~2 FontInfo dictionary. + * Note that for Multiple Master fonts, each instance has its own + * FontInfo dictionary. + */ typedef struct PS_FontInfoRec_ { FT_String* version; @@ -101,40 +101,39 @@ FT_BEGIN_HEADER } PS_FontInfoRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfo */ - /* */ - /* <Description> */ - /* A handle to a @PS_FontInfoRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_FontInfo + * + * @description: + * A handle to a @PS_FontInfoRec structure. + */ typedef struct PS_FontInfoRec_* PS_FontInfo; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_FontInfo */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_FontInfo + * + * @description: + * This type is equivalent to @PS_FontInfoRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ typedef PS_FontInfoRec T1_FontInfo; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_PrivateRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 private dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* Private dictionary. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_PrivateRec + * + * @description: + * A structure used to model a Type~1 or Type~2 private dictionary. Note + * that for Multiple Master fonts, each instance has its own Private + * dictionary. + */ typedef struct PS_PrivateRec_ { FT_Int unique_id; @@ -176,56 +175,55 @@ FT_BEGIN_HEADER } PS_PrivateRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Private */ - /* */ - /* <Description> */ - /* A handle to a @PS_PrivateRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_Private + * + * @description: + * A handle to a @PS_PrivateRec structure. + */ typedef struct PS_PrivateRec_* PS_Private; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_Private */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_PrivateRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_Private + * + * @description: + * This type is equivalent to @PS_PrivateRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ typedef PS_PrivateRec T1_Private; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_Blend_Flags */ - /* */ - /* <Description> */ - /* A set of flags used to indicate which fields are present in a */ - /* given blend dictionary (font info or private). Used to support */ - /* Multiple Masters fonts. */ - /* */ - /* <Values> */ - /* T1_BLEND_UNDERLINE_POSITION :: */ - /* T1_BLEND_UNDERLINE_THICKNESS :: */ - /* T1_BLEND_ITALIC_ANGLE :: */ - /* T1_BLEND_BLUE_VALUES :: */ - /* T1_BLEND_OTHER_BLUES :: */ - /* T1_BLEND_STANDARD_WIDTH :: */ - /* T1_BLEND_STANDARD_HEIGHT :: */ - /* T1_BLEND_STEM_SNAP_WIDTHS :: */ - /* T1_BLEND_STEM_SNAP_HEIGHTS :: */ - /* T1_BLEND_BLUE_SCALE :: */ - /* T1_BLEND_BLUE_SHIFT :: */ - /* T1_BLEND_FAMILY_BLUES :: */ - /* T1_BLEND_FAMILY_OTHER_BLUES :: */ - /* T1_BLEND_FORCE_BOLD :: */ - /* */ + /************************************************************************** + * + * @enum: + * T1_Blend_Flags + * + * @description: + * A set of flags used to indicate which fields are present in a given + * blend dictionary (font info or private). Used to support Multiple + * Masters fonts. + * + * @values: + * T1_BLEND_UNDERLINE_POSITION :: + * T1_BLEND_UNDERLINE_THICKNESS :: + * T1_BLEND_ITALIC_ANGLE :: + * T1_BLEND_BLUE_VALUES :: + * T1_BLEND_OTHER_BLUES :: + * T1_BLEND_STANDARD_WIDTH :: + * T1_BLEND_STANDARD_HEIGHT :: + * T1_BLEND_STEM_SNAP_WIDTHS :: + * T1_BLEND_STEM_SNAP_HEIGHTS :: + * T1_BLEND_BLUE_SCALE :: + * T1_BLEND_BLUE_SHIFT :: + * T1_BLEND_FAMILY_BLUES :: + * T1_BLEND_FAMILY_OTHER_BLUES :: + * T1_BLEND_FORCE_BOLD :: + */ typedef enum T1_Blend_Flags_ { /* required fields in a FontInfo blend dictionary */ @@ -252,7 +250,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `T1_Blend_Flags' values instead */ + /* `T1_Blend_Flags` values instead */ #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE @@ -330,14 +328,23 @@ FT_BEGIN_HEADER typedef PS_BlendRec T1_Blend; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDictRec */ - /* */ - /* <Description> */ - /* A structure used to represent data in a CID top-level dictionary. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceDictRec + * + * @description: + * A structure used to represent data in a CID top-level dictionary. In + * most cases, they are part of the font's '/FDArray' array. Within a + * CID font file, such (internal) subfont dictionaries are enclosed by + * '%ADOBeginFontDict' and '%ADOEndFontDict' comments. + * + * Note that `CID_FaceDictRec` misses a field for the '/FontName' + * keyword, specifying the subfont's name (the top-level font name is + * given by the '/CIDFontName' keyword). This is an oversight, but it + * doesn't limit the 'cid' font module's functionality because FreeType + * neither needs this entry nor gives access to CID subfonts. + */ typedef struct CID_FaceDictRec_ { PS_PrivateRec private_dict; @@ -345,8 +352,8 @@ FT_BEGIN_HEADER FT_UInt len_buildchar; FT_Fixed forcebold_threshold; FT_Pos stroke_width; - FT_Fixed expansion_factor; - + FT_Fixed expansion_factor; /* this is a duplicate of */ + /* `private_dict->expansion_factor' */ FT_Byte paint_type; FT_Byte font_type; FT_Matrix font_matrix; @@ -359,38 +366,38 @@ FT_BEGIN_HEADER } CID_FaceDictRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDict */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceDictRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceDict + * + * @description: + * A handle to a @CID_FaceDictRec structure. + */ typedef struct CID_FaceDictRec_* CID_FaceDict; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FontDict */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FontDict + * + * @description: + * This type is equivalent to @CID_FaceDictRec. It is deprecated but + * kept to maintain source compatibility between various versions of + * FreeType. + */ typedef CID_FaceDictRec CID_FontDict; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfoRec */ - /* */ - /* <Description> */ - /* A structure used to represent CID Face information. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceInfoRec + * + * @description: + * A structure used to represent CID Face information. + */ typedef struct CID_FaceInfoRec_ { FT_String* cid_font_name; @@ -421,47 +428,45 @@ FT_BEGIN_HEADER } CID_FaceInfoRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfo */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceInfoRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceInfo + * + * @description: + * A handle to a @CID_FaceInfoRec structure. + */ typedef struct CID_FaceInfoRec_* CID_FaceInfo; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_Info */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_Info + * + * @description: + * This type is equivalent to @CID_FaceInfoRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ typedef CID_FaceInfoRec CID_Info; - /************************************************************************ + /************************************************************************** * * @function: * FT_Has_PS_Glyph_Names * * @description: - * Return true if a given face provides reliable PostScript glyph - * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, - * except that certain fonts (mostly TrueType) contain incorrect - * glyph name tables. + * Return true if a given face provides reliable PostScript glyph names. + * This is similar to using the @FT_HAS_GLYPH_NAMES macro, except that + * certain fonts (mostly TrueType) contain incorrect glyph name tables. * * When this function returns true, the caller is sure that the glyph * names returned by @FT_Get_Glyph_Name are reliable. * * @input: * face :: - * face handle + * face handle * * @return: * Boolean. True if glyph names are reliable. @@ -471,7 +476,7 @@ FT_BEGIN_HEADER FT_Has_PS_Glyph_Names( FT_Face face ); - /************************************************************************ + /************************************************************************** * * @function: * FT_Get_PS_Font_Info @@ -482,22 +487,22 @@ FT_BEGIN_HEADER * * @input: * face :: - * PostScript face handle. + * PostScript face handle. * * @output: * afont_info :: - * Output font info structure pointer. + * Output font info structure pointer. * * @return: * FreeType error code. 0~means success. * * @note: - * String pointers within the @PS_FontInfoRec structure are owned by - * the face and don't need to be freed by the caller. Missing entries - * in the font's FontInfo dictionary are represented by NULL pointers. + * String pointers within the @PS_FontInfoRec structure are owned by the + * face and don't need to be freed by the caller. Missing entries in + * the font's FontInfo dictionary are represented by `NULL` pointers. * * If the font's format is not PostScript-based, this function will - * return the `FT_Err_Invalid_Argument' error code. + * return the `FT_Err_Invalid_Argument` error code. * */ FT_EXPORT( FT_Error ) @@ -505,7 +510,7 @@ FT_BEGIN_HEADER PS_FontInfo afont_info ); - /************************************************************************ + /************************************************************************** * * @function: * FT_Get_PS_Font_Private @@ -516,11 +521,11 @@ FT_BEGIN_HEADER * * @input: * face :: - * PostScript face handle. + * PostScript face handle. * * @output: * afont_private :: - * Output private dictionary structure pointer. + * Output private dictionary structure pointer. * * @return: * FreeType error code. 0~means success. @@ -530,7 +535,7 @@ FT_BEGIN_HEADER * the face and don't need to be freed by the caller. * * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. + * the `FT_Err_Invalid_Argument` error code. * */ FT_EXPORT( FT_Error ) @@ -538,25 +543,24 @@ FT_BEGIN_HEADER PS_Private afont_private ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_EncodingType */ - /* */ - /* <Description> */ - /* An enumeration describing the `Encoding' entry in a Type 1 */ - /* dictionary. */ - /* */ - /* <Values> */ - /* T1_ENCODING_TYPE_NONE :: */ - /* T1_ENCODING_TYPE_ARRAY :: */ - /* T1_ENCODING_TYPE_STANDARD :: */ - /* T1_ENCODING_TYPE_ISOLATIN1 :: */ - /* T1_ENCODING_TYPE_EXPERT :: */ - /* */ - /* <Since> */ - /* 2.4.8 */ - /* */ + /************************************************************************** + * + * @enum: + * T1_EncodingType + * + * @description: + * An enumeration describing the 'Encoding' entry in a Type 1 dictionary. + * + * @values: + * T1_ENCODING_TYPE_NONE :: + * T1_ENCODING_TYPE_ARRAY :: + * T1_ENCODING_TYPE_STANDARD :: + * T1_ENCODING_TYPE_ISOLATIN1 :: + * T1_ENCODING_TYPE_EXPERT :: + * + * @since: + * 2.4.8 + */ typedef enum T1_EncodingType_ { T1_ENCODING_TYPE_NONE = 0, @@ -568,66 +572,66 @@ FT_BEGIN_HEADER } T1_EncodingType; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* PS_Dict_Keys */ - /* */ - /* <Description> */ - /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */ - /* the Type~1 dictionary entry to retrieve. */ - /* */ - /* <Values> */ - /* PS_DICT_FONT_TYPE :: */ - /* PS_DICT_FONT_MATRIX :: */ - /* PS_DICT_FONT_BBOX :: */ - /* PS_DICT_PAINT_TYPE :: */ - /* PS_DICT_FONT_NAME :: */ - /* PS_DICT_UNIQUE_ID :: */ - /* PS_DICT_NUM_CHAR_STRINGS :: */ - /* PS_DICT_CHAR_STRING_KEY :: */ - /* PS_DICT_CHAR_STRING :: */ - /* PS_DICT_ENCODING_TYPE :: */ - /* PS_DICT_ENCODING_ENTRY :: */ - /* PS_DICT_NUM_SUBRS :: */ - /* PS_DICT_SUBR :: */ - /* PS_DICT_STD_HW :: */ - /* PS_DICT_STD_VW :: */ - /* PS_DICT_NUM_BLUE_VALUES :: */ - /* PS_DICT_BLUE_VALUE :: */ - /* PS_DICT_BLUE_FUZZ :: */ - /* PS_DICT_NUM_OTHER_BLUES :: */ - /* PS_DICT_OTHER_BLUE :: */ - /* PS_DICT_NUM_FAMILY_BLUES :: */ - /* PS_DICT_FAMILY_BLUE :: */ - /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */ - /* PS_DICT_FAMILY_OTHER_BLUE :: */ - /* PS_DICT_BLUE_SCALE :: */ - /* PS_DICT_BLUE_SHIFT :: */ - /* PS_DICT_NUM_STEM_SNAP_H :: */ - /* PS_DICT_STEM_SNAP_H :: */ - /* PS_DICT_NUM_STEM_SNAP_V :: */ - /* PS_DICT_STEM_SNAP_V :: */ - /* PS_DICT_FORCE_BOLD :: */ - /* PS_DICT_RND_STEM_UP :: */ - /* PS_DICT_MIN_FEATURE :: */ - /* PS_DICT_LEN_IV :: */ - /* PS_DICT_PASSWORD :: */ - /* PS_DICT_LANGUAGE_GROUP :: */ - /* PS_DICT_VERSION :: */ - /* PS_DICT_NOTICE :: */ - /* PS_DICT_FULL_NAME :: */ - /* PS_DICT_FAMILY_NAME :: */ - /* PS_DICT_WEIGHT :: */ - /* PS_DICT_IS_FIXED_PITCH :: */ - /* PS_DICT_UNDERLINE_POSITION :: */ - /* PS_DICT_UNDERLINE_THICKNESS :: */ - /* PS_DICT_FS_TYPE :: */ - /* PS_DICT_ITALIC_ANGLE :: */ - /* */ - /* <Since> */ - /* 2.4.8 */ - /* */ + /************************************************************************** + * + * @enum: + * PS_Dict_Keys + * + * @description: + * An enumeration used in calls to @FT_Get_PS_Font_Value to identify the + * Type~1 dictionary entry to retrieve. + * + * @values: + * PS_DICT_FONT_TYPE :: + * PS_DICT_FONT_MATRIX :: + * PS_DICT_FONT_BBOX :: + * PS_DICT_PAINT_TYPE :: + * PS_DICT_FONT_NAME :: + * PS_DICT_UNIQUE_ID :: + * PS_DICT_NUM_CHAR_STRINGS :: + * PS_DICT_CHAR_STRING_KEY :: + * PS_DICT_CHAR_STRING :: + * PS_DICT_ENCODING_TYPE :: + * PS_DICT_ENCODING_ENTRY :: + * PS_DICT_NUM_SUBRS :: + * PS_DICT_SUBR :: + * PS_DICT_STD_HW :: + * PS_DICT_STD_VW :: + * PS_DICT_NUM_BLUE_VALUES :: + * PS_DICT_BLUE_VALUE :: + * PS_DICT_BLUE_FUZZ :: + * PS_DICT_NUM_OTHER_BLUES :: + * PS_DICT_OTHER_BLUE :: + * PS_DICT_NUM_FAMILY_BLUES :: + * PS_DICT_FAMILY_BLUE :: + * PS_DICT_NUM_FAMILY_OTHER_BLUES :: + * PS_DICT_FAMILY_OTHER_BLUE :: + * PS_DICT_BLUE_SCALE :: + * PS_DICT_BLUE_SHIFT :: + * PS_DICT_NUM_STEM_SNAP_H :: + * PS_DICT_STEM_SNAP_H :: + * PS_DICT_NUM_STEM_SNAP_V :: + * PS_DICT_STEM_SNAP_V :: + * PS_DICT_FORCE_BOLD :: + * PS_DICT_RND_STEM_UP :: + * PS_DICT_MIN_FEATURE :: + * PS_DICT_LEN_IV :: + * PS_DICT_PASSWORD :: + * PS_DICT_LANGUAGE_GROUP :: + * PS_DICT_VERSION :: + * PS_DICT_NOTICE :: + * PS_DICT_FULL_NAME :: + * PS_DICT_FAMILY_NAME :: + * PS_DICT_WEIGHT :: + * PS_DICT_IS_FIXED_PITCH :: + * PS_DICT_UNDERLINE_POSITION :: + * PS_DICT_UNDERLINE_THICKNESS :: + * PS_DICT_FS_TYPE :: + * PS_DICT_ITALIC_ANGLE :: + * + * @since: + * 2.4.8 + */ typedef enum PS_Dict_Keys_ { /* conventionally in the font dictionary */ @@ -687,7 +691,7 @@ FT_BEGIN_HEADER } PS_Dict_Keys; - /************************************************************************ + /************************************************************************** * * @function: * FT_Get_PS_Font_Value @@ -697,57 +701,57 @@ FT_BEGIN_HEADER * * @input: * face :: - * PostScript face handle. + * PostScript face handle. * * key :: - * An enumeration value representing the dictionary key to retrieve. + * An enumeration value representing the dictionary key to retrieve. * * idx :: - * For array values, this specifies the index to be returned. + * For array values, this specifies the index to be returned. * * value :: - * A pointer to memory into which to write the value. + * A pointer to memory into which to write the value. * * valen_len :: - * The size, in bytes, of the memory supplied for the value. + * The size, in bytes, of the memory supplied for the value. * * @output: * value :: - * The value matching the above key, if it exists. + * The value matching the above key, if it exists. * * @return: - * The amount of memory (in bytes) required to hold the requested - * value (if it exists, -1 otherwise). + * The amount of memory (in bytes) required to hold the requested value + * (if it exists, -1 otherwise). * * @note: * The values returned are not pointers into the internal structures of - * the face, but are `fresh' copies, so that the memory containing them + * the face, but are 'fresh' copies, so that the memory containing them * belongs to the calling application. This also enforces the - * `read-only' nature of these values, i.e., this function cannot be + * 'read-only' nature of these values, i.e., this function cannot be * used to manipulate the face. * - * `value' is a void pointer because the values returned can be of + * `value` is a void pointer because the values returned can be of * various types. * - * If either `value' is NULL or `value_len' is too small, just the + * If either `value` is `NULL` or `value_len` is too small, just the * required memory size for the requested entry is returned. * - * The `idx' parameter is used, not only to retrieve elements of, for + * The `idx` parameter is used, not only to retrieve elements of, for * example, the FontMatrix or FontBBox, but also to retrieve name keys * from the CharStrings dictionary, and the charstrings themselves. It * is ignored for atomic values. * - * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To - * get the value as in the font stream, you need to divide by - * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale). + * `PS_DICT_BLUE_SCALE` returns a value that is scaled up by 1000. To + * get the value as in the font stream, you need to divide by 65536000.0 + * (to remove the FT_Fixed scale, and the x1000 scale). * * IMPORTANT: Only key/value pairs read by the FreeType interpreter can - * be retrieved. So, for example, PostScript procedures such as NP, - * ND, and RD are not available. Arbitrary keys are, obviously, not be + * be retrieved. So, for example, PostScript procedures such as NP, ND, + * and RD are not available. Arbitrary keys are, obviously, not be * available either. * * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. + * the `FT_Err_Invalid_Argument` error code. * * @since: * 2.4.8 diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h index 8605183dc70..cc677de75ad 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/ttnameid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttnameid.h */ -/* */ -/* TrueType name ID definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttnameid.h + * + * TrueType name ID definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTNAMEID_H_ @@ -26,53 +26,54 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ + /************************************************************************** + * + * @section: + * truetype_tables + */ - /*************************************************************************/ - /* */ - /* Possible values for the `platform' identifier code in the name */ - /* records of an SFNT `name' table. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Possible values for the 'platform' identifier code in the name records + * of an SFNT 'name' table. + * + */ - /*********************************************************************** + /************************************************************************** * * @enum: * TT_PLATFORM_XXX * * @description: - * A list of valid values for the `platform_id' identifier code in + * A list of valid values for the `platform_id` identifier code in * @FT_CharMapRec and @FT_SfntName structures. * * @values: * TT_PLATFORM_APPLE_UNICODE :: * Used by Apple to indicate a Unicode character map and/or name entry. - * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note + * See @TT_APPLE_ID_XXX for corresponding `encoding_id` values. Note * that name entries in this format are coded as big-endian UCS-2 * character codes _only_. * * TT_PLATFORM_MACINTOSH :: - * Used by Apple to indicate a MacOS-specific charmap and/or name entry. - * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that - * most TrueType fonts contain an Apple roman charmap to be usable on - * MacOS systems (even if they contain a Microsoft charmap as well). + * Used by Apple to indicate a MacOS-specific charmap and/or name + * entry. See @TT_MAC_ID_XXX for corresponding `encoding_id` values. + * Note that most TrueType fonts contain an Apple roman charmap to be + * usable on MacOS systems (even if they contain a Microsoft charmap as + * well). * * TT_PLATFORM_ISO :: - * This value was used to specify ISO/IEC 10646 charmaps. It is however - * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding - * `encoding_id' values. + * This value was used to specify ISO/IEC 10646 charmaps. It is + * however now deprecated. See @TT_ISO_ID_XXX for a list of + * corresponding `encoding_id` values. * * TT_PLATFORM_MICROSOFT :: * Used by Microsoft to indicate Windows-specific charmaps. See - * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. + * @TT_MS_ID_XXX for a list of corresponding `encoding_id` values. * Note that most fonts contain a Unicode charmap using - * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). + * (`TT_PLATFORM_MICROSOFT`, @TT_MS_ID_UNICODE_CS). * * TT_PLATFORM_CUSTOM :: * Used to indicate application-specific charmaps. @@ -91,13 +92,13 @@ FT_BEGIN_HEADER #define TT_PLATFORM_ADOBE 7 /* artificial */ - /*********************************************************************** + /************************************************************************** * * @enum: * TT_APPLE_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for + * A list of valid values for the `encoding_id` for * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. * * @values: @@ -117,8 +118,8 @@ FT_BEGIN_HEADER * Unicode 3.1 and beyond, using UTF-32. * * TT_APPLE_ID_VARIANT_SELECTOR :: - * From Adobe, not Apple. Not a normal cmap. Specifies variations - * on a real cmap. + * From Adobe, not Apple. Not a normal cmap. Specifies variations on + * a real cmap. * * TT_APPLE_ID_FULL_UNICODE :: * Used for fallback fonts that provide complete Unicode coverage with @@ -134,13 +135,13 @@ FT_BEGIN_HEADER #define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */ - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MAC_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for + * A list of valid values for the `encoding_id` for * @TT_PLATFORM_MACINTOSH charmaps and name entries. */ @@ -180,14 +181,14 @@ FT_BEGIN_HEADER #define TT_MAC_ID_UNINTERP 32 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_ISO_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ISO charmaps and name entries. + * A list of valid values for the `encoding_id` for @TT_PLATFORM_ISO + * charmaps and name entries. * * Their use is now deprecated. * @@ -205,13 +206,13 @@ FT_BEGIN_HEADER #define TT_ISO_ID_8859_1 2 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MS_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for + * A list of valid values for the `encoding_id` for * @TT_PLATFORM_MICROSOFT charmaps and name entries. * * @values: @@ -219,16 +220,15 @@ FT_BEGIN_HEADER * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL. * * TT_MS_ID_UNICODE_CS :: - * Microsoft WGL4 charmap, matching Unicode. See - * @FT_ENCODING_UNICODE. + * Microsoft WGL4 charmap, matching Unicode. See @FT_ENCODING_UNICODE. * * TT_MS_ID_SJIS :: * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS. * * TT_MS_ID_PRC :: * Chinese encodings as used in the People's Republic of China (PRC). - * This means the encodings GB~2312 and its supersets GBK and - * GB~18030. See @FT_ENCODING_PRC. + * This means the encodings GB~2312 and its supersets GBK and GB~18030. + * See @FT_ENCODING_PRC. * * TT_MS_ID_BIG_5 :: * Traditional Chinese as used in Taiwan and Hong Kong. See @@ -258,14 +258,14 @@ FT_BEGIN_HEADER #define TT_MS_ID_GB2312 TT_MS_ID_PRC - /*********************************************************************** + /************************************************************************** * * @enum: * TT_ADOBE_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! + * A list of valid values for the `encoding_id` for @TT_PLATFORM_ADOBE + * charmaps. This is a FreeType-specific extension! * * @values: * TT_ADOBE_ID_STANDARD :: @@ -284,14 +284,14 @@ FT_BEGIN_HEADER #define TT_ADOBE_ID_LATIN_1 3 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MAC_LANGID_XXX * * @description: * Possible values of the language identifier field in the name records - * of the SFNT `name' table if the `platform' identifier code is + * of the SFNT 'name' table if the 'platform' identifier code is * @TT_PLATFORM_MACINTOSH. These values are also used as return values * for function @FT_Get_CMap_Language_ID. * @@ -424,24 +424,24 @@ FT_BEGIN_HEADER #define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MS_LANGID_XXX * * @description: * Possible values of the language identifier field in the name records - * of the SFNT `name' table if the `platform' identifier code is + * of the SFNT 'name' table if the 'platform' identifier code is * @TT_PLATFORM_MICROSOFT. These values are also used as return values * for function @FT_Get_CMap_Language_ID. * * The canonical source for Microsoft's IDs is * - * https://www.microsoft.com/globaldev/reference/lcid-all.mspx , + * https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings , * * however, we only provide macros for language identifiers present in * the OpenType specification: Microsoft has abandoned the concept of - * LCIDs (language code identifiers), and format~1 of the `name' table + * LCIDs (language code identifiers), and format~1 of the 'name' table * provides a better mechanism for languages not covered here. * * More legacy values not listed in the reference can be found in the @@ -780,14 +780,14 @@ FT_BEGIN_HEADER TT_MS_LANGID_UIGHUR_PRC - /*********************************************************************** + /************************************************************************** * * @enum: * TT_NAME_ID_XXX * * @description: - * Possible values of the `name' identifier field in the name records of - * an SFNT `name' table. These values are platform independent. + * Possible values of the 'name' identifier field in the name records of + * an SFNT 'name' table. These values are platform independent. */ #define TT_NAME_ID_COPYRIGHT 0 @@ -834,14 +834,14 @@ FT_BEGIN_HEADER #define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY - /*********************************************************************** + /************************************************************************** * * @enum: * TT_UCR_XXX * * @description: - * Possible bit mask values for the `ulUnicodeRangeX' fields in an SFNT - * `OS/2' table. + * Possible bit mask values for the `ulUnicodeRangeX` fields in an SFNT + * 'OS/2' table. */ /* ulUnicodeRange1 */ diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h index ce6a61779c4..d04f8102184 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/tttables.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* tttables.h */ -/* */ -/* Basic SFNT/TrueType tables definitions and interface */ -/* (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * tttables.h + * + * Basic SFNT/TrueType tables definitions and interface + * (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTTABLES_H_ @@ -33,53 +33,55 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ - /* <Title> */ - /* TrueType Tables */ - /* */ - /* <Abstract> */ - /* TrueType specific table types and functions. */ - /* */ - /* <Description> */ - /* This section contains definitions of some basic tables specific to */ - /* TrueType and OpenType as well as some routines used to access and */ - /* process them. */ - /* */ - /* <Order> */ - /* TT_Header */ - /* TT_HoriHeader */ - /* TT_VertHeader */ - /* TT_OS2 */ - /* TT_Postscript */ - /* TT_PCLT */ - /* TT_MaxProfile */ - /* */ - /* FT_Sfnt_Tag */ - /* FT_Get_Sfnt_Table */ - /* FT_Load_Sfnt_Table */ - /* FT_Sfnt_Table_Info */ - /* */ - /* FT_Get_CMap_Language_ID */ - /* FT_Get_CMap_Format */ - /* */ - /* FT_PARAM_TAG_UNPATENTED_HINTING */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Header */ - /* */ - /* <Description> */ - /* A structure to model a TrueType font header table. All fields */ - /* follow the OpenType specification. */ - /* */ + /************************************************************************** + * + * @section: + * truetype_tables + * + * @title: + * TrueType Tables + * + * @abstract: + * TrueType-specific table types and functions. + * + * @description: + * This section contains definitions of some basic tables specific to + * TrueType and OpenType as well as some routines used to access and + * process them. + * + * @order: + * TT_Header + * TT_HoriHeader + * TT_VertHeader + * TT_OS2 + * TT_Postscript + * TT_PCLT + * TT_MaxProfile + * + * FT_Sfnt_Tag + * FT_Get_Sfnt_Table + * FT_Load_Sfnt_Table + * FT_Sfnt_Table_Info + * + * FT_Get_CMap_Language_ID + * FT_Get_CMap_Format + * + * FT_PARAM_TAG_UNPATENTED_HINTING + * + */ + + + /************************************************************************** + * + * @struct: + * TT_Header + * + * @description: + * A structure to model a TrueType font header table. All fields follow + * the OpenType specification. The 64-bit timestamps are stored in + * two-element arrays `Created` and `Modified`, first the upper then + * the lower 32~bits. + */ typedef struct TT_Header_ { FT_Fixed Table_Version; @@ -91,8 +93,8 @@ FT_BEGIN_HEADER FT_UShort Flags; FT_UShort Units_Per_EM; - FT_Long Created [2]; - FT_Long Modified[2]; + FT_ULong Created [2]; + FT_ULong Modified[2]; FT_Short xMin; FT_Short yMin; @@ -109,93 +111,93 @@ FT_BEGIN_HEADER } TT_Header; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_HoriHeader */ - /* */ - /* <Description> */ - /* A structure to model a TrueType horizontal header, the `hhea' */ - /* table, as well as the corresponding horizontal metrics table, */ - /* `hmtx'. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of all */ - /* glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoAscender' field */ - /* of the `OS/2' table instead if you want */ - /* the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the distance */ - /* from the baseline to the bottom-most of */ - /* all glyph points found in the font. It */ - /* is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the `OS/2' table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Width_Max :: This field is the maximum of all advance */ - /* widths found in the font. It can be */ - /* used to compute the maximum width of an */ - /* arbitrary string of text. */ - /* */ - /* min_Left_Side_Bearing :: The minimum left side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Right_Side_Bearing :: The minimum right side bearing of all */ - /* glyphs within the font. */ - /* */ - /* xMax_Extent :: The maximum horizontal extent (i.e., the */ - /* `width' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ - /* table -- this value can be smaller than */ - /* the total number of glyphs in the font. */ - /* */ - /* long_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */ - /* `caret_Slope_Run', and `caret_Offset'. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_HoriHeader + * + * @description: + * A structure to model a TrueType horizontal header, the 'hhea' table, + * as well as the corresponding horizontal metrics table, 'hmtx'. + * + * @fields: + * Version :: + * The table version. + * + * Ascender :: + * The font's ascender, i.e., the distance from the baseline to the + * top-most of all glyph points found in the font. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoAscender` field of the 'OS/2' table instead + * if you want the correct one. + * + * Descender :: + * The font's descender, i.e., the distance from the baseline to the + * bottom-most of all glyph points found in the font. It is negative. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoDescender` field of the 'OS/2' table + * instead if you want the correct one. + * + * Line_Gap :: + * The font's line gap, i.e., the distance to add to the ascender and + * descender to get the BTB, i.e., the baseline-to-baseline distance + * for the font. + * + * advance_Width_Max :: + * This field is the maximum of all advance widths found in the font. + * It can be used to compute the maximum width of an arbitrary string + * of text. + * + * min_Left_Side_Bearing :: + * The minimum left side bearing of all glyphs within the font. + * + * min_Right_Side_Bearing :: + * The minimum right side bearing of all glyphs within the font. + * + * xMax_Extent :: + * The maximum horizontal extent (i.e., the 'width' of a glyph's + * bounding box) for all glyphs in the font. + * + * caret_Slope_Rise :: + * The rise coefficient of the cursor's slope of the cursor + * (slope=rise/run). + * + * caret_Slope_Run :: + * The run coefficient of the cursor's slope. + * + * caret_Offset :: + * The cursor's offset for slanted fonts. + * + * Reserved :: + * 8~reserved bytes. + * + * metric_Data_Format :: + * Always~0. + * + * number_Of_HMetrics :: + * Number of HMetrics entries in the 'hmtx' table -- this value can be + * smaller than the total number of glyphs in the font. + * + * long_metrics :: + * A pointer into the 'hmtx' table. + * + * short_metrics :: + * A pointer into the 'hmtx' table. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `caret_Slope_Rise`, + * `caret_Slope_Run`, and `caret_Offset`. + */ typedef struct TT_HoriHeader_ { FT_Fixed Version; @@ -219,7 +221,7 @@ FT_BEGIN_HEADER /* The following fields are not defined by the OpenType specification */ /* but they are used to connect the metrics header to the relevant */ - /* `hmtx' table. */ + /* 'hmtx' table. */ void* long_metrics; void* short_metrics; @@ -227,97 +229,93 @@ FT_BEGIN_HEADER } TT_HoriHeader; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_VertHeader */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType vertical header, the `vhea' */ - /* table, as well as the corresponding vertical metrics table, */ - /* `vmtx'. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of */ - /* all glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoAscender' */ - /* field of the `OS/2' table instead if */ - /* you want the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the */ - /* distance from the baseline to the */ - /* bottom-most of all glyph points found */ - /* in the font. It is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the `OS/2' table instead if */ - /* you want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Height_Max :: This field is the maximum of all */ - /* advance heights found in the font. It */ - /* can be used to compute the maximum */ - /* height of an arbitrary string of text. */ - /* */ - /* min_Top_Side_Bearing :: The minimum top side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ - /* glyphs within the font. */ - /* */ - /* yMax_Extent :: The maximum vertical extent (i.e., the */ - /* `height' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_VMetrics :: Number of VMetrics entries in the */ - /* `vmtx' table -- this value can be */ - /* smaller than the total number of glyphs */ - /* in the font. */ - /* */ - /* long_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `Ascender', */ - /* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */ - /* and `caret_Offset'. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_VertHeader + * + * @description: + * A structure used to model a TrueType vertical header, the 'vhea' + * table, as well as the corresponding vertical metrics table, 'vmtx'. + * + * @fields: + * Version :: + * The table version. + * + * Ascender :: + * The font's ascender, i.e., the distance from the baseline to the + * top-most of all glyph points found in the font. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoAscender` field of the 'OS/2' table instead + * if you want the correct one. + * + * Descender :: + * The font's descender, i.e., the distance from the baseline to the + * bottom-most of all glyph points found in the font. It is negative. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoDescender` field of the 'OS/2' table + * instead if you want the correct one. + * + * Line_Gap :: + * The font's line gap, i.e., the distance to add to the ascender and + * descender to get the BTB, i.e., the baseline-to-baseline distance + * for the font. + * + * advance_Height_Max :: + * This field is the maximum of all advance heights found in the font. + * It can be used to compute the maximum height of an arbitrary string + * of text. + * + * min_Top_Side_Bearing :: + * The minimum top side bearing of all glyphs within the font. + * + * min_Bottom_Side_Bearing :: + * The minimum bottom side bearing of all glyphs within the font. + * + * yMax_Extent :: + * The maximum vertical extent (i.e., the 'height' of a glyph's + * bounding box) for all glyphs in the font. + * + * caret_Slope_Rise :: + * The rise coefficient of the cursor's slope of the cursor + * (slope=rise/run). + * + * caret_Slope_Run :: + * The run coefficient of the cursor's slope. + * + * caret_Offset :: + * The cursor's offset for slanted fonts. + * + * Reserved :: + * 8~reserved bytes. + * + * metric_Data_Format :: + * Always~0. + * + * number_Of_VMetrics :: + * Number of VMetrics entries in the 'vmtx' table -- this value can be + * smaller than the total number of glyphs in the font. + * + * long_metrics :: + * A pointer into the 'vmtx' table. + * + * short_metrics :: + * A pointer into the 'vmtx' table. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `Ascender`, `Descender`, + * `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`. + */ typedef struct TT_VertHeader_ { FT_Fixed Version; @@ -341,7 +339,7 @@ FT_BEGIN_HEADER /* The following fields are not defined by the OpenType specification */ /* but they are used to connect the metrics header to the relevant */ - /* `vmtx' table. */ + /* 'vmtx' table. */ void* long_metrics; void* short_metrics; @@ -349,33 +347,31 @@ FT_BEGIN_HEADER } TT_VertHeader; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_OS2 */ - /* */ - /* <Description> */ - /* A structure to model a TrueType `OS/2' table. All fields comply */ - /* to the OpenType specification. */ - /* */ - /* Note that we now support old Mac fonts that do not include an */ - /* `OS/2' table. In this case, the `version' field is always set to */ - /* 0xFFFF. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `sCapHeight', */ - /* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */ - /* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */ - /* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */ - /* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */ - /* `ySuperscriptXSize', `ySuperscriptYOffset', and */ - /* `ySuperscriptYSize'. */ - /* */ - /* Possible values for bits in the `ulUnicodeRangeX' fields are given */ - /* by the @TT_UCR_XXX macros. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_OS2 + * + * @description: + * A structure to model a TrueType 'OS/2' table. All fields comply to + * the OpenType specification. + * + * Note that we now support old Mac fonts that do not include an 'OS/2' + * table. In this case, the `version` field is always set to 0xFFFF. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`, + * `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`, + * `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`, + * `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`, + * `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`, + * `ySuperscriptYOffset`, and `ySuperscriptYSize`. + * + * Possible values for bits in the `ulUnicodeRangeX` fields are given by + * the @TT_UCR_XXX macros. + */ typedef struct TT_OS2_ { @@ -435,23 +431,23 @@ FT_BEGIN_HEADER } TT_OS2; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Postscript */ - /* */ - /* <Description> */ - /* A structure to model a TrueType `post' table. All fields comply */ - /* to the OpenType specification. This structure does not reference */ - /* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */ - /* retrieve them. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `underlinePosition' */ - /* and `underlineThickness'. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Postscript + * + * @description: + * A structure to model a TrueType 'post' table. All fields comply to + * the OpenType specification. This structure does not reference a + * font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve + * them. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `underlinePosition` and + * `underlineThickness`. + */ typedef struct TT_Postscript_ { FT_Fixed FormatType; @@ -464,21 +460,21 @@ FT_BEGIN_HEADER FT_ULong minMemType1; FT_ULong maxMemType1; - /* Glyph names follow in the `post' table, but we don't */ + /* Glyph names follow in the 'post' table, but we don't */ /* load them by default. */ } TT_Postscript; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_PCLT */ - /* */ - /* <Description> */ - /* A structure to model a TrueType `PCLT' table. All fields comply */ - /* to the OpenType specification. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_PCLT + * + * @description: + * A structure to model a TrueType 'PCLT' table. All fields comply to + * the OpenType specification. + */ typedef struct TT_PCLT_ { FT_Fixed Version; @@ -500,70 +496,75 @@ FT_BEGIN_HEADER } TT_PCLT; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_MaxProfile */ - /* */ - /* <Description> */ - /* The maximum profile (`maxp') table contains many max values, which */ - /* can be used to pre-allocate arrays for speeding up glyph loading */ - /* and hinting. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numGlyphs :: The number of glyphs in this TrueType */ - /* font. */ - /* */ - /* maxPoints :: The maximum number of points in a */ - /* non-composite TrueType glyph. See also */ - /* `maxCompositePoints'. */ - /* */ - /* maxContours :: The maximum number of contours in a */ - /* non-composite TrueType glyph. See also */ - /* `maxCompositeContours'. */ - /* */ - /* maxCompositePoints :: The maximum number of points in a */ - /* composite TrueType glyph. See also */ - /* `maxPoints'. */ - /* */ - /* maxCompositeContours :: The maximum number of contours in a */ - /* composite TrueType glyph. See also */ - /* `maxContours'. */ - /* */ - /* maxZones :: The maximum number of zones used for */ - /* glyph hinting. */ - /* */ - /* maxTwilightPoints :: The maximum number of points in the */ - /* twilight zone used for glyph hinting. */ - /* */ - /* maxStorage :: The maximum number of elements in the */ - /* storage area used for glyph hinting. */ - /* */ - /* maxFunctionDefs :: The maximum number of function */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxInstructionDefs :: The maximum number of instruction */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxStackElements :: The maximum number of stack elements used */ - /* during bytecode interpretation. */ - /* */ - /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ - /* used for glyph hinting. */ - /* */ - /* maxComponentElements :: The maximum number of simple (i.e., non- */ - /* composite) glyphs in a composite glyph. */ - /* */ - /* maxComponentDepth :: The maximum nesting depth of composite */ - /* glyphs. */ - /* */ - /* <Note> */ - /* This structure is only used during font loading. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_MaxProfile + * + * @description: + * The maximum profile ('maxp') table contains many max values, which can + * be used to pre-allocate arrays for speeding up glyph loading and + * hinting. + * + * @fields: + * version :: + * The version number. + * + * numGlyphs :: + * The number of glyphs in this TrueType font. + * + * maxPoints :: + * The maximum number of points in a non-composite TrueType glyph. See + * also `maxCompositePoints`. + * + * maxContours :: + * The maximum number of contours in a non-composite TrueType glyph. + * See also `maxCompositeContours`. + * + * maxCompositePoints :: + * The maximum number of points in a composite TrueType glyph. See + * also `maxPoints`. + * + * maxCompositeContours :: + * The maximum number of contours in a composite TrueType glyph. See + * also `maxContours`. + * + * maxZones :: + * The maximum number of zones used for glyph hinting. + * + * maxTwilightPoints :: + * The maximum number of points in the twilight zone used for glyph + * hinting. + * + * maxStorage :: + * The maximum number of elements in the storage area used for glyph + * hinting. + * + * maxFunctionDefs :: + * The maximum number of function definitions in the TrueType bytecode + * for this font. + * + * maxInstructionDefs :: + * The maximum number of instruction definitions in the TrueType + * bytecode for this font. + * + * maxStackElements :: + * The maximum number of stack elements used during bytecode + * interpretation. + * + * maxSizeOfInstructions :: + * The maximum number of TrueType opcodes used for glyph hinting. + * + * maxComponentElements :: + * The maximum number of simple (i.e., non-composite) glyphs in a + * composite glyph. + * + * maxComponentDepth :: + * The maximum nesting depth of composite glyphs. + * + * @note: + * This structure is only used during font loading. + */ typedef struct TT_MaxProfile_ { FT_Fixed version; @@ -585,31 +586,38 @@ FT_BEGIN_HEADER } TT_MaxProfile; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Sfnt_Tag */ - /* */ - /* <Description> */ - /* An enumeration to specify indices of SFNT tables loaded and parsed */ - /* by FreeType during initialization of an SFNT font. Used in the */ - /* @FT_Get_Sfnt_Table API function. */ - /* */ - /* <Values> */ - /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ - /* */ - /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */ - /* */ - /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */ - /* */ - /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */ - /* */ - /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader structure. */ - /* */ - /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */ - /* */ - /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Sfnt_Tag + * + * @description: + * An enumeration to specify indices of SFNT tables loaded and parsed by + * FreeType during initialization of an SFNT font. Used in the + * @FT_Get_Sfnt_Table API function. + * + * @values: + * FT_SFNT_HEAD :: + * To access the font's @TT_Header structure. + * + * FT_SFNT_MAXP :: + * To access the font's @TT_MaxProfile structure. + * + * FT_SFNT_OS2 :: + * To access the font's @TT_OS2 structure. + * + * FT_SFNT_HHEA :: + * To access the font's @TT_HoriHeader structure. + * + * FT_SFNT_VHEA :: + * To access the font's @TT_VertHeader structure. + * + * FT_SFNT_POST :: + * To access the font's @TT_Postscript structure. + * + * FT_SFNT_PCLT :: + * To access the font's @TT_PCLT structure. + */ typedef enum FT_Sfnt_Tag_ { FT_SFNT_HEAD, @@ -624,7 +632,7 @@ FT_BEGIN_HEADER } FT_Sfnt_Tag; - /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */ + /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */ /* values instead */ #define ft_sfnt_head FT_SFNT_HEAD #define ft_sfnt_maxp FT_SFNT_MAXP @@ -635,44 +643,46 @@ FT_BEGIN_HEADER #define ft_sfnt_pclt FT_SFNT_PCLT - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Table */ - /* */ - /* <Description> */ - /* Return a pointer to a given SFNT table stored within a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source. */ - /* */ - /* tag :: The index of the SFNT table. */ - /* */ - /* <Return> */ - /* A type-less pointer to the table. This will be NULL in case of */ - /* error, or if the corresponding table was not found *OR* loaded */ - /* from the file. */ - /* */ - /* Use a typecast according to `tag' to access the structure */ - /* elements. */ - /* */ - /* <Note> */ - /* The table is owned by the face object and disappears with it. */ - /* */ - /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ - /* a list. */ - /* */ - /* Here an example how to access the `vhea' table: */ - /* */ - /* { */ - /* TT_VertHeader* vert_header; */ - /* */ - /* */ - /* vert_header = */ - /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Table + * + * @description: + * Return a pointer to a given SFNT table stored within a face. + * + * @input: + * face :: + * A handle to the source. + * + * tag :: + * The index of the SFNT table. + * + * @return: + * A type-less pointer to the table. This will be `NULL` in case of + * error, or if the corresponding table was not found **OR** loaded from + * the file. + * + * Use a typecast according to `tag` to access the structure elements. + * + * @note: + * The table is owned by the face object and disappears with it. + * + * This function is only useful to access SFNT tables that are loaded by + * the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a + * list. + * + * @example: + * Here is an example demonstrating access to the 'vhea' table. + * + * ``` + * TT_VertHeader* vert_header; + * + * + * vert_header = + * (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); + * ``` + */ FT_EXPORT( void* ) FT_Get_Sfnt_Table( FT_Face face, FT_Sfnt_Tag tag ); @@ -691,8 +701,8 @@ FT_BEGIN_HEADER * A handle to the source face. * * tag :: - * The four-byte tag of the table to load. Use value~0 if you want - * to access the whole font file. Otherwise, you can use one of the + * The four-byte tag of the table to load. Use value~0 if you want to + * access the whole font file. Otherwise, you can use one of the * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new * one with @FT_MAKE_TAG. * @@ -706,10 +716,10 @@ FT_BEGIN_HEADER * * @inout: * length :: - * If the `length' parameter is NULL, try to load the whole table. + * If the `length` parameter is `NULL`, try to load the whole table. * Return an error code if it fails. * - * Else, if `*length' is~0, exit immediately while returning the + * Else, if `*length` is~0, exit immediately while returning the * table's (or file) full size in it. * * Else the number of bytes to read from the table or file, from the @@ -720,21 +730,21 @@ FT_BEGIN_HEADER * * @note: * If you need to determine the table's length you should first call this - * function with `*length' set to~0, as in the following example: + * function with `*length` set to~0, as in the following example: * - * { - * FT_ULong length = 0; + * ``` + * FT_ULong length = 0; * * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } - * } + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * ``` * * Note that structures like @TT_Header or @TT_OS2 can't be used with * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that @@ -768,14 +778,14 @@ FT_BEGIN_HEADER * * @inout: * tag :: - * The name tag of the SFNT table. If the value is NULL, `table_index' - * is ignored, and `length' returns the number of SFNT tables in the - * font. + * The name tag of the SFNT table. If the value is `NULL`, + * `table_index` is ignored, and `length` returns the number of SFNT + * tables in the font. * * @output: * length :: - * The length of the SFNT table (or the number of SFNT tables, depending - * on `tag'). + * The length of the SFNT table (or the number of SFNT tables, + * depending on `tag`). * * @return: * FreeType error code. 0~means success. @@ -792,46 +802,46 @@ FT_BEGIN_HEADER FT_ULong *length ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Language_ID */ - /* */ - /* <Description> */ - /* Return cmap language ID as specified in the OpenType standard. */ - /* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The language ID of `charmap'. If `charmap' doesn't belong to an */ - /* SFNT face, just return~0 as the default value. */ - /* */ - /* For a format~14 cmap (to access Unicode IVS), the return value is */ - /* 0xFFFFFFFF. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_CMap_Language_ID + * + * @description: + * Return cmap language ID as specified in the OpenType standard. + * Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. + * + * @input: + * charmap :: + * The target charmap. + * + * @return: + * The language ID of `charmap`. If `charmap` doesn't belong to an SFNT + * face, just return~0 as the default value. + * + * For a format~14 cmap (to access Unicode IVS), the return value is + * 0xFFFFFFFF. + */ FT_EXPORT( FT_ULong ) FT_Get_CMap_Language_ID( FT_CharMap charmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Format */ - /* */ - /* <Description> */ - /* Return the format of an SFNT `cmap' table. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The format of `charmap'. If `charmap' doesn't belong to an SFNT */ - /* face, return -1. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_CMap_Format + * + * @description: + * Return the format of an SFNT 'cmap' table. + * + * @input: + * charmap :: + * The target charmap. + * + * @return: + * The format of `charmap`. If `charmap` doesn't belong to an SFNT face, + * return -1. + */ FT_EXPORT( FT_Long ) FT_Get_CMap_Format( FT_CharMap charmap ); diff --git a/src/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h b/src/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h index e5cee68a159..bd0986eff09 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h +++ b/src/src/java.desktop/share/native/libfreetype/include/freetype/tttags.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* tttags.h */ -/* */ -/* Tags for TrueType and OpenType tables (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * tttags.h + * + * Tags for TrueType and OpenType tables (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTAGS_H_ @@ -46,6 +46,8 @@ FT_BEGIN_HEADER #define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' ) #define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_COLR FT_MAKE_TAG( 'C', 'O', 'L', 'R' ) +#define TTAG_CPAL FT_MAKE_TAG( 'C', 'P', 'A', 'L' ) #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) #define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) #define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) diff --git a/src/src/java.desktop/share/native/libfreetype/include/ft2build.h b/src/src/java.desktop/share/native/libfreetype/include/ft2build.h index e7ce99bc946..e3f4887943f 100644 --- a/src/src/java.desktop/share/native/libfreetype/include/ft2build.h +++ b/src/src/java.desktop/share/native/libfreetype/include/ft2build.h @@ -1,34 +1,36 @@ -/***************************************************************************/ -/* */ -/* ft2build.h */ -/* */ -/* FreeType 2 build and setup macros. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is the `entry point' for FreeType header file inclusions. It is */ - /* the only header file which should be included directly; all other */ - /* FreeType header files should be accessed with macro names (after */ - /* including `ft2build.h'). */ - /* */ - /* A typical example is */ - /* */ - /* #include <ft2build.h> */ - /* #include FT_FREETYPE_H */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ft2build.h + * + * FreeType 2 build and setup macros. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This is the 'entry point' for FreeType header file inclusions. It is + * the only header file which should be included directly; all other + * FreeType header files should be accessed with macro names (after + * including `ft2build.h`). + * + * A typical example is + * + * ``` + * #include <ft2build.h> + * #include FT_FREETYPE_H + * ``` + * + */ #ifndef FT2BUILD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.c index c65a3ae23e9..9e1f7a21ffd 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* afangles.c */ -/* */ -/* Routines used to compute vector angles with limited accuracy */ -/* and very high speed. It also contains sorting routines (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afangles.c + * + * Routines used to compute vector angles with limited accuracy + * and very high speed. It also contains sorting routines (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" /* - * We are not using `af_angle_atan' anymore, but we keep the source - * code below just in case... + * We are not using `af_angle_atan' anymore, but we keep the source + * code below just in case... */ @@ -30,16 +30,16 @@ /* - * The trick here is to realize that we don't need a very accurate angle - * approximation. We are going to use the result of `af_angle_atan' to - * only compare the sign of angle differences, or check whether its - * magnitude is very small. + * The trick here is to realize that we don't need a very accurate angle + * approximation. We are going to use the result of `af_angle_atan' to + * only compare the sign of angle differences, or check whether its + * magnitude is very small. * - * The approximation + * The approximation * - * dy * PI / (|dx|+|dy|) + * dy * PI / (|dx|+|dy|) * - * should be enough, and much faster to compute. + * should be enough, and much faster to compute. */ FT_LOCAL_DEF( AF_Angle ) af_angle_atan( FT_Fixed dx, diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.h index f33f9e108e3..18d7dae3a6b 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afangles.h @@ -1,7 +1,7 @@ /* - * afangles.h + * afangles.h * - * This is a dummy file, used to please the build system. It is never - * included by the auto-fitter sources. + * This is a dummy file, used to please the build system. It is never + * included by the auto-fitter sources. * */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c index e4078fd0444..28da159008e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.c @@ -1,22 +1,22 @@ /* This file has been generated by the Perl script `afblue.pl', */ /* using data from file `afblue.dat'. */ -/***************************************************************************/ -/* */ -/* afblue.c */ -/* */ -/* Auto-fitter data for blue strings (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.c + * + * Auto-fitter data for blue strings (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin index 4913e2eb6f2..6545d1fd433 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.cin @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afblue.c */ -/* */ -/* Auto-fitter data for blue strings (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.c + * + * Auto-fitter data for blue strings (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat index bc2f0d27540..14a0993b61d 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.dat @@ -1,15 +1,15 @@ -// afblue.dat +// afblue.dat // -// Auto-fitter data for blue strings. +// Auto-fitter data for blue strings. // -// Copyright 2013-2018 by -// David Turner, Robert Wilhelm, and Werner Lemberg. +// Copyright (C) 2013-2019 by +// David Turner, Robert Wilhelm, and Werner Lemberg. // -// This file is part of the FreeType project, and may only be used, -// modified, and distributed under the terms of the FreeType project -// license, LICENSE.TXT. By continuing to use, modify, or distribute -// this file you indicate that you have read the license and -// understand and accept it fully. +// This file is part of the FreeType project, and may only be used, +// modified, and distributed under the terms of the FreeType project +// license, LICENSE.TXT. By continuing to use, modify, or distribute +// this file you indicate that you have read the license and +// understand and accept it fully. // This file contains data specific to blue zones. It gets processed by diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h index de31e259c3b..a2ff597b8eb 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.h @@ -1,22 +1,22 @@ /* This file has been generated by the Perl script `afblue.pl', */ /* using data from file `afblue.dat'. */ -/***************************************************************************/ -/* */ -/* afblue.h */ -/* */ -/* Auto-fitter data for blue strings (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.h + * + * Auto-fitter data for blue strings (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFBLUE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin index 682147cb30d..30a28dafa53 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afblue.hin @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afblue.h */ -/* */ -/* Auto-fitter data for blue strings (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.h + * + * Auto-fitter data for blue strings (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFBLUE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c index 21b6bffa332..3b2b1cf24ce 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.c @@ -1,24 +1,24 @@ -/***************************************************************************/ -/* */ -/* afcjk.c */ -/* */ -/* Auto-fitter hinting routines for CJK writing system (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afcjk.c + * + * Auto-fitter hinting routines for CJK writing system (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* - * The algorithm is based on akito's autohint patch, archived at + * The algorithm is based on akito's autohint patch, archived at * - * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/ + * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/ * */ @@ -27,7 +27,6 @@ #include FT_INTERNAL_DEBUG_H #include "afglobal.h" -#include "afpic.h" #include "aflatin.h" #include "afcjk.h" @@ -44,14 +43,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afcjk +#define FT_COMPONENT afcjk /*************************************************************************/ @@ -92,23 +91,29 @@ AF_CJKMetricsRec dummy[1]; AF_Scaler scaler = &dummy->root.scaler; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = metrics->root.globals; -#endif - AF_StyleClass style_class = metrics->root.style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; + + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif - void* shaper_buf; const char* p; #ifdef FT_DEBUG_LEVEL_TRACE FT_ULong ch = 0; #endif - p = script_class->standard_charstring; + p = script_class->standard_charstring; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif /* We check a list of standard characters. The first match wins. */ @@ -193,10 +198,10 @@ goto Exit; /* - * We assume that the glyphs selected for the stem width - * computation are `featureless' enough so that the linking - * algorithm works fine without adjustments of its scoring - * function. + * We assume that the glyphs selected for the stem width + * computation are `featureless' enough so that the linking + * algorithm works fine without adjustments of its scoring + * function. */ af_latin_hints_link_segments( hints, 0, @@ -296,7 +301,14 @@ AF_Blue_Stringset bss = sc->blue_stringset; const AF_Blue_StringRec* bs = &af_blue_stringsets[bss]; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* we walk over the blue character strings as specified in the */ @@ -307,7 +319,9 @@ "==========================\n" "\n" )); +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ ) { @@ -483,8 +497,8 @@ if ( num_flats == 0 && num_fills == 0 ) { /* - * we couldn't find a single glyph to compute this blue zone, - * we will simply ignore it then + * we couldn't find a single glyph to compute this blue zone, + * we will simply ignore it then */ FT_TRACE5(( " empty\n" )); continue; @@ -565,15 +579,25 @@ FT_Bool started = 0, same_width = 1; FT_Fixed advance = 0, old_advance = 0; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* in all supported charmaps, digits have character codes 0x30-0x39 */ const char digits[] = "0 1 2 3 4 5 6 7 8 9"; const char* p; - p = digits; + p = digits; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif while ( *p ) { @@ -890,11 +914,11 @@ } /* - * now compute the `serif' segments + * now compute the `serif' segments * - * In Hanzi, some strokes are wider on one or both of the ends. - * We either identify the stems on the ends as serifs or remove - * the linkage, depending on the length of the stems. + * In Hanzi, some strokes are wider on one or both of the ends. + * We either identify the stems on the ends as serifs or remove + * the linkage, depending on the length of the stems. * */ @@ -1000,21 +1024,21 @@ scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale : hints->y_scale; - /*********************************************************************/ - /* */ - /* We begin by generating a sorted table of edges for the current */ - /* direction. To do so, we simply scan each segment and try to find */ - /* an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which is then processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the edges table is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ + /********************************************************************** + * + * We begin by generating a sorted table of edges for the current + * direction. To do so, we simply scan each segment and try to find + * an edge in our table that corresponds to its position. + * + * If no edge is found, we create and insert a new edge in the + * sorted table. Otherwise, we simply add the segment to the edge's + * list which is then processed in the second step to compute the + * edge's properties. + * + * Note that the edges table is sorted along the segment/edge + * position. + * + */ edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold, scale ); @@ -1114,17 +1138,17 @@ } } - /******************************************************************/ - /* */ - /* Good, we now compute each edge's properties according to the */ - /* segments found on its position. Basically, these are */ - /* */ - /* - the edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straight or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /******************************************************************/ + /******************************************************************* + * + * Good, we now compute each edge's properties according to the + * segments found on its position. Basically, these are + * + * - the edge's main direction + * - stem edge, serif edge or both (which defaults to stem then) + * - rounded edge, straight or both (which defaults to straight) + * - link for edge + * + */ /* first of all, set the `edge' field in each segment -- this is */ /* required in order to compute edge links */ @@ -1174,7 +1198,7 @@ /* check for links -- if seg->serif is set, then seg->link must */ /* be ignored */ - is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge ); + is_serif = FT_BOOL( seg->serif && seg->serif->edge != edge ); if ( seg->link || is_serif ) { @@ -1364,8 +1388,8 @@ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics ); /* - * correct x_scale and y_scale when needed, since they may have - * been modified af_cjk_scale_dim above + * correct x_scale and y_scale when needed, since they may have + * been modified af_cjk_scale_dim above */ hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale; hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta; @@ -1384,21 +1408,21 @@ other_flags = 0; /* - * We snap the width of vertical stems for the monochrome and - * horizontal LCD rendering targets only. + * We snap the width of vertical stems for the monochrome and + * horizontal LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_HORZ_SNAP; /* - * We snap the width of horizontal stems for the monochrome and - * vertical LCD rendering targets only. + * We snap the width of horizontal stems for the monochrome and + * vertical LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels unless in `light' or `lcd' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; @@ -2094,8 +2118,8 @@ goto Exit; /* - * now hint the remaining edges (serifs and single) in order - * to complete our processing + * now hint the remaining edges (serifs and single) in order + * to complete our processing */ for ( edge = edges; edge < edge_limit; edge++ ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h index d229c0c9cff..59acae53429 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afcjk.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afcjk.h */ -/* */ -/* Auto-fitter hinting routines for CJK writing system (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afcjk.h + * + * Auto-fitter hinting routines for CJK writing system (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFCJK_H_ @@ -41,9 +41,9 @@ FT_BEGIN_HEADER /* - * CJK glyphs tend to fill the square. So we have both vertical and - * horizontal blue zones. But some glyphs have flat bounding strokes that - * leave some space between neighbour glyphs. + * CJK glyphs tend to fill the square. So we have both vertical and + * horizontal blue zones. But some glyphs have flat bounding strokes that + * leave some space between neighbour glyphs. */ #define AF_CJK_IS_TOP_BLUE( b ) \ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h index 6eeb8fc9fb7..ff207a97e08 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afcover.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afcover.h */ -/* */ -/* Auto-fitter coverages (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afcover.h + * + * Auto-fitter coverages (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* This header file can be included multiple times. */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c index f30c517cbb3..7e07a41e7da 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afdummy.c */ -/* */ -/* Auto-fitter dummy routines to be used if no hinting should be */ -/* performed (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afdummy.c + * + * Auto-fitter dummy routines to be used if no hinting should be + * performed (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afdummy.h" @@ -38,13 +38,15 @@ static FT_Error - af_dummy_hints_apply( FT_UInt glyph_index, - AF_GlyphHints hints, - FT_Outline* outline ) + af_dummy_hints_apply( FT_UInt glyph_index, + AF_GlyphHints hints, + FT_Outline* outline, + AF_StyleMetrics metrics ) { FT_Error error; FT_UNUSED( glyph_index ); + FT_UNUSED( metrics ); error = af_glyph_hints_reload( hints, outline ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h index b382acd92ae..ab9227d35d9 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afdummy.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afdummy.h */ -/* */ -/* Auto-fitter dummy routines to be used if no hinting should be */ -/* performed (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afdummy.h + * + * Auto-fitter dummy routines to be used if no hinting should be + * performed (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFDUMMY_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h index e5de54360f7..2ec336f72c6 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/aferrors.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* aferrors.h */ -/* */ -/* Autofitter error codes (specification only). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the Autofitter error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * aferrors.h + * + * Autofitter error codes (specification only). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the Autofitter error enumeration + * constants. + * + */ #ifndef AFERRORS_H_ #define AFERRORS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c index 3d09c53e8a0..7183ce4a780 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afglobal.c */ -/* */ -/* Auto-fitter routines to compute global hinting values (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afglobal.c + * + * Auto-fitter routines to compute global hinting values (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afglobal.h" @@ -22,14 +22,14 @@ #include FT_INTERNAL_DEBUG_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afglobal +#define FT_COMPONENT afglobal /* get writing system specific header files */ @@ -38,7 +38,6 @@ #include "afwrtsys.h" #include "aferrors.h" -#include "afpic.h" #undef SCRIPT @@ -67,8 +66,6 @@ #include "afstyles.h" -#ifndef FT_CONFIG_OPTION_PIC - #undef WRITING_SYSTEM #define WRITING_SYSTEM( ws, WS ) \ &af_ ## ws ## _writing_system_class, @@ -110,8 +107,6 @@ NULL /* do not remove */ }; -#endif /* !FT_CONFIG_OPTION_PIC */ - #ifdef FT_DEBUG_LEVEL_TRACE @@ -159,12 +154,12 @@ } /* scan each style in a Unicode charmap */ - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { AF_StyleClass style_class = - AF_STYLE_CLASSES_GET[ss]; + af_style_classes[ss]; AF_ScriptClass script_class = - AF_SCRIPT_CLASSES_GET[style_class->script]; + af_script_classes[style_class->script]; AF_Script_UniRange range; @@ -172,8 +167,8 @@ continue; /* - * Scan all Unicode points in the range and set the corresponding - * glyph style index. + * Scan all Unicode points in the range and set the corresponding + * glyph style index. */ if ( style_class->coverage == AF_COVERAGE_DEFAULT ) { @@ -246,9 +241,9 @@ } /* handle the remaining default OpenType features ... */ - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; + AF_StyleClass style_class = af_style_classes[ss]; if ( style_class->coverage == AF_COVERAGE_DEFAULT ) @@ -256,7 +251,7 @@ } /* ... and finally the default OpenType features of the default script */ - af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles, 1 ); + af_shaper_get_coverage( globals, af_style_classes[dflt], gstyles, 1 ); /* mark ASCII digits */ for ( i = 0x30; i <= 0x39; i++ ) @@ -270,8 +265,8 @@ Exit: /* - * By default, all uncovered glyphs are set to the fallback style. - * XXX: Shouldn't we disable hinting or do something similar? + * By default, all uncovered glyphs are set to the fallback style. + * XXX: Shouldn't we disable hinting or do something similar? */ if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED ) { @@ -295,9 +290,9 @@ "==============\n" "\n" )); - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; + AF_StyleClass style_class = af_style_classes[ss]; FT_UInt count = 0; FT_Long idx; @@ -397,9 +392,9 @@ if ( globals->metrics[nn] ) { AF_StyleClass style_class = - AF_STYLE_CLASSES_GET[nn]; + af_style_classes[nn]; AF_WritingSystemClass writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; + af_writing_system_classes[style_class->writing_system]; if ( writing_system_class->style_metrics_done ) @@ -448,8 +443,8 @@ style = (AF_Style)( globals->glyph_styles[gindex] & AF_STYLE_UNASSIGNED ); - style_class = AF_STYLE_CLASSES_GET[style]; - writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET + style_class = af_style_classes[style]; + writing_system_class = af_writing_system_classes [style_class->writing_system]; metrics = globals->metrics[style]; @@ -494,9 +489,9 @@ FT_UInt gindex ) { if ( gindex < (FT_ULong)globals->glyph_count ) - return (FT_Bool)( globals->glyph_styles[gindex] & AF_DIGIT ); + return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT ); - return (FT_Bool)0; + return FT_BOOL( 0 ); } diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h index 489ed46d9ee..52f38350db3 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afglobal.h */ -/* */ -/* Auto-fitter routines to compute global hinting values */ -/* (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afglobal.h + * + * Auto-fitter routines to compute global hinting values + * (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFGLOBAL_H_ @@ -60,8 +60,8 @@ FT_BEGIN_HEADER /* - * Default values and flags for both autofitter globals (found in - * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec). + * Default values and flags for both autofitter globals (found in + * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec). */ /* index of fallback style in `af_style_classes' */ @@ -98,8 +98,8 @@ FT_BEGIN_HEADER /* - * Note that glyph_styles[] maps each glyph to an index into the - * `af_style_classes' array. + * Note that glyph_styles[] maps each glyph to an index into the + * `af_style_classes' array. * */ typedef struct AF_FaceGlobalsRec_ @@ -140,8 +140,8 @@ FT_BEGIN_HEADER /* - * model the global hints data for a given face, decomposed into - * style-specific items + * model the global hints data for a given face, decomposed into + * style-specific items */ FT_LOCAL( FT_Error ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c index 0666dbc8e20..ed111c41176 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afhints.c */ -/* */ -/* Auto-fitter hinting routines (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afhints.c + * + * Auto-fitter hinting routines (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afhints.h" @@ -22,14 +22,14 @@ #include FT_INTERNAL_DEBUG_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afhints +#define FT_COMPONENT afhints /* Get new segment for given axis. */ @@ -297,6 +297,19 @@ } + static int + af_get_strong_edge_index( AF_GlyphHints hints, + AF_Edge* strong_edges, + int dimension ) + { + AF_AxisHints axis = &hints->axis[dimension]; + AF_Edge edges = axis->edges; + + + return AF_INDEX_NUM( strong_edges[dimension], edges ); + } + + #ifdef __cplusplus extern "C" { #endif @@ -317,8 +330,10 @@ { AF_DUMP(( " index hedge hseg vedge vseg flags " /* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */ - " xorg yorg xscale yscale xfit yfit" )); + " xorg yorg xscale yscale xfit yfit " /* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */ + " hbef haft vbef vaft" )); + /* " XXXXX XXXXX XXXXX XXXXX" */ } else AF_DUMP(( " (none)\n" )); @@ -330,6 +345,7 @@ int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 ); char buf1[16], buf2[16], buf3[16], buf4[16]; + char buf5[16], buf6[16], buf7[16], buf8[16]; /* insert extra newline at the beginning of a contour */ @@ -340,7 +356,8 @@ } AF_DUMP(( " %5d %5s %5s %5s %5s %s" - " %5d %5d %7.2f %7.2f %7.2f %7.2f\n", + " %5d %5d %7.2f %7.2f %7.2f %7.2f" + " %5s %5s %5s %5s\n", point_idx, af_print_idx( buf1, af_get_edge_index( hints, segment_idx_1, 1 ) ), @@ -359,7 +376,20 @@ point->ox / 64.0, point->oy / 64.0, point->x / 64.0, - point->y / 64.0 )); + point->y / 64.0, + + af_print_idx( buf5, af_get_strong_edge_index( hints, + point->before, + 1 ) ), + af_print_idx( buf6, af_get_strong_edge_index( hints, + point->after, + 1 ) ), + af_print_idx( buf7, af_get_strong_edge_index( hints, + point->before, + 0 ) ), + af_print_idx( buf8, af_get_strong_edge_index( hints, + point->after, + 0 ) ) )); } AF_DUMP(( "\n" )); } @@ -519,7 +549,7 @@ *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx : seg->first->fy; if ( seg->edge ) - *is_blue = (FT_Bool)( seg->edge->blue_edge != 0 ); + *is_blue = FT_BOOL( seg->edge->blue_edge ); else *is_blue = FALSE; @@ -558,8 +588,8 @@ /* - * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges - * since they have a constant X coordinate. + * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges + * since they have a constant X coordinate. */ if ( dimension == AF_DIMENSION_HORZ ) AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n", @@ -681,8 +711,8 @@ memory = hints->memory; /* - * note that we don't need to free the segment and edge - * buffers since they are really within the hints->points array + * note that we don't need to free the segment and edge + * buffers since they are really within the hints->points array */ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) { @@ -776,9 +806,9 @@ } /* - * then reallocate the points arrays if necessary -- - * note that we reserve two additional point positions, used to - * hint metrics appropriately + * then reallocate the points arrays if necessary -- + * note that we reserve two additional point positions, used to + * hint metrics appropriately */ new_max = (FT_UInt)( outline->n_points + 2 ); old_max = (FT_UInt)hints->max_points; @@ -898,6 +928,14 @@ prev = end; } } + +#ifdef FT_DEBUG_AUTOFIT + point->before[0] = NULL; + point->before[1] = NULL; + point->after[0] = NULL; + point->after[1] = NULL; +#endif + } } @@ -918,15 +956,15 @@ { /* - * Compute directions of `in' and `out' vectors. + * Compute directions of `in' and `out' vectors. * - * Note that distances between points that are very near to each - * other are accumulated. In other words, the auto-hinter either - * prepends the small vectors between near points to the first - * non-near vector, or the sum of small vector lengths exceeds a - * threshold, thus `grouping' the small vectors. All intermediate - * points are tagged as weak; the directions are adjusted also to - * be equal to the accumulated one. + * Note that distances between points that are very near to each + * other are accumulated. In other words, the auto-hinter either + * prepends the small vectors between near points to the first + * non-near vector, or the sum of small vector lengths exceeds a + * threshold, thus `grouping' the small vectors. All intermediate + * points are tagged as weak; the directions are adjusted also to + * be equal to the accumulated one. */ FT_Int near_limit2 = 2 * near_limit - 1; @@ -956,12 +994,12 @@ out_y = point->fy - prev->fy; /* - * We use Taxicab metrics to measure the vector length. + * We use Taxicab metrics to measure the vector length. * - * Note that the accumulated distances so far could have the - * opposite direction of the distance measured here. For this - * reason we use `near_limit2' for the comparison to get a - * non-near point even in the worst case. + * Note that the accumulated distances so far could have the + * opposite direction of the distance measured here. For this + * reason we use `near_limit2' for the comparison to get a + * non-near point even in the worst case. */ if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 ) break; @@ -979,11 +1017,11 @@ curr = first; /* - * We abuse the `u' and `v' fields to store index deltas to the - * next and previous non-near point, respectively. + * We abuse the `u' and `v' fields to store index deltas to the + * next and previous non-near point, respectively. * - * To avoid problems with not having non-near points, we point to - * `first' by default as the next non-near point. + * To avoid problems with not having non-near points, we point to + * `first' by default as the next non-near point. * */ curr->u = (FT_Pos)( first - curr ); @@ -1035,12 +1073,12 @@ } /* - * The next step is to `simplify' an outline's topology so that we - * can identify local extrema more reliably: A series of - * non-horizontal or non-vertical vectors pointing into the same - * quadrant are handled as a single, long vector. From a - * topological point of the view, the intermediate points are of no - * interest and thus tagged as weak. + * The next step is to `simplify' an outline's topology so that we + * can identify local extrema more reliably: A series of + * non-horizontal or non-vertical vectors pointing into the same + * quadrant are handled as a single, long vector. From a + * topological point of the view, the intermediate points are of no + * interest and thus tagged as weak. */ for ( point = points; point < point_limit; point++ ) @@ -1080,9 +1118,9 @@ } /* - * Finally, check for remaining weak points. Everything else not - * collected in edges so far is then implicitly classified as strong - * points. + * Finally, check for remaining weak points. Everything else not + * collected in edges so far is then implicitly classified as strong + * points. */ for ( point = points; point < point_limit; point++ ) @@ -1309,6 +1347,12 @@ if ( delta >= 0 ) { u = edge->pos - ( edge->opos - ou ); + +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = edge; + point->after[dim] = NULL; +#endif + goto Store_Point; } @@ -1318,6 +1362,12 @@ if ( delta >= 0 ) { u = edge->pos + ( ou - edge->opos ); + +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = NULL; + point->after[dim] = edge; +#endif + goto Store_Point; } @@ -1364,6 +1414,12 @@ { /* we are on the edge */ u = edge->pos; + +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = NULL; + point->after[dim] = NULL; +#endif + goto Store_Point; } } @@ -1374,6 +1430,11 @@ AF_Edge after = edges + min + 0; +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = before; + point->after[dim] = after; +#endif + /* assert( before && after && before != after ) */ if ( before->scale == 0 ) before->scale = FT_DivFix( after->pos - before->pos, diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h index 3326ebc44e7..e0cf612f0c5 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afhints.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afhints.h */ -/* */ -/* Auto-fitter hinting routines (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afhints.h + * + * Auto-fitter hinting routines (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFHINTS_H_ @@ -26,8 +26,8 @@ FT_BEGIN_HEADER /* - * The definition of outline glyph hints. These are shared by all - * writing system analysis routines (until now). + * The definition of outline glyph hints. These are shared by all + * writing system analysis routines (until now). */ typedef enum AF_Dimension_ @@ -56,153 +56,153 @@ FT_BEGIN_HEADER /* - * The following explanations are mostly taken from the article + * The following explanations are mostly taken from the article * - * Real-Time Grid Fitting of Typographic Outlines + * Real-Time Grid Fitting of Typographic Outlines * - * by David Turner and Werner Lemberg + * by David Turner and Werner Lemberg * - * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf + * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf * - * with appropriate updates. + * with appropriate updates. * * - * Segments + * Segments * - * `af_{cjk,latin,...}_hints_compute_segments' are the functions to - * find segments in an outline. + * `af_{cjk,latin,...}_hints_compute_segments' are the functions to + * find segments in an outline. * - * A segment is a series of at least two consecutive points that are - * approximately aligned along a coordinate axis. The analysis to do - * so is specific to a writing system. + * A segment is a series of at least two consecutive points that are + * approximately aligned along a coordinate axis. The analysis to do + * so is specific to a writing system. * * - * Edges + * Edges * - * `af_{cjk,latin,...}_hints_compute_edges' are the functions to find - * edges. + * `af_{cjk,latin,...}_hints_compute_edges' are the functions to find + * edges. * - * As soon as segments are defined, the auto-hinter groups them into - * edges. An edge corresponds to a single position on the main - * dimension that collects one or more segments (allowing for a small - * threshold). + * As soon as segments are defined, the auto-hinter groups them into + * edges. An edge corresponds to a single position on the main + * dimension that collects one or more segments (allowing for a small + * threshold). * - * As an example, the `latin' writing system first tries to grid-fit - * edges, then to align segments on the edges unless it detects that - * they form a serif. + * As an example, the `latin' writing system first tries to grid-fit + * edges, then to align segments on the edges unless it detects that + * they form a serif. * * - * A H - * | | - * | | - * | | - * | | - * C | | F - * +------<-----+ +-----<------+ - * | B G | - * | | - * | | - * +--------------->------------------+ - * D E + * A H + * | | + * | | + * | | + * | | + * C | | F + * +------<-----+ +-----<------+ + * | B G | + * | | + * | | + * +--------------->------------------+ + * D E * * - * Stems + * Stems * - * Stems are detected by `af_{cjk,latin,...}_hint_edges'. + * Stems are detected by `af_{cjk,latin,...}_hint_edges'. * - * Segments need to be `linked' to other ones in order to detect stems. - * A stem is made of two segments that face each other in opposite - * directions and that are sufficiently close to each other. Using - * vocabulary from the TrueType specification, stem segments form a - * `black distance'. + * Segments need to be `linked' to other ones in order to detect stems. + * A stem is made of two segments that face each other in opposite + * directions and that are sufficiently close to each other. Using + * vocabulary from the TrueType specification, stem segments form a + * `black distance'. * - * In the above ASCII drawing, the horizontal segments are BC, DE, and - * FG; the vertical segments are AB, CD, EF, and GH. + * In the above ASCII drawing, the horizontal segments are BC, DE, and + * FG; the vertical segments are AB, CD, EF, and GH. * - * Each segment has at most one `best' candidate to form a black - * distance, or no candidate at all. Notice that two distinct segments - * can have the same candidate, which frequently means a serif. + * Each segment has at most one `best' candidate to form a black + * distance, or no candidate at all. Notice that two distinct segments + * can have the same candidate, which frequently means a serif. * - * A stem is recognized by the following condition: + * A stem is recognized by the following condition: * - * best segment_1 = segment_2 && best segment_2 = segment_1 + * best segment_1 = segment_2 && best segment_2 = segment_1 * - * The best candidate is stored in field `link' in structure - * `AF_Segment'. + * The best candidate is stored in field `link' in structure + * `AF_Segment'. * - * In the above ASCII drawing, the best candidate for both AB and CD is - * GH, while the best candidate for GH is AB. Similarly, the best - * candidate for EF and GH is AB, while the best candidate for AB is - * GH. + * In the above ASCII drawing, the best candidate for both AB and CD is + * GH, while the best candidate for GH is AB. Similarly, the best + * candidate for EF and GH is AB, while the best candidate for AB is + * GH. * - * The detection and handling of stems is dependent on the writing - * system. + * The detection and handling of stems is dependent on the writing + * system. * * - * Serifs + * Serifs * - * Serifs are detected by `af_{cjk,latin,...}_hint_edges'. + * Serifs are detected by `af_{cjk,latin,...}_hint_edges'. * - * In comparison to a stem, a serif (as handled by the auto-hinter - * module that takes care of the `latin' writing system) has + * In comparison to a stem, a serif (as handled by the auto-hinter + * module that takes care of the `latin' writing system) has * - * best segment_1 = segment_2 && best segment_2 != segment_1 + * best segment_1 = segment_2 && best segment_2 != segment_1 * - * where segment_1 corresponds to the serif segment (CD and EF in the - * above ASCII drawing). + * where segment_1 corresponds to the serif segment (CD and EF in the + * above ASCII drawing). * - * The best candidate is stored in field `serif' in structure - * `AF_Segment' (and `link' is set to NULL). + * The best candidate is stored in field `serif' in structure + * `AF_Segment' (and `link' is set to NULL). * * - * Touched points + * Touched points * - * A point is called `touched' if it has been processed somehow by the - * auto-hinter. It basically means that it shouldn't be moved again - * (or moved only under certain constraints to preserve the already - * applied processing). + * A point is called `touched' if it has been processed somehow by the + * auto-hinter. It basically means that it shouldn't be moved again + * (or moved only under certain constraints to preserve the already + * applied processing). * * - * Flat and round segments + * Flat and round segments * - * Segments are `round' or `flat', depending on the series of points - * that define them. A segment is round if the next and previous point - * of an extremum (which can be either a single point or sequence of - * points) are both conic or cubic control points. Otherwise, a - * segment with an extremum is flat. + * Segments are `round' or `flat', depending on the series of points + * that define them. A segment is round if the next and previous point + * of an extremum (which can be either a single point or sequence of + * points) are both conic or cubic control points. Otherwise, a + * segment with an extremum is flat. * * - * Strong Points + * Strong Points * - * Experience has shown that points not part of an edge need to be - * interpolated linearly between their two closest edges, even if these - * are not part of the contour of those particular points. Typical - * candidates for this are + * Experience has shown that points not part of an edge need to be + * interpolated linearly between their two closest edges, even if these + * are not part of the contour of those particular points. Typical + * candidates for this are * - * - angle points (i.e., points where the `in' and `out' direction - * differ greatly) + * - angle points (i.e., points where the `in' and `out' direction + * differ greatly) * - * - inflection points (i.e., where the `in' and `out' angles are the - * same, but the curvature changes sign) [currently, such points - * aren't handled specially in the auto-hinter] + * - inflection points (i.e., where the `in' and `out' angles are the + * same, but the curvature changes sign) [currently, such points + * aren't handled specially in the auto-hinter] * - * `af_glyph_hints_align_strong_points' is the function that takes - * care of such situations; it is equivalent to the TrueType `IP' - * hinting instruction. + * `af_glyph_hints_align_strong_points' is the function that takes + * care of such situations; it is equivalent to the TrueType `IP' + * hinting instruction. * * - * Weak Points + * Weak Points * - * Other points in the outline must be interpolated using the - * coordinates of their previous and next unfitted contour neighbours. - * These are called `weak points' and are touched by the function - * `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP' - * hinting instruction. Typical candidates are control points and - * points on the contour without a major direction. + * Other points in the outline must be interpolated using the + * coordinates of their previous and next unfitted contour neighbours. + * These are called `weak points' and are touched by the function + * `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP' + * hinting instruction. Typical candidates are control points and + * points on the contour without a major direction. * - * The major effect is to reduce possible distortion caused by - * alignment of edges and strong points, thus weak points are processed - * after strong points. + * The major effect is to reduce possible distortion caused by + * alignment of edges and strong points, thus weak points are processed + * after strong points. */ @@ -252,6 +252,12 @@ FT_BEGIN_HEADER AF_Point next; /* next point in contour */ AF_Point prev; /* previous point in contour */ +#ifdef FT_DEBUG_AUTOFIT + /* track `before' and `after' edges for strong points */ + AF_Edge before[2]; + AF_Edge after[2]; +#endif + } AF_PointRec; diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c index dfbea5f34c1..a17117c7129 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afindic.c */ -/* */ -/* Auto-fitter hinting routines for Indic writing system (body). */ -/* */ -/* Copyright 2007-2018 by */ -/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afindic.c + * + * Auto-fitter hinting routines for Indic writing system (body). + * + * Copyright (C) 2007-2019 by + * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h index 5688738e6e0..bc5bc59fa55 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afindic.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afindic.h */ -/* */ -/* Auto-fitter hinting routines for Indic writing system */ -/* (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afindic.h + * + * Auto-fitter hinting routines for Indic writing system + * (specification). + * + * Copyright (C) 2007-2019 by + * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFINDIC_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c index 9f1b54056f1..dccdcaf3457 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* aflatin.c */ -/* */ -/* Auto-fitter hinting routines for latin writing system (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aflatin.c + * + * Auto-fitter hinting routines for latin writing system (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,7 +21,6 @@ #include FT_INTERNAL_DEBUG_H #include "afglobal.h" -#include "afpic.h" #include "aflatin.h" #include "aferrors.h" @@ -31,14 +30,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_aflatin +#define FT_COMPONENT aflatin /* needed for computation of round vs. flat segments */ @@ -83,24 +82,30 @@ AF_LatinMetricsRec dummy[1]; AF_Scaler scaler = &dummy->root.scaler; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = metrics->root.globals; -#endif - AF_StyleClass style_class = metrics->root.style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; + + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif - void* shaper_buf; const char* p; #ifdef FT_DEBUG_LEVEL_TRACE FT_ULong ch = 0; #endif - p = script_class->standard_charstring; - shaper_buf = af_shaper_buf_create( face ); + p = script_class->standard_charstring; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + shaper_buf = af_shaper_buf_create( face ); +#endif /* * We check a list of standard characters to catch features like * `c2sc' (small caps from caps) that don't contain lowercase letters @@ -186,10 +191,10 @@ goto Exit; /* - * We assume that the glyphs selected for the stem width - * computation are `featureless' enough so that the linking - * algorithm works fine without adjustments of its scoring - * function. + * We assume that the glyphs selected for the stem width + * computation are `featureless' enough so that the linking + * algorithm works fine without adjustments of its scoring + * function. */ af_latin_hints_link_segments( hints, 0, @@ -329,7 +334,14 @@ FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em ); - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* we walk over the blue character strings as specified in the */ @@ -339,7 +351,9 @@ "============================\n" "\n" )); +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ ) { @@ -884,8 +898,8 @@ if ( num_flats == 0 && num_rounds == 0 ) { /* - * we couldn't find a single glyph to compute this blue zone, - * we will simply ignore it then + * we couldn't find a single glyph to compute this blue zone, + * we will simply ignore it then */ FT_TRACE5(( " empty\n" )); continue; @@ -1036,15 +1050,25 @@ FT_Bool started = 0, same_width = 1; FT_Fixed advance = 0, old_advance = 0; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* in all supported charmaps, digits have character codes 0x30-0x39 */ const char digits[] = "0 1 2 3 4 5 6 7 8 9"; const char* p; - p = digits; + p = digits; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif while ( *p ) { @@ -1283,7 +1307,7 @@ /* an extra-light axis corresponds to a standard width that is */ /* smaller than 5/8 pixels */ axis->extra_light = - (FT_Bool)( FT_MulFix( axis->standard_width, scale ) < 32 + 8 ); + FT_BOOL( FT_MulFix( axis->standard_width, scale ) < 32 + 8 ); #ifdef FT_DEBUG_LEVEL_TRACE if ( axis->extra_light ) @@ -1967,17 +1991,17 @@ if ( len >= len_threshold ) { /* - * The score is the sum of two demerits indicating the - * `badness' of a fit, measured along the segments' main axis - * and orthogonal to it, respectively. + * The score is the sum of two demerits indicating the + * `badness' of a fit, measured along the segments' main axis + * and orthogonal to it, respectively. * - * o The less overlapping along the main axis, the worse it - * is, causing a larger demerit. + * - The less overlapping along the main axis, the worse it + * is, causing a larger demerit. * - * o The nearer the orthogonal distance to a stem width, the - * better it is, causing a smaller demerit. For simplicity, - * however, we only increase the demerit for values that - * exceed the largest stem width. + * - The nearer the orthogonal distance to a stem width, the + * better it is, causing a smaller demerit. For simplicity, + * however, we only increase the demerit for values that + * exceed the largest stem width. */ FT_Pos dist = pos2 - pos1; @@ -2049,13 +2073,8 @@ FT_Memory memory = hints->memory; AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim]; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = hints->metrics->globals; -#endif - AF_StyleClass style_class = hints->metrics->style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; FT_Bool top_to_bottom_hinting = 0; @@ -2086,9 +2105,9 @@ top_to_bottom_hinting = script_class->top_to_bottom_hinting; /* - * We ignore all segments that are less than 1 pixel in length - * to avoid many problems with serif fonts. We compute the - * corresponding threshold in font units. + * We ignore all segments that are less than 1 pixel in length + * to avoid many problems with serif fonts. We compute the + * corresponding threshold in font units. */ if ( dim == AF_DIMENSION_HORZ ) segment_length_threshold = FT_DivFix( 64, hints->y_scale ); @@ -2096,26 +2115,26 @@ segment_length_threshold = 0; /* - * Similarly, we ignore segments that have a width delta - * larger than 0.5px (i.e., a width larger than 1px). + * Similarly, we ignore segments that have a width delta + * larger than 0.5px (i.e., a width larger than 1px). */ segment_width_threshold = FT_DivFix( 32, scale ); - /*********************************************************************/ - /* */ - /* We begin by generating a sorted table of edges for the current */ - /* direction. To do so, we simply scan each segment and try to find */ - /* an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which gets processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the table of edges is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ + /********************************************************************** + * + * We begin by generating a sorted table of edges for the current + * direction. To do so, we simply scan each segment and try to find + * an edge in our table that corresponds to its position. + * + * If no edge is found, we create and insert a new edge in the + * sorted table. Otherwise, we simply add the segment to the edge's + * list which gets processed in the second step to compute the + * edge's properties. + * + * Note that the table of edges is sorted along the segment/edge + * position. + * + */ /* assure that edge distance threshold is at most 0.25px */ edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold, @@ -2237,17 +2256,17 @@ } - /******************************************************************/ - /* */ - /* Good, we now compute each edge's properties according to the */ - /* segments found on its position. Basically, these are */ - /* */ - /* - the edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straight or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /******************************************************************/ + /******************************************************************* + * + * Good, we now compute each edge's properties according to the + * segments found on its position. Basically, these are + * + * - the edge's main direction + * - stem edge, serif edge or both (which defaults to stem then) + * - rounded edge, straight or both (which defaults to straight) + * - link for edge + * + */ /* first of all, set the `edge' field in each segment -- this is */ /* required in order to compute edge links */ @@ -2309,9 +2328,9 @@ /* check for links -- if seg->serif is set, then seg->link must */ /* be ignored */ - is_serif = (FT_Bool)( seg->serif && - seg->serif->edge && - seg->serif->edge != edge ); + is_serif = FT_BOOL( seg->serif && + seg->serif->edge && + seg->serif->edge != edge ); if ( ( seg->link && seg->link->edge ) || is_serif ) { @@ -2546,8 +2565,8 @@ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics ); /* - * correct x_scale and y_scale if needed, since they may have - * been modified by `af_latin_metrics_scale_dim' above + * correct x_scale and y_scale if needed, since they may have + * been modified by `af_latin_metrics_scale_dim' above */ hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale; hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta; @@ -2566,21 +2585,21 @@ other_flags = 0; /* - * We snap the width of vertical stems for the monochrome and - * horizontal LCD rendering targets only. + * We snap the width of vertical stems for the monochrome and + * horizontal LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_HORZ_SNAP; /* - * We snap the width of horizontal stems for the monochrome and - * vertical LCD rendering targets only. + * We snap the width of horizontal stems for the monochrome and + * vertical LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels unless in `light' or `lcd' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; @@ -2589,11 +2608,11 @@ other_flags |= AF_LATIN_HINTS_MONO; /* - * In `light' or `lcd' mode we disable horizontal hinting completely. - * We also do it if the face is italic. + * In `light' or `lcd' mode we disable horizontal hinting completely. + * We also do it if the face is italic. * - * However, if warping is enabled (which only works in `light' hinting - * mode), advance widths get adjusted, too. + * However, if warping is enabled (which only works in `light' hinting + * mode), advance widths get adjusted, too. */ if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD || ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) @@ -2936,13 +2955,8 @@ AF_Edge anchor = NULL; FT_Int has_serifs = 0; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = hints->metrics->globals; -#endif - AF_StyleClass style_class = hints->metrics->style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; FT_Bool top_to_bottom_hinting = 0; @@ -2976,12 +2990,12 @@ edge2 = edge->link; /* - * If a stem contains both a neutral and a non-neutral blue zone, - * skip the neutral one. Otherwise, outlines with different - * directions might be incorrectly aligned at the same vertical - * position. + * If a stem contains both a neutral and a non-neutral blue zone, + * skip the neutral one. Otherwise, outlines with different + * directions might be incorrectly aligned at the same vertical + * position. * - * If we have two neutral blue zones, skip one of them. + * If we have two neutral blue zones, skip one of them. * */ if ( edge->blue_edge && edge2 && edge2->blue_edge ) @@ -3344,8 +3358,8 @@ if ( has_serifs || !anchor ) { /* - * now hint the remaining edges (serifs and single) in order - * to complete our processing + * now hint the remaining edges (serifs and single) in order + * to complete our processing */ for ( edge = edges; edge < edge_limit; edge++ ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h index 432cccce4e2..40479538c25 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* aflatin.h */ -/* */ -/* Auto-fitter hinting routines for latin writing system */ -/* (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aflatin.h + * + * Auto-fitter hinting routines for latin writing system + * (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFLATIN_H_ @@ -45,9 +45,9 @@ FT_BEGIN_HEADER /* - * The following declarations could be embedded in the file `aflatin.c'; - * they have been made semi-public to allow alternate writing system - * hinters to re-use some of them. + * The following declarations could be embedded in the file `aflatin.c'; + * they have been made semi-public to allow alternate writing system + * hinters to re-use some of them. */ @@ -161,8 +161,8 @@ FT_BEGIN_HEADER /* - * The next functions shouldn't normally be exported. However, other - * writing systems might like to use these functions as-is. + * The next functions shouldn't normally be exported. However, other + * writing systems might like to use these functions as-is. */ FT_LOCAL( FT_Error ) af_latin_hints_compute_segments( AF_GlyphHints hints, diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c index a55550b3385..83743b7be15 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afloader.c */ -/* */ -/* Auto-fitter glyph loading routines (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afloader.c + * + * Auto-fitter glyph loading routines (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afglobal.h" @@ -21,7 +21,6 @@ #include "afhints.h" #include "aferrors.h" #include "afmodule.h" -#include "afpic.h" #include FT_INTERNAL_CALC_H @@ -119,12 +118,12 @@ } /* - * We depend on the writing system (script analyzers) to supply - * standard widths for the script of the glyph we are looking at. If - * it can't deliver, stem darkening is disabled. + * We depend on the writing system (script analyzers) to supply + * standard widths for the script of the glyph we are looking at. If + * it can't deliver, stem darkening is disabled. */ writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_metrics->style_class->writing_system]; + af_writing_system_classes[style_metrics->style_class->writing_system]; if ( writing_system_class->style_metrics_getstdw ) writing_system_class->style_metrics_getstdw( style_metrics, @@ -174,22 +173,22 @@ globals->darken_y = af_fixedToInt( darken_y ); /* - * Scale outlines down on the Y-axis to keep them inside their blue - * zones. The stronger the emboldening, the stronger the downscaling - * (plus heuristical padding to prevent outlines still falling out - * their zones due to rounding). + * Scale outlines down on the Y-axis to keep them inside their blue + * zones. The stronger the emboldening, the stronger the downscaling + * (plus heuristical padding to prevent outlines still falling out + * their zones due to rounding). * - * Reason: `FT_Outline_Embolden' works by shifting the rightmost - * points of stems farther to the right, and topmost points farther - * up. This positions points on the Y-axis outside their - * pre-computed blue zones and leads to distortion when applying the - * hints in the code further below. Code outside this emboldening - * block doesn't know we are presenting it with modified outlines the - * analyzer didn't see! + * Reason: `FT_Outline_Embolden' works by shifting the rightmost + * points of stems farther to the right, and topmost points farther + * up. This positions points on the Y-axis outside their + * pre-computed blue zones and leads to distortion when applying the + * hints in the code further below. Code outside this emboldening + * block doesn't know we are presenting it with modified outlines the + * analyzer didn't see! * - * An unfortunate side effect of downscaling is that the emboldening - * effect is slightly decreased. The loss becomes more pronounced - * versus the CFF driver at smaller sizes, e.g., at 9ppem and below. + * An unfortunate side effect of downscaling is that the emboldening + * effect is slightly decreased. The loss becomes more pronounced + * versus the CFF driver at smaller sizes, e.g., at 9ppem and below. */ globals->scale_down_factor = FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ), @@ -232,10 +231,6 @@ AF_StyleClass style_class; AF_WritingSystemClass writing_system_class; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = loader->globals; -#endif - if ( !size ) return FT_THROW( Invalid_Size_Handle ); @@ -282,13 +277,13 @@ } /* - * TODO: This code currently doesn't support fractional advance widths, - * i.e., placing hinted glyphs at anything other than integer - * x-positions. This is only relevant for the warper code, which - * scales and shifts glyphs to optimize blackness of stems (hinting on - * the x-axis by nature places things on pixel integers, hinting on the - * y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta - * values of the scaler would need to be adjusted. + * TODO: This code currently doesn't support fractional advance widths, + * i.e., placing hinted glyphs at anything other than integer + * x-positions. This is only relevant for the warper code, which + * scales and shifts glyphs to optimize blackness of stems (hinting on + * the x-axis by nature places things on pixel integers, hinting on the + * y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta + * values of the scaler would need to be adjusted. */ scaler.face = face; scaler.x_scale = size_internal->autohint_metrics.x_scale; @@ -312,10 +307,10 @@ #endif /* - * Glyphs (really code points) are assigned to scripts. Script - * analysis is done lazily: For each glyph that passes through here, - * the corresponding script analyzer is called, but returns immediately - * if it has been run already. + * Glyphs (really code points) are assigned to scripts. Script + * analysis is done lazily: For each glyph that passes through here, + * the corresponding script analyzer is called, but returns immediately + * if it has been run already. */ error = af_face_globals_get_metrics( loader->globals, glyph_index, style_options, &style_metrics ); @@ -324,7 +319,7 @@ style_class = style_metrics->style_class; writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; + af_writing_system_classes[style_class->writing_system]; loader->metrics = style_metrics; @@ -342,11 +337,11 @@ } /* - * Do the main work of `af_loader_load_glyph'. Note that we never have - * to deal with composite glyphs as those get loaded into - * FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. - * In the rare cases where FT_LOAD_NO_RECURSE is set, it implies - * FT_LOAD_NO_SCALE and as such the auto-hinter is never called. + * Do the main work of `af_loader_load_glyph'. Note that we never have + * to deal with composite glyphs as those get loaded into + * FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. + * In the rare cases where FT_LOAD_NO_RECURSE is set, it implies + * FT_LOAD_NO_SCALE and as such the auto-hinter is never called. */ load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM | @@ -358,26 +353,26 @@ goto Exit; /* - * Apply stem darkening (emboldening) here before hints are applied to - * the outline. Glyphs are scaled down proportionally to the - * emboldening so that curve points don't fall outside their - * precomputed blue zones. + * Apply stem darkening (emboldening) here before hints are applied to + * the outline. Glyphs are scaled down proportionally to the + * emboldening so that curve points don't fall outside their + * precomputed blue zones. * - * Any emboldening done by the font driver (e.g., the CFF driver) - * doesn't reach here because the autohinter loads the unprocessed - * glyphs in font units for analysis (functions `af_*_metrics_init_*') - * and then above to prepare it for the rasterizers by itself, - * independently of the font driver. So emboldening must be done here, - * within the autohinter. + * Any emboldening done by the font driver (e.g., the CFF driver) + * doesn't reach here because the autohinter loads the unprocessed + * glyphs in font units for analysis (functions `af_*_metrics_init_*') + * and then above to prepare it for the rasterizers by itself, + * independently of the font driver. So emboldening must be done here, + * within the autohinter. * - * All glyphs to be autohinted pass through here one by one. The - * standard widths can therefore change from one glyph to the next, - * depending on what script a glyph is assigned to (each script has its - * own set of standard widths and other metrics). The darkening amount - * must therefore be recomputed for each size and - * `standard_{vertical,horizontal}_width' change. + * All glyphs to be autohinted pass through here one by one. The + * standard widths can therefore change from one glyph to the next, + * depending on what script a glyph is assigned to (each script has its + * own set of standard widths and other metrics). The darkening amount + * must therefore be recomputed for each size and + * `standard_{vertical,horizontal}_width' change. * - * Ignore errors and carry on without emboldening. + * Ignore errors and carry on without emboldening. * */ @@ -426,35 +421,39 @@ /* now load the slot image into the auto-outline */ /* and run the automatic hinting process */ if ( writing_system_class->style_hints_apply ) - writing_system_class->style_hints_apply( glyph_index, - hints, - &gloader->base.outline, - style_metrics ); + { + error = writing_system_class->style_hints_apply( + glyph_index, + hints, + &gloader->base.outline, + style_metrics ); + if ( error ) + goto Exit; + } /* we now need to adjust the metrics according to the change in */ /* width/positioning that occurred during the hinting process */ if ( scaler.render_mode != FT_RENDER_MODE_LIGHT ) { - FT_Pos old_rsb, old_lsb, new_lsb; - FT_Pos pp1x_uh, pp2x_uh; - AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ]; - AF_Edge edge1 = axis->edges; /* leftmost edge */ - AF_Edge edge2 = edge1 + - axis->num_edges - 1; /* rightmost edge */ if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) ) { - old_rsb = loader->pp2.x - edge2->opos; + AF_Edge edge1 = axis->edges; /* leftmost edge */ + AF_Edge edge2 = edge1 + + axis->num_edges - 1; /* rightmost edge */ + + FT_Pos old_rsb = loader->pp2.x - edge2->opos; /* loader->pp1.x is always zero at this point of time */ - old_lsb = edge1->opos /* - loader->pp1.x */; - new_lsb = edge1->pos; + FT_Pos old_lsb = edge1->opos; /* - loader->pp1.x */ + FT_Pos new_lsb = edge1->pos; /* remember unhinted values to later account */ /* for rounding errors */ - pp1x_uh = new_lsb - old_lsb; - pp2x_uh = edge2->pos + old_rsb; + FT_Pos pp1x_uh = new_lsb - old_lsb; + FT_Pos pp2x_uh = edge2->pos + old_rsb; + /* prefer too much space over too little space */ /* for very small sizes */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h index d4d72d15830..d1e0f3c093d 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afloader.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afloader.h */ -/* */ -/* Auto-fitter glyph loading routines (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afloader.h + * + * Auto-fitter glyph loading routines (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFLOADER_H_ @@ -27,11 +27,11 @@ FT_BEGIN_HEADER /* - * The autofitter module's (global) data structure to communicate with - * actual fonts. If necessary, `local' data like the current face, the - * current face's auto-hint data, or the current glyph's parameters - * relevant to auto-hinting are `swapped in'. Cf. functions like - * `af_loader_reset' and `af_loader_load_g'. + * The autofitter module's (global) data structure to communicate with + * actual fonts. If necessary, `local' data like the current face, the + * current face's auto-hint data, or the current glyph's parameters + * relevant to auto-hinting are `swapped in'. Cf. functions like + * `af_loader_reset' and `af_loader_load_g'. */ typedef struct AF_LoaderRec_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c index dcaa17a27e9..3e46a3655a4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.c @@ -1,26 +1,25 @@ -/***************************************************************************/ -/* */ -/* afmodule.c */ -/* */ -/* Auto-fitter module implementation (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmodule.c + * + * Auto-fitter module implementation (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afglobal.h" #include "afmodule.h" #include "afloader.h" #include "aferrors.h" -#include "afpic.h" #ifdef FT_DEBUG_AUTOFIT @@ -60,14 +59,14 @@ #include FT_SERVICE_PROPERTIES_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afmodule +#define FT_COMPONENT afmodule static FT_Error @@ -104,19 +103,6 @@ } -#ifdef FT_CONFIG_OPTION_PIC - -#undef AF_SCRIPT_CLASSES_GET -#define AF_SCRIPT_CLASSES_GET \ - ( GET_PIC( ft_module->library )->af_script_classes ) - -#undef AF_STYLE_CLASSES_GET -#define AF_STYLE_CLASSES_GET \ - ( GET_PIC( ft_module->library )->af_style_classes ) - -#endif - - static FT_Error af_property_set( FT_Module ft_module, const char* property_name, @@ -147,9 +133,9 @@ /* We translate the fallback script to a fallback style that uses */ /* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */ /* coverage value. */ - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; + AF_StyleClass style_class = af_style_classes[ss]; if ( (FT_UInt)style_class->script == *fallback_script && @@ -160,7 +146,7 @@ } } - if ( !AF_STYLE_CLASSES_GET[ss] ) + if ( !af_style_classes[ss] ) { FT_TRACE0(( "af_property_set: Invalid value %d for property `%s'\n", fallback_script, property_name )); @@ -357,7 +343,7 @@ { FT_UInt* val = (FT_UInt*)value; - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[fallback_style]; + AF_StyleClass style_class = af_style_classes[fallback_style]; *val = style_class->script; @@ -440,28 +426,16 @@ FT_DEFINE_SERVICEDESCREC1( af_services, - FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET ) + FT_SERVICE_ID_PROPERTIES, &af_service_properties ) FT_CALLBACK_DEF( FT_Module_Interface ) af_get_interface( FT_Module module, const char* module_interface ) { - /* AF_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library; - - - if ( !module ) - return NULL; - library = module->library; - if ( !library ) - return NULL; -#else FT_UNUSED( module ); -#endif - return ft_service_list_lookup( AF_SERVICES_GET, module_interface ); + return ft_service_list_lookup( af_services, module_interface ); } @@ -533,7 +507,7 @@ glyph_index, load_flags ); #ifdef FT_DEBUG_LEVEL_TRACE - if ( ft_trace_levels[FT_COMPONENT] ) + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] ) { #endif af_glyph_hints_dump_points( hints, 0 ); @@ -589,7 +563,7 @@ 0x10000L, /* version 1.0 of the autofitter */ 0x20000L, /* requires FreeType 2.0 or above */ - (const void*)&AF_INTERFACE_GET, + (const void*)&af_autofitter_interface, (FT_Module_Constructor)af_autofitter_init, /* module_init */ (FT_Module_Destructor) af_autofitter_done, /* module_done */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h index 56f64eaf231..b410809aa83 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afmodule.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afmodule.h */ -/* */ -/* Auto-fitter module implementation (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmodule.h + * + * Auto-fitter module implementation (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFMODULE_H_ @@ -28,8 +28,8 @@ FT_BEGIN_HEADER /* - * This is the `extended' FT_Module structure that holds the - * autofitter's global data. + * This is the `extended' FT_Module structure that holds the + * autofitter's global data. */ typedef struct AF_ModuleRec_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afpic.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afpic.c deleted file mode 100644 index d48d016a0e8..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afpic.c +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************/ -/* */ -/* afpic.c */ -/* */ -/* The FreeType position independent code services for autofit module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "afpic.h" -#include "afglobal.h" -#include "aferrors.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from afmodule.c */ - FT_Error - FT_Create_Class_af_services( FT_Library library, - FT_ServiceDescRec** output_class ); - - void - FT_Destroy_Class_af_services( FT_Library library, - FT_ServiceDescRec* clazz ); - - void - FT_Init_Class_af_service_properties( FT_Service_PropertiesRec* clazz ); - - void FT_Init_Class_af_autofitter_interface( - FT_Library library, - FT_AutoHinter_InterfaceRec* clazz ); - - - /* forward declaration of PIC init functions from writing system classes */ -#undef WRITING_SYSTEM -#define WRITING_SYSTEM( ws, WS ) /* empty */ - -#include "afwrtsys.h" - - - void - autofit_module_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->autofit ) - { - AFModulePIC* container = (AFModulePIC*)pic_container->autofit; - - - if ( container->af_services ) - FT_Destroy_Class_af_services( library, - container->af_services ); - container->af_services = NULL; - - FT_FREE( container ); - pic_container->autofit = NULL; - } - } - - - FT_Error - autofit_module_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_UInt ss; - FT_Error error = FT_Err_Ok; - AFModulePIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC ( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->autofit = container; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - error = FT_Create_Class_af_services( library, - &container->af_services ); - if ( error ) - goto Exit; - - FT_Init_Class_af_service_properties( &container->af_service_properties ); - - for ( ss = 0; ss < AF_WRITING_SYSTEM_MAX; ss++ ) - container->af_writing_system_classes[ss] = - &container->af_writing_system_classes_rec[ss]; - container->af_writing_system_classes[AF_WRITING_SYSTEM_MAX] = NULL; - - for ( ss = 0; ss < AF_SCRIPT_MAX; ss++ ) - container->af_script_classes[ss] = - &container->af_script_classes_rec[ss]; - container->af_script_classes[AF_SCRIPT_MAX] = NULL; - - for ( ss = 0; ss < AF_STYLE_MAX; ss++ ) - container->af_style_classes[ss] = - &container->af_style_classes_rec[ss]; - container->af_style_classes[AF_STYLE_MAX] = NULL; - -#undef WRITING_SYSTEM -#define WRITING_SYSTEM( ws, WS ) \ - FT_Init_Class_af_ ## ws ## _writing_system_class( \ - &container->af_writing_system_classes_rec[ss++] ); - - ss = 0; -#include "afwrtsys.h" - -#undef SCRIPT -#define SCRIPT( s, S, d, h, H, sss ) \ - FT_Init_Class_af_ ## s ## _script_class( \ - &container->af_script_classes_rec[ss++] ); - - ss = 0; -#include "afscript.h" - -#undef STYLE -#define STYLE( s, S, d, ws, sc, bss, c ) \ - FT_Init_Class_af_ ## s ## _style_class( \ - &container->af_style_classes_rec[ss++] ); - - ss = 0; -#include "afstyles.h" - - FT_Init_Class_af_autofitter_interface( - library, &container->af_autofitter_interface ); - - Exit: - if ( error ) - autofit_module_class_pic_free( library ); - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afpic.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afpic.h deleted file mode 100644 index 0c734567859..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afpic.h +++ /dev/null @@ -1,105 +0,0 @@ -/***************************************************************************/ -/* */ -/* afpic.h */ -/* */ -/* The FreeType position independent code services for autofit module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef AFPIC_H_ -#define AFPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -#ifndef FT_CONFIG_OPTION_PIC - -#define AF_SERVICES_GET af_services -#define AF_SERVICE_PROPERTIES_GET af_service_properties - -#define AF_WRITING_SYSTEM_CLASSES_GET af_writing_system_classes -#define AF_SCRIPT_CLASSES_GET af_script_classes -#define AF_STYLE_CLASSES_GET af_style_classes -#define AF_INTERFACE_GET af_autofitter_interface - -#else /* FT_CONFIG_OPTION_PIC */ - - /* some include files required for members of AFModulePIC */ -#include FT_SERVICE_PROPERTIES_H - -#include "aftypes.h" - - -FT_BEGIN_HEADER - - typedef struct AFModulePIC_ - { - FT_ServiceDescRec* af_services; - FT_Service_PropertiesRec af_service_properties; - - AF_WritingSystemClass af_writing_system_classes - [AF_WRITING_SYSTEM_MAX + 1]; - AF_WritingSystemClassRec af_writing_system_classes_rec - [AF_WRITING_SYSTEM_MAX]; - - AF_ScriptClass af_script_classes - [AF_SCRIPT_MAX + 1]; - AF_ScriptClassRec af_script_classes_rec - [AF_SCRIPT_MAX]; - - AF_StyleClass af_style_classes - [AF_STYLE_MAX + 1]; - AF_StyleClassRec af_style_classes_rec - [AF_STYLE_MAX]; - - FT_AutoHinter_InterfaceRec af_autofitter_interface; - - } AFModulePIC; - - -#define GET_PIC( lib ) \ - ( (AFModulePIC*)( (lib)->pic_container.autofit ) ) - -#define AF_SERVICES_GET \ - ( GET_PIC( library )->af_services ) -#define AF_SERVICE_PROPERTIES_GET \ - ( GET_PIC( library )->af_service_properties ) - -#define AF_WRITING_SYSTEM_CLASSES_GET \ - ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_writing_system_classes ) -#define AF_SCRIPT_CLASSES_GET \ - ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes ) -#define AF_STYLE_CLASSES_GET \ - ( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_style_classes ) -#define AF_INTERFACE_GET \ - ( GET_PIC( library )->af_autofitter_interface ) - - - /* see afpic.c for the implementation */ - void - autofit_module_class_pic_free( FT_Library library ); - - FT_Error - autofit_module_class_pic_init( FT_Library library ); - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* AFPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c index cf67fafb11c..c0dba818a13 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afranges.c */ -/* */ -/* Auto-fitter Unicode script ranges (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afranges.c + * + * Auto-fitter Unicode script ranges (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afranges.h" diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h index ba3b5e7ccbc..d5917aefed0 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afranges.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afranges.h */ -/* */ -/* Auto-fitter Unicode script ranges (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afranges.h + * + * Auto-fitter Unicode script ranges (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFRANGES_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h index 623a1734a62..c2f0c7ac60a 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afscript.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afscript.h */ -/* */ -/* Auto-fitter scripts (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afscript.h + * + * Auto-fitter scripts (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* The following part can be included multiple times. */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c index f30828173cf..a5191c69158 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afshaper.c */ -/* */ -/* HarfBuzz interface for accessing OpenType features (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afshaper.c + * + * HarfBuzz interface for accessing OpenType features (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afshaper +#define FT_COMPONENT afshaper /* @@ -591,14 +591,9 @@ void* af_shaper_buf_create( FT_Face face ) { - FT_Error error; - FT_Memory memory = face->memory; - FT_ULong* buf; - - - FT_MEM_ALLOC( buf, sizeof ( FT_ULong ) ); + FT_UNUSED( face ); - return (void*)buf; + return NULL; } @@ -606,10 +601,8 @@ af_shaper_buf_destroy( FT_Face face, void* buf ) { - FT_Memory memory = face->memory; - - - FT_FREE( buf ); + FT_UNUSED( face ); + FT_UNUSED( buf ); } diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h index 7efd9f6a4e6..06a1e066162 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afshaper.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afshaper.h */ -/* */ -/* HarfBuzz interface for accessing OpenType features (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afshaper.h + * + * HarfBuzz interface for accessing OpenType features (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFSHAPER_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h index e2688b3fc25..edf4f54edd7 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afstyles.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afstyles.h */ -/* */ -/* Auto-fitter styles (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afstyles.h + * + * Auto-fitter styles (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* The following part can be included multiple times. */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h index 6bd8c895b2a..579003d27d9 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/aftypes.h @@ -1,30 +1,30 @@ -/***************************************************************************/ -/* */ -/* aftypes.h */ -/* */ -/* Auto-fitter types (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aftypes.h + * + * Auto-fitter types (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /************************************************************************* * - * The auto-fitter is a complete rewrite of the old auto-hinter. - * Its main feature is the ability to differentiate between different - * writing systems and scripts in order to apply specific rules. + * The auto-fitter is a complete rewrite of the old auto-hinter. + * Its main feature is the ability to differentiate between different + * writing systems and scripts in order to apply specific rules. * - * The code has also been compartmentalized into several entities that - * should make algorithmic experimentation easier than with the old - * code. + * The code has also been compartmentalized into several entities that + * should make algorithmic experimentation easier than with the old + * code. * *************************************************************************/ @@ -102,9 +102,9 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * The auto-fitter doesn't need a very high angular accuracy; - * this allows us to speed up some computations considerably with a - * light Cordic algorithm (see afangles.c). + * The auto-fitter doesn't need a very high angular accuracy; + * this allows us to speed up some computations considerably with a + * light Cordic algorithm (see afangles.c). */ typedef FT_Int AF_Angle; @@ -118,7 +118,7 @@ extern void* _af_debug_hints; #if 0 /* - * compute the angle of a given 2-D vector + * compute the angle of a given 2-D vector */ FT_LOCAL( AF_Angle ) af_angle_atan( FT_Pos dx, @@ -126,8 +126,8 @@ extern void* _af_debug_hints; /* - * compute `angle2 - angle1'; the result is always within - * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1] + * compute `angle2 - angle1'; the result is always within + * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1] */ FT_LOCAL( AF_Angle ) af_angle_diff( AF_Angle angle1, @@ -150,8 +150,9 @@ extern void* _af_debug_hints; FT_END_STMNT - /* opaque handle to glyph-specific hints -- see `afhints.h' for more - * details + /* + * opaque handle to glyph-specific hints -- see `afhints.h' for more + * details */ typedef struct AF_GlyphHintsRec_* AF_GlyphHints; @@ -165,8 +166,8 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * A scaler models the target pixel device that will receive the - * auto-hinted glyph image. + * A scaler models the target pixel device that will receive the + * auto-hinted glyph image. */ #define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */ @@ -197,8 +198,9 @@ extern void* _af_debug_hints; typedef struct AF_StyleMetricsRec_* AF_StyleMetrics; - /* This function parses an FT_Face to compute global metrics for - * a specific style. + /* + * This function parses an FT_Face to compute global metrics for + * a specific style. */ typedef FT_Error (*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics, @@ -237,22 +239,22 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * For the auto-hinter, a writing system consists of multiple scripts that - * can be handled similarly *in a typographical way*; the relationship is - * not based on history. For example, both the Greek and the unrelated - * Armenian scripts share the same features like ascender, descender, - * x-height, etc. Essentially, a writing system is covered by a - * submodule of the auto-fitter; it contains + * For the auto-hinter, a writing system consists of multiple scripts that + * can be handled similarly *in a typographical way*; the relationship is + * not based on history. For example, both the Greek and the unrelated + * Armenian scripts share the same features like ascender, descender, + * x-height, etc. Essentially, a writing system is covered by a + * submodule of the auto-fitter; it contains * - * - a specific global analyzer that computes global metrics specific to - * the script (based on script-specific characters to identify ascender - * height, x-height, etc.), + * - a specific global analyzer that computes global metrics specific to + * the script (based on script-specific characters to identify ascender + * height, x-height, etc.), * - * - a specific glyph analyzer that computes segments and edges for each - * glyph covered by the script, + * - a specific glyph analyzer that computes segments and edges for each + * glyph covered by the script, * - * - a specific grid-fitting algorithm that distorts the scaled glyph - * outline according to the results of the glyph analyzer. + * - a specific grid-fitting algorithm that distorts the scaled glyph + * outline according to the results of the glyph analyzer. */ #define AFWRTSYS_H_ /* don't load header files */ @@ -300,12 +302,12 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * Each script is associated with two sets of Unicode ranges to test - * whether the font face supports the script, and which non-base - * characters the script contains. + * Each script is associated with two sets of Unicode ranges to test + * whether the font face supports the script, and which non-base + * characters the script contains. * - * We use four-letter script tags from the OpenType specification, - * extended by `NONE', which indicates `no script'. + * We use four-letter script tags from the OpenType specification, + * extended by `NONE', which indicates `no script'. */ #undef SCRIPT @@ -361,41 +363,41 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * Usually, a font contains more glyphs than can be addressed by its - * character map. + * Usually, a font contains more glyphs than can be addressed by its + * character map. * - * In the PostScript font world, encoding vectors specific to a given - * task are used to select such glyphs, and these glyphs can be often - * recognized by having a suffix in its glyph names. For example, a - * superscript glyph `A' might be called `A.sup'. Unfortunately, this - * naming scheme is not standardized and thus unusable for us. + * In the PostScript font world, encoding vectors specific to a given + * task are used to select such glyphs, and these glyphs can be often + * recognized by having a suffix in its glyph names. For example, a + * superscript glyph `A' might be called `A.sup'. Unfortunately, this + * naming scheme is not standardized and thus unusable for us. * - * In the OpenType world, a better solution was invented, namely - * `features', which cleanly separate a character's input encoding from - * the corresponding glyph's appearance, and which don't use glyph names - * at all. For our purposes, and slightly generalized, an OpenType - * feature is a name of a mapping that maps character codes to - * non-standard glyph indices (features get used for other things also). - * For example, the `sups' feature provides superscript glyphs, thus - * mapping character codes like `A' or `B' to superscript glyph - * representation forms. How this mapping happens is completely - * uninteresting to us. + * In the OpenType world, a better solution was invented, namely + * `features', which cleanly separate a character's input encoding from + * the corresponding glyph's appearance, and which don't use glyph names + * at all. For our purposes, and slightly generalized, an OpenType + * feature is a name of a mapping that maps character codes to + * non-standard glyph indices (features get used for other things also). + * For example, the `sups' feature provides superscript glyphs, thus + * mapping character codes like `A' or `B' to superscript glyph + * representation forms. How this mapping happens is completely + * uninteresting to us. * - * For the auto-hinter, a `coverage' represents all glyphs of an OpenType - * feature collected in a set (as listed below) that can be hinted - * together. To continue the above example, superscript glyphs must not - * be hinted together with normal glyphs because the blue zones - * completely differ. + * For the auto-hinter, a `coverage' represents all glyphs of an OpenType + * feature collected in a set (as listed below) that can be hinted + * together. To continue the above example, superscript glyphs must not + * be hinted together with normal glyphs because the blue zones + * completely differ. * - * Note that FreeType itself doesn't compute coverages; it only provides - * the glyphs addressable by the default Unicode character map. Instead, - * we use the HarfBuzz library (if available), which has many functions - * exactly for this purpose. + * Note that FreeType itself doesn't compute coverages; it only provides + * the glyphs addressable by the default Unicode character map. Instead, + * we use the HarfBuzz library (if available), which has many functions + * exactly for this purpose. * - * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't - * listed separately (including the glyphs addressable by the character - * map). In case HarfBuzz isn't available, it exactly covers the glyphs - * addressable by the character map. + * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't + * listed separately (including the glyphs addressable by the character + * map). In case HarfBuzz isn't available, it exactly covers the glyphs + * addressable by the character map. * */ @@ -423,8 +425,8 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * The topmost structure for modelling the auto-hinter glyph input data - * is a `style class', grouping everything together. + * The topmost structure for modelling the auto-hinter glyph input data + * is a `style class', grouping everything together. */ #undef STYLE @@ -486,8 +488,6 @@ extern void* _af_debug_hints; /* Declare and define vtables for classes */ -#ifndef FT_CONFIG_OPTION_PIC - #define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \ FT_CALLBACK_TABLE const AF_WritingSystemClassRec \ writing_system_class; @@ -562,87 +562,9 @@ extern void* _af_debug_hints; coverage \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \ - FT_LOCAL( void ) \ - FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ); - -#define AF_DEFINE_WRITING_SYSTEM_CLASS( \ - writing_system_class, \ - system, \ - m_size, \ - m_init, \ - m_scale, \ - m_done, \ - m_stdw, \ - h_init, \ - h_apply ) \ - FT_LOCAL_DEF( void ) \ - FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \ - { \ - ac->writing_system = system; \ - \ - ac->style_metrics_size = m_size; \ - \ - ac->style_metrics_init = m_init; \ - ac->style_metrics_scale = m_scale; \ - ac->style_metrics_done = m_done; \ - ac->style_metrics_getstdw = m_stdw; \ - \ - ac->style_hints_init = h_init; \ - ac->style_hints_apply = h_apply; \ - } - - -#define AF_DECLARE_SCRIPT_CLASS( script_class ) \ - FT_LOCAL( void ) \ - FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ); - -#define AF_DEFINE_SCRIPT_CLASS( \ - script_class, \ - script_, \ - ranges, \ - nonbase_ranges, \ - top_to_bottom, \ - std_charstring ) \ - FT_LOCAL_DEF( void ) \ - FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \ - { \ - ac->script = script_; \ - ac->script_uni_ranges = ranges; \ - ac->script_uni_nonbase_ranges = nonbase_ranges; \ - ac->top_to_bottom_hinting = top_to_bottom; \ - ac->standard_charstring = std_charstring; \ - } - - -#define AF_DECLARE_STYLE_CLASS( style_class ) \ - FT_LOCAL( void ) \ - FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ); - -#define AF_DEFINE_STYLE_CLASS( \ - style_class, \ - style_, \ - writing_system_, \ - script_, \ - blue_stringset_, \ - coverage_ ) \ - FT_LOCAL_DEF( void ) \ - FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ) \ - { \ - ac->style = style_; \ - ac->writing_system = writing_system_; \ - ac->script = script_; \ - ac->blue_stringset = blue_stringset_; \ - ac->coverage = coverage_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ + FT_END_HEADER #endif /* AFTYPES_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.c b/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.c index 2a75ea7b35f..84e9753ad99 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.c +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.c @@ -1,40 +1,40 @@ -/***************************************************************************/ -/* */ -/* afwarp.c */ -/* */ -/* Auto-fitter warping algorithm (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afwarp.c + * + * Auto-fitter warping algorithm (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* - * The idea of the warping code is to slightly scale and shift a glyph - * within a single dimension so that as much of its segments are aligned - * (more or less) on the grid. To find out the optimal scaling and - * shifting value, various parameter combinations are tried and scored. + * The idea of the warping code is to slightly scale and shift a glyph + * within a single dimension so that as much of its segments are aligned + * (more or less) on the grid. To find out the optimal scaling and + * shifting value, various parameter combinations are tried and scored. */ #include "afwarp.h" #ifdef AF_CONFIG_OPTION_USE_WARPER - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afwarp +#define FT_COMPONENT afwarp /* The weights cover the range 0/64 - 63/64 of a pixel. Obviously, */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.h index 520b1be907c..9a2c9a42c1b 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afwarp.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afwarp.h */ -/* */ -/* Auto-fitter warping algorithm (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afwarp.h + * + * Auto-fitter warping algorithm (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFWARP_H_ @@ -47,12 +47,14 @@ FT_BEGIN_HEADER } AF_WarperRec, *AF_Warper; +#ifdef AF_CONFIG_OPTION_USE_WARPER FT_LOCAL( void ) af_warper_compute( AF_Warper warper, AF_GlyphHints hints, AF_Dimension dim, FT_Fixed *a_scale, - FT_Fixed *a_delta ); + FT_Pos *a_delta ); +#endif FT_END_HEADER diff --git a/src/src/java.desktop/share/native/libfreetype/src/autofit/afwrtsys.h b/src/src/java.desktop/share/native/libfreetype/src/autofit/afwrtsys.h index 4675f3242d1..5611cf441a4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/autofit/afwrtsys.h +++ b/src/src/java.desktop/share/native/libfreetype/src/autofit/afwrtsys.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afwrtsys.h */ -/* */ -/* Auto-fitter writing systems (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afwrtsys.h + * + * Auto-fitter writing systems (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFWRTSYS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/basepic.c b/src/src/java.desktop/share/native/libfreetype/src/base/basepic.c deleted file mode 100644 index bc804064416..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/base/basepic.c +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************/ -/* */ -/* basepic.c */ -/* */ -/* The FreeType position independent code services for base. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "basepic.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from ftglyph.c */ - void - FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class* clazz ); - - void - FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class* clazz ); - -#ifdef FT_CONFIG_OPTION_MAC_FONTS - /* forward declaration of PIC init function from ftrfork.c */ - /* (not modularized) */ - void - FT_Init_Table_ft_raccess_guess_table( ft_raccess_guess_rec* record ); -#endif - - /* forward declaration of PIC init functions from ftinit.c */ - FT_Error - ft_create_default_module_classes( FT_Library library ); - - void - ft_destroy_default_module_classes( FT_Library library ); - - - void - ft_base_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->base ) - { - /* destroy default module classes */ - /* (in case FT_Add_Default_Modules was used) */ - ft_destroy_default_module_classes( library ); - - FT_FREE( pic_container->base ); - pic_container->base = NULL; - } - } - - - FT_Error - ft_base_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - BasePIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->base = container; - - /* initialize default modules list and pointers */ - error = ft_create_default_module_classes( library ); - if ( error ) - goto Exit; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - FT_Init_Class_ft_outline_glyph_class( - &container->ft_outline_glyph_class ); - FT_Init_Class_ft_bitmap_glyph_class( - &container->ft_bitmap_glyph_class ); -#ifdef FT_CONFIG_OPTION_MAC_FONTS - FT_Init_Table_ft_raccess_guess_table( - (ft_raccess_guess_rec*)&container->ft_raccess_guess_table ); -#endif - - Exit: - if ( error ) - ft_base_pic_free( library ); - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/basepic.h b/src/src/java.desktop/share/native/libfreetype/src/base/basepic.h deleted file mode 100644 index 492d1ede564..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/base/basepic.h +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************/ -/* */ -/* basepic.h */ -/* */ -/* The FreeType position independent code services for base. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef BASEPIC_H_ -#define BASEPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_OUTLINE_GLYPH_CLASS_GET &ft_outline_glyph_class -#define FT_BITMAP_GLYPH_CLASS_GET &ft_bitmap_glyph_class -#define FT_DEFAULT_MODULES_GET ft_default_modules - -#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK -#define FT_RACCESS_GUESS_TABLE_GET ft_raccess_guess_table -#endif - -#else /* FT_CONFIG_OPTION_PIC */ - -#include FT_GLYPH_H - -#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK -#include FT_INTERNAL_RFORK_H -#endif - - -FT_BEGIN_HEADER - - typedef struct BasePIC_ - { - FT_Module_Class** default_module_classes; - FT_Glyph_Class ft_outline_glyph_class; - FT_Glyph_Class ft_bitmap_glyph_class; - -#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK - ft_raccess_guess_rec ft_raccess_guess_table[FT_RACCESS_N_RULES]; -#endif - - } BasePIC; - - -#define GET_PIC( lib ) ( (BasePIC*)( (lib)->pic_container.base ) ) - -#define FT_OUTLINE_GLYPH_CLASS_GET \ - ( &GET_PIC( library )->ft_outline_glyph_class ) -#define FT_BITMAP_GLYPH_CLASS_GET \ - ( &GET_PIC( library )->ft_bitmap_glyph_class ) -#define FT_DEFAULT_MODULES_GET \ - ( GET_PIC( library )->default_module_classes ) - -#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK -#define FT_RACCESS_GUESS_TABLE_GET \ - ( GET_PIC( library )->ft_raccess_guess_table ) -#endif - - - /* see basepic.c for the implementation */ - void - ft_base_pic_free( FT_Library library ); - - FT_Error - ft_base_pic_init( FT_Library library ); - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* BASEPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c index 230c84d6ad4..0dfba57036e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftadvanc.c */ -/* */ -/* Quick computation of advance widths (body). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftadvanc.c + * + * Quick computation of advance widths (body). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftapi.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftapi.c deleted file mode 100644 index 32d6e95d199..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftapi.c +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftapi.c */ -/* */ -/* The FreeType compatibility functions (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_LIST_H -#include FT_OUTLINE_H -#include FT_INTERNAL_OBJECTS_H -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_STREAM_H -#include FT_TRUETYPE_TABLES_H -#include FT_OUTLINE_H - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** C O M P A T I B I L I T Y ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* backward compatibility API */ - - FT_BASE_DEF( void ) - FT_New_Memory_Stream( FT_Library library, - FT_Byte* base, - FT_ULong size, - FT_Stream stream ) - { - FT_UNUSED( library ); - - FT_Stream_OpenMemory( stream, base, size ); - } - - - FT_BASE_DEF( FT_Error ) - FT_Seek_Stream( FT_Stream stream, - FT_ULong pos ) - { - return FT_Stream_Seek( stream, pos ); - } - - - FT_BASE_DEF( FT_Error ) - FT_Skip_Stream( FT_Stream stream, - FT_Long distance ) - { - return FT_Stream_Skip( stream, distance ); - } - - - FT_BASE_DEF( FT_Error ) - FT_Read_Stream( FT_Stream stream, - FT_Byte* buffer, - FT_ULong count ) - { - return FT_Stream_Read( stream, buffer, count ); - } - - - FT_BASE_DEF( FT_Error ) - FT_Read_Stream_At( FT_Stream stream, - FT_ULong pos, - FT_Byte* buffer, - FT_ULong count ) - { - return FT_Stream_ReadAt( stream, pos, buffer, count ); - } - - - FT_BASE_DEF( FT_Error ) - FT_Extract_Frame( FT_Stream stream, - FT_ULong count, - FT_Byte** pbytes ) - { - return FT_Stream_ExtractFrame( stream, count, pbytes ); - } - - - FT_BASE_DEF( void ) - FT_Release_Frame( FT_Stream stream, - FT_Byte** pbytes ) - { - FT_Stream_ReleaseFrame( stream, pbytes ); - } - - FT_BASE_DEF( FT_Error ) - FT_Access_Frame( FT_Stream stream, - FT_ULong count ) - { - return FT_Stream_EnterFrame( stream, count ); - } - - - FT_BASE_DEF( void ) - FT_Forget_Frame( FT_Stream stream ) - { - FT_Stream_ExitFrame( stream ); - } - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftbase.h b/src/src/java.desktop/share/native/libfreetype/src/base/ftbase.h index 7e8cfad9590..35b1c47fd9c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftbase.h +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftbase.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbase.h */ -/* */ -/* Private functions used in the `base' module (specification). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbase.h + * + * Private functions used in the `base' module (specification). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBASE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c index 151e85c97a5..0b04fde6359 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftbbox.c @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftbbox.c */ -/* */ -/* FreeType bbox computation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftbbox.c + * + * FreeType bbox computation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component has a _single_ role: to compute exact outline bounding + * boxes. + * + */ #include <ft2build.h> @@ -61,26 +61,28 @@ ( p->y < bbox.yMin || p->y > bbox.yMax ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Move_To */ - /* */ - /* <Description> */ - /* This function is used as a `move_to' emitter during */ - /* FT_Outline_Decompose(). It simply records the destination point */ - /* in `user->last'. We also update bbox in case contour starts with */ - /* an implicit `on' point. */ - /* */ - /* <Input> */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: A pointer to the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Move_To + * + * @Description: + * This function is used as a `move_to' emitter during + * FT_Outline_Decompose(). It simply records the destination point + * in `user->last'. We also update bbox in case contour starts with + * an implicit `on' point. + * + * @Input: + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * A pointer to the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + */ static int BBox_Move_To( FT_Vector* to, TBBox_Rec* user ) @@ -93,26 +95,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Line_To */ - /* */ - /* <Description> */ - /* This function is used as a `line_to' emitter during */ - /* FT_Outline_Decompose(). It simply records the destination point */ - /* in `user->last'; no further computations are necessary because */ - /* bbox already contains both explicit ends of the line segment. */ - /* */ - /* <Input> */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: A pointer to the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Line_To + * + * @Description: + * This function is used as a `line_to' emitter during + * FT_Outline_Decompose(). It simply records the destination point + * in `user->last'; no further computations are necessary because + * bbox already contains both explicit ends of the line segment. + * + * @Input: + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * A pointer to the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + */ static int BBox_Line_To( FT_Vector* to, TBBox_Rec* user ) @@ -123,28 +127,33 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Conic_Check */ - /* */ - /* <Description> */ - /* Find the extrema of a 1-dimensional conic Bezier curve and update */ - /* a bounding range. This version uses direct computation, as it */ - /* doesn't need square roots. */ - /* */ - /* <Input> */ - /* y1 :: The start coordinate. */ - /* */ - /* y2 :: The coordinate of the control point. */ - /* */ - /* y3 :: The end coordinate. */ - /* */ - /* <InOut> */ - /* min :: The address of the current minimum. */ - /* */ - /* max :: The address of the current maximum. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Conic_Check + * + * @Description: + * Find the extrema of a 1-dimensional conic Bezier curve and update + * a bounding range. This version uses direct computation, as it + * doesn't need square roots. + * + * @Input: + * y1 :: + * The start coordinate. + * + * y2 :: + * The coordinate of the control point. + * + * y3 :: + * The end coordinate. + * + * @InOut: + * min :: + * The address of the current minimum. + * + * max :: + * The address of the current maximum. + */ static void BBox_Conic_Check( FT_Pos y1, FT_Pos y2, @@ -168,32 +177,35 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Conic_To */ - /* */ - /* <Description> */ - /* This function is used as a `conic_to' emitter during */ - /* FT_Outline_Decompose(). It checks a conic Bezier curve with the */ - /* current bounding box, and computes its extrema if necessary to */ - /* update it. */ - /* */ - /* <Input> */ - /* control :: A pointer to a control point. */ - /* */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: The address of the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ - /* <Note> */ - /* In the case of a non-monotonous arc, we compute directly the */ - /* extremum coordinates, as it is sufficiently fast. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Conic_To + * + * @Description: + * This function is used as a `conic_to' emitter during + * FT_Outline_Decompose(). It checks a conic Bezier curve with the + * current bounding box, and computes its extrema if necessary to + * update it. + * + * @Input: + * control :: + * A pointer to a control point. + * + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * The address of the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + * + * @Note: + * In the case of a non-monotonous arc, we compute directly the + * extremum coordinates, as it is sufficiently fast. + */ static int BBox_Conic_To( FT_Vector* control, FT_Vector* to, @@ -222,30 +234,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Cubic_Check */ - /* */ - /* <Description> */ - /* Find the extrema of a 1-dimensional cubic Bezier curve and */ - /* update a bounding range. This version uses iterative splitting */ - /* because it is faster than the exact solution with square roots. */ - /* */ - /* <Input> */ - /* p1 :: The start coordinate. */ - /* */ - /* p2 :: The coordinate of the first control point. */ - /* */ - /* p3 :: The coordinate of the second control point. */ - /* */ - /* p4 :: The end coordinate. */ - /* */ - /* <InOut> */ - /* min :: The address of the current minimum. */ - /* */ - /* max :: The address of the current maximum. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Cubic_Check + * + * @Description: + * Find the extrema of a 1-dimensional cubic Bezier curve and + * update a bounding range. This version uses iterative splitting + * because it is faster than the exact solution with square roots. + * + * @Input: + * p1 :: + * The start coordinate. + * + * p2 :: + * The coordinate of the first control point. + * + * p3 :: + * The coordinate of the second control point. + * + * p4 :: + * The end coordinate. + * + * @InOut: + * min :: + * The address of the current minimum. + * + * max :: + * The address of the current maximum. + */ static FT_Pos cubic_peak( FT_Pos q1, FT_Pos q2, @@ -361,34 +379,38 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Cubic_To */ - /* */ - /* <Description> */ - /* This function is used as a `cubic_to' emitter during */ - /* FT_Outline_Decompose(). It checks a cubic Bezier curve with the */ - /* current bounding box, and computes its extrema if necessary to */ - /* update it. */ - /* */ - /* <Input> */ - /* control1 :: A pointer to the first control point. */ - /* */ - /* control2 :: A pointer to the second control point. */ - /* */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: The address of the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ - /* <Note> */ - /* In the case of a non-monotonous arc, we don't compute directly */ - /* extremum coordinates, we subdivide instead. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Cubic_To + * + * @Description: + * This function is used as a `cubic_to' emitter during + * FT_Outline_Decompose(). It checks a cubic Bezier curve with the + * current bounding box, and computes its extrema if necessary to + * update it. + * + * @Input: + * control1 :: + * A pointer to the first control point. + * + * control2 :: + * A pointer to the second control point. + * + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * The address of the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + * + * @Note: + * In the case of a non-monotonous arc, we don't compute directly + * extremum coordinates, we subdivide instead. + */ static int BBox_Cubic_To( FT_Vector* control1, FT_Vector* control2, @@ -490,12 +512,6 @@ FT_Error error; TBBox_Rec user; -#ifdef FT_CONFIG_OPTION_PIC - FT_Outline_Funcs bbox_interface; - - - Init_Class_bbox_interface( &bbox_interface ); -#endif user.bbox = bbox; diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c index a9746663faa..1bdcd9eff3e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbitmap.c */ -/* */ -/* FreeType utility functions for bitmaps (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbitmap.c + * + * FreeType utility functions for bitmaps (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,8 +24,18 @@ #include FT_INTERNAL_OBJECTS_H + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT bitmap + + static - const FT_Bitmap null_bitmap = { 0, 0, 0, 0, 0, 0, 0, 0 }; + const FT_Bitmap null_bitmap = { 0, 0, 0, NULL, 0, 0, 0, NULL }; /* documentation is in ftbitmap.h */ @@ -783,6 +793,331 @@ } + /* documentation is in ftbitmap.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Bitmap_Blend( FT_Library library, + const FT_Bitmap* source_, + const FT_Vector source_offset_, + FT_Bitmap* target, + FT_Vector *atarget_offset, + FT_Color color ) + { + FT_Error error = FT_Err_Ok; + FT_Memory memory; + + FT_Bitmap source_bitmap; + const FT_Bitmap* source; + + FT_Vector source_offset; + FT_Vector target_offset; + + FT_Bool free_source_bitmap = 0; + FT_Bool free_target_bitmap_on_error = 0; + + FT_Pos source_llx, source_lly, source_urx, source_ury; + FT_Pos target_llx, target_lly, target_urx, target_ury; + FT_Pos final_llx, final_lly, final_urx, final_ury; + + unsigned int final_rows, final_width; + long x, y; + + + if ( !library || !target || !source_ || !atarget_offset ) + return FT_THROW( Invalid_Argument ); + + memory = library->memory; + + if ( !( target->pixel_mode == FT_PIXEL_MODE_NONE || + ( target->pixel_mode == FT_PIXEL_MODE_BGRA && + target->buffer ) ) ) + return FT_THROW( Invalid_Argument ); + + if ( source_->pixel_mode == FT_PIXEL_MODE_NONE ) + return FT_Err_Ok; /* nothing to do */ + + /* pitches must have the same sign */ + if ( target->pixel_mode == FT_PIXEL_MODE_BGRA && + ( source_->pitch ^ target->pitch ) < 0 ) + return FT_THROW( Invalid_Argument ); + + if ( !( source_->width && source_->rows ) ) + return FT_Err_Ok; /* nothing to do */ + + /* assure integer pixel offsets */ + source_offset.x = FT_PIX_FLOOR( source_offset_.x ); + source_offset.y = FT_PIX_FLOOR( source_offset_.y ); + target_offset.x = FT_PIX_FLOOR( atarget_offset->x ); + target_offset.y = FT_PIX_FLOOR( atarget_offset->y ); + + /* get source bitmap dimensions */ + source_llx = source_offset.x; + if ( FT_LONG_MIN + (FT_Pos)( source_->rows << 6 ) + 64 > source_offset.y ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: y coordinate overflow in source bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + source_lly = source_offset.y - ( source_->rows << 6 ); + + if ( FT_LONG_MAX - (FT_Pos)( source_->width << 6 ) - 64 < source_llx ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: x coordinate overflow in source bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + source_urx = source_llx + ( source_->width << 6 ); + source_ury = source_offset.y; + + /* get target bitmap dimensions */ + if ( target->width && target->rows ) + { + target_llx = target_offset.x; + if ( FT_LONG_MIN + (FT_Pos)( target->rows << 6 ) > target_offset.y ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: y coordinate overflow in target bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + target_lly = target_offset.y - ( target->rows << 6 ); + + if ( FT_LONG_MAX - (FT_Pos)( target->width << 6 ) < target_llx ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: x coordinate overflow in target bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + target_urx = target_llx + ( target->width << 6 ); + target_ury = target_offset.y; + } + else + { + target_llx = FT_LONG_MAX; + target_lly = FT_LONG_MAX; + target_urx = FT_LONG_MIN; + target_ury = FT_LONG_MIN; + } + + /* compute final bitmap dimensions */ + final_llx = FT_MIN( source_llx, target_llx ); + final_lly = FT_MIN( source_lly, target_lly ); + final_urx = FT_MAX( source_urx, target_urx ); + final_ury = FT_MAX( source_ury, target_ury ); + + final_width = ( final_urx - final_llx ) >> 6; + final_rows = ( final_ury - final_lly ) >> 6; + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE5(( "FT_Bitmap_Blend:\n" + " source bitmap: (%d, %d) -- (%d, %d); %d x %d\n", + source_llx / 64, source_lly / 64, + source_urx / 64, source_ury / 64, + source_->width, source_->rows )); + + if ( target->width && target->rows ) + FT_TRACE5(( " target bitmap: (%d, %d) -- (%d, %d); %d x %d\n", + target_llx / 64, target_lly / 64, + target_urx / 64, target_ury / 64, + target->width, target->rows )); + else + FT_TRACE5(( " target bitmap: empty\n" )); + + FT_TRACE5(( " final bitmap: (%d, %d) -- (%d, %d); %d x %d\n", + final_llx / 64, final_lly / 64, + final_urx / 64, final_ury / 64, + final_width, final_rows )); +#endif /* FT_DEBUG_LEVEL_TRACE */ + + /* for blending, set offset vector of final bitmap */ + /* temporarily to (0,0) */ + source_llx -= final_llx; + source_lly -= final_lly; + + if ( target->width && target->rows ) + { + target_llx -= final_llx; + target_lly -= final_lly; + } + + /* set up target bitmap */ + if ( target->pixel_mode == FT_PIXEL_MODE_NONE ) + { + /* create new empty bitmap */ + target->width = final_width; + target->rows = final_rows; + target->pixel_mode = FT_PIXEL_MODE_BGRA; + target->pitch = (int)final_width * 4; + target->num_grays = 256; + + if ( FT_LONG_MAX / target->pitch < (int)target->rows ) + { + FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n", + final_width, final_rows )); + return FT_THROW( Invalid_Argument ); + } + + if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) ) + return error; + + free_target_bitmap_on_error = 1; + } + else if ( target->width != final_width || + target->rows != final_rows ) + { + /* adjust old bitmap to enlarged size */ + int pitch, new_pitch; + + unsigned char* buffer = NULL; + + + pitch = target->pitch; + if ( pitch < 0 ) + pitch = -pitch; + + new_pitch = (int)final_width * 4; + + if ( FT_LONG_MAX / new_pitch < (int)final_rows ) + { + FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n", + final_width, final_rows )); + return FT_THROW( Invalid_Argument ); + } + + /* TODO: provide an in-buffer solution for large bitmaps */ + /* to avoid allocation of a new buffer */ + if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) ) + goto Error; + + /* copy data to new buffer */ + x = target_llx >> 6; + y = target_lly >> 6; + + /* the bitmap flow is from top to bottom, */ + /* but y is measured from bottom to top */ + if ( target->pitch < 0 ) + { + /* XXX */ + } + else + { + unsigned char* p = + target->buffer; + unsigned char* q = + buffer + + ( final_rows - y - target->rows ) * new_pitch + + x * 4; + unsigned char* limit_p = + p + pitch * (int)target->rows; + + + while ( p < limit_p ) + { + FT_MEM_COPY( q, p, pitch ); + + p += pitch; + q += new_pitch; + } + } + + FT_FREE( target->buffer ); + + target->width = final_width; + target->rows = final_rows; + + if ( target->pitch < 0 ) + target->pitch = -new_pitch; + else + target->pitch = new_pitch; + + target->buffer = buffer; + } + + /* adjust source bitmap if necessary */ + if ( source_->pixel_mode != FT_PIXEL_MODE_GRAY ) + { + FT_Bitmap_Init( &source_bitmap ); + error = FT_Bitmap_Convert( library, source_, &source_bitmap, 1 ); + if ( error ) + goto Error; + + source = &source_bitmap; + free_source_bitmap = 1; + } + else + source = source_; + + /* do blending; the code below returns pre-multiplied channels, */ + /* similar to what FreeType gets from `CBDT' tables */ + x = source_llx >> 6; + y = source_lly >> 6; + + /* the bitmap flow is from top to bottom, */ + /* but y is measured from bottom to top */ + if ( target->pitch < 0 ) + { + /* XXX */ + } + else + { + unsigned char* p = + source->buffer; + unsigned char* q = + target->buffer + + ( target->rows - y - source->rows ) * target->pitch + + x * 4; + unsigned char* limit_p = + p + source->pitch * (int)source->rows; + + + while ( p < limit_p ) + { + unsigned char* r = p; + unsigned char* s = q; + unsigned char* limit_r = r + source->width; + + + while ( r < limit_r ) + { + int aa = *r++; + int fa = color.alpha * aa / 255; + + int fb = color.blue * fa / 255; + int fg = color.green * fa / 255; + int fr = color.red * fa / 255; + + int ba2 = 255 - fa; + + int bb = s[0]; + int bg = s[1]; + int br = s[2]; + int ba = s[3]; + + + *s++ = (unsigned char)( bb * ba2 / 255 + fb ); + *s++ = (unsigned char)( bg * ba2 / 255 + fg ); + *s++ = (unsigned char)( br * ba2 / 255 + fr ); + *s++ = (unsigned char)( ba * ba2 / 255 + fa ); + } + + p += source->pitch; + q += target->pitch; + } + } + + atarget_offset->x = final_llx; + atarget_offset->y = final_lly + ( final_rows << 6 ); + + Error: + if ( error && free_target_bitmap_on_error ) + FT_Bitmap_Done( library, target ); + + if ( free_source_bitmap ) + FT_Bitmap_Done( library, &source_bitmap ); + + return error; + } + + /* documentation is in ftbitmap.h */ FT_EXPORT_DEF( FT_Error ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c index f4ff45f8ef1..315dc441856 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftcalc.c @@ -1,35 +1,35 @@ -/***************************************************************************/ -/* */ -/* ftcalc.c */ -/* */ -/* Arithmetic computations (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Support for 1-complement arithmetic has been totally dropped in this */ - /* release. You can still write your own code if you need it. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* Implementing basic computation routines. */ - /* */ - /* FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), */ - /* and FT_FloorFix() are declared in freetype.h. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftcalc.c + * + * Arithmetic computations (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Support for 1-complement arithmetic has been totally dropped in this + * release. You can still write your own code if you need it. + * + */ + + /************************************************************************** + * + * Implementing basic computation routines. + * + * FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), + * and FT_FloorFix() are declared in freetype.h. + * + */ #include <ft2build.h> @@ -58,14 +58,14 @@ #endif /* !FT_LONG64 */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_calc +#define FT_COMPONENT calc /* transfer sign, leaving a positive number; */ @@ -516,10 +516,10 @@ #elif 0 /* - * This code is nonportable. See comment below. + * This code is nonportable. See comment below. * - * However, on a platform where right-shift of a signed quantity fills - * the leftmost bits by copying the sign bit, it might be faster. + * However, on a platform where right-shift of a signed quantity fills + * the leftmost bits by copying the sign bit, it might be faster. */ FT_Long sa, sb; @@ -527,22 +527,22 @@ /* - * This is a clever way of converting a signed number `a' into its - * absolute value (stored back into `a') and its sign. The sign is - * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a' - * was negative. (Similarly for `b' and `sb'). + * This is a clever way of converting a signed number `a' into its + * absolute value (stored back into `a') and its sign. The sign is + * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a' + * was negative. (Similarly for `b' and `sb'). * - * Unfortunately, it doesn't work (at least not portably). + * Unfortunately, it doesn't work (at least not portably). * - * It makes the assumption that right-shift on a negative signed value - * fills the leftmost bits by copying the sign bit. This is wrong. - * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, - * the result of right-shift of a negative signed value is - * implementation-defined. At least one implementation fills the - * leftmost bits with 0s (i.e., it is exactly the same as an unsigned - * right shift). This means that when `a' is negative, `sa' ends up - * with the value 1 rather than -1. After that, everything else goes - * wrong. + * It makes the assumption that right-shift on a negative signed value + * fills the leftmost bits by copying the sign bit. This is wrong. + * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, + * the result of right-shift of a negative signed value is + * implementation-defined. At least one implementation fills the + * leftmost bits with 0s (i.e., it is exactly the same as an unsigned + * right shift). This means that when `a' is negative, `sa' ends up + * with the value 1 rather than -1. After that, everything else goes + * wrong. */ sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) ); a = ( a_ ^ sa ) - sa; @@ -701,8 +701,8 @@ if ( !delta ) return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */ - matrix->xy = - FT_DivFix( matrix->xy, delta ); - matrix->yx = - FT_DivFix( matrix->yx, delta ); + matrix->xy = -FT_DivFix( matrix->xy, delta ); + matrix->yx = -FT_DivFix( matrix->yx, delta ); xx = matrix->xx; yy = matrix->yy; @@ -745,6 +745,76 @@ } + /* documentation is in ftcalc.h */ + + FT_BASE_DEF( FT_Bool ) + FT_Matrix_Check( const FT_Matrix* matrix ) + { + FT_Matrix m; + FT_Fixed val[4]; + FT_Fixed nonzero_minval, maxval; + FT_Fixed temp1, temp2; + FT_UInt i; + + + if ( !matrix ) + return 0; + + val[0] = FT_ABS( matrix->xx ); + val[1] = FT_ABS( matrix->xy ); + val[2] = FT_ABS( matrix->yx ); + val[3] = FT_ABS( matrix->yy ); + + /* + * To avoid overflow, we ensure that each value is not larger than + * + * int(sqrt(2^31 / 4)) = 23170 ; + * + * we also check that no value becomes zero if we have to scale. + */ + + maxval = 0; + nonzero_minval = FT_LONG_MAX; + + for ( i = 0; i < 4; i++ ) + { + if ( val[i] > maxval ) + maxval = val[i]; + if ( val[i] && val[i] < nonzero_minval ) + nonzero_minval = val[i]; + } + + /* we only handle 32bit values */ + if ( maxval > 0x7FFFFFFFL ) + return 0; + + if ( maxval > 23170 ) + { + FT_Fixed scale = FT_DivFix( maxval, 23170 ); + + + if ( !FT_DivFix( nonzero_minval, scale ) ) + return 0; /* value range too large */ + + m.xx = FT_DivFix( matrix->xx, scale ); + m.xy = FT_DivFix( matrix->xy, scale ); + m.yx = FT_DivFix( matrix->yx, scale ); + m.yy = FT_DivFix( matrix->yy, scale ); + } + else + m = *matrix; + + temp1 = FT_ABS( m.xx * m.yy - m.xy * m.yx ); + temp2 = m.xx * m.xx + m.xy * m.xy + m.yx * m.yx + m.yy * m.yy; + + if ( temp1 == 0 || + temp2 / temp1 > 50 ) + return 0; + + return 1; + } + + /* documentation is in ftcalc.h */ FT_BASE_DEF( void ) @@ -913,9 +983,13 @@ FT_Pos out_x, FT_Pos out_y ) { + /* we silently ignore overflow errors since such large values */ + /* lead to even more (harmless) rendering errors later on */ + #ifdef FT_LONG64 - FT_Int64 delta = (FT_Int64)in_x * out_y - (FT_Int64)in_y * out_x; + FT_Int64 delta = SUB_INT64( MUL_INT64( in_x, out_y ), + MUL_INT64( in_y, out_x ) ); return ( delta > 0 ) - ( delta < 0 ); @@ -925,8 +999,6 @@ FT_Int result; - /* we silently ignore overflow errors, since such large values */ - /* lead to even more (harmless) rendering errors later on */ if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L && ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftcid.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftcid.c index f5184649bfb..190b23f3571 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftcid.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftcid.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcid.c */ -/* */ -/* FreeType API for accessing CID font information. */ -/* */ -/* Copyright 2007-2018 by */ -/* Derek Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcid.c + * + * FreeType API for accessing CID font information. + * + * Copyright (C) 2007-2019 by + * Derek Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c index c33d8acb4e1..55cd269e1fe 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftdbgmem.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftdbgmem.c */ -/* */ -/* Memory debugger (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdbgmem.c + * + * Memory debugger (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -50,9 +50,9 @@ #define FT_MEM_VAL( addr ) ( (FT_PtrDist)(FT_Pointer)( addr ) ) /* - * This structure holds statistics for a single allocation/release - * site. This is useful to know where memory operations happen the - * most. + * This structure holds statistics for a single allocation/release + * site. This is useful to know where memory operations happen the + * most. */ typedef struct FT_MemSourceRec_ { @@ -76,17 +76,17 @@ /* - * We don't need a resizable array for the memory sources because - * their number is pretty limited within FreeType. + * We don't need a resizable array for the memory sources because + * their number is pretty limited within FreeType. */ #define FT_MEM_SOURCE_BUCKETS 128 /* - * This structure holds information related to a single allocated - * memory block. If KEEPALIVE is defined, blocks that are freed by - * FreeType are never released to the system. Instead, their `size' - * field is set to `-size'. This is mainly useful to detect double - * frees, at the price of a large memory footprint during execution. + * This structure holds information related to a single allocated + * memory block. If KEEPALIVE is defined, blocks that are freed by + * FreeType are never released to the system. Instead, their `size' + * field is set to `-size'. This is mainly useful to detect double + * frees, at the price of a large memory footprint during execution. */ typedef struct FT_MemNodeRec_ { @@ -106,8 +106,8 @@ /* - * The global structure, containing compound statistics and all hash - * tables. + * The global structure, containing compound statistics and all hash + * tables. */ typedef struct FT_MemTableRec_ { @@ -146,8 +146,8 @@ /* - * Prime numbers are ugly to handle. It would be better to implement - * L-Hashing, which is 10% faster and doesn't require divisions. + * Prime numbers are ugly to handle. It would be better to implement + * L-Hashing, which is 10% faster and doesn't require divisions. */ static const FT_Int ft_mem_primes[] = { diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c index fe263091014..ec723378730 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftdebug.c @@ -1,44 +1,44 @@ -/***************************************************************************/ -/* */ -/* ftdebug.c */ -/* */ -/* Debugging and logging component (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component contains various macros and functions used to ease the */ - /* debugging of the FreeType engine. Its main purpose is in assertion */ - /* checking, tracing, and error detection. */ - /* */ - /* There are now three debugging modes: */ - /* */ - /* - trace mode */ - /* */ - /* Error and trace messages are sent to the log file (which can be the */ - /* standard error output). */ - /* */ - /* - error mode */ - /* */ - /* Only error messages are generated. */ - /* */ - /* - release mode: */ - /* */ - /* No error message is sent or generated. The code is free from any */ - /* debugging parts. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftdebug.c + * + * Debugging and logging component (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component contains various macros and functions used to ease the + * debugging of the FreeType engine. Its main purpose is in assertion + * checking, tracing, and error detection. + * + * There are now three debugging modes: + * + * - trace mode + * + * Error and trace messages are sent to the log file (which can be the + * standard error output). + * + * - error mode + * + * Only error messages are generated. + * + * - release mode: + * + * No error message is sent or generated. The code is free from any + * debugging parts. + * + */ #include <ft2build.h> @@ -87,9 +87,19 @@ int line, const char* file ) { +#if 0 + /* activating the code in this block makes FreeType very chatty */ + fprintf( stderr, + "%s:%d: error 0x%02x: %s\n", + file, + line, + error, + FT_Error_String( error ) ); +#else FT_UNUSED( error ); FT_UNUSED( line ); FT_UNUSED( file ); +#endif return 0; } @@ -100,9 +110,16 @@ #ifdef FT_DEBUG_LEVEL_TRACE - /* array of trace levels, initialized to 0 */ - int ft_trace_levels[trace_count]; + /* array of trace levels, initialized to 0; */ + /* this gets adjusted at run-time */ + static int ft_trace_levels_enabled[trace_count]; + /* array of trace levels, always initialized to 0 */ + static int ft_trace_levels_disabled[trace_count]; + + /* a pointer to either `ft_trace_levels_enabled' */ + /* or `ft_trace_levels_disabled' */ + int* ft_trace_levels; /* define array of trace toggle names */ #define FT_TRACE_DEF( x ) #x , @@ -140,24 +157,42 @@ } - /*************************************************************************/ - /* */ - /* Initialize the tracing sub-system. This is done by retrieving the */ - /* value of the `FT2_DEBUG' environment variable. It must be a list of */ - /* toggles, separated by spaces, `;', or `,'. Example: */ - /* */ - /* export FT2_DEBUG="any:3 memory:7 stream:5" */ - /* */ - /* This requests that all levels be set to 3, except the trace level for */ - /* the memory and stream components which are set to 7 and 5, */ - /* respectively. */ - /* */ - /* See the file `include/freetype/internal/fttrace.h' for details of */ - /* the available toggle names. */ - /* */ - /* The level must be between 0 and 7; 0 means quiet (except for serious */ - /* runtime errors), and 7 means _very_ verbose. */ - /* */ + /* documentation is in ftdebug.h */ + + FT_BASE_DEF( void ) + FT_Trace_Disable( void ) + { + ft_trace_levels = ft_trace_levels_disabled; + } + + + /* documentation is in ftdebug.h */ + + FT_BASE_DEF( void ) + FT_Trace_Enable( void ) + { + ft_trace_levels = ft_trace_levels_enabled; + } + + + /************************************************************************** + * + * Initialize the tracing sub-system. This is done by retrieving the + * value of the `FT2_DEBUG' environment variable. It must be a list of + * toggles, separated by spaces, `;', or `,'. Example: + * + * export FT2_DEBUG="any:3 memory:7 stream:5" + * + * This requests that all levels be set to 3, except the trace level for + * the memory and stream components which are set to 7 and 5, + * respectively. + * + * See the file `include/freetype/internal/fttrace.h' for details of + * the available toggle names. + * + * The level must be between 0 and 7; 0 means quiet (except for serious + * runtime errors), and 7 means _very_ verbose. + */ FT_BASE_DEF( void ) ft_debug_init( void ) { @@ -223,14 +258,16 @@ { /* special case for `any' */ for ( n = 0; n < trace_count; n++ ) - ft_trace_levels[n] = level; + ft_trace_levels_enabled[n] = level; } else - ft_trace_levels[found] = level; + ft_trace_levels_enabled[found] = level; } } } } + + ft_trace_levels = ft_trace_levels_enabled; } @@ -260,6 +297,22 @@ } + FT_BASE_DEF( void ) + FT_Trace_Disable( void ) + { + /* nothing */ + } + + + /* documentation is in ftdebug.h */ + + FT_BASE_DEF( void ) + FT_Trace_Enable( void ) + { + /* nothing */ + } + + #endif /* !FT_DEBUG_LEVEL_TRACE */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c index a2900ceb098..54ba5374164 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftfntfmt.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftfntfmt.c */ -/* */ -/* FreeType utility file for font formats (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftfntfmt.c + * + * FreeType utility file for font formats (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c index e6cdf6e2ec6..45e2d8089bf 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftfstype.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftfstype.c */ -/* */ -/* FreeType utility file to access FSType data (body). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftfstype.c + * + * FreeType utility file to access FSType data (body). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_TYPE1_TABLES_H diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c index 4f80bba630c..720fb113ca3 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftgasp.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgasp.c */ -/* */ -/* Access of TrueType's `gasp' table (body). */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgasp.c + * + * Access of TrueType's `gasp' table (body). + * + * Copyright (C) 2007-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c index 47202496b9c..bfeed461a83 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftgloadr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgloadr.c */ -/* */ -/* The FreeType glyph loader (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgloadr.c + * + * The FreeType glyph loader (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -23,7 +23,7 @@ #include FT_INTERNAL_OBJECTS_H #undef FT_COMPONENT -#define FT_COMPONENT trace_gloader +#define FT_COMPONENT gloader /*************************************************************************/ @@ -38,31 +38,31 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* The glyph loader is a simple object which is used to load a set of */ - /* glyphs easily. It is critical for the correct loading of composites. */ - /* */ - /* Ideally, one can see it as a stack of abstract `glyph' objects. */ - /* */ - /* loader.base Is really the bottom of the stack. It describes a */ - /* single glyph image made of the juxtaposition of */ - /* several glyphs (those `in the stack'). */ - /* */ - /* loader.current Describes the top of the stack, on which a new */ - /* glyph can be loaded. */ - /* */ - /* Rewind Clears the stack. */ - /* Prepare Set up `loader.current' for addition of a new glyph */ - /* image. */ - /* Add Add the `current' glyph image to the `base' one, */ - /* and prepare for another one. */ - /* */ - /* The glyph loader is now a base object. Each driver used to */ - /* re-implement it in one way or the other, which wasted code and */ - /* energy. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * The glyph loader is a simple object which is used to load a set of + * glyphs easily. It is critical for the correct loading of composites. + * + * Ideally, one can see it as a stack of abstract `glyph' objects. + * + * loader.base Is really the bottom of the stack. It describes a + * single glyph image made of the juxtaposition of + * several glyphs (those `in the stack'). + * + * loader.current Describes the top of the stack, on which a new + * glyph can be loaded. + * + * Rewind Clears the stack. + * Prepare Set up `loader.current' for addition of a new glyph + * image. + * Add Add the `current' glyph image to the `base' one, + * and prepare for another one. + * + * The glyph loader is now a base object. Each driver used to + * re-implement it in one way or the other, which wasted code and + * energy. + * + */ /* create a new glyph loader */ @@ -99,12 +99,12 @@ } - /* reset the glyph loader, frees all allocated tables */ - /* and starts from zero */ + /* reset glyph loader, free all allocated tables, */ + /* and start from zero */ FT_BASE_DEF( void ) FT_GlyphLoader_Reset( FT_GlyphLoader loader ) { - FT_Memory memory = loader->memory; + FT_Memory memory = loader->memory; FT_FREE( loader->base.outline.points ); @@ -129,7 +129,7 @@ { if ( loader ) { - FT_Memory memory = loader->memory; + FT_Memory memory = loader->memory; FT_GlyphLoader_Reset( loader ); @@ -361,46 +361,4 @@ } - FT_BASE_DEF( FT_Error ) - FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, - FT_GlyphLoader source ) - { - FT_Error error; - FT_UInt num_points = (FT_UInt)source->base.outline.n_points; - FT_UInt num_contours = (FT_UInt)source->base.outline.n_contours; - - - error = FT_GlyphLoader_CheckPoints( target, num_points, num_contours ); - if ( !error ) - { - FT_Outline* out = &target->base.outline; - FT_Outline* in = &source->base.outline; - - - FT_ARRAY_COPY( out->points, in->points, - num_points ); - FT_ARRAY_COPY( out->tags, in->tags, - num_points ); - FT_ARRAY_COPY( out->contours, in->contours, - num_contours ); - - /* do we need to copy the extra points? */ - if ( target->use_extra && source->use_extra ) - { - FT_ARRAY_COPY( target->base.extra_points, source->base.extra_points, - num_points ); - FT_ARRAY_COPY( target->base.extra_points2, source->base.extra_points2, - num_points ); - } - - out->n_points = (short)num_points; - out->n_contours = (short)num_contours; - - FT_GlyphLoader_Adjust_Points( target ); - } - - return error; - } - - /* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c index 6759aa25d0e..e6b13279015 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* ftglyph.c */ -/* */ -/* FreeType convenience functions to handle glyphs (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftglyph.c + * + * FreeType convenience functions to handle glyphs (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file contains the definition of several convenience functions + * that can be used by client applications to easily retrieve glyph + * bitmaps and outlines from a given face. + * + * These functions should be optional if you are writing a font server + * or text layout engine on top of FreeType. However, they are pretty + * handy for many other simple uses of the library. + * + */ #include <ft2build.h> @@ -36,16 +36,15 @@ #include FT_BITMAP_H #include FT_INTERNAL_OBJECTS_H -#include "basepic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_glyph +#define FT_COMPONENT glyph /*************************************************************************/ @@ -77,7 +76,7 @@ /* do lazy copying whenever possible */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { - glyph->bitmap = slot->bitmap; + glyph->bitmap = slot->bitmap; slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } else @@ -359,37 +358,28 @@ /* documentation is in ftglyph.h */ - FT_EXPORT_DEF( FT_Error ) - FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph *aglyph ) + FT_EXPORT( FT_Error ) + FT_New_Glyph( FT_Library library, + FT_Glyph_Format format, + FT_Glyph *aglyph ) { - FT_Library library; - FT_Error error; - FT_Glyph glyph; - const FT_Glyph_Class* clazz = NULL; - - if ( !slot ) - return FT_THROW( Invalid_Slot_Handle ); - - library = slot->library; - - if ( !aglyph ) + if ( !library || !aglyph ) return FT_THROW( Invalid_Argument ); /* if it is a bitmap, that's easy :-) */ - if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) - clazz = FT_BITMAP_GLYPH_CLASS_GET; + if ( format == FT_GLYPH_FORMAT_BITMAP ) + clazz = &ft_bitmap_glyph_class; /* if it is an outline */ - else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) - clazz = FT_OUTLINE_GLYPH_CLASS_GET; + else if ( format == FT_GLYPH_FORMAT_OUTLINE ) + clazz = &ft_outline_glyph_class; else { /* try to find a renderer that supports the glyph image format */ - FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 ); + FT_Renderer render = FT_Lookup_Renderer( library, format, 0 ); if ( render ) @@ -397,13 +387,31 @@ } if ( !clazz ) - { - error = FT_THROW( Invalid_Glyph_Format ); - goto Exit; - } + return FT_THROW( Invalid_Glyph_Format ); + + /* create FT_Glyph object */ + return ft_new_glyph( library, clazz, aglyph ); + } + + + /* documentation is in ftglyph.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Glyph( FT_GlyphSlot slot, + FT_Glyph *aglyph ) + { + FT_Error error; + FT_Glyph glyph; + + + if ( !slot ) + return FT_THROW( Invalid_Slot_Handle ); + + if ( !aglyph ) + return FT_THROW( Invalid_Argument ); /* create FT_Glyph object */ - error = ft_new_glyph( library, clazz, &glyph ); + error = FT_New_Glyph( slot->library, slot->format, &glyph ); if ( error ) goto Exit; @@ -427,7 +435,7 @@ glyph->advance.y = slot->advance.y * 1024; /* now import the image from the glyph slot */ - error = clazz->glyph_init( glyph, slot ); + error = glyph->clazz->glyph_init( glyph, slot ); Exit2: /* if an error occurred, destroy the glyph */ @@ -505,8 +513,8 @@ { acbox->xMin = FT_PIX_FLOOR( acbox->xMin ); acbox->yMin = FT_PIX_FLOOR( acbox->yMin ); - acbox->xMax = FT_PIX_CEIL( acbox->xMax ); - acbox->yMax = FT_PIX_CEIL( acbox->yMax ); + acbox->xMax = FT_PIX_CEIL_LONG( acbox->xMax ); + acbox->yMax = FT_PIX_CEIL_LONG( acbox->yMax ); } /* convert to integer pixels if needed */ @@ -536,7 +544,6 @@ FT_BitmapGlyph bitmap = NULL; const FT_Glyph_Class* clazz; - /* FT_BITMAP_GLYPH_CLASS_GET dereferences `library' in PIC mode */ FT_Library library; @@ -553,7 +560,7 @@ goto Bad; /* when called with a bitmap glyph, do nothing and return successfully */ - if ( clazz == FT_BITMAP_GLYPH_CLASS_GET ) + if ( clazz == &ft_bitmap_glyph_class ) goto Exit; if ( !clazz->glyph_prepare ) @@ -569,7 +576,7 @@ dummy.format = clazz->glyph_format; /* create result bitmap glyph */ - error = ft_new_glyph( library, FT_BITMAP_GLYPH_CLASS_GET, &b ); + error = ft_new_glyph( library, &ft_bitmap_glyph_class, &b ); if ( error ) goto Exit; bitmap = (FT_BitmapGlyph)b; diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/fthash.c b/src/src/java.desktop/share/native/libfreetype/src/base/fthash.c index 21bc8dd5b42..387e6d26db9 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/fthash.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/fthash.c @@ -1,10 +1,10 @@ -/***************************************************************************/ -/* */ -/* fthash.c */ -/* */ -/* Hashing functions (body). */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fthash.c + * + * Hashing functions (body). + * + */ /* * Copyright 2000 Computing Research Labs, New Mexico State University @@ -30,13 +30,13 @@ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /*************************************************************************/ - /* */ - /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ - /* */ - /* taken from Mark Leisher's xmbdfed package */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 + * + * taken from Mark Leisher's xmbdfed package + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftinit.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftinit.c index 1fa4721094a..9d524effa92 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftinit.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftinit.c @@ -1,40 +1,40 @@ -/***************************************************************************/ -/* */ -/* ftinit.c */ -/* */ -/* FreeType initialization layer (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* The purpose of this file is to implement the following two */ - /* functions: */ - /* */ - /* FT_Add_Default_Modules(): */ - /* This function is used to add the set of default modules to a */ - /* fresh new library object. The set is taken from the header file */ - /* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */ - /* Build System' for more information. */ - /* */ - /* FT_Init_FreeType(): */ - /* This function creates a system object for the current platform, */ - /* builds a library out of it, then calls FT_Default_Drivers(). */ - /* */ - /* Note that even if FT_Init_FreeType() uses the implementation of the */ - /* system object defined at build time, client applications are still */ - /* able to provide their own `ftsystem.c'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftinit.c + * + * FreeType initialization layer (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * The purpose of this file is to implement the following two + * functions: + * + * FT_Add_Default_Modules(): + * This function is used to add the set of default modules to a + * fresh new library object. The set is taken from the header file + * `freetype/config/ftmodule.h'. See the document `FreeType 2.0 + * Build System' for more information. + * + * FT_Init_FreeType(): + * This function creates a system object for the current platform, + * builds a library out of it, then calls FT_Default_Drivers(). + * + * Note that even if FT_Init_FreeType() uses the implementation of the + * system object defined at build time, client applications are still + * able to provide their own `ftsystem.c'. + * + */ #include <ft2build.h> @@ -42,20 +42,16 @@ #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_MODULE_H -#include "basepic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_init - - -#ifndef FT_CONFIG_OPTION_PIC +#define FT_COMPONENT init #undef FT_USE_MODULE @@ -78,120 +74,6 @@ }; -#else /* FT_CONFIG_OPTION_PIC */ - - -#ifdef __cplusplus -#define FT_EXTERNC extern "C" -#else -#define FT_EXTERNC extern -#endif - - /* declare the module's class creation/destruction functions */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) \ - FT_EXTERNC FT_Error \ - FT_Create_Class_ ## x( FT_Library library, \ - FT_Module_Class* *output_class ); \ - FT_EXTERNC void \ - FT_Destroy_Class_ ## x( FT_Library library, \ - FT_Module_Class* clazz ); - -#include FT_CONFIG_MODULES_H - - /* count all module classes */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x, - - enum - { -#include FT_CONFIG_MODULES_H - FT_NUM_MODULE_CLASSES - }; - - /* destroy all module classes */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) \ - if ( classes[i] ) \ - { \ - FT_Destroy_Class_ ## x( library, classes[i] ); \ - } \ - i++; - - - FT_BASE_DEF( void ) - ft_destroy_default_module_classes( FT_Library library ) - { - FT_Module_Class* *classes; - FT_Memory memory; - FT_UInt i; - BasePIC* pic_container = (BasePIC*)library->pic_container.base; - - - if ( !pic_container->default_module_classes ) - return; - - memory = library->memory; - classes = pic_container->default_module_classes; - i = 0; - -#include FT_CONFIG_MODULES_H - - FT_FREE( classes ); - pic_container->default_module_classes = NULL; - } - - - /* initialize all module classes and the pointer table */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) \ - error = FT_Create_Class_ ## x( library, &clazz ); \ - if ( error ) \ - goto Exit; \ - classes[i++] = clazz; - - - FT_BASE_DEF( FT_Error ) - ft_create_default_module_classes( FT_Library library ) - { - FT_Error error; - FT_Memory memory; - FT_Module_Class* *classes = NULL; - FT_Module_Class* clazz; - FT_UInt i; - BasePIC* pic_container = (BasePIC*)library->pic_container.base; - - - memory = library->memory; - - pic_container->default_module_classes = NULL; - - if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) * - ( FT_NUM_MODULE_CLASSES + 1 ) ) ) - return error; - - /* initialize all pointers to 0, especially the last one */ - for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ ) - classes[i] = NULL; - classes[FT_NUM_MODULE_CLASSES] = NULL; - - i = 0; - -#include FT_CONFIG_MODULES_H - - Exit: - if ( error ) - ft_destroy_default_module_classes( library ); - else - pic_container->default_module_classes = classes; - - return error; - } - - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( void ) @@ -201,16 +83,10 @@ const FT_Module_Class* const* cur; - /* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - if ( !library ) - return; -#endif - /* GCC 4.6 warns the type difference: * FT_Module_Class** != const FT_Module_Class* const* */ - cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET; + cur = (const FT_Module_Class* const*)ft_default_modules; /* test for valid `library' delayed to FT_Add_Module() */ while ( *cur ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c index 8d314df0803..9fb49ba116e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftlcdfil.c */ -/* */ -/* FreeType API for color filtering of subpixel bitmap glyphs (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftlcdfil.c + * + * FreeType API for color filtering of subpixel bitmap glyphs (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -34,9 +34,9 @@ /* add padding according to filter weights */ FT_BASE_DEF (void) - ft_lcd_padding( FT_Pos* Min, - FT_Pos* Max, - FT_GlyphSlot slot ) + ft_lcd_padding( FT_BBox* cbox, + FT_GlyphSlot slot, + FT_Render_Mode mode ) { FT_Byte* lcd_weights; FT_Bitmap_LcdFilterFunc lcd_filter_func; @@ -56,10 +56,20 @@ if ( lcd_filter_func == ft_lcd_filter_fir ) { - *Min -= lcd_weights[0] ? 43 : - lcd_weights[1] ? 22 : 0; - *Max += lcd_weights[4] ? 43 : - lcd_weights[3] ? 22 : 0; + if ( mode == FT_RENDER_MODE_LCD ) + { + cbox->xMin -= lcd_weights[0] ? 43 : + lcd_weights[1] ? 22 : 0; + cbox->xMax += lcd_weights[4] ? 43 : + lcd_weights[3] ? 22 : 0; + } + else if ( mode == FT_RENDER_MODE_LCD_V ) + { + cbox->yMin -= lcd_weights[0] ? 43 : + lcd_weights[1] ? 22 : 0; + cbox->yMax += lcd_weights[4] ? 43 : + lcd_weights[3] ? 22 : 0; + } } } @@ -275,6 +285,8 @@ #endif /* USE_LEGACY */ + /* documentation in ftlcdfil.h */ + FT_EXPORT_DEF( FT_Error ) FT_Library_SetLcdFilterWeights( FT_Library library, unsigned char *weights ) @@ -292,6 +304,8 @@ } + /* documentation in ftlcdfil.h */ + FT_EXPORT_DEF( FT_Error ) FT_Library_SetLcdFilter( FT_Library library, FT_LcdFilter filter ) @@ -341,18 +355,41 @@ return FT_Err_Ok; } + + FT_EXPORT_DEF( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector* sub ) + { + FT_UNUSED( library ); + FT_UNUSED( sub ); + + return FT_THROW( Unimplemented_Feature ); + } + #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /* add padding according to accommodate outline shifts */ + /* add padding to accommodate outline shifts */ FT_BASE_DEF (void) - ft_lcd_padding( FT_Pos* Min, - FT_Pos* Max, - FT_GlyphSlot slot ) + ft_lcd_padding( FT_BBox* cbox, + FT_GlyphSlot slot, + FT_Render_Mode mode ) { - FT_UNUSED( slot ); + FT_Vector* sub = slot->library->lcd_geometry; - *Min -= 21; - *Max += 21; + if ( mode == FT_RENDER_MODE_LCD ) + { + cbox->xMin -= FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x ); + cbox->xMax -= FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x ); + cbox->yMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y ); + cbox->yMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y ); + } + else if ( mode == FT_RENDER_MODE_LCD_V ) + { + cbox->xMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y ); + cbox->xMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y ); + cbox->yMin += FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x ); + cbox->yMax += FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x ); + } } @@ -377,6 +414,24 @@ return FT_THROW( Unimplemented_Feature ); } + + /* documentation in ftlcdfil.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector sub[3] ) + { + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + if ( !sub ) + return FT_THROW( Invalid_Argument ); + + ft_memcpy( library->lcd_geometry, sub, 3 * sizeof( FT_Vector ) ); + + return FT_THROW( Unimplemented_Feature ); + } + #endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftmac.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftmac.c index fd4c0cc274f..5f23ceea9f3 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftmac.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftmac.c @@ -1,23 +1,23 @@ -/***************************************************************************/ -/* */ -/* ftmac.c */ -/* */ -/* Mac FOND support. Written by just@letterror.com. */ -/* Heavily modified by mpsuzuki, George Williams, and Sean McBride. */ -/* */ -/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */ -/* classic platforms built by MPW. */ -/* */ -/* Copyright 1996-2018 by */ -/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmac.c + * + * Mac FOND support. Written by just@letterror.com. + * Heavily modified by mpsuzuki, George Williams, and Sean McBride. + * + * This file is for Mac OS X only; see builds/mac/ftoldmac.c for + * classic platforms built by MPW. + * + * Copyright (C) 1996-2019 by + * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* @@ -954,17 +954,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face */ - /* */ - /* <Description> */ - /* This is the Mac-specific implementation of FT_New_Face. In */ - /* addition to the standard FT_New_Face() functionality, it also */ - /* accepts pathnames to Mac suitcase files. For further */ - /* documentation see the original FT_New_Face() in freetype.h. */ - /* */ + /************************************************************************** + * + * @Function: + * FT_New_Face + * + * @Description: + * This is the Mac-specific implementation of FT_New_Face. In + * addition to the standard FT_New_Face() functionality, it also + * accepts pathnames to Mac suitcase files. For further + * documentation see the original FT_New_Face() in freetype.h. + */ FT_EXPORT_DEF( FT_Error ) FT_New_Face( FT_Library library, const char* pathname, @@ -995,17 +995,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSRef */ - /* */ - /* <Description> */ - /* FT_New_Face_From_FSRef is identical to FT_New_Face except it */ - /* accepts an FSRef instead of a path. */ - /* */ - /* This function is deprecated because Carbon data types (FSRef) */ - /* are not cross-platform, and thus not suitable for the FreeType API. */ + /************************************************************************** + * + * @Function: + * FT_New_Face_From_FSRef + * + * @Description: + * FT_New_Face_From_FSRef is identical to FT_New_Face except it + * accepts an FSRef instead of a path. + * + * This function is deprecated because Carbon data types (FSRef) + * are not cross-platform, and thus not suitable for the FreeType API. + */ FT_EXPORT_DEF( FT_Error ) FT_New_Face_From_FSRef( FT_Library library, const FSRef* ref, @@ -1040,16 +1041,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSSpec */ - /* */ - /* <Description> */ - /* FT_New_Face_From_FSSpec is identical to FT_New_Face except it */ - /* accepts an FSSpec instead of a path. */ - /* */ - /* This function is deprecated because FSSpec is deprecated in Mac OS X */ + /************************************************************************** + * + * @Function: + * FT_New_Face_From_FSSpec + * + * @Description: + * FT_New_Face_From_FSSpec is identical to FT_New_Face except it + * accepts an FSSpec instead of a path. + * + * This function is deprecated because FSSpec is deprecated in Mac OS X + */ FT_EXPORT_DEF( FT_Error ) FT_New_Face_From_FSSpec( FT_Library library, const FSSpec* spec, diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftmm.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftmm.c index 800441bcac8..ba9e67f008a 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftmm.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftmm.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmm.c */ -/* */ -/* Multiple Master font support (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmm.c + * + * Multiple Master font support (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,14 +25,14 @@ #include FT_SERVICE_METRICS_VARIATIONS_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_mm +#define FT_COMPONENT mm static FT_Error @@ -199,6 +199,67 @@ } + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Set_MM_WeightVector( FT_Face face, + FT_UInt len, + FT_Fixed* weightvector ) + { + FT_Error error; + FT_Service_MultiMasters service; + + + /* check of `face' delayed to `ft_face_get_mm_service' */ + + if ( len && !weightvector ) + return FT_THROW( Invalid_Argument ); + + error = ft_face_get_mm_service( face, &service ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service->set_mm_weightvector ) + error = service->set_mm_weightvector( face, len, weightvector ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + return error; + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_MM_WeightVector( FT_Face face, + FT_UInt* len, + FT_Fixed* weightvector ) + { + FT_Error error; + FT_Service_MultiMasters service; + + + /* check of `face' delayed to `ft_face_get_mm_service' */ + + if ( len && !weightvector ) + return FT_THROW( Invalid_Argument ); + + error = ft_face_get_mm_service( face, &service ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service->get_mm_weightvector ) + error = service->get_mm_weightvector( face, len, weightvector ); + } + + return error; + } + + /* documentation is in ftmm.h */ FT_EXPORT_DEF( FT_Error ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c index 8d07e35ae37..3f8619d3b3c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftobjs.c */ -/* */ -/* The FreeType private base classes (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftobjs.c + * + * The FreeType private base classes (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -79,6 +79,18 @@ #pragma warning( pop ) #endif + static const char* const pixel_modes[] = + { + "none", + "monochrome bitmap", + "gray 8-bit bitmap", + "gray 2-bit bitmap", + "gray 4-bit bitmap", + "LCD 8-bit bitmap", + "vertical LCD 8-bit bitmap", + "BGRA 32-bit color image bitmap" + }; + #endif /* FT_DEBUG_LEVEL_TRACE */ @@ -259,14 +271,14 @@ } - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs /*************************************************************************/ @@ -330,7 +342,9 @@ } - FT_BASE_DEF( void ) + /* overflow-resistant presetting of bitmap position and dimensions; */ + /* also check whether the size is too large for rendering */ + FT_BASE_DEF( FT_Bool ) ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) @@ -340,15 +354,15 @@ FT_Pixel_Mode pixel_mode; - FT_BBox cbox; + FT_BBox cbox, pbox; FT_Pos x_shift = 0; FT_Pos y_shift = 0; FT_Pos x_left, y_top; FT_Pos width, height, pitch; - if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) - return; + if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) + return 1; if ( origin ) { @@ -360,76 +374,89 @@ /* taking into account the origin shift */ FT_Outline_Get_CBox( outline, &cbox ); - cbox.xMin += x_shift; - cbox.yMin += y_shift; - cbox.xMax += x_shift; - cbox.yMax += y_shift; + /* rough estimate of pixel box */ + pbox.xMin = ( cbox.xMin >> 6 ) + ( x_shift >> 6 ); + pbox.yMin = ( cbox.yMin >> 6 ) + ( y_shift >> 6 ); + pbox.xMax = ( cbox.xMax >> 6 ) + ( x_shift >> 6 ); + pbox.yMax = ( cbox.yMax >> 6 ) + ( y_shift >> 6 ); + + /* tiny remainder box */ + cbox.xMin = ( cbox.xMin & 63 ) + ( x_shift & 63 ); + cbox.yMin = ( cbox.yMin & 63 ) + ( y_shift & 63 ); + cbox.xMax = ( cbox.xMax & 63 ) + ( x_shift & 63 ); + cbox.yMax = ( cbox.yMax & 63 ) + ( y_shift & 63 ); switch ( mode ) { case FT_RENDER_MODE_MONO: pixel_mode = FT_PIXEL_MODE_MONO; #if 1 - /* undocumented but confirmed: bbox values get rounded */ - /* unless the rounded box can collapse for a narrow glyph */ - if ( cbox.xMax - cbox.xMin < 64 ) - { - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); - } - else - { - cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin ); - cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax ); - } + /* x */ + + /* undocumented but confirmed: bbox values get rounded; */ + /* we do asymmetric rounding so that the center of a pixel */ + /* gets always included */ + + pbox.xMin += ( cbox.xMin + 31 ) >> 6; + pbox.xMax += ( cbox.xMax + 32 ) >> 6; - if ( cbox.yMax - cbox.yMin < 64 ) + /* if the bbox collapsed, we add a pixel based on the total */ + /* rounding remainder to cover most of the original cbox */ + + if ( pbox.xMin == pbox.xMax ) { - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + if ( ( ( cbox.xMin + 31 ) & 63 ) - 31 + + ( ( cbox.xMax + 32 ) & 63 ) - 32 < 0 ) + pbox.xMin -= 1; + else + pbox.xMax += 1; } - else + + /* y */ + + pbox.yMin += ( cbox.yMin + 31 ) >> 6; + pbox.yMax += ( cbox.yMax + 32 ) >> 6; + + if ( pbox.yMin == pbox.yMax ) { - cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin ); - cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax ); + if ( ( ( cbox.yMin + 31 ) & 63 ) - 31 + + ( ( cbox.yMax + 32 ) & 63 ) - 32 < 0 ) + pbox.yMin -= 1; + else + pbox.yMax += 1; } + + break; #else - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + goto Adjust; #endif - break; case FT_RENDER_MODE_LCD: pixel_mode = FT_PIXEL_MODE_LCD; - ft_lcd_padding( &cbox.xMin, &cbox.xMax, slot ); - goto Round; + ft_lcd_padding( &cbox, slot, mode ); + goto Adjust; case FT_RENDER_MODE_LCD_V: pixel_mode = FT_PIXEL_MODE_LCD_V; - ft_lcd_padding( &cbox.yMin, &cbox.yMax, slot ); - goto Round; + ft_lcd_padding( &cbox, slot, mode ); + goto Adjust; case FT_RENDER_MODE_NORMAL: case FT_RENDER_MODE_LIGHT: default: pixel_mode = FT_PIXEL_MODE_GRAY; - Round: - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + Adjust: + pbox.xMin += cbox.xMin >> 6; + pbox.yMin += cbox.yMin >> 6; + pbox.xMax += ( cbox.xMax + 63 ) >> 6; + pbox.yMax += ( cbox.yMax + 63 ) >> 6; } - x_shift = SUB_LONG( x_shift, cbox.xMin ); - y_shift = SUB_LONG( y_shift, cbox.yMin ); + x_left = pbox.xMin; + y_top = pbox.yMax; - x_left = cbox.xMin >> 6; - y_top = cbox.yMax >> 6; - - width = ( (FT_ULong)cbox.xMax - (FT_ULong)cbox.xMin ) >> 6; - height = ( (FT_ULong)cbox.yMax - (FT_ULong)cbox.yMin ) >> 6; + width = pbox.xMax - pbox.xMin; + height = pbox.yMax - pbox.yMin; switch ( pixel_mode ) { @@ -459,6 +486,16 @@ bitmap->width = (unsigned int)width; bitmap->rows = (unsigned int)height; bitmap->pitch = pitch; + + if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF || + pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF ) + { + FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n", + pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax )); + return 1; + } + + return 0; } @@ -807,7 +844,7 @@ * - Do only auto-hinting if we have * * - a hinter module, - * - a scalable font format dealing with outlines, + * - a scalable font, * - not a tricky font, and * - no transforms except simple slants and/or rotations by * integer multiples of 90 degrees. @@ -825,8 +862,7 @@ if ( hinter && !( load_flags & FT_LOAD_NO_HINTING ) && !( load_flags & FT_LOAD_NO_AUTOHINT ) && - FT_DRIVER_IS_SCALABLE( driver ) && - FT_DRIVER_USES_OUTLINES( driver ) && + FT_IS_SCALABLE( face ) && !FT_IS_TRICKY( face ) && ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) || ( face->internal->transform_matrix.yx == 0 && @@ -846,7 +882,7 @@ /* only the new Adobe engine (for both CFF and Type 1) is `light'; */ /* we use `strstr' to catch both `Type 1' and `CID Type 1' */ is_light_type1 = - ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL && + ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL && ((PS_Driver)driver)->hinting_engine == FT_HINTING_ADOBE; /* the check for `num_locations' assures that we actually */ @@ -926,8 +962,9 @@ #ifdef GRID_FIT_METRICS if ( !( load_flags & FT_LOAD_NO_HINTING ) ) - ft_glyphslot_grid_fit_metrics( slot, - FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); + ft_glyphslot_grid_fit_metrics( + slot, + FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); #endif } } @@ -995,6 +1032,9 @@ } } + slot->glyph_index = glyph_index; + slot->internal->load_flags = load_flags; + /* do we need to render the image or preset the bitmap now? */ if ( !error && ( load_flags & FT_LOAD_NO_SCALE ) == 0 && @@ -1014,17 +1054,21 @@ ft_glyphslot_preset_bitmap( slot, mode, NULL ); } - FT_TRACE5(( "FT_Load_Glyph: index %d, flags %x\n", - glyph_index, load_flags )); +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n", + glyph_index, load_flags )); FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 )); FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 )); FT_TRACE5(( " linear x advance: %f\n", slot->linearHoriAdvance / 65536.0 )); FT_TRACE5(( " linear y advance: %f\n", slot->linearVertAdvance / 65536.0 )); - FT_TRACE5(( " bitmap %dx%d, mode %d\n", - slot->bitmap.width, slot->bitmap.rows, - slot->bitmap.pixel_mode )); + FT_TRACE5(( " bitmap %dx%d, %s (mode %d)\n", + slot->bitmap.width, + slot->bitmap.rows, + pixel_modes[slot->bitmap.pixel_mode], + slot->bitmap.pixel_mode )); +#endif Exit: return error; @@ -1162,20 +1206,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* find_unicode_charmap */ - /* */ - /* <Description> */ - /* This function finds a Unicode charmap, if there is one. */ - /* And if there is more than one, it tries to favour the more */ - /* extensive one, i.e., one that supports UCS-4 against those which */ - /* are limited to the BMP (said UCS-2 encoding.) */ - /* */ - /* This function is called from open_face() (just below), and also */ - /* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). */ - /* */ + /************************************************************************** + * + * @Function: + * find_unicode_charmap + * + * @Description: + * This function finds a Unicode charmap, if there is one. + * And if there is more than one, it tries to favour the more + * extensive one, i.e., one that supports UCS-4 against those which + * are limited to the BMP (said UCS-2 encoding.) + * + * This function is called from open_face() (just below), and also + * from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). + */ static FT_Error find_unicode_charmap( FT_Face face ) { @@ -1192,26 +1236,26 @@ return FT_THROW( Invalid_CharMap_Handle ); /* - * The original TrueType specification(s) only specified charmap - * formats that are capable of mapping 8 or 16 bit character codes to - * glyph indices. + * The original TrueType specification(s) only specified charmap + * formats that are capable of mapping 8 or 16 bit character codes to + * glyph indices. * - * However, recent updates to the Apple and OpenType specifications - * introduced new formats that are capable of mapping 32-bit character - * codes as well. And these are already used on some fonts, mainly to - * map non-BMP Asian ideographs as defined in Unicode. + * However, recent updates to the Apple and OpenType specifications + * introduced new formats that are capable of mapping 32-bit character + * codes as well. And these are already used on some fonts, mainly to + * map non-BMP Asian ideographs as defined in Unicode. * - * For compatibility purposes, these fonts generally come with - * *several* Unicode charmaps: + * For compatibility purposes, these fonts generally come with + * *several* Unicode charmaps: * - * - One of them in the "old" 16-bit format, that cannot access - * all glyphs in the font. + * - One of them in the "old" 16-bit format, that cannot access + * all glyphs in the font. * - * - Another one in the "new" 32-bit format, that can access all - * the glyphs. + * - Another one in the "new" 32-bit format, that can access all + * the glyphs. * - * This function has been written to always favor a 32-bit charmap - * when found. Otherwise, a 16-bit one is returned when found. + * This function has been written to always favor a 32-bit charmap + * when found. Otherwise, a 16-bit one is returned when found. */ /* Since the `interesting' table, with IDs (3,10), is normally the */ @@ -1255,15 +1299,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* find_variant_selector_charmap */ - /* */ - /* <Description> */ - /* This function finds the variant selector charmap, if there is one. */ - /* There can only be one (platform=0, specific=5, format=14). */ - /* */ + /************************************************************************** + * + * @Function: + * find_variant_selector_charmap + * + * @Description: + * This function finds the variant selector charmap, if there is one. + * There can only be one (platform=0, specific=5, format=14). + */ static FT_CharMap find_variant_selector_charmap( FT_Face face ) { @@ -1294,14 +1338,14 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* open_face */ - /* */ - /* <Description> */ - /* This function does some work for FT_Open_Face(). */ - /* */ + /************************************************************************** + * + * @Function: + * open_face + * + * @Description: + * This function does some work for FT_Open_Face(). + */ static FT_Error open_face( FT_Driver driver, FT_Stream *astream, @@ -2176,13 +2220,13 @@ { #undef FT_COMPONENT -#define FT_COMPONENT trace_raccess +#define FT_COMPONENT raccess FT_Memory memory = library->memory; FT_Error error = FT_ERR( Unknown_File_Format ); FT_UInt i; - char * file_names[FT_RACCESS_N_RULES]; + char* file_names[FT_RACCESS_N_RULES]; FT_Long offsets[FT_RACCESS_N_RULES]; FT_Error errors[FT_RACCESS_N_RULES]; FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ @@ -2254,7 +2298,7 @@ return error; #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs } @@ -2282,7 +2326,7 @@ { #undef FT_COMPONENT -#define FT_COMPONENT trace_raccess +#define FT_COMPONENT raccess #ifdef FT_DEBUG_LEVEL_TRACE FT_TRACE3(( "Try as dfont: " )); @@ -2295,7 +2339,7 @@ FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs } @@ -2693,8 +2737,8 @@ /* close the attached stream */ FT_Stream_Free( stream, - (FT_Bool)( parameters->stream && - ( parameters->flags & FT_OPEN_STREAM ) ) ); + FT_BOOL( parameters->stream && + ( parameters->flags & FT_OPEN_STREAM ) ) ); Exit: return error; @@ -3464,7 +3508,8 @@ if ( !face ) return FT_THROW( Invalid_Face_Handle ); - if ( encoding == FT_ENCODING_NONE ) + /* FT_ENCODING_NONE is a valid encoding for BDF, PCF, and Windows FNT */ + if ( encoding == FT_ENCODING_NONE && !face->num_charmaps ) return FT_THROW( Invalid_Argument ); /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ @@ -3485,7 +3530,7 @@ if ( cur[0]->encoding == encoding ) { face->charmap = cur[0]; - return 0; + return FT_Err_Ok; } } @@ -3510,14 +3555,12 @@ if ( !cur || !charmap ) return FT_THROW( Invalid_CharMap_Handle ); - if ( FT_Get_CMap_Format( charmap ) == 14 ) - return FT_THROW( Invalid_Argument ); - limit = cur + face->num_charmaps; for ( ; cur < limit; cur++ ) { - if ( cur[0] == charmap ) + if ( cur[0] == charmap && + FT_Get_CMap_Format ( charmap ) != 14 ) { face->charmap = cur[0]; return FT_Err_Ok; @@ -4487,16 +4530,89 @@ FT_Render_Mode render_mode ) { FT_Error error = FT_Err_Ok; + FT_Face face = slot->face; FT_Renderer renderer; - /* if it is already a bitmap, no need to do anything */ switch ( slot->format ) { case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ break; default: + if ( slot->internal->load_flags & FT_LOAD_COLOR ) + { + FT_LayerIterator iterator; + + FT_UInt base_glyph = slot->glyph_index; + + FT_Bool have_layers; + FT_UInt glyph_index; + FT_UInt color_index; + + + /* check whether we have colored glyph layers */ + iterator.p = NULL; + have_layers = FT_Get_Color_Glyph_Layer( face, + base_glyph, + &glyph_index, + &color_index, + &iterator ); + if ( have_layers ) + { + error = FT_New_GlyphSlot( face, NULL ); + if ( !error ) + { + TT_Face ttface = (TT_Face)face; + SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; + + + do + { + FT_Int32 load_flags = slot->internal->load_flags; + + + /* disable the `FT_LOAD_COLOR' flag to avoid recursion */ + /* right here in this function */ + load_flags &= ~FT_LOAD_COLOR; + + /* render into the new `face->glyph' glyph slot */ + load_flags |= FT_LOAD_RENDER; + + error = FT_Load_Glyph( face, glyph_index, load_flags ); + if ( error ) + break; + + /* blend new `face->glyph' into old `slot'; */ + /* at the first call, `slot' is still empty */ + error = sfnt->colr_blend( ttface, + color_index, + slot, + face->glyph ); + if ( error ) + break; + + } while ( FT_Get_Color_Glyph_Layer( face, + base_glyph, + &glyph_index, + &color_index, + &iterator ) ); + + if ( !error ) + slot->format = FT_GLYPH_FORMAT_BITMAP; + + /* this call also restores `slot' as the glyph slot */ + FT_Done_GlyphSlot( face->glyph ); + } + + if ( !error ) + return error; + + /* Failed to do the colored layer. Draw outline instead. */ + slot->format = FT_GLYPH_FORMAT_OUTLINE; + } + } + { FT_ListNode node = NULL; @@ -4532,7 +4648,7 @@ #ifdef FT_DEBUG_LEVEL_TRACE #undef FT_COMPONENT -#define FT_COMPONENT trace_bitmap +#define FT_COMPONENT checksum /* * Computing the MD5 checksum is expensive, unnecessarily distorting a @@ -4542,9 +4658,9 @@ */ /* we use FT_TRACE3 in this block */ - if ( !error && - ft_trace_levels[trace_bitmap] >= 3 && - slot->bitmap.buffer ) + if ( !error && + ft_trace_levels[trace_checksum] >= 3 && + slot->bitmap.buffer ) { FT_Bitmap bitmap; FT_Error err; @@ -4565,8 +4681,11 @@ int pitch = bitmap.pitch; - FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, mode %d\n", - rows, pitch, slot->bitmap.pixel_mode )); + FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, %s (mode %d)\n", + pitch, + rows, + pixel_modes[slot->bitmap.pixel_mode], + slot->bitmap.pixel_mode )); for ( i = 0; i < rows; i++ ) for ( j = 0; j < pitch; j++ ) @@ -4594,49 +4713,56 @@ */ /* we use FT_TRACE7 in this block */ - if ( !error && - ft_trace_levels[trace_bitmap] >= 7 && - slot->bitmap.rows < 128U && - slot->bitmap.width < 128U && - slot->bitmap.buffer ) + if ( !error && + ft_trace_levels[trace_checksum] >= 7 ) { - int rows = (int)slot->bitmap.rows; - int width = (int)slot->bitmap.width; - int pitch = slot->bitmap.pitch; - int i, j, m; - unsigned char* topleft = slot->bitmap.buffer; + if ( slot->bitmap.rows < 128U && + slot->bitmap.width < 128U && + slot->bitmap.buffer ) + { + int rows = (int)slot->bitmap.rows; + int width = (int)slot->bitmap.width; + int pitch = slot->bitmap.pitch; + int i, j, m; - if ( pitch < 0 ) - topleft -= pitch * ( rows - 1 ); + unsigned char* topleft = slot->bitmap.buffer; - FT_TRACE7(( "Netpbm image: start\n" )); - switch ( slot->bitmap.pixel_mode ) - { - case FT_PIXEL_MODE_MONO: - FT_TRACE7(( "P1 %d %d\n", width, rows )); - for ( i = 0; i < rows; i++ ) - { - for ( j = 0; j < width; ) - for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) - FT_TRACE7(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 )); - FT_TRACE7(( "\n" )); - } - break; - default: - FT_TRACE7(( "P2 %d %d 255\n", width, rows )); - for ( i = 0; i < rows; i++ ) + if ( pitch < 0 ) + topleft -= pitch * ( rows - 1 ); + + FT_TRACE7(( "Netpbm image: start\n" )); + switch ( slot->bitmap.pixel_mode ) { - for ( j = 0; j < width; j += 1 ) - FT_TRACE7(( " %3u", topleft[i * pitch + j] )); - FT_TRACE7(( "\n" )); + case FT_PIXEL_MODE_MONO: + FT_TRACE7(( "P1 %d %d\n", width, rows )); + for ( i = 0; i < rows; i++ ) + { + for ( j = 0; j < width; ) + for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) + FT_TRACE7(( " %d", + ( topleft[i * pitch + j / 8] & m ) != 0 )); + FT_TRACE7(( "\n" )); + } + break; + + default: + FT_TRACE7(( "P2 %d %d 255\n", width, rows )); + for ( i = 0; i < rows; i++ ) + { + for ( j = 0; j < width; j += 1 ) + FT_TRACE7(( " %3u", topleft[i * pitch + j] )); + FT_TRACE7(( "\n" )); + } } + FT_TRACE7(( "Netpbm image: end\n" )); } - FT_TRACE7(( "Netpbm image: end\n" )); + else + FT_TRACE7(( "Netpbm image: too large, omitted\n" )); } #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs #endif /* FT_DEBUG_LEVEL_TRACE */ @@ -4675,21 +4801,22 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* Destroy_Module */ - /* */ - /* <Description> */ - /* Destroys a given module object. For drivers, this also destroys */ - /* all child faces. */ - /* */ - /* <InOut> */ - /* module :: A handle to the target driver object. */ - /* */ - /* <Note> */ - /* The driver _must_ be LOCKED! */ - /* */ + /************************************************************************** + * + * @Function: + * Destroy_Module + * + * @Description: + * Destroys a given module object. For drivers, this also destroys + * all child faces. + * + * @InOut: + * module :: + * A handle to the target driver object. + * + * @Note: + * The driver _must_ be LOCKED! + */ static void Destroy_Module( FT_Module module ) { @@ -5028,9 +5155,9 @@ service = (FT_Service_Properties)interface; if ( set ) - missing_func = (FT_Bool)( !service->set_property ); + missing_func = FT_BOOL( !service->set_property ); else - missing_func = (FT_Bool)( !service->get_property ); + missing_func = FT_BOOL( !service->get_property ); if ( missing_func ) { @@ -5156,13 +5283,6 @@ library->memory = memory; -#ifdef FT_CONFIG_OPTION_PIC - /* initialize position independent code containers */ - error = ft_pic_container_init( library ); - if ( error ) - goto Fail; -#endif - library->version_major = FREETYPE_MAJOR; library->version_minor = FREETYPE_MINOR; library->version_patch = FREETYPE_PATCH; @@ -5173,13 +5293,6 @@ *alibrary = library; return FT_Err_Ok; - -#ifdef FT_CONFIG_OPTION_PIC - Fail: - ft_pic_container_destroy( library ); - FT_FREE( library ); - return error; -#endif } @@ -5237,10 +5350,10 @@ * * Example: * - * - the cff font driver uses the pshinter module in cff_size_done - * - if the pshinter module is destroyed before the cff font driver, - * opened FT_Face objects managed by the driver are not properly - * destroyed, resulting in a memory leak + * - the cff font driver uses the pshinter module in cff_size_done + * - if the pshinter module is destroyed before the cff font driver, + * opened FT_Face objects managed by the driver are not properly + * destroyed, resulting in a memory leak * * Some faces are dependent on other faces, like Type42 faces that * depend on TrueType faces synthesized internally. @@ -5310,11 +5423,6 @@ } #endif -#ifdef FT_CONFIG_OPTION_PIC - /* Destroy pic container contents */ - ft_pic_container_destroy( library ); -#endif - FT_FREE( library ); Exit: @@ -5402,4 +5510,41 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Bool ) + FT_Get_Color_Glyph_Layer( FT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ) + { + TT_Face ttface; + SFNT_Service sfnt; + + + if ( !face || + !aglyph_index || + !acolor_index || + !iterator || + base_glyph >= (FT_UInt)face->num_glyphs ) + return 0; + + if ( !FT_IS_SFNT( face ) ) + return 0; + + ttface = (TT_Face)face; + sfnt = (SFNT_Service)ttface->sfnt; + + if ( sfnt->get_colr_layer ) + return sfnt->get_colr_layer( ttface, + base_glyph, + aglyph_index, + acolor_index, + iterator ); + else + return 0; + } + + /* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c index cb91321debf..00329b46c64 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftoutln.c @@ -1,26 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftoutln.c */ -/* */ -/* FreeType outline management (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* All functions are declared in freetype.h. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftoutln.c + * + * FreeType outline management (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +24,14 @@ #include FT_TRIGONOMETRY_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_outline +#define FT_COMPONENT outline static @@ -296,15 +289,23 @@ } + /* documentation is in ftoutln.h */ + FT_EXPORT_DEF( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ) + FT_Outline_New( FT_Library library, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ) { - FT_Error error; + FT_Error error; + FT_Memory memory; + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + memory = library->memory; + if ( !anoutline || !memory ) return FT_THROW( Invalid_Argument ); @@ -330,28 +331,12 @@ Fail: anoutline->flags |= FT_OUTLINE_OWNER; - FT_Outline_Done_Internal( memory, anoutline ); + FT_Outline_Done( library, anoutline ); return error; } - /* documentation is in ftoutln.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_Outline_New( FT_Library library, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ) - { - if ( !library ) - return FT_THROW( Invalid_Library_Handle ); - - return FT_Outline_New_Internal( library->memory, numPoints, - numContours, anoutline ); - } - - /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) @@ -436,13 +421,23 @@ } + /* documentation is in ftoutln.h */ + FT_EXPORT_DEF( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ) + FT_Outline_Done( FT_Library library, + FT_Outline* outline ) { + FT_Memory memory; + + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + if ( !outline ) return FT_THROW( Invalid_Outline ); + memory = library->memory; + if ( !memory ) return FT_THROW( Invalid_Argument ); @@ -458,21 +453,6 @@ } - /* documentation is in ftoutln.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_Outline_Done( FT_Library library, - FT_Outline* outline ) - { - /* check for valid `outline' in FT_Outline_Done_Internal() */ - - if ( !library ) - return FT_THROW( Invalid_Library_Handle ); - - return FT_Outline_Done_Internal( library->memory, outline ); - } - - /* documentation is in ftoutln.h */ FT_EXPORT_DEF( void ) @@ -619,6 +599,7 @@ FT_Error error; FT_Renderer renderer; FT_ListNode node; + FT_BBox cbox; if ( !library ) @@ -630,6 +611,11 @@ if ( !params ) return FT_THROW( Invalid_Argument ); + FT_Outline_Get_CBox( outline, &cbox ); + if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L || + cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L ) + return FT_THROW( Invalid_Outline ); + renderer = library->cur_renderer; node = library->renderers.head; @@ -911,9 +897,9 @@ FT_Pos xstrength, FT_Pos ystrength ) { - FT_Vector* points; - FT_Int c, first, last; - FT_Int orientation; + FT_Vector* points; + FT_Int c, first, last; + FT_Orientation orientation; if ( !outline ) @@ -1044,7 +1030,7 @@ FT_EXPORT_DEF( FT_Orientation ) FT_Outline_Get_Orientation( FT_Outline* outline ) { - FT_BBox cbox; + FT_BBox cbox = { 0, 0, 0, 0 }; FT_Int xshift, yshift; FT_Vector* points; FT_Vector v_prev, v_cur; @@ -1090,7 +1076,8 @@ v_cur.y = points[n].y >> yshift; area = ADD_LONG( area, - ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ) ); + MUL_LONG( v_cur.y - v_prev.y, + v_cur.x + v_prev.x ) ); v_prev = v_cur; } diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c index e23ee2e3f48..020f4646ebe 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftpatent.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftpatent.c */ -/* */ -/* FreeType API for checking patented TrueType bytecode instructions */ -/* (body). Obsolete, retained for backward compatibility. */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpatent.c + * + * FreeType API for checking patented TrueType bytecode instructions + * (body). Obsolete, retained for backward compatibility. + * + * Copyright (C) 2007-2019 by + * David Turner. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_FREETYPE_H diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftpic.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftpic.c deleted file mode 100644 index 1492e1809a5..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftpic.c +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpic.c */ -/* */ -/* The FreeType position independent code services (body). */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "basepic.h" - -#ifdef FT_CONFIG_OPTION_PIC - - /* documentation is in ftpic.h */ - - FT_BASE_DEF( FT_Error ) - ft_pic_container_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error; - - - FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) ); - - error = ft_base_pic_init( library ); - if ( error ) - return error; - - return FT_Err_Ok; - } - - - /* Destroy the contents of the container. */ - FT_BASE_DEF( void ) - ft_pic_container_destroy( FT_Library library ) - { - ft_base_pic_free( library ); - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c index 459b5e6054c..52b9d453ad2 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftpsprop.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftpsprop.c */ -/* */ -/* Get and set properties of PostScript drivers (body). */ -/* See `ftdriver.h' for available properties. */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpsprop.c + * + * Get and set properties of PostScript drivers (body). + * See `ftdriver.h' for available properties. + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,14 +25,14 @@ #include FT_INTERNAL_POSTSCRIPT_PROPS_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_psprops +#define FT_COMPONENT psprops FT_BASE_CALLBACK_DEF( FT_Error ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c index c3a2b9151ac..73b7eb0ded4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftrfork.c @@ -1,38 +1,38 @@ -/***************************************************************************/ -/* */ -/* ftrfork.c */ -/* */ -/* Embedded resource forks accessor (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ -/* derived from ftobjs.c. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* Development of the code in this file is support of */ -/* Information-technology Promotion Agency, Japan. */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrfork.c + * + * Embedded resource forks accessor (body). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO and Redhat K.K. + * + * FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are + * derived from ftobjs.c. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * Development of the code in this file is support of + * Information-technology Promotion Agency, Japan. + */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_RFORK_H -#include "basepic.h" + #include "ftbase.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_raccess +#define FT_COMPONENT raccess /*************************************************************************/ @@ -438,7 +438,7 @@ static FT_Error raccess_guess_linux_double_from_file_name( FT_Library library, - char * file_name, + char* file_name, FT_Long *result_offset ); static char * @@ -468,10 +468,10 @@ if ( errors[i] ) continue; - errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library, - stream, base_name, - &(new_names[i]), - &(offsets[i]) ); + errors[i] = ft_raccess_guess_table[i].func( library, + stream, base_name, + &(new_names[i]), + &(offsets[i]) ); } return; @@ -488,7 +488,7 @@ if ( rule_index >= FT_RACCESS_N_RULES ) return FT_RFork_Rule_invalid; - return FT_RACCESS_GUESS_TABLE_GET[rule_index].type; + return ft_raccess_guess_table[rule_index].type; } @@ -847,7 +847,7 @@ { FT_Open_Args args2; FT_Stream stream2; - char * nouse = NULL; + char* nouse = NULL; FT_Error error; @@ -909,9 +909,9 @@ #else /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ - /*************************************************************************/ - /* Dummy function; just sets errors */ - /*************************************************************************/ + /************************************************************************** + * Dummy function; just sets errors + */ FT_BASE_DEF( void ) FT_Raccess_Guess( FT_Library library, diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c index 90ea1e2be7b..7ab3fe3cfac 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftsnames.c @@ -1,22 +1,22 @@ -/***************************************************************************/ -/* */ -/* ftsnames.c */ -/* */ -/* Simple interface to access SFNT name tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (body). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsnames.c + * + * Simple interface to access SFNT name tables (which are used + * to hold font names, copyright info, notices, etc.) (body). + * + * This is _not_ used to retrieve glyph names! + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -142,7 +142,45 @@ } -#endif /* TT_CONFIG_OPTION_SFNT_NAMES */ +#else /* !TT_CONFIG_OPTION_SFNT_NAMES */ + + + FT_EXPORT_DEF( FT_UInt ) + FT_Get_Sfnt_Name_Count( FT_Face face ) + { + FT_UNUSED( face ); + + return 0; + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Sfnt_Name( FT_Face face, + FT_UInt idx, + FT_SfntName *aname ) + { + FT_UNUSED( face ); + FT_UNUSED( idx ); + FT_UNUSED( aname ); + + return FT_THROW( Unimplemented_Feature ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Sfnt_LangTag( FT_Face face, + FT_UInt langID, + FT_SfntLangTag *alangTag ) + { + FT_UNUSED( face ); + FT_UNUSED( langID ); + FT_UNUSED( alangTag ); + + return FT_THROW( Unimplemented_Feature ); + } + + +#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */ /* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftstream.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftstream.c index 18df7dcfef6..4b0890d7fd5 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftstream.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftstream.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstream.c */ -/* */ -/* I/O stream support (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstream.c + * + * I/O stream support (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,14 +21,14 @@ #include FT_INTERNAL_DEBUG_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_stream +#define FT_COMPONENT stream FT_BASE_DEF( void ) @@ -219,13 +219,14 @@ { FT_Memory memory = stream->memory; + #ifdef FT_DEBUG_MEMORY ft_mem_free( memory, *pbytes ); - *pbytes = NULL; #else FT_FREE( *pbytes ); #endif } + *pbytes = NULL; } @@ -238,6 +239,8 @@ FT_ULong read_bytes; + FT_TRACE7(( "FT_Stream_EnterFrame: %ld bytes\n", count )); + /* check for nested frame access */ FT_ASSERT( stream && stream->cursor == 0 ); @@ -281,6 +284,7 @@ FT_FREE( stream->base ); error = FT_THROW( Invalid_Stream_Operation ); } + stream->cursor = stream->base; stream->limit = stream->cursor + count; stream->pos += read_bytes; @@ -321,13 +325,16 @@ /* In this case, the loader code handles the 0-length table */ /* gracefully; however, stream.cursor is really set to 0 by the */ /* FT_Stream_EnterFrame() call, and this is not an error. */ - /* */ + + FT_TRACE7(( "FT_Stream_ExitFrame\n" )); + FT_ASSERT( stream ); if ( stream->read ) { FT_Memory memory = stream->memory; + #ifdef FT_DEBUG_MEMORY ft_mem_free( memory, stream->base ); stream->base = NULL; @@ -335,6 +342,7 @@ FT_FREE( stream->base ); #endif } + stream->cursor = NULL; stream->limit = NULL; } diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c index 6ae18190679..826062c94ec 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftstroke.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstroke.c */ -/* */ -/* FreeType path stroker (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstroke.c + * + * FreeType path stroker (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,15 +24,10 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_OBJECTS_H -#include "basepic.h" - - /* declare an extern to access `ft_outline_glyph_class' globally */ - /* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */ - /* macro to access it when FT_CONFIG_OPTION_PIC is defined */ -#ifndef FT_CONFIG_OPTION_PIC + /* declare an extern to access `ft_outline_glyph_class' globally */ + /* allocated in `ftglyph.c' */ FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class; -#endif /* documentation is in ftstroke.h */ @@ -372,6 +367,7 @@ /* it contains the `adjusted' starting coordinates */ border->num_points = --count; border->points[start] = border->points[count]; + border->tags[start] = border->tags[count]; if ( reverse ) { @@ -436,8 +432,8 @@ } else { - /* don't add zero-length lineto */ - if ( border->num_points > 0 && + /* don't add zero-length lineto, but always add moveto */ + if ( border->num_points > (FT_UInt)border->start && FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) && FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) ) return error; @@ -2087,8 +2083,8 @@ /* documentation is in ftstroke.h */ /* - * The following is very similar to FT_Outline_Decompose, except - * that we do support opened paths, and do not scale the outline. + * The following is very similar to FT_Outline_Decompose, except + * that we do support opened paths, and do not scale the outline. */ FT_EXPORT_DEF( FT_Error ) FT_Stroker_ParseOutline( FT_Stroker stroker, @@ -2306,17 +2302,12 @@ FT_Error error = FT_ERR( Invalid_Argument ); FT_Glyph glyph = NULL; - /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */ - FT_Library library = stroker->library; - - FT_UNUSED( library ); - if ( !pglyph ) goto Exit; glyph = *pglyph; - if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) + if ( !glyph || glyph->clazz != &ft_outline_glyph_class ) goto Exit; { @@ -2386,17 +2377,12 @@ FT_Error error = FT_ERR( Invalid_Argument ); FT_Glyph glyph = NULL; - /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */ - FT_Library library = stroker->library; - - FT_UNUSED( library ); - if ( !pglyph ) goto Exit; glyph = *pglyph; - if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) + if ( !glyph || glyph->clazz != &ft_outline_glyph_class ) goto Exit; { diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c index c28346707bd..f87ed65e751 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftsynth.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsynth.c */ -/* */ -/* FreeType synthesizing code for emboldening and slanting (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsynth.c + * + * FreeType synthesizing code for emboldening and slanting (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,14 +24,14 @@ #include FT_BITMAP_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_synth +#define FT_COMPONENT synth /*************************************************************************/ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c index 6adebdb9383..f92b3a03d58 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftsystem.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftsystem.c */ -/* */ -/* ANSI-specific FreeType low-level system interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file contains the default interface used by FreeType to access */ - /* low-level, i.e. memory management, i/o access as well as thread */ - /* synchronisation. It can be replaced by user-specific routines if */ - /* necessary. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftsystem.c + * + * ANSI-specific FreeType low-level system interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file contains the default interface used by FreeType to access + * low-level, i.e. memory management, i/o access as well as thread + * synchronisation. It can be replaced by user-specific routines if + * necessary. + * + */ #include <ft2build.h> @@ -34,37 +34,39 @@ #include FT_TYPES_H - /*************************************************************************/ - /* */ - /* MEMORY MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* It is not necessary to do any error checking for the */ - /* allocation-related functions. This will be done by the higher level */ - /* routines like ft_mem_alloc() or ft_mem_realloc(). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_alloc */ - /* */ - /* <Description> */ - /* The memory allocation function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* size :: The requested size in bytes. */ - /* */ - /* <Return> */ - /* The address of newly allocated block. */ - /* */ + /************************************************************************** + * + * MEMORY MANAGEMENT INTERFACE + * + */ + + /************************************************************************** + * + * It is not necessary to do any error checking for the + * allocation-related functions. This will be done by the higher level + * routines like ft_mem_alloc() or ft_mem_realloc(). + * + */ + + + /************************************************************************** + * + * @Function: + * ft_alloc + * + * @Description: + * The memory allocation function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * size :: + * The requested size in bytes. + * + * @Return: + * The address of newly allocated block. + */ FT_CALLBACK_DEF( void* ) ft_alloc( FT_Memory memory, long size ) @@ -75,26 +77,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_realloc */ - /* */ - /* <Description> */ - /* The memory reallocation function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* cur_size :: The current size of the allocated memory block. */ - /* */ - /* new_size :: The newly requested size in bytes. */ - /* */ - /* block :: The current address of the block in memory. */ - /* */ - /* <Return> */ - /* The address of the reallocated memory block. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_realloc + * + * @Description: + * The memory reallocation function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * cur_size :: + * The current size of the allocated memory block. + * + * new_size :: + * The newly requested size in bytes. + * + * block :: + * The current address of the block in memory. + * + * @Return: + * The address of the reallocated memory block. + */ FT_CALLBACK_DEF( void* ) ft_realloc( FT_Memory memory, long cur_size, @@ -108,19 +114,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_free */ - /* */ - /* <Description> */ - /* The memory release function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* block :: The address of block in memory to be freed. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_free + * + * @Description: + * The memory release function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * block :: + * The address of block in memory to be freed. + */ FT_CALLBACK_DEF( void ) ft_free( FT_Memory memory, void* block ) @@ -131,39 +139,40 @@ } - /*************************************************************************/ - /* */ - /* RESOURCE MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * RESOURCE MANAGEMENT INTERFACE + * + */ #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_io +#define FT_COMPONENT io /* We use the macro STREAM_FILE for convenience to extract the */ /* system-specific stream handle from a given FreeType stream object */ #define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_ansi_stream_close */ - /* */ - /* <Description> */ - /* The function to close a stream. */ - /* */ - /* <Input> */ - /* stream :: A pointer to the stream object. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_ansi_stream_close + * + * @Description: + * The function to close a stream. + * + * @Input: + * stream :: + * A pointer to the stream object. + */ FT_CALLBACK_DEF( void ) ft_ansi_stream_close( FT_Stream stream ) { @@ -175,28 +184,32 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_ansi_stream_io */ - /* */ - /* <Description> */ - /* The function to open a stream. */ - /* */ - /* <Input> */ - /* stream :: A pointer to the stream object. */ - /* */ - /* offset :: The position in the data stream to start reading. */ - /* */ - /* buffer :: The address of buffer to store the read data. */ - /* */ - /* count :: The number of bytes to read from the stream. */ - /* */ - /* <Return> */ - /* The number of bytes actually read. If `count' is zero (this is, */ - /* the function is used for seeking), a non-zero return value */ - /* indicates an error. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_ansi_stream_io + * + * @Description: + * The function to open a stream. + * + * @Input: + * stream :: + * A pointer to the stream object. + * + * offset :: + * The position in the data stream to start reading. + * + * buffer :: + * The address of buffer to store the read data. + * + * count :: + * The number of bytes to read from the stream. + * + * @Return: + * The number of bytes actually read. If `count' is zero (this is, + * the function is used for seeking), a non-zero return value + * indicates an error. + */ FT_CALLBACK_DEF( unsigned long ) ft_ansi_stream_io( FT_Stream stream, unsigned long offset, diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c b/src/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c index d6dd098c426..38721977c78 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/fttrigon.c @@ -1,33 +1,33 @@ -/***************************************************************************/ -/* */ -/* fttrigon.c */ -/* */ -/* FreeType trigonometric functions (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This is a fixed-point CORDIC implementation of trigonometric */ - /* functions as well as transformations between Cartesian and polar */ - /* coordinates. The angles are represented as 16.16 fixed-point values */ - /* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */ - /* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */ - /* discrete Cartesian grid can have the same or better angular */ - /* resolution. Therefore, to maintain this precision, some functions */ - /* require an interim upscaling of the vectors, whereas others operate */ - /* with 24-bit long vectors directly. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * fttrigon.c + * + * FreeType trigonometric functions (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This is a fixed-point CORDIC implementation of trigonometric + * functions as well as transformations between Cartesian and polar + * coordinates. The angles are represented as 16.16 fixed-point values + * in degrees, i.e., the angular resolution is 2^-16 degrees. Note that + * only vectors longer than 2^16*180/pi (or at least 22 bits) on a + * discrete Cartesian grid can have the same or better angular + * resolution. Therefore, to maintain this precision, some functions + * require an interim upscaling of the vectors, whereas others operate + * with 24-bit long vectors directly. + * + */ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H @@ -325,10 +325,10 @@ FT_EXPORT_DEF( FT_Fixed ) FT_Tan( FT_Angle angle ) { - FT_Vector v; + FT_Vector v = { 1 << 24, 0 }; - FT_Vector_Unit( &v, angle ); + ft_trig_pseudo_rotate( &v, angle ); return FT_DivFix( v.y, v.x ); } @@ -372,14 +372,6 @@ } - /* these macros return 0 for positive numbers, - and -1 for negative ones */ -#define FT_SIGN_LONG( x ) ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) ) -#define FT_SIGN_INT( x ) ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) ) -#define FT_SIGN_INT32( x ) ( (x) >> 31 ) -#define FT_SIGN_INT16( x ) ( (x) >> 15 ) - - /* documentation is in fttrigon.h */ FT_EXPORT_DEF( void ) @@ -408,8 +400,8 @@ FT_Int32 half = (FT_Int32)1L << ( shift - 1 ); - vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; - vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift; + vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift; + vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift; } else { diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/fttype1.c b/src/src/java.desktop/share/native/libfreetype/src/base/fttype1.c index aa8f8ccbbb4..26d4f1c3a8a 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/fttype1.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/fttype1.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttype1.c */ -/* */ -/* FreeType utility file for PS names support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttype1.c + * + * FreeType utility file for PS names support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/ftutil.c b/src/src/java.desktop/share/native/libfreetype/src/base/ftutil.c index 4de5f2c145d..92bd857e922 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/base/ftutil.c +++ b/src/src/java.desktop/share/native/libfreetype/src/base/ftutil.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftutil.c */ -/* */ -/* FreeType utility file for memory and list management (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftutil.c + * + * FreeType utility file for memory and list management (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -23,14 +23,14 @@ #include FT_LIST_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_memory +#define FT_COMPONENT memory /*************************************************************************/ @@ -54,7 +54,7 @@ FT_Error error; FT_Pointer block = ft_mem_qalloc( memory, size, &error ); - if ( !error && size > 0 ) + if ( !error && block && size > 0 ) FT_MEM_ZERO( block, size ); *p_error = error; @@ -101,7 +101,7 @@ block = ft_mem_qrealloc( memory, item_size, cur_count, new_count, block, &error ); - if ( !error && new_count > cur_count ) + if ( !error && block && new_count > cur_count ) FT_MEM_ZERO( (char*)block + cur_count * item_size, ( new_count - cur_count ) * item_size ); @@ -185,7 +185,7 @@ FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error ); - if ( !error && address ) + if ( !error && address && size > 0 ) ft_memcpy( p, address, size ); *p_error = error; @@ -236,7 +236,7 @@ /*************************************************************************/ #undef FT_COMPONENT -#define FT_COMPONENT trace_list +#define FT_COMPONENT list /* documentation is in ftlist.h */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/md5.c b/src/src/java.desktop/share/native/libfreetype/src/base/md5.c deleted file mode 100644 index 90d0ff268d3..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/base/md5.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. - * MD5 Message-Digest Algorithm (RFC 1321). - * - * Homepage: - * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 - * - * Author: - * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> - * - * This software was written by Alexander Peslyak in 2001. No copyright is - * claimed, and the software is hereby placed in the public domain. - * In case this attempt to disclaim copyright and place the software in the - * public domain is deemed null and void, then the software is - * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - * general public under the following terms: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * There's ABSOLUTELY NO WARRANTY, express or implied. - * - * (This is a heavily cut-down "BSD license".) - * - * This differs from Colin Plumb's older public domain implementation in that - * no exactly 32-bit integer data type is required (any 32-bit or wider - * unsigned integer data type will do), there's no compile-time endianness - * configuration, and the function prototypes match OpenSSL's. No code from - * Colin Plumb's implementation has been reused; this comment merely compares - * the properties of the two independent implementations. - * - * The primary goals of this implementation are portability and ease of use. - * It is meant to be fast, but not as fast as possible. Some known - * optimizations are not included to reduce source code size and avoid - * compile-time configuration. - */ - -#ifndef HAVE_OPENSSL - -#include <string.h> - -#include "md5.h" - -/* - * The basic MD5 functions. - * - * F and G are optimized compared to their RFC 1321 definitions for - * architectures that lack an AND-NOT instruction, just like in Colin Plumb's - * implementation. - */ -#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) -#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) -#define H(x, y, z) (((x) ^ (y)) ^ (z)) -#define H2(x, y, z) ((x) ^ ((y) ^ (z))) -#define I(x, y, z) ((y) ^ ((x) | ~(z))) - -/* - * The MD5 transformation for all four rounds. - */ -#define STEP(f, a, b, c, d, x, t, s) \ - (a) += f((b), (c), (d)) + (x) + (t); \ - (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ - (a) += (b); - -/* - * SET reads 4 input bytes in little-endian byte order and stores them in a - * properly aligned word in host byte order. - * - * The check for little-endian architectures that tolerate unaligned memory - * accesses is just an optimization. Nothing will break if it fails to detect - * a suitable architecture. - * - * Unfortunately, this optimization may be a C strict aliasing rules violation - * if the caller's data buffer has effective type that cannot be aliased by - * MD5_u32plus. In practice, this problem may occur if these MD5 routines are - * inlined into a calling function, or with future and dangerously advanced - * link-time optimizations. For the time being, keeping these MD5 routines in - * their own translation unit avoids the problem. - */ -#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -#define SET(n) \ - (*(MD5_u32plus *)&ptr[(n) * 4]) -#define GET(n) \ - SET(n) -#else -#define SET(n) \ - (ctx->block[(n)] = \ - (MD5_u32plus)ptr[(n) * 4] | \ - ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ - ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ - ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) -#define GET(n) \ - (ctx->block[(n)]) -#endif - -/* - * This processes one or more 64-byte data blocks, but does NOT update the bit - * counters. There are no alignment requirements. - */ -static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) -{ - const unsigned char *ptr; - MD5_u32plus a, b, c, d; - MD5_u32plus saved_a, saved_b, saved_c, saved_d; - - ptr = (const unsigned char *)data; - - a = ctx->a; - b = ctx->b; - c = ctx->c; - d = ctx->d; - - do { - saved_a = a; - saved_b = b; - saved_c = c; - saved_d = d; - -/* Round 1 */ - STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) - STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) - STEP(F, c, d, a, b, SET(2), 0x242070db, 17) - STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) - STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) - STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) - STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) - STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) - STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) - STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) - STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) - STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) - STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) - STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) - STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) - STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) - -/* Round 2 */ - STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) - STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) - STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) - STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) - STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) - STEP(G, d, a, b, c, GET(10), 0x02441453, 9) - STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) - STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) - STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) - STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) - STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) - STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) - STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) - STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) - STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) - STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) - -/* Round 3 */ - STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) - STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) - STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) - STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) - STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) - STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) - STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) - STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) - STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) - STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) - STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) - STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) - STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) - STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) - STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) - STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) - -/* Round 4 */ - STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) - STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) - STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) - STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) - STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) - STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) - STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) - STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) - STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) - STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) - STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) - STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) - STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) - STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) - STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) - STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) - - a += saved_a; - b += saved_b; - c += saved_c; - d += saved_d; - - ptr += 64; - } while (size -= 64); - - ctx->a = a; - ctx->b = b; - ctx->c = c; - ctx->d = d; - - return ptr; -} - -void MD5_Init(MD5_CTX *ctx) -{ - ctx->a = 0x67452301; - ctx->b = 0xefcdab89; - ctx->c = 0x98badcfe; - ctx->d = 0x10325476; - - ctx->lo = 0; - ctx->hi = 0; -} - -void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) -{ - MD5_u32plus saved_lo; - unsigned long used, available; - - saved_lo = ctx->lo; - if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) - ctx->hi++; - ctx->hi += size >> 29; - - used = saved_lo & 0x3f; - - if (used) { - available = 64 - used; - - if (size < available) { - memcpy(&ctx->buffer[used], data, size); - return; - } - - memcpy(&ctx->buffer[used], data, available); - data = (const unsigned char *)data + available; - size -= available; - body(ctx, ctx->buffer, 64); - } - - if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); - size &= 0x3f; - } - - memcpy(ctx->buffer, data, size); -} - -#define OUT(dst, src) \ - (dst)[0] = (unsigned char)(src); \ - (dst)[1] = (unsigned char)((src) >> 8); \ - (dst)[2] = (unsigned char)((src) >> 16); \ - (dst)[3] = (unsigned char)((src) >> 24); - -void MD5_Final(unsigned char *result, MD5_CTX *ctx) -{ - unsigned long used, available; - - used = ctx->lo & 0x3f; - - ctx->buffer[used++] = 0x80; - - available = 64 - used; - - if (available < 8) { - memset(&ctx->buffer[used], 0, available); - body(ctx, ctx->buffer, 64); - used = 0; - available = 64; - } - - memset(&ctx->buffer[used], 0, available - 8); - - ctx->lo <<= 3; - OUT(&ctx->buffer[56], ctx->lo) - OUT(&ctx->buffer[60], ctx->hi) - - body(ctx, ctx->buffer, 64); - - OUT(&result[0], ctx->a) - OUT(&result[4], ctx->b) - OUT(&result[8], ctx->c) - OUT(&result[12], ctx->d) - - memset(ctx, 0, sizeof(*ctx)); -} - -#endif diff --git a/src/src/java.desktop/share/native/libfreetype/src/base/md5.h b/src/src/java.desktop/share/native/libfreetype/src/base/md5.h deleted file mode 100644 index 2cbda9b87ae..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/base/md5.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. - * MD5 Message-Digest Algorithm (RFC 1321). - * - * Homepage: - * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 - * - * Author: - * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> - * - * This software was written by Alexander Peslyak in 2001. No copyright is - * claimed, and the software is hereby placed in the public domain. - * In case this attempt to disclaim copyright and place the software in the - * public domain is deemed null and void, then the software is - * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - * general public under the following terms: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * There's ABSOLUTELY NO WARRANTY, express or implied. - * - * See md5.c for more information. - */ - -#ifdef HAVE_OPENSSL -#include <openssl/md5.h> -#elif !defined(_MD5_H) -#define _MD5_H - -/* Any 32-bit or wider unsigned integer data type will do */ -typedef unsigned int MD5_u32plus; - -typedef struct { - MD5_u32plus lo, hi; - MD5_u32plus a, b, c, d; - unsigned char buffer[64]; - MD5_u32plus block[16]; -} MD5_CTX; - -extern void MD5_Init(MD5_CTX *ctx); -extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); -extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); - -#endif diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c index e45ae1127bf..15cc94cafb0 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffcmap.c */ -/* */ -/* CFF character mapping table (cmap) support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffcmap.c + * + * CFF character mapping table (cmap) support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -161,6 +161,9 @@ if ( !charset->sids ) return FT_THROW( No_Unicode_Glyph_Name ); + if ( !psnames->unicodes_init ) + return FT_THROW( Unimplemented_Feature ); + return psnames->unicodes_init( memory, unicodes, cff->num_glyphs, diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h index 856a43dd1b9..07366bc7486 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffcmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffcmap.h */ -/* */ -/* CFF character mapping table (cmap) support (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffcmap.h + * + * CFF character mapping table (cmap) support (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFCMAP_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c index df896848da4..bbd5c403297 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdrivr.c */ -/* */ -/* OpenType font driver implementation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdrivr.c + * + * OpenType font driver implementation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -42,7 +42,6 @@ #endif #include "cfferrs.h" -#include "cffpic.h" #include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_GLYPH_DICT_H @@ -50,14 +49,14 @@ #include FT_DRIVER_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffdriver +#define FT_COMPONENT cffdriver /*************************************************************************/ @@ -73,38 +72,42 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_get_kerning */ - /* */ - /* <Description> */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* <Output> */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this function. Other layouts, or more sophisticated */ - /* kernings, are out of scope of this method (the basic driver */ - /* interface is meant to be simple). */ - /* */ - /* They can be implemented by format-specific interfaces. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_get_kerning + * + * @Description: + * A driver method used to return the kerning vector between two + * glyphs of the same face. + * + * @Input: + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * @Output: + * kerning :: + * The kerning vector. This is in font units for + * scalable formats, and in pixels for fixed-sizes + * formats. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only horizontal layouts (left-to-right & right-to-left) are + * supported by this function. Other layouts, or more sophisticated + * kernings, are out of scope of this method (the basic driver + * interface is meant to be simple). + * + * They can be implemented by format-specific interfaces. + */ FT_CALLBACK_DEF( FT_Error ) cff_get_kerning( FT_Face ttface, /* TT_Face */ FT_UInt left_glyph, @@ -125,32 +128,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_glyph_load */ - /* */ - /* <Description> */ - /* A driver method used to load a glyph within a given glyph slot. */ - /* */ - /* <Input> */ - /* slot :: A handle to the target slot object where the glyph */ - /* will be loaded. */ - /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled, loaded, etc. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_??? constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_glyph_load + * + * @Description: + * A driver method used to load a glyph within a given glyph slot. + * + * @Input: + * slot :: + * A handle to the target slot object where the glyph + * will be loaded. + * + * size :: + * A handle to the source face size at which the glyph + * must be scaled, loaded, etc. + * + * glyph_index :: + * The index of the glyph in the font file. + * + * load_flags :: + * A flag indicating what to load for this glyph. The + * FT_LOAD_??? constants can be used to control the + * glyph loading process (e.g., whether the outline + * should be scaled, whether to load bitmaps or not, + * whether to hint the outline, etc). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_CALLBACK_DEF( FT_Error ) cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ FT_Size cffsize, /* CFF_Size */ @@ -302,7 +309,7 @@ /* - * GLYPH DICT SERVICE + * GLYPH DICT SERVICE * */ @@ -341,7 +348,7 @@ FT_ERROR(( "cff_get_glyph_name:" " cannot get glyph name from a CFF2 font\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } @@ -352,7 +359,7 @@ FT_ERROR(( "cff_get_glyph_name:" " cannot get glyph name from CFF & CEF fonts\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } @@ -408,7 +415,7 @@ FT_ERROR(( "cff_get_name_index:" " cannot get glyph index from a CFF2 font\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); return 0; } } @@ -446,7 +453,7 @@ /* - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -593,7 +600,7 @@ /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -654,8 +661,8 @@ FT_Library library = FT_FACE_LIBRARY( face ); - if ( cmap->clazz != &CFF_CMAP_ENCODING_CLASS_REC_GET && - cmap->clazz != &CFF_CMAP_UNICODE_CLASS_REC_GET ) + if ( cmap->clazz != &cff_cmap_encoding_class_rec && + cmap->clazz != &cff_cmap_unicode_class_rec ) { FT_Module sfnt = FT_Get_Module( library, "sfnt" ); FT_Service_TTCMaps service = @@ -682,7 +689,7 @@ /* - * CID INFO SERVICE + * CID INFO SERVICE * */ static FT_Error @@ -788,7 +795,7 @@ goto Fail; } - if ( glyph_index > cff->num_glyphs ) + if ( glyph_index >= cff->num_glyphs ) { error = FT_THROW( Invalid_Argument ); goto Fail; @@ -818,7 +825,7 @@ /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ @@ -832,7 +839,7 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* - * MULTIPLE MASTER SERVICE + * MULTIPLE MASTER SERVICE * */ @@ -860,6 +867,30 @@ } + static FT_Error + cff_set_mm_weightvector( CFF_Face face, + FT_UInt len, + FT_Fixed* weightvector ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->set_mm_weightvector( FT_FACE( face ), len, weightvector ); + } + + + static FT_Error + cff_get_mm_weightvector( CFF_Face face, + FT_UInt* len, + FT_Fixed* weightvector ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->get_mm_weightvector( FT_FACE( face ), len, weightvector ); + } + + static FT_Error cff_get_mm_var( CFF_Face face, FT_MM_Var* *master ) @@ -909,22 +940,24 @@ FT_DEFINE_SERVICE_MULTIMASTERSREC( cff_service_multi_masters, - (FT_Get_MM_Func) NULL, /* get_mm */ - (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ - (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ - (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ - (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ - (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */ - (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */ - (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ - - (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ - (FT_Done_Blend_Func) cff_done_blend /* done_blend */ + (FT_Get_MM_Func) NULL, /* get_mm */ + (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ + (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ + (FT_Set_Var_Design_Func) cff_set_var_design, /* set_var_design */ + (FT_Get_Var_Design_Func) cff_get_var_design, /* get_var_design */ + (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ + (FT_Set_MM_WeightVector_Func)cff_set_mm_weightvector, /* set_mm_weightvector */ + (FT_Get_MM_WeightVector_Func)cff_get_mm_weightvector, /* get_mm_weightvector */ + + (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ + (FT_Done_Blend_Func) cff_done_blend /* done_blend */ ) /* - * METRICS VARIATIONS SERVICE + * METRICS VARIATIONS SERVICE * */ @@ -968,7 +1001,7 @@ /* - * CFFLOAD SERVICE + * CFFLOAD SERVICE * */ @@ -1001,54 +1034,54 @@ cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, - FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters, + FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_variations, + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES FT_DEFINE_SERVICEDESCREC8( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_DEFINE_SERVICEDESCREC9( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, - FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters, + FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_var, + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #else FT_DEFINE_SERVICEDESCREC7( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #endif @@ -1062,27 +1095,16 @@ FT_Module_Interface result; - /* CFF_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - if ( !driver ) - return NULL; - library = driver->library; - if ( !library ) - return NULL; -#endif - - result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface ); + result = ft_service_list_lookup( cff_services, module_interface ); if ( result ) return result; - /* `driver' is not yet evaluated in non-PIC mode */ -#ifndef FT_CONFIG_OPTION_PIC + /* `driver' is not yet evaluated */ if ( !driver ) return NULL; library = driver->library; if ( !library ) return NULL; -#endif /* we pass our request to the `sfnt' module */ sfnt = FT_Get_Module( library, "sfnt" ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h index ad7c3ad70a8..f2bbcfe4f11 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdrivr.h */ -/* */ -/* High-level OpenType driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdrivr.h + * + * High-level OpenType driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFDRIVER_H_ @@ -26,10 +26,8 @@ FT_BEGIN_HEADER - FT_DECLARE_DRIVER( cff_driver_class ) - FT_END_HEADER #endif /* CFFDRIVER_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h index b2e1bfaf9db..78d47a156db 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cfferrs.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* cfferrs.h */ -/* */ -/* CFF error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the CFF error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * cfferrs.h + * + * CFF error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the CFF error enumeration constants. + * + */ #ifndef CFFERRS_H_ #define CFFERRS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c index c58471ce861..36aa7d1b9ca 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffgload.c */ -/* */ -/* OpenType Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffgload.c + * + * OpenType Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +31,14 @@ #include "cfferrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffgload +#define FT_COMPONENT cffgload FT_LOCAL_DEF( FT_Error ) @@ -280,16 +280,16 @@ glyph->root.outline.n_points = 0; glyph->root.outline.n_contours = 0; - glyph->root.metrics.width = (FT_Pos)metrics.width << 6; - glyph->root.metrics.height = (FT_Pos)metrics.height << 6; + glyph->root.metrics.width = (FT_Pos)metrics.width * 64; + glyph->root.metrics.height = (FT_Pos)metrics.height * 64; - glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; - glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; - glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; + glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX * 64; + glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY * 64; + glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance * 64; - glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; - glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; - glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; + glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX * 64; + glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY * 64; + glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance * 64; glyph->root.format = FT_GLYPH_FORMAT_BITMAP; @@ -414,7 +414,7 @@ decoder.width_only = TRUE; decoder.builder.no_recurse = - (FT_Bool)( load_flags & FT_LOAD_NO_RECURSE ); + FT_BOOL( load_flags & FT_LOAD_NO_RECURSE ); /* now load the unscaled outline */ error = cff_get_glyph_data( face, glyph_index, diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h index 803f3974fc7..754c55acf9e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffgload.h */ -/* */ -/* OpenType Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffgload.h + * + * OpenType Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFGLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.c index 1c6fe515667..12efd18dc4b 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffload.c */ -/* */ -/* OpenType and CFF data/program tables loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffload.c + * + * OpenType and CFF data/program tables loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -196,14 +196,14 @@ } - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffload +#define FT_COMPONENT cffload /* read an offset from the index's stream current position */ @@ -1398,7 +1398,14 @@ FT_UInt master; - FT_ASSERT( lenNDV == 0 || NDV ); + /* protect against malformed fonts */ + if ( !( lenNDV == 0 || NDV ) ) + { + FT_TRACE4(( " cff_blend_build_vector:" + " Malformed Normalize Design Vector data\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } blend->builtBV = FALSE; @@ -2080,13 +2087,13 @@ /* * Initialize the random number generator. * - * . If we have a face-specific seed, use it. + * - If we have a face-specific seed, use it. * If non-zero, update it to a positive value. * - * . Otherwise, use the seed from the CFF driver. + * - Otherwise, use the seed from the CFF driver. * If non-zero, update it to a positive value. * - * . If the random value is zero, use the seed given by the subfont's + * - If the random value is zero, use the seed given by the subfont's * `initialRandomSeed' value. * */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.h index 14d14e21122..42d2696f33c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffload.h */ -/* */ -/* OpenType & CFF data/program tables loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffload.h + * + * OpenType & CFF data/program tables loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c index a2d7aec65ef..1a1030c0650 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffobjs.c */ -/* */ -/* OpenType objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffobjs.c + * + * OpenType objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -37,7 +37,6 @@ #include "cffobjs.h" #include "cffload.h" #include "cffcmap.h" -#include "cffpic.h" #include "cfferrs.h" @@ -45,21 +44,21 @@ #include FT_SERVICE_CFF_TABLE_LOAD_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffobjs +#define FT_COMPONENT cffobjs - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ static PSH_Globals_Funcs @@ -341,11 +340,11 @@ } - /*************************************************************************/ - /* */ - /* SLOT FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SLOT FUNCTIONS + * + */ FT_LOCAL_DEF( void ) cff_slot_done( FT_GlyphSlot slot ) @@ -383,11 +382,11 @@ } - /*************************************************************************/ - /* */ - /* FACE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * FACE FUNCTIONS + * + */ static FT_String* cff_strcpy( FT_Memory memory, @@ -645,14 +644,14 @@ dict = &cff->top_font.font_dict; - /* we need the `PSNames' module for CFF and CEF formats */ + /* we need the `psnames' module for CFF and CEF formats */ /* which aren't CID-keyed */ if ( dict->cid_registry == 0xFFFFU && !psnames ) { FT_ERROR(( "cff_face_init:" " cannot open CFF & CEF fonts\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } @@ -965,10 +964,10 @@ /* assume "Regular" style if we don't know better */ cffface->style_name = cff_strcpy( memory, (char *)"Regular" ); - /*******************************************************************/ - /* */ - /* Compute face flags. */ - /* */ + /******************************************************************** + * + * Compute face flags. + */ flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ FT_FACE_FLAG_HINTER; /* has native hinter */ @@ -989,10 +988,10 @@ cffface->face_flags |= flags; - /*******************************************************************/ - /* */ - /* Compute style flags. */ - /* */ + /******************************************************************** + * + * Compute style flags. + */ flags = 0; if ( dict->italic_angle ) @@ -1028,10 +1027,10 @@ if ( dict->cid_registry != 0xFFFFU && pure_cff ) cffface->face_flags |= FT_FACE_FLAG_CID_KEYED; - /*******************************************************************/ - /* */ - /* Compute char maps. */ - /* */ + /******************************************************************** + * + * Compute char maps. + */ /* Try to synthesize a Unicode charmap if there is none available */ /* already. If an OpenType font contains a Unicode "cmap", we */ @@ -1070,10 +1069,11 @@ nn = (FT_UInt)cffface->num_charmaps; - error = FT_CMap_New( &CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, + error = FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -1094,19 +1094,19 @@ { cmaprec.encoding_id = TT_ADOBE_ID_STANDARD; cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD; - clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; + clazz = &cff_cmap_encoding_class_rec; } else if ( encoding->offset == 1 ) { cmaprec.encoding_id = TT_ADOBE_ID_EXPERT; cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT; - clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; + clazz = &cff_cmap_encoding_class_rec; } else { cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM; cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM; - clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; + clazz = &cff_cmap_encoding_class_rec; } error = FT_CMap_New( clazz, NULL, &cmaprec, NULL ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h index 616a25b3b59..03bc78a67f4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffobjs.h */ -/* */ -/* OpenType objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffobjs.h + * + * OpenType objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFOBJS_H_ @@ -51,10 +51,10 @@ FT_BEGIN_HEADER cff_slot_init( FT_GlyphSlot slot ); - /*************************************************************************/ - /* */ - /* Face functions */ - /* */ + /************************************************************************** + * + * Face functions + */ FT_LOCAL( FT_Error ) cff_face_init( FT_Stream stream, FT_Face face, /* CFF_Face */ @@ -66,10 +66,10 @@ FT_BEGIN_HEADER cff_face_done( FT_Face face ); /* CFF_Face */ - /*************************************************************************/ - /* */ - /* Driver functions */ - /* */ + /************************************************************************** + * + * Driver functions + */ FT_LOCAL( FT_Error ) cff_driver_init( FT_Module module ); /* PS_Driver */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c index b9611cf548a..fa806f1a905 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffparse.c */ -/* */ -/* CFF token stream parser (body) */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffparse.c + * + * CFF token stream parser (body) + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -22,20 +22,20 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_CALC_H #include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_LIST_H #include "cfferrs.h" -#include "cffpic.h" #include "cffload.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffparse +#define FT_COMPONENT cffparse FT_LOCAL_DEF( FT_Error ) @@ -605,7 +605,6 @@ FT_Vector* offset = &dict->font_offset; FT_ULong* upm = &dict->units_per_em; FT_Byte** data = parser->stack; - FT_Error error = FT_ERR( Stack_Underflow ); if ( parser->top >= parser->stack + 6 ) @@ -617,8 +616,6 @@ int i; - error = FT_Err_Ok; - dict->has_font_matrix = TRUE; /* We expect a well-formed font matrix, this is, the matrix elements */ @@ -647,22 +644,11 @@ ( max_scaling - min_scaling ) < 0 || ( max_scaling - min_scaling ) > 9 ) { - /* Return default matrix in case of unlikely values. */ - FT_TRACE1(( "cff_parse_font_matrix:" " strange scaling values (minimum %d, maximum %d),\n" " " " using default matrix\n", min_scaling, max_scaling )); - - matrix->xx = 0x10000L; - matrix->yx = 0; - matrix->xy = 0; - matrix->yy = 0x10000L; - offset->x = 0; - offset->y = 0; - *upm = 1; - - goto Exit; + goto Unlikely; } for ( i = 0; i < 6; i++ ) @@ -709,10 +695,31 @@ (double)matrix->yy / *upm / 65536, (double)offset->x / *upm / 65536, (double)offset->y / *upm / 65536 )); + + if ( !FT_Matrix_Check( matrix ) ) + { + FT_TRACE1(( "cff_parse_font_matrix:" + " degenerate values, using default matrix\n" )); + goto Unlikely; + } + + return FT_Err_Ok; } + else + return FT_THROW( Stack_Underflow ); - Exit: - return error; + Unlikely: + /* Return default matrix in case of unlikely values. */ + + matrix->xx = 0x10000L; + matrix->yx = 0; + matrix->xy = 0; + matrix->yy = 0x10000L; + offset->x = 0; + offset->y = 0; + *upm = 1; + + return FT_Err_Ok; } @@ -802,7 +809,7 @@ #ifdef FT_DEBUG_LEVEL_TRACE /* beautify tracing message */ - if ( ft_trace_levels[FT_COMPONENT] < 4 ) + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] < 4 ) FT_TRACE1(( "Multiple Master CFFs not supported yet," " handling first master design only\n" )); else @@ -1003,9 +1010,6 @@ CFF_FIELD( code, name, id, cff_kind_bool ) -#ifndef FT_CONFIG_OPTION_PIC - - #undef CFF_FIELD #undef CFF_FIELD_DELTA @@ -1118,182 +1122,16 @@ #endif /* FT_DEBUG_LEVEL_TRACE */ -#else /* FT_CONFIG_OPTION_PIC */ - - - void - FT_Destroy_Class_cff_field_handlers( FT_Library library, - CFF_Field_Handler* clazz ) +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + static void + destruct_t2s_item( FT_Memory memory, + void* data, + void* user ) { - FT_Memory memory = library->memory; - - - if ( clazz ) - FT_FREE( clazz ); + FT_UNUSED( user ); + memory->free( memory, data ); } - - - FT_Error - FT_Create_Class_cff_field_handlers( FT_Library library, - CFF_Field_Handler** output_class ) - { - CFF_Field_Handler* clazz = NULL; - FT_Error error; - FT_Memory memory = library->memory; - - int i = 0; - - -#undef CFF_FIELD -#define CFF_FIELD( code, name, id, kind ) i++; -#undef CFF_FIELD_DELTA -#define CFF_FIELD_DELTA( code, name, max, id ) i++; -#undef CFF_FIELD_CALLBACK -#define CFF_FIELD_CALLBACK( code, name, id ) i++; -#undef CFF_FIELD_BLEND -#define CFF_FIELD_BLEND( code, id ) i++; - -#include "cfftoken.h" - - i++; /* { 0, 0, 0, 0, 0, 0, 0 } */ - - if ( FT_ALLOC( clazz, sizeof ( CFF_Field_Handler ) * i ) ) - return error; - - i = 0; - - -#ifndef FT_DEBUG_LEVEL_TRACE - - -#undef CFF_FIELD_CALLBACK -#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \ - clazz[i].kind = cff_kind_callback; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_ ## name_; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - i++; - -#undef CFF_FIELD -#define CFF_FIELD( code_, name_, id_, kind_ ) \ - clazz[i].kind = kind_; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - i++; \ - -#undef CFF_FIELD_DELTA -#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \ - clazz[i].kind = cff_kind_delta; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = max_; \ - clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \ - i++; - -#undef CFF_FIELD_BLEND -#define CFF_FIELD_BLEND( code_, id_ ) \ - clazz[i].kind = cff_kind_blend; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_blend; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - i++; - -#include "cfftoken.h" - - clazz[i].kind = 0; - clazz[i].code = 0; - clazz[i].offset = 0; - clazz[i].size = 0; - clazz[i].reader = 0; - clazz[i].array_max = 0; - clazz[i].count_offset = 0; - - -#else /* FT_DEBUG_LEVEL_TRACE */ - - -#undef CFF_FIELD_CALLBACK -#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \ - clazz[i].kind = cff_kind_callback; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_ ## name_; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - clazz[i].id = id_; \ - i++; - -#undef CFF_FIELD -#define CFF_FIELD( code_, name_, id_, kind_ ) \ - clazz[i].kind = kind_; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - clazz[i].id = id_; \ - i++; \ - -#undef CFF_FIELD_DELTA -#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \ - clazz[i].kind = cff_kind_delta; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = max_; \ - clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \ - clazz[i].id = id_; \ - i++; - -#undef CFF_FIELD_BLEND -#define CFF_FIELD_BLEND( code_, id_ ) \ - clazz[i].kind = cff_kind_blend; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_blend; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - clazz[i].id = id_; \ - i++; - -#include "cfftoken.h" - - clazz[i].kind = 0; - clazz[i].code = 0; - clazz[i].offset = 0; - clazz[i].size = 0; - clazz[i].reader = 0; - clazz[i].array_max = 0; - clazz[i].count_offset = 0; - clazz[i].id = 0; - - -#endif /* FT_DEBUG_LEVEL_TRACE */ - - - *output_class = clazz; - - return FT_Err_Ok; - } - - -#endif /* FT_CONFIG_OPTION_PIC */ +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ FT_LOCAL_DEF( FT_Error ) @@ -1301,17 +1139,21 @@ FT_Byte* start, FT_Byte* limit ) { + FT_Byte* p = start; + FT_Error error = FT_Err_Ok; + #ifdef CFF_CONFIG_OPTION_OLD_ENGINE PSAux_Service psaux; -#endif - FT_Byte* p = start; - FT_Error error = FT_Err_Ok; FT_Library library = parser->library; + FT_Memory memory = library->memory; - FT_UNUSED( library ); + FT_ListRec t2s; + FT_ZERO( &t2s ); +#endif + parser->top = parser->stack; parser->start = start; parser->limit = limit; @@ -1321,6 +1163,7 @@ { FT_UInt v = *p; + /* Opcode 31 is legacy MM T2 operator, not a number. */ /* Opcode 255 is reserved and should not appear in fonts; */ /* it is used internally for CFF2 blends. */ @@ -1369,8 +1212,9 @@ FT_Byte* charstring_base; FT_ULong charstring_len; - FT_Fixed* stack; - FT_Byte* q; + FT_Fixed* stack; + FT_ListNode node; + FT_Byte* q; charstring_base = ++p; @@ -1405,17 +1249,29 @@ error = psaux->cff_decoder_funcs->parse_charstrings_old( &decoder, charstring_base, charstring_len, 1 ); + if ( error ) + goto Exit; /* Now copy the stack data in the temporary decoder object, */ /* converting it back to charstring number representations */ /* (this is ugly, I know). */ - /* */ - /* We overwrite the original top DICT charstring under the */ - /* assumption that the charstring representation of the result */ - /* of `cff_decoder_parse_charstrings' is shorter, which should */ - /* be always true. */ - q = charstring_base - 1; + node = (FT_ListNode)memory->alloc( memory, + sizeof ( FT_ListNodeRec ) ); + if ( !node ) + goto Out_Of_Memory_Error; + + /* `5' is the conservative upper bound of required bytes per stack */ + /* element. */ + q = (FT_Byte*)memory->alloc( memory, + 5 * ( decoder.top - decoder.stack ) ); + if ( !q ) + goto Out_Of_Memory_Error; + + node->data = q; + + FT_List_Add( &t2s, node ); + stack = decoder.stack; while ( stack < decoder.top ) @@ -1431,7 +1287,7 @@ if ( *stack < 0 ) { - num = (FT_ULong)-*stack; + num = (FT_ULong)NEG_LONG( *stack ); neg = 1; } else @@ -1523,7 +1379,7 @@ } code = code | parser->object_code; - for ( field = CFF_FIELD_HANDLERS_GET; field->kind; field++ ) + for ( field = cff_field_handlers; field->kind; field++ ) { if ( field->code == (FT_Int)code ) { @@ -1672,11 +1528,20 @@ parser->top = parser->stack; } p++; - } + } /* while ( p < limit ) */ Exit: +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_List_Finalize( &t2s, destruct_t2s_item, memory, NULL ); +#endif return error; +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + Out_Of_Memory_Error: + error = FT_THROW( Out_Of_Memory ); + goto Exit; +#endif + Stack_Overflow: error = FT_THROW( Invalid_Argument ); goto Exit; diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h index 8a8caeca446..bac32f94491 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cffparse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffparse.h */ -/* */ -/* CFF token stream parser (specification) */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffparse.h + * + * CFF token stream parser (specification) + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFPARSE_H_ @@ -33,11 +33,11 @@ FT_BEGIN_HEADER #define CFF_MAX_STACK_DEPTH 96 /* - * There are plans to remove the `maxstack' operator in a forthcoming - * revision of the CFF2 specification, increasing the (then static) stack - * size to 513. By making the default stack size equal to the maximum - * stack size, the operator is essentially disabled, which has the - * desired effect in FreeType. + * There are plans to remove the `maxstack' operator in a forthcoming + * revision of the CFF2 specification, increasing the (then static) stack + * size to 513. By making the default stack size equal to the maximum + * stack size, the operator is essentially disabled, which has the + * desired effect in FreeType. */ #define CFF2_MAX_STACK 513 #define CFF2_DEFAULT_STACK 513 diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffpic.c b/src/src/java.desktop/share/native/libfreetype/src/cff/cffpic.c deleted file mode 100644 index 08b74c7cf20..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffpic.c +++ /dev/null @@ -1,138 +0,0 @@ -/***************************************************************************/ -/* */ -/* cffpic.c */ -/* */ -/* The FreeType position independent code services for cff module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "cffcmap.h" -#include "cffpic.h" -#include "cfferrs.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from cffdrivr.c */ - FT_Error - FT_Create_Class_cff_services( FT_Library library, - FT_ServiceDescRec** output_class ); - void - FT_Destroy_Class_cff_services( FT_Library library, - FT_ServiceDescRec* clazz ); - void - FT_Init_Class_cff_service_ps_info( FT_Library library, - FT_Service_PsInfoRec* clazz ); - void - FT_Init_Class_cff_service_glyph_dict( FT_Library library, - FT_Service_GlyphDictRec* clazz ); - void - FT_Init_Class_cff_service_ps_name( FT_Library library, - FT_Service_PsFontNameRec* clazz ); - void - FT_Init_Class_cff_service_get_cmap_info( FT_Library library, - FT_Service_TTCMapsRec* clazz ); - void - FT_Init_Class_cff_service_cid_info( FT_Library library, - FT_Service_CIDRec* clazz ); - - /* forward declaration of PIC init functions from cffparse.c */ - FT_Error - FT_Create_Class_cff_field_handlers( FT_Library library, - CFF_Field_Handler** output_class ); - void - FT_Destroy_Class_cff_field_handlers( FT_Library library, - CFF_Field_Handler* clazz ); - - - void - cff_driver_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->cff ) - { - CffModulePIC* container = (CffModulePIC*)pic_container->cff; - - - if ( container->cff_services ) - FT_Destroy_Class_cff_services( library, - container->cff_services ); - container->cff_services = NULL; - if ( container->cff_field_handlers ) - FT_Destroy_Class_cff_field_handlers( - library, container->cff_field_handlers ); - container->cff_field_handlers = NULL; - FT_FREE( container ); - pic_container->cff = NULL; - } - } - - - FT_Error - cff_driver_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - CffModulePIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC ( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->cff = container; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - error = FT_Create_Class_cff_services( library, - &container->cff_services ); - if ( error ) - goto Exit; - - error = FT_Create_Class_cff_field_handlers( - library, &container->cff_field_handlers ); - if ( error ) - goto Exit; - - FT_Init_Class_cff_service_ps_info( - library, &container->cff_service_ps_info ); - FT_Init_Class_cff_service_glyph_dict( - library, &container->cff_service_glyph_dict ); - FT_Init_Class_cff_service_ps_name( - library, &container->cff_service_ps_name ); - FT_Init_Class_cff_service_get_cmap_info( - library, &container->cff_service_get_cmap_info ); - FT_Init_Class_cff_service_cid_info( - library, &container->cff_service_cid_info ); - FT_Init_Class_cff_cmap_encoding_class_rec( - library, &container->cff_cmap_encoding_class_rec ); - FT_Init_Class_cff_cmap_unicode_class_rec( - library, &container->cff_cmap_unicode_class_rec ); - - Exit: - if ( error ) - cff_driver_class_pic_free( library ); - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cffpic.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cffpic.h deleted file mode 100644 index 8ba4203a8de..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cffpic.h +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************/ -/* */ -/* cffpic.h */ -/* */ -/* The FreeType position independent code services for cff module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CFFPIC_H_ -#define CFFPIC_H_ - - -#include FT_INTERNAL_PIC_H - -#ifndef FT_CONFIG_OPTION_PIC - -#define CFF_SERVICE_PS_INFO_GET cff_service_ps_info -#define CFF_SERVICE_GLYPH_DICT_GET cff_service_glyph_dict -#define CFF_SERVICE_PS_NAME_GET cff_service_ps_name -#define CFF_SERVICE_GET_CMAP_INFO_GET cff_service_get_cmap_info -#define CFF_SERVICE_CID_INFO_GET cff_service_cid_info -#define CFF_SERVICE_PROPERTIES_GET cff_service_properties -#define CFF_SERVICES_GET cff_services -#define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters -#define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations -#define CFF_SERVICE_CFF_LOAD_GET cff_service_cff_load -#define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec -#define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec -#define CFF_FIELD_HANDLERS_GET cff_field_handlers - -#else /* FT_CONFIG_OPTION_PIC */ - -#include FT_SERVICE_GLYPH_DICT_H -#include "cffparse.h" -#include FT_SERVICE_POSTSCRIPT_INFO_H -#include FT_SERVICE_POSTSCRIPT_NAME_H -#include FT_SERVICE_TT_CMAP_H -#include FT_SERVICE_CID_H -#include FT_SERVICE_PROPERTIES_H -#include FT_SERVICE_MULTIPLE_MASTERS_H -#include FT_SERVICE_METRICS_VARIATIONS_H - - -FT_BEGIN_HEADER - - typedef struct CffModulePIC_ - { - FT_ServiceDescRec* cff_services; - CFF_Field_Handler* cff_field_handlers; - FT_Service_PsInfoRec cff_service_ps_info; - FT_Service_GlyphDictRec cff_service_glyph_dict; - FT_Service_PsFontNameRec cff_service_ps_name; - FT_Service_TTCMapsRec cff_service_get_cmap_info; - FT_Service_CIDRec cff_service_cid_info; - FT_Service_PropertiesRec cff_service_properties; - FT_Service_MultiMastersRec cff_service_multi_masters; - FT_Service_MetricsVariationsRec cff_service_metrics_variations; - FT_Service_CFFLoadRec cff_service_cff_load; - FT_CMap_ClassRec cff_cmap_encoding_class_rec; - FT_CMap_ClassRec cff_cmap_unicode_class_rec; - - } CffModulePIC; - - -#define GET_PIC( lib ) \ - ( (CffModulePIC*)( (lib)->pic_container.cff ) ) - -#define CFF_SERVICE_PS_INFO_GET \ - ( GET_PIC( library )->cff_service_ps_info ) -#define CFF_SERVICE_GLYPH_DICT_GET \ - ( GET_PIC( library )->cff_service_glyph_dict ) -#define CFF_SERVICE_PS_NAME_GET \ - ( GET_PIC( library )->cff_service_ps_name ) -#define CFF_SERVICE_GET_CMAP_INFO_GET \ - ( GET_PIC( library )->cff_service_get_cmap_info ) -#define CFF_SERVICE_CID_INFO_GET \ - ( GET_PIC( library )->cff_service_cid_info ) -#define CFF_SERVICE_PROPERTIES_GET \ - ( GET_PIC( library )->cff_service_properties ) -#define CFF_SERVICES_GET \ - ( GET_PIC( library )->cff_services ) -#define CFF_SERVICE_MULTI_MASTERS_GET \ - ( GET_PIC( library )->cff_service_multi_masters ) -#define CFF_SERVICE_METRICS_VAR_GET \ - ( GET_PIC( library )->cff_service_metrics_variations ) -#define CFF_SERVICE_CFF_LOAD_GET \ - ( GET_PIC( library )->cff_service_cff_load ) -#define CFF_CMAP_ENCODING_CLASS_REC_GET \ - ( GET_PIC( library )->cff_cmap_encoding_class_rec ) -#define CFF_CMAP_UNICODE_CLASS_REC_GET \ - ( GET_PIC( library )->cff_cmap_unicode_class_rec ) -#define CFF_FIELD_HANDLERS_GET \ - ( GET_PIC( library )->cff_field_handlers ) - - /* see cffpic.c for the implementation */ - void - cff_driver_class_pic_free( FT_Library library ); - - FT_Error - cff_driver_class_pic_init( FT_Library library ); - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* CFFPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h b/src/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h index fec1ca20bde..063a7b3be07 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cfftoken.h */ -/* */ -/* CFF token definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cfftoken.h + * + * CFF token definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #undef FT_STRUCTURE diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h b/src/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h index a5a86e3fc68..be80bed3bea 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/ciderrs.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* ciderrs.h */ -/* */ -/* CID error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the CID error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ciderrs.h + * + * CID error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the CID error enumeration constants. + * + */ #ifndef CIDERRS_H_ #define CIDERRS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c b/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c index d14f9a2cc97..f59f2880f09 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidgload.c */ -/* */ -/* CID-keyed Type1 Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidgload.c + * + * CID-keyed Type1 Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +31,14 @@ #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidgload +#define FT_COMPONENT cidgload FT_CALLBACK_DEF( FT_Error ) @@ -393,8 +393,7 @@ must_finish_decoder = TRUE; /* set up the decoder */ - decoder.builder.no_recurse = FT_BOOL( - ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) ); + decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE ); error = cid_load_glyph( &decoder, glyph_index ); if ( error ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h b/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h index 4811852ae43..37eba7ca7be 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidgload.h */ -/* */ -/* OpenType Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidgload.h + * + * OpenType Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDGLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.c b/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.c index 27cd09b3c35..fce3e37da74 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidload.c */ -/* */ -/* CID-keyed Type1 font loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidload.c + * + * CID-keyed Type1 font loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,20 +21,21 @@ #include FT_CONFIG_CONFIG_H #include FT_MULTIPLE_MASTERS_H #include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include "cidload.h" #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidload +#define FT_COMPONENT cidload /* read a single offset */ @@ -81,6 +82,8 @@ /* if the keyword has a dedicated callback, call it */ if ( keyword->type == T1_FIELD_TYPE_CALLBACK ) { + FT_TRACE4(( " %s", keyword->ident )); + keyword->reader( (FT_Face)face, parser ); error = parser->root.error; goto Exit; @@ -131,6 +134,8 @@ } } + FT_TRACE4(( " %s", keyword->ident )); + dummy_object = object; /* now, load the keyword data in the object's field(s) */ @@ -141,12 +146,15 @@ else error = cid_parser_load_field( &loader->parser, keyword, &dummy_object ); + + FT_TRACE4(( "\n" )); + Exit: return error; } - FT_CALLBACK_DEF( FT_Error ) + FT_CALLBACK_DEF( void ) cid_parse_font_matrix( CID_Face face, CID_Parser* parser ) { @@ -171,14 +179,25 @@ result = cid_parser_to_fixed_array( parser, 6, temp, 3 ); if ( result < 6 ) - return FT_THROW( Invalid_File_Format ); + { + FT_ERROR(( "cid_parse_font_matrix: not enough matrix elements\n" )); + goto Exit; + } + + FT_TRACE4(( " [%f %f %f %f %f %f]\n", + (double)temp[0] / 65536 / 1000, + (double)temp[1] / 65536 / 1000, + (double)temp[2] / 65536 / 1000, + (double)temp[3] / 65536 / 1000, + (double)temp[4] / 65536 / 1000, + (double)temp[5] / 65536 / 1000 )); temp_scale = FT_ABS( temp[3] ); if ( temp_scale == 0 ) { FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" )); - return FT_THROW( Invalid_File_Format ); + goto Exit; } /* atypical case */ @@ -200,16 +219,24 @@ matrix->xy = temp[2]; matrix->yy = temp[3]; + if ( !FT_Matrix_Check( matrix ) ) + { + FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" )); + parser->root.error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + /* note that the font offsets are expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; } - return FT_Err_Ok; + Exit: + return; } - FT_CALLBACK_DEF( FT_Error ) + FT_CALLBACK_DEF( void ) parse_fd_array( CID_Face face, CID_Parser* parser ) { @@ -224,10 +251,11 @@ if ( num_dicts < 0 ) { FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" )); - error = FT_THROW( Invalid_File_Format ); goto Exit; } + FT_TRACE4(( " %d\n", num_dicts )); + /* * A single entry in the FDArray must (at least) contain the following * structure elements. @@ -263,27 +291,31 @@ cid->num_dicts = num_dicts; - /* don't forget to set a few defaults */ + /* set some default values (the same as for Type 1 fonts) */ for ( n = 0; n < cid->num_dicts; n++ ) { CID_FaceDict dict = cid->font_dicts + n; - /* default value for lenIV */ - dict->private_dict.lenIV = 4; + dict->private_dict.blue_shift = 7; + dict->private_dict.blue_fuzz = 1; + dict->private_dict.lenIV = 4; + dict->private_dict.expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); + dict->private_dict.blue_scale = (FT_Fixed)( + 0.039625 * 0x10000L * 1000 ); } } Exit: - return error; + return; } - /* by mistake, `expansion_factor' appears both in PS_PrivateRec */ + /* By mistake, `expansion_factor' appears both in PS_PrivateRec */ /* and CID_FaceDictRec (both are public header files and can't */ - /* changed); we simply copy the value */ + /* changed). We simply copy the value. */ - FT_CALLBACK_DEF( FT_Error ) + FT_CALLBACK_DEF( void ) parse_expansion_factor( CID_Face face, CID_Parser* parser ) { @@ -296,9 +328,43 @@ dict->expansion_factor = cid_parser_to_fixed( parser, 0 ); dict->private_dict.expansion_factor = dict->expansion_factor; + + FT_TRACE4(( "%d\n", dict->expansion_factor )); + } + + return; + } + + + /* By mistake, `CID_FaceDictRec' doesn't contain a field for the */ + /* `FontName' keyword. FreeType doesn't need it, but it is nice */ + /* to catch it for producing better trace output. */ + + FT_CALLBACK_DEF( void ) + parse_font_name( CID_Face face, + CID_Parser* parser ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts ) + { + T1_TokenRec token; + FT_UInt len; + + + cid_parser_to_token( parser, &token ); + + len = (FT_UInt)( token.limit - token.start ); + if ( len ) + FT_TRACE4(( " %.*s\n", len, token.start )); + else + FT_TRACE4(( " <no value>\n" )); } +#else + FT_UNUSED( face ); + FT_UNUSED( parser ); +#endif - return FT_Err_Ok; + return; } @@ -311,6 +377,7 @@ T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 ) T1_FIELD_CALLBACK( "FontMatrix", cid_parse_font_matrix, 0 ) T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 ) + T1_FIELD_CALLBACK( "FontName", parse_font_name, 0 ) { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 } }; @@ -356,7 +423,16 @@ /* if /FDArray was found, then cid->num_dicts is > 0, and */ /* we can start increasing parser->num_dict */ if ( face->cid.num_dicts > 0 ) + { parser->num_dict++; + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " FontDict %d", parser->num_dict )); + if ( parser->num_dict > face->cid.num_dicts ) + FT_TRACE4(( " (ignored)" )); + FT_TRACE4(( "\n" )); +#endif + } } } @@ -757,7 +833,7 @@ if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 ) { - FT_ERROR(( "cid_parse_dict:" + FT_ERROR(( "cid_face_open:" " Invalid `FDBytes' or `GDBytes' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; @@ -766,7 +842,7 @@ /* allow at most 32bit offsets */ if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 ) { - FT_ERROR(( "cid_parse_dict:" + FT_ERROR(( "cid_face_open:" " Values of `FDBytes' or `GDBytes' larger than 4\n" " " " are not supported\n" )); @@ -782,17 +858,36 @@ CID_FaceDict dict = cid->font_dicts + n; + /* the upper limits are ad-hoc values */ + if ( dict->private_dict.blue_shift > 1000 || + dict->private_dict.blue_shift < 0 ) + { + FT_TRACE2(( "cid_face_open:" + " setting unlikely BlueShift value %d to default (7)\n", + dict->private_dict.blue_shift )); + dict->private_dict.blue_shift = 7; + } + + if ( dict->private_dict.blue_fuzz > 1000 || + dict->private_dict.blue_fuzz < 0 ) + { + FT_TRACE2(( "cid_face_open:" + " setting unlikely BlueFuzz value %d to default (1)\n", + dict->private_dict.blue_fuzz )); + dict->private_dict.blue_fuzz = 1; + } + if ( dict->sd_bytes < 0 || ( dict->num_subrs && dict->sd_bytes < 1 ) ) { - FT_ERROR(( "cid_parse_dict: Invalid `SDBytes' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `SDBytes' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } if ( dict->sd_bytes > 4 ) { - FT_ERROR(( "cid_parse_dict:" + FT_ERROR(( "cid_face_open:" " Values of `SDBytes' larger than 4" " are not supported\n" )); error = FT_THROW( Invalid_File_Format ); @@ -801,7 +896,7 @@ if ( dict->subrmap_offset > binary_length ) { - FT_ERROR(( "cid_parse_dict: Invalid `SubrMapOffset' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `SubrMapOffset' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -812,7 +907,7 @@ dict->num_subrs > ( binary_length - dict->subrmap_offset ) / (FT_UInt)dict->sd_bytes ) ) { - FT_ERROR(( "cid_parse_dict: Invalid `SubrCount' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `SubrCount' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -820,7 +915,7 @@ if ( cid->cidmap_offset > binary_length ) { - FT_ERROR(( "cid_parse_dict: Invalid `CIDMapOffset' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `CIDMapOffset' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -829,7 +924,7 @@ cid->cid_count > ( binary_length - cid->cidmap_offset ) / entry_len ) { - FT_ERROR(( "cid_parse_dict: Invalid `CIDCount' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `CIDCount' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.h b/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.h index 3f8bd08620a..fb9d46216d0 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidload.h */ -/* */ -/* CID-keyed Type1 font loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidload.h + * + * CID-keyed Type1 font loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c b/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c index 77afe1c8751..4e9728719b7 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidobjs.c */ -/* */ -/* CID objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidobjs.c + * + * CID objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,21 +31,21 @@ #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidobjs +#define FT_COMPONENT cidobjs - /*************************************************************************/ - /* */ - /* SLOT FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SLOT FUNCTIONS + * + */ FT_LOCAL_DEF( void ) cid_slot_done( FT_GlyphSlot slot ) @@ -85,11 +85,11 @@ } - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ static PSH_Globals_Funcs @@ -174,23 +174,24 @@ } - /*************************************************************************/ - /* */ - /* FACE FUNCTIONS */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_face_done */ - /* */ - /* <Description> */ - /* Finalizes a given face object. */ - /* */ - /* <Input> */ - /* face :: A pointer to the face object to destroy. */ - /* */ + /************************************************************************** + * + * FACE FUNCTIONS + * + */ + + /************************************************************************** + * + * @Function: + * cid_face_done + * + * @Description: + * Finalizes a given face object. + * + * @Input: + * face :: + * A pointer to the face object to destroy. + */ FT_LOCAL_DEF( void ) cid_face_done( FT_Face cidface ) /* CID_Face */ { @@ -252,29 +253,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_face_init */ - /* */ - /* <Description> */ - /* Initializes a given CID face object. */ - /* */ - /* <Input> */ - /* stream :: The source font stream. */ - /* */ - /* face_index :: The index of the font face in the resource. */ - /* */ - /* num_params :: Number of additional generic parameters. Ignored. */ - /* */ - /* params :: Additional generic parameters. Ignored. */ - /* */ - /* <InOut> */ - /* face :: The newly built face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cid_face_init + * + * @Description: + * Initializes a given CID face object. + * + * @Input: + * stream :: + * The source font stream. + * + * face_index :: + * The index of the font face in the resource. + * + * num_params :: + * Number of additional generic parameters. Ignored. + * + * params :: + * Additional generic parameters. Ignored. + * + * @InOut: + * face :: + * The newly built face object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) cid_face_init( FT_Stream stream, FT_Face cidface, /* CID_Face */ @@ -449,20 +455,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_driver_init */ - /* */ - /* <Description> */ - /* Initializes a given CID driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cid_driver_init + * + * @Description: + * Initializes a given CID driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) cid_driver_init( FT_Module module ) { @@ -505,17 +512,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_driver_done */ - /* */ - /* <Description> */ - /* Finalizes a given CID driver. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target CID driver. */ - /* */ + /************************************************************************** + * + * @Function: + * cid_driver_done + * + * @Description: + * Finalizes a given CID driver. + * + * @Input: + * driver :: + * A handle to the target CID driver. + */ FT_LOCAL_DEF( void ) cid_driver_done( FT_Module driver ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h b/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h index 0221f017dd2..89c9aa74ab8 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidobjs.h */ -/* */ -/* CID objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidobjs.h + * + * CID objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDOBJS_H_ @@ -34,60 +34,60 @@ FT_BEGIN_HEADER typedef struct CID_Glyph_Hints_ CID_Glyph_Hints; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_Driver */ - /* */ - /* <Description> */ - /* A handle to a Type 1 driver object. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_Driver + * + * @Description: + * A handle to a Type 1 driver object. + */ typedef struct CID_DriverRec_* CID_Driver; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_Size */ - /* */ - /* <Description> */ - /* A handle to a Type 1 size object. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_Size + * + * @Description: + * A handle to a Type 1 size object. + */ typedef struct CID_SizeRec_* CID_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a Type 1 glyph slot object. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_GlyphSlot + * + * @Description: + * A handle to a Type 1 glyph slot object. + */ typedef struct CID_GlyphSlotRec_* CID_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_CharMap */ - /* */ - /* <Description> */ - /* A handle to a Type 1 character mapping object. */ - /* */ - /* <Note> */ - /* The Type 1 format doesn't use a charmap but an encoding table. */ - /* The driver is responsible for making up charmap objects */ - /* corresponding to these tables. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_CharMap + * + * @Description: + * A handle to a Type 1 character mapping object. + * + * @Note: + * The Type 1 format doesn't use a charmap but an encoding table. + * The driver is responsible for making up charmap objects + * corresponding to these tables. + */ typedef struct CID_CharMapRec_* CID_CharMap; - /*************************************************************************/ - /* */ - /* HERE BEGINS THE TYPE 1 SPECIFIC STUFF */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * HERE BEGINS THE TYPE 1 SPECIFIC STUFF + * + */ typedef struct CID_SizeRec_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c b/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c index b1c7f3cb2c9..1be46ec3287 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidparse.c */ -/* */ -/* CID-keyed Type1 parser (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidparse.c + * + * CID-keyed Type1 parser (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidparse +#define FT_COMPONENT cidparse /*************************************************************************/ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h b/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h index 61602f76741..ec1f6a346db 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidparse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidparse.h */ -/* */ -/* CID-keyed Type1 parser (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidparse.h + * + * CID-keyed Type1 parser (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDPARSE_H_ @@ -29,35 +29,43 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_Parser */ - /* */ - /* <Description> */ - /* A CID_Parser is an object used to parse a Type 1 fonts very */ - /* quickly. */ - /* */ - /* <Fields> */ - /* root :: The root PS_ParserRec fields. */ - /* */ - /* stream :: The current input stream. */ - /* */ - /* postscript :: A pointer to the data to be parsed. */ - /* */ - /* postscript_len :: The length of the data to be parsed. */ - /* */ - /* data_offset :: The start position of the binary data (i.e., the */ - /* end of the data to be parsed. */ - /* */ - /* binary_length :: The length of the data after the `StartData' */ - /* command if the data format is hexadecimal. */ - /* */ - /* cid :: A structure which holds the information about */ - /* the current font. */ - /* */ - /* num_dict :: The number of font dictionaries. */ - /* */ + /************************************************************************** + * + * @Struct: + * CID_Parser + * + * @Description: + * A CID_Parser is an object used to parse a Type 1 fonts very + * quickly. + * + * @Fields: + * root :: + * The root PS_ParserRec fields. + * + * stream :: + * The current input stream. + * + * postscript :: + * A pointer to the data to be parsed. + * + * postscript_len :: + * The length of the data to be parsed. + * + * data_offset :: + * The start position of the binary data (i.e., the + * end of the data to be parsed. + * + * binary_length :: + * The length of the data after the `StartData' + * command if the data format is hexadecimal. + * + * cid :: + * A structure which holds the information about + * the current font. + * + * num_dict :: + * The number of font dictionaries. + */ typedef struct CID_Parser_ { PS_ParserRec root; @@ -86,11 +94,11 @@ FT_BEGIN_HEADER cid_parser_done( CID_Parser* parser ); - /*************************************************************************/ - /* */ - /* PARSING ROUTINES */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * PARSING ROUTINES + * + */ #define cid_parser_skip_spaces( p ) \ (p)->root.funcs.skip_spaces( &(p)->root ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c b/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c index d9faf353ea4..4d91e875291 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidriver.c */ -/* */ -/* CID driver interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidriver.c + * + * CID driver interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -34,18 +34,18 @@ #include FT_INTERNAL_POSTSCRIPT_AUX_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ciddriver +#define FT_COMPONENT ciddriver /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -69,7 +69,7 @@ /* - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -105,7 +105,7 @@ /* - * CID INFO SERVICE + * CID INFO SERVICE * */ static FT_Error @@ -173,7 +173,7 @@ /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ @@ -185,7 +185,7 @@ /* - * SERVICE LIST + * SERVICE LIST * */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h b/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h index 59d9ded9015..3402fd7e994 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidriver.h */ -/* */ -/* High-level CID driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidriver.h + * + * High-level CID driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDRIVER_H_ @@ -26,15 +26,9 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - - FT_CALLBACK_TABLE const FT_Driver_ClassRec t1cid_driver_class; - FT_END_HEADER #endif /* CIDRIVER_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h b/src/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h index b0e2dac6aaf..f505c9e1664 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h +++ b/src/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidtoken.h */ -/* */ -/* CID token definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidtoken.h + * + * CID token definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #undef FT_STRUCTURE @@ -21,17 +21,20 @@ #undef T1CODE #define T1CODE T1_FIELD_LOCATION_CID_INFO - T1_FIELD_KEY ( "CIDFontName", cid_font_name, 0 ) - T1_FIELD_FIXED ( "CIDFontVersion", cid_version, 0 ) - T1_FIELD_NUM ( "CIDFontType", cid_font_type, 0 ) - T1_FIELD_STRING( "Registry", registry, 0 ) - T1_FIELD_STRING( "Ordering", ordering, 0 ) - T1_FIELD_NUM ( "Supplement", supplement, 0 ) - T1_FIELD_NUM ( "UIDBase", uid_base, 0 ) - T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset, 0 ) - T1_FIELD_NUM ( "FDBytes", fd_bytes, 0 ) - T1_FIELD_NUM ( "GDBytes", gd_bytes, 0 ) - T1_FIELD_NUM ( "CIDCount", cid_count, 0 ) + T1_FIELD_KEY ( "CIDFontName", cid_font_name, 0 ) + T1_FIELD_FIXED ( "CIDFontVersion", cid_version, 0 ) + T1_FIELD_NUM ( "CIDFontType", cid_font_type, 0 ) + T1_FIELD_STRING ( "Registry", registry, 0 ) + T1_FIELD_STRING ( "Ordering", ordering, 0 ) + T1_FIELD_NUM ( "Supplement", supplement, 0 ) + T1_FIELD_NUM ( "UIDBase", uid_base, 0 ) + + T1_FIELD_NUM_TABLE( "XUID", xuid, 16, 0 ) + + T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset, 0 ) + T1_FIELD_NUM ( "FDBytes", fd_bytes, 0 ) + T1_FIELD_NUM ( "GDBytes", gd_bytes, 0 ) + T1_FIELD_NUM ( "CIDCount", cid_count, 0 ) #undef FT_STRUCTURE diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c index 0c33d5949bc..49225a9f78e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afmparse.c */ -/* */ -/* AFM parser (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmparse.c + * + * AFM parser (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_FREETYPE_H @@ -28,13 +28,13 @@ #include "psauxerr.h" -/***************************************************************************/ -/* */ -/* AFM_Stream */ -/* */ -/* The use of AFM_Stream is largely inspired by parseAFM.[ch] from t1lib. */ -/* */ -/* */ + /************************************************************************** + * + * AFM_Stream + * + * The use of AFM_Stream is largely inspired by parseAFM.[ch] from t1lib. + * + */ enum { @@ -193,11 +193,11 @@ } - /*************************************************************************/ - /* */ - /* AFM_Parser */ - /* */ - /* */ + /************************************************************************** + * + * AFM_Parser + * + */ /* all keys defined in Ch. 7-10 of 5004.AFM_Spec.pdf */ typedef enum AFM_Token_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h index 86f852a2477..2ceb77553b2 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/afmparse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afmparse.h */ -/* */ -/* AFM parser (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmparse.h + * + * AFM parser (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFMPARSE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c index 80d622c0e1b..17cccf818b4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdecode.c */ -/* */ -/* PostScript CFF (Type 2) decoding routines (body). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdecode.c + * + * PostScript CFF (Type 2) decoding routines (body). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -28,14 +28,14 @@ #include "psauxerr.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffdecode +#define FT_COMPONENT cffdecode #ifdef CFF_CONFIG_OPTION_OLD_ENGINE @@ -235,8 +235,8 @@ return FT_THROW( Syntax_Error ); } - adx += decoder->builder.left_bearing.x; - ady += decoder->builder.left_bearing.y; + adx = ADD_LONG( adx, decoder->builder.left_bearing.x ); + ady = ADD_LONG( ady, decoder->builder.left_bearing.y ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* Incremental fonts don't necessarily have valid charsets. */ @@ -378,23 +378,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_compute_bias */ - /* */ - /* <Description> */ - /* Computes the bias value in dependence of the number of glyph */ - /* subroutines. */ - /* */ - /* <Input> */ - /* in_charstring_type :: The `CharstringType' value of the top DICT */ - /* dictionary. */ - /* */ - /* num_subrs :: The number of glyph subroutines. */ - /* */ - /* <Return> */ - /* The bias value. */ + /************************************************************************** + * + * @Function: + * cff_compute_bias + * + * @Description: + * Computes the bias value in dependence of the number of glyph + * subroutines. + * + * @Input: + * in_charstring_type :: + * The `CharstringType' value of the top DICT + * dictionary. + * + * num_subrs :: + * The number of glyph subroutines. + * + * @Return: + * The bias value. + */ static FT_Int cff_compute_bias( FT_Int in_charstring_type, FT_UInt num_subrs ) @@ -464,28 +467,32 @@ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_decoder_parse_charstrings */ - /* */ - /* <Description> */ - /* Parses a given Type 2 charstrings program. */ - /* */ - /* <InOut> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* <Input> */ - /* charstring_base :: The base of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* in_dict :: Set to 1 if function is called from top or */ - /* private DICT (needed for Multiple Master CFFs). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_decoder_parse_charstrings + * + * @Description: + * Parses a given Type 2 charstrings program. + * + * @InOut: + * decoder :: + * The current Type 1 decoder. + * + * @Input: + * charstring_base :: + * The base of the charstring stream. + * + * charstring_len :: + * The length in bytes of the charstring stream. + * + * in_dict :: + * Set to 1 if function is called from top or + * private DICT (needed for Multiple Master CFFs). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) cff_decoder_parse_charstrings( CFF_Decoder* decoder, FT_Byte* charstring_base, @@ -543,10 +550,10 @@ FT_Byte v; - /********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ + /********************************************************************* + * + * Decode operator or operand + */ v = *ip++; if ( v >= 32 || v == 28 ) { @@ -853,6 +860,15 @@ case cff_op_flex1: case cff_op_callsubr: case cff_op_callgsubr: + /* deprecated opcodes */ + case cff_op_dotsection: + /* invalid Type 1 opcodes */ + case cff_op_hsbw: + case cff_op_closepath: + case cff_op_callothersubr: + case cff_op_seac: + case cff_op_sbw: + case cff_op_setcurrentpoint: goto MM_Error; default: @@ -948,10 +964,10 @@ case cff_op_hstemhm: case cff_op_vstemhm: /* the number of arguments is always even here */ - FT_TRACE4(( - op == cff_op_hstem ? " hstem\n" : - ( op == cff_op_vstem ? " vstem\n" : - ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) )); + FT_TRACE4(( "%s\n", + op == cff_op_hstem ? " hstem" : + ( op == cff_op_vstem ? " vstem" : + ( op == cff_op_hstemhm ? " hstemhm" : " vstemhm" ) ) )); if ( hinter ) hinter->stems( hinter->hints, @@ -965,7 +981,8 @@ case cff_op_hintmask: case cff_op_cntrmask: - FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" )); + FT_TRACE4(( "%s", op == cff_op_hintmask ? " hintmask" + : " cntrmask" )); /* implement vstem when needed -- */ /* the specification doesn't say it, but this also works */ @@ -1078,8 +1095,8 @@ FT_Int phase = ( op == cff_op_hlineto ); - FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n" - : " vlineto\n" )); + FT_TRACE4(( "%s\n", op == cff_op_hlineto ? " hlineto" + : " vlineto" )); if ( num_args < 0 ) goto Stack_Underflow; @@ -1250,8 +1267,8 @@ FT_Int nargs; - FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n" - : " hvcurveto\n" )); + FT_TRACE4(( "%s\n", op == cff_op_vhcurveto ? " vhcurveto" + : " hvcurveto" )); if ( cff_builder_start_point( builder, x, y ) ) goto Fail; @@ -1539,9 +1556,9 @@ } if ( dx < 0 ) - dx = -dx; + dx = NEG_LONG( dx ); if ( dy < 0 ) - dy = -dy; + dy = NEG_LONG( dy ); /* strange test, but here it is... */ horizontal = ( dx > dy ); @@ -1551,7 +1568,7 @@ x = ADD_LONG( x, args[0] ); y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 3 ) ); + FT_BOOL( count == 3 ) ); args += 2; } @@ -1589,7 +1606,7 @@ x = ADD_LONG( x, args[0] ); y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 4 || count == 1 ) ); + FT_BOOL( count == 4 || count == 1 ) ); args += 2; } @@ -1705,16 +1722,20 @@ break; case cff_op_random: - FT_TRACE4(( " random\n" )); + { + FT_UInt32* randval = in_dict ? &decoder->cff->top_font.random + : &decoder->current_subfont->random; - /* only use the lower 16 bits of `random' */ - /* to generate a number in the range (0;1] */ - args[0] = (FT_Fixed) - ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); - args++; - decoder->current_subfont->random = - cff_random( decoder->current_subfont->random ); + FT_TRACE4(( " random\n" )); + + /* only use the lower 16 bits of `random' */ + /* to generate a number in the range (0;1] */ + args[0] = (FT_Fixed)( ( *randval & 0xFFFF ) + 1 ); + args++; + + *randval = cff_random( *randval ); + } break; case cff_op_mul: @@ -1727,7 +1748,10 @@ case cff_op_sqrt: FT_TRACE4(( " sqrt\n" )); - if ( args[0] > 0 ) + /* without upper limit the loop below might not finish */ + if ( args[0] > 0x7FFFFFFFL ) + args[0] = 46341; + else if ( args[0] > 0 ) { FT_Fixed root = args[0]; FT_Fixed new_root; @@ -1800,6 +1824,7 @@ if ( idx >= 0 ) { + idx = idx % count; while ( idx > 0 ) { FT_Fixed tmp = args[count - 1]; @@ -1814,6 +1839,10 @@ } else { + /* before C99 it is implementation-defined whether */ + /* the result of `%' is negative if the first operand */ + /* is negative */ + idx = -( NEG_INT( idx ) % count ); while ( idx < 0 ) { FT_Fixed tmp = args[0]; @@ -1914,6 +1943,7 @@ case cff_op_blend: /* this operator was removed from the Type2 specification */ /* in version 16-March-2000 */ + if ( num_designs ) { FT_Int num_results = (FT_Int)( args[0] >> 16 ); @@ -1923,7 +1953,8 @@ if ( num_results < 0 ) goto Syntax_Error; - if ( num_results * (FT_Int)num_designs > num_args ) + if ( num_results > num_args || + num_results * (FT_Int)num_designs > num_args ) goto Stack_Underflow; /* since we currently don't handle interpolation of multiple */ @@ -1932,6 +1963,8 @@ args -= num_results * ( num_designs - 1 ); num_args -= num_results * ( num_designs - 1 ); } + else + goto Syntax_Error; break; case cff_op_dotsection: @@ -1998,20 +2031,31 @@ break; case cff_op_callothersubr: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ + { + FT_Fixed arg; - FT_TRACE4(( " callothersubr (invalid op)\n" )); - /* subsequent `pop' operands should add the arguments, */ - /* this is the implementation described for `unknown' other */ - /* subroutines in the Type1 spec. */ - /* */ - /* XXX Fix return arguments (see discussion below). */ - args -= 2 + ( args[-2] >> 16 ); - if ( args < stack ) - goto Stack_Underflow; + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from */ + /* probably Type 1 to CFF, and some parsers seem to accept */ + /* it */ + + FT_TRACE4(( " callothersubr (invalid op)\n" )); + + /* subsequent `pop' operands should add the arguments, */ + /* this is the implementation described for `unknown' */ + /* other subroutines in the Type1 spec. */ + /* */ + /* XXX Fix return arguments (see discussion below). */ + + arg = 2 + ( args[-2] >> 16 ); + if ( arg >= CFF_MAX_OPERANDS ) + goto Stack_Underflow; + + args -= arg; + if ( args < stack ) + goto Stack_Underflow; + } break; case cff_op_pop: @@ -2251,28 +2295,34 @@ #endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_decoder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph decoder. */ - /* */ - /* <InOut> */ - /* decoder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* slot :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ - /* hint_mode :: The hinting mode. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_decoder_init + * + * @Description: + * Initializes a given glyph decoder. + * + * @InOut: + * decoder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * slot :: + * The current glyph object. + * + * hinting :: + * Whether hinting is active. + * + * hint_mode :: + * The hinting mode. + */ FT_LOCAL_DEF( void ) cff_decoder_init( CFF_Decoder* decoder, TT_Face face, diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h index 0d4f5fef631..a6691979f0c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/cffdecode.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdecode.h */ -/* */ -/* PostScript CFF (Type 2) decoding routines (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdecode.h + * + * PostScript CFF (Type 2) decoding routines (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFDECODE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.c index a8780947f9d..011803b4161 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psarrst.c */ -/* */ -/* Adobe's code for Array Stacks (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psarrst.c + * + * Adobe's code for Array Stacks (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.h index b3568eb61fc..098617b2575 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psarrst.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psarrst.h */ -/* */ -/* Adobe's code for Array Stacks (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psarrst.h + * + * Adobe's code for Array Stacks (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSARRST_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h index cc33fd2eeac..523e1886c22 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxerr.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* psauxerr.h */ -/* */ -/* PS auxiliary module error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PS auxiliary module error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * psauxerr.h + * + * PS auxiliary module error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PS auxiliary module error enumeration + * constants. + * + */ #ifndef PSAUXERR_H_ #define PSAUXERR_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c index ee497085cc2..5df8e690561 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psauxmod.c */ -/* */ -/* FreeType auxiliary PostScript module implementation (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psauxmod.c + * + * FreeType auxiliary PostScript module implementation (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h index f30978f0220..a0eda0bfc03 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psauxmod.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psauxmod.h */ -/* */ -/* FreeType auxiliary PostScript module implementation (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psauxmod.h + * + * FreeType auxiliary PostScript module implementation (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSAUXMOD_H_ @@ -28,10 +28,6 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - FT_CALLBACK_TABLE const CFF_Builder_FuncsRec cff_builder_funcs; diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c index ae39d03c777..89738ce4749 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psblues.c */ -/* */ -/* Adobe's code for handling Blue Zones (body). */ -/* */ -/* Copyright 2009-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psblues.c + * + * Adobe's code for handling Blue Zones (body). + * + * Copyright 2009-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -44,14 +44,14 @@ #include "psfont.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cf2blues +#define FT_COMPONENT cf2blues /* @@ -452,13 +452,13 @@ * zones in the same pass (see `BlueLock'). If a hint is captured, * return true and position the edge(s) in one of 3 ways: * - * 1) If `BlueScale' suppresses overshoot, position the captured edge - * at the flat edge of the zone. - * 2) If overshoot is not suppressed and `BlueShift' requires - * overshoot, position the captured edge a minimum of 1 device pixel - * from the flat edge. - * 3) If overshoot is not suppressed or required, position the captured - * edge at the nearest device pixel. + * 1) If `BlueScale' suppresses overshoot, position the captured edge + * at the flat edge of the zone. + * 2) If overshoot is not suppressed and `BlueShift' requires + * overshoot, position the captured edge a minimum of 1 device pixel + * from the flat edge. + * 3) If overshoot is not suppressed or required, position the captured + * edge at the nearest device pixel. * */ FT_LOCAL_DEF( FT_Bool ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.h index 25ef6849c77..55fb88ecddf 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psblues.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psblues.h */ -/* */ -/* Adobe's code for handling Blue Zones (specification). */ -/* */ -/* Copyright 2009-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psblues.h + * + * Adobe's code for handling Blue Zones (specification). + * + * Copyright 2009-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ /* diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c index a03385000df..c88761681cc 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psconv.c */ -/* */ -/* Some convenience conversions (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psconv.c + * + * Some convenience conversions (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,14 +24,14 @@ #include "psauxerr.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_psconv +#define FT_COMPONENT psconv /* The following array is used by various functions to quickly convert */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h index d643ffcfc2c..6b24bf6fc95 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psconv.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psconv.h */ -/* */ -/* Some convenience conversions (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psconv.h + * + * Some convenience conversions (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSCONV_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.c index 9169e5222d0..98cebcf74d9 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pserror.c */ -/* */ -/* Adobe's code for error handling (body). */ -/* */ -/* Copyright 2006-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pserror.c + * + * Adobe's code for error handling (body). + * + * Copyright 2006-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.h index 13d52062bf3..b2156b3318b 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/pserror.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pserror.h */ -/* */ -/* Adobe's code for error handling (specification). */ -/* */ -/* Copyright 2006-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pserror.h + * + * Adobe's code for error handling (specification). + * + * Copyright 2006-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSERROR_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psfixed.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psfixed.h index 219589e7fc7..fd3460f34af 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psfixed.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psfixed.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psfixed.h */ -/* */ -/* Adobe's code for Fixed Point Mathematics (specification only). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psfixed.h + * + * Adobe's code for Fixed Point Mathematics (specification only). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSFIXED_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.c index dde67a739d6..bb5faa38f5c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psfont.c */ -/* */ -/* Adobe's code for font instances (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psfont.c + * + * Adobe's code for font instances (body). + * + * Copyright 2007-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include <ft2build.h> @@ -331,7 +331,7 @@ } /* copy hinted flag on each call */ - font->hinted = (FT_Bool)( font->renderingFlags & CF2_FlagsHinted ); + font->hinted = FT_BOOL( font->renderingFlags & CF2_FlagsHinted ); /* determine if transform has changed; */ /* include Fontmatrix but ignore translation */ @@ -366,7 +366,7 @@ if ( font->stemDarkened != ( font->renderingFlags & CF2_FlagsDarkened ) ) { font->stemDarkened = - (FT_Bool)( font->renderingFlags & CF2_FlagsDarkened ); + FT_BOOL( font->renderingFlags & CF2_FlagsDarkened ); /* blue zones depend on darkened flag */ needExtraSetup = TRUE; diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.h index e611ac4bdc8..8fbacbb6e34 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psfont.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psfont.h */ -/* */ -/* Adobe's code for font instances (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psfont.h + * + * Adobe's code for font instances (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSFONT_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.c index 1f750174a1c..54be4683430 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psft.c */ -/* */ -/* FreeType Glue Component to Adobe's Interpreter (body). */ -/* */ -/* Copyright 2013-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psft.c + * + * FreeType Glue Component to Adobe's Interpreter (body). + * + * Copyright 2013-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -120,12 +120,12 @@ } - /********************************************/ - /* */ - /* functions for handling client outline; */ - /* FreeType uses coordinates in 26.6 format */ - /* */ - /********************************************/ + /********************************************* + * + * functions for handling client outline; + * FreeType uses coordinates in 26.6 format + * + */ static void cf2_builder_moveTo( CF2_OutlineCallbacks callbacks, @@ -767,13 +767,14 @@ cf2_freeT1SeacComponent( PS_Decoder* decoder, CF2_Buffer buf ) { +#ifdef FT_CONFIG_OPTION_INCREMENTAL + T1_Face face; FT_Data data; FT_ASSERT( decoder ); -#ifdef FT_CONFIG_OPTION_INCREMENTAL face = (T1_Face)decoder->builder.face; data.pointer = buf->start; @@ -783,7 +784,13 @@ face->root.internal->incremental_interface->funcs->free_glyph_data( face->root.internal->incremental_interface->object, &data ); -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + +#else /* !FT_CONFIG_OPTION_INCREMENTAL */ + + FT_UNUSED( decoder ); + FT_UNUSED( buf ); + +#endif /* !FT_CONFIG_OPTION_INCREMENTAL */ } diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.h index ab172110bb6..4c930f0d73f 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psft.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psft.h */ -/* */ -/* FreeType Glue Component to Adobe's Interpreter (specification). */ -/* */ -/* Copyright 2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psft.h + * + * FreeType Glue Component to Adobe's Interpreter (specification). + * + * Copyright 2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSFT_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psglue.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psglue.h index 5545e12a5bf..022aafbfcac 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psglue.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psglue.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psglue.h */ -/* */ -/* Adobe's code for shared stuff (specification only). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psglue.h + * + * Adobe's code for shared stuff (specification only). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSGLUE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.c index 36151964253..1cbecd2b193 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pshints.c */ -/* */ -/* Adobe's code for handling CFF hints (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshints.c + * + * Adobe's code for handling CFF hints (body). + * + * Copyright 2007-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -45,14 +45,14 @@ #include "psintrp.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cf2hints +#define FT_COMPONENT cf2hints typedef struct CF2_HintMoveRec_ @@ -217,52 +217,49 @@ FT_LOCAL_DEF( FT_Bool ) cf2_hint_isValid( const CF2_Hint hint ) { - return (FT_Bool)( hint->flags != 0 ); + return FT_BOOL( hint->flags ); } static FT_Bool cf2_hint_isPair( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & - ( CF2_PairBottom | CF2_PairTop ) ) != 0 ); + return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_PairTop ) ); } static FT_Bool cf2_hint_isPairTop( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & CF2_PairTop ) != 0 ); + return FT_BOOL( hint->flags & CF2_PairTop ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isTop( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & - ( CF2_PairTop | CF2_GhostTop ) ) != 0 ); + return FT_BOOL( hint->flags & ( CF2_PairTop | CF2_GhostTop ) ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isBottom( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & - ( CF2_PairBottom | CF2_GhostBottom ) ) != 0 ); + return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_GhostBottom ) ); } static FT_Bool cf2_hint_isLocked( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & CF2_Locked ) != 0 ); + return FT_BOOL( hint->flags & CF2_Locked ); } static FT_Bool cf2_hint_isSynthetic( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & CF2_Synthetic ) != 0 ); + return FT_BOOL( hint->flags & CF2_Synthetic ); } @@ -334,7 +331,7 @@ cf2_hintmap_map( CF2_HintMap hintmap, CF2_Fixed csCoord ) { - if ( hintmap->count == 0 || ! hintmap->hinted ) + if ( hintmap->count == 0 || !hintmap->hinted ) { /* there are no hints; use uniform scale and zero offset */ return FT_MulFix( csCoord, hintmap->scale ); @@ -497,7 +494,7 @@ { move = moveDown; /* true if non-optimum move */ - saveEdge = (FT_Bool)( moveUp < -moveDown ); + saveEdge = FT_BOOL( moveUp < -moveDown ); } else { @@ -1025,10 +1022,10 @@ } } - FT_TRACE6(( initialMap ? "flags: [p]air [g]host [t]op " - "[b]ottom [L]ocked [S]ynthetic\n" - "Initial hintmap\n" - : "Hints:\n" )); + FT_TRACE6(( "%s\n", initialMap ? "flags: [p]air [g]host [t]op" + " [b]ottom [L]ocked [S]ynthetic\n" + "Initial hintmap" + : "Hints:" )); cf2_hintmap_dump( hintmap ); /* @@ -1215,7 +1212,7 @@ * (`u'). * * See notation in - * http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm. + * http://geomalgorithms.com/a05-_intersect-1.html. * Calculations are done in 16.16, but must handle the squaring of * line lengths in character space. We scale all vectors by 1/32 to * avoid overflow. This allows values up to 4095 to be squared. The diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.h index 92e37e98aef..31a8230364c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/pshints.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pshints.h */ -/* */ -/* Adobe's code for handling CFF hints (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshints.h + * + * Adobe's code for handling CFF hints (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSHINT_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c index da5a8dad1db..e2f3accdd5c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psintrp.c */ -/* */ -/* Adobe's CFF Interpreter (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psintrp.c + * + * Adobe's CFF Interpreter (body). + * + * Copyright 2007-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -52,14 +52,14 @@ #include "t1decode.h" /* for t1 seac */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cf2interp +#define FT_COMPONENT cf2interp FT_LOCAL_DEF( void ) @@ -287,7 +287,7 @@ { CF2_UInt i; CF2_UInt count = cf2_stack_count( opStack ); - FT_Bool hasWidthArg = (FT_Bool)( count & 1 ); + FT_Bool hasWidthArg = FT_BOOL( count & 1 ); /* variable accumulates delta values from operand stack */ CF2_Fixed position = hintOffset; @@ -364,7 +364,7 @@ if ( doConditionalLastRead ) { - FT_Bool lastIsX = (FT_Bool)( + FT_Bool lastIsX = FT_BOOL( cf2_fixedAbs( SUB_INT32( vals[10], *curX ) ) > cf2_fixedAbs( SUB_INT32( vals[11], *curY ) ) ); CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx ); @@ -612,14 +612,14 @@ cf2_arrstack_setCount( &subrStack, CF2_MAX_SUBR + 1 ); charstring = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack ); - *charstring = *buf; /* structure copy */ - - charstringIndex = 0; /* entry is valid now */ /* catch errors so far */ if ( *error ) goto exit; + *charstring = *buf; /* structure copy */ + charstringIndex = 0; /* entry is valid now */ + /* main interpreter loop */ while ( 1 ) { @@ -663,6 +663,7 @@ /* Skip outline commands first time round. */ /* `endchar' will trigger initial hintmap build */ /* and rewind the charstring. */ + FT_TRACE4(( " <outline command skipped>\n" )); cf2_stack_clear( opStack ); continue; } @@ -775,7 +776,8 @@ case cf2_cmdHSTEMHM: case cf2_cmdHSTEM: - FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" )); + FT_TRACE4(( "%s\n", op1 == cf2_cmdHSTEMHM ? " hstemhm" + : " hstem" )); if ( !font->isT1 ) { @@ -805,7 +807,8 @@ case cf2_cmdVSTEMHM: case cf2_cmdVSTEM: - FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" )); + FT_TRACE4(( "%s\n", op1 == cf2_cmdVSTEMHM ? " vstemhm" + : " vstem" )); if ( !font->isT1 ) { @@ -888,7 +891,7 @@ FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO ); - FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" )); + FT_TRACE4(( "%s\n", isX ? " hlineto" : " vlineto" )); for ( idx = 0; idx < count; idx++ ) { @@ -916,8 +919,8 @@ CF2_UInt idx = 0; - FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n" - : " rrcurveto\n" )); + FT_TRACE4(( "%s\n", op1 == cf2_cmdRCURVELINE ? " rcurveline" + : " rrcurveto" )); while ( idx + 6 <= count ) { @@ -957,10 +960,10 @@ FT_TRACE4(( " unknown op (%d)\n", op1 )); else { - FT_TRACE4(( " closepath" )); + FT_TRACE4(( " closepath\n" )); /* if there is no path, `closepath' is a no-op */ - ps_builder_close_contour( &decoder->builder ); + cf2_glyphpath_closeOpenPath( &glyphPath ); haveWidth = TRUE; } @@ -972,8 +975,8 @@ CF2_Int subrNum; - FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr" - : " callsubr" )); + FT_TRACE4(( "%s", op1 == cf2_cmdCALLGSUBR ? " callgsubr" + : " callsubr" )); if ( ( !font->isT1 && charstringIndex > CF2_MAX_SUBR ) || ( font->isT1 && charstringIndex > T1_MAX_SUBRS_CALLS ) ) @@ -1212,8 +1215,8 @@ FT_Bool isV = FT_BOOL( op2 == cf2_escVSTEM3 ); - FT_TRACE4(( isV ? " vstem3\n" - : " hstem3\n" )); + FT_TRACE4(( "%s\n", isV ? " vstem3" + : " hstem3" )); FT_ASSERT( cf2_stack_count( opStack ) == 6 ); @@ -1644,16 +1647,17 @@ subr_no = cf2_stack_popInt( opStack ); arg_cnt = cf2_stack_popInt( opStack ); - /*******************************************************/ - /* */ - /* remove all operands to callothersubr from the stack */ - /* */ - /* for handled othersubrs, where we know the number of */ - /* arguments, we increase the stack by the value of */ - /* known_othersubr_result_cnt */ - /* */ - /* for unhandled othersubrs the following pops adjust */ - /* the stack pointer as necessary */ + /******************************************************** + * + * remove all operands to callothersubr from the stack + * + * for handled othersubrs, where we know the number of + * arguments, we increase the stack by the value of + * known_othersubr_result_cnt + * + * for unhandled othersubrs the following pops adjust + * the stack pointer as necessary + */ count = cf2_stack_count( opStack ); FT_ASSERT( (CF2_UInt)arg_cnt <= count ); @@ -2416,7 +2420,7 @@ PS_Builder* builder; - FT_TRACE4(( " hsbw" )); + FT_TRACE4(( " hsbw\n" )); builder = &decoder->builder; @@ -2562,7 +2566,7 @@ case cf2_cmdHINTMASK: /* the final \n in the tracing message gets added in */ /* `cf2_hintmask_read' (which also traces the mask bytes) */ - FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" )); + FT_TRACE4(( "%s", op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" )); /* never add hints after the mask is computed */ if ( cf2_stack_count( opStack ) > 1 && @@ -2828,7 +2832,7 @@ count = count1 & ~2U; idx += count1 - count; - FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" )); + FT_TRACE4(( "%s\n", alternate ? " hvcurveto" : " vhcurveto" )); while ( idx < count ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.h index 4790aaa302a..669c09c0ae5 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psintrp.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psintrp.h */ -/* */ -/* Adobe's CFF Interpreter (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psintrp.h + * + * Adobe's CFF Interpreter (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSINTRP_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c index f54bc7e4164..e2168a33240 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psobjs.c */ -/* */ -/* Auxiliary functions for PostScript fonts (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psobjs.c + * + * Auxiliary functions for PostScript fonts (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -29,14 +29,14 @@ #include "psauxmod.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_psobjs +#define FT_COMPONENT psobjs /*************************************************************************/ @@ -47,26 +47,29 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_table_new */ - /* */ - /* <Description> */ - /* Initializes a PS_Table. */ - /* */ - /* <InOut> */ - /* table :: The address of the target table. */ - /* */ - /* <Input> */ - /* count :: The table size = the maximum number of elements. */ - /* */ - /* memory :: The memory object to use for all subsequent */ - /* reallocations. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_table_new + * + * @Description: + * Initializes a PS_Table. + * + * @InOut: + * table :: + * The address of the target table. + * + * @Input: + * count :: + * The table size = the maximum number of elements. + * + * memory :: + * The memory object to use for all subsequent + * reallocations. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) ps_table_new( PS_Table table, FT_Int count, @@ -144,28 +147,32 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_table_add */ - /* */ - /* <Description> */ - /* Adds an object to a PS_Table, possibly growing its memory block. */ - /* */ - /* <InOut> */ - /* table :: The target table. */ - /* */ - /* <Input> */ - /* idx :: The index of the object in the table. */ - /* */ - /* object :: The address of the object to copy in memory. */ - /* */ - /* length :: The length in bytes of the source object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. An error is returned if a */ - /* reallocation fails. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_table_add + * + * @Description: + * Adds an object to a PS_Table, possibly growing its memory block. + * + * @InOut: + * table :: + * The target table. + * + * @Input: + * idx :: + * The index of the object in the table. + * + * object :: + * The address of the object to copy in memory. + * + * length :: + * The length in bytes of the source object. + * + * @Return: + * FreeType error code. 0 means success. An error is returned if a + * reallocation fails. + */ FT_LOCAL_DEF( FT_Error ) ps_table_add( PS_Table table, FT_Int idx, @@ -216,22 +223,23 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_table_done */ - /* */ - /* <Description> */ - /* Finalizes a PS_TableRec (i.e., reallocate it to its current */ - /* cursor). */ - /* */ - /* <InOut> */ - /* table :: The target table. */ - /* */ - /* <Note> */ - /* This function does NOT release the heap's memory block. It is up */ - /* to the caller to clean it, or reference it in its own structures. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_table_done + * + * @Description: + * Finalizes a PS_TableRec (i.e., reallocate it to its current + * cursor). + * + * @InOut: + * table :: + * The target table. + * + * @Note: + * This function does NOT release the heap's memory block. It is up + * to the caller to clean it, or reference it in its own structures. + */ FT_LOCAL_DEF( void ) ps_table_done( PS_Table table ) { @@ -498,12 +506,12 @@ } - /***********************************************************************/ - /* */ - /* All exported parsing routines handle leading whitespace and stop at */ - /* the first character which isn't part of the just handled token. */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * All exported parsing routines handle leading whitespace and stop at + * the first character which isn't part of the just handled token. + * + */ FT_LOCAL_DEF( void ) @@ -1100,18 +1108,22 @@ { case T1_FIELD_TYPE_BOOL: val = ps_tobool( &cur, limit ); + FT_TRACE4(( " %s", val ? "true" : "false" )); goto Store_Integer; case T1_FIELD_TYPE_FIXED: val = PS_Conv_ToFixed( &cur, limit, 0 ); + FT_TRACE4(( " %f", (double)val / 65536 )); goto Store_Integer; case T1_FIELD_TYPE_FIXED_1000: val = PS_Conv_ToFixed( &cur, limit, 3 ); + FT_TRACE4(( " %f", (double)val / 65536 / 1000 )); goto Store_Integer; case T1_FIELD_TYPE_INTEGER: val = PS_Conv_ToInt( &cur, limit ); + FT_TRACE4(( " %ld", val )); /* fall through */ Store_Integer: @@ -1188,6 +1200,13 @@ FT_MEM_COPY( string, cur, len ); string[len] = 0; +#ifdef FT_DEBUG_LEVEL_TRACE + if ( token.type == T1_TOKEN_TYPE_STRING ) + FT_TRACE4(( " (%s)", string )); + else + FT_TRACE4(( " /%s", string )); +#endif + *(FT_String**)q = string; } break; @@ -1213,6 +1232,12 @@ bbox->yMin = FT_RoundFix( temp[1] ); bbox->xMax = FT_RoundFix( temp[2] ); bbox->yMax = FT_RoundFix( temp[3] ); + + FT_TRACE4(( " [%d %d %d %d]", + bbox->xMin / 65536, + bbox->yMin / 65536, + bbox->xMax / 65536, + bbox->yMax / 65536 )); } break; @@ -1251,6 +1276,7 @@ skip_spaces( &cur, limit ); } + FT_TRACE4(( " [" )); for ( i = 0; i < max_objects; i++ ) { FT_BBox* bbox = (FT_BBox*)objects[i]; @@ -1260,7 +1286,14 @@ bbox->yMin = FT_RoundFix( temp[i + max_objects] ); bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] ); bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] ); + + FT_TRACE4(( " [%d %d %d %d]", + bbox->xMin / 65536, + bbox->yMin / 65536, + bbox->xMax / 65536, + bbox->yMax / 65536 )); } + FT_TRACE4(( "]" )); FT_FREE( temp ); } @@ -1333,6 +1366,8 @@ *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = (FT_Byte)num_elements; + FT_TRACE4(( " [" )); + /* we now load each element, adjusting the field.offset on each one */ token = elements; for ( ; num_elements > 0; num_elements--, token++ ) @@ -1351,6 +1386,8 @@ fieldrec.offset += fieldrec.size; } + FT_TRACE4(( "]" )); + #if 0 /* obsolete -- keep for reference */ if ( pflags ) *pflags |= 1L << field->flag_bit; @@ -1410,6 +1447,8 @@ bytes, max_bytes ); + parser->cursor = cur; + if ( delimiters ) { if ( cur < parser->limit && *cur != '>' ) @@ -1419,11 +1458,9 @@ goto Exit; } - cur++; + parser->cursor++; } - parser->cursor = cur; - Exit: return error; } @@ -1509,26 +1546,31 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting should be applied. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_builder_init + * + * @Description: + * Initializes a given glyph builder. + * + * @InOut: + * builder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * glyph :: + * The current glyph object. + * + * hinting :: + * Whether hinting should be applied. + */ FT_LOCAL_DEF( void ) t1_builder_init( T1_Builder builder, FT_Face face, @@ -1572,19 +1614,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_builder_done + * + * @Description: + * Finalizes a given glyph builder. Its contents can still be used + * after the call, but the function saves important information + * within the corresponding glyph slot. + * + * @Input: + * builder :: + * A pointer to the glyph builder to finalize. + */ FT_LOCAL_DEF( void ) t1_builder_done( T1_Builder builder ) { @@ -1769,26 +1812,31 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_builder_init + * + * @Description: + * Initializes a given glyph builder. + * + * @InOut: + * builder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * glyph :: + * The current glyph object. + * + * hinting :: + * Whether hinting is active. + */ FT_LOCAL_DEF( void ) cff_builder_init( CFF_Builder* builder, TT_Face face, @@ -1841,19 +1889,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_builder_done + * + * @Description: + * Finalizes a given glyph builder. Its contents can still be used + * after the call, but the function saves important information + * within the corresponding glyph slot. + * + * @Input: + * builder :: + * A pointer to the glyph builder to finalize. + */ FT_LOCAL_DEF( void ) cff_builder_done( CFF_Builder* builder ) { @@ -1993,6 +2042,14 @@ first = outline->n_contours <= 1 ? 0 : outline->contours[outline->n_contours - 2] + 1; + /* in malformed fonts it can happen that a contour was started */ + /* but no points were added */ + if ( outline->n_contours && first == outline->n_points ) + { + outline->n_contours--; + return; + } + /* We must not include the last point in the path if it */ /* is located on the first point. */ if ( outline->n_points > 1 ) @@ -2033,26 +2090,31 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting should be applied. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_builder_init + * + * @Description: + * Initializes a given glyph builder. + * + * @InOut: + * builder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * glyph :: + * The current glyph object. + * + * hinting :: + * Whether hinting should be applied. + */ FT_LOCAL_DEF( void ) ps_builder_init( PS_Builder* ps_builder, void* builder, @@ -2116,19 +2178,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_builder_done + * + * @Description: + * Finalizes a given glyph builder. Its contents can still be used + * after the call, but the function saves important information + * within the corresponding glyph slot. + * + * @Input: + * builder :: + * A pointer to the glyph builder to finalize. + */ FT_LOCAL_DEF( void ) ps_builder_done( PS_Builder* builder ) { @@ -2336,23 +2399,26 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_decoder_init */ - /* */ - /* <Description> */ - /* Creates a wrapper decoder for use in the combined */ - /* Type 1 / CFF interpreter. */ - /* */ - /* <InOut> */ - /* ps_decoder :: A pointer to the decoder to initialize. */ - /* */ - /* <Input> */ - /* decoder :: A pointer to the original decoder. */ - /* */ - /* is_t1 :: Flag indicating Type 1 or CFF */ - /* */ + /************************************************************************** + * + * @Function: + * ps_decoder_init + * + * @Description: + * Creates a wrapper decoder for use in the combined + * Type 1 / CFF interpreter. + * + * @InOut: + * ps_decoder :: + * A pointer to the decoder to initialize. + * + * @Input: + * decoder :: + * A pointer to the original decoder. + * + * is_t1 :: + * Flag indicating Type 1 or CFF + */ FT_LOCAL_DEF( void ) ps_decoder_init( PS_Decoder* ps_decoder, void* decoder, diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h index 8e0fe5fa4c0..9466a1d0754 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psobjs.h */ -/* */ -/* Auxiliary functions for PostScript fonts (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psobjs.h + * + * Auxiliary functions for PostScript fonts (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSOBJS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.c index 719863ce178..86bfc03c6e5 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psread.c */ -/* */ -/* Adobe's code for stream handling (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psread.c + * + * Adobe's code for stream handling (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -105,7 +105,7 @@ FT_LOCAL_DEF( FT_Bool ) cf2_buf_isEnd( CF2_Buffer buf ) { - return (FT_Bool)( buf->ptr >= buf->end ); + return FT_BOOL( buf->ptr >= buf->end ); } diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.h index 464b29ba743..9e55fe04470 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psread.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psread.h */ -/* */ -/* Adobe's code for stream handling (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psread.h + * + * Adobe's code for stream handling (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSREAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.c index 69d063349a1..6659068001c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psstack.c */ -/* */ -/* Adobe's code for emulating a CFF stack (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psstack.c + * + * Adobe's code for emulating a CFF stack (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -258,6 +258,9 @@ return; } + /* before C99 it is implementation-defined whether */ + /* the result of `%' is negative if the first operand */ + /* is negative */ if ( shift < 0 ) shift = -( ( -shift ) % count ); else diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.h index 38f7b41c689..18cd39bc6a0 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/psstack.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psstack.h */ -/* */ -/* Adobe's code for emulating a CFF stack (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psstack.h + * + * Adobe's code for emulating a CFF stack (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSSTACK_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/pstypes.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/pstypes.h index dfbaa3d475b..041287e8d5e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/pstypes.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/pstypes.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pstypes.h */ -/* */ -/* Adobe's code for defining data types (specification only). */ -/* */ -/* Copyright 2011-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pstypes.h + * + * Adobe's code for defining data types (specification only). + * + * Copyright 2011-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSTYPES_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c index 112a7892bac..d62d2d5c816 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1cmap.c */ -/* */ -/* Type 1 character map support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1cmap.c + * + * Type 1 character map support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "t1cmap.h" @@ -305,6 +305,9 @@ FT_UNUSED( pointer ); + if ( !psnames->unicodes_init ) + return FT_THROW( Unimplemented_Feature ); + return psnames->unicodes_init( memory, unicodes, (FT_UInt)face->type1.num_glyphs, diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h index 4308e31d2d7..d325e7b5a65 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1cmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1cmap.h */ -/* */ -/* Type 1 character map support (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1cmap.h + * + * Type 1 character map support (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1CMAP_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c index 6ad145661f2..c2b3729b539 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1decode.c */ -/* */ -/* PostScript Type 1 decoding routines (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1decode.c + * + * PostScript Type 1 decoding routines (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +31,14 @@ /* ensure proper sign extension */ #define Fix2Int( f ) ( (FT_Int)(FT_Short)( (f) >> 16 ) ) - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1decode +#define FT_COMPONENT t1decode typedef enum T1_Operator_ @@ -109,24 +109,26 @@ }; - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_lookup_glyph_by_stdcharcode_ps */ - /* */ - /* <Description> */ - /* Looks up a given glyph by its StandardEncoding charcode. Used to */ - /* implement the SEAC Type 1 operator in the Adobe engine */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* charcode :: The character code to look for. */ - /* */ - /* <Return> */ - /* A glyph index in the font face. Returns -1 if the corresponding */ - /* glyph wasn't found. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_lookup_glyph_by_stdcharcode_ps + * + * @Description: + * Looks up a given glyph by its StandardEncoding charcode. Used to + * implement the SEAC Type 1 operator in the Adobe engine + * + * @Input: + * face :: + * The current face object. + * + * charcode :: + * The character code to look for. + * + * @Return: + * A glyph index in the font face. Returns -1 if the corresponding + * glyph wasn't found. + */ FT_LOCAL_DEF( FT_Int ) t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder, FT_Int charcode ) @@ -159,24 +161,27 @@ #ifdef T1_CONFIG_OPTION_OLD_ENGINE - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_lookup_glyph_by_stdcharcode */ - /* */ - /* <Description> */ - /* Looks up a given glyph by its StandardEncoding charcode. Used to */ - /* implement the SEAC Type 1 operator. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* charcode :: The character code to look for. */ - /* */ - /* <Return> */ - /* A glyph index in the font face. Returns -1 if the corresponding */ - /* glyph wasn't found. */ - /* */ + + /************************************************************************** + * + * @Function: + * t1_lookup_glyph_by_stdcharcode + * + * @Description: + * Looks up a given glyph by its StandardEncoding charcode. Used to + * implement the SEAC Type 1 operator. + * + * @Input: + * face :: + * The current face object. + * + * charcode :: + * The character code to look for. + * + * @Return: + * A glyph index in the font face. Returns -1 if the corresponding + * glyph wasn't found. + */ static FT_Int t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder, FT_Int charcode ) @@ -217,30 +222,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1operator_seac */ - /* */ - /* <Description> */ - /* Implements the `seac' Type 1 operator for a Type 1 decoder. */ - /* */ - /* <Input> */ - /* decoder :: The current CID decoder. */ - /* */ - /* asb :: The accent's side bearing. */ - /* */ - /* adx :: The horizontal offset of the accent. */ - /* */ - /* ady :: The vertical offset of the accent. */ - /* */ - /* bchar :: The base character's StandardEncoding charcode. */ - /* */ - /* achar :: The accent character's StandardEncoding charcode. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * t1operator_seac + * + * @Description: + * Implements the `seac' Type 1 operator for a Type 1 decoder. + * + * @Input: + * decoder :: + * The current CID decoder. + * + * asb :: + * The accent's side bearing. + * + * adx :: + * The horizontal offset of the accent. + * + * ady :: + * The vertical offset of the accent. + * + * bchar :: + * The base character's StandardEncoding charcode. + * + * achar :: + * The accent character's StandardEncoding charcode. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error t1operator_seac( T1_Decoder decoder, FT_Pos asb, @@ -399,24 +410,27 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_decoder_parse_charstrings */ - /* */ - /* <Description> */ - /* Parses a given Type 1 charstrings program. */ - /* */ - /* <Input> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* charstring_base :: The base address of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_decoder_parse_charstrings + * + * @Description: + * Parses a given Type 1 charstrings program. + * + * @Input: + * decoder :: + * The current Type 1 decoder. + * + * charstring_base :: + * The base address of the charstring stream. + * + * charstring_len :: + * The length in bytes of the charstring stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* charstring_base, @@ -466,9 +480,6 @@ if ( decoder->buildchar && decoder->len_buildchar > 0 ) FT_ARRAY_ZERO( decoder->buildchar, decoder->len_buildchar ); - FT_TRACE4(( "\n" - "Start charstring\n" )); - zone->base = charstring_base; limit = zone->limit = charstring_base + charstring_len; ip = zone->cursor = zone->base; @@ -503,11 +514,11 @@ } #endif - /*********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - /* */ + /********************************************************************** + * + * Decode operator or operand + * + */ /* first of all, decompress operator or value */ switch ( *ip++ ) @@ -710,11 +721,11 @@ large_int = FALSE; } - /*********************************************************************/ - /* */ - /* Push value on stack, or process operator */ - /* */ - /* */ + /********************************************************************** + * + * Push value on stack, or process operator + * + */ if ( op == op_none ) { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) @@ -752,16 +763,17 @@ subr_no = Fix2Int( top[1] ); arg_cnt = Fix2Int( top[0] ); - /***********************************************************/ - /* */ - /* remove all operands to callothersubr from the stack */ - /* */ - /* for handled othersubrs, where we know the number of */ - /* arguments, we increase the stack by the value of */ - /* known_othersubr_result_cnt */ - /* */ - /* for unhandled othersubrs the following pops adjust the */ - /* stack pointer as necessary */ + /************************************************************ + * + * remove all operands to callothersubr from the stack + * + * for handled othersubrs, where we know the number of + * arguments, we increase the stack by the value of + * known_othersubr_result_cnt + * + * for unhandled othersubrs the following pops adjust the + * stack pointer as necessary + */ if ( arg_cnt > top - decoder->stack ) goto Stack_Underflow; @@ -1223,7 +1235,10 @@ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) + { + FT_TRACE4(( "\n" )); return FT_Err_Ok; + } break; @@ -1255,7 +1270,10 @@ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) + { + FT_TRACE4(( "\n" )); return FT_Err_Ok; + } break; @@ -1638,26 +1656,31 @@ return FT_THROW( Stack_Underflow ); } -#else /* T1_CONFIG_OPTION_OLD_ENGINE */ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_decoder_parse_metrics */ - /* */ - /* <Description> */ - /* Parses a given Type 1 charstrings program to extract width */ - /* */ - /* <Input> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* charstring_base :: The base address of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + +#else /* !T1_CONFIG_OPTION_OLD_ENGINE */ + + + /************************************************************************** + * + * @Function: + * t1_decoder_parse_metrics + * + * @Description: + * Parses a given Type 1 charstrings program to extract width + * + * @Input: + * decoder :: + * The current Type 1 decoder. + * + * charstring_base :: + * The base address of the charstring stream. + * + * charstring_len :: + * The length in bytes of the charstring stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) t1_decoder_parse_metrics( T1_Decoder decoder, FT_Byte* charstring_base, @@ -1680,9 +1703,6 @@ builder->parse_state = T1_Parse_Start; - FT_TRACE4(( "\n" - "Start charstring: get width\n" )); - zone->base = charstring_base; limit = zone->limit = charstring_base + charstring_len; ip = zone->cursor = zone->base; @@ -1703,11 +1723,11 @@ } #endif - /*********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - /* */ + /********************************************************************** + * + * Decode operator or operand + * + */ /* first of all, decompress operator or value */ switch ( *ip++ ) @@ -1817,11 +1837,11 @@ } } - /*********************************************************************/ - /* */ - /* Push value on stack, or process operator */ - /* */ - /* */ + /********************************************************************** + * + * Push value on stack, or process operator + * + */ if ( op == op_none ) { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) @@ -1875,6 +1895,7 @@ /* we only want to compute the glyph's metrics */ /* (lsb + advance width), not load the rest of */ /* it; so exit immediately */ + FT_TRACE4(( "\n" )); return FT_Err_Ok; case op_sbw: @@ -1893,6 +1914,7 @@ /* we only want to compute the glyph's metrics */ /* (lsb + advance width), not load the rest of */ /* it; so exit immediately */ + FT_TRACE4(( "\n" )); return FT_Err_Ok; default: @@ -1917,7 +1939,8 @@ Stack_Underflow: return FT_THROW( Stack_Underflow ); } -#endif /* T1_CONFIG_OPTION_OLD_ENGINE */ + +#endif /* !T1_CONFIG_OPTION_OLD_ENGINE */ /* initialize T1 decoder */ @@ -1934,7 +1957,7 @@ { FT_ZERO( decoder ); - /* retrieve PSNames interface from list of current modules */ + /* retrieve `psnames' interface from list of current modules */ { FT_Service_PsCMaps psnames; diff --git a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h index 1d9718d678e..1b5d6263d37 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psaux/t1decode.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1decode.h */ -/* */ -/* PostScript Type 1 decoding routines (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1decode.h + * + * PostScript Type 1 decoding routines (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1DECODE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c index b98077c62ef..0c5ae626999 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshalgo.c */ -/* */ -/* PostScript hinting algorithm (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshalgo.c + * + * PostScript hinting algorithm (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,7 +26,7 @@ #undef FT_COMPONENT -#define FT_COMPONENT trace_pshalgo +#define FT_COMPONENT pshalgo #ifdef DEBUG_HINTER @@ -53,8 +53,8 @@ psh_hint_overlap( PSH_Hint hint1, PSH_Hint hint2 ) { - return hint1->org_pos + hint1->org_len >= hint2->org_pos && - hint2->org_pos + hint2->org_len >= hint1->org_pos; + return ADD_INT( hint1->org_pos, hint1->org_len ) >= hint2->org_pos && + ADD_INT( hint2->org_pos, hint2->org_len ) >= hint1->org_pos; } @@ -479,7 +479,7 @@ if ( dimension == 1 ) psh_blues_snap_stem( &globals->blues, - hint->org_pos + hint->org_len, + ADD_INT( hint->org_pos, hint->org_len ), hint->org_pos, &align ); @@ -658,8 +658,8 @@ #if 0 /* not used for now, experimental */ /* - * A variant to perform "light" hinting (i.e. FT_RENDER_MODE_LIGHT) - * of stems + * A variant to perform "light" hinting (i.e. FT_RENDER_MODE_LIGHT) + * of stems */ static void psh_hint_align_light( PSH_Hint hint, @@ -703,7 +703,7 @@ if ( dimension == 1 ) psh_blues_snap_stem( &globals->blues, - hint->org_pos + hint->org_len, + ADD_INT( hint->org_pos, hint->org_len ), hint->org_pos, &align ); @@ -1538,8 +1538,8 @@ PSH_Hint hint = sort[nn]; - if ( org_u >= hint->org_pos && - org_u <= hint->org_pos + hint->org_len ) + if ( org_u >= hint->org_pos && + org_u <= ADD_INT( hint->org_pos, hint->org_len ) ) { point->hint = hint; break; diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h index c50683fbec6..6859e95cd2d 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshalgo.h */ -/* */ -/* PostScript hinting algorithm (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshalgo.h + * + * PostScript hinting algorithm (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHALGO_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c index accc04921d0..b021e6e42a3 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c @@ -1,25 +1,26 @@ -/***************************************************************************/ -/* */ -/* pshglob.c */ -/* */ -/* PostScript hinter global hinting management (body). */ -/* Inspired by the new auto-hinter module. */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshglob.c + * + * PostScript hinter global hinting management (body). + * Inspired by the new auto-hinter module. + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_CALC_H #include "pshglob.h" #ifdef DEBUG_HINTER @@ -568,7 +569,7 @@ for ( ; count > 0; count--, zone++ ) { - delta = stem_top - zone->org_bottom; + delta = SUB_LONG( stem_top, zone->org_bottom ); if ( delta < -blues->blue_fuzz ) break; @@ -590,7 +591,7 @@ for ( ; count > 0; count--, zone-- ) { - delta = zone->org_top - stem_bot; + delta = SUB_LONG( zone->org_top, stem_bot ); if ( delta < -blues->blue_fuzz ) break; diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h index cf80bf40e64..0049d4c0bc8 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshglob.h */ -/* */ -/* PostScript hinter global hinting management. */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshglob.h + * + * PostScript hinter global hinting management. + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHGLOB_H_ @@ -36,27 +36,27 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @constant: */ - /* PS_GLOBALS_MAX_BLUE_ZONES */ - /* */ - /* @description: */ - /* The maximum number of blue zones in a font global hints structure. */ - /* See @PS_Globals_BluesRec. */ - /* */ + /************************************************************************** + * + * @constant: + * PS_GLOBALS_MAX_BLUE_ZONES + * + * @description: + * The maximum number of blue zones in a font global hints structure. + * See @PS_Globals_BluesRec. + */ #define PS_GLOBALS_MAX_BLUE_ZONES 16 - /*************************************************************************/ - /* */ - /* @constant: */ - /* PS_GLOBALS_MAX_STD_WIDTHS */ - /* */ - /* @description: */ - /* The maximum number of standard and snap widths in either the */ - /* horizontal or vertical direction. See @PS_Globals_WidthsRec. */ - /* */ + /************************************************************************** + * + * @constant: + * PS_GLOBALS_MAX_STD_WIDTHS + * + * @description: + * The maximum number of standard and snap widths in either the + * horizontal or vertical direction. See @PS_Globals_WidthsRec. + */ #define PS_GLOBALS_MAX_STD_WIDTHS 16 diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c index 0b8f6f99b83..2d36ea2a6a6 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.c @@ -1,26 +1,25 @@ -/***************************************************************************/ -/* */ -/* pshmod.c */ -/* */ -/* FreeType PostScript hinter module implementation (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshmod.c + * + * FreeType PostScript hinter module implementation (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include "pshrec.h" #include "pshalgo.h" -#include "pshpic.h" /* the Postscript Hinter module structure */ @@ -111,7 +110,7 @@ 0x10000L, 0x20000L, - &PSHINTER_INTERFACE_GET, /* module-specific interface */ + &pshinter_interface, /* module-specific interface */ (FT_Module_Constructor)ps_hinter_init, /* module_init */ (FT_Module_Destructor) ps_hinter_done, /* module_done */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h index 556de2fbc0e..ea8771308af 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshmod.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshmod.h */ -/* */ -/* PostScript hinter module interface (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshmod.h + * + * PostScript hinter module interface (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHMOD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h index b9d02d2956a..fb9dbca2b1f 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshnterr.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* pshnterr.h */ -/* */ -/* PS Hinter error codes (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PSHinter error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * pshnterr.h + * + * PS Hinter error codes (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PSHinter error enumeration constants. + * + */ #ifndef PSHNTERR_H_ #define PSHNTERR_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshpic.c b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshpic.c deleted file mode 100644 index 465ad31885b..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshpic.c +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************/ -/* */ -/* pshpic.c */ -/* */ -/* The FreeType position independent code services for pshinter module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "pshpic.h" -#include "pshnterr.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from pshmod.c */ - void - FT_Init_Class_pshinter_interface( FT_Library library, - PSHinter_Interface* clazz ); - - void - pshinter_module_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->pshinter ) - { - FT_FREE( pic_container->pshinter ); - pic_container->pshinter = NULL; - } - } - - - FT_Error - pshinter_module_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - PSHinterPIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->pshinter = container; - - /* add call to initialization function when you add new scripts */ - FT_Init_Class_pshinter_interface( - library, &container->pshinter_interface ); - - if ( error ) - pshinter_module_class_pic_free( library ); - - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshpic.h b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshpic.h deleted file mode 100644 index 4469ba87c80..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshpic.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************/ -/* */ -/* pshpic.h */ -/* */ -/* The FreeType position independent code services for pshinter module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef PSHPIC_H_ -#define PSHPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -#ifndef FT_CONFIG_OPTION_PIC - -#define PSHINTER_INTERFACE_GET pshinter_interface - -#else /* FT_CONFIG_OPTION_PIC */ - -#include FT_INTERNAL_POSTSCRIPT_HINTS_H - -FT_BEGIN_HEADER - - typedef struct PSHinterPIC_ - { - PSHinter_Interface pshinter_interface; - - } PSHinterPIC; - - -#define GET_PIC( lib ) ( (PSHinterPIC*)( (lib)->pic_container.pshinter ) ) - -#define PSHINTER_INTERFACE_GET ( GET_PIC( library )->pshinter_interface ) - - /* see pshpic.c for the implementation */ - void - pshinter_module_class_pic_free( FT_Library library ); - - FT_Error - pshinter_module_class_pic_init( FT_Library library ); - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* PSHPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c index 6648d13d60f..9dd09efe4ca 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshrec.c */ -/* */ -/* FreeType PostScript hints recorder (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshrec.c + * + * FreeType PostScript hints recorder (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -28,7 +28,7 @@ #include "pshnterr.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pshrec +#define FT_COMPONENT pshrec #ifdef DEBUG_HINTER PS_Hints ps_debug_hints = NULL; @@ -666,7 +666,7 @@ if ( len == -21 ) { flags |= PS_HINT_FLAG_BOTTOM; - pos += len; + pos = ADD_INT( pos, len ); } len = 0; } @@ -1187,7 +1187,7 @@ /* compute integer stem positions in font units */ for ( n = 0; n < count * 2; n++ ) { - y += coords[n]; + y = ADD_LONG( y, coords[n] ); stems[n] = FIXED_TO_INT( y ); } diff --git a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h index 7e3dfe0d538..02cc2102ec3 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h +++ b/src/src/java.desktop/share/native/libfreetype/src/pshinter/pshrec.h @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* pshrec.h */ -/* */ -/* Postscript (Type1/Type2) hints recorder (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /**************************************************************************/ - /* */ - /* The functions defined here are called from the Type 1, CID and CFF */ - /* font drivers to record the hints of a given character/glyph. */ - /* */ - /* The hints are recorded in a unified format, and are later processed */ - /* by the `optimizer' and `fitter' to adjust the outlines to the pixel */ - /* grid. */ - /* */ - /**************************************************************************/ +/**************************************************************************** + * + * pshrec.h + * + * Postscript (Type1/Type2) hints recorder (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /*************************************************************************** + * + * The functions defined here are called from the Type 1, CID and CFF + * font drivers to record the hints of a given character/glyph. + * + * The hints are recorded in a unified format, and are later processed + * by the `optimizer' and `fitter' to adjust the outlines to the pixel + * grid. + * + */ #ifndef PSHREC_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c b/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c index 8929ebe751d..0ec440e67b4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c +++ b/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psmodule.c */ -/* */ -/* PSNames module implementation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psmodule.c + * + * psnames module implementation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,16 +24,16 @@ #include "psmodule.h" /* - * The file `pstables.h' with its arrays and its function - * `ft_get_adobe_glyph_index' is useful for other projects also (for - * example, `pdfium' is using it). However, if used as a C++ header, - * including it in two different source files makes it necessary to use - * `extern const' for the declaration of its arrays, otherwise the data - * would be duplicated as mandated by the C++ standard. + * The file `pstables.h' with its arrays and its function + * `ft_get_adobe_glyph_index' is useful for other projects also (for + * example, `pdfium' is using it). However, if used as a C++ header, + * including it in two different source files makes it necessary to use + * `extern const' for the declaration of its arrays, otherwise the data + * would be duplicated as mandated by the C++ standard. * - * For this reason, we use `DEFINE_PS_TABLES' to guard the function - * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array - * declarations and definitions. + * For this reason, we use `DEFINE_PS_TABLES' to guard the function + * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array + * declarations and definitions. */ #include "pstables.h" #define DEFINE_PS_TABLES @@ -41,7 +41,6 @@ #include "pstables.h" #include "psnamerr.h" -#include "pspic.h" #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES @@ -393,7 +392,9 @@ /* Reallocate if the number of used entries is much smaller. */ if ( count < num_glyphs / 2 ) { - (void)FT_RENEW_ARRAY( table->maps, num_glyphs, count ); + (void)FT_RENEW_ARRAY( table->maps, + num_glyphs + EXTRA_GLYPH_LIST_SIZE, + count ); error = FT_Err_Ok; } @@ -577,28 +578,16 @@ FT_DEFINE_SERVICEDESCREC1( pscmaps_services, - FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET ) + FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface ) static FT_Pointer psnames_get_service( FT_Module module, const char* service_id ) { - /* PSCMAPS_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library; - - - if ( !module ) - return NULL; - library = module->library; - if ( !library ) - return NULL; -#else FT_UNUSED( module ); -#endif - return ft_service_list_lookup( PSCMAPS_SERVICES_GET, service_id ); + return ft_service_list_lookup( pscmaps_services, service_id ); } #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ @@ -621,7 +610,7 @@ 0x20000L, /* driver requires FreeType 2 or above */ PUT_PS_NAMES_SERVICE( - (void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */ + (void*)&pscmaps_interface ), /* module specific interface */ (FT_Module_Constructor)NULL, /* module_init */ (FT_Module_Destructor) NULL, /* module_done */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h b/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h index 3e94f8b437e..0df9a7d889c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psnames/psmodule.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psmodule.h */ -/* */ -/* High-level PSNames module interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psmodule.h + * + * High-level psnames module interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSMODULE_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h b/src/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h index 14eb76c99cf..67ab1765d38 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psnames/psnamerr.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* psnamerr.h */ -/* */ -/* PS names module error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PS names module error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * psnamerr.h + * + * PS names module error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PS names module error enumeration + * constants. + * + */ #ifndef PSNAMERR_H_ #define PSNAMERR_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psnames/pspic.c b/src/src/java.desktop/share/native/libfreetype/src/psnames/pspic.c deleted file mode 100644 index 85a06f36037..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/psnames/pspic.c +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************/ -/* */ -/* pspic.c */ -/* */ -/* The FreeType position independent code services for psnames module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "pspic.h" -#include "psnamerr.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from psmodule.c */ - FT_Error - FT_Create_Class_pscmaps_services( FT_Library library, - FT_ServiceDescRec** output_class ); - void - FT_Destroy_Class_pscmaps_services( FT_Library library, - FT_ServiceDescRec* clazz ); - - void - FT_Init_Class_pscmaps_interface( FT_Library library, - FT_Service_PsCMapsRec* clazz ); - - - void - psnames_module_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->psnames ) - { - PSModulePIC* container = (PSModulePIC*)pic_container->psnames; - - - if ( container->pscmaps_services ) - FT_Destroy_Class_pscmaps_services( library, - container->pscmaps_services ); - container->pscmaps_services = NULL; - FT_FREE( container ); - pic_container->psnames = NULL; - } - } - - - FT_Error - psnames_module_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - PSModulePIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->psnames = container; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - error = FT_Create_Class_pscmaps_services( - library, &container->pscmaps_services ); - if ( error ) - goto Exit; - FT_Init_Class_pscmaps_interface( library, - &container->pscmaps_interface ); - - Exit: - if ( error ) - psnames_module_class_pic_free( library ); - return error; - } - - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psnames/pspic.h b/src/src/java.desktop/share/native/libfreetype/src/psnames/pspic.h deleted file mode 100644 index 889780cc032..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/psnames/pspic.h +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************/ -/* */ -/* pspic.h */ -/* */ -/* The FreeType position independent code services for psnames module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef PSPIC_H_ -#define PSPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -#ifndef FT_CONFIG_OPTION_PIC - -#define PSCMAPS_SERVICES_GET pscmaps_services -#define PSCMAPS_INTERFACE_GET pscmaps_interface - -#else /* FT_CONFIG_OPTION_PIC */ - -#include FT_SERVICE_POSTSCRIPT_CMAPS_H - - -FT_BEGIN_HEADER - - typedef struct PSModulePIC_ - { - FT_ServiceDescRec* pscmaps_services; - FT_Service_PsCMapsRec pscmaps_interface; - - } PSModulePIC; - - -#define GET_PIC( lib ) \ - ( (PSModulePIC*)((lib)->pic_container.psnames) ) -#define PSCMAPS_SERVICES_GET ( GET_PIC( library )->pscmaps_services ) -#define PSCMAPS_INTERFACE_GET ( GET_PIC( library )->pscmaps_interface ) - - - /* see pspic.c for the implementation */ - void - psnames_module_class_pic_free( FT_Library library ); - - FT_Error - psnames_module_class_pic_init( FT_Library library ); - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* PSPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h b/src/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h index 79545ee0396..c0139bbc601 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h +++ b/src/src/java.desktop/share/native/libfreetype/src/psnames/pstables.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pstables.h */ -/* */ -/* PostScript glyph names. */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pstables.h + * + * PostScript glyph names. + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* This file has been generated automatically -- do not edit! */ @@ -609,12 +609,12 @@ /* - * This table is a compressed version of the Adobe Glyph List (AGL), - * optimized for efficient searching. It has been generated by the - * `glnames.py' python script located in the `src/tools' directory. + * This table is a compressed version of the Adobe Glyph List (AGL), + * optimized for efficient searching. It has been generated by the + * `glnames.py' python script located in the `src/tools' directory. * - * The lookup function to get the Unicode value for a given string - * is defined below the table. + * The lookup function to get the Unicode value for a given string + * is defined below the table. */ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST @@ -4137,7 +4137,7 @@ #ifdef DEFINE_PS_TABLES /* - * This function searches the compressed table efficiently. + * This function searches the compressed table efficiently. */ static unsigned long ft_get_adobe_glyph_index( const char* name, diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h b/src/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h index 7e401190711..a246569e3be 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h +++ b/src/src/java.desktop/share/native/libfreetype/src/raster/ftmisc.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftmisc.h */ -/* */ -/* Miscellaneous macros for stand-alone rasterizer (specification */ -/* only). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /***************************************************/ - /* */ - /* This file is *not* portable! You have to adapt */ - /* its definitions to your platform. */ - /* */ - /***************************************************/ +/**************************************************************************** + * + * ftmisc.h + * + * Miscellaneous macros for stand-alone rasterizer (specification + * only). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /**************************************************** + * + * This file is *not* portable! You have to adapt + * its definitions to your platform. + * + */ #ifndef FTMISC_H_ #define FTMISC_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c b/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c index 4354730d54e..798a72d02a1 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c +++ b/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.c @@ -1,51 +1,51 @@ -/***************************************************************************/ -/* */ -/* ftraster.c */ -/* */ -/* The FreeType glyph rasterizer (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file can be compiled without the rest of the FreeType engine, by */ - /* defining the STANDALONE_ macro when compiling it. You also need to */ - /* put the files `ftimage.h' and `ftmisc.h' into the $(incdir) */ - /* directory. Typically, you should do something like */ - /* */ - /* - copy `src/raster/ftraster.c' (this file) to your current directory */ - /* */ - /* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' to your */ - /* current directory */ - /* */ - /* - compile `ftraster' with the STANDALONE_ macro defined, as in */ - /* */ - /* cc -c -DSTANDALONE_ ftraster.c */ - /* */ - /* The renderer can be initialized with a call to */ - /* `ft_standard_raster.raster_new'; a bitmap can be generated */ - /* with a call to `ft_standard_raster.raster_render'. */ - /* */ - /* See the comments and documentation in the file `ftimage.h' for more */ - /* details on how the raster works. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is a rewrite of the FreeType 1.x scan-line converter */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftraster.c + * + * The FreeType glyph rasterizer (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file can be compiled without the rest of the FreeType engine, by + * defining the STANDALONE_ macro when compiling it. You also need to + * put the files `ftimage.h' and `ftmisc.h' into the $(incdir) + * directory. Typically, you should do something like + * + * - copy `src/raster/ftraster.c' (this file) to your current directory + * + * - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' to your + * current directory + * + * - compile `ftraster' with the STANDALONE_ macro defined, as in + * + * cc -c -DSTANDALONE_ ftraster.c + * + * The renderer can be initialized with a call to + * `ft_standard_raster.raster_new'; a bitmap can be generated + * with a call to `ft_standard_raster.raster_render'. + * + * See the comments and documentation in the file `ftimage.h' for more + * details on how the raster works. + * + */ + + + /************************************************************************** + * + * This is a rewrite of the FreeType 1.x scan-line converter + * + */ #ifdef STANDALONE_ @@ -65,82 +65,81 @@ #include <ft2build.h> #include "ftraster.h" #include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */ - -#include "rastpic.h" +#include FT_OUTLINE_H /* for FT_Outline_Get_CBox */ #endif /* !STANDALONE_ */ - /*************************************************************************/ - /* */ - /* A simple technical note on how the raster works */ - /* ----------------------------------------------- */ - /* */ - /* Converting an outline into a bitmap is achieved in several steps: */ - /* */ - /* 1 - Decomposing the outline into successive `profiles'. Each */ - /* profile is simply an array of scanline intersections on a given */ - /* dimension. A profile's main attributes are */ - /* */ - /* o its scanline position boundaries, i.e. `Ymin' and `Ymax' */ - /* */ - /* o an array of intersection coordinates for each scanline */ - /* between `Ymin' and `Ymax' */ - /* */ - /* o a direction, indicating whether it was built going `up' or */ - /* `down', as this is very important for filling rules */ - /* */ - /* o its drop-out mode */ - /* */ - /* 2 - Sweeping the target map's scanlines in order to compute segment */ - /* `spans' which are then filled. Additionally, this pass */ - /* performs drop-out control. */ - /* */ - /* The outline data is parsed during step 1 only. The profiles are */ - /* built from the bottom of the render pool, used as a stack. The */ - /* following graphics shows the profile list under construction: */ - /* */ - /* __________________________________________________________ _ _ */ - /* | | | | | */ - /* | profile | coordinates for | profile | coordinates for |--> */ - /* | 1 | profile 1 | 2 | profile 2 |--> */ - /* |_________|_________________|_________|_________________|__ _ _ */ - /* */ - /* ^ ^ */ - /* | | */ - /* start of render pool top */ - /* */ - /* The top of the profile stack is kept in the `top' variable. */ - /* */ - /* As you can see, a profile record is pushed on top of the render */ - /* pool, which is then followed by its coordinates/intersections. If */ - /* a change of direction is detected in the outline, a new profile is */ - /* generated until the end of the outline. */ - /* */ - /* Note that when all profiles have been generated, the function */ - /* Finalize_Profile_Table() is used to record, for each profile, its */ - /* bottom-most scanline as well as the scanline above its upmost */ - /* boundary. These positions are called `y-turns' because they (sort */ - /* of) correspond to local extrema. They are stored in a sorted list */ - /* built from the top of the render pool as a downwards stack: */ - /* */ - /* _ _ _______________________________________ */ - /* | | */ - /* <--| sorted list of | */ - /* <--| extrema scanlines | */ - /* _ _ __________________|____________________| */ - /* */ - /* ^ ^ */ - /* | | */ - /* maxBuff sizeBuff = end of pool */ - /* */ - /* This list is later used during the sweep phase in order to */ - /* optimize performance (see technical note on the sweep below). */ - /* */ - /* Of course, the raster detects whether the two stacks collide and */ - /* handles the situation properly. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * A simple technical note on how the raster works + * ----------------------------------------------- + * + * Converting an outline into a bitmap is achieved in several steps: + * + * 1 - Decomposing the outline into successive `profiles'. Each + * profile is simply an array of scanline intersections on a given + * dimension. A profile's main attributes are + * + * o its scanline position boundaries, i.e. `Ymin' and `Ymax' + * + * o an array of intersection coordinates for each scanline + * between `Ymin' and `Ymax' + * + * o a direction, indicating whether it was built going `up' or + * `down', as this is very important for filling rules + * + * o its drop-out mode + * + * 2 - Sweeping the target map's scanlines in order to compute segment + * `spans' which are then filled. Additionally, this pass + * performs drop-out control. + * + * The outline data is parsed during step 1 only. The profiles are + * built from the bottom of the render pool, used as a stack. The + * following graphics shows the profile list under construction: + * + * __________________________________________________________ _ _ + * | | | | | + * | profile | coordinates for | profile | coordinates for |--> + * | 1 | profile 1 | 2 | profile 2 |--> + * |_________|_________________|_________|_________________|__ _ _ + * + * ^ ^ + * | | + * start of render pool top + * + * The top of the profile stack is kept in the `top' variable. + * + * As you can see, a profile record is pushed on top of the render + * pool, which is then followed by its coordinates/intersections. If + * a change of direction is detected in the outline, a new profile is + * generated until the end of the outline. + * + * Note that when all profiles have been generated, the function + * Finalize_Profile_Table() is used to record, for each profile, its + * bottom-most scanline as well as the scanline above its upmost + * boundary. These positions are called `y-turns' because they (sort + * of) correspond to local extrema. They are stored in a sorted list + * built from the top of the render pool as a downwards stack: + * + * _ _ _______________________________________ + * | | + * <--| sorted list of | + * <--| extrema scanlines | + * _ _ __________________|____________________| + * + * ^ ^ + * | | + * maxBuff sizeBuff = end of pool + * + * This list is later used during the sweep phase in order to + * optimize performance (see technical note on the sweep below). + * + * Of course, the raster detects whether the two stacks collide and + * handles the situation properly. + * + */ /*************************************************************************/ @@ -163,14 +162,14 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_raster +#define FT_COMPONENT raster #ifdef STANDALONE_ @@ -452,9 +451,9 @@ #define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision ) #define TRUNC( x ) ( (Long)(x) >> ras.precision_bits ) #define FRAC( x ) ( (x) & ( ras.precision - 1 ) ) -#define SCALED( x ) ( ( (x) < 0 ? -( -(x) << ras.scale_shift ) \ - : ( (x) << ras.scale_shift ) ) \ - - ras.precision_half ) + + /* scale and shift grid to pixel centers */ +#define SCALED( x ) ( (x) * ras.precision_scale - ras.precision_half ) #define IS_BOTTOM_OVERSHOOT( x ) \ (Bool)( CEILING( x ) - x >= ras.precision_half ) @@ -476,13 +475,10 @@ Int precision_bits; /* precision related variables */ Int precision; Int precision_half; - Int precision_shift; + Int precision_scale; Int precision_step; Int precision_jitter; - Int scale_shift; /* == precision_shift for bitmaps */ - /* == precision_shift+1 for pixmaps */ - PLong buff; /* The profiles buffer */ PLong sizeBuff; /* Render pool size */ PLong maxBuff; /* Profiles buffer size */ @@ -495,8 +491,7 @@ TPoint* arc; /* current Bezier arc pointer */ UShort bWidth; /* target bitmap width */ - PByte bTarget; /* target bitmap buffer */ - PByte gTarget; /* target pixmap buffer */ + PByte bOrigin; /* target bitmap bottom-left origin */ Long lastX, lastY; Long minY, maxY; @@ -519,8 +514,6 @@ FT_Outline outline; Long traceOfs; /* current offset in target bitmap */ - Long traceG; /* current offset in target pixmap */ - Short traceIncr; /* sweep's increment in target bitmap */ /* dispatch variables */ @@ -572,18 +565,19 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* Set_High_Precision */ - /* */ - /* <Description> */ - /* Set precision variables according to param flag. */ - /* */ - /* <Input> */ - /* High :: Set to True for high precision (typically for ppem < 24), */ - /* false otherwise. */ - /* */ + /************************************************************************** + * + * @Function: + * Set_High_Precision + * + * @Description: + * Set precision variables according to param flag. + * + * @Input: + * High :: + * Set to True for high precision (typically for ppem < 24), + * false otherwise. + */ static void Set_High_Precision( RAS_ARGS Int High ) { @@ -625,29 +619,31 @@ FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" )); ras.precision = 1 << ras.precision_bits; - ras.precision_half = ras.precision / 2; - ras.precision_shift = ras.precision_bits - Pixel_Bits; + ras.precision_half = ras.precision >> 1; + ras.precision_scale = ras.precision >> Pixel_Bits; } - /*************************************************************************/ - /* */ - /* <Function> */ - /* New_Profile */ - /* */ - /* <Description> */ - /* Create a new profile in the render pool. */ - /* */ - /* <Input> */ - /* aState :: The state/orientation of the new profile. */ - /* */ - /* overshoot :: Whether the profile's unrounded start position */ - /* differs by at least a half pixel. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow or of incoherent */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * New_Profile + * + * @Description: + * Create a new profile in the render pool. + * + * @Input: + * aState :: + * The state/orientation of the new profile. + * + * overshoot :: + * Whether the profile's unrounded start position + * differs by at least a half pixel. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow or of incoherent + * profile. + */ static Bool New_Profile( RAS_ARGS TStates aState, Bool overshoot ) @@ -706,21 +702,22 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* End_Profile */ - /* */ - /* <Description> */ - /* Finalize the current profile. */ - /* */ - /* <Input> */ - /* overshoot :: Whether the profile's unrounded end position differs */ - /* by at least a half pixel. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow or incoherency. */ - /* */ + /************************************************************************** + * + * @Function: + * End_Profile + * + * @Description: + * Finalize the current profile. + * + * @Input: + * overshoot :: + * Whether the profile's unrounded end position differs + * by at least a half pixel. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow or incoherency. + */ static Bool End_Profile( RAS_ARGS Bool overshoot ) { @@ -778,21 +775,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Insert_Y_Turn */ - /* */ - /* <Description> */ - /* Insert a salient into the sorted list placed on top of the render */ - /* pool. */ - /* */ - /* <Input> */ - /* New y scanline position. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Insert_Y_Turn + * + * @Description: + * Insert a salient into the sorted list placed on top of the render + * pool. + * + * @Input: + * New y scanline position. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow. + */ static Bool Insert_Y_Turn( RAS_ARGS Int y ) { @@ -834,17 +831,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Finalize_Profile_Table */ - /* */ - /* <Description> */ - /* Adjust all links in the profiles list. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Finalize_Profile_Table + * + * @Description: + * Adjust all links in the profiles list. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow. + */ static Bool Finalize_Profile_Table( RAS_ARG ) { @@ -894,22 +891,22 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Split_Conic */ - /* */ - /* <Description> */ - /* Subdivide one conic Bezier into two joint sub-arcs in the Bezier */ - /* stack. */ - /* */ - /* <Input> */ - /* None (subdivided Bezier is taken from the top of the stack). */ - /* */ - /* <Note> */ - /* This routine is the `beef' of this component. It is _the_ inner */ - /* loop that should be optimized to hell to get the best performance. */ - /* */ + /************************************************************************** + * + * @Function: + * Split_Conic + * + * @Description: + * Subdivide one conic Bezier into two joint sub-arcs in the Bezier + * stack. + * + * @Input: + * None (subdivided Bezier is taken from the top of the stack). + * + * @Note: + * This routine is the `beef' of this component. It is _the_ inner + * loop that should be optimized to hell to get the best performance. + */ static void Split_Conic( TPoint* base ) { @@ -933,20 +930,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Split_Cubic */ - /* */ - /* <Description> */ - /* Subdivide a third-order Bezier arc into two joint sub-arcs in the */ - /* Bezier stack. */ - /* */ - /* <Note> */ - /* This routine is the `beef' of the component. It is one of _the_ */ - /* inner loops that should be optimized like hell to get the best */ - /* performance. */ - /* */ + /************************************************************************** + * + * @Function: + * Split_Cubic + * + * @Description: + * Subdivide a third-order Bezier arc into two joint sub-arcs in the + * Bezier stack. + * + * @Note: + * This routine is the `beef' of the component. It is one of _the_ + * inner loops that should be optimized like hell to get the best + * performance. + */ static void Split_Cubic( TPoint* base ) { @@ -975,31 +972,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Line_Up */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an ascending line segment and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* x1 :: The x-coordinate of the segment's start point. */ - /* */ - /* y1 :: The y-coordinate of the segment's start point. */ - /* */ - /* x2 :: The x-coordinate of the segment's end point. */ - /* */ - /* y2 :: The y-coordinate of the segment's end point. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Line_Up + * + * @Description: + * Compute the x-coordinates of an ascending line segment and store + * them in the render pool. + * + * @Input: + * x1 :: + * The x-coordinate of the segment's start point. + * + * y1 :: + * The y-coordinate of the segment's start point. + * + * x2 :: + * The x-coordinate of the segment's end point. + * + * y2 :: + * The y-coordinate of the segment's end point. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Line_Up( RAS_ARGS Long x1, Long y1, @@ -1114,31 +1117,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Line_Down */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an descending line segment and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* x1 :: The x-coordinate of the segment's start point. */ - /* */ - /* y1 :: The y-coordinate of the segment's start point. */ - /* */ - /* x2 :: The x-coordinate of the segment's end point. */ - /* */ - /* y2 :: The y-coordinate of the segment's end point. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Line_Down + * + * @Description: + * Compute the x-coordinates of an descending line segment and store + * them in the render pool. + * + * @Input: + * x1 :: + * The x-coordinate of the segment's start point. + * + * y1 :: + * The y-coordinate of the segment's start point. + * + * x2 :: + * The x-coordinate of the segment's end point. + * + * y2 :: + * The y-coordinate of the segment's end point. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Line_Down( RAS_ARGS Long x1, Long y1, @@ -1165,27 +1174,31 @@ typedef void (*TSplitter)( TPoint* base ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* Bezier_Up */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an ascending Bezier arc and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* degree :: The degree of the Bezier arc (either 2 or 3). */ - /* */ - /* splitter :: The function to split Bezier arcs. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Bezier_Up + * + * @Description: + * Compute the x-coordinates of an ascending Bezier arc and store + * them in the render pool. + * + * @Input: + * degree :: + * The degree of the Bezier arc (either 2 or 3). + * + * splitter :: + * The function to split Bezier arcs. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Bezier_Up( RAS_ARGS Int degree, TSplitter splitter, @@ -1298,27 +1311,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Bezier_Down */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an descending Bezier arc and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* degree :: The degree of the Bezier arc (either 2 or 3). */ - /* */ - /* splitter :: The function to split Bezier arcs. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Bezier_Down + * + * @Description: + * Compute the x-coordinates of an descending Bezier arc and store + * them in the render pool. + * + * @Input: + * degree :: + * The degree of the Bezier arc (either 2 or 3). + * + * splitter :: + * The function to split Bezier arcs. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Bezier_Down( RAS_ARGS Int degree, TSplitter splitter, @@ -1347,25 +1364,27 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Line_To */ - /* */ - /* <Description> */ - /* Inject a new line segment and adjust the Profiles list. */ - /* */ - /* <Input> */ - /* x :: The x-coordinate of the segment's end point (its start point */ - /* is stored in `lastX'). */ - /* */ - /* y :: The y-coordinate of the segment's end point (its start point */ - /* is stored in `lastY'). */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow or incorrect */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * Line_To + * + * @Description: + * Inject a new line segment and adjust the Profiles list. + * + * @Input: + * x :: + * The x-coordinate of the segment's end point (its start point + * is stored in `lastX'). + * + * y :: + * The y-coordinate of the segment's end point (its start point + * is stored in `lastY'). + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow or incorrect + * profile. + */ static Bool Line_To( RAS_ARGS Long x, Long y ) @@ -1441,29 +1460,33 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Conic_To */ - /* */ - /* <Description> */ - /* Inject a new conic arc and adjust the profile list. */ - /* */ - /* <Input> */ - /* cx :: The x-coordinate of the arc's new control point. */ - /* */ - /* cy :: The y-coordinate of the arc's new control point. */ - /* */ - /* x :: The x-coordinate of the arc's end point (its start point is */ - /* stored in `lastX'). */ - /* */ - /* y :: The y-coordinate of the arc's end point (its start point is */ - /* stored in `lastY'). */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow or incorrect */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * Conic_To + * + * @Description: + * Inject a new conic arc and adjust the profile list. + * + * @Input: + * cx :: + * The x-coordinate of the arc's new control point. + * + * cy :: + * The y-coordinate of the arc's new control point. + * + * x :: + * The x-coordinate of the arc's end point (its start point is + * stored in `lastX'). + * + * y :: + * The y-coordinate of the arc's end point (its start point is + * stored in `lastY'). + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow or incorrect + * profile. + */ static Bool Conic_To( RAS_ARGS Long cx, Long cy, @@ -1558,33 +1581,39 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Cubic_To */ - /* */ - /* <Description> */ - /* Inject a new cubic arc and adjust the profile list. */ - /* */ - /* <Input> */ - /* cx1 :: The x-coordinate of the arc's first new control point. */ - /* */ - /* cy1 :: The y-coordinate of the arc's first new control point. */ - /* */ - /* cx2 :: The x-coordinate of the arc's second new control point. */ - /* */ - /* cy2 :: The y-coordinate of the arc's second new control point. */ - /* */ - /* x :: The x-coordinate of the arc's end point (its start point is */ - /* stored in `lastX'). */ - /* */ - /* y :: The y-coordinate of the arc's end point (its start point is */ - /* stored in `lastY'). */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow or incorrect */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * Cubic_To + * + * @Description: + * Inject a new cubic arc and adjust the profile list. + * + * @Input: + * cx1 :: + * The x-coordinate of the arc's first new control point. + * + * cy1 :: + * The y-coordinate of the arc's first new control point. + * + * cx2 :: + * The x-coordinate of the arc's second new control point. + * + * cy2 :: + * The y-coordinate of the arc's second new control point. + * + * x :: + * The x-coordinate of the arc's end point (its start point is + * stored in `lastX'). + * + * y :: + * The y-coordinate of the arc's end point (its start point is + * stored in `lastY'). + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow or incorrect + * profile. + */ static Bool Cubic_To( RAS_ARGS Long cx1, Long cy1, @@ -1705,27 +1734,30 @@ } while ( 0 ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* Decompose_Curve */ - /* */ - /* <Description> */ - /* Scan the outline arrays in order to emit individual segments and */ - /* Beziers by calling Line_To() and Bezier_To(). It handles all */ - /* weird cases, like when the first point is off the curve, or when */ - /* there are simply no `on' points in the contour! */ - /* */ - /* <Input> */ - /* first :: The index of the first point in the contour. */ - /* */ - /* last :: The index of the last point in the contour. */ - /* */ - /* flipped :: If set, flip the direction of the curve. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on error. */ - /* */ + /************************************************************************** + * + * @Function: + * Decompose_Curve + * + * @Description: + * Scan the outline arrays in order to emit individual segments and + * Beziers by calling Line_To() and Bezier_To(). It handles all + * weird cases, like when the first point is off the curve, or when + * there are simply no `on' points in the contour! + * + * @Input: + * first :: + * The index of the first point in the contour. + * + * last :: + * The index of the last point in the contour. + * + * flipped :: + * If set, flip the direction of the curve. + * + * @Return: + * SUCCESS on success, FAILURE on error. + */ static Bool Decompose_Curve( RAS_ARGS UShort first, UShort last, @@ -1934,22 +1966,23 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Convert_Glyph */ - /* */ - /* <Description> */ - /* Convert a glyph into a series of segments and arcs and make a */ - /* profiles list with them. */ - /* */ - /* <Input> */ - /* flipped :: If set, flip the direction of curve. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE if any error was encountered during */ - /* rendering. */ - /* */ + /************************************************************************** + * + * @Function: + * Convert_Glyph + * + * @Description: + * Convert a glyph into a series of segments and arcs and make a + * profiles list with them. + * + * @Input: + * flipped :: + * If set, flip the direction of curve. + * + * @Return: + * SUCCESS on success, FAILURE if any error was encountered during + * rendering. + */ static Bool Convert_Glyph( RAS_ARGS Int flipped ) { @@ -2028,12 +2061,12 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Init_Linked */ - /* */ - /* Initializes an empty linked list. */ - /* */ + /************************************************************************** + * + * Init_Linked + * + * Initializes an empty linked list. + */ static void Init_Linked( TProfileList* l ) { @@ -2041,12 +2074,12 @@ } - /*************************************************************************/ - /* */ - /* InsNew */ - /* */ - /* Inserts a new profile in a linked list. */ - /* */ + /************************************************************************** + * + * InsNew + * + * Inserts a new profile in a linked list. + */ static void InsNew( PProfileList list, PProfile profile ) @@ -2072,12 +2105,12 @@ } - /*************************************************************************/ - /* */ - /* DelOld */ - /* */ - /* Removes an old profile from a linked list. */ - /* */ + /************************************************************************** + * + * DelOld + * + * Removes an old profile from a linked list. + */ static void DelOld( PProfileList list, PProfile profile ) @@ -2105,14 +2138,14 @@ } - /*************************************************************************/ - /* */ - /* Sort */ - /* */ - /* Sorts a trace list. In 95%, the list is already sorted. We need */ - /* an algorithm which is fast in this case. Bubble sort is enough */ - /* and simple. */ - /* */ + /************************************************************************** + * + * Sort + * + * Sorts a trace list. In 95%, the list is already sorted. We need + * an algorithm which is fast in this case. Bubble sort is enough + * and simple. + */ static void Sort( PProfileList list ) { @@ -2163,14 +2196,14 @@ } - /*************************************************************************/ - /* */ - /* Vertical Sweep Procedure Set */ - /* */ - /* These four routines are used during the vertical black/white sweep */ - /* phase by the generic Draw_Sweep() function. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Vertical Sweep Procedure Set + * + * These four routines are used during the vertical black/white sweep + * phase by the generic Draw_Sweep() function. + * + */ static void Vertical_Sweep_Init( RAS_ARGS Short* min, @@ -2183,8 +2216,6 @@ ras.traceIncr = (Short)-pitch; ras.traceOfs = -*min * pitch; - if ( pitch > 0 ) - ras.traceOfs += (Long)( ras.target.rows - 1 ) * pitch; } @@ -2215,13 +2246,18 @@ /* Drop-out control */ - e1 = TRUNC( CEILING( x1 ) ); + e1 = CEILING( x1 ); + e2 = FLOOR( x2 ); + /* take care of the special case where both the left */ + /* and right contour lie exactly on pixel centers */ if ( dropOutControl != 2 && - x2 - x1 - ras.precision <= ras.precision_jitter ) + x2 - x1 - ras.precision <= ras.precision_jitter && + e1 != x1 && e2 != x2 ) e2 = e1; - else - e2 = TRUNC( FLOOR( x2 ) ); + + e1 = TRUNC( e1 ); + e2 = TRUNC( e2 ); if ( e2 >= 0 && e1 < ras.bWidth ) { @@ -2242,7 +2278,7 @@ f1 = (Byte) ( 0xFF >> ( e1 & 7 ) ); f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) ); - target = ras.bTarget + ras.traceOfs + c1; + target = ras.bOrigin + ras.traceOfs + c1; c2 -= c1; if ( c2 > 0 ) @@ -2252,12 +2288,9 @@ /* memset() is slower than the following code on many platforms. */ /* This is due to the fact that, in the vast majority of cases, */ /* the span length in bytes is relatively small. */ - c2--; - while ( c2 > 0 ) - { + while ( --c2 > 0 ) *(++target) = 0xFF; - c2--; - } + target[1] |= f2; } else @@ -2400,7 +2433,7 @@ f1 = (Short)( e1 & 7 ); if ( e1 >= 0 && e1 < ras.bWidth && - ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) ) + ras.bOrigin[ras.traceOfs + c1] & ( 0x80 >> f1 ) ) goto Exit; } else @@ -2416,7 +2449,7 @@ c1 = (Short)( e1 >> 3 ); f1 = (Short)( e1 & 7 ); - ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 ); + ras.bOrigin[ras.traceOfs + c1] |= (char)( 0x80 >> f1 ); } Exit: @@ -2431,14 +2464,14 @@ } - /***********************************************************************/ - /* */ - /* Horizontal Sweep Procedure Set */ - /* */ - /* These four routines are used during the horizontal black/white */ - /* sweep phase by the generic Draw_Sweep() function. */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * Horizontal Sweep Procedure Set + * + * These four routines are used during the horizontal black/white + * sweep phase by the generic Draw_Sweep() function. + * + */ static void Horizontal_Sweep_Init( RAS_ARGS Short* min, @@ -2483,19 +2516,14 @@ { Byte f1; PByte bits; - PByte p; FT_TRACE7(( " -> y=%d (drop-out)", e1 )); - bits = ras.bTarget + ( y >> 3 ); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); - p = bits - e1 * ras.target.pitch; - if ( ras.target.pitch > 0 ) - p += (Long)( ras.target.rows - 1 ) * ras.target.pitch; - - p[0] |= f1; + bits[0] |= f1; } } @@ -2597,13 +2625,9 @@ e1 = TRUNC( e1 ); - bits = ras.bTarget + ( y >> 3 ); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); - bits -= e1 * ras.target.pitch; - if ( ras.target.pitch > 0 ) - bits += (Long)( ras.target.rows - 1 ) * ras.target.pitch; - if ( e1 >= 0 && (ULong)e1 < ras.target.rows && *bits & f1 ) @@ -2619,12 +2643,8 @@ { FT_TRACE7(( " -> y=%d (drop-out)", e1 )); - bits = ras.bTarget + ( y >> 3 ); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); - bits -= e1 * ras.target.pitch; - - if ( ras.target.pitch > 0 ) - bits += (Long)( ras.target.rows - 1 ) * ras.target.pitch; bits[0] |= f1; } @@ -2642,11 +2662,11 @@ } - /*************************************************************************/ - /* */ - /* Generic Sweep Drawing routine */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Generic Sweep Drawing routine + * + */ static Bool Draw_Sweep( RAS_ARG ) @@ -2888,20 +2908,109 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Render_Single_Pass */ - /* */ - /* <Description> */ - /* Perform one sweep with sub-banding. */ - /* */ - /* <Input> */ - /* flipped :: If set, flip the direction of the outline. */ - /* */ - /* <Return> */ - /* Renderer error code. */ - /* */ +#ifdef STANDALONE_ + + /************************************************************************** + * + * The following functions should only compile in stand-alone mode, + * i.e., when building this component without the rest of FreeType. + * + */ + + /************************************************************************** + * + * @Function: + * FT_Outline_Get_CBox + * + * @Description: + * Return an outline's `control box'. The control box encloses all + * the outline's points, including Bézier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline + * that contains Bézier outside arcs). + * + * Computing the control box is very fast, while getting the bounding + * box can take much more time as it needs to walk over all segments + * and arcs in the outline. To get the latter, you can use the + * `ftbbox' component, which is dedicated to this single task. + * + * @Input: + * outline :: + * A pointer to the source outline descriptor. + * + * @Output: + * acbox :: + * The outline's control box. + * + * @Note: + * See @FT_Glyph_Get_CBox for a discussion of tricky fonts. + */ + + static void + FT_Outline_Get_CBox( const FT_Outline* outline, + FT_BBox *acbox ) + { + Long xMin, yMin, xMax, yMax; + + + if ( outline && acbox ) + { + if ( outline->n_points == 0 ) + { + xMin = 0; + yMin = 0; + xMax = 0; + yMax = 0; + } + else + { + FT_Vector* vec = outline->points; + FT_Vector* limit = vec + outline->n_points; + + + xMin = xMax = vec->x; + yMin = yMax = vec->y; + vec++; + + for ( ; vec < limit; vec++ ) + { + Long x, y; + + + x = vec->x; + if ( x < xMin ) xMin = x; + if ( x > xMax ) xMax = x; + + y = vec->y; + if ( y < yMin ) yMin = y; + if ( y > yMax ) yMax = y; + } + } + acbox->xMin = xMin; + acbox->xMax = xMax; + acbox->yMin = yMin; + acbox->yMax = yMax; + } + } + +#endif /* STANDALONE_ */ + + + /************************************************************************** + * + * @Function: + * Render_Single_Pass + * + * @Description: + * Perform one sweep with sub-banding. + * + * @Input: + * flipped :: + * If set, flip the direction of the outline. + * + * @Return: + * Renderer error code. + */ static int Render_Single_Pass( RAS_ARGS Bool flipped ) { @@ -2963,17 +3072,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Render_Glyph */ - /* */ - /* <Description> */ - /* Render a glyph in a bitmap. Sub-banding if needed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * Render_Glyph + * + * @Description: + * Render a glyph in a bitmap. Sub-banding if needed. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error Render_Glyph( RAS_ARG ) { @@ -2982,7 +3091,6 @@ Set_High_Precision( RAS_VARS ras.outline.flags & FT_OUTLINE_HIGH_PRECISION ); - ras.scale_shift = ras.precision_shift; if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS ) ras.dropOutControl = 2; @@ -3013,7 +3121,10 @@ ras.band_stack[0].y_max = (Short)( ras.target.rows - 1 ); ras.bWidth = (UShort)ras.target.width; - ras.bTarget = (Byte*)ras.target.buffer; + ras.bOrigin = (Byte*)ras.target.buffer; + + if ( ras.target.pitch > 0 ) + ras.bOrigin += (Long)( ras.target.rows - 1 ) * ras.target.pitch; if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 ) return error; @@ -3185,20 +3296,6 @@ if ( !target_map->buffer ) return FT_THROW( Invalid ); - /* reject too large outline coordinates */ - { - FT_Vector* vec = outline->points; - FT_Vector* limit = vec + outline->n_points; - - - for ( ; vec < limit; vec++ ) - { - if ( vec->x < -0x1000000L || vec->x > 0x1000000L || - vec->y < -0x1000000L || vec->y > 0x1000000L ) - return FT_THROW( Invalid ); - } - } - ras.outline = *outline; ras.target = *target_map; diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h b/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h index 40b5d6d321c..50d34201a1c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h +++ b/src/src/java.desktop/share/native/libfreetype/src/raster/ftraster.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftraster.h */ -/* */ -/* The FreeType glyph rasterizer (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftraster.h + * + * The FreeType glyph rasterizer (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTRASTER_H_ @@ -28,11 +28,11 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* Uncomment the following line if you are using ftraster.c as a */ - /* standalone module, fully independent of FreeType. */ - /* */ + /************************************************************************** + * + * Uncomment the following line if you are using ftraster.c as a + * standalone module, fully independent of FreeType. + */ /* #define STANDALONE_ */ FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_standard_raster; diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c b/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c index a7ce9731d77..62c727182a4 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c +++ b/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftrend1.c */ -/* */ -/* The FreeType glyph rasterizer interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrend1.c + * + * The FreeType glyph rasterizer interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -22,7 +22,6 @@ #include FT_OUTLINE_H #include "ftrend1.h" #include "ftraster.h" -#include "rastpic.h" #include "rasterrs.h" @@ -128,7 +127,11 @@ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } - ft_glyphslot_preset_bitmap( slot, mode, origin ); + if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) ) + { + error = FT_THROW( Raster_Overflow ); + goto Exit; + } /* allocate new one */ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) @@ -197,7 +200,7 @@ (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_raster1_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_STANDARD_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_standard_raster /* raster_class */ ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h b/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h index 2abdf2d703b..82ecac686c1 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h +++ b/src/src/java.desktop/share/native/libfreetype/src/raster/ftrend1.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftrend1.h */ -/* */ -/* The FreeType glyph rasterizer interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrend1.h + * + * The FreeType glyph rasterizer interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTREND1_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h b/src/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h index 22a3e153406..72664073657 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/raster/rasterrs.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* rasterrs.h */ -/* */ -/* monochrome renderer error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the monochrome renderer error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * rasterrs.h + * + * monochrome renderer error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the monochrome renderer error enumeration + * constants. + * + */ #ifndef RASTERRS_H_ #define RASTERRS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/rastpic.c b/src/src/java.desktop/share/native/libfreetype/src/raster/rastpic.c deleted file mode 100644 index 1dc8981b8a6..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/rastpic.c +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************/ -/* */ -/* rastpic.c */ -/* */ -/* The FreeType position independent code services for raster module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "rastpic.h" -#include "rasterrs.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from ftraster.c */ - void - FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs ); - - - void - ft_raster1_renderer_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->raster ) - { - RasterPIC* container = (RasterPIC*)pic_container->raster; - - - if ( --container->ref_count ) - return; - FT_FREE( container ); - pic_container->raster = NULL; - } - } - - - FT_Error - ft_raster1_renderer_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - RasterPIC* container = NULL; - FT_Memory memory = library->memory; - - - /* XXX: since this function also served the no longer available */ - /* raster5 renderer it uses reference counting, which could */ - /* be removed now */ - if ( pic_container->raster ) - { - ((RasterPIC*)pic_container->raster)->ref_count++; - return error; - } - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->raster = container; - - container->ref_count = 1; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - FT_Init_Class_ft_standard_raster( &container->ft_standard_raster ); - - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/raster/rastpic.h b/src/src/java.desktop/share/native/libfreetype/src/raster/rastpic.h deleted file mode 100644 index 6d0877c4239..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/raster/rastpic.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************/ -/* */ -/* rastpic.h */ -/* */ -/* The FreeType position independent code services for raster module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef RASTPIC_H_ -#define RASTPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -FT_BEGIN_HEADER - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_STANDARD_RASTER_GET ft_standard_raster - -#else /* FT_CONFIG_OPTION_PIC */ - - typedef struct RasterPIC_ - { - int ref_count; - FT_Raster_Funcs ft_standard_raster; - - } RasterPIC; - - -#define GET_PIC( lib ) \ - ( (RasterPIC*)( (lib)->pic_container.raster ) ) -#define FT_STANDARD_RASTER_GET ( GET_PIC( library )->ft_standard_raster ) - - - /* see rastpic.c for the implementation */ - void - ft_raster1_renderer_class_pic_free( FT_Library library ); - - FT_Error - ft_raster1_renderer_class_pic_init( FT_Library library ); - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -FT_END_HEADER - -#endif /* RASTPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c index 16020266afd..ca85d9751f0 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* pngshim.c */ -/* */ -/* PNG Bitmap glyph support. */ -/* */ -/* Copyright 2013-2018 by */ -/* Google, Inc. */ -/* Written by Stuart Gill and Behdad Esfahbod. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pngshim.c + * + * PNG Bitmap glyph support. + * + * Copyright (C) 2013-2019 by + * Google, Inc. + * Written by Stuart Gill and Behdad Esfahbod. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h index 194238c3a20..06c6f6b20e7 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* pngshim.h */ -/* */ -/* PNG Bitmap glyph support. */ -/* */ -/* Copyright 2013-2018 by */ -/* Google, Inc. */ -/* Written by Stuart Gill and Behdad Esfahbod. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pngshim.h + * + * PNG Bitmap glyph support. + * + * Copyright (C) 2013-2019 by + * Google, Inc. + * Written by Stuart Gill and Behdad Esfahbod. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PNGSHIM_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c index 303e1ca9f1a..c467ff4d370 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfdriver.c */ -/* */ -/* High-level SFNT driver interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfdriver.c + * + * High-level SFNT driver interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,7 +25,6 @@ #include "sfdriver.h" #include "ttload.h" #include "sfobjs.h" -#include "sfntpic.h" #include "sferrors.h" @@ -33,6 +32,11 @@ #include "ttsbit.h" #endif +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS +#include "ttcolr.h" +#include "ttcpal.h" +#endif + #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES #include "ttpost.h" #endif @@ -57,18 +61,18 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_sfdriver +#define FT_COMPONENT sfdriver /* - * SFNT TABLE SERVICE + * SFNT TABLE SERVICE * */ @@ -155,7 +159,7 @@ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES /* - * GLYPH DICT SERVICE + * GLYPH DICT SERVICE * */ @@ -222,7 +226,7 @@ /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -460,14 +464,12 @@ typedef int (*char_type_func)( int c ); - /* handling of PID/EID 3/0 and 3/1 is the same */ + /* Handling of PID/EID 3/0 and 3/1 is the same. */ #define IS_WIN( n ) ( (n)->platformID == 3 && \ - ( (n)->encodingID == 1 || (n)->encodingID == 0 ) && \ - (n)->languageID == 0x409 ) + ( (n)->encodingID == 1 || (n)->encodingID == 0 ) ) #define IS_APPLE( n ) ( (n)->platformID == 1 && \ - (n)->encodingID == 0 && \ - (n)->languageID == 0 ) + (n)->encodingID == 0 ) static char* get_win_string( FT_Memory memory, @@ -491,42 +493,40 @@ if ( FT_STREAM_SEEK( entry->stringOffset ) || FT_FRAME_ENTER( entry->stringLength ) ) - { - FT_FREE( result ); - entry->stringLength = 0; - entry->stringOffset = 0; - FT_FREE( entry->string ); - - return NULL; - } + goto get_win_string_error; r = (FT_String*)result; p = (FT_Char*)stream->cursor; for ( len = entry->stringLength / 2; len > 0; len--, p += 2 ) { - if ( p[0] == 0 ) + if ( p[0] == 0 && char_type( p[1] ) ) + *r++ = p[1]; + else { - if ( char_type( p[1] ) ) - *r++ = p[1]; - else - { - if ( report_invalid_characters ) - { - FT_TRACE0(( "get_win_string:" - " Character `%c' (0x%X) invalid in PS name string\n", - p[1], p[1] )); - /* it's not the job of FreeType to correct PS names... */ - *r++ = p[1]; - } - } + if ( report_invalid_characters ) + FT_TRACE0(( "get_win_string:" + " Character 0x%X invalid in PS name string\n", + ((unsigned)p[0])*256 + (unsigned)p[1] )); + break; } } - *r = '\0'; + if ( !len ) + *r = '\0'; FT_FRAME_EXIT(); - return result; + if ( !len ) + return result; + + get_win_string_error: + FT_FREE( result ); + + entry->stringLength = 0; + entry->stringOffset = 0; + FT_FREE( entry->string ); + + return NULL; } @@ -552,14 +552,7 @@ if ( FT_STREAM_SEEK( entry->stringOffset ) || FT_FRAME_ENTER( entry->stringLength ) ) - { - FT_FREE( result ); - entry->stringOffset = 0; - entry->stringLength = 0; - FT_FREE( entry->string ); - - return NULL; - } + goto get_apple_string_error; r = (FT_String*)result; p = (FT_Char*)stream->cursor; @@ -571,20 +564,28 @@ else { if ( report_invalid_characters ) - { FT_TRACE0(( "get_apple_string:" " Character `%c' (0x%X) invalid in PS name string\n", *p, *p )); - /* it's not the job of FreeType to correct PS names... */ - *r++ = *p; - } + break; } } - *r = '\0'; + if ( !len ) + *r = '\0'; FT_FRAME_EXIT(); - return result; + if ( !len ) + return result; + + get_apple_string_error: + FT_FREE( result ); + + entry->stringOffset = 0; + entry->stringLength = 0; + FT_FREE( entry->string ); + + return NULL; } @@ -607,10 +608,10 @@ if ( name->nameID == id && name->stringLength > 0 ) { - if ( IS_WIN( name ) ) + if ( IS_WIN( name ) && ( name->languageID == 0x409 || *win == -1 ) ) *win = n; - if ( IS_APPLE( name ) ) + if ( IS_APPLE( name ) && ( name->languageID == 0 || *apple == -1 ) ) *apple = n; } } @@ -643,9 +644,9 @@ /* - * Find the shortest decimal representation of a 16.16 fixed point - * number. The function fills `buf' with the result, returning a pointer - * to the position after the representation's last byte. + * Find the shortest decimal representation of a 16.16 fixed point + * number. The function fills `buf' with the result, returning a pointer + * to the position after the representation's last byte. */ static char* @@ -673,7 +674,7 @@ if ( fixed < 0 ) { *p++ = '-'; - fixed = -fixed; + fixed = NEG_INT( fixed ); } int_part = ( fixed >> 16 ) & 0xFFFF; @@ -828,13 +829,20 @@ face->name_table.names + win, sfnt_is_alphanumeric, 0 ); - else + if ( !result && apple != -1 ) result = get_apple_string( face->root.memory, face->name_table.stream, face->name_table.names + apple, sfnt_is_alphanumeric, 0 ); + if ( !result ) + { + FT_TRACE0(( "sfnt_get_var_ps_name:" + " No valid PS name prefix for font instances found\n" )); + return NULL; + } + len = ft_strlen( result ); /* sanitize if necessary; we reserve space for 36 bytes (a 128bit */ @@ -1052,7 +1060,7 @@ face->name_table.names + win, sfnt_is_postscript, 1 ); - else + if ( !result && apple != -1 ) result = get_apple_string( face->root.memory, face->name_table.stream, face->name_table.names + apple, @@ -1073,7 +1081,7 @@ /* - * TT CMAP INFO + * TT CMAP INFO */ FT_DEFINE_SERVICE_TTCMAPSREC( tt_service_get_cmap_info, @@ -1132,41 +1140,41 @@ /* - * SERVICE LIST + * SERVICE LIST */ #if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF FT_DEFINE_SERVICEDESCREC5( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict, + FT_SERVICE_ID_BDF, &sfnt_service_bdf, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_DEFINE_SERVICEDESCREC4( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #elif defined TT_CONFIG_OPTION_BDF FT_DEFINE_SERVICEDESCREC4( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_BDF, &sfnt_service_bdf, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #else FT_DEFINE_SERVICEDESCREC3( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #endif @@ -1174,21 +1182,9 @@ sfnt_get_interface( FT_Module module, const char* module_interface ) { - /* SFNT_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library; - - - if ( !module ) - return NULL; - library = module->library; - if ( !library ) - return NULL; -#else FT_UNUSED( module ); -#endif - return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface ); + return ft_service_list_lookup( sfnt_services, module_interface ); } @@ -1198,6 +1194,12 @@ #define PUT_EMBEDDED_BITMAPS( a ) NULL #endif +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS +#define PUT_COLOR_LAYERS( a ) a +#else +#define PUT_COLOR_LAYERS( a ) NULL +#endif + #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES #define PUT_PS_NAMES( a ) a #else @@ -1256,9 +1258,24 @@ /* TT_Free_Table_Func free_eblc */ PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ), - /* TT_Set_SBit_Strike_Func set_sbit_strike */ + /* TT_Set_SBit_Strike_Func set_sbit_strike */ PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ), - /* TT_Load_Strike_Metrics_Func load_strike_metrics */ + /* TT_Load_Strike_Metrics_Func load_strike_metrics */ + + PUT_COLOR_LAYERS( tt_face_load_cpal ), + /* TT_Load_Table_Func load_cpal */ + PUT_COLOR_LAYERS( tt_face_load_colr ), + /* TT_Load_Table_Func load_colr */ + PUT_COLOR_LAYERS( tt_face_free_cpal ), + /* TT_Free_Table_Func free_cpal */ + PUT_COLOR_LAYERS( tt_face_free_colr ), + /* TT_Free_Table_Func free_colr */ + PUT_COLOR_LAYERS( tt_face_palette_set ), + /* TT_Set_Palette_Func set_palette */ + PUT_COLOR_LAYERS( tt_face_get_colr_layer ), + /* TT_Get_Colr_Layer_Func get_colr_layer */ + PUT_COLOR_LAYERS( tt_face_colr_blend_layer ), + /* TT_Blend_Colr_Func colr_blend */ tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */ @@ -1277,7 +1294,7 @@ 0x10000L, /* driver version 1.0 */ 0x20000L, /* driver requires FreeType 2.0 or higher */ - (const void*)&SFNT_INTERFACE_GET, /* module specific interface */ + (const void*)&sfnt_interface, /* module specific interface */ (FT_Module_Constructor)NULL, /* module_init */ (FT_Module_Destructor) NULL, /* module_done */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h index 81c22d28870..8c174634b37 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfdriver.h */ -/* */ -/* High-level SFNT driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfdriver.h + * + * High-level SFNT driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SFDRIVER_H_ @@ -26,10 +26,8 @@ FT_BEGIN_HEADER - FT_DECLARE_MODULE( sfnt_module_class ) - FT_END_HEADER #endif /* SFDRIVER_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h index 74003d4b38c..43e148d2954 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sferrors.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* sferrors.h */ -/* */ -/* SFNT error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the SFNT error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * sferrors.h + * + * SFNT error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the SFNT error enumeration constants. + * + */ #ifndef SFERRORS_H_ #define SFERRORS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.c deleted file mode 100644 index db2d816ce68..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.c +++ /dev/null @@ -1,143 +0,0 @@ -/***************************************************************************/ -/* */ -/* sfntpic.c */ -/* */ -/* The FreeType position independent code services for sfnt module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "sfntpic.h" -#include "sferrors.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from sfdriver.c */ - FT_Error - FT_Create_Class_sfnt_services( FT_Library library, - FT_ServiceDescRec** output_class ); - void - FT_Destroy_Class_sfnt_services( FT_Library library, - FT_ServiceDescRec* clazz ); - void - FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz ); - void - FT_Init_Class_sfnt_interface( FT_Library library, - SFNT_Interface* clazz ); - void - FT_Init_Class_sfnt_service_glyph_dict( - FT_Library library, - FT_Service_GlyphDictRec* clazz ); - void - FT_Init_Class_sfnt_service_ps_name( - FT_Library library, - FT_Service_PsFontNameRec* clazz ); - void - FT_Init_Class_tt_service_get_cmap_info( - FT_Library library, - FT_Service_TTCMapsRec* clazz ); - void - FT_Init_Class_sfnt_service_sfnt_table( - FT_Service_SFNT_TableRec* clazz ); - - - /* forward declaration of PIC init functions from ttcmap.c */ - FT_Error - FT_Create_Class_tt_cmap_classes( FT_Library library, - TT_CMap_Class** output_class ); - void - FT_Destroy_Class_tt_cmap_classes( FT_Library library, - TT_CMap_Class* clazz ); - - - void - sfnt_module_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->sfnt ) - { - sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt; - - - if ( container->sfnt_services ) - FT_Destroy_Class_sfnt_services( library, - container->sfnt_services ); - container->sfnt_services = NULL; - - if ( container->tt_cmap_classes ) - FT_Destroy_Class_tt_cmap_classes( library, - container->tt_cmap_classes ); - container->tt_cmap_classes = NULL; - - FT_FREE( container ); - pic_container->sfnt = NULL; - } - } - - - FT_Error - sfnt_module_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - sfntModulePIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->sfnt = container; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - error = FT_Create_Class_sfnt_services( library, - &container->sfnt_services ); - if ( error ) - goto Exit; - - error = FT_Create_Class_tt_cmap_classes( library, - &container->tt_cmap_classes ); - if ( error ) - goto Exit; - - FT_Init_Class_sfnt_service_glyph_dict( - library, &container->sfnt_service_glyph_dict ); - FT_Init_Class_sfnt_service_ps_name( - library, &container->sfnt_service_ps_name ); - FT_Init_Class_tt_service_get_cmap_info( - library, &container->tt_service_get_cmap_info ); - FT_Init_Class_sfnt_service_sfnt_table( - &container->sfnt_service_sfnt_table ); -#ifdef TT_CONFIG_OPTION_BDF - FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf ); -#endif - FT_Init_Class_sfnt_interface( library, &container->sfnt_interface ); - - Exit: - if ( error ) - sfnt_module_class_pic_free( library ); - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.h deleted file mode 100644 index 8f43122d81b..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfntpic.h +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************/ -/* */ -/* sfntpic.h */ -/* */ -/* The FreeType position independent code services for sfnt module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef SFNTPIC_H_ -#define SFNTPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -#ifndef FT_CONFIG_OPTION_PIC - -#define SFNT_SERVICES_GET sfnt_services -#define SFNT_SERVICE_GLYPH_DICT_GET sfnt_service_glyph_dict -#define SFNT_SERVICE_PS_NAME_GET sfnt_service_ps_name -#define TT_SERVICE_CMAP_INFO_GET tt_service_get_cmap_info -#define TT_CMAP_CLASSES_GET tt_cmap_classes -#define SFNT_SERVICE_SFNT_TABLE_GET sfnt_service_sfnt_table -#define SFNT_SERVICE_BDF_GET sfnt_service_bdf -#define SFNT_INTERFACE_GET sfnt_interface - -#else /* FT_CONFIG_OPTION_PIC */ - - /* some include files required for members of sfntModulePIC */ -#include FT_SERVICE_GLYPH_DICT_H -#include FT_SERVICE_POSTSCRIPT_NAME_H -#include FT_SERVICE_SFNT_H -#include FT_SERVICE_TT_CMAP_H - -#ifdef TT_CONFIG_OPTION_BDF -#include "ttbdf.h" -#include FT_SERVICE_BDF_H -#endif - -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_STREAM_H -#include FT_INTERNAL_SFNT_H -#include "ttcmap.h" - - -FT_BEGIN_HEADER - - typedef struct sfntModulePIC_ - { - FT_ServiceDescRec* sfnt_services; - FT_Service_GlyphDictRec sfnt_service_glyph_dict; - FT_Service_PsFontNameRec sfnt_service_ps_name; - FT_Service_TTCMapsRec tt_service_get_cmap_info; - TT_CMap_Class* tt_cmap_classes; - FT_Service_SFNT_TableRec sfnt_service_sfnt_table; -#ifdef TT_CONFIG_OPTION_BDF - FT_Service_BDFRec sfnt_service_bdf; -#endif - SFNT_Interface sfnt_interface; - - } sfntModulePIC; - - -#define GET_PIC( lib ) \ - ( (sfntModulePIC*)( (lib)->pic_container.sfnt ) ) - -#define SFNT_SERVICES_GET \ - ( GET_PIC( library )->sfnt_services ) -#define SFNT_SERVICE_GLYPH_DICT_GET \ - ( GET_PIC( library )->sfnt_service_glyph_dict ) -#define SFNT_SERVICE_PS_NAME_GET \ - ( GET_PIC( library )->sfnt_service_ps_name ) -#define TT_SERVICE_CMAP_INFO_GET \ - ( GET_PIC( library )->tt_service_get_cmap_info ) -#define TT_CMAP_CLASSES_GET \ - ( GET_PIC( library )->tt_cmap_classes ) -#define SFNT_SERVICE_SFNT_TABLE_GET \ - ( GET_PIC( library )->sfnt_service_sfnt_table ) -#define SFNT_SERVICE_BDF_GET \ - ( GET_PIC( library )->sfnt_service_bdf ) -#define SFNT_INTERFACE_GET \ - ( GET_PIC( library )->sfnt_interface ) - - - /* see sfntpic.c for the implementation */ - void - sfnt_module_class_pic_free( FT_Library library ); - - FT_Error - sfnt_module_class_pic_init( FT_Library library ); - - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* SFNTPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c index 6ba8509f569..0b43d251b87 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfobjs.c */ -/* */ -/* SFNT object management (base). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfobjs.c + * + * SFNT object management (base). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -41,14 +41,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_sfobjs +#define FT_COMPONENT sfobjs @@ -918,7 +918,9 @@ /* Stream may have changed in sfnt_open_font. */ stream = face->root.stream; - FT_TRACE2(( "sfnt_init_face: %08p, %d\n", face, face_instance_index )); + FT_TRACE2(( "sfnt_init_face: %08p (index %d)\n", + face, + face_instance_index )); face_index = FT_ABS( face_instance_index ) & 0xFFFF; @@ -1001,15 +1003,15 @@ face->variation_support |= TT_FACE_FLAG_VAR_FVAR; /* - * As documented in the OpenType specification, an entry for the - * default instance may be omitted in the named instance table. In - * particular this means that even if there is no named instance - * table in the font we actually do have a named instance, namely the - * default instance. + * As documented in the OpenType specification, an entry for the + * default instance may be omitted in the named instance table. In + * particular this means that even if there is no named instance + * table in the font we actually do have a named instance, namely the + * default instance. * - * For consistency, we always want the default instance in our list - * of named instances. If it is missing, we try to synthesize it - * later on. Here, we have to adjust `num_instances' accordingly. + * For consistency, we always want the default instance in our list + * of named instances. If it is missing, we try to synthesize it + * later on. Here, we have to adjust `num_instances' accordingly. */ if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) && @@ -1341,6 +1343,13 @@ if ( sfnt->load_eblc ) LOAD_( eblc ); + /* colored glyph support */ + if ( sfnt->load_cpal ) + { + LOAD_( cpal ); + LOAD_( colr ); + } + /* consider the pclt, kerning, and gasp tables as optional */ LOAD_( pclt ); LOAD_( gasp ); @@ -1389,12 +1398,13 @@ FT_Long flags = root->face_flags; - /*********************************************************************/ - /* */ - /* Compute face flags. */ - /* */ + /********************************************************************** + * + * Compute face flags. + */ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC || - face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ) + face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX || + face->colr ) flags |= FT_FACE_FLAG_COLOR; /* color glyphs */ if ( has_outline == TRUE ) @@ -1438,10 +1448,10 @@ root->face_flags = flags; - /*********************************************************************/ - /* */ - /* Compute style flags. */ - /* */ + /********************************************************************** + * + * Compute style flags. + */ flags = 0; if ( has_outline == TRUE && face->os2.version != 0xFFFFU ) @@ -1471,14 +1481,14 @@ root->style_flags |= flags; - /*********************************************************************/ - /* */ - /* Polish the charmaps. */ - /* */ - /* Try to set the charmap encoding according to the platform & */ - /* encoding ID of each charmap. Emulate Unicode charmap if one */ - /* is missing. */ - /* */ + /********************************************************************** + * + * Polish the charmaps. + * + * Try to set the charmap encoding according to the platform & + * encoding ID of each charmap. Emulate Unicode charmap if one + * is missing. + */ tt_face_build_cmaps( face ); /* ignore errors */ @@ -1521,7 +1531,8 @@ error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec, NULL, &cmaprec, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -1533,9 +1544,9 @@ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* - * Now allocate the root array of FT_Bitmap_Size records and - * populate them. Unfortunately, it isn't possible to indicate bit - * depths in the FT_Bitmap_Size record. This is a design error. + * Now allocate the root array of FT_Bitmap_Size records and + * populate them. Unfortunately, it isn't possible to indicate bit + * depths in the FT_Bitmap_Size record. This is a design error. */ { FT_UInt count; @@ -1615,10 +1626,10 @@ root->face_flags |= FT_FACE_FLAG_SCALABLE; - /*********************************************************************/ - /* */ - /* Set up metrics. */ - /* */ + /********************************************************************** + * + * Set up metrics. + */ if ( FT_IS_SCALABLE( root ) ) { /* XXX What about if outline header is missing */ @@ -1630,59 +1641,73 @@ root->units_per_EM = face->header.Units_Per_EM; - /* XXX: Computing the ascender/descender/height is very different */ - /* from what the specification tells you. Apparently, we */ - /* must be careful because */ - /* */ - /* - not all fonts have an OS/2 table; in this case, we take */ - /* the values in the horizontal header. However, these */ - /* values very often are not reliable. */ - /* */ - /* - otherwise, the correct typographic values are in the */ - /* sTypoAscender, sTypoDescender & sTypoLineGap fields. */ - /* */ - /* However, certain fonts have these fields set to 0. */ - /* Rather, they have usWinAscent & usWinDescent correctly */ - /* set (but with different values). */ - /* */ - /* As an example, Arial Narrow is implemented through four */ - /* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */ - /* */ - /* Strangely, all fonts have the same values in their */ - /* sTypoXXX fields, except ARIALNB which sets them to 0. */ - /* */ - /* On the other hand, they all have different */ - /* usWinAscent/Descent values -- as a conclusion, the OS/2 */ - /* table cannot be used to compute the text height reliably! */ - /* */ - - /* The ascender and descender are taken from the `hhea' table. */ - /* If zero, they are taken from the `OS/2' table. */ - - root->ascender = face->horizontal.Ascender; - root->descender = face->horizontal.Descender; - - root->height = root->ascender - root->descender + - face->horizontal.Line_Gap; - - if ( !( root->ascender || root->descender ) ) + /* + * Computing the ascender/descender/height is tricky. + * + * The OpenType specification v1.8.3 says: + * + * [OS/2's] sTypoAscender, sTypoDescender and sTypoLineGap fields + * are intended to allow applications to lay out documents in a + * typographically-correct and portable fashion. + * + * This is somewhat at odds with the decades of backwards + * compatibility, operating systems and applications doing whatever + * they want, not to mention broken fonts. + * + * Not all fonts have an OS/2 table; in this case, we take the values + * in the horizontal header, although there is nothing stopping the + * values from being unreliable. Even with a OS/2 table, certain fonts + * set the sTypoAscender, sTypoDescender and sTypoLineGap fields to 0 + * and instead correctly set usWinAscent and usWinDescent. + * + * As an example, Arial Narrow is shipped as four files ARIALN.TTF, + * ARIALNI.TTF, ARIALNB.TTF and ARIALNBI.TTF. Strangely, all fonts have + * the same values in their sTypo* fields, except ARIALNB.ttf which + * sets them to 0. All of them have different usWinAscent/Descent + * values. The OS/2 table therefore cannot be trusted for computing the + * text height reliably. + * + * As a compromise, do the following: + * + * 1. If the OS/2 table exists and the fsSelection bit 7 is set + * (USE_TYPO_METRICS), trust the font and use the sTypo* metrics. + * 2. Otherwise, use the `hhea' table's metrics. + * 3. If they are zero and the OS/2 table exists, + * 1. use the OS/2 table's sTypo* metrics if they are non-zero. + * 2. Otherwise, use the OS/2 table's usWin* metrics. + */ + + if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 128 ) { - if ( face->os2.version != 0xFFFFU ) - { - if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) - { - root->ascender = face->os2.sTypoAscender; - root->descender = face->os2.sTypoDescender; + root->ascender = face->os2.sTypoAscender; + root->descender = face->os2.sTypoDescender; + root->height = root->ascender - root->descender + + face->os2.sTypoLineGap; + } + else + { + root->ascender = face->horizontal.Ascender; + root->descender = face->horizontal.Descender; + root->height = root->ascender - root->descender + + face->horizontal.Line_Gap; - root->height = root->ascender - root->descender + - face->os2.sTypoLineGap; - } - else + if ( !( root->ascender || root->descender ) ) + { + if ( face->os2.version != 0xFFFFU ) { - root->ascender = (FT_Short)face->os2.usWinAscent; - root->descender = -(FT_Short)face->os2.usWinDescent; - - root->height = root->ascender - root->descender; + if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) + { + root->ascender = face->os2.sTypoAscender; + root->descender = face->os2.sTypoDescender; + root->height = root->ascender - root->descender + + face->os2.sTypoLineGap; + } + else + { + root->ascender = (FT_Short)face->os2.usWinAscent; + root->descender = -(FT_Short)face->os2.usWinDescent; + root->height = root->ascender - root->descender; + } } } } @@ -1737,6 +1762,13 @@ /* destroy the embedded bitmaps table if it is loaded */ if ( sfnt->free_eblc ) sfnt->free_eblc( face ); + + /* destroy color table data if it is loaded */ + if ( sfnt->free_cpal ) + { + sfnt->free_cpal( face ); + sfnt->free_colr( face ); + } } #ifdef TT_CONFIG_OPTION_BDF @@ -1792,11 +1824,18 @@ FT_FREE( face->sbit_strike_map ); face->root.num_fixed_sizes = 0; -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_FREE( face->postscript_name ); + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_FREE( face->var_postscript_prefix ); #endif + /* freeing glyph color palette data */ + FT_FREE( face->palette_data.palette_name_ids ); + FT_FREE( face->palette_data.palette_flags ); + FT_FREE( face->palette_data.palette_entry_name_ids ); + FT_FREE( face->palette ); + face->sfnt = NULL; } diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h index 1b8d1be5b1a..17b0d50105e 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/sfobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfobjs.h */ -/* */ -/* SFNT object management (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfobjs.h + * + * SFNT object management (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SFOBJS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c index 996e66485fa..8d9737310c7 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttcmap.c */ -/* */ -/* TrueType character mapping table (cmap) support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttcmap.c + * + * TrueType character mapping table (cmap) support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -27,17 +27,16 @@ #include "ttload.h" #include "ttcmap.h" #include "ttpost.h" -#include "sfntpic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttcmap +#define FT_COMPONENT ttcmap #define TT_PEEK_SHORT FT_PEEK_SHORT @@ -77,19 +76,19 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 0 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* glyph_ids 6 BYTE[256] array of glyph indices */ - /* 262 */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 0 + * length 2 USHORT table length in bytes + * language 4 USHORT Mac language code + * glyph_ids 6 BYTE[256] array of glyph indices + * 262 + */ #ifdef TT_CONFIG_CMAP_FORMAT_0 @@ -238,57 +237,57 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 2 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* keys 6 USHORT[256] sub-header keys */ - /* subs 518 SUBHEAD[NSUBS] sub-headers array */ - /* glyph_ids 518+NSUB*8 USHORT[] glyph ID array */ - /* */ - /* The `keys' table is used to map charcode high bytes to sub-headers. */ - /* The value of `NSUBS' is the number of sub-headers defined in the */ - /* table and is computed by finding the maximum of the `keys' table. */ - /* */ - /* Note that for any `n', `keys[n]' is a byte offset within the `subs' */ - /* table, i.e., it is the corresponding sub-header index multiplied */ - /* by 8. */ - /* */ - /* Each sub-header has the following format. */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* first 0 USHORT first valid low-byte */ - /* count 2 USHORT number of valid low-bytes */ - /* delta 4 SHORT see below */ - /* offset 6 USHORT see below */ - /* */ - /* A sub-header defines, for each high byte, the range of valid */ - /* low bytes within the charmap. Note that the range defined by `first' */ - /* and `count' must be completely included in the interval [0..255] */ - /* according to the specification. */ - /* */ - /* If a character code is contained within a given sub-header, then */ - /* mapping it to a glyph index is done as follows. */ - /* */ - /* * The value of `offset' is read. This is a _byte_ distance from the */ - /* location of the `offset' field itself into a slice of the */ - /* `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too). */ - /* */ - /* * The value `slice[char.lo - first]' is read. If it is 0, there is */ - /* no glyph for the charcode. Otherwise, the value of `delta' is */ - /* added to it (modulo 65536) to form a new glyph index. */ - /* */ - /* It is up to the validation routine to check that all offsets fall */ - /* within the glyph IDs table (and not within the `subs' table itself or */ - /* outside of the CMap). */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 2 + * length 2 USHORT table length in bytes + * language 4 USHORT Mac language code + * keys 6 USHORT[256] sub-header keys + * subs 518 SUBHEAD[NSUBS] sub-headers array + * glyph_ids 518+NSUB*8 USHORT[] glyph ID array + * + * The `keys' table is used to map charcode high bytes to sub-headers. + * The value of `NSUBS' is the number of sub-headers defined in the + * table and is computed by finding the maximum of the `keys' table. + * + * Note that for any `n', `keys[n]' is a byte offset within the `subs' + * table, i.e., it is the corresponding sub-header index multiplied + * by 8. + * + * Each sub-header has the following format. + * + * NAME OFFSET TYPE DESCRIPTION + * + * first 0 USHORT first valid low-byte + * count 2 USHORT number of valid low-bytes + * delta 4 SHORT see below + * offset 6 USHORT see below + * + * A sub-header defines, for each high byte, the range of valid + * low bytes within the charmap. Note that the range defined by `first' + * and `count' must be completely included in the interval [0..255] + * according to the specification. + * + * If a character code is contained within a given sub-header, then + * mapping it to a glyph index is done as follows. + * + * - The value of `offset' is read. This is a _byte_ distance from the + * location of the `offset' field itself into a slice of the + * `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too). + * + * - The value `slice[char.lo - first]' is read. If it is 0, there is + * no glyph for the charcode. Otherwise, the value of `delta' is + * added to it (modulo 65536) to form a new glyph index. + * + * It is up to the validation routine to check that all offsets fall + * within the glyph IDs table (and not within the `subs' table itself or + * outside of the CMap). + */ #ifdef TT_CONFIG_CMAP_FORMAT_2 @@ -626,68 +625,68 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 4 */ - /* length 2 USHORT table length */ - /* in bytes */ - /* language 4 USHORT Mac language code */ - /* */ - /* segCountX2 6 USHORT 2*NUM_SEGS */ - /* searchRange 8 USHORT 2*(1 << LOG_SEGS) */ - /* entrySelector 10 USHORT LOG_SEGS */ - /* rangeShift 12 USHORT segCountX2 - */ - /* searchRange */ - /* */ - /* endCount 14 USHORT[NUM_SEGS] end charcode for */ - /* each segment; last */ - /* is 0xFFFF */ - /* */ - /* pad 14+NUM_SEGS*2 USHORT padding */ - /* */ - /* startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for */ - /* each segment */ - /* */ - /* idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each */ - /* segment */ - /* idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for */ - /* each segment; can be */ - /* zero */ - /* */ - /* glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID */ - /* ranges */ - /* */ - /* Character codes are modelled by a series of ordered (increasing) */ - /* intervals called segments. Each segment has start and end codes, */ - /* provided by the `startCount' and `endCount' arrays. Segments must */ - /* not overlap, and the last segment should always contain the value */ - /* 0xFFFF for `endCount'. */ - /* */ - /* The fields `searchRange', `entrySelector' and `rangeShift' are better */ - /* ignored (they are traces of over-engineering in the TrueType */ - /* specification). */ - /* */ - /* Each segment also has a signed `delta', as well as an optional offset */ - /* within the `glyphIds' table. */ - /* */ - /* If a segment's idOffset is 0, the glyph index corresponding to any */ - /* charcode within the segment is obtained by adding the value of */ - /* `idDelta' directly to the charcode, modulo 65536. */ - /* */ - /* Otherwise, a glyph index is taken from the glyph IDs sub-array for */ - /* the segment, and the value of `idDelta' is added to it. */ - /* */ - /* */ - /* Finally, note that a lot of fonts contain an invalid last segment, */ - /* where `start' and `end' are correctly set to 0xFFFF but both `delta' */ - /* and `offset' are incorrect (e.g., `opens___.ttf' which comes with */ - /* OpenOffice.org). We need special code to deal with them correctly. */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 4 + * length 2 USHORT table length + * in bytes + * language 4 USHORT Mac language code + * + * segCountX2 6 USHORT 2*NUM_SEGS + * searchRange 8 USHORT 2*(1 << LOG_SEGS) + * entrySelector 10 USHORT LOG_SEGS + * rangeShift 12 USHORT segCountX2 - + * searchRange + * + * endCount 14 USHORT[NUM_SEGS] end charcode for + * each segment; last + * is 0xFFFF + * + * pad 14+NUM_SEGS*2 USHORT padding + * + * startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for + * each segment + * + * idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each + * segment + * idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for + * each segment; can be + * zero + * + * glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID + * ranges + * + * Character codes are modelled by a series of ordered (increasing) + * intervals called segments. Each segment has start and end codes, + * provided by the `startCount' and `endCount' arrays. Segments must + * not overlap, and the last segment should always contain the value + * 0xFFFF for `endCount'. + * + * The fields `searchRange', `entrySelector' and `rangeShift' are better + * ignored (they are traces of over-engineering in the TrueType + * specification). + * + * Each segment also has a signed `delta', as well as an optional offset + * within the `glyphIds' table. + * + * If a segment's idOffset is 0, the glyph index corresponding to any + * charcode within the segment is obtained by adding the value of + * `idDelta' directly to the charcode, modulo 65536. + * + * Otherwise, a glyph index is taken from the glyph IDs sub-array for + * the segment, and the value of `idDelta' is added to it. + * + * + * Finally, note that a lot of fonts contain an invalid last segment, + * where `start' and `end' are correctly set to 0xFFFF but both `delta' + * and `offset' are incorrect (e.g., `opens___.ttf' which comes with + * OpenOffice.org). We need special code to deal with them correctly. + */ #ifdef TT_CONFIG_CMAP_FORMAT_4 @@ -1573,23 +1572,23 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 6 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* */ - /* first 6 USHORT first segment code */ - /* count 8 USHORT segment size in chars */ - /* glyphIds 10 USHORT[count] glyph IDs */ - /* */ - /* A very simplified segment mapping. */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 6 + * length 2 USHORT table length in bytes + * language 4 USHORT Mac language code + * + * first 6 USHORT first segment code + * count 8 USHORT segment size in chars + * glyphIds 10 USHORT[count] glyph IDs + * + * A very simplified segment mapping. + */ #ifdef TT_CONFIG_CMAP_FORMAT_6 @@ -1768,26 +1767,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 8 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* is32 12 BYTE[8192] 32-bitness bitmap */ - /* count 8204 ULONG number of groups */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* startId 8 ULONG start glyph ID for the group */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 8 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * is32 12 BYTE[8192] 32-bitness bitmap + * count 8204 ULONG number of groups + * + * This header is followed by `count' groups of the following format: + * + * start 0 ULONG first charcode + * end 4 ULONG last charcode + * startId 8 ULONG start glyph ID for the group + */ #ifdef TT_CONFIG_CMAP_FORMAT_8 @@ -2037,22 +2036,22 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 10 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* */ - /* start 12 ULONG first char in range */ - /* count 16 ULONG number of chars in range */ - /* glyphIds 20 USHORT[count] glyph indices covered */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 10 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * + * start 12 ULONG first char in range + * count 16 ULONG number of chars in range + * glyphIds 20 USHORT[count] glyph indices covered + */ #ifdef TT_CONFIG_CMAP_FORMAT_10 @@ -2209,26 +2208,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 12 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* count 12 ULONG number of groups */ - /* 16 */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* startId 8 ULONG start glyph ID for the group */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 12 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * count 12 ULONG number of groups + * 16 + * + * This header is followed by `count' groups of the following format: + * + * start 0 ULONG first charcode + * end 4 ULONG last charcode + * startId 8 ULONG start glyph ID for the group + */ #ifdef TT_CONFIG_CMAP_FORMAT_12 @@ -2565,26 +2564,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 13 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* count 12 ULONG number of groups */ - /* 16 */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* glyphId 8 ULONG glyph ID for the whole group */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 13 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * count 12 ULONG number of groups + * 16 + * + * This header is followed by `count' groups of the following format: + * + * start 0 ULONG first charcode + * end 4 ULONG last charcode + * glyphId 8 ULONG glyph ID for the whole group + */ #ifdef TT_CONFIG_CMAP_FORMAT_13 @@ -2891,58 +2890,59 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 14 */ - /* length 2 ULONG table length in bytes */ - /* numSelector 6 ULONG number of variation sel. records */ - /* */ - /* Followed by numSelector records, each of which looks like */ - /* */ - /* varSelector 0 UINT24 Unicode codepoint of sel. */ - /* defaultOff 3 ULONG offset to a default UVS table */ - /* describing any variants to be found in */ - /* the normal Unicode subtable. */ - /* nonDefOff 7 ULONG offset to a non-default UVS table */ - /* describing any variants not in the */ - /* standard cmap, with GIDs here */ - /* (either offset may be 0 NULL) */ - /* */ - /* Selectors are sorted by code point. */ - /* */ - /* A default Unicode Variation Selector (UVS) subtable is just a list of */ - /* ranges of code points which are to be found in the standard cmap. No */ - /* glyph IDs (GIDs) here. */ - /* */ - /* numRanges 0 ULONG number of ranges following */ - /* */ - /* A range looks like */ - /* */ - /* uniStart 0 UINT24 code point of the first character in */ - /* this range */ - /* additionalCnt 3 UBYTE count of additional characters in this */ - /* range (zero means a range of a single */ - /* character) */ - /* */ - /* Ranges are sorted by `uniStart'. */ - /* */ - /* A non-default Unicode Variation Selector (UVS) subtable is a list of */ - /* mappings from codepoint to GID. */ - /* */ - /* numMappings 0 ULONG number of mappings */ - /* */ - /* A range looks like */ - /* */ - /* uniStart 0 UINT24 code point of the first character in */ - /* this range */ - /* GID 3 USHORT and its GID */ - /* */ - /* Ranges are sorted by `uniStart'. */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 14 + * length 2 ULONG table length in bytes + * numSelector 6 ULONG number of variation sel. records + * + * Followed by numSelector records, each of which looks like + * + * varSelector 0 UINT24 Unicode codepoint of sel. + * defaultOff 3 ULONG offset to a default UVS table + * describing any variants to be found in + * the normal Unicode subtable. + * nonDefOff 7 ULONG offset to a non-default UVS table + * describing any variants not in the + * standard cmap, with GIDs here + * (either offset may be 0 NULL) + * + * Selectors are sorted by code point. + * + * A default Unicode Variation Selector (UVS) subtable is just a list of + * ranges of code points which are to be found in the standard cmap. No + * glyph IDs (GIDs) here. + * + * numRanges 0 ULONG number of ranges following + * + * A range looks like + * + * uniStart 0 UINT24 code point of the first character in + * this range + * additionalCnt 3 UBYTE count of additional characters in this + * range (zero means a range of a single + * character) + * + * Ranges are sorted by `uniStart'. + * + * A non-default Unicode Variation Selector (UVS) subtable is a list of + * mappings from codepoint to GID. + * + * numMappings 0 ULONG number of mappings + * + * A range looks like + * + * uniStart 0 UINT24 code point of the first character in + * this range + * GID 3 USHORT and its GID + * + * Ranges are sorted by `uniStart'. + */ #ifdef TT_CONFIG_CMAP_FORMAT_14 @@ -3681,6 +3681,9 @@ FT_UNUSED( pointer ); + if ( !psnames->unicodes_init ) + return FT_THROW( Unimplemented_Feature ); + return psnames->unicodes_init( memory, unicodes, face->root.num_glyphs, @@ -3749,7 +3752,6 @@ #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ -#ifndef FT_CONFIG_OPTION_PIC static const TT_CMap_Class tt_cmap_classes[] = { @@ -3758,61 +3760,6 @@ NULL, }; -#else /*FT_CONFIG_OPTION_PIC*/ - - void - FT_Destroy_Class_tt_cmap_classes( FT_Library library, - TT_CMap_Class* clazz ) - { - FT_Memory memory = library->memory; - - - if ( clazz ) - FT_FREE( clazz ); - } - - - FT_Error - FT_Create_Class_tt_cmap_classes( FT_Library library, - TT_CMap_Class** output_class ) - { - TT_CMap_Class* clazz = NULL; - TT_CMap_ClassRec* recs; - FT_Error error; - FT_Memory memory = library->memory; - - int i = 0; - - -#define TTCMAPCITEM( a ) i++; -#include "ttcmapc.h" - - /* allocate enough space for both the pointers */ - /* plus terminator and the class instances */ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * ( i + 1 ) + - sizeof ( TT_CMap_ClassRec ) * i ) ) - return error; - - /* the location of the class instances follows the array of pointers */ - recs = (TT_CMap_ClassRec*)( (char*)clazz + - sizeof ( *clazz ) * ( i + 1 ) ); - i = 0; - -#undef TTCMAPCITEM -#define TTCMAPCITEM( a ) \ - FT_Init_Class_ ## a( &recs[i] ); \ - clazz[i] = &recs[i]; \ - i++; -#include "ttcmapc.h" - - clazz[i] = NULL; - - *output_class = clazz; - return FT_Err_Ok; - } - -#endif /*FT_CONFIG_OPTION_PIC*/ - /* parse the `cmap' table and build the corresponding TT_CMap objects */ /* in the current face */ @@ -3859,7 +3806,7 @@ { FT_Byte* volatile cmap = table + offset; volatile FT_UInt format = TT_PEEK_USHORT( cmap ); - const TT_CMap_Class* volatile pclazz = TT_CMAP_CLASSES_GET; + const TT_CMap_Class* volatile pclazz = tt_cmap_classes; TT_CMap_Class volatile clazz; diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h index d264d99d2c9..36801c939ee 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttcmap.h */ -/* */ -/* TrueType character mapping table (cmap) support (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttcmap.h + * + * TrueType character mapping table (cmap) support (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTCMAP_H_ @@ -56,8 +56,6 @@ FT_BEGIN_HEADER } TT_CMap_ClassRec; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_TT_CMAP( class_, \ size_, \ init_, \ @@ -92,42 +90,6 @@ FT_BEGIN_HEADER get_cmap_info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_TT_CMAP( class_, \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_, \ - format_, \ - validate_, \ - get_cmap_info_ ) \ - void \ - FT_Init_Class_ ## class_( TT_CMap_ClassRec* clazz ) \ - { \ - clazz->clazz.size = size_; \ - clazz->clazz.init = init_; \ - clazz->clazz.done = done_; \ - clazz->clazz.char_index = char_index_; \ - clazz->clazz.char_next = char_next_; \ - clazz->clazz.char_var_index = char_var_index_; \ - clazz->clazz.char_var_default = char_var_default_; \ - clazz->clazz.variant_list = variant_list_; \ - clazz->clazz.charvariant_list = charvariant_list_; \ - clazz->clazz.variantchar_list = variantchar_list_; \ - clazz->format = format_; \ - clazz->validate = validate_; \ - clazz->get_cmap_info = get_cmap_info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - typedef struct TT_ValidatorRec_ { diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h index 4980e9dd3dc..ace9e69ca8d 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcmapc.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttcmapc.h */ -/* */ -/* TT CMAP classes definitions (specification only). */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttcmapc.h + * + * TT CMAP classes definitions (specification only). + * + * Copyright (C) 2009-2019 by + * Oran Agra and Mickey Gabel. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifdef TT_CONFIG_CMAP_FORMAT_0 diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c new file mode 100644 index 00000000000..6b537d95b85 --- /dev/null +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c @@ -0,0 +1,451 @@ +/**************************************************************************** + * + * ttcolr.c + * + * TrueType and OpenType colored glyph layer support (body). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * `COLR' table specification: + * + * https://www.microsoft.com/typography/otspec/colr.htm + * + */ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_COLOR_H + + +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS + +#include "ttcolr.h" + + + /* NOTE: These are the table sizes calculated through the specs. */ +#define BASE_GLYPH_SIZE 6 +#define LAYER_SIZE 4 +#define COLR_HEADER_SIZE 14 + + + typedef struct BaseGlyphRecord_ + { + FT_UShort gid; + FT_UShort first_layer_index; + FT_UShort num_layers; + + } BaseGlyphRecord; + + + typedef struct Colr_ + { + FT_UShort version; + FT_UShort num_base_glyphs; + FT_UShort num_layers; + + FT_Byte* base_glyphs; + FT_Byte* layers; + + /* The memory which backs up the `COLR' table. */ + void* table; + FT_ULong table_size; + + } Colr; + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT ttcolr + + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_colr( TT_Face face, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = face->root.memory; + + FT_Byte* table = NULL; + FT_Byte* p = NULL; + + Colr* colr = NULL; + + FT_ULong base_glyph_offset, layer_offset; + FT_ULong table_size; + + + /* `COLR' always needs `CPAL' */ + if ( !face->cpal ) + return FT_THROW( Invalid_File_Format ); + + error = face->goto_table( face, TTAG_COLR, stream, &table_size ); + if ( error ) + goto NoColr; + + if ( table_size < COLR_HEADER_SIZE ) + goto InvalidTable; + + if ( FT_FRAME_EXTRACT( table_size, table ) ) + goto NoColr; + + p = table; + + if ( FT_NEW( colr ) ) + goto NoColr; + + colr->version = FT_NEXT_USHORT( p ); + if ( colr->version != 0 ) + goto InvalidTable; + + colr->num_base_glyphs = FT_NEXT_USHORT( p ); + base_glyph_offset = FT_NEXT_ULONG( p ); + + if ( base_glyph_offset >= table_size ) + goto InvalidTable; + if ( colr->num_base_glyphs * BASE_GLYPH_SIZE > + table_size - base_glyph_offset ) + goto InvalidTable; + + layer_offset = FT_NEXT_ULONG( p ); + colr->num_layers = FT_NEXT_USHORT( p ); + + if ( layer_offset >= table_size ) + goto InvalidTable; + if ( colr->num_layers * LAYER_SIZE > table_size - layer_offset ) + goto InvalidTable; + + colr->base_glyphs = (FT_Byte*)( table + base_glyph_offset ); + colr->layers = (FT_Byte*)( table + layer_offset ); + colr->table = table; + colr->table_size = table_size; + + face->colr = colr; + + return FT_Err_Ok; + + InvalidTable: + error = FT_THROW( Invalid_Table ); + + NoColr: + FT_FRAME_RELEASE( table ); + FT_FREE( colr ); + + return error; + } + + + FT_LOCAL_DEF( void ) + tt_face_free_colr( TT_Face face ) + { + FT_Stream stream = face->root.stream; + FT_Memory memory = face->root.memory; + + Colr* colr = (Colr*)face->colr; + + + if ( colr ) + { + FT_FRAME_RELEASE( colr->table ); + FT_FREE( colr ); + } + } + + + static FT_Bool + find_base_glyph_record( FT_Byte* base_glyph_begin, + FT_Int num_base_glyph, + FT_UInt glyph_id, + BaseGlyphRecord* record ) + { + FT_Int min = 0; + FT_Int max = num_base_glyph - 1; + + + while ( min <= max ) + { + FT_Int mid = min + ( max - min ) / 2; + FT_Byte* p = base_glyph_begin + mid * BASE_GLYPH_SIZE; + + FT_UShort gid = FT_NEXT_USHORT( p ); + + + if ( gid < glyph_id ) + min = mid + 1; + else if (gid > glyph_id ) + max = mid - 1; + else + { + record->gid = gid; + record->first_layer_index = FT_NEXT_USHORT( p ); + record->num_layers = FT_NEXT_USHORT( p ); + + return 1; + } + } + + return 0; + } + + + FT_LOCAL_DEF( FT_Bool ) + tt_face_get_colr_layer( TT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ) + { + Colr* colr = (Colr*)face->colr; + BaseGlyphRecord glyph_record; + + + if ( !colr ) + return 0; + + if ( !iterator->p ) + { + FT_ULong offset; + + + /* first call to function */ + iterator->layer = 0; + + if ( !find_base_glyph_record( colr->base_glyphs, + colr->num_base_glyphs, + base_glyph, + &glyph_record ) ) + return 0; + + if ( glyph_record.num_layers ) + iterator->num_layers = glyph_record.num_layers; + else + return 0; + + offset = LAYER_SIZE * glyph_record.first_layer_index; + if ( offset + LAYER_SIZE * glyph_record.num_layers > colr->table_size ) + return 0; + + iterator->p = colr->layers + offset; + } + + if ( iterator->layer >= iterator->num_layers ) + return 0; + + *aglyph_index = FT_NEXT_USHORT( iterator->p ); + *acolor_index = FT_NEXT_USHORT( iterator->p ); + + if ( *aglyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) || + ( *acolor_index != 0xFFFF && + *acolor_index >= face->palette_data.num_palette_entries ) ) + return 0; + + iterator->layer++; + + return 1; + } + + + FT_LOCAL_DEF( FT_Error ) + tt_face_colr_blend_layer( TT_Face face, + FT_UInt color_index, + FT_GlyphSlot dstSlot, + FT_GlyphSlot srcSlot ) + { + FT_Error error; + + FT_UInt x, y; + FT_Byte b, g, r, alpha; + + FT_ULong size; + FT_Byte* src; + FT_Byte* dst; + + + if ( !dstSlot->bitmap.buffer ) + { + /* Initialize destination of color bitmap */ + /* with the size of first component. */ + dstSlot->bitmap_left = srcSlot->bitmap_left; + dstSlot->bitmap_top = srcSlot->bitmap_top; + + dstSlot->bitmap.width = srcSlot->bitmap.width; + dstSlot->bitmap.rows = srcSlot->bitmap.rows; + dstSlot->bitmap.pixel_mode = FT_PIXEL_MODE_BGRA; + dstSlot->bitmap.pitch = (int)dstSlot->bitmap.width * 4; + dstSlot->bitmap.num_grays = 256; + + size = dstSlot->bitmap.rows * (unsigned int)dstSlot->bitmap.pitch; + + error = ft_glyphslot_alloc_bitmap( dstSlot, size ); + if ( error ) + return error; + + FT_MEM_ZERO( dstSlot->bitmap.buffer, size ); + } + else + { + /* Resize destination if needed such that new component fits. */ + FT_Int x_min, x_max, y_min, y_max; + + + x_min = FT_MIN( dstSlot->bitmap_left, srcSlot->bitmap_left ); + x_max = FT_MAX( dstSlot->bitmap_left + (FT_Int)dstSlot->bitmap.width, + srcSlot->bitmap_left + (FT_Int)srcSlot->bitmap.width ); + + y_min = FT_MIN( dstSlot->bitmap_top - (FT_Int)dstSlot->bitmap.rows, + srcSlot->bitmap_top - (FT_Int)srcSlot->bitmap.rows ); + y_max = FT_MAX( dstSlot->bitmap_top, srcSlot->bitmap_top ); + + if ( x_min != dstSlot->bitmap_left || + x_max != dstSlot->bitmap_left + (FT_Int)dstSlot->bitmap.width || + y_min != dstSlot->bitmap_top - (FT_Int)dstSlot->bitmap.rows || + y_max != dstSlot->bitmap_top ) + { + FT_Memory memory = face->root.memory; + + FT_UInt width = (FT_UInt)( x_max - x_min ); + FT_UInt rows = (FT_UInt)( y_max - y_min ); + FT_UInt pitch = width * 4; + + FT_Byte* buf = NULL; + FT_Byte* p; + FT_Byte* q; + + + size = rows * pitch; + if ( FT_ALLOC( buf, size ) ) + return error; + + p = dstSlot->bitmap.buffer; + q = buf + + (int)pitch * ( y_max - dstSlot->bitmap_top ) + + 4 * ( dstSlot->bitmap_left - x_min ); + + for ( y = 0; y < dstSlot->bitmap.rows; y++ ) + { + FT_MEM_COPY( q, p, dstSlot->bitmap.width * 4 ); + + p += dstSlot->bitmap.pitch; + q += pitch; + } + + ft_glyphslot_set_bitmap( dstSlot, buf ); + + dstSlot->bitmap_top = y_max; + dstSlot->bitmap_left = x_min; + + dstSlot->bitmap.width = width; + dstSlot->bitmap.rows = rows; + dstSlot->bitmap.pitch = (int)pitch; + + dstSlot->internal->flags |= FT_GLYPH_OWN_BITMAP; + dstSlot->format = FT_GLYPH_FORMAT_BITMAP; + } + } + + if ( color_index == 0xFFFF ) + { + if ( face->have_foreground_color ) + { + b = face->foreground_color.blue; + g = face->foreground_color.green; + r = face->foreground_color.red; + alpha = face->foreground_color.alpha; + } + else + { + if ( face->palette_data.palette_flags && + ( face->palette_data.palette_flags[face->palette_index] & + FT_PALETTE_FOR_DARK_BACKGROUND ) ) + { + /* white opaque */ + b = 0xFF; + g = 0xFF; + r = 0xFF; + alpha = 0xFF; + } + else + { + /* black opaque */ + b = 0x00; + g = 0x00; + r = 0x00; + alpha = 0xFF; + } + } + } + else + { + b = face->palette[color_index].blue; + g = face->palette[color_index].green; + r = face->palette[color_index].red; + alpha = face->palette[color_index].alpha; + } + + /* XXX Convert if srcSlot.bitmap is not grey? */ + src = srcSlot->bitmap.buffer; + dst = dstSlot->bitmap.buffer + + dstSlot->bitmap.pitch * ( dstSlot->bitmap_top - srcSlot->bitmap_top ) + + 4 * ( srcSlot->bitmap_left - dstSlot->bitmap_left ); + + for ( y = 0; y < srcSlot->bitmap.rows; y++ ) + { + for ( x = 0; x < srcSlot->bitmap.width; x++ ) + { + int aa = src[x]; + int fa = alpha * aa / 255; + + int fb = b * fa / 255; + int fg = g * fa / 255; + int fr = r * fa / 255; + + int ba2 = 255 - fa; + + int bb = dst[4 * x + 0]; + int bg = dst[4 * x + 1]; + int br = dst[4 * x + 2]; + int ba = dst[4 * x + 3]; + + + dst[4 * x + 0] = (FT_Byte)( bb * ba2 / 255 + fb ); + dst[4 * x + 1] = (FT_Byte)( bg * ba2 / 255 + fg ); + dst[4 * x + 2] = (FT_Byte)( br * ba2 / 255 + fr ); + dst[4 * x + 3] = (FT_Byte)( ba * ba2 / 255 + fa ); + } + + src += srcSlot->bitmap.pitch; + dst += dstSlot->bitmap.pitch; + } + + return FT_Err_Ok; + } + +#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_colr_dummy; + +#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + +/* EOF */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h new file mode 100644 index 00000000000..817489a855a --- /dev/null +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.h @@ -0,0 +1,58 @@ +/**************************************************************************** + * + * ttcolr.h + * + * TrueType and OpenType colored glyph layer support (specification). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef __TTCOLR_H__ +#define __TTCOLR_H__ + + +#include <ft2build.h> +#include "ttload.h" + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + tt_face_load_colr( TT_Face face, + FT_Stream stream ); + + FT_LOCAL( void ) + tt_face_free_colr( TT_Face face ); + + FT_LOCAL( FT_Bool ) + tt_face_get_colr_layer( TT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); + + FT_LOCAL( FT_Error ) + tt_face_colr_blend_layer( TT_Face face, + FT_UInt color_index, + FT_GlyphSlot dstSlot, + FT_GlyphSlot srcSlot ); + + +FT_END_HEADER + + +#endif /* __TTCOLR_H__ */ + +/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c new file mode 100644 index 00000000000..3482169a891 --- /dev/null +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.c @@ -0,0 +1,311 @@ +/**************************************************************************** + * + * ttcpal.c + * + * TrueType and OpenType color palette support (body). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * `CPAL' table specification: + * + * https://www.microsoft.com/typography/otspec/cpal.htm + * + */ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_COLOR_H + + +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS + +#include "ttcpal.h" + + + /* NOTE: These are the table sizes calculated through the specs. */ +#define CPAL_V0_HEADER_BASE_SIZE 12 +#define COLOR_SIZE 4 + + + /* all data from `CPAL' not covered in FT_Palette_Data */ + typedef struct Cpal_ + { + FT_UShort version; /* Table version number (0 or 1 supported). */ + FT_UShort num_colors; /* Total number of color records, */ + /* combined for all palettes. */ + FT_Byte* colors; /* RGBA array of colors */ + FT_Byte* color_indices; /* Index of each palette's first color record */ + /* in the combined color record array. */ + + /* The memory which backs up the `CPAL' table. */ + void* table; + FT_ULong table_size; + + } Cpal; + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT ttcpal + + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_cpal( TT_Face face, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = face->root.memory; + + FT_Byte* table = NULL; + FT_Byte* p = NULL; + + Cpal* cpal = NULL; + + FT_ULong colors_offset; + FT_ULong table_size; + + + error = face->goto_table( face, TTAG_CPAL, stream, &table_size ); + if ( error ) + goto NoCpal; + + if ( table_size < CPAL_V0_HEADER_BASE_SIZE ) + goto InvalidTable; + + if ( FT_FRAME_EXTRACT( table_size, table ) ) + goto NoCpal; + + p = table; + + if ( FT_NEW( cpal ) ) + goto NoCpal; + + cpal->version = FT_NEXT_USHORT( p ); + if ( cpal->version > 1 ) + goto InvalidTable; + + face->palette_data.num_palette_entries = FT_NEXT_USHORT( p ); + face->palette_data.num_palettes = FT_NEXT_USHORT( p ); + + cpal->num_colors = FT_NEXT_USHORT( p ); + colors_offset = FT_NEXT_ULONG( p ); + + if ( CPAL_V0_HEADER_BASE_SIZE + + face->palette_data.num_palettes * 2U > table_size ) + goto InvalidTable; + + if ( colors_offset >= table_size ) + goto InvalidTable; + if ( cpal->num_colors * COLOR_SIZE > table_size - colors_offset ) + goto InvalidTable; + + if ( face->palette_data.num_palette_entries > cpal->num_colors ) + goto InvalidTable; + + cpal->color_indices = p; + cpal->colors = (FT_Byte*)( table + colors_offset ); + + if ( cpal->version == 1 ) + { + FT_ULong type_offset, label_offset, entry_label_offset; + FT_UShort* array = NULL; + FT_UShort* limit; + FT_UShort* q; + + + if ( CPAL_V0_HEADER_BASE_SIZE + + face->palette_data.num_palettes * 2U + + 3U * 4 > table_size ) + goto InvalidTable; + + p += face->palette_data.num_palettes * 2; + + type_offset = FT_NEXT_ULONG( p ); + label_offset = FT_NEXT_ULONG( p ); + entry_label_offset = FT_NEXT_ULONG( p ); + + if ( type_offset ) + { + if ( type_offset >= table_size ) + goto InvalidTable; + if ( face->palette_data.num_palettes * 2 > + table_size - type_offset ) + goto InvalidTable; + + if ( FT_QNEW_ARRAY( array, face->palette_data.num_palettes ) ) + goto NoCpal; + + p = table + type_offset; + q = array; + limit = q + face->palette_data.num_palettes; + + while ( q < limit ) + *q++ = FT_NEXT_USHORT( p ); + + face->palette_data.palette_flags = array; + } + + if ( label_offset ) + { + if ( label_offset >= table_size ) + goto InvalidTable; + if ( face->palette_data.num_palettes * 2 > + table_size - label_offset ) + goto InvalidTable; + + if ( FT_QNEW_ARRAY( array, face->palette_data.num_palettes ) ) + goto NoCpal; + + p = table + label_offset; + q = array; + limit = q + face->palette_data.num_palettes; + + while ( q < limit ) + *q++ = FT_NEXT_USHORT( p ); + + face->palette_data.palette_name_ids = array; + } + + if ( entry_label_offset ) + { + if ( entry_label_offset >= table_size ) + goto InvalidTable; + if ( face->palette_data.num_palette_entries * 2 > + table_size - entry_label_offset ) + goto InvalidTable; + + if ( FT_QNEW_ARRAY( array, face->palette_data.num_palette_entries ) ) + goto NoCpal; + + p = table + entry_label_offset; + q = array; + limit = q + face->palette_data.num_palette_entries; + + while ( q < limit ) + *q++ = FT_NEXT_USHORT( p ); + + face->palette_data.palette_entry_name_ids = array; + } + } + + cpal->table = table; + cpal->table_size = table_size; + + face->cpal = cpal; + + /* set up default palette */ + if ( FT_NEW_ARRAY( face->palette, + face->palette_data.num_palette_entries ) ) + goto NoCpal; + + if ( tt_face_palette_set( face, 0 ) ) + goto InvalidTable; + + return FT_Err_Ok; + + InvalidTable: + error = FT_THROW( Invalid_Table ); + + NoCpal: + FT_FRAME_RELEASE( table ); + FT_FREE( cpal ); + + face->cpal = NULL; + + /* arrays in `face->palette_data' and `face->palette' */ + /* are freed in `sfnt_done_face' */ + + return error; + } + + + FT_LOCAL_DEF( void ) + tt_face_free_cpal( TT_Face face ) + { + FT_Stream stream = face->root.stream; + FT_Memory memory = face->root.memory; + + Cpal* cpal = (Cpal*)face->cpal; + + + if ( cpal ) + { + FT_FRAME_RELEASE( cpal->table ); + FT_FREE( cpal ); + } + } + + + FT_LOCAL_DEF( FT_Error ) + tt_face_palette_set( TT_Face face, + FT_UInt palette_index ) + { + Cpal* cpal = (Cpal*)face->cpal; + + FT_Byte* offset; + FT_Byte* p; + + FT_Color* q; + FT_Color* limit; + + FT_UShort color_index; + + + if ( !cpal || palette_index >= face->palette_data.num_palettes ) + return FT_THROW( Invalid_Argument ); + + offset = cpal->color_indices + 2 * palette_index; + color_index = FT_PEEK_USHORT( offset ); + + if ( color_index + face->palette_data.num_palette_entries > + cpal->num_colors ) + return FT_THROW( Invalid_Table ); + + p = cpal->colors + COLOR_SIZE * color_index; + q = face->palette; + limit = q + face->palette_data.num_palette_entries; + + while ( q < limit ) + { + q->blue = FT_NEXT_BYTE( p ); + q->green = FT_NEXT_BYTE( p ); + q->red = FT_NEXT_BYTE( p ); + q->alpha = FT_NEXT_BYTE( p ); + + q++; + } + + return FT_Err_Ok; + } + + +#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_cpal_dummy; + +#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + +/* EOF */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h new file mode 100644 index 00000000000..d1b244f3e34 --- /dev/null +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttcpal.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * + * ttcpal.h + * + * TrueType and OpenType color palette support (specification). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef __TTCPAL_H__ +#define __TTCPAL_H__ + + +#include <ft2build.h> +#include "ttload.h" + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + tt_face_load_cpal( TT_Face face, + FT_Stream stream ); + + FT_LOCAL( void ) + tt_face_free_cpal( TT_Face face ); + + FT_LOCAL( FT_Error ) + tt_face_palette_set( TT_Face face, + FT_UInt palette_index ); + + +FT_END_HEADER + + +#endif /* __TTCPAL_H__ */ + +/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c index 68f15a20102..8d1b7810904 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttkern.c */ -/* */ -/* Load the basic TrueType kerning table. This doesn't handle */ -/* kerning data within the GPOS table at the moment. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttkern.c + * + * Load the basic TrueType kerning table. This doesn't handle + * kerning data within the GPOS table at the moment. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #include "sferrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttkern +#define FT_COMPONENT ttkern #undef TT_KERN_INDEX @@ -127,8 +127,8 @@ avail |= mask; /* - * Now check whether the pairs in this table are ordered. - * We then can use binary search. + * Now check whether the pairs in this table are ordered. + * We then can use binary search. */ if ( num_pairs > 0 ) { @@ -283,8 +283,8 @@ break; /* - * We don't support format 2 because we haven't seen a single font - * using it in real life... + * We don't support format 2 because we haven't seen a single font + * using it in real life... */ default: diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h index 4e45d0964b4..5f283e5e622 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttkern.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttkern.h */ -/* */ -/* Load the basic TrueType kerning table. This doesn't handle */ -/* kerning data within the GPOS table at the moment. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttkern.h + * + * Load the basic TrueType kerning table. This doesn't handle + * kerning data within the GPOS table at the moment. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTKERN_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c index a86a546c3dd..5443bf4b696 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttload.c */ -/* */ -/* Load the basic TrueType tables, i.e., tables that can be either in */ -/* TTF or OTF fonts (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttload.c + * + * Load the basic TrueType tables, i.e., tables that can be either in + * TTF or OTF fonts (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,32 +26,34 @@ #include "sferrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttload - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_lookup_table */ - /* */ - /* <Description> */ - /* Looks for a TrueType table by name. */ - /* */ - /* <Input> */ - /* face :: A face object handle. */ - /* */ - /* tag :: The searched tag. */ - /* */ - /* <Return> */ - /* A pointer to the table directory entry. 0 if not found. */ - /* */ +#define FT_COMPONENT ttload + + + /************************************************************************** + * + * @Function: + * tt_face_lookup_table + * + * @Description: + * Looks for a TrueType table by name. + * + * @Input: + * face :: + * A face object handle. + * + * tag :: + * The searched tag. + * + * @Return: + * A pointer to the table directory entry. 0 if not found. + */ FT_LOCAL_DEF( TT_Table ) tt_face_lookup_table( TT_Face face, FT_ULong tag ) @@ -101,27 +103,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_goto_table */ - /* */ - /* <Description> */ - /* Looks for a TrueType table by name, then seek a stream to it. */ - /* */ - /* <Input> */ - /* face :: A face object handle. */ - /* */ - /* tag :: The searched tag. */ - /* */ - /* stream :: The stream to seek when the table is found. */ - /* */ - /* <Output> */ - /* length :: The length of the table if found, undefined otherwise. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_goto_table + * + * @Description: + * Looks for a TrueType table by name, then seek a stream to it. + * + * @Input: + * face :: + * A face object handle. + * + * tag :: + * The searched tag. + * + * stream :: + * The stream to seek when the table is found. + * + * @Output: + * length :: + * The length of the table if found, undefined otherwise. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_goto_table( TT_Face face, FT_ULong tag, @@ -309,28 +315,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_font_dir */ - /* */ - /* <Description> */ - /* Loads the header of a SFNT font file. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Output> */ - /* sfnt :: The SFNT header. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the beginning of the font directory. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_font_dir + * + * @Description: + * Loads the header of a SFNT font file. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Output: + * sfnt :: + * The SFNT header. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * The stream cursor must be at the beginning of the font directory. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_font_dir( TT_Face face, FT_Stream stream ) @@ -496,46 +505,51 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_any */ - /* */ - /* <Description> */ - /* Loads any font table into client memory. */ - /* */ - /* <Input> */ - /* face :: The face object to look for. */ - /* */ - /* tag :: The tag of table to load. Use the value 0 if you want */ - /* to access the whole font file, else set this parameter */ - /* to a valid TrueType table tag that you can forge with */ - /* the MAKE_TT_TAG macro. */ - /* */ - /* offset :: The starting offset in the table (or the file if */ - /* tag == 0). */ - /* */ - /* length :: The address of the decision variable: */ - /* */ - /* If length == NULL: */ - /* Loads the whole table. Returns an error if */ - /* `offset' == 0! */ - /* */ - /* If *length == 0: */ - /* Exits immediately; returning the length of the given */ - /* table or of the font file, depending on the value of */ - /* `tag'. */ - /* */ - /* If *length != 0: */ - /* Loads the next `length' bytes of table or font, */ - /* starting at offset `offset' (in table or font too). */ - /* */ - /* <Output> */ - /* buffer :: The address of target buffer. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_any + * + * @Description: + * Loads any font table into client memory. + * + * @Input: + * face :: + * The face object to look for. + * + * tag :: + * The tag of table to load. Use the value 0 if you want + * to access the whole font file, else set this parameter + * to a valid TrueType table tag that you can forge with + * the MAKE_TT_TAG macro. + * + * offset :: + * The starting offset in the table (or the file if + * tag == 0). + * + * length :: + * The address of the decision variable: + * + * If length == NULL: + * Loads the whole table. Returns an error if + * `offset' == 0! + * + * If *length == 0: + * Exits immediately; returning the length of the given + * table or of the font file, depending on the value of + * `tag'. + * + * If *length != 0: + * Loads the next `length' bytes of table or font, + * starting at offset `offset' (in table or font too). + * + * @Output: + * buffer :: + * The address of target buffer. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_any( TT_Face face, FT_ULong tag, @@ -586,22 +600,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_generic_header */ - /* */ - /* <Description> */ - /* Loads the TrueType table `head' or `bhed'. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_generic_header + * + * @Description: + * Loads the TrueType table `head' or `bhed'. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error tt_face_load_generic_header( TT_Face face, FT_Stream stream, @@ -622,10 +638,10 @@ FT_FRAME_LONG ( Magic_Number ), FT_FRAME_USHORT( Flags ), FT_FRAME_USHORT( Units_Per_EM ), - FT_FRAME_LONG ( Created[0] ), - FT_FRAME_LONG ( Created[1] ), - FT_FRAME_LONG ( Modified[0] ), - FT_FRAME_LONG ( Modified[1] ), + FT_FRAME_ULONG ( Created[0] ), + FT_FRAME_ULONG ( Created[1] ), + FT_FRAME_ULONG ( Modified[0] ), + FT_FRAME_ULONG ( Modified[1] ), FT_FRAME_SHORT ( xMin ), FT_FRAME_SHORT ( yMin ), FT_FRAME_SHORT ( xMax ), @@ -676,22 +692,24 @@ #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_maxp */ - /* */ - /* <Description> */ - /* Loads the maximum profile into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_maxp + * + * @Description: + * Loads the maximum profile into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_maxp( TT_Face face, FT_Stream stream ) @@ -784,22 +802,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_name */ - /* */ - /* <Description> */ - /* Loads the name records. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_name + * + * @Description: + * Loads the name records. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_name( TT_Face face, FT_Stream stream ) @@ -981,17 +1001,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_free_name */ - /* */ - /* <Description> */ - /* Frees the name records. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_free_name + * + * @Description: + * Frees the name records. + * + * @Input: + * face :: + * A handle to the target face object. + */ FT_LOCAL_DEF( void ) tt_face_free_name( TT_Face face ) { @@ -1030,23 +1051,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_cmap */ - /* */ - /* <Description> */ - /* Loads the cmap directory in a face object. The cmaps themselves */ - /* are loaded on demand in the `ttcmap.c' module. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_cmap + * + * @Description: + * Loads the cmap directory in a face object. The cmaps themselves + * are loaded on demand in the `ttcmap.c' module. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_cmap( TT_Face face, @@ -1068,22 +1091,24 @@ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_os2 */ - /* */ - /* <Description> */ - /* Loads the OS2 table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_os2 + * + * @Description: + * Loads the OS2 table. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_os2( TT_Face face, FT_Stream stream ) @@ -1228,22 +1253,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_postscript */ - /* */ - /* <Description> */ - /* Loads the Postscript table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_postscript + * + * @Description: + * Loads the Postscript table. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_post( TT_Face face, FT_Stream stream ) @@ -1288,22 +1315,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_pclt */ - /* */ - /* <Description> */ - /* Loads the PCL 5 Table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_pclt + * + * @Description: + * Loads the PCL 5 Table. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_pclt( TT_Face face, FT_Stream stream ) @@ -1349,22 +1378,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_gasp */ - /* */ - /* <Description> */ - /* Loads the `gasp' table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_gasp + * + * @Description: + * Loads the `gasp' table into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_gasp( TT_Face face, FT_Stream stream ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h index f94be8b7bd0..cc18c18694c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttload.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttload.h */ -/* */ -/* Load the basic TrueType tables, i.e., tables that can be either in */ -/* TTF or OTF fonts (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttload.h + * + * Load the basic TrueType tables, i.e., tables that can be either in + * TTF or OTF fonts (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c index 6ddda95b567..7a4d2be2cb8 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttmtx.c */ -/* */ -/* Load the metrics tables common to TTF and OTF fonts (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttmtx.c + * + * Load the metrics tables common to TTF and OTF fonts (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -38,34 +38,37 @@ /* both the horizontal and vertical headers. */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttmtx - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hmtx */ - /* */ - /* <Description> */ - /* Load the `hmtx' or `vmtx' table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load `vmtx'. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ +#define FT_COMPONENT ttmtx + + + /************************************************************************** + * + * @Function: + * tt_face_load_hmtx + * + * @Description: + * Load the `hmtx' or `vmtx' table into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * vertical :: + * A boolean flag. If set, load `vmtx'. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_hmtx( TT_Face face, FT_Stream stream, @@ -102,24 +105,27 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hhea */ - /* */ - /* <Description> */ - /* Load the `hhea' or 'vhea' table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load `vhea'. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_hhea + * + * @Description: + * Load the `hhea' or 'vhea' table into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * vertical :: + * A boolean flag. If set, load `vhea'. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_hhea( TT_Face face, FT_Stream stream, @@ -190,30 +196,35 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_get_metrics */ - /* */ - /* <Description> */ - /* Return the horizontal or vertical metrics in font units for a */ - /* given glyph. The values are the left side bearing (top side */ - /* bearing for vertical metrics) and advance width (advance height */ - /* for vertical metrics). */ - /* */ - /* <Input> */ - /* face :: A pointer to the TrueType face structure. */ - /* */ - /* vertical :: If set to TRUE, get vertical metrics. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* abearing :: The bearing, either left side or top side. */ - /* */ - /* aadvance :: The advance width or advance height, depending on */ - /* the `vertical' flag. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_get_metrics + * + * @Description: + * Return the horizontal or vertical metrics in font units for a + * given glyph. The values are the left side bearing (top side + * bearing for vertical metrics) and advance width (advance height + * for vertical metrics). + * + * @Input: + * face :: + * A pointer to the TrueType face structure. + * + * vertical :: + * If set to TRUE, get vertical metrics. + * + * gindex :: + * The glyph index. + * + * @Output: + * abearing :: + * The bearing, either left side or top side. + * + * aadvance :: + * The advance width or advance height, depending on + * the `vertical' flag. + */ FT_LOCAL_DEF( void ) tt_face_get_metrics( TT_Face face, FT_Bool vertical, diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h index ab00acd7952..5b0b60b641c 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttmtx.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttmtx.h */ -/* */ -/* Load the metrics tables common to TTF and OTF fonts (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttmtx.h + * + * Load the metrics tables common to TTF and OTF fonts (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTMTX_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c index 6de99ef9778..636a0a004ac 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ttpost.c */ -/* */ -/* PostScript name table processing for TrueType and OpenType fonts */ -/* (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* The post table is not completely loaded by the core engine. This */ - /* file loads the missing PS glyph names and implements an API to access */ - /* them. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ttpost.c + * + * PostScript name table processing for TrueType and OpenType fonts + * (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * The post table is not completely loaded by the core engine. This + * file loads the missing PS glyph names and implements an API to access + * them. + * + */ #include <ft2build.h> @@ -38,17 +38,17 @@ #include "sferrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttpost +#define FT_COMPONENT ttpost - /* If this configuration macro is defined, we rely on the `PSNames' */ + /* If this configuration macro is defined, we rely on the `psnames' */ /* module to grab the glyph names. */ #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES @@ -62,9 +62,9 @@ #else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ - /* Otherwise, we ignore the `PSNames' module, and provide our own */ + /* Otherwise, we ignore the `psnames' module, and provide our own */ /* table of Mac names. Thus, it is possible to build a version of */ - /* FreeType without the Type 1 driver & PSNames module. */ + /* FreeType without the Type 1 driver & psnames module. */ #define MAC_NAME( x ) (FT_String*)tt_post_default_names[x] @@ -459,28 +459,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_get_ps_name */ - /* */ - /* <Description> */ - /* Get the PostScript glyph name of a glyph. */ - /* */ - /* <Input> */ - /* face :: A handle to the parent face. */ - /* */ - /* idx :: The glyph index. */ - /* */ - /* <InOut> */ - /* PSname :: The address of a string pointer. Undefined in case of */ - /* error, otherwise it is a pointer to the glyph name. */ - /* */ - /* You must not modify the returned string! */ - /* */ - /* <Output> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_get_ps_name + * + * @Description: + * Get the PostScript glyph name of a glyph. + * + * @Input: + * face :: + * A handle to the parent face. + * + * idx :: + * The glyph index. + * + * @InOut: + * PSname :: + * The address of a string pointer. Undefined in case of + * error, otherwise it is a pointer to the glyph name. + * + * You must not modify the returned string! + * + * @Output: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_get_ps_name( TT_Face face, FT_UInt idx, diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h index 3bec07e4454..812a0fc92db 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttpost.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttpost.h */ -/* */ -/* PostScript name table processing for TrueType and OpenType fonts */ -/* (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttpost.h + * + * PostScript name table processing for TrueType and OpenType fonts + * (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTPOST_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c index 33b8640bc31..23bd9d7eb00 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c @@ -1,22 +1,22 @@ -/***************************************************************************/ -/* */ -/* ttsbit.c */ -/* */ -/* TrueType and OpenType embedded bitmap support (body). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* Copyright 2013 by Google, Inc. */ -/* Google Author(s): Behdad Esfahbod. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsbit.c + * + * TrueType and OpenType embedded bitmap support (body). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Copyright 2013 by Google, Inc. + * Google Author(s): Behdad Esfahbod. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -36,14 +36,14 @@ #include "pngshim.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttsbit +#define FT_COMPONENT ttsbit FT_LOCAL_DEF( FT_Error ) @@ -129,8 +129,8 @@ } /* - * Count the number of strikes available in the table. We are a bit - * paranoid there and don't trust the data. + * Count the number of strikes available in the table. We are a bit + * paranoid there and don't trust the data. */ count = (FT_UInt)num_strikes; if ( 8 + 48UL * count > table_size ) @@ -182,8 +182,8 @@ " expect bad rendering results\n" )); /* - * Count the number of strikes available in the table. We are a bit - * paranoid there and don't trust the data. + * Count the number of strikes available in the table. We are a bit + * paranoid there and don't trust the data. */ count = (FT_UInt)num_strikes; if ( 8 + 4UL * count > table_size ) @@ -1014,8 +1014,8 @@ for ( nn = 0; nn < num_components; nn++ ) { FT_UInt gindex = FT_NEXT_USHORT( p ); - FT_Byte dx = FT_NEXT_BYTE( p ); - FT_Byte dy = FT_NEXT_BYTE( p ); + FT_Char dx = FT_NEXT_CHAR( p ); + FT_Char dy = FT_NEXT_CHAR( p ); /* NB: a recursive call */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h index ce2af3c1628..5ab8ff55689 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h +++ b/src/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttsbit.h */ -/* */ -/* TrueType and OpenType embedded bitmap support (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsbit.h + * + * TrueType and OpenType embedded bitmap support (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTSBIT_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c index 803a19e4150..91293ac9463 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c +++ b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c @@ -1,94 +1,94 @@ -/***************************************************************************/ -/* */ -/* ftgrays.c */ -/* */ -/* A new `perfect' anti-aliasing renderer (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file can be compiled without the rest of the FreeType engine, by */ - /* defining the STANDALONE_ macro when compiling it. You also need to */ - /* put the files `ftgrays.h' and `ftimage.h' into the current */ - /* compilation directory. Typically, you could do something like */ - /* */ - /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */ - /* */ - /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */ - /* same directory */ - /* */ - /* - compile `ftgrays' with the STANDALONE_ macro defined, as in */ - /* */ - /* cc -c -DSTANDALONE_ ftgrays.c */ - /* */ - /* The renderer can be initialized with a call to */ - /* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */ - /* with a call to `ft_gray_raster.raster_render'. */ - /* */ - /* See the comments and documentation in the file `ftimage.h' for more */ - /* details on how the raster works. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* This is a new anti-aliasing scan-converter for FreeType 2. The */ - /* algorithm used here is _very_ different from the one in the standard */ - /* `ftraster' module. Actually, `ftgrays' computes the _exact_ */ - /* coverage of the outline on each pixel cell. */ - /* */ - /* It is based on ideas that I initially found in Raph Levien's */ - /* excellent LibArt graphics library (see http://www.levien.com/libart */ - /* for more information, though the web pages do not tell anything */ - /* about the renderer; you'll have to dive into the source code to */ - /* understand how it works). */ - /* */ - /* Note, however, that this is a _very_ different implementation */ - /* compared to Raph's. Coverage information is stored in a very */ - /* different way, and I don't use sorted vector paths. Also, it doesn't */ - /* use floating point values. */ - /* */ - /* This renderer has the following advantages: */ - /* */ - /* - It doesn't need an intermediate bitmap. Instead, one can supply a */ - /* callback function that will be called by the renderer to draw gray */ - /* spans on any target surface. You can thus do direct composition on */ - /* any kind of bitmap, provided that you give the renderer the right */ - /* callback. */ - /* */ - /* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */ - /* each pixel cell. */ - /* */ - /* - It performs a single pass on the outline (the `standard' FT2 */ - /* renderer makes two passes). */ - /* */ - /* - It can easily be modified to render to _any_ number of gray levels */ - /* cheaply. */ - /* */ - /* - For small (< 20) pixel sizes, it is faster than the standard */ - /* renderer. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ +/**************************************************************************** + * + * ftgrays.c + * + * A new `perfect' anti-aliasing renderer (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file can be compiled without the rest of the FreeType engine, by + * defining the STANDALONE_ macro when compiling it. You also need to + * put the files `ftgrays.h' and `ftimage.h' into the current + * compilation directory. Typically, you could do something like + * + * - copy `src/smooth/ftgrays.c' (this file) to your current directory + * + * - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the + * same directory + * + * - compile `ftgrays' with the STANDALONE_ macro defined, as in + * + * cc -c -DSTANDALONE_ ftgrays.c + * + * The renderer can be initialized with a call to + * `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated + * with a call to `ft_gray_raster.raster_render'. + * + * See the comments and documentation in the file `ftimage.h' for more + * details on how the raster works. + * + */ + + /************************************************************************** + * + * This is a new anti-aliasing scan-converter for FreeType 2. The + * algorithm used here is _very_ different from the one in the standard + * `ftraster' module. Actually, `ftgrays' computes the _exact_ + * coverage of the outline on each pixel cell. + * + * It is based on ideas that I initially found in Raph Levien's + * excellent LibArt graphics library (see https://www.levien.com/libart + * for more information, though the web pages do not tell anything + * about the renderer; you'll have to dive into the source code to + * understand how it works). + * + * Note, however, that this is a _very_ different implementation + * compared to Raph's. Coverage information is stored in a very + * different way, and I don't use sorted vector paths. Also, it doesn't + * use floating point values. + * + * This renderer has the following advantages: + * + * - It doesn't need an intermediate bitmap. Instead, one can supply a + * callback function that will be called by the renderer to draw gray + * spans on any target surface. You can thus do direct composition on + * any kind of bitmap, provided that you give the renderer the right + * callback. + * + * - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on + * each pixel cell. + * + * - It performs a single pass on the outline (the `standard' FT2 + * renderer makes two passes). + * + * - It can easily be modified to render to _any_ number of gray levels + * cheaply. + * + * - For small (< 20) pixel sizes, it is faster than the standard + * renderer. + * + */ + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_smooth +#define FT_COMPONENT smooth #ifdef STANDALONE_ @@ -112,9 +112,9 @@ /* - * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' - * algorithm. We use alpha = 1, beta = 3/8, giving us results with a - * largest error less than 7% compared to the exact value. + * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' + * algorithm. We use alpha = 1, beta = 3/8, giving us results with a + * largest error less than 7% compared to the exact value. */ #define FT_HYPOT( x, y ) \ ( x = FT_ABS( x ), \ @@ -222,10 +222,10 @@ typedef ptrdiff_t FT_PtrDist; #endif #define FT_THROW( e ) \ - ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \ + ( FT_Throw( FT_ERR_CAT( ErrRaster_, e ), \ __LINE__, \ __FILE__ ) | \ - FT_ERR_CAT( ErrRaster, e ) ) + FT_ERR_CAT( ErrRaster_, e ) ) #else /* !FT_DEBUG_LEVEL_TRACE */ @@ -279,8 +279,6 @@ typedef ptrdiff_t FT_PtrDist; #include "ftsmerrs.h" -#include "ftspic.h" - #define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph #define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory @@ -395,10 +393,10 @@ typedef ptrdiff_t FT_PtrDist; ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) ) - /*************************************************************************/ - /* */ - /* TYPE DEFINITIONS */ - /* */ + /************************************************************************** + * + * TYPE DEFINITIONS + */ /* don't change the following types to FT_Int or FT_Pos, since we might */ /* need to define them to "float" or "double" when experimenting with */ @@ -516,10 +514,10 @@ typedef ptrdiff_t FT_PtrDist; #endif /* FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* Record the current cell in the table. */ - /* */ + /************************************************************************** + * + * Record the current cell in the table. + */ static void gray_record_cell( RAS_ARG ) { @@ -561,10 +559,10 @@ typedef ptrdiff_t FT_PtrDist; } - /*************************************************************************/ - /* */ - /* Set the current cell to a new position. */ - /* */ + /************************************************************************** + * + * Set the current cell to a new position. + */ static void gray_set_cell( RAS_ARG_ TCoord ex, TCoord ey ) @@ -598,10 +596,10 @@ typedef ptrdiff_t FT_PtrDist; #ifndef FT_LONG64 - /*************************************************************************/ - /* */ - /* Render a scanline as one or more cells. */ - /* */ + /************************************************************************** + * + * Render a scanline as one or more cells. + */ static void gray_render_scanline( RAS_ARG_ TCoord ey, TPos x1, @@ -696,10 +694,10 @@ typedef ptrdiff_t FT_PtrDist; } - /*************************************************************************/ - /* */ - /* Render a given line as a series of scanlines. */ - /* */ + /************************************************************************** + * + * Render a given line as a series of scanlines. + */ static void gray_render_line( RAS_ARG_ TPos to_x, TPos to_y ) @@ -837,10 +835,10 @@ typedef ptrdiff_t FT_PtrDist; #else - /*************************************************************************/ - /* */ - /* Render a straight line across multiple cells in any direction. */ - /* */ + /************************************************************************** + * + * Render a straight line across multiple cells in any direction. + */ static void gray_render_line( RAS_ARG_ TPos to_x, TPos to_y ) @@ -1330,40 +1328,43 @@ typedef ptrdiff_t FT_PtrDist; #ifdef STANDALONE_ - /*************************************************************************/ - /* */ - /* The following functions should only compile in stand-alone mode, */ - /* i.e., when building this component without the rest of FreeType. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Decompose */ - /* */ - /* <Description> */ - /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bézier arcs. This function is also able to emit */ - /* `move to' and `close to' operations to indicate the start and end */ - /* of new contours in the outline. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source target. */ - /* */ - /* func_interface :: A table of `emitters', i.e., function pointers */ - /* called during decomposition to indicate path */ - /* operations. */ - /* */ - /* <InOut> */ - /* user :: A typeless pointer which is passed to each */ - /* emitter during the decomposition. It can be */ - /* used to store the state during the */ - /* decomposition. */ - /* */ - /* <Return> */ - /* Error code. 0 means success. */ - /* */ + /************************************************************************** + * + * The following functions should only compile in stand-alone mode, + * i.e., when building this component without the rest of FreeType. + * + */ + + /************************************************************************** + * + * @Function: + * FT_Outline_Decompose + * + * @Description: + * Walk over an outline's structure to decompose it into individual + * segments and Bézier arcs. This function is also able to emit + * `move to' and `close to' operations to indicate the start and end + * of new contours in the outline. + * + * @Input: + * outline :: + * A pointer to the source target. + * + * func_interface :: + * A table of `emitters', i.e., function pointers + * called during decomposition to indicate path + * operations. + * + * @InOut: + * user :: + * A typeless pointer which is passed to each + * emitter during the decomposition. It can be + * used to store the state during the + * decomposition. + * + * @Return: + * Error code. 0 means success. + */ static int FT_Outline_Decompose( const FT_Outline* outline, const FT_Outline_Funcs* func_interface, @@ -1610,81 +1611,6 @@ typedef ptrdiff_t FT_PtrDist; return FT_THROW( Invalid_Outline ); } - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_CBox */ - /* */ - /* <Description> */ - /* Return an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bézier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bézier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <Output> */ - /* acbox :: The outline's control box. */ - /* */ - /* <Note> */ - /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ - /* */ - - static void - FT_Outline_Get_CBox( const FT_Outline* outline, - FT_BBox *acbox ) - { - TPos xMin, yMin, xMax, yMax; - - - if ( outline && acbox ) - { - if ( outline->n_points == 0 ) - { - xMin = 0; - yMin = 0; - xMax = 0; - yMax = 0; - } - else - { - FT_Vector* vec = outline->points; - FT_Vector* limit = vec + outline->n_points; - - - xMin = xMax = vec->x; - yMin = yMax = vec->y; - vec++; - - for ( ; vec < limit; vec++ ) - { - TPos x, y; - - - x = vec->x; - if ( x < xMin ) xMin = x; - if ( x > xMax ) xMax = x; - - y = vec->y; - if ( y < yMin ) yMin = y; - if ( y > yMax ) yMax = y; - } - } - acbox->xMin = xMin; - acbox->xMax = xMax; - acbox->yMin = yMin; - acbox->yMax = yMax; - } - } - #endif /* STANDALONE_ */ @@ -1702,19 +1628,20 @@ typedef ptrdiff_t FT_PtrDist; static int - gray_convert_glyph_inner( RAS_ARG ) + gray_convert_glyph_inner( RAS_ARG, + int continued ) { - volatile int error = 0; -#ifdef FT_CONFIG_OPTION_PIC - FT_Outline_Funcs func_interface; - Init_Class_func_interface(&func_interface); -#endif if ( ft_setjmp( ras.jump_buffer ) == 0 ) { + if ( continued ) + FT_Trace_Disable(); error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); + if ( continued ) + FT_Trace_Enable(); + if ( !ras.invalid ) gray_record_cell( RAS_VAR ); @@ -1741,8 +1668,6 @@ typedef ptrdiff_t FT_PtrDist; { const TCoord yMin = ras.min_ey; const TCoord yMax = ras.max_ey; - const TCoord xMin = ras.min_ex; - const TCoord xMax = ras.max_ex; TCell buffer[FT_MAX_GRAY_POOL]; size_t height = (size_t)( yMax - yMin ); @@ -1751,6 +1676,8 @@ typedef ptrdiff_t FT_PtrDist; TCoord bands[32]; /* enough to accommodate bisections */ TCoord* band; + int continued = 0; + /* set up vertical bands */ if ( height > n ) @@ -1774,8 +1701,8 @@ typedef ptrdiff_t FT_PtrDist; ras.max_ey = FT_MIN( y, yMax ); band = bands; - band[1] = xMin; - band[0] = xMax; + band[1] = ras.min_ey; + band[0] = ras.max_ey; do { @@ -1787,10 +1714,11 @@ typedef ptrdiff_t FT_PtrDist; ras.num_cells = 0; ras.invalid = 1; - ras.min_ex = band[1]; - ras.max_ex = band[0]; + ras.min_ey = band[1]; + ras.max_ey = band[0]; - error = gray_convert_glyph_inner( RAS_VAR ); + error = gray_convert_glyph_inner( RAS_VAR, continued ); + continued = 1; if ( !error ) { @@ -1827,7 +1755,7 @@ typedef ptrdiff_t FT_PtrDist; { const FT_Outline* outline = (const FT_Outline*)params->source; const FT_Bitmap* target_map = params->target; - FT_BBox cbox, clip; + FT_BBox clip; #ifndef FT_STATIC_RASTER gray_TWorker worker[1]; @@ -1890,21 +1818,11 @@ typedef ptrdiff_t FT_PtrDist; ras.render_span_data = NULL; } - FT_Outline_Get_CBox( outline, &cbox ); - - /* reject too large outline coordinates */ - if ( cbox.xMin < -0x1000000L || cbox.xMax > 0x1000000L || - cbox.yMin < -0x1000000L || cbox.yMax > 0x1000000L ) - return FT_THROW( Invalid_Outline ); - - /* truncate the bounding box to integer pixels */ - cbox.xMin = cbox.xMin >> 6; - cbox.yMin = cbox.yMin >> 6; - cbox.xMax = ( cbox.xMax + 63 ) >> 6; - cbox.yMax = ( cbox.yMax + 63 ) >> 6; - /* compute clipping box */ - if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) + if ( params->flags & FT_RASTER_FLAG_DIRECT && + params->flags & FT_RASTER_FLAG_CLIP ) + clip = params->clip_box; + else { /* compute clip box from target pixmap */ clip.xMin = 0; @@ -1912,21 +1830,12 @@ typedef ptrdiff_t FT_PtrDist; clip.xMax = (FT_Pos)target_map->width; clip.yMax = (FT_Pos)target_map->rows; } - else if ( params->flags & FT_RASTER_FLAG_CLIP ) - clip = params->clip_box; - else - { - clip.xMin = -32768L; - clip.yMin = -32768L; - clip.xMax = 32767L; - clip.yMax = 32767L; - } /* clip to target bitmap, exit if nothing to do */ - ras.min_ex = FT_MAX( cbox.xMin, clip.xMin ); - ras.min_ey = FT_MAX( cbox.yMin, clip.yMin ); - ras.max_ex = FT_MIN( cbox.xMax, clip.xMax ); - ras.max_ey = FT_MIN( cbox.yMax, clip.yMax ); + ras.min_ex = clip.xMin; + ras.min_ey = clip.yMin; + ras.max_ex = clip.xMax; + ras.max_ey = clip.yMax; if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey ) return 0; diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h index 9e11ca675ef..e9f9c7a4add 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h +++ b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgrays.h */ -/* */ -/* FreeType smooth renderer declaration */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgrays.h + * + * FreeType smooth renderer declaration + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGRAYS_H_ @@ -28,19 +28,18 @@ #include "ftimage.h" #else #include <ft2build.h> -#include FT_CONFIG_CONFIG_H /* for FT_CONFIG_OPTION_PIC */ #include FT_IMAGE_H #endif - /*************************************************************************/ - /* */ - /* To make ftgrays.h independent from configuration files we check */ - /* whether FT_EXPORT_VAR has been defined already. */ - /* */ - /* On some systems and compilers (Win32 mostly), an extra keyword is */ - /* necessary to compile the library as a DLL. */ - /* */ + /************************************************************************** + * + * To make ftgrays.h independent from configuration files we check + * whether FT_EXPORT_VAR has been defined already. + * + * On some systems and compilers (Win32 mostly), an extra keyword is + * necessary to compile the library as a DLL. + */ #ifndef FT_EXPORT_VAR #define FT_EXPORT_VAR( x ) extern x #endif diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h index 226dc1b0017..d52c0dd9e20 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmerrs.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftsmerrs.h */ -/* */ -/* smooth renderer error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the smooth renderer error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftsmerrs.h + * + * smooth renderer error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the smooth renderer error enumeration + * constants. + * + */ #ifndef FTSMERRS_H_ #define FTSMERRS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c index ef176bdf1ec..c8b6bb75186 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c +++ b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsmooth.c */ -/* */ -/* Anti-aliasing renderer interface (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsmooth.c + * + * Anti-aliasing renderer interface (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -22,7 +22,6 @@ #include FT_OUTLINE_H #include "ftsmooth.h" #include "ftgrays.h" -#include "ftspic.h" #include "ftsmerrs.h" @@ -31,6 +30,26 @@ static FT_Error ft_smooth_init( FT_Renderer render ) { + +#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + + FT_Vector* sub = render->root.library->lcd_geometry; + + + /* set up default subpixel geometry for striped RGB panels. */ + sub[0].x = -21; + sub[0].y = 0; + sub[1].x = 0; + sub[1].y = 0; + sub[2].x = 21; + sub[2].y = 0; + +#elif 0 /* or else, once ClearType patents expire */ + + FT_Library_SetLcdFilter( render->root.library, FT_LCD_FILTER_DEFAULT ); + +#endif + render->clazz->raster_class->raster_reset( render->raster, NULL, 0 ); return 0; @@ -130,7 +149,11 @@ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } - ft_glyphslot_preset_bitmap( slot, mode, origin ); + if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) ) + { + error = FT_THROW( Raster_Overflow ); + goto Exit; + } /* allocate new one */ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) @@ -235,33 +258,40 @@ unsigned int width = bitmap->width; int pitch = bitmap->pitch; + FT_Vector* sub = slot->library->lcd_geometry; - /* Render 3 separate monochrome bitmaps, shifting the outline */ - /* by 1/3 pixel. */ - width /= 3; - bitmap->buffer += width; + /* Render 3 separate monochrome bitmaps, shifting the outline. */ + width /= 3; + FT_Outline_Translate( outline, + -sub[0].x, + -sub[0].y ); error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, -21, 0 ); - x_shift -= 21; bitmap->buffer += width; - + FT_Outline_Translate( outline, + sub[0].x - sub[1].x, + sub[0].y - sub[1].y ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= width; if ( error ) goto Exit; - FT_Outline_Translate( outline, 42, 0 ); - x_shift += 42; - bitmap->buffer -= 2 * width; - + bitmap->buffer += 2 * width; + FT_Outline_Translate( outline, + sub[1].x - sub[2].x, + sub[1].y - sub[2].y ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= 2 * width; if ( error ) goto Exit; + x_shift -= sub[2].x; + y_shift -= sub[2].y; + /* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */ /* XXX: It is more efficient to render every third byte above. */ @@ -286,34 +316,43 @@ { int pitch = bitmap->pitch; + FT_Vector* sub = slot->library->lcd_geometry; + - /* Render 3 separate monochrome bitmaps, shifting the outline */ - /* by 1/3 pixel. Triple the pitch to render on each third row. */ + /* Render 3 separate monochrome bitmaps, shifting the outline. */ + /* Notice that the subpixel geometry vectors are rotated. */ + /* Triple the pitch to render on each third row. */ bitmap->pitch *= 3; bitmap->rows /= 3; - bitmap->buffer += pitch; - + FT_Outline_Translate( outline, + -sub[0].y, + sub[0].x ); error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, 21 ); - y_shift += 21; bitmap->buffer += pitch; - + FT_Outline_Translate( outline, + sub[0].y - sub[1].y, + sub[1].x - sub[0].x ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= pitch; if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, -42 ); - y_shift -= 42; - bitmap->buffer -= 2 * pitch; - + bitmap->buffer += 2 * pitch; + FT_Outline_Translate( outline, + sub[1].y - sub[2].y, + sub[2].x - sub[1].x ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= 2 * pitch; if ( error ) goto Exit; + x_shift -= sub[2].y; + y_shift += sub[2].x; + bitmap->pitch /= 3; bitmap->rows *= 3; } @@ -403,7 +442,7 @@ (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */ ) @@ -430,7 +469,7 @@ (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */ ) @@ -457,7 +496,7 @@ (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */ ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h index c76ffc5034e..fbb21a31d05 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h +++ b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsmooth.h */ -/* */ -/* Anti-aliasing renderer interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsmooth.h + * + * Anti-aliasing renderer interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSMOOTH_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftspic.c b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftspic.c deleted file mode 100644 index 10f04cf4ccf..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftspic.c +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftspic.c */ -/* */ -/* The FreeType position independent code services for smooth module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "ftspic.h" -#include "ftsmerrs.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from ftgrays.c */ - void - FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs ); - - - void - ft_smooth_renderer_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->smooth ) - { - SmoothPIC* container = (SmoothPIC*)pic_container->smooth; - - - if ( --container->ref_count ) - return; - - FT_FREE( container ); - pic_container->smooth = NULL; - } - } - - - FT_Error - ft_smooth_renderer_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - SmoothPIC* container = NULL; - FT_Memory memory = library->memory; - - - /* since this function also serve smooth_lcd and smooth_lcdv renderers, - it implements reference counting */ - if ( pic_container->smooth ) - { - ((SmoothPIC*)pic_container->smooth)->ref_count++; - return error; - } - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->smooth = container; - - container->ref_count = 1; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - FT_Init_Class_ft_grays_raster( &container->ft_grays_raster ); - - return error; - } - - - /* re-route these init and free functions to the above functions */ - FT_Error - ft_smooth_lcd_renderer_class_pic_init( FT_Library library ) - { - return ft_smooth_renderer_class_pic_init( library ); - } - - - void - ft_smooth_lcd_renderer_class_pic_free( FT_Library library ) - { - ft_smooth_renderer_class_pic_free( library ); - } - - - FT_Error - ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ) - { - return ft_smooth_renderer_class_pic_init( library ); - } - - - void - ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ) - { - ft_smooth_renderer_class_pic_free( library ); - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftspic.h b/src/src/java.desktop/share/native/libfreetype/src/smooth/ftspic.h deleted file mode 100644 index 80fb64cff43..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/smooth/ftspic.h +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftspic.h */ -/* */ -/* The FreeType position independent code services for smooth module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTSPIC_H_ -#define FTSPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -FT_BEGIN_HEADER - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_GRAYS_RASTER_GET ft_grays_raster - -#else /* FT_CONFIG_OPTION_PIC */ - - typedef struct SmoothPIC_ - { - int ref_count; - FT_Raster_Funcs ft_grays_raster; - - } SmoothPIC; - - -#define GET_PIC( lib ) \ - ( (SmoothPIC*)( (lib)->pic_container.smooth ) ) -#define FT_GRAYS_RASTER_GET ( GET_PIC( library )->ft_grays_raster ) - - - /* see ftspic.c for the implementation */ - void - ft_smooth_renderer_class_pic_free( FT_Library library ); - - void - ft_smooth_lcd_renderer_class_pic_free( FT_Library library ); - - void - ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ); - - FT_Error - ft_smooth_renderer_class_pic_init( FT_Library library ); - - FT_Error - ft_smooth_lcd_renderer_class_pic_init( FT_Library library ); - - FT_Error - ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ); - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -FT_END_HEADER - -#endif /* FTSPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c index 820cafbb8d8..ff626d53ab9 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttdriver.c */ -/* */ -/* TrueType font driver implementation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttdriver.c + * + * TrueType font driver implementation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -43,20 +43,19 @@ #include "tterrors.h" -#include "ttpic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttdriver +#define FT_COMPONENT ttdriver /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ static FT_Error @@ -164,38 +163,42 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_get_kerning */ - /* */ - /* <Description> */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* <Output> */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this function. Other layouts, or more sophisticated */ - /* kernings, are out of scope of this method (the basic driver */ - /* interface is meant to be simple). */ - /* */ - /* They can be implemented by format-specific interfaces. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_get_kerning + * + * @Description: + * A driver method used to return the kerning vector between two + * glyphs of the same face. + * + * @Input: + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * @Output: + * kerning :: + * The kerning vector. This is in font units for + * scalable formats, and in pixels for fixed-sizes + * formats. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only horizontal layouts (left-to-right & right-to-left) are + * supported by this function. Other layouts, or more sophisticated + * kernings, are out of scope of this method (the basic driver + * interface is meant to be simple). + * + * They can be implemented by format-specific interfaces. + */ static FT_Error tt_get_kerning( FT_Face ttface, /* TT_Face */ FT_UInt left_glyph, @@ -384,32 +387,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_glyph_load */ - /* */ - /* <Description> */ - /* A driver method used to load a glyph within a given glyph slot. */ - /* */ - /* <Input> */ - /* slot :: A handle to the target slot object where the glyph */ - /* will be loaded. */ - /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled, loaded, etc. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_glyph_load + * + * @Description: + * A driver method used to load a glyph within a given glyph slot. + * + * @Input: + * slot :: + * A handle to the target slot object where the glyph + * will be loaded. + * + * size :: + * A handle to the source face size at which the glyph + * must be scaled, loaded, etc. + * + * glyph_index :: + * The index of the glyph in the font file. + * + * load_flags :: + * A flag indicating what to load for this glyph. The + * FT_LOAD_XXX constants can be used to control the + * glyph loading process (e.g., whether the outline + * should be scaled, whether to load bitmaps or not, + * whether to hint the outline, etc). + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */ FT_Size ttsize, /* TT_Size */ @@ -464,7 +471,7 @@ ? &ttsize->metrics : &size->hinted_metrics; - /* now load the glyph outline if necessary */ + /* now fill in the glyph slot with outline/bitmap/layered */ error = TT_Load_Glyph( size, slot, glyph_index, load_flags ); /* force drop-out mode to 2 - irrelevant now */ @@ -491,17 +498,19 @@ FT_DEFINE_SERVICE_MULTIMASTERSREC( tt_service_gx_multi_masters, - (FT_Get_MM_Func) NULL, /* get_mm */ - (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ - (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */ - (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */ - (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */ - (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */ - (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */ - (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */ - - (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */ - (FT_Done_Blend_Func) tt_done_blend /* done_blend */ + (FT_Get_MM_Func) NULL, /* get_mm */ + (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ + (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */ + (FT_Set_Var_Design_Func) TT_Set_Var_Design, /* set_var_design */ + (FT_Get_Var_Design_Func) TT_Get_Var_Design, /* get_var_design */ + (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */ + (FT_Set_MM_WeightVector_Func)NULL, /* set_mm_weightvector */ + (FT_Get_MM_WeightVector_Func)NULL, /* get_mm_weightvector */ + + (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */ + (FT_Done_Blend_Func) tt_done_blend /* done_blend */ ) FT_DEFINE_SERVICE_METRICSVARIATIONSREC( @@ -548,19 +557,19 @@ tt_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, - FT_SERVICE_ID_MULTI_MASTERS, &TT_SERVICE_GX_MULTI_MASTERS_GET, - FT_SERVICE_ID_METRICS_VARIATIONS, &TT_SERVICE_METRICS_VARIATIONS_GET, + FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters, + FT_SERVICE_ID_METRICS_VARIATIONS, &tt_service_metrics_variations, FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, - FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, - FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET ) + FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, + FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) #else FT_DEFINE_SERVICEDESCREC4( tt_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, - FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, - FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET ) + FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, + FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) #endif @@ -574,26 +583,15 @@ SFNT_Service sfnt; - /* TT_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - if ( !driver ) - return NULL; - library = driver->library; - if ( !library ) - return NULL; -#endif - - result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface ); + result = ft_service_list_lookup( tt_services, tt_interface ); if ( result ) return result; -#ifndef FT_CONFIG_OPTION_PIC if ( !driver ) return NULL; library = driver->library; if ( !library ) return NULL; -#endif /* only return the default interface from the SFNT module */ sfntd = FT_Get_Module( library, "sfnt" ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h index 707aa68edf3..3936c6a4def 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttdriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttdriver.h */ -/* */ -/* High-level TrueType driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttdriver.h + * + * High-level TrueType driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTDRIVER_H_ @@ -26,10 +26,8 @@ FT_BEGIN_HEADER - FT_DECLARE_DRIVER( tt_driver_class ) - FT_END_HEADER #endif /* TTDRIVER_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h index 88bca3a04af..5609d28d689 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/tterrors.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* tterrors.h */ -/* */ -/* TrueType error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the TrueType error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * tterrors.h + * + * TrueType error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the TrueType error enumeration + * constants. + * + */ #ifndef TTERRORS_H_ #define TTERRORS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c index 39d9c3f7362..cbee27aa692 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttgload.c */ -/* */ -/* TrueType Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttgload.c + * + * TrueType Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -38,20 +38,35 @@ #include "ttsubpix.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttgload +#define FT_COMPONENT ttgload - /*************************************************************************/ - /* */ - /* Composite glyph flags. */ - /* */ + /************************************************************************** + * + * Simple glyph flags. + */ +#define ON_CURVE_POINT 0x01 /* same value as FT_CURVE_TAG_ON */ +#define X_SHORT_VECTOR 0x02 +#define Y_SHORT_VECTOR 0x04 +#define REPEAT_FLAG 0x08 +#define X_POSITIVE 0x10 /* two meanings depending on X_SHORT_VECTOR */ +#define SAME_X 0x10 +#define Y_POSITIVE 0x20 /* two meanings depending on Y_SHORT_VECTOR */ +#define SAME_Y 0x20 +#define OVERLAP_SIMPLE 0x40 /* we ignore this value */ + + + /************************************************************************** + * + * Composite glyph flags. + */ #define ARGS_ARE_WORDS 0x0001 #define ARGS_ARE_XY_VALUES 0x0002 #define ROUND_XY_TO_GRID 0x0004 @@ -62,15 +77,15 @@ #define WE_HAVE_A_2X2 0x0080 #define WE_HAVE_INSTR 0x0100 #define USE_MY_METRICS 0x0200 -#define OVERLAP_COMPOUND 0x0400 +#define OVERLAP_COMPOUND 0x0400 /* we ignore this value */ #define SCALED_COMPONENT_OFFSET 0x0800 #define UNSCALED_COMPONENT_OFFSET 0x1000 - /*************************************************************************/ - /* */ - /* Return the horizontal metrics in font units for a given glyph. */ - /* */ + /************************************************************************** + * + * Return the horizontal metrics in font units for a given glyph. + */ FT_LOCAL_DEF( void ) TT_Get_HMetrics( TT_Face face, FT_UInt idx, @@ -84,11 +99,11 @@ } - /*************************************************************************/ - /* */ - /* Return the vertical metrics in font units for a given glyph. */ - /* See function `tt_loader_set_pp' below for explanations. */ - /* */ + /************************************************************************** + * + * Return the vertical metrics in font units for a given glyph. + * See function `tt_loader_set_pp' below for explanations. + */ FT_LOCAL_DEF( void ) TT_Get_VMetrics( TT_Face face, FT_UInt idx, @@ -250,13 +265,13 @@ #endif /* FT_CONFIG_OPTION_INCREMENTAL */ - /*************************************************************************/ - /* */ - /* The following functions are used by default with TrueType fonts. */ - /* However, they can be replaced by alternatives if we need to support */ - /* TrueType-compressed formats (like MicroType) in the future. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * The following functions are used by default with TrueType fonts. + * However, they can be replaced by alternatives if we need to support + * TrueType-compressed formats (like MicroType) in the future. + * + */ FT_CALLBACK_DEF( FT_Error ) TT_Access_Glyph_Frame( TT_Loader loader, @@ -267,12 +282,9 @@ FT_Error error; FT_Stream stream = loader->stream; - /* for non-debug mode */ FT_UNUSED( glyph_index ); - FT_TRACE4(( "Glyph %ld\n", glyph_index )); - /* the following line sets the `error' variable through macros! */ if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) ) return error; @@ -337,7 +349,7 @@ FT_Byte *flag, *flag_limit; FT_Byte c, count; FT_Vector *vec, *vec_limit; - FT_Pos x; + FT_Pos x, y; FT_Short *cont, *cont_limit, prev_cont; FT_Int xy_size = 0; @@ -382,6 +394,8 @@ goto Invalid_Outline; } + FT_TRACE5(( " # of points: %d\n", n_points )); + /* note that we will add four phantom points later */ error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 ); if ( error ) @@ -452,7 +466,7 @@ goto Invalid_Outline; *flag++ = c = FT_NEXT_BYTE( p ); - if ( c & 8 ) + if ( c & REPEAT_FLAG ) { if ( p + 1 > limit ) goto Invalid_Outline; @@ -478,31 +492,29 @@ for ( ; vec < vec_limit; vec++, flag++ ) { - FT_Pos y = 0; - FT_Byte f = *flag; + FT_Pos delta = 0; + FT_Byte f = *flag; - if ( f & 2 ) + if ( f & X_SHORT_VECTOR ) { if ( p + 1 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_BYTE( p ); - if ( ( f & 16 ) == 0 ) - y = -y; + delta = (FT_Pos)FT_NEXT_BYTE( p ); + if ( !( f & X_POSITIVE ) ) + delta = -delta; } - else if ( ( f & 16 ) == 0 ) + else if ( !( f & SAME_X ) ) { if ( p + 2 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_SHORT( p ); + delta = (FT_Pos)FT_NEXT_SHORT( p ); } - x += y; + x += delta; vec->x = x; - /* the cast is for stupid compilers */ - *flag = (FT_Byte)( f & ~( 2 | 16 ) ); } /* reading the Y coordinates */ @@ -510,35 +522,36 @@ vec = gloader->current.outline.points; vec_limit = vec + n_points; flag = (FT_Byte*)outline->tags; - x = 0; + y = 0; for ( ; vec < vec_limit; vec++, flag++ ) { - FT_Pos y = 0; - FT_Byte f = *flag; + FT_Pos delta = 0; + FT_Byte f = *flag; - if ( f & 4 ) + if ( f & Y_SHORT_VECTOR ) { if ( p + 1 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_BYTE( p ); - if ( ( f & 32 ) == 0 ) - y = -y; + delta = (FT_Pos)FT_NEXT_BYTE( p ); + if ( !( f & Y_POSITIVE ) ) + delta = -delta; } - else if ( ( f & 32 ) == 0 ) + else if ( !( f & SAME_Y ) ) { if ( p + 2 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_SHORT( p ); + delta = (FT_Pos)FT_NEXT_SHORT( p ); } - x += y; - vec->y = x; + y += delta; + vec->y = y; + /* the cast is for stupid compilers */ - *flag = (FT_Byte)( f & FT_CURVE_TAG_ON ); + *flag = (FT_Byte)( f & ON_CURVE_POINT ); } outline->n_points = (FT_Short)n_points; @@ -559,9 +572,10 @@ TT_Load_Composite_Glyph( TT_Loader loader ) { FT_Error error; - FT_Byte* p = loader->cursor; - FT_Byte* limit = loader->limit; - FT_GlyphLoader gloader = loader->gloader; + FT_Byte* p = loader->cursor; + FT_Byte* limit = loader->limit; + FT_GlyphLoader gloader = loader->gloader; + FT_Long num_glyphs = loader->face->root.num_glyphs; FT_SubGlyph subglyph; FT_UInt num_subglyphs; @@ -590,6 +604,11 @@ subglyph->flags = FT_NEXT_USHORT( p ); subglyph->index = FT_NEXT_USHORT( p ); + /* we reject composites that have components */ + /* with invalid glyph indices */ + if ( subglyph->index >= num_glyphs ) + goto Invalid_Composite; + /* check space */ count = 2; if ( subglyph->flags & ARGS_ARE_WORDS ) @@ -768,15 +787,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Hint_Glyph */ - /* */ - /* <Description> */ - /* Hint the glyph using the zone prepared by the caller. Note that */ - /* the zone is supposed to include four phantom points. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Hint_Glyph + * + * @Description: + * Hint the glyph using the zone prepared by the caller. Note that + * the zone is supposed to include four phantom points. + */ static FT_Error TT_Hint_Glyph( TT_Loader loader, FT_Bool is_composite ) @@ -797,15 +816,9 @@ #ifdef TT_USE_BYTECODE_INTERPRETER - if ( loader->glyph->control_len > 0xFFFFL ) - { - FT_TRACE1(( "TT_Hint_Glyph: too long instructions" )); - FT_TRACE1(( " (0x%lx byte) is truncated\n", - loader->glyph->control_len )); - } n_ins = loader->glyph->control_len; - /* save original point position in org */ + /* save original point positions in `org' array */ if ( n_ins > 0 ) FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points ); @@ -896,16 +909,16 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Process_Simple_Glyph */ - /* */ - /* <Description> */ - /* Once a simple glyph has been loaded, it needs to be processed. */ - /* Usually, this means scaling and hinting through bytecode */ - /* interpretation. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Process_Simple_Glyph + * + * @Description: + * Once a simple glyph has been loaded, it needs to be processed. + * Usually, this means scaling and hinting through bytecode + * interpretation. + */ static FT_Error TT_Process_Simple_Glyph( TT_Loader loader ) { @@ -1071,15 +1084,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Process_Composite_Component */ - /* */ - /* <Description> */ - /* Once a composite component has been loaded, it needs to be */ - /* processed. Usually, this means transforming and translating. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Process_Composite_Component + * + * @Description: + * Once a composite component has been loaded, it needs to be + * processed. Usually, this means transforming and translating. + */ static FT_Error TT_Process_Composite_Component( TT_Loader loader, FT_SubGlyph subglyph, @@ -1153,10 +1166,10 @@ #if 0 - /*******************************************************************/ - /* */ - /* This algorithm is what Apple documents. But it doesn't work. */ - /* */ + /******************************************************************** + * + * This algorithm is what Apple documents. But it doesn't work. + */ int a = subglyph->transform.xx > 0 ? subglyph->transform.xx : -subglyph->transform.xx; int b = subglyph->transform.yx > 0 ? subglyph->transform.yx @@ -1178,10 +1191,10 @@ #else /* 1 */ - /*******************************************************************/ - /* */ - /* This algorithm is a guess and works much better than the above. */ - /* */ + /******************************************************************** + * + * This algorithm is a guess and works much better than the above. + */ FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx, subglyph->transform.xy ); FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy, @@ -1239,16 +1252,16 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Process_Composite_Glyph */ - /* */ - /* <Description> */ - /* This is slightly different from TT_Process_Simple_Glyph, in that */ - /* its sole purpose is to hint the glyph. Thus this function is */ - /* only available when bytecode interpreter is enabled. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Process_Composite_Glyph + * + * @Description: + * This is slightly different from TT_Process_Simple_Glyph, in that + * its sole purpose is to hint the glyph. Thus this function is + * only available when bytecode interpreter is enabled. + */ static FT_Error TT_Process_Composite_Glyph( TT_Loader loader, FT_UInt start_point, @@ -1460,7 +1473,7 @@ } #endif - use_aw_2 = (FT_Bool)( subpixel_hinting && grayscale ); + use_aw_2 = FT_BOOL( subpixel_hinting && grayscale ); loader->pp1.x = loader->bbox.xMin - loader->left_bearing; loader->pp1.y = 0; @@ -1497,27 +1510,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* load_truetype_glyph */ - /* */ - /* <Description> */ - /* Loads a given truetype glyph. Handles composites and uses a */ - /* TT_Loader object. */ - /* */ + /************************************************************************** + * + * @Function: + * load_truetype_glyph + * + * @Description: + * Loads a given truetype glyph. Handles composites and uses a + * TT_Loader object. + */ static FT_Error load_truetype_glyph( TT_Loader loader, FT_UInt glyph_index, FT_UInt recurse_count, FT_Bool header_only ) { - FT_Error error = FT_Err_Ok; + FT_Error error = FT_Err_Ok; FT_Fixed x_scale, y_scale; FT_ULong offset; - TT_Face face = loader->face; - FT_GlyphLoader gloader = loader->gloader; - FT_Bool opened_frame = 0; + TT_Face face = loader->face; + FT_GlyphLoader gloader = loader->gloader; + + FT_Bool opened_frame = 0; #ifdef FT_CONFIG_OPTION_INCREMENTAL FT_StreamRec inc_stream; @@ -1550,15 +1564,15 @@ loader->glyph_index = glyph_index; - if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) + if ( loader->load_flags & FT_LOAD_NO_SCALE ) { - x_scale = loader->size->metrics->x_scale; - y_scale = loader->size->metrics->y_scale; + x_scale = 0x10000L; + y_scale = 0x10000L; } else { - x_scale = 0x10000L; - y_scale = 0x10000L; + x_scale = loader->size->metrics->x_scale; + y_scale = loader->size->metrics->y_scale; } /* Set `offset' to the start of the glyph relative to the start of */ @@ -1617,38 +1631,36 @@ if ( error ) goto Exit; - opened_frame = 1; - /* read glyph header first */ error = face->read_glyph_header( loader ); - if ( error ) - goto Exit; - /* the metrics must be computed after loading the glyph header */ - /* since we need the glyph's `yMax' value in case the vertical */ - /* metrics must be emulated */ - error = tt_get_metrics( loader, glyph_index ); - if ( error ) - goto Exit; + face->forget_glyph_frame( loader ); - if ( header_only ) + if ( error ) goto Exit; } + /* a space glyph */ if ( loader->byte_len == 0 || loader->n_contours == 0 ) { loader->bbox.xMin = 0; loader->bbox.xMax = 0; loader->bbox.yMin = 0; loader->bbox.yMax = 0; + } - error = tt_get_metrics( loader, glyph_index ); - if ( error ) - goto Exit; + /* the metrics must be computed after loading the glyph header */ + /* since we need the glyph's `yMax' value in case the vertical */ + /* metrics must be emulated */ + error = tt_get_metrics( loader, glyph_index ); + if ( error ) + goto Exit; - if ( header_only ) - goto Exit; + if ( header_only ) + goto Exit; + if ( loader->byte_len == 0 || loader->n_contours == 0 ) + { /* must initialize points before (possibly) overriding */ /* glyph metrics from the incremental interface */ tt_loader_set_pp( loader ); @@ -1704,7 +1716,6 @@ loader->pp4.x = points[3].x; loader->pp4.y = points[3].y; - /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) @@ -1745,6 +1756,16 @@ /***********************************************************************/ /***********************************************************************/ + /* we now open a frame again, right after the glyph header */ + /* (which consists of 10 bytes) */ + error = face->access_glyph_frame( loader, glyph_index, + face->glyf_offset + offset + 10, + (FT_UInt)loader->byte_len - 10 ); + if ( error ) + goto Exit; + + opened_frame = 1; + /* if it is a simple glyph, load it */ if ( loader->n_contours > 0 ) @@ -1790,7 +1811,6 @@ * pointers with a width of at least 32 bits. */ - /* clear the nodes filled by sibling chains */ node = ft_list_get_node_at( &loader->composites, recurse_count ); for ( node2 = node; node2; node2 = node2->next ) @@ -2002,7 +2022,7 @@ FT_Int linear_vadvance; - /* Each time we call load_truetype_glyph in this loop, the */ + /* Each time we call `load_truetype_glyph' in this loop, the */ /* value of `gloader.base.subglyphs' can change due to table */ /* reallocations. We thus need to recompute the subglyph */ /* pointer on each iteration. */ @@ -2045,12 +2065,14 @@ if ( num_points == num_base_points ) continue; - /* gloader->base.outline consists of three parts: */ - /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */ - /* */ - /* (1): exists from the beginning */ - /* (2): components that have been loaded so far */ - /* (3): the newly loaded component */ + /* gloader->base.outline consists of three parts: */ + /* */ + /* 0 ----> start_point ----> num_base_points ----> n_points */ + /* (1) (2) (3) */ + /* */ + /* (1) points that exist from the beginning */ + /* (2) component points that have been loaded so far */ + /* (3) points of the newly loaded component */ error = TT_Process_Composite_Component( loader, subglyph, start_point, @@ -2132,7 +2154,7 @@ glyph->metrics.horiBearingX = bbox.xMin; glyph->metrics.horiBearingY = bbox.yMax; - glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; + glyph->metrics.horiAdvance = SUB_LONG(loader->pp2.x, loader->pp1.x); /* Adjust advance width to the value contained in the hdmx table */ /* unless FT_LOAD_COMPUTE_METRICS is set or backward compatibility */ @@ -2276,13 +2298,13 @@ /* XXX: for now, we have no better algorithm for the lsb, but it */ /* should work fine. */ /* */ - glyph->metrics.vertBearingX = glyph->metrics.horiBearingX - - glyph->metrics.horiAdvance / 2; + glyph->metrics.vertBearingX = SUB_LONG( glyph->metrics.horiBearingX, + glyph->metrics.horiAdvance / 2 ); glyph->metrics.vertBearingY = top; glyph->metrics.vertAdvance = advance; } - return 0; + return FT_Err_Ok; } @@ -2656,33 +2678,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Load_Glyph */ - /* */ - /* <Description> */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size. */ - /* */ - /* <Input> */ - /* glyph :: A handle to a target slot object where the glyph */ - /* will be loaded. */ - /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled/loaded. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Load_Glyph + * + * @Description: + * A function used to load a single glyph within a given glyph slot, + * for a given size. + * + * @Input: + * glyph :: + * A handle to a target slot object where the glyph + * will be loaded. + * + * size :: + * A handle to the source face size at which the glyph + * must be scaled/loaded. + * + * glyph_index :: + * The index of the glyph in the font file. + * + * load_flags :: + * A flag indicating what to load for this glyph. The + * FT_LOAD_XXX constants can be used to control the + * glyph loading process (e.g., whether the outline + * should be scaled, whether to load bitmaps or not, + * whether to hint the outline, etc). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Load_Glyph( TT_Size size, TT_GlyphSlot glyph, diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h index d237cfd2841..f1324bc8621 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttgload.h */ -/* */ -/* TrueType Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttgload.h + * + * TrueType Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTGLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c index 29ab2a4efdd..020918f5336 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* ttgxvar.c */ -/* */ -/* TrueType GX Font Variation loader */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html */ - /* */ - /* The documentation for `gvar' is not intelligible; `cvar' refers you */ - /* to `gvar' and is thus also incomprehensible. */ - /* */ - /* The documentation for `avar' appears correct, but Apple has no fonts */ - /* with an `avar' table, so it is hard to test. */ - /* */ - /* Many thanks to John Jenkins (at Apple) in figuring this out. */ - /* */ - /* */ - /* Apple's `kern' table has some references to tuple indices, but as */ - /* there is no indication where these indices are defined, nor how to */ - /* interpolate the kerning values (different tuples have different */ - /* classes) this issue is ignored. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ttgxvar.c + * + * TrueType GX Font Variation loader + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * Apple documents the `fvar', `gvar', `cvar', and `avar' tables at + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html + * + * The documentation for `gvar' is not intelligible; `cvar' refers you + * to `gvar' and is thus also incomprehensible. + * + * The documentation for `avar' appears correct, but Apple has no fonts + * with an `avar' table, so it is hard to test. + * + * Many thanks to John Jenkins (at Apple) in figuring this out. + * + * + * Apple's `kern' table has some references to tuple indices, but as + * there is no indication where these indices are defined, nor how to + * interpolate the kerning values (different tuples have different + * classes) this issue is ignored. + * + */ #include <ft2build.h> @@ -67,14 +67,23 @@ : (stream)->limit - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /* some macros we need */ +#define FT_fdot14ToFixed( x ) \ + ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) +#define FT_intToFixed( i ) \ + ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) +#define FT_fixedToInt( x ) \ + ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttgxvar +#define FT_COMPONENT ttgxvar /*************************************************************************/ @@ -86,12 +95,12 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It */ - /* indicates that there is a delta for every point without needing to */ - /* enumerate all of them. */ - /* */ + /************************************************************************** + * + * The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It + * indicates that there is a delta for every point without needing to + * enumerate all of them. + */ /* ensure that value `0' has the same width as a pointer */ #define ALL_POINTS (FT_UShort*)~(FT_PtrDist)0 @@ -101,29 +110,32 @@ #define GX_PT_POINT_RUN_COUNT_MASK 0x7FU - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_readpackedpoints */ - /* */ - /* <Description> */ - /* Read a set of points to which the following deltas will apply. */ - /* Points are packed with a run length encoding. */ - /* */ - /* <Input> */ - /* stream :: The data stream. */ - /* */ - /* size :: The size of the table holding the data. */ - /* */ - /* <Output> */ - /* point_cnt :: The number of points read. A zero value means that */ - /* all points in the glyph will be affected, without */ - /* enumerating them individually. */ - /* */ - /* <Return> */ - /* An array of FT_UShort containing the affected points or the */ - /* special value ALL_POINTS. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_readpackedpoints + * + * @Description: + * Read a set of points to which the following deltas will apply. + * Points are packed with a run length encoding. + * + * @Input: + * stream :: + * The data stream. + * + * size :: + * The size of the table holding the data. + * + * @Output: + * point_cnt :: + * The number of points read. A zero value means that + * all points in the glyph will be affected, without + * enumerating them individually. + * + * @Return: + * An array of FT_UShort containing the affected points or the + * special value ALL_POINTS. + */ static FT_UShort* ft_var_readpackedpoints( FT_Stream stream, FT_ULong size, @@ -211,34 +223,41 @@ #define GX_DT_DELTA_RUN_COUNT_MASK 0x3FU - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_readpackeddeltas */ - /* */ - /* <Description> */ - /* Read a set of deltas. These are packed slightly differently than */ - /* points. In particular there is no overall count. */ - /* */ - /* <Input> */ - /* stream :: The data stream. */ - /* */ - /* size :: The size of the table holding the data. */ - /* */ - /* delta_cnt :: The number of deltas to be read. */ - /* */ - /* <Return> */ - /* An array of FT_Short containing the deltas for the affected */ - /* points. (This only gets the deltas for one dimension. It will */ - /* generally be called twice, once for x, once for y. When used in */ - /* cvt table, it will only be called once.) */ - /* */ - static FT_Short* + /************************************************************************** + * + * @Function: + * ft_var_readpackeddeltas + * + * @Description: + * Read a set of deltas. These are packed slightly differently than + * points. In particular there is no overall count. + * + * @Input: + * stream :: + * The data stream. + * + * size :: + * The size of the table holding the data. + * + * delta_cnt :: + * The number of deltas to be read. + * + * @Return: + * An array of FT_Fixed containing the deltas for the affected + * points. (This only gets the deltas for one dimension. It will + * generally be called twice, once for x, once for y. When used in + * cvt table, it will only be called once.) + * + * We use FT_Fixed to avoid accumulation errors while summing up all + * deltas (the rounding to integer values happens as the very last + * step). + */ + static FT_Fixed* ft_var_readpackeddeltas( FT_Stream stream, FT_ULong size, FT_UInt delta_cnt ) { - FT_Short *deltas = NULL; + FT_Fixed *deltas = NULL; FT_UInt runcnt, cnt; FT_UInt i, j; FT_Memory memory = stream->memory; @@ -272,13 +291,13 @@ { /* `runcnt' shorts from the stack */ for ( j = 0; j <= cnt && i < delta_cnt; j++ ) - deltas[i++] = FT_GET_SHORT(); + deltas[i++] = FT_intToFixed( FT_GET_SHORT() ); } else { /* `runcnt' signed bytes from the stack */ for ( j = 0; j <= cnt && i < delta_cnt; j++ ) - deltas[i++] = FT_GET_CHAR(); + deltas[i++] = FT_intToFixed( FT_GET_CHAR() ); } if ( j <= cnt ) @@ -293,18 +312,19 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_avar */ - /* */ - /* <Description> */ - /* Parse the `avar' table if present. It need not be, so we return */ - /* nothing. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_avar + * + * @Description: + * Parse the `avar' table if present. It need not be, so we return + * nothing. + * + * @InOut: + * face :: + * The font face. + */ static void ft_var_load_avar( TT_Face face ) { @@ -394,17 +414,6 @@ } - /* some macros we need */ -#define FT_FIXED_ONE ( (FT_Fixed)0x10000 ) - -#define FT_fdot14ToFixed( x ) \ - ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) -#define FT_intToFixed( i ) \ - ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) -#define FT_fixedToInt( x ) \ - ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) - - static FT_Error ft_var_load_item_variation_store( TT_Face face, FT_ULong offset, @@ -702,29 +711,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_hvvar */ - /* */ - /* <Description> */ - /* If `vertical' is zero, parse the `HVAR' table and set */ - /* `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked' */ - /* is set to TRUE. */ - /* */ - /* If `vertical' is not zero, parse the `VVAR' table and set */ - /* `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked' */ - /* is set to TRUE. */ - /* */ - /* Some memory may remain allocated on error; it is always freed in */ - /* `tt_done_blend', however. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_hvvar + * + * @Description: + * If `vertical' is zero, parse the `HVAR' table and set + * `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked' + * is set to TRUE. + * + * If `vertical' is not zero, parse the `VVAR' table and set + * `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked' + * is set to TRUE. + * + * Some memory may remain allocated on error; it is always freed in + * `tt_done_blend', however. + * + * @InOut: + * face :: + * The font face. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error ft_var_load_hvvar( TT_Face face, FT_Bool vertical ) @@ -872,7 +882,7 @@ /* outer loop steps through master designs to be blended */ for ( master = 0; master < varData->regionIdxCount; master++ ) { - FT_Fixed scalar = FT_FIXED_ONE; + FT_Fixed scalar = 0x10000L; FT_UInt regionIndex = varData->regionIndices[master]; GX_AxisCoords axis = itemStore->varRegionList[regionIndex].axisList; @@ -881,47 +891,43 @@ /* inner loop steps through axes in this region */ for ( j = 0; j < itemStore->axisCount; j++, axis++ ) { - FT_Fixed axisScalar; - - /* compute the scalar contribution of this axis; */ /* ignore invalid ranges */ if ( axis->startCoord > axis->peakCoord || axis->peakCoord > axis->endCoord ) - axisScalar = FT_FIXED_ONE; + continue; else if ( axis->startCoord < 0 && axis->endCoord > 0 && axis->peakCoord != 0 ) - axisScalar = FT_FIXED_ONE; + continue; /* peak of 0 means ignore this axis */ else if ( axis->peakCoord == 0 ) - axisScalar = FT_FIXED_ONE; + continue; - /* ignore this region if coords are out of range */ - else if ( face->blend->normalizedcoords[j] < axis->startCoord || - face->blend->normalizedcoords[j] > axis->endCoord ) - axisScalar = 0; + else if ( face->blend->normalizedcoords[j] == axis->peakCoord ) + continue; - /* calculate a proportional factor */ - else + /* ignore this region if coords are out of range */ + else if ( face->blend->normalizedcoords[j] <= axis->startCoord || + face->blend->normalizedcoords[j] >= axis->endCoord ) { - if ( face->blend->normalizedcoords[j] == axis->peakCoord ) - axisScalar = FT_FIXED_ONE; - else if ( face->blend->normalizedcoords[j] < axis->peakCoord ) - axisScalar = - FT_DivFix( face->blend->normalizedcoords[j] - axis->startCoord, - axis->peakCoord - axis->startCoord ); - else - axisScalar = - FT_DivFix( axis->endCoord - face->blend->normalizedcoords[j], - axis->endCoord - axis->peakCoord ); + scalar = 0; + break; } - /* take product of all the axis scalars */ - scalar = FT_MulFix( scalar, axisScalar ); - + /* cumulative product of all the axis scalars */ + else if ( face->blend->normalizedcoords[j] < axis->peakCoord ) + scalar = + FT_MulDiv( scalar, + face->blend->normalizedcoords[j] - axis->startCoord, + axis->peakCoord - axis->startCoord ); + else + scalar = + FT_MulDiv( scalar, + axis->endCoord - face->blend->normalizedcoords[j], + axis->endCoord - axis->peakCoord ); } /* per-axis loop */ /* get the scaled delta for this region */ @@ -937,25 +943,29 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_hvadvance_adjust */ - /* */ - /* <Description> */ - /* Apply `HVAR' advance width or `VVAR' advance height adjustment of */ - /* a given glyph. */ - /* */ - /* <Input> */ - /* gindex :: The glyph index. */ - /* */ - /* vertical :: If set, handle `VVAR' table. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* adelta :: Points to width or height value that gets modified. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_hvadvance_adjust + * + * @Description: + * Apply `HVAR' advance width or `VVAR' advance height adjustment of + * a given glyph. + * + * @Input: + * gindex :: + * The glyph index. + * + * vertical :: + * If set, handle `VVAR' table. + * + * @InOut: + * face :: + * The font face. + * + * adelta :: + * Points to width or height value that gets modified. + */ static FT_Error tt_hvadvance_adjust( TT_Face face, FT_UInt gindex, @@ -1151,20 +1161,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_mvar */ - /* */ - /* <Description> */ - /* Parse the `MVAR' table. */ - /* */ - /* Some memory may remain allocated on error; it is always freed in */ - /* `tt_done_blend', however. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_mvar + * + * @Description: + * Parse the `MVAR' table. + * + * Some memory may remain allocated on error; it is always freed in + * `tt_done_blend', however. + * + * @InOut: + * face :: + * The font face. + */ static void ft_var_load_mvar( TT_Face face ) { @@ -1297,22 +1308,26 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_apply_mvar */ - /* */ - /* <Description> */ - /* Apply `MVAR' table adjustments. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_apply_mvar + * + * @Description: + * Apply `MVAR' table adjustments. + * + * @InOut: + * face :: + * The font face. + */ FT_LOCAL_DEF( void ) tt_apply_mvar( TT_Face face ) { GX_Blend blend = face->blend; GX_Value value, limit; + FT_Short mvar_hasc_delta = 0; + FT_Short mvar_hdsc_delta = 0; + FT_Short mvar_hlgp_delta = 0; if ( !( face->variation_support & TT_FACE_FLAG_VAR_MVAR ) ) @@ -1347,6 +1362,14 @@ /* since we handle both signed and unsigned values as FT_Short, */ /* ensure proper overflow arithmetic */ *p = (FT_Short)( value->unmodified + (FT_Short)delta ); + + /* Treat hasc, hdsc and hlgp specially, see below. */ + if ( value->tag == MVAR_TAG_HASC ) + mvar_hasc_delta = (FT_Short)delta; + else if ( value->tag == MVAR_TAG_HDSC ) + mvar_hdsc_delta = (FT_Short)delta; + else if ( value->tag == MVAR_TAG_HLGP ) + mvar_hlgp_delta = (FT_Short)delta; } } @@ -1354,25 +1377,40 @@ { FT_Face root = &face->root; - - if ( face->os2.version != 0xFFFFU ) - { - if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) - { - root->ascender = face->os2.sTypoAscender; - root->descender = face->os2.sTypoDescender; - - root->height = root->ascender - root->descender + - face->os2.sTypoLineGap; - } - else - { - root->ascender = (FT_Short)face->os2.usWinAscent; - root->descender = -(FT_Short)face->os2.usWinDescent; - - root->height = root->ascender - root->descender; - } - } + /* + * Apply the deltas of hasc, hdsc and hlgp to the FT_Face's ascender, + * descender and height attributes, no matter how they were originally + * computed. + * + * (Code that ignores those and accesses the font's metrics values + * directly is already served by the delta application code above.) + * + * The MVAR table supports variations for both typo and win metrics. + * According to Behdad Esfahbod, the thinking of the working group was + * that no one uses win metrics anymore for setting line metrics (the + * specification even calls these metrics "horizontal clipping + * ascent/descent", probably for their role on the Windows platform in + * computing clipping boxes), and new fonts should use typo metrics, so + * typo deltas should be applied to whatever sfnt_load_face decided the + * line metrics should be. + * + * Before, the following led to different line metrics between default + * outline and instances, visible when e.g. the default outlines were + * used as the regular face and instances for everything else: + * + * 1. sfnt_load_face applied the hhea metrics by default. + * 2. This code later applied the typo metrics by default, regardless of + * whether they were actually changed or the font had the OS/2 table's + * fsSelection's bit 7 (USE_TYPO_METRICS) set. + */ + FT_Short current_line_gap = root->height - root->ascender + + root->descender; + + + root->ascender = root->ascender + mvar_hasc_delta; + root->descender = root->descender + mvar_hdsc_delta; + root->height = root->ascender - root->descender + + current_line_gap + mvar_hlgp_delta; root->underline_position = face->postscript.underlinePosition - face->postscript.underlineThickness / 2; @@ -1400,21 +1438,22 @@ } GX_GVar_Head; - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_gvar */ - /* */ - /* <Description> */ - /* Parse the `gvar' table if present. If `fvar' is there, `gvar' had */ - /* better be there too. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_gvar + * + * @Description: + * Parse the `gvar' table if present. If `fvar' is there, `gvar' had + * better be there too. + * + * @InOut: + * face :: + * The font face. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error ft_var_load_gvar( TT_Face face ) { @@ -1512,28 +1551,55 @@ if ( gvar_head.flags & 1 ) { + FT_ULong limit = gvar_start + table_len; + + /* long offsets (one more offset than glyphs, to mark size of last) */ if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) ) goto Exit; for ( i = 0; i <= blend->gv_glyphcnt; i++ ) + { blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG(); - - FT_FRAME_EXIT(); + /* use `>', not `>=' */ + if ( blend->glyphoffsets[i] > limit ) + { + FT_TRACE2(( "ft_var_load_gvar:" + " invalid glyph variation data offset for index %d\n", + i )); + error = FT_THROW( Invalid_Table ); + break; + } + } } else { + FT_ULong limit = gvar_start + table_len; + + /* short offsets (one more offset than glyphs, to mark size of last) */ if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) ) goto Exit; for ( i = 0; i <= blend->gv_glyphcnt; i++ ) + { blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2; - /* XXX: Undocumented: `*2'! */ - - FT_FRAME_EXIT(); + /* use `>', not `>=' */ + if ( blend->glyphoffsets[i] > limit ) + { + FT_TRACE2(( "ft_var_load_gvar:" + " invalid glyph variation data offset for index %d\n", + i )); + error = FT_THROW( Invalid_Table ); + break; + } + } } + FT_FRAME_EXIT(); + if ( error ) + goto Exit; + if ( blend->tuplecount != 0 ) { if ( FT_NEW_ARRAY( blend->tuplecoords, @@ -1567,33 +1633,38 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_apply_tuple */ - /* */ - /* <Description> */ - /* Figure out whether a given tuple (design) applies to the current */ - /* blend, and if so, what is the scaling factor. */ - /* */ - /* <Input> */ - /* blend :: The current blend of the font. */ - /* */ - /* tupleIndex :: A flag saying whether this is an intermediate */ - /* tuple or not. */ - /* */ - /* tuple_coords :: The coordinates of the tuple in normalized axis */ - /* units. */ - /* */ - /* im_start_coords :: The initial coordinates where this tuple starts */ - /* to apply (for intermediate coordinates). */ - /* */ - /* im_end_coords :: The final coordinates after which this tuple no */ - /* longer applies (for intermediate coordinates). */ - /* */ - /* <Return> */ - /* An FT_Fixed value containing the scaling factor. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_apply_tuple + * + * @Description: + * Figure out whether a given tuple (design) applies to the current + * blend, and if so, what is the scaling factor. + * + * @Input: + * blend :: + * The current blend of the font. + * + * tupleIndex :: + * A flag saying whether this is an intermediate + * tuple or not. + * + * tuple_coords :: + * The coordinates of the tuple in normalized axis + * units. + * + * im_start_coords :: + * The initial coordinates where this tuple starts + * to apply (for intermediate coordinates). + * + * im_end_coords :: + * The final coordinates after which this tuple no + * longer applies (for intermediate coordinates). + * + * @Return: + * An FT_Fixed value containing the scaling factor. + */ static FT_Fixed ft_var_apply_tuple( GX_Blend blend, FT_UShort tupleIndex, @@ -1607,13 +1678,8 @@ for ( i = 0; i < blend->num_axis; i++ ) { - FT_TRACE6(( " axis coordinate %d (%.5f):\n", + FT_TRACE6(( " axis %d coordinate %.5f:\n", i, blend->normalizedcoords[i] / 65536.0 )); - if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) ) - FT_TRACE6(( " intermediate coordinates %d (%.5f, %.5f):\n", - i, - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); /* It's not clear why (for intermediate tuples) we don't need */ /* to check against start/end -- the documentation says we don't. */ @@ -1622,7 +1688,7 @@ if ( tuple_coords[i] == 0 ) { - FT_TRACE6(( " tuple coordinate is zero, ignored\n", i )); + FT_TRACE6(( " tuple coordinate is zero, ignore\n", i )); continue; } @@ -1635,7 +1701,7 @@ if ( blend->normalizedcoords[i] == tuple_coords[i] ) { - FT_TRACE6(( " tuple coordinate value %.5f fits perfectly\n", + FT_TRACE6(( " tuple coordinate %.5f fits perfectly\n", tuple_coords[i] / 65536.0 )); /* `apply' does not change */ continue; @@ -1648,13 +1714,13 @@ if ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) || blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) ) { - FT_TRACE6(( " tuple coordinate value %.5f is exceeded, stop\n", + FT_TRACE6(( " tuple coordinate %.5f is exceeded, stop\n", tuple_coords[i] / 65536.0 )); apply = 0; break; } - FT_TRACE6(( " tuple coordinate value %.5f fits\n", + FT_TRACE6(( " tuple coordinate %.5f fits\n", tuple_coords[i] / 65536.0 )); apply = FT_MulDiv( apply, blend->normalizedcoords[i], @@ -1664,10 +1730,10 @@ { /* intermediate tuple */ - if ( blend->normalizedcoords[i] < im_start_coords[i] || - blend->normalizedcoords[i] > im_end_coords[i] ) + if ( blend->normalizedcoords[i] <= im_start_coords[i] || + blend->normalizedcoords[i] >= im_end_coords[i] ) { - FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] is exceeded," + FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ is exceeded," " stop\n", im_start_coords[i] / 65536.0, im_end_coords[i] / 65536.0 )); @@ -1675,25 +1741,17 @@ break; } - else if ( blend->normalizedcoords[i] < tuple_coords[i] ) - { - FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); + FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ fits\n", + im_start_coords[i] / 65536.0, + im_end_coords[i] / 65536.0 )); + if ( blend->normalizedcoords[i] < tuple_coords[i] ) apply = FT_MulDiv( apply, blend->normalizedcoords[i] - im_start_coords[i], tuple_coords[i] - im_start_coords[i] ); - } - else - { - FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); apply = FT_MulDiv( apply, im_end_coords[i] - blend->normalizedcoords[i], im_end_coords[i] - tuple_coords[i] ); - } } } @@ -1756,11 +1814,11 @@ } if ( coord < a->def ) - normalized[i] = -FT_DivFix( coord - a->def, - a->minimum - a->def ); + normalized[i] = -FT_DivFix( SUB_LONG( coord, a->def ), + SUB_LONG( a->minimum, a->def ) ); else if ( coord > a->def ) - normalized[i] = FT_DivFix( coord - a->def, - a->maximum - a->def ); + normalized[i] = FT_DivFix( SUB_LONG( coord, a->def ), + SUB_LONG( a->maximum, a->def ) ); else normalized[i] = 0; } @@ -1910,27 +1968,29 @@ } GX_FVar_Axis; - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Get_MM_Var */ - /* */ - /* <Description> */ - /* Check that the font's `fvar' table is valid, parse it, and return */ - /* those data. It also loads (and parses) the `MVAR' table, if */ - /* possible. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* TT_Get_MM_Var initializes the blend structure. */ - /* */ - /* <Output> */ - /* master :: The `fvar' data (must be freed by caller). Can be NULL, */ - /* which makes this function simply load MM support. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Get_MM_Var + * + * @Description: + * Check that the font's `fvar' table is valid, parse it, and return + * those data. It also loads (and parses) the `MVAR' table, if + * possible. + * + * @InOut: + * face :: + * The font face. + * TT_Get_MM_Var initializes the blend structure. + * + * @Output: + * master :: + * The `fvar' data (must be freed by caller). Can be NULL, + * which makes this function simply load MM support. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Get_MM_Var( TT_Face face, FT_MM_Var* *master ) @@ -2507,11 +2567,14 @@ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ) { - FT_UInt idx = (FT_UInt)face->root.face_index >> 16; + FT_UInt instance_index = (FT_UInt)face->root.face_index >> 16; c = blend->normalizedcoords + i; - n = blend->normalized_stylecoords + idx * mmvar->num_axis + i; + n = blend->normalized_stylecoords + + ( instance_index - 1 ) * mmvar->num_axis + + i; + for ( j = i; j < mmvar->num_axis; j++, n++, c++ ) if ( *c != *n ) have_diff = 1; @@ -2526,7 +2589,11 @@ /* return value -1 indicates `no change' */ if ( !have_diff ) + { + face->doblend = TRUE; + return -1; + } for ( ; i < mmvar->num_axis; i++ ) { @@ -2590,31 +2657,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_MM_Blend */ - /* */ - /* <Description> */ - /* Set the blend (normalized) coordinates for this instance of the */ - /* font. Check that the `gvar' table is reasonable and does some */ - /* initial preparation. */ - /* */ - /* <InOut> */ - /* face :: The font. */ - /* Initialize the blend structure with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use the default value (0) for the remaining axes. */ - /* */ - /* coords :: An array of `num_coords', each between [-1,1]. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_MM_Blend + * + * @Description: + * Set the blend (normalized) coordinates for this instance of the + * font. Check that the `gvar' table is reasonable and does some + * initial preparation. + * + * @InOut: + * face :: + * The font. + * Initialize the blend structure with `gvar' data. + * + * @Input: + * num_coords :: + * The number of available coordinates. If it is + * larger than the number of axes, ignore the excess + * values. If it is smaller than the number of axes, + * use the default value (0) for the remaining axes. + * + * coords :: + * An array of `num_coords', each between [-1,1]. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Set_MM_Blend( TT_Face face, FT_UInt num_coords, @@ -2636,29 +2706,32 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Get_MM_Blend */ - /* */ - /* <Description> */ - /* Get the blend (normalized) coordinates for this instance of the */ - /* font. */ - /* */ - /* <InOut> */ - /* face :: The font. */ - /* Initialize the blend structure with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, set the excess */ - /* values to 0. */ - /* */ - /* coords :: An array of `num_coords', each between [-1,1]. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Get_MM_Blend + * + * @Description: + * Get the blend (normalized) coordinates for this instance of the + * font. + * + * @InOut: + * face :: + * The font. + * Initialize the blend structure with `gvar' data. + * + * @Input: + * num_coords :: + * The number of available coordinates. If it is + * larger than the number of axes, set the excess + * values to 0. + * + * coords :: + * An array of `num_coords', each between [-1,1]. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Get_MM_Blend( TT_Face face, FT_UInt num_coords, @@ -2712,31 +2785,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_Var_Design */ - /* */ - /* <Description> */ - /* Set the coordinates for the instance, measured in the user */ - /* coordinate system. Parse the `avar' table (if present) to convert */ - /* from user to normalized coordinates. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* Initialize the blend struct with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use the default values for the remaining axes. */ - /* */ - /* coords :: A coordinate array with `num_coords' elements. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_Var_Design + * + * @Description: + * Set the coordinates for the instance, measured in the user + * coordinate system. Parse the `avar' table (if present) to convert + * from user to normalized coordinates. + * + * @InOut: + * face :: + * The font face. + * Initialize the blend struct with `gvar' data. + * + * @Input: + * num_coords :: + * The number of available coordinates. If it is + * larger than the number of axes, ignore the excess + * values. If it is smaller than the number of axes, + * use the default values for the remaining axes. + * + * coords :: + * A coordinate array with `num_coords' elements. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Set_Var_Design( TT_Face face, FT_UInt num_coords, @@ -2854,28 +2930,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Get_Var_Design */ - /* */ - /* <Description> */ - /* Get the design coordinates of the currently selected interpolated */ - /* font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* num_coords :: The number of design coordinates to retrieve. If it */ - /* is larger than the number of axes, set the excess */ - /* values to~0. */ - /* */ - /* <Output> */ - /* coords :: The design coordinates array. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Get_Var_Design + * + * @Description: + * Get the design coordinates of the currently selected interpolated + * font. + * + * @Input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of design coordinates to retrieve. If it + * is larger than the number of axes, set the excess + * values to~0. + * + * @Output: + * coords :: + * The design coordinates array. + * + * @Return: + * FreeType error code. 0~means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Get_Var_Design( TT_Face face, FT_UInt num_coords, @@ -2929,24 +3008,26 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_Named_Instance */ - /* */ - /* <Description> */ - /* Set the given named instance, also resetting any further */ - /* variation. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* instance_index :: The instance index, starting with value 1. */ - /* Value 0 indicates to not use an instance. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_Named_Instance + * + * @Description: + * Set the given named instance, also resetting any further + * variation. + * + * @Input: + * face :: + * A handle to the source face. + * + * instance_index :: + * The instance index, starting with value 1. + * Value 0 indicates to not use an instance. + * + * @Return: + * FreeType error code. 0~means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Set_Named_Instance( TT_Face face, FT_UInt instance_index ) @@ -3022,48 +3103,60 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_vary_cvt */ - /* */ - /* <Description> */ - /* Modify the loaded cvt table according to the `cvar' table and the */ - /* font's blend. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* Most errors are ignored. It is perfectly valid not to have a */ - /* `cvar' table even if there is a `gvar' and `fvar' table. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_vary_cvt + * + * @Description: + * Modify the loaded cvt table according to the `cvar' table and the + * font's blend. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + * + * Most errors are ignored. It is perfectly valid not to have a + * `cvar' table even if there is a `gvar' and `fvar' table. + */ FT_LOCAL_DEF( FT_Error ) tt_face_vary_cvt( TT_Face face, FT_Stream stream ) { - FT_Error error; - FT_Memory memory = stream->memory; - FT_ULong table_start; - FT_ULong table_len; - FT_UInt tupleCount; - FT_ULong offsetToData; - FT_ULong here; - FT_UInt i, j; - FT_Fixed* tuple_coords = NULL; - FT_Fixed* im_start_coords = NULL; - FT_Fixed* im_end_coords = NULL; - GX_Blend blend = face->blend; - FT_UInt point_count, spoint_count = 0; + FT_Error error; + FT_Memory memory = stream->memory; + + FT_ULong table_start; + FT_ULong table_len; + + FT_UInt tupleCount; + FT_ULong offsetToData; + + FT_ULong here; + FT_UInt i, j; + + FT_Fixed* tuple_coords = NULL; + FT_Fixed* im_start_coords = NULL; + FT_Fixed* im_end_coords = NULL; + + GX_Blend blend = face->blend; + + FT_UInt point_count; + FT_UInt spoint_count = 0; + FT_UShort* sharedpoints = NULL; FT_UShort* localpoints = NULL; FT_UShort* points; - FT_Short* deltas; + + FT_Fixed* deltas = NULL; + FT_Fixed* cvt_deltas = NULL; FT_TRACE2(( "CVAR " )); @@ -3146,11 +3239,14 @@ } FT_TRACE5(( "cvar: there %s %d tuple%s:\n", - ( tupleCount & 0xFFF ) == 1 ? "is" : "are", - tupleCount & 0xFFF, - ( tupleCount & 0xFFF ) == 1 ? "" : "s" )); + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are", + tupleCount & GX_TC_TUPLE_COUNT_MASK, + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" )); + + if ( FT_NEW_ARRAY( cvt_deltas, face->cvt_size ) ) + goto FExit; - for ( i = 0; i < ( tupleCount & 0xFFF ); i++ ) + for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ ) { FT_UInt tupleDataSize; FT_UInt tupleIndex; @@ -3174,13 +3270,25 @@ " invalid tuple index\n" )); error = FT_THROW( Invalid_Table ); - goto Exit; + goto FExit; } else + { + if ( !blend->tuplecoords ) + { + FT_TRACE2(( "tt_face_vary_cvt:" + " no valid tuple coordinates available\n" )); + + error = FT_THROW( Invalid_Table ); + goto FExit; + } + FT_MEM_COPY( tuple_coords, - &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis], + blend->tuplecoords + + ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis, blend->num_axis * sizeof ( FT_Fixed ) ); + } if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) { @@ -3241,17 +3349,21 @@ /* this means that there are deltas for every entry in cvt */ for ( j = 0; j < face->cvt_size; j++ ) { - FT_Long orig_cvt = face->cvt[j]; + FT_Fixed old_cvt_delta; - face->cvt[j] = (FT_Short)( orig_cvt + - FT_MulFix( deltas[j], apply ) ); + old_cvt_delta = cvt_deltas[j]; + cvt_deltas[j] = old_cvt_delta + FT_MulFix( deltas[j], apply ); #ifdef FT_DEBUG_LEVEL_TRACE - if ( orig_cvt != face->cvt[j] ) + if ( old_cvt_delta != cvt_deltas[j] ) { - FT_TRACE7(( " %d: %d -> %d\n", - j, orig_cvt, face->cvt[j] )); + FT_TRACE7(( " %d: %f -> %f\n", + j, + ( FT_intToFixed( face->cvt[j] ) + + old_cvt_delta ) / 65536.0, + ( FT_intToFixed( face->cvt[j] ) + + cvt_deltas[j] ) / 65536.0 )); count++; } #endif @@ -3274,23 +3386,26 @@ for ( j = 0; j < point_count; j++ ) { - int pindex; - FT_Long orig_cvt; + int pindex; + FT_Fixed old_cvt_delta; pindex = points[j]; if ( (FT_ULong)pindex >= face->cvt_size ) continue; - orig_cvt = face->cvt[pindex]; - face->cvt[pindex] = (FT_Short)( orig_cvt + - FT_MulFix( deltas[j], apply ) ); + old_cvt_delta = cvt_deltas[pindex]; + cvt_deltas[pindex] = old_cvt_delta + FT_MulFix( deltas[j], apply ); #ifdef FT_DEBUG_LEVEL_TRACE - if ( orig_cvt != face->cvt[pindex] ) + if ( old_cvt_delta != cvt_deltas[pindex] ) { - FT_TRACE7(( " %d: %d -> %d\n", - pindex, orig_cvt, face->cvt[pindex] )); + FT_TRACE7(( " %d: %f -> %f\n", + pindex, + ( FT_intToFixed( face->cvt[pindex] ) + + old_cvt_delta ) / 65536.0, + ( FT_intToFixed( face->cvt[pindex] ) + + cvt_deltas[pindex] ) / 65536.0 )); count++; } #endif @@ -3313,6 +3428,9 @@ FT_TRACE5(( "\n" )); + for ( i = 0; i < face->cvt_size; i++ ) + face->cvt[i] += FT_fixedToInt( cvt_deltas[i] ); + FExit: FT_FRAME_EXIT(); @@ -3322,6 +3440,7 @@ FT_FREE( tuple_coords ); FT_FREE( im_start_coords ); FT_FREE( im_end_coords ); + FT_FREE( cvt_deltas ); return error; } @@ -3367,9 +3486,8 @@ /* between `p1' and `p2', using `ref1' and `ref2' as the reference */ /* point indices. */ - /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */ - /* `Ins_IUP' */ - + /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */ + /* `Ins_IUP' with spec differences in handling ill-defined cases. */ static void tt_delta_interpolate( int p1, int p2, @@ -3528,56 +3646,72 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Vary_Apply_Glyph_Deltas */ - /* */ - /* <Description> */ - /* Apply the appropriate deltas to the current glyph. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* glyph_index :: The index of the glyph being modified. */ - /* */ - /* n_points :: The number of the points in the glyph, including */ - /* phantom points. */ - /* */ - /* <InOut> */ - /* outline :: The outline to change. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Vary_Apply_Glyph_Deltas + * + * @Description: + * Apply the appropriate deltas to the current glyph. + * + * @Input: + * face :: + * A handle to the target face object. + * + * glyph_index :: + * The index of the glyph being modified. + * + * n_points :: + * The number of the points in the glyph, including + * phantom points. + * + * @InOut: + * outline :: + * The outline to change. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Vary_Apply_Glyph_Deltas( TT_Face face, FT_UInt glyph_index, FT_Outline* outline, FT_UInt n_points ) { - FT_Stream stream = face->root.stream; - FT_Memory memory = stream->memory; - GX_Blend blend = face->blend; + FT_Error error; + FT_Stream stream = face->root.stream; + FT_Memory memory = stream->memory; - FT_Vector* points_org = NULL; - FT_Vector* points_out = NULL; + FT_Vector* points_org = NULL; /* coordinates in 16.16 format */ + FT_Vector* points_out = NULL; /* coordinates in 16.16 format */ FT_Bool* has_delta = NULL; - FT_Error error; - FT_ULong glyph_start; - FT_UInt tupleCount; - FT_ULong offsetToData; - FT_ULong here; - FT_UInt i, j; - FT_Fixed* tuple_coords = NULL; - FT_Fixed* im_start_coords = NULL; - FT_Fixed* im_end_coords = NULL; - FT_UInt point_count, spoint_count = 0; + FT_ULong glyph_start; + + FT_UInt tupleCount; + FT_ULong offsetToData; + FT_ULong dataSize; + + FT_ULong here; + FT_UInt i, j; + + FT_Fixed* tuple_coords = NULL; + FT_Fixed* im_start_coords = NULL; + FT_Fixed* im_end_coords = NULL; + + GX_Blend blend = face->blend; + + FT_UInt point_count; + FT_UInt spoint_count = 0; + FT_UShort* sharedpoints = NULL; FT_UShort* localpoints = NULL; FT_UShort* points; - FT_Short *deltas_x, *deltas_y; + + FT_Fixed* deltas_x = NULL; + FT_Fixed* deltas_y = NULL; + FT_Fixed* point_deltas_x = NULL; + FT_Fixed* point_deltas_y = NULL; if ( !face->doblend || !blend ) @@ -3597,9 +3731,11 @@ FT_NEW_ARRAY( has_delta, n_points ) ) goto Fail1; - if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) || - FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] - - blend->glyphoffsets[glyph_index] ) ) + dataSize = blend->glyphoffsets[glyph_index + 1] - + blend->glyphoffsets[glyph_index]; + + if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) || + FT_FRAME_ENTER( dataSize ) ) goto Fail1; glyph_start = FT_Stream_FTell( stream ); @@ -3615,8 +3751,8 @@ offsetToData = FT_GET_USHORT(); /* rough sanity test */ - if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > - blend->gvar_size ) + if ( offsetToData > dataSize || + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > dataSize ) { FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:" " invalid glyph variation array header\n" )); @@ -3646,8 +3782,15 @@ tupleCount & GX_TC_TUPLE_COUNT_MASK, ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" )); + if ( FT_NEW_ARRAY( point_deltas_x, n_points ) || + FT_NEW_ARRAY( point_deltas_y, n_points ) ) + goto Fail3; + for ( j = 0; j < n_points; j++ ) - points_org[j] = outline->points[j]; + { + points_org[j].x = FT_intToFixed( outline->points[j].x ); + points_org[j].y = FT_intToFixed( outline->points[j].y ); + } for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ ) { @@ -3673,12 +3816,13 @@ " invalid tuple index\n" )); error = FT_THROW( Invalid_Table ); - goto Fail2; + goto Fail3; } else FT_MEM_COPY( tuple_coords, - &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis], + blend->tuplecoords + + ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis, blend->num_axis * sizeof ( FT_Fixed ) ); if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) @@ -3742,14 +3886,17 @@ /* this means that there are deltas for every point in the glyph */ for ( j = 0; j < n_points; j++ ) { - FT_Pos delta_x = FT_MulFix( deltas_x[j], apply ); - FT_Pos delta_y = FT_MulFix( deltas_y[j], apply ); + FT_Fixed old_point_delta_x = point_deltas_x[j]; + FT_Fixed old_point_delta_y = point_deltas_y[j]; + + FT_Fixed point_delta_x = FT_MulFix( deltas_x[j], apply ); + FT_Fixed point_delta_y = FT_MulFix( deltas_y[j], apply ); if ( j < n_points - 4 ) { - outline->points[j].x += delta_x; - outline->points[j].y += delta_y; + point_deltas_x[j] = old_point_delta_x + point_delta_x; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } else { @@ -3759,33 +3906,37 @@ if ( j == ( n_points - 4 ) && !( face->variation_support & TT_FACE_FLAG_VAR_LSB ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 3 ) && !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 2 ) && !( face->variation_support & TT_FACE_FLAG_VAR_TSB ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; else if ( j == ( n_points - 1 ) && !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } #ifdef FT_DEBUG_LEVEL_TRACE - if ( delta_x || delta_y ) + if ( point_delta_x || point_delta_y ) { - FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", + FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n", j, - outline->points[j].x - delta_x, - outline->points[j].y - delta_y, - outline->points[j].x, - outline->points[j].y )); + ( FT_intToFixed( outline->points[j].x ) + + old_point_delta_x ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + old_point_delta_y ) / 65536.0, + ( FT_intToFixed( outline->points[j].x ) + + point_deltas_x[j] ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + point_deltas_y[j] ) / 65536.0 )); count++; } #endif @@ -3837,14 +3988,17 @@ for ( j = 0; j < n_points; j++ ) { - FT_Pos delta_x = points_out[j].x - points_org[j].x; - FT_Pos delta_y = points_out[j].y - points_org[j].y; + FT_Fixed old_point_delta_x = point_deltas_x[j]; + FT_Fixed old_point_delta_y = point_deltas_y[j]; + + FT_Pos point_delta_x = points_out[j].x - points_org[j].x; + FT_Pos point_delta_y = points_out[j].y - points_org[j].y; if ( j < n_points - 4 ) { - outline->points[j].x += delta_x; - outline->points[j].y += delta_y; + point_deltas_x[j] = old_point_delta_x + point_delta_x; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } else { @@ -3854,33 +4008,37 @@ if ( j == ( n_points - 4 ) && !( face->variation_support & TT_FACE_FLAG_VAR_LSB ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 3 ) && !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 2 ) && !( face->variation_support & TT_FACE_FLAG_VAR_TSB ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; else if ( j == ( n_points - 1 ) && !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } #ifdef FT_DEBUG_LEVEL_TRACE - if ( delta_x || delta_y ) + if ( point_delta_x || point_delta_y ) { - FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", + FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n", j, - outline->points[j].x - delta_x, - outline->points[j].y - delta_y, - outline->points[j].x, - outline->points[j].y )); + ( FT_intToFixed( outline->points[j].x ) + + old_point_delta_x ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + old_point_delta_y ) / 65536.0, + ( FT_intToFixed( outline->points[j].x ) + + point_deltas_x[j] ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + point_deltas_y[j] ) / 65536.0 )); count++; } #endif @@ -3904,6 +4062,16 @@ FT_TRACE5(( "\n" )); + for ( i = 0; i < n_points; i++ ) + { + outline->points[i].x += FT_fixedToInt( point_deltas_x[i] ); + outline->points[i].y += FT_fixedToInt( point_deltas_y[i] ); + } + + Fail3: + FT_FREE( point_deltas_x ); + FT_FREE( point_deltas_y ); + Fail2: if ( sharedpoints != ALL_POINTS ) FT_FREE( sharedpoints ); @@ -3922,16 +4090,16 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_get_var_blend */ - /* */ - /* <Description> */ - /* An extended internal version of `TT_Get_MM_Blend' that returns */ - /* pointers instead of copying data, without any initialization of */ - /* the MM machinery in case it isn't loaded yet. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_get_var_blend + * + * @Description: + * An extended internal version of `TT_Get_MM_Blend' that returns + * pointers instead of copying data, without any initialization of + * the MM machinery in case it isn't loaded yet. + */ FT_LOCAL_DEF( FT_Error ) tt_get_var_blend( TT_Face face, FT_UInt *num_coords, @@ -3993,14 +4161,14 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_done_blend */ - /* */ - /* <Description> */ - /* Free the blend internal data structure. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_done_blend + * + * @Description: + * Free the blend internal data structure. + */ FT_LOCAL_DEF( void ) tt_done_blend( TT_Face face ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h index a37bb90266c..7e8d9768a76 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttgxvar.h */ -/* */ -/* TrueType GX Font Variation loader (specification) */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttgxvar.h + * + * TrueType GX Font Variation loader (specification) + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, Werner Lemberg and George Williams. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTGXVAR_H_ @@ -29,15 +29,15 @@ FT_BEGIN_HEADER #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_AVarCorrespondenceRec */ - /* */ - /* <Description> */ - /* A data structure representing `shortFracCorrespondence' in `avar' */ - /* table according to the specifications from Apple. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_AVarCorrespondenceRec + * + * @Description: + * A data structure representing `shortFracCorrespondence' in `avar' + * table according to the specifications from Apple. + */ typedef struct GX_AVarCorrespondenceRec_ { FT_Fixed fromCoord; @@ -46,15 +46,15 @@ FT_BEGIN_HEADER } GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_AVarRec */ - /* */ - /* <Description> */ - /* Data from the segment field of `avar' table. */ - /* There is one of these for each axis. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_AVarRec + * + * @Description: + * Data from the segment field of `avar' table. + * There is one of these for each axis. + */ typedef struct GX_AVarSegmentRec_ { FT_UShort pairCount; @@ -114,14 +114,14 @@ FT_BEGIN_HEADER } GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_HVVarTableRec */ - /* */ - /* <Description> */ - /* Data from either the `HVAR' or `VVAR' table. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_HVVarTableRec + * + * @Description: + * Data from either the `HVAR' or `VVAR' table. + */ typedef struct GX_HVVarTableRec_ { GX_ItemVarStoreRec itemStore; /* Item Variation Store */ @@ -191,14 +191,14 @@ FT_BEGIN_HEADER } GX_ValueRec, *GX_Value; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_MVarTableRec */ - /* */ - /* <Description> */ - /* Data from the `MVAR' table. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_MVarTableRec + * + * @Description: + * Data from the `MVAR' table. + */ typedef struct GX_MVarTableRec_ { FT_UShort valueCount; @@ -209,95 +209,95 @@ FT_BEGIN_HEADER } GX_MVarTableRec, *GX_MVarTable; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_BlendRec */ - /* */ - /* <Description> */ - /* Data for interpolating a font from a distortable font specified */ - /* by the GX *var tables ([fgcahvm]var). */ - /* */ - /* <Fields> */ - /* num_axis :: */ - /* The number of axes along which interpolation may happen. */ - /* */ - /* coords :: */ - /* An array of design coordinates (in user space) indicating the */ - /* contribution along each axis to the final interpolated font. */ - /* `normalizedcoords' holds the same values. */ - /* */ - /* normalizedcoords :: */ - /* An array of normalized values (between [-1,1]) indicating the */ - /* contribution along each axis to the final interpolated font. */ - /* `coords' holds the same values. */ - /* */ - /* mmvar :: */ - /* Data from the `fvar' table. */ - /* */ - /* mmvar_len :: */ - /* The length of the `mmvar' structure. */ - /* */ - /* normalized_stylecoords :: */ - /* A two-dimensional array that holds the named instance data from */ - /* `mmvar' as normalized values. */ - /* */ - /* avar_loaded :: */ - /* A Boolean; if set, FreeType tried to load (and parse) the `avar' */ - /* table. */ - /* */ - /* avar_segment :: */ - /* Data from the `avar' table. */ - /* */ - /* hvar_loaded :: */ - /* A Boolean; if set, FreeType tried to load (and parse) the `hvar' */ - /* table. */ - /* */ - /* hvar_checked :: */ - /* A Boolean; if set, FreeType successfully loaded and parsed the */ - /* `hvar' table. */ - /* */ - /* hvar_error :: */ - /* If loading and parsing of the `hvar' table failed, this field */ - /* holds the corresponding error code. */ - /* */ - /* hvar_table :: */ - /* Data from the `hvar' table. */ - /* */ - /* vvar_loaded :: */ - /* A Boolean; if set, FreeType tried to load (and parse) the `vvar' */ - /* table. */ - /* */ - /* vvar_checked :: */ - /* A Boolean; if set, FreeType successfully loaded and parsed the */ - /* `vvar' table. */ - /* */ - /* vvar_error :: */ - /* If loading and parsing of the `vvar' table failed, this field */ - /* holds the corresponding error code. */ - /* */ - /* vvar_table :: */ - /* Data from the `vvar' table. */ - /* */ - /* mvar_table :: */ - /* Data from the `mvar' table. */ - /* */ - /* tuplecount :: */ - /* The number of shared tuples in the `gvar' table. */ - /* */ - /* tuplecoords :: */ - /* A two-dimensional array that holds the shared tuple coordinates */ - /* in the `gvar' table. */ - /* */ - /* gv_glyphcnt :: */ - /* The number of glyphs handled in the `gvar' table. */ - /* */ - /* glyphoffsets :: */ - /* Offsets into the glyph variation data array. */ - /* */ - /* gvar_size :: */ - /* The size of the `gvar' table. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_BlendRec + * + * @Description: + * Data for interpolating a font from a distortable font specified + * by the GX *var tables ([fgcahvm]var). + * + * @Fields: + * num_axis :: + * The number of axes along which interpolation may happen. + * + * coords :: + * An array of design coordinates (in user space) indicating the + * contribution along each axis to the final interpolated font. + * `normalizedcoords' holds the same values. + * + * normalizedcoords :: + * An array of normalized values (between [-1,1]) indicating the + * contribution along each axis to the final interpolated font. + * `coords' holds the same values. + * + * mmvar :: + * Data from the `fvar' table. + * + * mmvar_len :: + * The length of the `mmvar' structure. + * + * normalized_stylecoords :: + * A two-dimensional array that holds the named instance data from + * `mmvar' as normalized values. + * + * avar_loaded :: + * A Boolean; if set, FreeType tried to load (and parse) the `avar' + * table. + * + * avar_segment :: + * Data from the `avar' table. + * + * hvar_loaded :: + * A Boolean; if set, FreeType tried to load (and parse) the `hvar' + * table. + * + * hvar_checked :: + * A Boolean; if set, FreeType successfully loaded and parsed the + * `hvar' table. + * + * hvar_error :: + * If loading and parsing of the `hvar' table failed, this field + * holds the corresponding error code. + * + * hvar_table :: + * Data from the `hvar' table. + * + * vvar_loaded :: + * A Boolean; if set, FreeType tried to load (and parse) the `vvar' + * table. + * + * vvar_checked :: + * A Boolean; if set, FreeType successfully loaded and parsed the + * `vvar' table. + * + * vvar_error :: + * If loading and parsing of the `vvar' table failed, this field + * holds the corresponding error code. + * + * vvar_table :: + * Data from the `vvar' table. + * + * mvar_table :: + * Data from the `mvar' table. + * + * tuplecount :: + * The number of shared tuples in the `gvar' table. + * + * tuplecoords :: + * A two-dimensional array that holds the shared tuple coordinates + * in the `gvar' table. + * + * gv_glyphcnt :: + * The number of glyphs handled in the `gvar' table. + * + * glyphoffsets :: + * Offsets into the glyph variation data array. + * + * gvar_size :: + * The size of the `gvar' table. + */ typedef struct GX_BlendRec_ { FT_UInt num_axis; @@ -336,14 +336,14 @@ FT_BEGIN_HEADER } GX_BlendRec; - /*************************************************************************/ - /* */ - /* <enum> */ - /* GX_TupleCountFlags */ - /* */ - /* <Description> */ - /* Flags used within the `TupleCount' field of the `gvar' table. */ - /* */ + /************************************************************************** + * + * @enum: + * GX_TupleCountFlags + * + * @Description: + * Flags used within the `TupleCount' field of the `gvar' table. + */ typedef enum GX_TupleCountFlags_ { GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000, @@ -353,15 +353,15 @@ FT_BEGIN_HEADER } GX_TupleCountFlags; - /*************************************************************************/ - /* */ - /* <enum> */ - /* GX_TupleIndexFlags */ - /* */ - /* <Description> */ - /* Flags used within the `TupleIndex' field of the `gvar' and `cvar' */ - /* tables. */ - /* */ + /************************************************************************** + * + * @enum: + * GX_TupleIndexFlags + * + * @Description: + * Flags used within the `TupleIndex' field of the `gvar' and `cvar' + * tables. + */ typedef enum GX_TupleIndexFlags_ { GX_TI_EMBEDDED_TUPLE_COORD = 0x8000, diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c index da9b595aba0..403f3753c7b 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttinterp.c */ -/* */ -/* TrueType bytecode interpreter (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttinterp.c + * + * TrueType bytecode interpreter (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */ @@ -39,14 +39,14 @@ #ifdef TT_USE_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttinterp +#define FT_COMPONENT ttinterp #define NO_SUBPIXEL_HINTING \ @@ -82,10 +82,10 @@ exc->func_dualproj( exc, (v)->x, (v)->y ) - /*************************************************************************/ - /* */ - /* Two simple bounds-checking macros. */ - /* */ + /************************************************************************** + * + * Two simple bounds-checking macros. + */ #define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) ) #define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) ) @@ -97,30 +97,33 @@ #define FAILURE 1 - /*************************************************************************/ - /* */ - /* CODERANGE FUNCTIONS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Goto_CodeRange */ - /* */ - /* <Description> */ - /* Switches to a new code range (updates the code related elements in */ - /* `exec', and `IP'). */ - /* */ - /* <Input> */ - /* range :: The new execution code range. */ - /* */ - /* IP :: The new IP in the new code range. */ - /* */ - /* <InOut> */ - /* exec :: The target execution context. */ - /* */ + /************************************************************************** + * + * CODERANGE FUNCTIONS + * + */ + + + /************************************************************************** + * + * @Function: + * TT_Goto_CodeRange + * + * @Description: + * Switches to a new code range (updates the code related elements in + * `exec', and `IP'). + * + * @Input: + * range :: + * The new execution code range. + * + * IP :: + * The new IP in the new code range. + * + * @InOut: + * exec :: + * The target execution context. + */ FT_LOCAL_DEF( void ) TT_Goto_CodeRange( TT_ExecContext exec, FT_Int range, @@ -148,24 +151,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_CodeRange */ - /* */ - /* <Description> */ - /* Sets a code range. */ - /* */ - /* <Input> */ - /* range :: The code range index. */ - /* */ - /* base :: The new code base. */ - /* */ - /* length :: The range size in bytes. */ - /* */ - /* <InOut> */ - /* exec :: The target execution context. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_CodeRange + * + * @Description: + * Sets a code range. + * + * @Input: + * range :: + * The code range index. + * + * base :: + * The new code base. + * + * length :: + * The range size in bytes. + * + * @InOut: + * exec :: + * The target execution context. + */ FT_LOCAL_DEF( void ) TT_Set_CodeRange( TT_ExecContext exec, FT_Int range, @@ -179,20 +186,22 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Clear_CodeRange */ - /* */ - /* <Description> */ - /* Clears a code range. */ - /* */ - /* <Input> */ - /* range :: The code range index. */ - /* */ - /* <InOut> */ - /* exec :: The target execution context. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Clear_CodeRange + * + * @Description: + * Clears a code range. + * + * @Input: + * range :: + * The code range index. + * + * @InOut: + * exec :: + * The target execution context. + */ FT_LOCAL_DEF( void ) TT_Clear_CodeRange( TT_ExecContext exec, FT_Int range ) @@ -204,29 +213,31 @@ } - /*************************************************************************/ - /* */ - /* EXECUTION CONTEXT ROUTINES */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Done_Context */ - /* */ - /* <Description> */ - /* Destroys a given context. */ - /* */ - /* <Input> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* memory :: A handle to the parent memory object. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* */ + /************************************************************************** + * + * EXECUTION CONTEXT ROUTINES + * + */ + + + /************************************************************************** + * + * @Function: + * TT_Done_Context + * + * @Description: + * Destroys a given context. + * + * @Input: + * exec :: + * A handle to the target execution context. + * + * memory :: + * A handle to the parent memory object. + * + * @Note: + * Only the glyph loader and debugger should call this function. + */ FT_LOCAL_DEF( void ) TT_Done_Context( TT_ExecContext exec ) { @@ -257,23 +268,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Init_Context */ - /* */ - /* <Description> */ - /* Initializes a context object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the parent memory object. */ - /* */ - /* <InOut> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * Init_Context + * + * @Description: + * Initializes a context object. + * + * @Input: + * memory :: + * A handle to the parent memory object. + * + * @InOut: + * exec :: + * A handle to the target execution context. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error Init_Context( TT_ExecContext exec, FT_Memory memory ) @@ -313,30 +326,35 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Update_Max */ - /* */ - /* <Description> */ - /* Checks the size of a buffer and reallocates it if necessary. */ - /* */ - /* <Input> */ - /* memory :: A handle to the parent memory object. */ - /* */ - /* multiplier :: The size in bytes of each element in the buffer. */ - /* */ - /* new_max :: The new capacity (size) of the buffer. */ - /* */ - /* <InOut> */ - /* size :: The address of the buffer's current size expressed */ - /* in elements. */ - /* */ - /* buff :: The address of the buffer base pointer. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * Update_Max + * + * @Description: + * Checks the size of a buffer and reallocates it if necessary. + * + * @Input: + * memory :: + * A handle to the parent memory object. + * + * multiplier :: + * The size in bytes of each element in the buffer. + * + * new_max :: + * The new capacity (size) of the buffer. + * + * @InOut: + * size :: + * The address of the buffer's current size expressed + * in elements. + * + * buff :: + * The address of the buffer base pointer. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) Update_Max( FT_Memory memory, FT_ULong* size, @@ -359,28 +377,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Load_Context */ - /* */ - /* <Description> */ - /* Prepare an execution context for glyph hinting. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* size :: A handle to the source size object. */ - /* */ - /* <InOut> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Load_Context + * + * @Description: + * Prepare an execution context for glyph hinting. + * + * @Input: + * face :: + * A handle to the source face object. + * + * size :: + * A handle to the source size object. + * + * @InOut: + * exec :: + * A handle to the target execution context. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only the glyph loader and debugger should call this function. + */ FT_LOCAL_DEF( FT_Error ) TT_Load_Context( TT_ExecContext exec, TT_Face face, @@ -467,23 +488,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Save_Context */ - /* */ - /* <Description> */ - /* Saves the code ranges in a `size' object. */ - /* */ - /* <Input> */ - /* exec :: A handle to the source execution context. */ - /* */ - /* <InOut> */ - /* size :: A handle to the target size object. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Save_Context + * + * @Description: + * Saves the code ranges in a `size' object. + * + * @Input: + * exec :: + * A handle to the source execution context. + * + * @InOut: + * size :: + * A handle to the target size object. + * + * @Note: + * Only the glyph loader and debugger should call this function. + */ FT_LOCAL_DEF( void ) TT_Save_Context( TT_ExecContext exec, TT_Size size ) @@ -505,27 +528,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Run_Context */ - /* */ - /* <Description> */ - /* Executes one or more instructions in the execution context. */ - /* */ - /* <Input> */ - /* debug :: A Boolean flag. If set, the function sets some internal */ - /* variables and returns immediately, otherwise TT_RunIns() */ - /* is called. */ - /* */ - /* This is commented out currently. */ - /* */ - /* <Input> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* TrueType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Run_Context + * + * @Description: + * Executes one or more instructions in the execution context. + * + * @Input: + * exec :: + * A handle to the target execution context. + * + * @Return: + * TrueType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Run_Context( TT_ExecContext exec ) { @@ -609,22 +626,22 @@ } - /*************************************************************************/ - /* */ - /* Before an opcode is executed, the interpreter verifies that there are */ - /* enough arguments on the stack, with the help of the `Pop_Push_Count' */ - /* table. */ - /* */ - /* For each opcode, the first column gives the number of arguments that */ - /* are popped from the stack; the second one gives the number of those */ - /* that are pushed in result. */ - /* */ - /* Opcodes which have a varying number of parameters in the data stream */ - /* (NPUSHB, NPUSHW) are handled specially; they have a negative value in */ - /* the `opcode_length' table, and the value in `Pop_Push_Count' is set */ - /* to zero. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Before an opcode is executed, the interpreter verifies that there are + * enough arguments on the stack, with the help of the `Pop_Push_Count' + * table. + * + * For each opcode, the first column gives the number of arguments that + * are popped from the stack; the second one gives the number of those + * that are pushed in result. + * + * Opcodes which have a varying number of parameters in the data stream + * (NPUSHB, NPUSHW) are handled specially; they have a negative value in + * the `opcode_length' table, and the value in `Pop_Push_Count' is set + * to zero. + * + */ #undef PACK @@ -1129,73 +1146,73 @@ "8 PushW[6]", "8 PushW[7]", - "8 MDRP[00]", - "8 MDRP[01]", - "8 MDRP[02]", - "8 MDRP[03]", - "8 MDRP[04]", - "8 MDRP[05]", - "8 MDRP[06]", - "8 MDRP[07]", - "8 MDRP[08]", - "8 MDRP[09]", - "8 MDRP[10]", - "8 MDRP[11]", - "8 MDRP[12]", - "8 MDRP[13]", - "8 MDRP[14]", - "8 MDRP[15]", - - "8 MDRP[16]", - "8 MDRP[17]", - "8 MDRP[18]", - "8 MDRP[19]", - "8 MDRP[20]", - "8 MDRP[21]", - "8 MDRP[22]", - "8 MDRP[23]", - "8 MDRP[24]", - "8 MDRP[25]", - "8 MDRP[26]", - "8 MDRP[27]", - "8 MDRP[28]", - "8 MDRP[29]", - "8 MDRP[30]", - "8 MDRP[31]", - - "8 MIRP[00]", - "8 MIRP[01]", - "8 MIRP[02]", - "8 MIRP[03]", - "8 MIRP[04]", - "8 MIRP[05]", - "8 MIRP[06]", - "8 MIRP[07]", - "8 MIRP[08]", - "8 MIRP[09]", - "8 MIRP[10]", - "8 MIRP[11]", - "8 MIRP[12]", - "8 MIRP[13]", - "8 MIRP[14]", - "8 MIRP[15]", - - "8 MIRP[16]", - "8 MIRP[17]", - "8 MIRP[18]", - "8 MIRP[19]", - "8 MIRP[20]", - "8 MIRP[21]", - "8 MIRP[22]", - "8 MIRP[23]", - "8 MIRP[24]", - "8 MIRP[25]", - "8 MIRP[26]", - "8 MIRP[27]", - "8 MIRP[28]", - "8 MIRP[29]", - "8 MIRP[30]", - "8 MIRP[31]" + "7 MDRP[G]", + "7 MDRP[B]", + "7 MDRP[W]", + "7 MDRP[?]", + "8 MDRP[rG]", + "8 MDRP[rB]", + "8 MDRP[rW]", + "8 MDRP[r?]", + "8 MDRP[mG]", + "8 MDRP[mB]", + "8 MDRP[mW]", + "8 MDRP[m?]", + "9 MDRP[mrG]", + "9 MDRP[mrB]", + "9 MDRP[mrW]", + "9 MDRP[mr?]", + + "8 MDRP[pG]", + "8 MDRP[pB]", + "8 MDRP[pW]", + "8 MDRP[p?]", + "9 MDRP[prG]", + "9 MDRP[prB]", + "9 MDRP[prW]", + "9 MDRP[pr?]", + "9 MDRP[pmG]", + "9 MDRP[pmB]", + "9 MDRP[pmW]", + "9 MDRP[pm?]", + "A MDRP[pmrG]", + "A MDRP[pmrB]", + "A MDRP[pmrW]", + "A MDRP[pmr?]", + + "7 MIRP[G]", + "7 MIRP[B]", + "7 MIRP[W]", + "7 MIRP[?]", + "8 MIRP[rG]", + "8 MIRP[rB]", + "8 MIRP[rW]", + "8 MIRP[r?]", + "8 MIRP[mG]", + "8 MIRP[mB]", + "8 MIRP[mW]", + "8 MIRP[m?]", + "9 MIRP[mrG]", + "9 MIRP[mrB]", + "9 MIRP[mrW]", + "9 MIRP[mr?]", + + "8 MIRP[pG]", + "8 MIRP[pB]", + "8 MIRP[pW]", + "8 MIRP[p?]", + "9 MIRP[prG]", + "9 MIRP[prB]", + "9 MIRP[prW]", + "9 MIRP[pr?]", + "9 MIRP[pmG]", + "9 MIRP[pmB]", + "9 MIRP[pmW]", + "9 MIRP[pm?]", + "A MIRP[pmrG]", + "A MIRP[pmrB]", + "A MIRP[pmrW]", + "A MIRP[pmr?]" }; #endif /* FT_DEBUG_LEVEL_TRACE */ @@ -1448,18 +1465,18 @@ #endif /* TT_DotFix14 */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* Current_Ratio */ - /* */ - /* <Description> */ - /* Returns the current aspect ratio scaling factor depending on the */ - /* projection vector's state and device resolutions. */ - /* */ - /* <Return> */ - /* The aspect ratio in 16.16 format, always <= 1.0 . */ - /* */ + /************************************************************************** + * + * @Function: + * Current_Ratio + * + * @Description: + * Returns the current aspect ratio scaling factor depending on the + * projection vector's state and device resolutions. + * + * @Return: + * The aspect ratio in 16.16 format, always <= 1.0 . + */ static FT_Long Current_Ratio( TT_ExecContext exc ) { @@ -1501,11 +1518,11 @@ } - /*************************************************************************/ - /* */ - /* Functions related to the control value table (CVT). */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Functions related to the control value table (CVT). + * + */ FT_CALLBACK_DEF( FT_F26Dot6 ) @@ -1547,7 +1564,7 @@ FT_ULong idx, FT_F26Dot6 value ) { - exc->cvt[idx] += value; + exc->cvt[idx] = ADD_LONG( exc->cvt[idx], value ); } @@ -1556,25 +1573,26 @@ FT_ULong idx, FT_F26Dot6 value ) { - exc->cvt[idx] += FT_DivFix( value, Current_Ratio( exc ) ); - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* GetShortIns */ - /* */ - /* <Description> */ - /* Returns a short integer taken from the instruction stream at */ - /* address IP. */ - /* */ - /* <Return> */ - /* Short read at code[IP]. */ - /* */ - /* <Note> */ - /* This one could become a macro. */ - /* */ + exc->cvt[idx] = ADD_LONG( exc->cvt[idx], + FT_DivFix( value, Current_Ratio( exc ) ) ); + } + + + /************************************************************************** + * + * @Function: + * GetShortIns + * + * @Description: + * Returns a short integer taken from the instruction stream at + * address IP. + * + * @Return: + * Short read at code[IP]. + * + * @Note: + * This one could become a macro. + */ static FT_Short GetShortIns( TT_ExecContext exc ) { @@ -1585,22 +1603,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Ins_Goto_CodeRange */ - /* */ - /* <Description> */ - /* Goes to a certain code range in the instruction stream. */ - /* */ - /* <Input> */ - /* aRange :: The index of the code range. */ - /* */ - /* aIP :: The new IP address in the code range. */ - /* */ - /* <Return> */ - /* SUCCESS or FAILURE. */ - /* */ + /************************************************************************** + * + * @Function: + * Ins_Goto_CodeRange + * + * @Description: + * Goes to a certain code range in the instruction stream. + * + * @Input: + * aRange :: + * The index of the code range. + * + * aIP :: + * The new IP address in the code range. + * + * @Return: + * SUCCESS or FAILURE. + */ static FT_Bool Ins_Goto_CodeRange( TT_ExecContext exc, FT_Int aRange, @@ -1642,27 +1662,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Direct_Move */ - /* */ - /* <Description> */ - /* Moves a point by a given distance along the freedom vector. The */ - /* point will be `touched'. */ - /* */ - /* <Input> */ - /* point :: The index of the point to move. */ - /* */ - /* distance :: The distance to apply. */ - /* */ - /* <InOut> */ - /* zone :: The affected glyph zone. */ - /* */ - /* <Note> */ - /* See `ttinterp.h' for details on backward compatibility mode. */ - /* `Touches' the point. */ - /* */ + /************************************************************************** + * + * @Function: + * Direct_Move + * + * @Description: + * Moves a point by a given distance along the freedom vector. The + * point will be `touched'. + * + * @Input: + * point :: + * The index of the point to move. + * + * distance :: + * The distance to apply. + * + * @InOut: + * zone :: + * The affected glyph zone. + * + * @Note: + * See `ttinterp.h' for details on backward compatibility mode. + * `Touches' the point. + */ static void Direct_Move( TT_ExecContext exc, TT_GlyphZone zone, @@ -1728,23 +1751,26 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Direct_Move_Orig */ - /* */ - /* <Description> */ - /* Moves the *original* position of a point by a given distance along */ - /* the freedom vector. Obviously, the point will not be `touched'. */ - /* */ - /* <Input> */ - /* point :: The index of the point to move. */ - /* */ - /* distance :: The distance to apply. */ - /* */ - /* <InOut> */ - /* zone :: The affected glyph zone. */ - /* */ + /************************************************************************** + * + * @Function: + * Direct_Move_Orig + * + * @Description: + * Moves the *original* position of a point by a given distance along + * the freedom vector. Obviously, the point will not be `touched'. + * + * @Input: + * point :: + * The index of the point to move. + * + * distance :: + * The distance to apply. + * + * @InOut: + * zone :: + * The affected glyph zone. + */ static void Direct_Move_Orig( TT_ExecContext exc, TT_GlyphZone zone, @@ -1772,15 +1798,15 @@ } - /*************************************************************************/ - /* */ - /* Special versions of Direct_Move() */ - /* */ - /* The following versions are used whenever both vectors are both */ - /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */ - /* See `ttinterp.h' for details on backward compatibility mode. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Special versions of Direct_Move() + * + * The following versions are used whenever both vectors are both + * along one of the coordinate unit vectors, i.e. in 90% of the cases. + * See `ttinterp.h' for details on backward compatibility mode. + * + */ static void @@ -1827,14 +1853,14 @@ } - /*************************************************************************/ - /* */ - /* Special versions of Direct_Move_Orig() */ - /* */ - /* The following versions are used whenever both vectors are both */ - /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Special versions of Direct_Move_Orig() + * + * The following versions are used whenever both vectors are both + * along one of the coordinate unit vectors, i.e. in 90% of the cases. + * + */ static void @@ -1861,28 +1887,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_None */ - /* */ - /* <Description> */ - /* Does not round, but adds engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance (not) to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* The compensated distance. */ - /* */ - /* <Note> */ - /* The TrueType specification says very few about the relationship */ - /* between rounding and engine compensation. However, it seems from */ - /* the description of super round that we should add the compensation */ - /* before rounding. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_None + * + * @Description: + * Does not round, but adds engine compensation. + * + * @Input: + * distance :: + * The distance (not) to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * The compensated distance. + * + * @Note: + * The TrueType specification says very few about the relationship + * between rounding and engine compensation. However, it seems from + * the description of super round that we should add the compensation + * before rounding. + */ static FT_F26Dot6 Round_None( TT_ExecContext exc, FT_F26Dot6 distance, @@ -1909,22 +1937,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_To_Grid */ - /* */ - /* <Description> */ - /* Rounds value to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_To_Grid + * + * @Description: + * Rounds value to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_To_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -1953,22 +1983,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_To_Half_Grid */ - /* */ - /* <Description> */ - /* Rounds value to half grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_To_Half_Grid + * + * @Description: + * Rounds value to half grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_To_Half_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -1999,22 +2031,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Down_To_Grid */ - /* */ - /* <Description> */ - /* Rounds value down to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Down_To_Grid + * + * @Description: + * Rounds value down to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_Down_To_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2042,22 +2076,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Up_To_Grid */ - /* */ - /* <Description> */ - /* Rounds value up to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Up_To_Grid + * + * @Description: + * Rounds value up to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_Up_To_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2086,22 +2122,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_To_Double_Grid */ - /* */ - /* <Description> */ - /* Rounds value to double grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_To_Double_Grid + * + * @Description: + * Rounds value to double grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_To_Double_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2130,28 +2168,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Super */ - /* */ - /* <Description> */ - /* Super-rounds value to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ - /* <Note> */ - /* The TrueType specification says very little about the relationship */ - /* between rounding and engine compensation. However, it seems from */ - /* the description of super round that we should add the compensation */ - /* before rounding. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Super + * + * @Description: + * Super-rounds value to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + * + * @Note: + * The TrueType specification says very little about the relationship + * between rounding and engine compensation. However, it seems from + * the description of super round that we should add the compensation + * before rounding. + */ static FT_F26Dot6 Round_Super( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2183,26 +2223,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Super_45 */ - /* */ - /* <Description> */ - /* Super-rounds value to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ - /* <Note> */ - /* There is a separate function for Round_Super_45() as we may need */ - /* greater precision. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Super_45 + * + * @Description: + * Super-rounds value to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + * + * @Note: + * There is a separate function for Round_Super_45() as we may need + * greater precision. + */ static FT_F26Dot6 Round_Super_45( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2234,17 +2276,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Compute_Round */ - /* */ - /* <Description> */ - /* Sets the rounding mode. */ - /* */ - /* <Input> */ - /* round_mode :: The rounding mode to be used. */ - /* */ + /************************************************************************** + * + * @Function: + * Compute_Round + * + * @Description: + * Sets the rounding mode. + * + * @Input: + * round_mode :: + * The rounding mode to be used. + */ static void Compute_Round( TT_ExecContext exc, FT_Byte round_mode ) @@ -2286,19 +2329,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* SetSuperRound */ - /* */ - /* <Description> */ - /* Sets Super Round parameters. */ - /* */ - /* <Input> */ - /* GridPeriod :: The grid period. */ - /* */ - /* selector :: The SROUND opcode. */ - /* */ + /************************************************************************** + * + * @Function: + * SetSuperRound + * + * @Description: + * Sets Super Round parameters. + * + * @Input: + * GridPeriod :: + * The grid period. + * + * selector :: + * The SROUND opcode. + */ static void SetSuperRound( TT_ExecContext exc, FT_F2Dot14 GridPeriod, @@ -2355,22 +2400,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Project */ - /* */ - /* <Description> */ - /* Computes the projection of vector given by (v2-v1) along the */ - /* current projection vector. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Project + * + * @Description: + * Computes the projection of vector given by (v2-v1) along the + * current projection vector. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Project( TT_ExecContext exc, FT_Pos dx, @@ -2382,22 +2429,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Dual_Project */ - /* */ - /* <Description> */ - /* Computes the projection of the vector given by (v2-v1) along the */ - /* current dual vector. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Dual_Project + * + * @Description: + * Computes the projection of the vector given by (v2-v1) along the + * current dual vector. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Dual_Project( TT_ExecContext exc, FT_Pos dx, @@ -2409,22 +2458,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Project_x */ - /* */ - /* <Description> */ - /* Computes the projection of the vector given by (v2-v1) along the */ - /* horizontal axis. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Project_x + * + * @Description: + * Computes the projection of the vector given by (v2-v1) along the + * horizontal axis. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Project_x( TT_ExecContext exc, FT_Pos dx, @@ -2437,22 +2488,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Project_y */ - /* */ - /* <Description> */ - /* Computes the projection of the vector given by (v2-v1) along the */ - /* vertical axis. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Project_y + * + * @Description: + * Computes the projection of the vector given by (v2-v1) along the + * vertical axis. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Project_y( TT_ExecContext exc, FT_Pos dx, @@ -2465,15 +2518,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Compute_Funcs */ - /* */ - /* <Description> */ - /* Computes the projection and movement function pointers according */ - /* to the current graphics state. */ - /* */ + /************************************************************************** + * + * @Function: + * Compute_Funcs + * + * @Description: + * Computes the projection and movement function pointers according + * to the current graphics state. + */ static void Compute_Funcs( TT_ExecContext exc ) { @@ -2528,28 +2581,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Normalize */ - /* */ - /* <Description> */ - /* Norms a vector. */ - /* */ - /* <Input> */ - /* Vx :: The horizontal input vector coordinate. */ - /* Vy :: The vertical input vector coordinate. */ - /* */ - /* <Output> */ - /* R :: The normed unit vector. */ - /* */ - /* <Return> */ - /* Returns FAILURE if a vector parameter is zero. */ - /* */ - /* <Note> */ - /* In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and */ - /* R is undefined. */ - /* */ + /************************************************************************** + * + * @Function: + * Normalize + * + * @Description: + * Norms a vector. + * + * @Input: + * Vx :: + * The horizontal input vector coordinate. + * Vy :: + * The vertical input vector coordinate. + * + * @Output: + * R :: + * The normed unit vector. + * + * @Return: + * Returns FAILURE if a vector parameter is zero. + * + * @Note: + * In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and + * R is undefined. + */ static FT_Bool Normalize( FT_F26Dot6 Vx, FT_F26Dot6 Vy, @@ -2577,11 +2633,11 @@ } - /*************************************************************************/ - /* */ - /* Here we start with the implementation of the various opcodes. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Here we start with the implementation of the various opcodes. + * + */ #define ARRAY_BOUND_ERROR \ @@ -2592,12 +2648,12 @@ } while (0) - /*************************************************************************/ - /* */ - /* MPPEM[]: Measure Pixel Per EM */ - /* Opcode range: 0x4B */ - /* Stack: --> Euint16 */ - /* */ + /************************************************************************** + * + * MPPEM[]: Measure Pixel Per EM + * Opcode range: 0x4B + * Stack: --> Euint16 + */ static void Ins_MPPEM( TT_ExecContext exc, FT_Long* args ) @@ -2606,12 +2662,12 @@ } - /*************************************************************************/ - /* */ - /* MPS[]: Measure Point Size */ - /* Opcode range: 0x4C */ - /* Stack: --> Euint16 */ - /* */ + /************************************************************************** + * + * MPS[]: Measure Point Size + * Opcode range: 0x4C + * Stack: --> Euint16 + */ static void Ins_MPS( TT_ExecContext exc, FT_Long* args ) @@ -2633,12 +2689,12 @@ } - /*************************************************************************/ - /* */ - /* DUP[]: DUPlicate the stack's top element */ - /* Opcode range: 0x20 */ - /* Stack: StkElt --> StkElt StkElt */ - /* */ + /************************************************************************** + * + * DUP[]: DUPlicate the stack's top element + * Opcode range: 0x20 + * Stack: StkElt --> StkElt StkElt + */ static void Ins_DUP( FT_Long* args ) { @@ -2646,12 +2702,12 @@ } - /*************************************************************************/ - /* */ - /* POP[]: POP the stack's top element */ - /* Opcode range: 0x21 */ - /* Stack: StkElt --> */ - /* */ + /************************************************************************** + * + * POP[]: POP the stack's top element + * Opcode range: 0x21 + * Stack: StkElt --> + */ static void Ins_POP( void ) { @@ -2659,12 +2715,12 @@ } - /*************************************************************************/ - /* */ - /* CLEAR[]: CLEAR the entire stack */ - /* Opcode range: 0x22 */ - /* Stack: StkElt... --> */ - /* */ + /************************************************************************** + * + * CLEAR[]: CLEAR the entire stack + * Opcode range: 0x22 + * Stack: StkElt... --> + */ static void Ins_CLEAR( TT_ExecContext exc ) { @@ -2672,12 +2728,12 @@ } - /*************************************************************************/ - /* */ - /* SWAP[]: SWAP the stack's top two elements */ - /* Opcode range: 0x23 */ - /* Stack: 2 * StkElt --> 2 * StkElt */ - /* */ + /************************************************************************** + * + * SWAP[]: SWAP the stack's top two elements + * Opcode range: 0x23 + * Stack: 2 * StkElt --> 2 * StkElt + */ static void Ins_SWAP( FT_Long* args ) { @@ -2690,12 +2746,12 @@ } - /*************************************************************************/ - /* */ - /* DEPTH[]: return the stack DEPTH */ - /* Opcode range: 0x24 */ - /* Stack: --> uint32 */ - /* */ + /************************************************************************** + * + * DEPTH[]: return the stack DEPTH + * Opcode range: 0x24 + * Stack: --> uint32 + */ static void Ins_DEPTH( TT_ExecContext exc, FT_Long* args ) @@ -2704,12 +2760,12 @@ } - /*************************************************************************/ - /* */ - /* LT[]: Less Than */ - /* Opcode range: 0x50 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * LT[]: Less Than + * Opcode range: 0x50 + * Stack: int32? int32? --> bool + */ static void Ins_LT( FT_Long* args ) { @@ -2717,12 +2773,12 @@ } - /*************************************************************************/ - /* */ - /* LTEQ[]: Less Than or EQual */ - /* Opcode range: 0x51 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * LTEQ[]: Less Than or EQual + * Opcode range: 0x51 + * Stack: int32? int32? --> bool + */ static void Ins_LTEQ( FT_Long* args ) { @@ -2730,12 +2786,12 @@ } - /*************************************************************************/ - /* */ - /* GT[]: Greater Than */ - /* Opcode range: 0x52 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * GT[]: Greater Than + * Opcode range: 0x52 + * Stack: int32? int32? --> bool + */ static void Ins_GT( FT_Long* args ) { @@ -2743,12 +2799,12 @@ } - /*************************************************************************/ - /* */ - /* GTEQ[]: Greater Than or EQual */ - /* Opcode range: 0x53 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * GTEQ[]: Greater Than or EQual + * Opcode range: 0x53 + * Stack: int32? int32? --> bool + */ static void Ins_GTEQ( FT_Long* args ) { @@ -2756,12 +2812,12 @@ } - /*************************************************************************/ - /* */ - /* EQ[]: EQual */ - /* Opcode range: 0x54 */ - /* Stack: StkElt StkElt --> bool */ - /* */ + /************************************************************************** + * + * EQ[]: EQual + * Opcode range: 0x54 + * Stack: StkElt StkElt --> bool + */ static void Ins_EQ( FT_Long* args ) { @@ -2769,12 +2825,12 @@ } - /*************************************************************************/ - /* */ - /* NEQ[]: Not EQual */ - /* Opcode range: 0x55 */ - /* Stack: StkElt StkElt --> bool */ - /* */ + /************************************************************************** + * + * NEQ[]: Not EQual + * Opcode range: 0x55 + * Stack: StkElt StkElt --> bool + */ static void Ins_NEQ( FT_Long* args ) { @@ -2782,12 +2838,12 @@ } - /*************************************************************************/ - /* */ - /* ODD[]: Is ODD */ - /* Opcode range: 0x56 */ - /* Stack: f26.6 --> bool */ - /* */ + /************************************************************************** + * + * ODD[]: Is ODD + * Opcode range: 0x56 + * Stack: f26.6 --> bool + */ static void Ins_ODD( TT_ExecContext exc, FT_Long* args ) @@ -2796,12 +2852,12 @@ } - /*************************************************************************/ - /* */ - /* EVEN[]: Is EVEN */ - /* Opcode range: 0x57 */ - /* Stack: f26.6 --> bool */ - /* */ + /************************************************************************** + * + * EVEN[]: Is EVEN + * Opcode range: 0x57 + * Stack: f26.6 --> bool + */ static void Ins_EVEN( TT_ExecContext exc, FT_Long* args ) @@ -2810,12 +2866,12 @@ } - /*************************************************************************/ - /* */ - /* AND[]: logical AND */ - /* Opcode range: 0x5A */ - /* Stack: uint32 uint32 --> uint32 */ - /* */ + /************************************************************************** + * + * AND[]: logical AND + * Opcode range: 0x5A + * Stack: uint32 uint32 --> uint32 + */ static void Ins_AND( FT_Long* args ) { @@ -2823,12 +2879,12 @@ } - /*************************************************************************/ - /* */ - /* OR[]: logical OR */ - /* Opcode range: 0x5B */ - /* Stack: uint32 uint32 --> uint32 */ - /* */ + /************************************************************************** + * + * OR[]: logical OR + * Opcode range: 0x5B + * Stack: uint32 uint32 --> uint32 + */ static void Ins_OR( FT_Long* args ) { @@ -2836,12 +2892,12 @@ } - /*************************************************************************/ - /* */ - /* NOT[]: logical NOT */ - /* Opcode range: 0x5C */ - /* Stack: StkElt --> uint32 */ - /* */ + /************************************************************************** + * + * NOT[]: logical NOT + * Opcode range: 0x5C + * Stack: StkElt --> uint32 + */ static void Ins_NOT( FT_Long* args ) { @@ -2849,12 +2905,12 @@ } - /*************************************************************************/ - /* */ - /* ADD[]: ADD */ - /* Opcode range: 0x60 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * ADD[]: ADD + * Opcode range: 0x60 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_ADD( FT_Long* args ) { @@ -2862,12 +2918,12 @@ } - /*************************************************************************/ - /* */ - /* SUB[]: SUBtract */ - /* Opcode range: 0x61 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * SUB[]: SUBtract + * Opcode range: 0x61 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_SUB( FT_Long* args ) { @@ -2875,12 +2931,12 @@ } - /*************************************************************************/ - /* */ - /* DIV[]: DIVide */ - /* Opcode range: 0x62 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * DIV[]: DIVide + * Opcode range: 0x62 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_DIV( TT_ExecContext exc, FT_Long* args ) @@ -2892,12 +2948,12 @@ } - /*************************************************************************/ - /* */ - /* MUL[]: MULtiply */ - /* Opcode range: 0x63 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * MUL[]: MULtiply + * Opcode range: 0x63 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_MUL( FT_Long* args ) { @@ -2905,12 +2961,12 @@ } - /*************************************************************************/ - /* */ - /* ABS[]: ABSolute value */ - /* Opcode range: 0x64 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * ABS[]: ABSolute value + * Opcode range: 0x64 + * Stack: f26.6 --> f26.6 + */ static void Ins_ABS( FT_Long* args ) { @@ -2919,12 +2975,12 @@ } - /*************************************************************************/ - /* */ - /* NEG[]: NEGate */ - /* Opcode range: 0x65 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * NEG[]: NEGate + * Opcode range: 0x65 + * Stack: f26.6 --> f26.6 + */ static void Ins_NEG( FT_Long* args ) { @@ -2932,12 +2988,12 @@ } - /*************************************************************************/ - /* */ - /* FLOOR[]: FLOOR */ - /* Opcode range: 0x66 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * FLOOR[]: FLOOR + * Opcode range: 0x66 + * Stack: f26.6 --> f26.6 + */ static void Ins_FLOOR( FT_Long* args ) { @@ -2945,12 +3001,12 @@ } - /*************************************************************************/ - /* */ - /* CEILING[]: CEILING */ - /* Opcode range: 0x67 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * CEILING[]: CEILING + * Opcode range: 0x67 + * Stack: f26.6 --> f26.6 + */ static void Ins_CEILING( FT_Long* args ) { @@ -2958,12 +3014,12 @@ } - /*************************************************************************/ - /* */ - /* RS[]: Read Store */ - /* Opcode range: 0x43 */ - /* Stack: uint32 --> uint32 */ - /* */ + /************************************************************************** + * + * RS[]: Read Store + * Opcode range: 0x43 + * Stack: uint32 --> uint32 + */ static void Ins_RS( TT_ExecContext exc, FT_Long* args ) @@ -3004,12 +3060,12 @@ } - /*************************************************************************/ - /* */ - /* WS[]: Write Store */ - /* Opcode range: 0x42 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * WS[]: Write Store + * Opcode range: 0x42 + * Stack: uint32 uint32 --> + */ static void Ins_WS( TT_ExecContext exc, FT_Long* args ) @@ -3027,12 +3083,12 @@ } - /*************************************************************************/ - /* */ - /* WCVTP[]: Write CVT in Pixel units */ - /* Opcode range: 0x44 */ - /* Stack: f26.6 uint32 --> */ - /* */ + /************************************************************************** + * + * WCVTP[]: Write CVT in Pixel units + * Opcode range: 0x44 + * Stack: f26.6 uint32 --> + */ static void Ins_WCVTP( TT_ExecContext exc, FT_Long* args ) @@ -3050,12 +3106,12 @@ } - /*************************************************************************/ - /* */ - /* WCVTF[]: Write CVT in Funits */ - /* Opcode range: 0x70 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * WCVTF[]: Write CVT in Funits + * Opcode range: 0x70 + * Stack: uint32 uint32 --> + */ static void Ins_WCVTF( TT_ExecContext exc, FT_Long* args ) @@ -3073,12 +3129,12 @@ } - /*************************************************************************/ - /* */ - /* RCVT[]: Read CVT */ - /* Opcode range: 0x45 */ - /* Stack: uint32 --> f26.6 */ - /* */ + /************************************************************************** + * + * RCVT[]: Read CVT + * Opcode range: 0x45 + * Stack: uint32 --> f26.6 + */ static void Ins_RCVT( TT_ExecContext exc, FT_Long* args ) @@ -3098,12 +3154,12 @@ } - /*************************************************************************/ - /* */ - /* AA[]: Adjust Angle */ - /* Opcode range: 0x7F */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * AA[]: Adjust Angle + * Opcode range: 0x7F + * Stack: uint32 --> + */ static void Ins_AA( void ) { @@ -3111,14 +3167,14 @@ } - /*************************************************************************/ - /* */ - /* DEBUG[]: DEBUG. Unsupported. */ - /* Opcode range: 0x4F */ - /* Stack: uint32 --> */ - /* */ - /* Note: The original instruction pops a value from the stack. */ - /* */ + /************************************************************************** + * + * DEBUG[]: DEBUG. Unsupported. + * Opcode range: 0x4F + * Stack: uint32 --> + * + * Note: The original instruction pops a value from the stack. + */ static void Ins_DEBUG( TT_ExecContext exc ) { @@ -3126,12 +3182,12 @@ } - /*************************************************************************/ - /* */ - /* ROUND[ab]: ROUND value */ - /* Opcode range: 0x68-0x6B */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * ROUND[ab]: ROUND value + * Opcode range: 0x68-0x6B + * Stack: f26.6 --> f26.6 + */ static void Ins_ROUND( TT_ExecContext exc, FT_Long* args ) @@ -3143,12 +3199,12 @@ } - /*************************************************************************/ - /* */ - /* NROUND[ab]: No ROUNDing of value */ - /* Opcode range: 0x6C-0x6F */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * NROUND[ab]: No ROUNDing of value + * Opcode range: 0x6C-0x6F + * Stack: f26.6 --> f26.6 + */ static void Ins_NROUND( TT_ExecContext exc, FT_Long* args ) @@ -3160,12 +3216,12 @@ } - /*************************************************************************/ - /* */ - /* MAX[]: MAXimum */ - /* Opcode range: 0x8B */ - /* Stack: int32? int32? --> int32 */ - /* */ + /************************************************************************** + * + * MAX[]: MAXimum + * Opcode range: 0x8B + * Stack: int32? int32? --> int32 + */ static void Ins_MAX( FT_Long* args ) { @@ -3174,12 +3230,12 @@ } - /*************************************************************************/ - /* */ - /* MIN[]: MINimum */ - /* Opcode range: 0x8C */ - /* Stack: int32? int32? --> int32 */ - /* */ + /************************************************************************** + * + * MIN[]: MINimum + * Opcode range: 0x8C + * Stack: int32? int32? --> int32 + */ static void Ins_MIN( FT_Long* args ) { @@ -3188,12 +3244,12 @@ } - /*************************************************************************/ - /* */ - /* MINDEX[]: Move INDEXed element */ - /* Opcode range: 0x26 */ - /* Stack: int32? --> StkElt */ - /* */ + /************************************************************************** + * + * MINDEX[]: Move INDEXed element + * Opcode range: 0x26 + * Stack: int32? --> StkElt + */ static void Ins_MINDEX( TT_ExecContext exc, FT_Long* args ) @@ -3221,12 +3277,12 @@ } - /*************************************************************************/ - /* */ - /* CINDEX[]: Copy INDEXed element */ - /* Opcode range: 0x25 */ - /* Stack: int32 --> StkElt */ - /* */ + /************************************************************************** + * + * CINDEX[]: Copy INDEXed element + * Opcode range: 0x25 + * Stack: int32 --> StkElt + */ static void Ins_CINDEX( TT_ExecContext exc, FT_Long* args ) @@ -3247,12 +3303,12 @@ } - /*************************************************************************/ - /* */ - /* ROLL[]: ROLL top three elements */ - /* Opcode range: 0x8A */ - /* Stack: 3 * StkElt --> 3 * StkElt */ - /* */ + /************************************************************************** + * + * ROLL[]: ROLL top three elements + * Opcode range: 0x8A + * Stack: 3 * StkElt --> 3 * StkElt + */ static void Ins_ROLL( FT_Long* args ) { @@ -3269,19 +3325,19 @@ } - /*************************************************************************/ - /* */ - /* MANAGING THE FLOW OF CONTROL */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MANAGING THE FLOW OF CONTROL + * + */ - /*************************************************************************/ - /* */ - /* SLOOP[]: Set LOOP variable */ - /* Opcode range: 0x17 */ - /* Stack: int32? --> */ - /* */ + /************************************************************************** + * + * SLOOP[]: Set LOOP variable + * Opcode range: 0x17 + * Stack: int32? --> + */ static void Ins_SLOOP( TT_ExecContext exc, FT_Long* args ) @@ -3323,12 +3379,12 @@ } - /*************************************************************************/ - /* */ - /* IF[]: IF test */ - /* Opcode range: 0x58 */ - /* Stack: StkElt --> */ - /* */ + /************************************************************************** + * + * IF[]: IF test + * Opcode range: 0x58 + * Stack: StkElt --> + */ static void Ins_IF( TT_ExecContext exc, FT_Long* args ) @@ -3367,12 +3423,12 @@ } - /*************************************************************************/ - /* */ - /* ELSE[]: ELSE */ - /* Opcode range: 0x1B */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * ELSE[]: ELSE + * Opcode range: 0x1B + * Stack: --> + */ static void Ins_ELSE( TT_ExecContext exc ) { @@ -3400,12 +3456,12 @@ } - /*************************************************************************/ - /* */ - /* EIF[]: End IF */ - /* Opcode range: 0x59 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * EIF[]: End IF + * Opcode range: 0x59 + * Stack: --> + */ static void Ins_EIF( void ) { @@ -3413,12 +3469,12 @@ } - /*************************************************************************/ - /* */ - /* JMPR[]: JuMP Relative */ - /* Opcode range: 0x1C */ - /* Stack: int32 --> */ - /* */ + /************************************************************************** + * + * JMPR[]: JuMP Relative + * Opcode range: 0x1C + * Stack: int32 --> + */ static void Ins_JMPR( TT_ExecContext exc, FT_Long* args ) @@ -3448,12 +3504,12 @@ } - /*************************************************************************/ - /* */ - /* JROT[]: Jump Relative On True */ - /* Opcode range: 0x78 */ - /* Stack: StkElt int32 --> */ - /* */ + /************************************************************************** + * + * JROT[]: Jump Relative On True + * Opcode range: 0x78 + * Stack: StkElt int32 --> + */ static void Ins_JROT( TT_ExecContext exc, FT_Long* args ) @@ -3463,12 +3519,12 @@ } - /*************************************************************************/ - /* */ - /* JROF[]: Jump Relative On False */ - /* Opcode range: 0x79 */ - /* Stack: StkElt int32 --> */ - /* */ + /************************************************************************** + * + * JROF[]: Jump Relative On False + * Opcode range: 0x79 + * Stack: StkElt int32 --> + */ static void Ins_JROF( TT_ExecContext exc, FT_Long* args ) @@ -3478,19 +3534,19 @@ } - /*************************************************************************/ - /* */ - /* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * DEFINING AND USING FUNCTIONS AND INSTRUCTIONS + * + */ - /*************************************************************************/ - /* */ - /* FDEF[]: Function DEFinition */ - /* Opcode range: 0x2C */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * FDEF[]: Function DEFinition + * Opcode range: 0x2C + * Stack: uint32 --> + */ static void Ins_FDEF( TT_ExecContext exc, FT_Long* args ) @@ -3788,12 +3844,12 @@ } - /*************************************************************************/ - /* */ - /* ENDF[]: END Function definition */ - /* Opcode range: 0x2D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * ENDF[]: END Function definition + * Opcode range: 0x2D + * Stack: --> + */ static void Ins_ENDF( TT_ExecContext exc ) { @@ -3837,12 +3893,12 @@ } - /*************************************************************************/ - /* */ - /* CALL[]: CALL function */ - /* Opcode range: 0x2B */ - /* Stack: uint32? --> */ - /* */ + /************************************************************************** + * + * CALL[]: CALL function + * Opcode range: 0x2B + * Stack: uint32? --> + */ static void Ins_CALL( TT_ExecContext exc, FT_Long* args ) @@ -3926,12 +3982,12 @@ } - /*************************************************************************/ - /* */ - /* LOOPCALL[]: LOOP and CALL function */ - /* Opcode range: 0x2A */ - /* Stack: uint32? Eint16? --> */ - /* */ + /************************************************************************** + * + * LOOPCALL[]: LOOP and CALL function + * Opcode range: 0x2A + * Stack: uint32? Eint16? --> + */ static void Ins_LOOPCALL( TT_ExecContext exc, FT_Long* args ) @@ -4019,12 +4075,12 @@ } - /*************************************************************************/ - /* */ - /* IDEF[]: Instruction DEFinition */ - /* Opcode range: 0x89 */ - /* Stack: Eint8 --> */ - /* */ + /************************************************************************** + * + * IDEF[]: Instruction DEFinition + * Opcode range: 0x89 + * Stack: Eint8 --> + */ static void Ins_IDEF( TT_ExecContext exc, FT_Long* args ) @@ -4094,19 +4150,19 @@ } - /*************************************************************************/ - /* */ - /* PUSHING DATA ONTO THE INTERPRETER STACK */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * PUSHING DATA ONTO THE INTERPRETER STACK + * + */ - /*************************************************************************/ - /* */ - /* NPUSHB[]: PUSH N Bytes */ - /* Opcode range: 0x40 */ - /* Stack: --> uint32... */ - /* */ + /************************************************************************** + * + * NPUSHB[]: PUSH N Bytes + * Opcode range: 0x40 + * Stack: --> uint32... + */ static void Ins_NPUSHB( TT_ExecContext exc, FT_Long* args ) @@ -4129,12 +4185,12 @@ } - /*************************************************************************/ - /* */ - /* NPUSHW[]: PUSH N Words */ - /* Opcode range: 0x41 */ - /* Stack: --> int32... */ - /* */ + /************************************************************************** + * + * NPUSHW[]: PUSH N Words + * Opcode range: 0x41 + * Stack: --> int32... + */ static void Ins_NPUSHW( TT_ExecContext exc, FT_Long* args ) @@ -4160,12 +4216,12 @@ } - /*************************************************************************/ - /* */ - /* PUSHB[abc]: PUSH Bytes */ - /* Opcode range: 0xB0-0xB7 */ - /* Stack: --> uint32... */ - /* */ + /************************************************************************** + * + * PUSHB[abc]: PUSH Bytes + * Opcode range: 0xB0-0xB7 + * Stack: --> uint32... + */ static void Ins_PUSHB( TT_ExecContext exc, FT_Long* args ) @@ -4186,12 +4242,12 @@ } - /*************************************************************************/ - /* */ - /* PUSHW[abc]: PUSH Words */ - /* Opcode range: 0xB8-0xBF */ - /* Stack: --> int32... */ - /* */ + /************************************************************************** + * + * PUSHW[abc]: PUSH Words + * Opcode range: 0xB8-0xBF + * Stack: --> int32... + */ static void Ins_PUSHW( TT_ExecContext exc, FT_Long* args ) @@ -4216,11 +4272,11 @@ } - /*************************************************************************/ - /* */ - /* MANAGING THE GRAPHICS STATE */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MANAGING THE GRAPHICS STATE + * + */ static FT_Bool @@ -4274,20 +4330,20 @@ } - /*************************************************************************/ - /* */ - /* SVTCA[a]: Set (F and P) Vectors to Coordinate Axis */ - /* Opcode range: 0x00-0x01 */ - /* Stack: --> */ - /* */ - /* SPvTCA[a]: Set PVector to Coordinate Axis */ - /* Opcode range: 0x02-0x03 */ - /* Stack: --> */ - /* */ - /* SFvTCA[a]: Set FVector to Coordinate Axis */ - /* Opcode range: 0x04-0x05 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * SVTCA[a]: Set (F and P) Vectors to Coordinate Axis + * Opcode range: 0x00-0x01 + * Stack: --> + * + * SPvTCA[a]: Set PVector to Coordinate Axis + * Opcode range: 0x02-0x03 + * Stack: --> + * + * SFvTCA[a]: Set FVector to Coordinate Axis + * Opcode range: 0x04-0x05 + * Stack: --> + */ static void Ins_SxyTCA( TT_ExecContext exc ) { @@ -4318,12 +4374,12 @@ } - /*************************************************************************/ - /* */ - /* SPvTL[a]: Set PVector To Line */ - /* Opcode range: 0x06-0x07 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * SPvTL[a]: Set PVector To Line + * Opcode range: 0x06-0x07 + * Stack: uint32 uint32 --> + */ static void Ins_SPVTL( TT_ExecContext exc, FT_Long* args ) @@ -4339,12 +4395,12 @@ } - /*************************************************************************/ - /* */ - /* SFvTL[a]: Set FVector To Line */ - /* Opcode range: 0x08-0x09 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * SFvTL[a]: Set FVector To Line + * Opcode range: 0x08-0x09 + * Stack: uint32 uint32 --> + */ static void Ins_SFVTL( TT_ExecContext exc, FT_Long* args ) @@ -4359,12 +4415,12 @@ } - /*************************************************************************/ - /* */ - /* SFvTPv[]: Set FVector To PVector */ - /* Opcode range: 0x0E */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * SFvTPv[]: Set FVector To PVector + * Opcode range: 0x0E + * Stack: --> + */ static void Ins_SFVTPV( TT_ExecContext exc ) { @@ -4373,12 +4429,12 @@ } - /*************************************************************************/ - /* */ - /* SPvFS[]: Set PVector From Stack */ - /* Opcode range: 0x0A */ - /* Stack: f2.14 f2.14 --> */ - /* */ + /************************************************************************** + * + * SPvFS[]: Set PVector From Stack + * Opcode range: 0x0A + * Stack: f2.14 f2.14 --> + */ static void Ins_SPVFS( TT_ExecContext exc, FT_Long* args ) @@ -4400,12 +4456,12 @@ } - /*************************************************************************/ - /* */ - /* SFvFS[]: Set FVector From Stack */ - /* Opcode range: 0x0B */ - /* Stack: f2.14 f2.14 --> */ - /* */ + /************************************************************************** + * + * SFvFS[]: Set FVector From Stack + * Opcode range: 0x0B + * Stack: f2.14 f2.14 --> + */ static void Ins_SFVFS( TT_ExecContext exc, FT_Long* args ) @@ -4425,12 +4481,12 @@ } - /*************************************************************************/ - /* */ - /* GPv[]: Get Projection Vector */ - /* Opcode range: 0x0C */ - /* Stack: ef2.14 --> ef2.14 */ - /* */ + /************************************************************************** + * + * GPv[]: Get Projection Vector + * Opcode range: 0x0C + * Stack: ef2.14 --> ef2.14 + */ static void Ins_GPV( TT_ExecContext exc, FT_Long* args ) @@ -4440,12 +4496,12 @@ } - /*************************************************************************/ - /* */ - /* GFv[]: Get Freedom Vector */ - /* Opcode range: 0x0D */ - /* Stack: ef2.14 --> ef2.14 */ - /* */ + /************************************************************************** + * + * GFv[]: Get Freedom Vector + * Opcode range: 0x0D + * Stack: ef2.14 --> ef2.14 + */ static void Ins_GFV( TT_ExecContext exc, FT_Long* args ) @@ -4455,12 +4511,12 @@ } - /*************************************************************************/ - /* */ - /* SRP0[]: Set Reference Point 0 */ - /* Opcode range: 0x10 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SRP0[]: Set Reference Point 0 + * Opcode range: 0x10 + * Stack: uint32 --> + */ static void Ins_SRP0( TT_ExecContext exc, FT_Long* args ) @@ -4469,12 +4525,12 @@ } - /*************************************************************************/ - /* */ - /* SRP1[]: Set Reference Point 1 */ - /* Opcode range: 0x11 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SRP1[]: Set Reference Point 1 + * Opcode range: 0x11 + * Stack: uint32 --> + */ static void Ins_SRP1( TT_ExecContext exc, FT_Long* args ) @@ -4483,12 +4539,12 @@ } - /*************************************************************************/ - /* */ - /* SRP2[]: Set Reference Point 2 */ - /* Opcode range: 0x12 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SRP2[]: Set Reference Point 2 + * Opcode range: 0x12 + * Stack: uint32 --> + */ static void Ins_SRP2( TT_ExecContext exc, FT_Long* args ) @@ -4497,12 +4553,12 @@ } - /*************************************************************************/ - /* */ - /* SMD[]: Set Minimum Distance */ - /* Opcode range: 0x1A */ - /* Stack: f26.6 --> */ - /* */ + /************************************************************************** + * + * SMD[]: Set Minimum Distance + * Opcode range: 0x1A + * Stack: f26.6 --> + */ static void Ins_SMD( TT_ExecContext exc, FT_Long* args ) @@ -4511,12 +4567,12 @@ } - /*************************************************************************/ - /* */ - /* SCVTCI[]: Set Control Value Table Cut In */ - /* Opcode range: 0x1D */ - /* Stack: f26.6 --> */ - /* */ + /************************************************************************** + * + * SCVTCI[]: Set Control Value Table Cut In + * Opcode range: 0x1D + * Stack: f26.6 --> + */ static void Ins_SCVTCI( TT_ExecContext exc, FT_Long* args ) @@ -4525,12 +4581,12 @@ } - /*************************************************************************/ - /* */ - /* SSWCI[]: Set Single Width Cut In */ - /* Opcode range: 0x1E */ - /* Stack: f26.6 --> */ - /* */ + /************************************************************************** + * + * SSWCI[]: Set Single Width Cut In + * Opcode range: 0x1E + * Stack: f26.6 --> + */ static void Ins_SSWCI( TT_ExecContext exc, FT_Long* args ) @@ -4539,12 +4595,12 @@ } - /*************************************************************************/ - /* */ - /* SSW[]: Set Single Width */ - /* Opcode range: 0x1F */ - /* Stack: int32? --> */ - /* */ + /************************************************************************** + * + * SSW[]: Set Single Width + * Opcode range: 0x1F + * Stack: int32? --> + */ static void Ins_SSW( TT_ExecContext exc, FT_Long* args ) @@ -4554,12 +4610,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPON[]: Set auto-FLIP to ON */ - /* Opcode range: 0x4D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * FLIPON[]: Set auto-FLIP to ON + * Opcode range: 0x4D + * Stack: --> + */ static void Ins_FLIPON( TT_ExecContext exc ) { @@ -4567,12 +4623,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPOFF[]: Set auto-FLIP to OFF */ - /* Opcode range: 0x4E */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * FLIPOFF[]: Set auto-FLIP to OFF + * Opcode range: 0x4E + * Stack: --> + */ static void Ins_FLIPOFF( TT_ExecContext exc ) { @@ -4580,12 +4636,12 @@ } - /*************************************************************************/ - /* */ - /* SANGW[]: Set ANGle Weight */ - /* Opcode range: 0x7E */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SANGW[]: Set ANGle Weight + * Opcode range: 0x7E + * Stack: uint32 --> + */ static void Ins_SANGW( void ) { @@ -4593,12 +4649,12 @@ } - /*************************************************************************/ - /* */ - /* SDB[]: Set Delta Base */ - /* Opcode range: 0x5E */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SDB[]: Set Delta Base + * Opcode range: 0x5E + * Stack: uint32 --> + */ static void Ins_SDB( TT_ExecContext exc, FT_Long* args ) @@ -4607,12 +4663,12 @@ } - /*************************************************************************/ - /* */ - /* SDS[]: Set Delta Shift */ - /* Opcode range: 0x5F */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SDS[]: Set Delta Shift + * Opcode range: 0x5F + * Stack: uint32 --> + */ static void Ins_SDS( TT_ExecContext exc, FT_Long* args ) @@ -4624,12 +4680,12 @@ } - /*************************************************************************/ - /* */ - /* RTHG[]: Round To Half Grid */ - /* Opcode range: 0x19 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * RTHG[]: Round To Half Grid + * Opcode range: 0x19 + * Stack: --> + */ static void Ins_RTHG( TT_ExecContext exc ) { @@ -4638,12 +4694,12 @@ } - /*************************************************************************/ - /* */ - /* RTG[]: Round To Grid */ - /* Opcode range: 0x18 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * RTG[]: Round To Grid + * Opcode range: 0x18 + * Stack: --> + */ static void Ins_RTG( TT_ExecContext exc ) { @@ -4652,11 +4708,11 @@ } - /*************************************************************************/ - /* RTDG[]: Round To Double Grid */ - /* Opcode range: 0x3D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * RTDG[]: Round To Double Grid + * Opcode range: 0x3D + * Stack: --> + */ static void Ins_RTDG( TT_ExecContext exc ) { @@ -4665,11 +4721,11 @@ } - /*************************************************************************/ - /* RUTG[]: Round Up To Grid */ - /* Opcode range: 0x7C */ - /* Stack: --> */ - /* */ + /************************************************************************** + * RUTG[]: Round Up To Grid + * Opcode range: 0x7C + * Stack: --> + */ static void Ins_RUTG( TT_ExecContext exc ) { @@ -4678,12 +4734,12 @@ } - /*************************************************************************/ - /* */ - /* RDTG[]: Round Down To Grid */ - /* Opcode range: 0x7D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * RDTG[]: Round Down To Grid + * Opcode range: 0x7D + * Stack: --> + */ static void Ins_RDTG( TT_ExecContext exc ) { @@ -4692,12 +4748,12 @@ } - /*************************************************************************/ - /* */ - /* ROFF[]: Round OFF */ - /* Opcode range: 0x7A */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * ROFF[]: Round OFF + * Opcode range: 0x7A + * Stack: --> + */ static void Ins_ROFF( TT_ExecContext exc ) { @@ -4706,12 +4762,12 @@ } - /*************************************************************************/ - /* */ - /* SROUND[]: Super ROUND */ - /* Opcode range: 0x76 */ - /* Stack: Eint8 --> */ - /* */ + /************************************************************************** + * + * SROUND[]: Super ROUND + * Opcode range: 0x76 + * Stack: Eint8 --> + */ static void Ins_SROUND( TT_ExecContext exc, FT_Long* args ) @@ -4723,12 +4779,12 @@ } - /*************************************************************************/ - /* */ - /* S45ROUND[]: Super ROUND 45 degrees */ - /* Opcode range: 0x77 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * S45ROUND[]: Super ROUND 45 degrees + * Opcode range: 0x77 + * Stack: uint32 --> + */ static void Ins_S45ROUND( TT_ExecContext exc, FT_Long* args ) @@ -4740,15 +4796,15 @@ } - /*************************************************************************/ - /* */ - /* GC[a]: Get Coordinate projected onto */ - /* Opcode range: 0x46-0x47 */ - /* Stack: uint32 --> f26.6 */ - /* */ - /* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */ - /* along the dual projection vector! */ - /* */ + /************************************************************************** + * + * GC[a]: Get Coordinate projected onto + * Opcode range: 0x46-0x47 + * Stack: uint32 --> f26.6 + * + * XXX: UNDOCUMENTED: Measures from the original glyph must be taken + * along the dual projection vector! + */ static void Ins_GC( TT_ExecContext exc, FT_Long* args ) @@ -4777,16 +4833,16 @@ } - /*************************************************************************/ - /* */ - /* SCFS[]: Set Coordinate From Stack */ - /* Opcode range: 0x48 */ - /* Stack: f26.6 uint32 --> */ - /* */ - /* Formula: */ - /* */ - /* OA := OA + ( value - OA.p )/( f.p ) * f */ - /* */ + /************************************************************************** + * + * SCFS[]: Set Coordinate From Stack + * Opcode range: 0x48 + * Stack: f26.6 uint32 --> + * + * Formula: + * + * OA := OA + ( value - OA.p )/( f.p ) * f + */ static void Ins_SCFS( TT_ExecContext exc, FT_Long* args ) @@ -4815,21 +4871,21 @@ } - /*************************************************************************/ - /* */ - /* MD[a]: Measure Distance */ - /* Opcode range: 0x49-0x4A */ - /* Stack: uint32 uint32 --> f26.6 */ - /* */ - /* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */ - /* the dual projection vector. */ - /* */ - /* XXX: UNDOCUMENTED: Flag attributes are inverted! */ - /* 0 => measure distance in original outline */ - /* 1 => measure distance in grid-fitted outline */ - /* */ - /* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */ - /* */ + /************************************************************************** + * + * MD[a]: Measure Distance + * Opcode range: 0x49-0x4A + * Stack: uint32 uint32 --> f26.6 + * + * XXX: UNDOCUMENTED: Measure taken in the original glyph must be along + * the dual projection vector. + * + * XXX: UNDOCUMENTED: Flag attributes are inverted! + * 0 => measure distance in original outline + * 1 => measure distance in grid-fitted outline + * + * XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! + */ static void Ins_MD( TT_ExecContext exc, FT_Long* args ) @@ -4902,12 +4958,12 @@ } - /*************************************************************************/ - /* */ - /* SDPvTL[a]: Set Dual PVector to Line */ - /* Opcode range: 0x86-0x87 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * SDPvTL[a]: Set Dual PVector to Line + * Opcode range: 0x86-0x87 + * Stack: uint32 uint32 --> + */ static void Ins_SDPVTL( TT_ExecContext exc, FT_Long* args ) @@ -4985,12 +5041,12 @@ } - /*************************************************************************/ - /* */ - /* SZP0[]: Set Zone Pointer 0 */ - /* Opcode range: 0x13 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZP0[]: Set Zone Pointer 0 + * Opcode range: 0x13 + * Stack: uint32 --> + */ static void Ins_SZP0( TT_ExecContext exc, FT_Long* args ) @@ -5015,12 +5071,12 @@ } - /*************************************************************************/ - /* */ - /* SZP1[]: Set Zone Pointer 1 */ - /* Opcode range: 0x14 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZP1[]: Set Zone Pointer 1 + * Opcode range: 0x14 + * Stack: uint32 --> + */ static void Ins_SZP1( TT_ExecContext exc, FT_Long* args ) @@ -5045,12 +5101,12 @@ } - /*************************************************************************/ - /* */ - /* SZP2[]: Set Zone Pointer 2 */ - /* Opcode range: 0x15 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZP2[]: Set Zone Pointer 2 + * Opcode range: 0x15 + * Stack: uint32 --> + */ static void Ins_SZP2( TT_ExecContext exc, FT_Long* args ) @@ -5075,12 +5131,12 @@ } - /*************************************************************************/ - /* */ - /* SZPS[]: Set Zone PointerS */ - /* Opcode range: 0x16 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZPS[]: Set Zone PointerS + * Opcode range: 0x16 + * Stack: uint32 --> + */ static void Ins_SZPS( TT_ExecContext exc, FT_Long* args ) @@ -5110,12 +5166,12 @@ } - /*************************************************************************/ - /* */ - /* INSTCTRL[]: INSTruction ConTRoL */ - /* Opcode range: 0x8E */ - /* Stack: int32 int32 --> */ - /* */ + /************************************************************************** + * + * INSTCTRL[]: INSTruction ConTRoL + * Opcode range: 0x8E + * Stack: int32 int32 --> + */ static void Ins_INSTCTRL( TT_ExecContext exc, FT_Long* args ) @@ -5172,12 +5228,12 @@ } - /*************************************************************************/ - /* */ - /* SCANCTRL[]: SCAN ConTRoL */ - /* Opcode range: 0x85 */ - /* Stack: uint32? --> */ - /* */ + /************************************************************************** + * + * SCANCTRL[]: SCAN ConTRoL + * Opcode range: 0x85 + * Stack: uint32? --> + */ static void Ins_SCANCTRL( TT_ExecContext exc, FT_Long* args ) @@ -5219,12 +5275,12 @@ } - /*************************************************************************/ - /* */ - /* SCANTYPE[]: SCAN TYPE */ - /* Opcode range: 0x8D */ - /* Stack: uint16 --> */ - /* */ + /************************************************************************** + * + * SCANTYPE[]: SCAN TYPE + * Opcode range: 0x8D + * Stack: uint16 --> + */ static void Ins_SCANTYPE( TT_ExecContext exc, FT_Long* args ) @@ -5234,19 +5290,19 @@ } - /*************************************************************************/ - /* */ - /* MANAGING OUTLINES */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MANAGING OUTLINES + * + */ - /*************************************************************************/ - /* */ - /* FLIPPT[]: FLIP PoinT */ - /* Opcode range: 0x80 */ - /* Stack: uint32... --> */ - /* */ + /************************************************************************** + * + * FLIPPT[]: FLIP PoinT + * Opcode range: 0x80 + * Stack: uint32... --> + */ static void Ins_FLIPPT( TT_ExecContext exc ) { @@ -5295,12 +5351,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPRGON[]: FLIP RanGe ON */ - /* Opcode range: 0x81 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * FLIPRGON[]: FLIP RanGe ON + * Opcode range: 0x81 + * Stack: uint32 uint32 --> + */ static void Ins_FLIPRGON( TT_ExecContext exc, FT_Long* args ) @@ -5333,12 +5389,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPRGOFF: FLIP RanGe OFF */ - /* Opcode range: 0x82 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * FLIPRGOFF: FLIP RanGe OFF + * Opcode range: 0x82 + * Stack: uint32 uint32 --> + */ static void Ins_FLIPRGOFF( TT_ExecContext exc, FT_Long* args ) @@ -5450,12 +5506,12 @@ } - /*************************************************************************/ - /* */ - /* SHP[a]: SHift Point by the last point */ - /* Opcode range: 0x32-0x33 */ - /* Stack: uint32... --> */ - /* */ + /************************************************************************** + * + * SHP[a]: SHift Point by the last point + * Opcode range: 0x32-0x33 + * Stack: uint32... --> + */ static void Ins_SHP( TT_ExecContext exc ) { @@ -5507,16 +5563,16 @@ } - /*************************************************************************/ - /* */ - /* SHC[a]: SHift Contour */ - /* Opcode range: 0x34-35 */ - /* Stack: uint32 --> */ - /* */ - /* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */ - /* contour in the twilight zone, namely contour number */ - /* zero which includes all points of it. */ - /* */ + /************************************************************************** + * + * SHC[a]: SHift Contour + * Opcode range: 0x34-35 + * Stack: uint32 --> + * + * UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) + * contour in the twilight zone, namely contour number + * zero which includes all points of it. + */ static void Ins_SHC( TT_ExecContext exc, FT_Long* args ) @@ -5563,12 +5619,12 @@ } - /*************************************************************************/ - /* */ - /* SHZ[a]: SHift Zone */ - /* Opcode range: 0x36-37 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SHZ[a]: SHift Zone + * Opcode range: 0x36-37 + * Stack: uint32 --> + */ static void Ins_SHZ( TT_ExecContext exc, FT_Long* args ) @@ -5611,12 +5667,12 @@ } - /*************************************************************************/ - /* */ - /* SHPIX[]: SHift points by a PIXel amount */ - /* Opcode range: 0x38 */ - /* Stack: f26.6 uint32... --> */ - /* */ + /************************************************************************** + * + * SHPIX[]: SHift points by a PIXel amount + * Opcode range: 0x38 + * Stack: f26.6 uint32... --> + */ static void Ins_SHPIX( TT_ExecContext exc, FT_Long* args ) @@ -5771,12 +5827,12 @@ } - /*************************************************************************/ - /* */ - /* MSIRP[a]: Move Stack Indirect Relative Position */ - /* Opcode range: 0x3A-0x3B */ - /* Stack: f26.6 uint32 --> */ - /* */ + /************************************************************************** + * + * MSIRP[a]: Move Stack Indirect Relative Position + * Opcode range: 0x3A-0x3B + * Stack: f26.6 uint32 --> + */ static void Ins_MSIRP( TT_ExecContext exc, FT_Long* args ) @@ -5846,12 +5902,12 @@ } - /*************************************************************************/ - /* */ - /* MDAP[a]: Move Direct Absolute Point */ - /* Opcode range: 0x2E-0x2F */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * MDAP[a]: Move Direct Absolute Point + * Opcode range: 0x2E-0x2F + * Stack: uint32 --> + */ static void Ins_MDAP( TT_ExecContext exc, FT_Long* args ) @@ -5900,12 +5956,12 @@ } - /*************************************************************************/ - /* */ - /* MIAP[a]: Move Indirect Absolute Point */ - /* Opcode range: 0x3E-0x3F */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * MIAP[a]: Move Indirect Absolute Point + * Opcode range: 0x3E-0x3F + * Stack: uint32 uint32 --> + */ static void Ins_MIAP( TT_ExecContext exc, FT_Long* args ) @@ -6020,12 +6076,12 @@ } - /*************************************************************************/ - /* */ - /* MDRP[abcde]: Move Direct Relative Point */ - /* Opcode range: 0xC0-0xDF */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * MDRP[abcde]: Move Direct Relative Point + * Opcode range: 0xC0-0xDF + * Stack: uint32 --> + */ static void Ins_MDRP( TT_ExecContext exc, FT_Long* args ) @@ -6164,12 +6220,12 @@ } - /*************************************************************************/ - /* */ - /* MIRP[abcde]: Move Indirect Relative Point */ - /* Opcode range: 0xE0-0xFF */ - /* Stack: int32? uint32 --> */ - /* */ + /************************************************************************** + * + * MIRP[abcde]: Move Indirect Relative Point + * Opcode range: 0xE0-0xFF + * Stack: int32? uint32 --> + */ static void Ins_MIRP( TT_ExecContext exc, FT_Long* args ) @@ -6189,6 +6245,8 @@ FT_Bool reverse_move = FALSE; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ + FT_F26Dot6 delta; + minimum_distance = exc->GS.minimum_distance; control_value_cutin = exc->GS.control_value_cutin; @@ -6221,8 +6279,11 @@ /* single width test */ - if ( FT_ABS( cvt_dist - exc->GS.single_width_value ) < - exc->GS.single_width_cutin ) + delta = SUB_LONG( cvt_dist, exc->GS.single_width_value ); + if ( delta < 0 ) + delta = NEG_LONG( delta ); + + if ( delta < exc->GS.single_width_cutin ) { if ( cvt_dist >= 0 ) cvt_dist = exc->GS.single_width_value; @@ -6251,7 +6312,7 @@ if ( exc->GS.auto_flip ) { if ( ( org_dist ^ cvt_dist ) < 0 ) - cvt_dist = -cvt_dist; + cvt_dist = NEG_LONG( cvt_dist ); } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY @@ -6276,9 +6337,6 @@ if ( exc->GS.gep0 == exc->GS.gep1 ) { - FT_F26Dot6 delta; - - /* XXX: According to Greg Hitchcock, the following wording is */ /* the right one: */ /* */ @@ -6313,9 +6371,6 @@ exc->ignore_x_mode && exc->GS.gep0 == exc->GS.gep1 ) { - FT_F26Dot6 delta; - - delta = SUB_LONG( cvt_dist, org_dist ); if ( delta < 0 ) delta = NEG_LONG( delta ); @@ -6412,12 +6467,12 @@ } - /*************************************************************************/ - /* */ - /* ALIGNRP[]: ALIGN Relative Point */ - /* Opcode range: 0x3C */ - /* Stack: uint32 uint32... --> */ - /* */ + /************************************************************************** + * + * ALIGNRP[]: ALIGN Relative Point + * Opcode range: 0x3C + * Stack: uint32 uint32... --> + */ static void Ins_ALIGNRP( TT_ExecContext exc ) { @@ -6475,12 +6530,12 @@ } - /*************************************************************************/ - /* */ - /* ISECT[]: moves point to InterSECTion */ - /* Opcode range: 0x0F */ - /* Stack: 5 * uint32 --> */ - /* */ + /************************************************************************** + * + * ISECT[]: moves point to InterSECTion + * Opcode range: 0x0F + * Stack: 5 * uint32 --> + */ static void Ins_ISECT( TT_ExecContext exc, FT_Long* args ) @@ -6571,12 +6626,12 @@ } - /*************************************************************************/ - /* */ - /* ALIGNPTS[]: ALIGN PoinTS */ - /* Opcode range: 0x27 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * ALIGNPTS[]: ALIGN PoinTS + * Opcode range: 0x27 + * Stack: uint32 uint32 --> + */ static void Ins_ALIGNPTS( TT_ExecContext exc, FT_Long* args ) @@ -6603,12 +6658,12 @@ } - /*************************************************************************/ - /* */ - /* IP[]: Interpolate Point */ - /* Opcode range: 0x39 */ - /* Stack: uint32... --> */ - /* */ + /************************************************************************** + * + * IP[]: Interpolate Point + * Opcode range: 0x39 + * Stack: uint32... --> + */ /* SOMETIMES, DUMBER CODE IS BETTER CODE */ @@ -6763,12 +6818,12 @@ } - /*************************************************************************/ - /* */ - /* UTP[a]: UnTouch Point */ - /* Opcode range: 0x29 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * UTP[a]: UnTouch Point + * Opcode range: 0x29 + * Stack: uint32 --> + */ static void Ins_UTP( TT_ExecContext exc, FT_Long* args ) @@ -6932,12 +6987,12 @@ } - /*************************************************************************/ - /* */ - /* IUP[a]: Interpolate Untouched Points */ - /* Opcode range: 0x30-0x31 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * IUP[a]: Interpolate Untouched Points + * Opcode range: 0x30-0x31 + * Stack: --> + */ static void Ins_IUP( TT_ExecContext exc ) { @@ -7060,12 +7115,12 @@ } - /*************************************************************************/ - /* */ - /* DELTAPn[]: DELTA exceptions P1, P2, P3 */ - /* Opcode range: 0x5D,0x71,0x72 */ - /* Stack: uint32 (2 * uint32)... --> */ - /* */ + /************************************************************************** + * + * DELTAPn[]: DELTA exceptions P1, P2, P3 + * Opcode range: 0x5D,0x71,0x72 + * Stack: uint32 (2 * uint32)... --> + */ static void Ins_DELTAP( TT_ExecContext exc, FT_Long* args ) @@ -7142,12 +7197,12 @@ if ( SUBPIXEL_HINTING_INFINALITY ) { /* - * Allow delta move if + * Allow delta move if * - * - not using ignore_x_mode rendering, - * - glyph is specifically set to allow it, or - * - glyph is composite and freedom vector is not in subpixel - * direction. + * - not using ignore_x_mode rendering, + * - glyph is specifically set to allow it, or + * - glyph is composite and freedom vector is not in subpixel + * direction. */ if ( !exc->ignore_x_mode || ( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) || @@ -7227,12 +7282,12 @@ } - /*************************************************************************/ - /* */ - /* DELTACn[]: DELTA exceptions C1, C2, C3 */ - /* Opcode range: 0x73,0x74,0x75 */ - /* Stack: uint32 (2 * uint32)... --> */ - /* */ + /************************************************************************** + * + * DELTACn[]: DELTA exceptions C1, C2, C3 + * Opcode range: 0x73,0x74,0x75 + * Stack: uint32 (2 * uint32)... --> + */ static void Ins_DELTAC( TT_ExecContext exc, FT_Long* args ) @@ -7305,27 +7360,27 @@ } - /*************************************************************************/ - /* */ - /* MISC. INSTRUCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MISC. INSTRUCTIONS + * + */ - /*************************************************************************/ - /* */ - /* GETINFO[]: GET INFOrmation */ - /* Opcode range: 0x88 */ - /* Stack: uint32 --> uint32 */ - /* */ - /* XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May */ - /* 2015) not documented in the OpenType specification. */ - /* */ - /* Selector bit 11 is incorrectly described as bit 8, while the */ - /* real meaning of bit 8 (vertical LCD subpixels) stays */ - /* undocumented. The same mistake can be found in Greg Hitchcock's */ - /* whitepaper. */ - /* */ + /************************************************************************** + * + * GETINFO[]: GET INFOrmation + * Opcode range: 0x88 + * Stack: uint32 --> uint32 + * + * XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May + * 2015) not documented in the OpenType specification. + * + * Selector bit 11 is incorrectly described as bit 8, while the + * real meaning of bit 8 (vertical LCD subpixels) stays + * undocumented. The same mistake can be found in Greg Hitchcock's + * whitepaper. + */ static void Ins_GETINFO( TT_ExecContext exc, FT_Long* args ) @@ -7337,11 +7392,11 @@ K = 0; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - /********************************/ - /* RASTERIZER VERSION */ - /* Selector Bit: 0 */ - /* Return Bit(s): 0-7 */ - /* */ + /********************************* + * RASTERIZER VERSION + * Selector Bit: 0 + * Return Bit(s): 0-7 + */ if ( SUBPIXEL_HINTING_INFINALITY && ( args[0] & 1 ) != 0 && exc->subpixel_hinting ) @@ -7362,39 +7417,40 @@ if ( ( args[0] & 1 ) != 0 ) K = driver->interpreter_version; - /********************************/ - /* GLYPH ROTATED */ - /* Selector Bit: 1 */ - /* Return Bit(s): 8 */ - /* */ + /********************************* + * GLYPH ROTATED + * Selector Bit: 1 + * Return Bit(s): 8 + */ if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated ) K |= 1 << 8; - /********************************/ - /* GLYPH STRETCHED */ - /* Selector Bit: 2 */ - /* Return Bit(s): 9 */ - /* */ + /********************************* + * GLYPH STRETCHED + * Selector Bit: 2 + * Return Bit(s): 9 + */ if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched ) K |= 1 << 9; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /********************************/ - /* VARIATION GLYPH */ - /* Selector Bit: 3 */ - /* Return Bit(s): 10 */ - /* */ - /* XXX: UNDOCUMENTED! */ + /********************************* + * VARIATION GLYPH + * Selector Bit: 3 + * Return Bit(s): 10 + * + * XXX: UNDOCUMENTED! + */ if ( (args[0] & 8 ) != 0 && exc->face->blend ) K |= 1 << 10; #endif - /********************************/ - /* BI-LEVEL HINTING AND */ - /* GRAYSCALE RENDERING */ - /* Selector Bit: 5 */ - /* Return Bit(s): 12 */ - /* */ + /********************************* + * BI-LEVEL HINTING AND + * GRAYSCALE RENDERING + * Selector Bit: 5 + * Return Bit(s): 12 + */ if ( ( args[0] & 32 ) != 0 && exc->grayscale ) K |= 1 << 12; @@ -7405,50 +7461,54 @@ /* Bold Italic'. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean ) { - /********************************/ - /* HINTING FOR SUBPIXEL */ - /* Selector Bit: 6 */ - /* Return Bit(s): 13 */ - /* */ - /* v40 does subpixel hinting by default. */ + /********************************* + * HINTING FOR SUBPIXEL + * Selector Bit: 6 + * Return Bit(s): 13 + * + * v40 does subpixel hinting by default. + */ if ( ( args[0] & 64 ) != 0 ) K |= 1 << 13; - /********************************/ - /* VERTICAL LCD SUBPIXELS? */ - /* Selector Bit: 8 */ - /* Return Bit(s): 15 */ - /* */ + /********************************* + * VERTICAL LCD SUBPIXELS? + * Selector Bit: 8 + * Return Bit(s): 15 + */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean ) K |= 1 << 15; - /********************************/ - /* SUBPIXEL POSITIONED? */ - /* Selector Bit: 10 */ - /* Return Bit(s): 17 */ - /* */ - /* XXX: FreeType supports it, dependent on what client does? */ + /********************************* + * SUBPIXEL POSITIONED? + * Selector Bit: 10 + * Return Bit(s): 17 + * + * XXX: FreeType supports it, dependent on what client does? + */ if ( ( args[0] & 1024 ) != 0 ) K |= 1 << 17; - /********************************/ - /* SYMMETRICAL SMOOTHING */ - /* Selector Bit: 11 */ - /* Return Bit(s): 18 */ - /* */ - /* The only smoothing method FreeType supports unless someone sets */ - /* FT_LOAD_TARGET_MONO. */ + /********************************* + * SYMMETRICAL SMOOTHING + * Selector Bit: 11 + * Return Bit(s): 18 + * + * The only smoothing method FreeType supports unless someone sets + * FT_LOAD_TARGET_MONO. + */ if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean ) K |= 1 << 18; - /********************************/ - /* CLEARTYPE HINTING AND */ - /* GRAYSCALE RENDERING */ - /* Selector Bit: 12 */ - /* Return Bit(s): 19 */ - /* */ - /* Grayscale rendering is what FreeType does anyway unless someone */ - /* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */ + /********************************* + * CLEARTYPE HINTING AND + * GRAYSCALE RENDERING + * Selector Bit: 12 + * Return Bit(s): 19 + * + * Grayscale rendering is what FreeType does anyway unless someone + * sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) + */ if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype ) K |= 1 << 19; } @@ -7462,67 +7522,73 @@ if ( exc->rasterizer_version >= 37 ) { - /********************************/ - /* HINTING FOR SUBPIXEL */ - /* Selector Bit: 6 */ - /* Return Bit(s): 13 */ - /* */ + /********************************* + * HINTING FOR SUBPIXEL + * Selector Bit: 6 + * Return Bit(s): 13 + */ if ( ( args[0] & 64 ) != 0 && exc->subpixel_hinting ) K |= 1 << 13; - /********************************/ - /* COMPATIBLE WIDTHS ENABLED */ - /* Selector Bit: 7 */ - /* Return Bit(s): 14 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * COMPATIBLE WIDTHS ENABLED + * Selector Bit: 7 + * Return Bit(s): 14 + * + * Functionality still needs to be added + */ if ( ( args[0] & 128 ) != 0 && exc->compatible_widths ) K |= 1 << 14; - /********************************/ - /* VERTICAL LCD SUBPIXELS? */ - /* Selector Bit: 8 */ - /* Return Bit(s): 15 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * VERTICAL LCD SUBPIXELS? + * Selector Bit: 8 + * Return Bit(s): 15 + * + * Functionality still needs to be added + */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd ) K |= 1 << 15; - /********************************/ - /* HINTING FOR BGR? */ - /* Selector Bit: 9 */ - /* Return Bit(s): 16 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * HINTING FOR BGR? + * Selector Bit: 9 + * Return Bit(s): 16 + * + * Functionality still needs to be added + */ if ( ( args[0] & 512 ) != 0 && exc->bgr ) K |= 1 << 16; if ( exc->rasterizer_version >= 38 ) { - /********************************/ - /* SUBPIXEL POSITIONED? */ - /* Selector Bit: 10 */ - /* Return Bit(s): 17 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * SUBPIXEL POSITIONED? + * Selector Bit: 10 + * Return Bit(s): 17 + * + * Functionality still needs to be added + */ if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned ) K |= 1 << 17; - /********************************/ - /* SYMMETRICAL SMOOTHING */ - /* Selector Bit: 11 */ - /* Return Bit(s): 18 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * SYMMETRICAL SMOOTHING + * Selector Bit: 11 + * Return Bit(s): 18 + * + * Functionality still needs to be added + */ if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing ) K |= 1 << 18; - /********************************/ - /* GRAY CLEARTYPE */ - /* Selector Bit: 12 */ - /* Return Bit(s): 19 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * GRAY CLEARTYPE + * Selector Bit: 12 + * Return Bit(s): 19 + * + * Functionality still needs to be added + */ if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype ) K |= 1 << 19; } @@ -7537,16 +7603,16 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /*************************************************************************/ - /* */ - /* GETVARIATION[]: get normalized variation (blend) coordinates */ - /* Opcode range: 0x91 */ - /* Stack: --> f2.14... */ - /* */ - /* XXX: UNDOCUMENTED! There is no official documentation from Apple for */ - /* this bytecode instruction. Active only if a font has GX */ - /* variation axes. */ - /* */ + /************************************************************************** + * + * GETVARIATION[]: get normalized variation (blend) coordinates + * Opcode range: 0x91 + * Stack: --> f2.14... + * + * XXX: UNDOCUMENTED! There is no official documentation from Apple for + * this bytecode instruction. Active only if a font has GX + * variation axes. + */ static void Ins_GETVARIATION( TT_ExecContext exc, FT_Long* args ) @@ -7576,15 +7642,15 @@ } - /*************************************************************************/ - /* */ - /* GETDATA[]: no idea what this is good for */ - /* Opcode range: 0x92 */ - /* Stack: --> 17 */ - /* */ - /* XXX: UNDOCUMENTED! There is no documentation from Apple for this */ - /* very weird bytecode instruction. */ - /* */ + /************************************************************************** + * + * GETDATA[]: no idea what this is good for + * Opcode range: 0x92 + * Stack: --> 17 + * + * XXX: UNDOCUMENTED! There is no documentation from Apple for this + * very weird bytecode instruction. + */ static void Ins_GETDATA( FT_Long* args ) { @@ -7632,34 +7698,34 @@ } - /*************************************************************************/ - /* */ - /* RUN */ - /* */ - /* This function executes a run of opcodes. It will exit in the */ - /* following cases: */ - /* */ - /* - Errors (in which case it returns FALSE). */ - /* */ - /* - Reaching the end of the main code range (returns TRUE). */ - /* Reaching the end of a code range within a function call is an */ - /* error. */ - /* */ - /* - After executing one single opcode, if the flag `Instruction_Trap' */ - /* is set to TRUE (returns TRUE). */ - /* */ - /* On exit with TRUE, test IP < CodeSize to know whether it comes from */ - /* an instruction trap or a normal termination. */ - /* */ - /* */ - /* Note: The documented DEBUG opcode pops a value from the stack. This */ - /* behaviour is unsupported; here a DEBUG opcode is always an */ - /* error. */ - /* */ - /* */ - /* THIS IS THE INTERPRETER'S MAIN LOOP. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * RUN + * + * This function executes a run of opcodes. It will exit in the + * following cases: + * + * - Errors (in which case it returns FALSE). + * + * - Reaching the end of the main code range (returns TRUE). + * Reaching the end of a code range within a function call is an + * error. + * + * - After executing one single opcode, if the flag `Instruction_Trap' + * is set to TRUE (returns TRUE). + * + * On exit with TRUE, test IP < CodeSize to know whether it comes from + * an instruction trap or a normal termination. + * + * + * Note: The documented DEBUG opcode pops a value from the stack. This + * behaviour is unsupported; here a DEBUG opcode is always an + * error. + * + * + * THIS IS THE INTERPRETER'S MAIN LOOP. + * + */ /* documentation is in ttinterp.h */ @@ -7691,16 +7757,16 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* - * Toggle backward compatibility according to what font wants, except - * when + * Toggle backward compatibility according to what font wants, except + * when * - * 1) we have a `tricky' font that heavily relies on the interpreter to - * render glyphs correctly, for example DFKai-SB, or - * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. + * 1) we have a `tricky' font that heavily relies on the interpreter to + * render glyphs correctly, for example DFKai-SB, or + * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. * - * In those cases, backward compatibility needs to be turned off to get - * correct rendering. The rendering is then completely up to the - * font's programming. + * In those cases, backward compatibility needs to be turned off to get + * correct rendering. The rendering is then completely up to the + * font's programming. * */ if ( SUBPIXEL_HINTING_MINIMAL && @@ -7801,7 +7867,7 @@ /* and the first few stack elements also */ FT_TRACE6(( " " )); FT_TRACE7(( "%06d ", exc->IP )); - FT_TRACE6(( opcode_name[exc->opcode] + 2 )); + FT_TRACE6(( "%s", opcode_name[exc->opcode] + 2 )); FT_TRACE7(( "%*s", *opcode_name[exc->opcode] == 'A' ? 2 : 12 - ( *opcode_name[exc->opcode] - '0' ), diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h index 2966439ea25..0cb1e892fb8 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttinterp.h */ -/* */ -/* TrueType bytecode interpreter (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttinterp.h + * + * TrueType bytecode interpreter (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTINTERP_H_ @@ -26,10 +26,10 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* Rounding mode constants. */ - /* */ + /************************************************************************** + * + * Rounding mode constants. + */ #define TT_Round_Off 5 #define TT_Round_To_Half_Grid 0 #define TT_Round_To_Grid 1 @@ -40,13 +40,13 @@ FT_BEGIN_HEADER #define TT_Round_Super_45 7 - /*************************************************************************/ - /* */ - /* Function types used by the interpreter, depending on various modes */ - /* (e.g. the rounding mode, whether to render a vertical or horizontal */ - /* line etc). */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Function types used by the interpreter, depending on various modes + * (e.g. the rounding mode, whether to render a vertical or horizontal + * line etc). + * + */ /* Rounding function */ typedef FT_F26Dot6 @@ -84,10 +84,10 @@ FT_BEGIN_HEADER FT_F26Dot6 value ); - /*************************************************************************/ - /* */ - /* This structure defines a call record, used to manage function calls. */ - /* */ + /************************************************************************** + * + * This structure defines a call record, used to manage function calls. + */ typedef struct TT_CallRec_ { FT_Int Caller_Range; @@ -101,11 +101,11 @@ FT_BEGIN_HEADER #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - /*************************************************************************/ - /* */ - /* These structures define rules used to tweak subpixel hinting for */ - /* various fonts. "", 0, "", NULL value indicates to match any value. */ - /* */ + /************************************************************************** + * + * These structures define rules used to tweak subpixel hinting for + * various fonts. "", 0, "", NULL value indicates to match any value. + */ #define SPH_MAX_NAME_SIZE 32 #define SPH_MAX_CLASS_MEMBERS 100 @@ -141,11 +141,11 @@ FT_BEGIN_HEADER #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ - /*************************************************************************/ - /* */ - /* The main structure for the interpreter which collects all necessary */ - /* variables and states. */ - /* */ + /************************************************************************** + * + * The main structure for the interpreter which collects all necessary + * variables and states. + */ typedef struct TT_ExecContextRec_ { TT_Face face; @@ -352,7 +352,7 @@ FT_BEGIN_HEADER * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx * * [3] Beat Stamm describes it in more detail: - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec12 + * http://rastertragedy.com/RTRCh4.htm#Sec12. * * [4] The list of `native ClearType' fonts is small at the time of this * writing; I found the following on a Windows 10 Update 1511 @@ -464,26 +464,27 @@ FT_BEGIN_HEADER #endif /* TT_USE_BYTECODE_INTERPRETER */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_New_Context */ - /* */ - /* <Description> */ - /* Queries the face context for a given font. Note that there is */ - /* now a _single_ execution context in the TrueType driver which is */ - /* shared among faces. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* A handle to the execution context. Initialized for `face'. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* (And right now only the glyph loader uses it.) */ - /* */ + /************************************************************************** + * + * @Function: + * TT_New_Context + * + * @Description: + * Queries the face context for a given font. Note that there is + * now a _single_ execution context in the TrueType driver which is + * shared among faces. + * + * @Input: + * face :: + * A handle to the source face object. + * + * @Return: + * A handle to the execution context. Initialized for `face'. + * + * @Note: + * Only the glyph loader and debugger should call this function. + * (And right now only the glyph loader uses it.) + */ FT_EXPORT( TT_ExecContext ) TT_New_Context( TT_Driver driver ); @@ -506,27 +507,28 @@ FT_BEGIN_HEADER #endif /* TT_USE_BYTECODE_INTERPRETER */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_RunIns */ - /* */ - /* <Description> */ - /* Executes one or more instruction in the execution context. This */ - /* is the main function of the TrueType opcode interpreter. */ - /* */ - /* <Input> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only the object manager and debugger should call this function. */ - /* */ - /* This function is publicly exported because it is directly */ - /* invoked by the TrueType debugger. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_RunIns + * + * @Description: + * Executes one or more instruction in the execution context. This + * is the main function of the TrueType opcode interpreter. + * + * @Input: + * exec :: + * A handle to the target execution context. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only the object manager and debugger should call this function. + * + * This function is publicly exported because it is directly + * invoked by the TrueType debugger. + */ FT_EXPORT( FT_Error ) TT_RunIns( TT_ExecContext exec ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c index 6685dc81960..f3a432cedd6 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttobjs.c */ -/* */ -/* Objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttobjs.c + * + * Objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -36,36 +36,37 @@ #include "ttgxvar.h" #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttobjs +#define FT_COMPONENT ttobjs #ifdef TT_USE_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* GLYPH ZONE FUNCTIONS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_glyphzone_done */ - /* */ - /* <Description> */ - /* Deallocate a glyph zone. */ - /* */ - /* <Input> */ - /* zone :: A pointer to the target glyph zone. */ - /* */ + /************************************************************************** + * + * GLYPH ZONE FUNCTIONS + * + */ + + + /************************************************************************** + * + * @Function: + * tt_glyphzone_done + * + * @Description: + * Deallocate a glyph zone. + * + * @Input: + * zone :: + * A pointer to the target glyph zone. + */ FT_LOCAL_DEF( void ) tt_glyphzone_done( TT_GlyphZone zone ) { @@ -87,27 +88,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_glyphzone_new */ - /* */ - /* <Description> */ - /* Allocate a new glyph zone. */ - /* */ - /* <Input> */ - /* memory :: A handle to the current memory object. */ - /* */ - /* maxPoints :: The capacity of glyph zone in points. */ - /* */ - /* maxContours :: The capacity of glyph zone in contours. */ - /* */ - /* <Output> */ - /* zone :: A pointer to the target glyph zone record. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_glyphzone_new + * + * @Description: + * Allocate a new glyph zone. + * + * @Input: + * memory :: + * A handle to the current memory object. + * + * maxPoints :: + * The capacity of glyph zone in points. + * + * maxContours :: + * The capacity of glyph zone in contours. + * + * @Output: + * zone :: + * A pointer to the target glyph zone record. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_glyphzone_new( FT_Memory memory, FT_UShort maxPoints, @@ -566,32 +571,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_init */ - /* */ - /* <Description> */ - /* Initialize a given TrueType face object. */ - /* */ - /* <Input> */ - /* stream :: The source font stream. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection, in bits 0-15. The numbered instance */ - /* index~+~1 of a GX (sub)font, if applicable, in bits */ - /* 16-30. */ - /* */ - /* num_params :: Number of additional generic parameters. Ignored. */ - /* */ - /* params :: Additional generic parameters. Ignored. */ - /* */ - /* <InOut> */ - /* face :: The newly built face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_init + * + * @Description: + * Initialize a given TrueType face object. + * + * @Input: + * stream :: + * The source font stream. + * + * face_index :: + * The index of the TrueType font, if we are opening a + * collection, in bits 0-15. The numbered instance + * index~+~1 of a GX (sub)font, if applicable, in bits + * 16-30. + * + * num_params :: + * Number of additional generic parameters. Ignored. + * + * params :: + * Additional generic parameters. Ignored. + * + * @InOut: + * face :: + * The newly built face object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ @@ -743,17 +753,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_done */ - /* */ - /* <Description> */ - /* Finalize a given face object. */ - /* */ - /* <Input> */ - /* face :: A pointer to the face object to destroy. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_done + * + * @Description: + * Finalize a given face object. + * + * @Input: + * face :: + * A pointer to the face object to destroy. + */ FT_LOCAL_DEF( void ) tt_face_done( FT_Face ttface ) /* TT_Face */ { @@ -799,30 +810,32 @@ } - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ #ifdef TT_USE_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_run_fpgm */ - /* */ - /* <Description> */ - /* Run the font program. */ - /* */ - /* <Input> */ - /* size :: A handle to the size object. */ - /* */ - /* pedantic :: Set if bytecode execution should be pedantic. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_run_fpgm + * + * @Description: + * Run the font program. + * + * @Input: + * size :: + * A handle to the size object. + * + * pedantic :: + * Set if bytecode execution should be pedantic. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_size_run_fpgm( TT_Size size, FT_Bool pedantic ) @@ -899,22 +912,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_run_prep */ - /* */ - /* <Description> */ - /* Run the control value program. */ - /* */ - /* <Input> */ - /* size :: A handle to the size object. */ - /* */ - /* pedantic :: Set if bytecode execution should be pedantic. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_run_prep + * + * @Description: + * Run the control value program. + * + * @Input: + * size :: + * A handle to the size object. + * + * pedantic :: + * Set if bytecode execution should be pedantic. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_size_run_prep( TT_Size size, FT_Bool pedantic ) @@ -1159,10 +1174,16 @@ TT_Face face = (TT_Face)size->root.face; - /* Scale the cvt values to the new ppem. */ - /* We use by default the y ppem to scale the CVT. */ + /* Scale the cvt values to the new ppem. */ + /* By default, we use the y ppem value for scaling. */ + FT_TRACE6(( "CVT values:\n" )); for ( i = 0; i < size->cvt_size; i++ ) + { size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); + FT_TRACE6(( " %3d: %d (%f)\n", + i, face->cvt[i], size->cvt[i] / 64.0 )); + } + FT_TRACE6(( "\n" )); /* all twilight points are originally zero */ for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) @@ -1191,20 +1212,21 @@ #endif /* TT_USE_BYTECODE_INTERPRETER */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_init */ - /* */ - /* <Description> */ - /* Initialize a new TrueType size object. */ - /* */ - /* <InOut> */ - /* size :: A handle to the size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_init + * + * @Description: + * Initialize a new TrueType size object. + * + * @InOut: + * size :: + * A handle to the size object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_size_init( FT_Size ttsize ) /* TT_Size */ { @@ -1224,17 +1246,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_done */ - /* */ - /* <Description> */ - /* The TrueType size object finalizer. */ - /* */ - /* <Input> */ - /* size :: A handle to the target size object. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_done + * + * @Description: + * The TrueType size object finalizer. + * + * @Input: + * size :: + * A handle to the target size object. + */ FT_LOCAL_DEF( void ) tt_size_done( FT_Size ttsize ) /* TT_Size */ { @@ -1249,22 +1272,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_reset */ - /* */ - /* <Description> */ - /* Reset a TrueType size when resolutions and character dimensions */ - /* have been changed. */ - /* */ - /* <Input> */ - /* size :: A handle to the target size object. */ - /* */ - /* only_height :: Only recompute ascender, descender, and height; */ - /* this flag is used for variation fonts where */ - /* `tt_size_reset' is used as an iterator function. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_reset + * + * @Description: + * Reset a TrueType size when resolutions and character dimensions + * have been changed. + * + * @Input: + * size :: + * A handle to the target size object. + * + * only_height :: + * Only recompute ascender, descender, and height; + * this flag is used for variation fonts where + * `tt_size_reset' is used as an iterator function. + */ FT_LOCAL_DEF( FT_Error ) tt_size_reset( TT_Size size, FT_Bool only_height ) @@ -1358,20 +1383,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_driver_init */ - /* */ - /* <Description> */ - /* Initialize a given TrueType driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_driver_init + * + * @Description: + * Initialize a given TrueType driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ { @@ -1398,17 +1424,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_driver_done */ - /* */ - /* <Description> */ - /* Finalize a given TrueType driver. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target TrueType driver. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_driver_done + * + * @Description: + * Finalize a given TrueType driver. + * + * @Input: + * driver :: + * A handle to the target TrueType driver. + */ FT_LOCAL_DEF( void ) tt_driver_done( FT_Module ttdriver ) /* TT_Driver */ { @@ -1416,20 +1443,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_slot_init */ - /* */ - /* <Description> */ - /* Initialize a new slot object. */ - /* */ - /* <InOut> */ - /* slot :: A handle to the slot object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_slot_init + * + * @Description: + * Initialize a new slot object. + * + * @InOut: + * slot :: + * A handle to the slot object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_slot_init( FT_GlyphSlot slot ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h index 38fa30e4e9f..9fc654d5d10 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttobjs.h */ -/* */ -/* Objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttobjs.h + * + * Objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTOBJS_H_ @@ -28,40 +28,40 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Driver */ - /* */ - /* <Description> */ - /* A handle to a TrueType driver object. */ - /* */ + /************************************************************************** + * + * @Type: + * TT_Driver + * + * @Description: + * A handle to a TrueType driver object. + */ typedef struct TT_DriverRec_* TT_Driver; - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a TrueType glyph slot object. */ - /* */ - /* <Note> */ - /* This is a direct typedef of FT_GlyphSlot, as there is nothing */ - /* specific about the TrueType glyph slot. */ - /* */ + /************************************************************************** + * + * @Type: + * TT_GlyphSlot + * + * @Description: + * A handle to a TrueType glyph slot object. + * + * @Note: + * This is a direct typedef of FT_GlyphSlot, as there is nothing + * specific about the TrueType glyph slot. + */ typedef FT_GlyphSlot TT_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GraphicsState */ - /* */ - /* <Description> */ - /* The TrueType graphics state used during bytecode interpretation. */ - /* */ + /************************************************************************** + * + * @Struct: + * TT_GraphicsState + * + * @Description: + * The TrueType graphics state used during bytecode interpretation. + */ typedef struct TT_GraphicsState_ { FT_UShort rp0; @@ -113,25 +113,25 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* EXECUTION SUBTABLES */ - /* */ - /* These sub-tables relate to instruction execution. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * EXECUTION SUBTABLES + * + * These sub-tables relate to instruction execution. + * + */ #define TT_MAX_CODE_RANGES 3 - /*************************************************************************/ - /* */ - /* There can only be 3 active code ranges at once: */ - /* - the Font Program */ - /* - the CVT Program */ - /* - a glyph's instructions set */ - /* */ + /************************************************************************** + * + * There can only be 3 active code ranges at once: + * - the Font Program + * - the CVT Program + * - a glyph's instructions set + */ typedef enum TT_CodeRange_Tag_ { tt_coderange_none = 0, @@ -152,10 +152,10 @@ FT_BEGIN_HEADER typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES]; - /*************************************************************************/ - /* */ - /* Defines a function/instruction definition record. */ - /* */ + /************************************************************************** + * + * Defines a function/instruction definition record. + */ typedef struct TT_DefRecord_ { FT_Int range; /* in which code range is it located? */ @@ -169,10 +169,10 @@ FT_BEGIN_HEADER } TT_DefRecord, *TT_DefArray; - /*************************************************************************/ - /* */ - /* Subglyph transformation record. */ - /* */ + /************************************************************************** + * + * Subglyph transformation record. + */ typedef struct TT_Transform_ { FT_Fixed xx, xy; /* transformation matrix coefficients */ @@ -182,72 +182,72 @@ FT_BEGIN_HEADER } TT_Transform; - /*************************************************************************/ - /* */ - /* A note regarding non-squared pixels: */ - /* */ - /* (This text will probably go into some docs at some time; for now, it */ - /* is kept here to explain some definitions in the TT_Size_Metrics */ - /* record). */ - /* */ - /* The CVT is a one-dimensional array containing values that control */ - /* certain important characteristics in a font, like the height of all */ - /* capitals, all lowercase letter, default spacing or stem width/height. */ - /* */ - /* These values are found in FUnits in the font file, and must be scaled */ - /* to pixel coordinates before being used by the CVT and glyph programs. */ - /* Unfortunately, when using distinct x and y resolutions (or distinct x */ - /* and y pointsizes), there are two possible scalings. */ - /* */ - /* A first try was to implement a `lazy' scheme where all values were */ - /* scaled when first used. However, while some values are always used */ - /* in the same direction, some others are used under many different */ - /* circumstances and orientations. */ - /* */ - /* I have found a simpler way to do the same, and it even seems to work */ - /* in most of the cases: */ - /* */ - /* - All CVT values are scaled to the maximum ppem size. */ - /* */ - /* - When performing a read or write in the CVT, a ratio factor is used */ - /* to perform adequate scaling. Example: */ - /* */ - /* x_ppem = 14 */ - /* y_ppem = 10 */ - /* */ - /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */ - /* entries are scaled to it. */ - /* */ - /* x_ratio = 1.0 */ - /* y_ratio = y_ppem/ppem (< 1.0) */ - /* */ - /* We compute the current ratio like: */ - /* */ - /* - If projVector is horizontal, */ - /* ratio = x_ratio = 1.0 */ - /* */ - /* - if projVector is vertical, */ - /* ratio = y_ratio */ - /* */ - /* - else, */ - /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */ - /* */ - /* Reading a cvt value returns */ - /* ratio * cvt[index] */ - /* */ - /* Writing a cvt value in pixels: */ - /* cvt[index] / ratio */ - /* */ - /* The current ppem is simply */ - /* ratio * ppem */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Metrics used by the TrueType size and context objects. */ - /* */ + /************************************************************************** + * + * A note regarding non-squared pixels: + * + * (This text will probably go into some docs at some time; for now, it + * is kept here to explain some definitions in the TT_Size_Metrics + * record). + * + * The CVT is a one-dimensional array containing values that control + * certain important characteristics in a font, like the height of all + * capitals, all lowercase letter, default spacing or stem width/height. + * + * These values are found in FUnits in the font file, and must be scaled + * to pixel coordinates before being used by the CVT and glyph programs. + * Unfortunately, when using distinct x and y resolutions (or distinct x + * and y pointsizes), there are two possible scalings. + * + * A first try was to implement a `lazy' scheme where all values were + * scaled when first used. However, while some values are always used + * in the same direction, some others are used under many different + * circumstances and orientations. + * + * I have found a simpler way to do the same, and it even seems to work + * in most of the cases: + * + * - All CVT values are scaled to the maximum ppem size. + * + * - When performing a read or write in the CVT, a ratio factor is used + * to perform adequate scaling. Example: + * + * x_ppem = 14 + * y_ppem = 10 + * + * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt + * entries are scaled to it. + * + * x_ratio = 1.0 + * y_ratio = y_ppem/ppem (< 1.0) + * + * We compute the current ratio like: + * + * - If projVector is horizontal, + * ratio = x_ratio = 1.0 + * + * - if projVector is vertical, + * ratio = y_ratio + * + * - else, + * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) + * + * Reading a cvt value returns + * ratio * cvt[index] + * + * Writing a cvt value in pixels: + * cvt[index] / ratio + * + * The current ppem is simply + * ratio * ppem + * + */ + + + /************************************************************************** + * + * Metrics used by the TrueType size and context objects. + */ typedef struct TT_Size_Metrics_ { /* for non-square pixels */ @@ -268,10 +268,10 @@ FT_BEGIN_HEADER } TT_Size_Metrics; - /*************************************************************************/ - /* */ - /* TrueType size class. */ - /* */ + /************************************************************************** + * + * TrueType size class. + */ typedef struct TT_SizeRec_ { FT_SizeRec root; @@ -324,10 +324,10 @@ FT_BEGIN_HEADER } TT_SizeRec; - /*************************************************************************/ - /* */ - /* TrueType driver class. */ - /* */ + /************************************************************************** + * + * TrueType driver class. + */ typedef struct TT_DriverRec_ { FT_DriverRec root; @@ -348,10 +348,10 @@ FT_BEGIN_HEADER /* will always use the TT driver to create them. */ - /*************************************************************************/ - /* */ - /* Face functions */ - /* */ + /************************************************************************** + * + * Face functions + */ FT_LOCAL( FT_Error ) tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ @@ -363,10 +363,10 @@ FT_BEGIN_HEADER tt_face_done( FT_Face ttface ); /* TT_Face */ - /*************************************************************************/ - /* */ - /* Size functions */ - /* */ + /************************************************************************** + * + * Size functions + */ FT_LOCAL( FT_Error ) tt_size_init( FT_Size ttsize ); /* TT_Size */ @@ -394,10 +394,10 @@ FT_BEGIN_HEADER FT_Bool only_height ); - /*************************************************************************/ - /* */ - /* Driver functions */ - /* */ + /************************************************************************** + * + * Driver functions + */ FT_LOCAL( FT_Error ) tt_driver_init( FT_Module ttdriver ); /* TT_Driver */ @@ -405,10 +405,10 @@ FT_BEGIN_HEADER tt_driver_done( FT_Module ttdriver ); /* TT_Driver */ - /*************************************************************************/ - /* */ - /* Slot functions */ - /* */ + /************************************************************************** + * + * Slot functions + */ FT_LOCAL( FT_Error ) tt_slot_init( FT_GlyphSlot slot ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpic.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpic.c deleted file mode 100644 index cdbb80639e1..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpic.c +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttpic.c */ -/* */ -/* The FreeType position independent code services for truetype module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "ttpic.h" -#include "tterrors.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from ttdriver.c */ - FT_Error - FT_Create_Class_tt_services( FT_Library library, - FT_ServiceDescRec** output_class ); - void - FT_Destroy_Class_tt_services( FT_Library library, - FT_ServiceDescRec* clazz ); - void - FT_Init_Class_tt_service_gx_multi_masters( - FT_Service_MultiMastersRec* sv_mm ); - void - FT_Init_Class_tt_service_truetype_glyf( - FT_Service_TTGlyfRec* sv_ttglyf ); - - - void - tt_driver_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->truetype ) - { - TTModulePIC* container = (TTModulePIC*)pic_container->truetype; - - - if ( container->tt_services ) - FT_Destroy_Class_tt_services( library, container->tt_services ); - container->tt_services = NULL; - FT_FREE( container ); - pic_container->truetype = NULL; - } - } - - - FT_Error - tt_driver_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - TTModulePIC* container = NULL; - FT_Memory memory = library->memory; - - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->truetype = container; - - /* initialize pointer table - this is how the module usually */ - /* expects this data */ - error = FT_Create_Class_tt_services( library, - &container->tt_services ); - if ( error ) - goto Exit; -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Init_Class_tt_service_gx_multi_masters( - &container->tt_service_gx_multi_masters ); -#endif - FT_Init_Class_tt_service_truetype_glyf( - &container->tt_service_truetype_glyf ); - - Exit: - if ( error ) - tt_driver_class_pic_free( library ); - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpic.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpic.h deleted file mode 100644 index df878ae6f1d..00000000000 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpic.h +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttpic.h */ -/* */ -/* The FreeType position independent code services for truetype module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTPIC_H_ -#define TTPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -#ifndef FT_CONFIG_OPTION_PIC - -#define TT_SERVICES_GET tt_services -#define TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters -#define TT_SERVICE_METRICS_VARIATIONS_GET tt_service_metrics_variations -#define TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf -#define TT_SERVICE_PROPERTIES_GET tt_service_properties - -#else /* FT_CONFIG_OPTION_PIC */ - -#include FT_MULTIPLE_MASTERS_H -#include FT_SERVICE_MULTIPLE_MASTERS_H -#include FT_SERVICE_METRICS_VARIATIONS_H -#include FT_SERVICE_TRUETYPE_GLYF_H -#include FT_SERVICE_PROPERTIES_H - - -FT_BEGIN_HEADER - - typedef struct TTModulePIC_ - { - FT_ServiceDescRec* tt_services; -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Service_MultiMastersRec tt_service_gx_multi_masters; - FT_Service_MetricsVariationsRec tt_service_metrics_variations; -#endif - FT_Service_TTGlyfRec tt_service_truetype_glyf; - FT_Service_PropertiesRec tt_service_properties; - - } TTModulePIC; - - -#define GET_PIC( lib ) \ - ( (TTModulePIC*)((lib)->pic_container.truetype) ) -#define TT_SERVICES_GET \ - ( GET_PIC( library )->tt_services ) -#define TT_SERVICE_METRICS_VARIATIONS_GET \ - ( GET_PIC( library )->tt_service_metrics_variations ) -#define TT_SERVICE_GX_MULTI_MASTERS_GET \ - ( GET_PIC( library )->tt_service_gx_multi_masters ) -#define TT_SERVICE_TRUETYPE_GLYF_GET \ - ( GET_PIC( library )->tt_service_truetype_glyf ) -#define TT_SERVICE_PROPERTIES_GET \ - ( GET_PIC( library )->tt_service_properties ) - - - /* see ttpic.c for the implementation */ - void - tt_driver_class_pic_free( FT_Library library ); - - FT_Error - tt_driver_class_pic_init( FT_Library library ); - -FT_END_HEADER - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -#endif /* TTPIC_H_ */ - - -/* END */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c index d9526ad082b..e7718bf9b79 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttpload.c */ -/* */ -/* TrueType-specific tables loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttpload.c + * + * TrueType-specific tables loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,33 +31,35 @@ #include "tterrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttpload - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_loca */ - /* */ - /* <Description> */ - /* Load the locations table. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ +#define FT_COMPONENT ttpload + + + /************************************************************************** + * + * @Function: + * tt_face_load_loca + * + * @Description: + * Load the locations table. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_loca( TT_Face face, FT_Stream stream ) @@ -297,23 +299,25 @@ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_cvt */ - /* */ - /* <Description> */ - /* Load the control value table into a face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_cvt + * + * @Description: + * Load the control value table into a face object. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_cvt( TT_Face face, FT_Stream stream ) @@ -378,23 +382,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_fpgm */ - /* */ - /* <Description> */ - /* Load the font program. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_fpgm + * + * @Description: + * Load the font program. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_fpgm( TT_Face face, FT_Stream stream ) @@ -440,23 +446,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_prep */ - /* */ - /* <Description> */ - /* Load the cvt program. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_prep + * + * @Description: + * Load the cvt program. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_prep( TT_Face face, FT_Stream stream ) @@ -501,22 +509,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hdmx */ - /* */ - /* <Description> */ - /* Load the `hdmx' table into the face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_hdmx + * + * @Description: + * Load the `hdmx' table into the face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_hdmx( TT_Face face, @@ -610,11 +620,11 @@ } - /*************************************************************************/ - /* */ - /* Return the advance width table for a given pixel size if it is found */ - /* in the font's `hdmx' table (if any). */ - /* */ + /************************************************************************** + * + * Return the advance width table for a given pixel size if it is found + * in the font's `hdmx' table (if any). + */ FT_LOCAL_DEF( FT_Byte* ) tt_face_get_device_metrics( TT_Face face, FT_UInt ppem, diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h index fa125272472..022750e3246 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttpload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttpload.h */ -/* */ -/* TrueType-specific tables loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttpload.h + * + * TrueType-specific tables loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTPLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c index d94bcc8b50d..23a2e5b4401 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttsubpix.c */ -/* */ -/* TrueType Subpixel Hinting. */ -/* */ -/* Copyright 2010-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsubpix.c + * + * TrueType Subpixel Hinting. + * + * Copyright (C) 2010-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H @@ -30,35 +30,35 @@ #if defined( TT_USE_BYTECODE_INTERPRETER ) && \ defined( TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY ) - /*************************************************************************/ - /* */ - /* These rules affect how the TT Interpreter does hinting, with the */ - /* goal of doing subpixel hinting by (in general) ignoring x moves. */ - /* Some of these rules are fixes that go above and beyond the */ - /* stated techniques in the MS whitepaper on Cleartype, due to */ - /* artifacts in many glyphs. So, these rules make some glyphs render */ - /* better than they do in the MS rasterizer. */ - /* */ - /* "" string or 0 int/char indicates to apply to all glyphs. */ - /* "-" used as dummy placeholders, but any non-matching string works. */ - /* */ - /* Some of this could arguably be implemented in fontconfig, however: */ - /* */ - /* - Fontconfig can't set things on a glyph-by-glyph basis. */ - /* - The tweaks that happen here are very low-level, from an average */ - /* user's point of view and are best implemented in the hinter. */ - /* */ - /* The goal is to make the subpixel hinting techniques as generalized */ - /* as possible across all fonts to prevent the need for extra rules such */ - /* as these. */ - /* */ - /* The rule structure is designed so that entirely new rules can easily */ - /* be added when a new compatibility feature is discovered. */ - /* */ - /* The rule structures could also use some enhancement to handle ranges. */ - /* */ - /* ****************** WORK IN PROGRESS ******************* */ - /* */ + /************************************************************************** + * + * These rules affect how the TT Interpreter does hinting, with the + * goal of doing subpixel hinting by (in general) ignoring x moves. + * Some of these rules are fixes that go above and beyond the + * stated techniques in the MS whitepaper on Cleartype, due to + * artifacts in many glyphs. So, these rules make some glyphs render + * better than they do in the MS rasterizer. + * + * "" string or 0 int/char indicates to apply to all glyphs. + * "-" used as dummy placeholders, but any non-matching string works. + * + * Some of this could arguably be implemented in fontconfig, however: + * + * - Fontconfig can't set things on a glyph-by-glyph basis. + * - The tweaks that happen here are very low-level, from an average + * user's point of view and are best implemented in the hinter. + * + * The goal is to make the subpixel hinting techniques as generalized + * as possible across all fonts to prevent the need for extra rules such + * as these. + * + * The rule structure is designed so that entirely new rules can easily + * be added when a new compatibility feature is discovered. + * + * The rule structures could also use some enhancement to handle ranges. + * + * ****************** WORK IN PROGRESS ******************* + */ /* These are `classes' of fonts that can be grouped together and used in */ /* rules below. A blank entry "" is required at the end of these! */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h index 1070bb016fd..4966800c2d7 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h +++ b/src/src/java.desktop/share/native/libfreetype/src/truetype/ttsubpix.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttsubpix.h */ -/* */ -/* TrueType Subpixel Hinting. */ -/* */ -/* Copyright 2010-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsubpix.h + * + * TrueType Subpixel Hinting. + * + * Copyright (C) 2010-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTSUBPIX_H_ @@ -29,11 +29,11 @@ FT_BEGIN_HEADER #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - /*************************************************************************/ - /* */ - /* ID flags to identify special functions at FDEF and runtime. */ - /* */ - /* */ + /************************************************************************** + * + * ID flags to identify special functions at FDEF and runtime. + * + */ #define SPH_FDEF_INLINE_DELTA_1 0x0000001 #define SPH_FDEF_INLINE_DELTA_2 0x0000002 #define SPH_FDEF_DIAGONAL_STROKE 0x0000004 @@ -45,11 +45,11 @@ FT_BEGIN_HEADER #define SPH_FDEF_TYPEMAN_DIAGENDCTRL 0x0000100 - /*************************************************************************/ - /* */ - /* Tweak flags that are set for each glyph by the below rules. */ - /* */ - /* */ + /************************************************************************** + * + * Tweak flags that are set for each glyph by the below rules. + * + */ #define SPH_TWEAK_ALLOW_X_DMOVE 0x0000001UL #define SPH_TWEAK_ALWAYS_DO_DELTAP 0x0000002UL #define SPH_TWEAK_ALWAYS_SKIP_DELTAP 0x0000004UL diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c b/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c index 61053d9a640..6841184539f 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1afm.c */ -/* */ -/* AFM support for Type 1 fonts (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1afm.c + * + * AFM support for Type 1 fonts (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #ifndef T1_CONFIG_OPTION_NO_AFM - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1afm +#define FT_COMPONENT t1afm FT_LOCAL_DEF( void ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h index cb8d302b4d4..a8e6a5495a2 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1afm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1afm.h */ -/* */ -/* AFM support for Type 1 fonts (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1afm.h + * + * AFM support for Type 1 fonts (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1AFM_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c b/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c index 029b410b476..8625db5b015 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1driver.c */ -/* */ -/* Type 1 driver interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1driver.c + * + * Type 1 driver interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -43,19 +43,19 @@ #include FT_SERVICE_KERNING_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1driver +#define FT_COMPONENT t1driver - /* - * GLYPH DICT SERVICE - * - */ + /* + * GLYPH DICT SERVICE + * + */ static FT_Error t1_get_glyph_name( T1_Face face, @@ -97,7 +97,7 @@ /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -115,30 +115,32 @@ /* - * MULTIPLE MASTERS SERVICE + * MULTIPLE MASTERS SERVICE * */ #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT static const FT_Service_MultiMastersRec t1_service_multi_masters = { - (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */ - (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */ - (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */ - (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */ - (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */ - (FT_Set_Var_Design_Func)T1_Set_Var_Design, /* set_var_design */ - (FT_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */ - (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */ - - (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */ - (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */ + (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */ + (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */ + (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */ + (FT_Set_Var_Design_Func) T1_Set_Var_Design, /* set_var_design */ + (FT_Get_Var_Design_Func) T1_Get_Var_Design, /* get_var_design */ + (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */ + (FT_Set_MM_WeightVector_Func)T1_Set_MM_WeightVector, /* set_mm_weightvector */ + (FT_Get_MM_WeightVector_Func)T1_Get_MM_WeightVector, /* get_mm_weightvector */ + + (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */ + (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */ }; #endif /* - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -270,9 +272,12 @@ break; case PS_DICT_FONT_NAME: - retval = ft_strlen( type1->font_name ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_name ), retval ); + if ( type1->font_name ) + { + retval = ft_strlen( type1->font_name ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_name ), retval ); + } break; case PS_DICT_UNIQUE_ID: @@ -362,7 +367,7 @@ ok = 1; } - if ( ok ) + if ( ok && type1->subrs ) { retval = type1->subrs_len[idx] + 1; if ( value && value_len >= retval ) @@ -559,33 +564,49 @@ break; case PS_DICT_VERSION: - retval = ft_strlen( type1->font_info.version ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.version ), retval ); + if ( type1->font_info.version ) + { + retval = ft_strlen( type1->font_info.version ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.version ), retval ); + } break; case PS_DICT_NOTICE: - retval = ft_strlen( type1->font_info.notice ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.notice ), retval ); + if ( type1->font_info.notice ) + { + retval = ft_strlen( type1->font_info.notice ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.notice ), retval ); + } break; case PS_DICT_FULL_NAME: - retval = ft_strlen( type1->font_info.full_name ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.full_name ), retval ); + if ( type1->font_info.full_name ) + { + retval = ft_strlen( type1->font_info.full_name ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.full_name ), retval ); + } break; case PS_DICT_FAMILY_NAME: - retval = ft_strlen( type1->font_info.family_name ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.family_name ), retval ); + if ( type1->font_info.family_name ) + { + retval = ft_strlen( type1->font_info.family_name ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.family_name ), + retval ); + } break; case PS_DICT_WEIGHT: - retval = ft_strlen( type1->font_info.weight ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.weight ), retval ); + if ( type1->font_info.weight ) + { + retval = ft_strlen( type1->font_info.weight ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.weight ), retval ); + } break; case PS_DICT_ITALIC_ANGLE: @@ -618,7 +639,7 @@ /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ @@ -630,7 +651,7 @@ /* - * SERVICE LIST + * SERVICE LIST * */ @@ -665,38 +686,42 @@ #ifndef T1_CONFIG_OPTION_NO_AFM - /*************************************************************************/ - /* */ - /* <Function> */ - /* Get_Kerning */ - /* */ - /* <Description> */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* <Output> */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this function. Other layouts, or more sophisticated */ - /* kernings are out of scope of this method (the basic driver */ - /* interface is meant to be simple). */ - /* */ - /* They can be implemented by format-specific interfaces. */ - /* */ + /************************************************************************** + * + * @Function: + * Get_Kerning + * + * @Description: + * A driver method used to return the kerning vector between two + * glyphs of the same face. + * + * @Input: + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * @Output: + * kerning :: + * The kerning vector. This is in font units for + * scalable formats, and in pixels for fixed-sizes + * formats. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only horizontal layouts (left-to-right & right-to-left) are + * supported by this function. Other layouts, or more sophisticated + * kernings are out of scope of this method (the basic driver + * interface is meant to be simple). + * + * They can be implemented by format-specific interfaces. + */ static FT_Error Get_Kerning( FT_Face t1face, /* T1_Face */ FT_UInt left_glyph, diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h index 2b1507233dd..206f64a0bca 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1driver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1driver.h */ -/* */ -/* High-level Type 1 driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1driver.h + * + * High-level Type 1 driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1DRIVER_H_ @@ -26,14 +26,8 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - - FT_EXPORT_VAR( const FT_Driver_ClassRec ) t1_driver_class; - FT_END_HEADER #endif /* T1DRIVER_H_ */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h index 9e0151b9571..b35f67a24c9 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1errors.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* t1errors.h */ -/* */ -/* Type 1 error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the Type 1 error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t1errors.h + * + * Type 1 error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the Type 1 error enumeration constants. + * + */ #ifndef T1ERRORS_H_ #define T1ERRORS_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c b/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c index 87d40e75660..f9b115b1864 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1gload.c */ -/* */ -/* Type 1 Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1gload.c + * + * Type 1 Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -29,14 +29,14 @@ #include "t1errors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1gload +#define FT_COMPONENT t1gload static FT_Error @@ -62,6 +62,7 @@ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); #endif + decoder->font_matrix = type1->font_matrix; decoder->font_offset = type1->font_offset; @@ -249,6 +250,8 @@ *max_advance = 0; + FT_TRACE6(( "T1_Compute_Max_Advance:\n" )); + /* for each glyph, parse the glyph charstring and extract */ /* the advance width */ for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ ) @@ -261,6 +264,9 @@ /* ignore the error if one occurred - skip to next glyph */ } + FT_TRACE6(( "T1_Compute_Max_Advance: max advance: %f\n", + *max_advance / 65536.0 )); + psaux->t1_decoder_funcs->done( &decoder ); return FT_Err_Ok; @@ -282,11 +288,18 @@ FT_Error error; + FT_TRACE5(( "T1_Get_Advances:\n" )); + if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { for ( nn = 0; nn < count; nn++ ) + { advances[nn] = 0; + FT_TRACE5(( " idx %d: advance height 0 font units\n", + first + nn )); + } + return FT_Err_Ok; } @@ -320,6 +333,11 @@ advances[nn] = FIXED_TO_INT( decoder.builder.advance.x ); else advances[nn] = 0; + + FT_TRACE5(( " idx %d: advance width %d font unit%s\n", + first + nn, + advances[nn], + advances[nn] == 1 ? "" : "s" )); } return FT_Err_Ok; @@ -384,9 +402,9 @@ t1glyph->outline.n_points = 0; t1glyph->outline.n_contours = 0; - hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && - ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); - scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ); + hinting = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) && + !( load_flags & FT_LOAD_NO_HINTING ) ); + scaled = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) ); glyph->hint = hinting; glyph->scaled = scaled; @@ -398,7 +416,7 @@ t1glyph, (FT_Byte**)type1->glyph_names, face->blend, - FT_BOOL( hinting ), + hinting, FT_LOAD_TARGET_MODE( load_flags ), T1_Parse_Glyph ); if ( error ) @@ -406,8 +424,7 @@ must_finish_decoder = TRUE; - decoder.builder.no_recurse = FT_BOOL( - ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); + decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE ); decoder.num_subrs = type1->num_subrs; decoder.subrs = type1->subrs; @@ -528,7 +545,7 @@ /* First of all, scale the points, if we are not hinting */ - if ( !hinting || ! decoder.builder.hints_funcs ) + if ( !hinting || !decoder.builder.hints_funcs ) for ( n = cur->n_points; n > 0; n--, vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h index 72ef76f6ae3..80440369dc0 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1gload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1gload.h */ -/* */ -/* Type 1 Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1gload.h + * + * Type 1 Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1GLOAD_H_ diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.c b/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.c index 9dfa637a695..3896af70ba1 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.c +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.c @@ -1,63 +1,63 @@ -/***************************************************************************/ -/* */ -/* t1load.c */ -/* */ -/* Type 1 font loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is the new and improved Type 1 data loader for FreeType 2. The */ - /* old loader has several problems: it is slow, complex, difficult to */ - /* maintain, and contains incredible hacks to make it accept some */ - /* ill-formed Type 1 fonts without hiccup-ing. Moreover, about 5% of */ - /* the Type 1 fonts on my machine still aren't loaded correctly by it. */ - /* */ - /* This version is much simpler, much faster and also easier to read and */ - /* maintain by a great order of magnitude. The idea behind it is to */ - /* _not_ try to read the Type 1 token stream with a state machine (i.e. */ - /* a Postscript-like interpreter) but rather to perform simple pattern */ - /* matching. */ - /* */ - /* Indeed, nearly all data definitions follow a simple pattern like */ - /* */ - /* ... /Field <data> ... */ - /* */ - /* where <data> can be a number, a boolean, a string, or an array of */ - /* numbers. There are a few exceptions, namely the encoding, font name, */ - /* charstrings, and subrs; they are handled with a special pattern */ - /* matching routine. */ - /* */ - /* All other common cases are handled very simply. The matching rules */ - /* are defined in the file `t1tokens.h' through the use of several */ - /* macros calls PARSE_XXX. This file is included twice here; the first */ - /* time to generate parsing callback functions, the second time to */ - /* generate a table of keywords (with pointers to the associated */ - /* callback functions). */ - /* */ - /* The function `parse_dict' simply scans *linearly* a given dictionary */ - /* (either the top-level or private one) and calls the appropriate */ - /* callback when it encounters an immediate keyword. */ - /* */ - /* This is by far the fastest way one can find to parse and read all */ - /* data. */ - /* */ - /* This led to tremendous code size reduction. Note that later, the */ - /* glyph loader will also be _greatly_ simplified, and the automatic */ - /* hinter will replace the clumsy `t1hinter'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t1load.c + * + * Type 1 font loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This is the new and improved Type 1 data loader for FreeType 2. The + * old loader has several problems: it is slow, complex, difficult to + * maintain, and contains incredible hacks to make it accept some + * ill-formed Type 1 fonts without hiccup-ing. Moreover, about 5% of + * the Type 1 fonts on my machine still aren't loaded correctly by it. + * + * This version is much simpler, much faster and also easier to read and + * maintain by a great order of magnitude. The idea behind it is to + * _not_ try to read the Type 1 token stream with a state machine (i.e. + * a Postscript-like interpreter) but rather to perform simple pattern + * matching. + * + * Indeed, nearly all data definitions follow a simple pattern like + * + * ... /Field <data> ... + * + * where <data> can be a number, a boolean, a string, or an array of + * numbers. There are a few exceptions, namely the encoding, font name, + * charstrings, and subrs; they are handled with a special pattern + * matching routine. + * + * All other common cases are handled very simply. The matching rules + * are defined in the file `t1tokens.h' through the use of several + * macros calls PARSE_XXX. This file is included twice here; the first + * time to generate parsing callback functions, the second time to + * generate a table of keywords (with pointers to the associated + * callback functions). + * + * The function `parse_dict' simply scans *linearly* a given dictionary + * (either the top-level or private one) and calls the appropriate + * callback when it encounters an immediate keyword. + * + * This is by far the fastest way one can find to parse and read all + * data. + * + * This led to tremendous code size reduction. Note that later, the + * glyph loader will also be _greatly_ simplified, and the automatic + * hinter will replace the clumsy `t1hinter'. + * + */ #include <ft2build.h> @@ -73,20 +73,20 @@ #ifdef FT_CONFIG_OPTION_INCREMENTAL -#define IS_INCREMENTAL (FT_Bool)( face->root.internal->incremental_interface != 0 ) +#define IS_INCREMENTAL FT_BOOL( face->root.internal->incremental_interface ) #else #define IS_INCREMENTAL 0 #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1load +#define FT_COMPONENT t1load #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT @@ -222,11 +222,11 @@ } - /*************************************************************************/ - /* */ - /* Given a normalized (blend) coordinate, figure out the design */ - /* coordinate appropriate for that value. */ - /* */ + /************************************************************************** + * + * Given a normalized (blend) coordinate, figure out the design + * coordinate appropriate for that value. + */ static FT_Fixed mm_axis_unmap( PS_DesignMap axismap, FT_Fixed ncv ) @@ -251,11 +251,11 @@ } - /*************************************************************************/ - /* */ - /* Given a vector of weights, one for each design, figure out the */ - /* normalized axis coordinates which gave rise to those weights. */ - /* */ + /************************************************************************** + * + * Given a vector of weights, one for each design, figure out the + * normalized axis coordinates which gave rise to those weights. + */ static void mm_weights_unmap( FT_Fixed* weights, FT_Fixed* axiscoords, @@ -293,11 +293,11 @@ } - /*************************************************************************/ - /* */ - /* Just a wrapper around T1_Get_Multi_Master to support the different */ - /* arguments needed by the GX var distortable fonts. */ - /* */ + /************************************************************************** + * + * Just a wrapper around T1_Get_Multi_Master to support the different + * arguments needed by the GX var distortable fonts. + */ FT_LOCAL_DEF( FT_Error ) T1_Get_MM_Var( T1_Face face, FT_MM_Var* *master ) @@ -348,16 +348,13 @@ mmvar->axis[i].tag = FT_MAKE_TAG( 'o', 'p', 's', 'z' ); } - if ( blend->num_designs == ( 1U << blend->num_axis ) ) - { - mm_weights_unmap( blend->default_weight_vector, - axiscoords, - blend->num_axis ); + mm_weights_unmap( blend->default_weight_vector, + axiscoords, + blend->num_axis ); - for ( i = 0; i < mmaster.num_axis; i++ ) - mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i], - axiscoords[i] ); - } + for ( i = 0; i < mmaster.num_axis; i++ ) + mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i], + axiscoords[i] ); *master = mmvar; @@ -387,24 +384,31 @@ for ( n = 0; n < blend->num_designs; n++ ) { FT_Fixed result = 0x10000L; /* 1.0 fixed */ + FT_Fixed factor; for ( m = 0; m < blend->num_axis; m++ ) { - FT_Fixed factor; - - - /* get current blend axis position; */ /* use a default value if we don't have a coordinate */ - factor = m < num_coords ? coords[m] : 0x8000; - if ( factor < 0 ) - factor = 0; - if ( factor > 0x10000L ) - factor = 0x10000L; + if ( m >= num_coords ) + { + result >>= 1; + continue; + } + /* get current blend axis position */ + factor = coords[m]; if ( ( n & ( 1 << m ) ) == 0 ) factor = 0x10000L - factor; + if ( factor <= 0 ) + { + result = 0; + break; + } + else if ( factor >= 0x10000L ) + continue; + result = FT_MulFix( result, factor ); } @@ -476,6 +480,75 @@ } + FT_LOCAL_DEF( FT_Error ) + T1_Set_MM_WeightVector( T1_Face face, + FT_UInt len, + FT_Fixed* weightvector ) + { + PS_Blend blend = face->blend; + FT_UInt i, n; + + + if ( !blend ) + return FT_THROW( Invalid_Argument ); + + if ( !len && !weightvector ) + { + for ( i = 0; i < blend->num_designs; i++ ) + blend->weight_vector[i] = blend->default_weight_vector[i]; + } + else + { + if ( !weightvector ) + return FT_THROW( Invalid_Argument ); + + n = len < blend->num_designs ? len : blend->num_designs; + + for ( i = 0; i < n; i++ ) + blend->weight_vector[i] = weightvector[i]; + + for ( ; i < blend->num_designs; i++ ) + blend->weight_vector[i] = (FT_Fixed)0; + + if ( len ) + face->root.face_flags |= FT_FACE_FLAG_VARIATION; + else + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; + } + + return FT_Err_Ok; + } + + + FT_LOCAL_DEF( FT_Error ) + T1_Get_MM_WeightVector( T1_Face face, + FT_UInt* len, + FT_Fixed* weightvector ) + { + PS_Blend blend = face->blend; + FT_UInt i; + + + if ( !blend ) + return FT_THROW( Invalid_Argument ); + + if ( *len < blend->num_designs ) + { + *len = blend->num_designs; + return FT_THROW( Invalid_Argument ); + } + + for ( i = 0; i < blend->num_designs; i++ ) + weightvector[i] = blend->weight_vector[i]; + for ( ; i < *len; i++ ) + weightvector[i] = (FT_Fixed)0; + + *len = blend->num_designs; + + return FT_Err_Ok; + } + + FT_LOCAL_DEF( FT_Error ) T1_Set_MM_Design( T1_Face face, FT_UInt num_coords, @@ -573,11 +646,11 @@ } - /*************************************************************************/ - /* */ - /* Just a wrapper around T1_Set_MM_Design to support the different */ - /* arguments needed by the GX var distortable fonts. */ - /* */ + /************************************************************************** + * + * Just a wrapper around T1_Set_MM_Design to support the different + * arguments needed by the GX var distortable fonts. + */ FT_LOCAL_DEF( FT_Error ) T1_Set_Var_Design( T1_Face face, FT_UInt num_coords, @@ -719,6 +792,8 @@ if ( error ) goto Exit; + FT_TRACE4(( " [" )); + blend = face->blend; memory = face->root.memory; @@ -741,11 +816,13 @@ goto Exit; } + FT_TRACE4(( " /%.*s", len, token->start )); + name = (FT_Byte*)blend->axis_names[n]; if ( name ) { FT_TRACE0(( "parse_blend_axis_types:" - " overwriting axis name `%s' with `%*.s'\n", + " overwriting axis name `%s' with `%.*s'\n", name, len, token->start )); FT_FREE( name ); } @@ -758,6 +835,8 @@ name[len] = '\0'; } + FT_TRACE4(( "]\n" )); + Exit: loader->parser.root.error = error; } @@ -802,6 +881,8 @@ blend = face->blend; num_axis = 0; /* make compiler happy */ + FT_TRACE4(( " [" )); + for ( n = 0; n < num_designs; n++ ) { T1_TokenRec axis_tokens[T1_MAX_MM_AXIS]; @@ -842,6 +923,7 @@ } /* now read each axis token into the design position */ + FT_TRACE4(( " [" )) ; for ( axis = 0; axis < n_axis; axis++ ) { T1_Token token2 = axis_tokens + axis; @@ -850,9 +932,13 @@ parser->root.cursor = token2->start; parser->root.limit = token2->limit; blend->design_pos[n][axis] = T1_ToFixed( parser, 0 ); + FT_TRACE4(( " %f", (double)blend->design_pos[n][axis] / 65536 )); } + FT_TRACE4(( "]" )) ; } + FT_TRACE4(( "]\n" )); + loader->parser.root.cursor = old_cursor; loader->parser.root.limit = old_limit; } @@ -899,6 +985,8 @@ goto Exit; blend = face->blend; + FT_TRACE4(( " [" )); + /* now read each axis design map */ for ( n = 0; n < num_axis; n++ ) { @@ -915,6 +1003,8 @@ T1_ToTokenArray( parser, point_tokens, T1_MAX_MM_MAP_POINTS, &num_points ); + FT_TRACE4(( " [" )); + if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS ) { FT_ERROR(( "parse_blend_design_map: incorrect table\n" )); @@ -948,9 +1038,17 @@ map->design_points[p] = T1_ToInt( parser ); map->blend_points [p] = T1_ToFixed( parser, 0 ); + + FT_TRACE4(( " [%d %f]", + map->design_points[p], + (double)map->blend_points[p] / 65536 )); } + + FT_TRACE4(( "]" )); } + FT_TRACE4(( "]\n" )); + parser->root.cursor = old_cursor; parser->root.limit = old_limit; @@ -1010,6 +1108,8 @@ old_cursor = parser->root.cursor; old_limit = parser->root.limit; + FT_TRACE4(( "[" )); + for ( n = 0; n < num_designs; n++ ) { token = design_tokens + n; @@ -1018,8 +1118,12 @@ blend->default_weight_vector[n] = blend->weight_vector[n] = T1_ToFixed( parser, 0 ); + + FT_TRACE4(( " %f", (double)blend->weight_vector[n] / 65536 )); } + FT_TRACE4(( "]\n" )); + parser->root.cursor = old_cursor; parser->root.limit = old_limit; @@ -1036,6 +1140,20 @@ { face->len_buildchar = (FT_UInt)T1_ToFixedArray( &loader->parser, 0, NULL, 0 ); + +#ifdef FT_DEBUG_LEVEL_TRACE + { + FT_UInt i; + + + FT_TRACE4(( " [" )); + for ( i = 0; i < face->len_buildchar; i++ ) + FT_TRACE4(( " 0" )); + + FT_TRACE4(( "]\n" )); + } +#endif + return; } @@ -1071,6 +1189,8 @@ /* if the keyword has a dedicated callback, call it */ if ( field->type == T1_FIELD_TYPE_CALLBACK ) { + FT_TRACE4(( " %s", field->ident )); + field->reader( (FT_Face)face, loader ); error = loader->parser.root.error; goto Exit; @@ -1148,6 +1268,8 @@ max_objects = 0; } + FT_TRACE4(( " %s", field->ident )); + if ( *objects ) { if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY || @@ -1167,6 +1289,8 @@ error = FT_Err_Ok; } + FT_TRACE4(( "\n" )); + Exit: return error; } @@ -1179,6 +1303,8 @@ FT_UNUSED( face ); loader->keywords_encountered |= T1_PRIVATE; + + FT_TRACE4(( "\n" )); } @@ -1258,6 +1384,14 @@ return; } + FT_TRACE4(( " [%f %f %f %f %f %f]\n", + (double)temp[0] / 65536 / 1000, + (double)temp[1] / 65536 / 1000, + (double)temp[2] / 65536 / 1000, + (double)temp[3] / 65536 / 1000, + (double)temp[4] / 65536 / 1000, + (double)temp[5] / 65536 / 1000 )); + temp_scale = FT_ABS( temp[3] ); if ( temp_scale == 0 ) @@ -1280,12 +1414,18 @@ temp[5] = FT_DivFix( temp[5], temp_scale ); temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L; } - matrix->xx = temp[0]; matrix->yx = temp[1]; matrix->xy = temp[2]; matrix->yy = temp[3]; + if ( !FT_Matrix_Check( matrix ) ) + { + FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" )); + parser->root.error = FT_THROW( Invalid_File_Format ); + return; + } + /* note that the offsets must be expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; @@ -1494,6 +1634,15 @@ T1_Skip_Spaces( parser ); } +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " [" )); + + /* XXX show encoding vector */ + FT_TRACE4(( "..." )); + + FT_TRACE4(( "]\n" )); +#endif + face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY; parser->root.cursor = cur; } @@ -1504,18 +1653,30 @@ { if ( cur + 17 < limit && ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 ) + { face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD; + FT_TRACE4(( " StandardEncoding\n" )); + } else if ( cur + 15 < limit && ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 ) + { face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT; + FT_TRACE4(( " ExpertEncoding\n" )); + } else if ( cur + 18 < limit && ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 ) + { face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1; + FT_TRACE4(( " ISOLatin1Encoding\n" )); + } else + { parser->root.error = FT_ERR( Ignore ); + FT_TRACE4(( "<unknown>\n" )); + } } } @@ -1696,6 +1857,15 @@ if ( !loader->num_subrs ) loader->num_subrs = num_subrs; +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " <" )); + + /* XXX show subrs? */ + FT_TRACE4(( "%d elements", num_subrs )); + + FT_TRACE4(( ">\n" )); +#endif + return; Fail: @@ -2017,6 +2187,15 @@ loader->num_glyphs += 1; } +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " <" )); + + /* XXX show charstrings? */ + FT_TRACE4(( "%d elements", loader->num_glyphs )); + + FT_TRACE4(( ">\n" )); +#endif + return; Fail: @@ -2024,12 +2203,12 @@ } - /*************************************************************************/ - /* */ - /* Define the token field static variables. This is a set of */ - /* T1_FieldRec variables. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the token field static variables. This is a set of + * T1_FieldRec variables. + * + */ static @@ -2216,6 +2395,7 @@ ? T1_FIELD_DICT_PRIVATE : T1_FIELD_DICT_FONTDICT; + if ( !( dict & keyword->dict ) ) { FT_TRACE1(( "parse_dict: found `%s' but ignoring it" @@ -2330,6 +2510,7 @@ if ( error ) goto Exit; + FT_TRACE4(( " top dictionary:\n" )); error = parse_dict( face, &loader, parser->base_dict, parser->base_len ); if ( error ) @@ -2339,6 +2520,7 @@ if ( error ) goto Exit; + FT_TRACE4(( " private dictionary:\n" )); error = parse_dict( face, &loader, parser->private_dict, parser->private_len ); if ( error ) @@ -2349,6 +2531,16 @@ #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT + /* we don't support Multiple Master fonts with intermediate designs; */ + /* this implies that `num_designs' must be equal to `2^^num_axis' */ + if ( face->blend && + face->blend->num_designs != ( 1U << face->blend->num_axis ) ) + { + FT_ERROR(( "T1_Open_Face:" + " number-of-designs != 2 ^^ number-of-axes\n" )); + T1_Done_Blend( face ); + } + if ( face->blend && face->blend->num_default_design_vector != 0 && face->blend->num_default_design_vector != face->blend->num_axis ) diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.h index 03be3f7f937..44f835bde23 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1load.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1load.h */ -/* */ -/* Type 1 font loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1load.h + * + * Type 1 font loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1LOAD_H_ @@ -106,6 +106,16 @@ FT_BEGIN_HEADER FT_LOCAL( void ) T1_Done_Blend( T1_Face face ); + FT_LOCAL( FT_Error ) + T1_Set_MM_WeightVector( T1_Face face, + FT_UInt len, + FT_Fixed* weightvector ); + + FT_LOCAL( FT_Error ) + T1_Get_MM_WeightVector( T1_Face face, + FT_UInt* len, + FT_Fixed* weightvector ); + #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c b/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c index 7333c4c9587..741388a645a 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1objs.c */ -/* */ -/* Type 1 objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1objs.c + * + * Type 1 objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -36,21 +36,21 @@ #include FT_INTERNAL_POSTSCRIPT_AUX_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1objs +#define FT_COMPONENT t1objs - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ static PSH_Globals_Funcs @@ -133,11 +133,11 @@ } - /*************************************************************************/ - /* */ - /* SLOT FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SLOT FUNCTIONS + * + */ FT_LOCAL_DEF( void ) T1_GlyphSlot_Done( FT_GlyphSlot slot ) @@ -177,24 +177,25 @@ } - /*************************************************************************/ - /* */ - /* FACE FUNCTIONS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Face_Done */ - /* */ - /* <Description> */ - /* The face object destructor. */ - /* */ - /* <Input> */ - /* face :: A typeless pointer to the face object to destroy. */ - /* */ + /************************************************************************** + * + * FACE FUNCTIONS + * + */ + + + /************************************************************************** + * + * @Function: + * T1_Face_Done + * + * @Description: + * The face object destructor. + * + * @Input: + * face :: + * A typeless pointer to the face object to destroy. + */ FT_LOCAL_DEF( void ) T1_Face_Done( FT_Face t1face ) /* T1_Face */ { @@ -274,29 +275,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Face_Init */ - /* */ - /* <Description> */ - /* The face object constructor. */ - /* */ - /* <Input> */ - /* stream :: input stream where to load font data. */ - /* */ - /* face_index :: The index of the font face in the resource. */ - /* */ - /* num_params :: Number of additional generic parameters. Ignored. */ - /* */ - /* params :: Additional generic parameters. Ignored. */ - /* */ - /* <InOut> */ - /* face :: The face record to build. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * T1_Face_Init + * + * @Description: + * The face object constructor. + * + * @Input: + * stream :: + * input stream where to load font data. + * + * face_index :: + * The index of the font face in the resource. + * + * num_params :: + * Number of additional generic parameters. Ignored. + * + * params :: + * Additional generic parameters. Ignored. + * + * @InOut: + * face :: + * The face record to build. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) T1_Face_Init( FT_Stream stream, FT_Face t1face, /* T1_Face */ @@ -341,6 +347,10 @@ if ( error ) goto Exit; + FT_TRACE2(( "T1_Face_Init: %08p (index %d)\n", + face, + face_index )); + /* if we just wanted to check the format, leave successfully now */ if ( face_index < 0 ) goto Exit; @@ -516,7 +526,8 @@ error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -564,20 +575,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Driver_Init */ - /* */ - /* <Description> */ - /* Initializes a given Type 1 driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * T1_Driver_Init + * + * @Description: + * Initializes a given Type 1 driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) T1_Driver_Init( FT_Module module ) { @@ -620,17 +632,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Driver_Done */ - /* */ - /* <Description> */ - /* Finalizes a given Type 1 driver. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target Type 1 driver. */ - /* */ + /************************************************************************** + * + * @Function: + * T1_Driver_Done + * + * @Description: + * Finalizes a given Type 1 driver. + * + * @Input: + * driver :: + * A handle to the target Type 1 driver. + */ FT_LOCAL_DEF( void ) T1_Driver_Done( FT_Module driver ) { diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h index 8298e036f4b..2161091f779 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1objs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1objs.h */ -/* */ -/* Type 1 objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1objs.h + * + * Type 1 objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1OBJS_H_ @@ -34,59 +34,59 @@ FT_BEGIN_HEADER typedef struct T1_Glyph_Hints_ T1_Glyph_Hints; - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_Size */ - /* */ - /* <Description> */ - /* A handle to a Type 1 size object. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_Size + * + * @Description: + * A handle to a Type 1 size object. + */ typedef struct T1_SizeRec_* T1_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a Type 1 glyph slot object. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_GlyphSlot + * + * @Description: + * A handle to a Type 1 glyph slot object. + */ typedef struct T1_GlyphSlotRec_* T1_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_CharMap */ - /* */ - /* <Description> */ - /* A handle to a Type 1 character mapping object. */ - /* */ - /* <Note> */ - /* The Type 1 format doesn't use a charmap but an encoding table. */ - /* The driver is responsible for making up charmap objects */ - /* corresponding to these tables. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_CharMap + * + * @Description: + * A handle to a Type 1 character mapping object. + * + * @Note: + * The Type 1 format doesn't use a charmap but an encoding table. + * The driver is responsible for making up charmap objects + * corresponding to these tables. + */ typedef struct T1_CharMapRec_* T1_CharMap; - /*************************************************************************/ - /* */ - /* HERE BEGINS THE TYPE1 SPECIFIC STUFF */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * HERE BEGINS THE TYPE1 SPECIFIC STUFF + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_SizeRec */ - /* */ - /* <Description> */ - /* Type 1 size record. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_SizeRec + * + * @Description: + * Type 1 size record. + */ typedef struct T1_SizeRec_ { FT_SizeRec root; @@ -105,14 +105,14 @@ FT_BEGIN_HEADER T1_Size_Init( FT_Size size ); - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_GlyphSlotRec */ - /* */ - /* <Description> */ - /* Type 1 glyph slot record. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_GlyphSlotRec + * + * @Description: + * Type 1 glyph slot record. + */ typedef struct T1_GlyphSlotRec_ { FT_GlyphSlotRec root; diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c b/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c index 8e201e5ef5a..56caeb9e407 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.c @@ -1,36 +1,36 @@ -/***************************************************************************/ -/* */ -/* t1parse.c */ -/* */ -/* Type 1 parser (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The Type 1 parser is in charge of the following: */ - /* */ - /* - provide an implementation of a growing sequence of objects called */ - /* a `T1_Table' (used to build various tables needed by the loader). */ - /* */ - /* - opening .pfb and .pfa files to extract their top-level and private */ - /* dictionaries. */ - /* */ - /* - read numbers, arrays & strings from any dictionary. */ - /* */ - /* See `t1load.c' to see how data is loaded from the font file. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t1parse.c + * + * Type 1 parser (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * The Type 1 parser is in charge of the following: + * + * - provide an implementation of a growing sequence of objects called + * a `T1_Table' (used to build various tables needed by the loader). + * + * - opening .pfb and .pfa files to extract their top-level and private + * dictionaries. + * + * - read numbers, arrays & strings from any dictionary. + * + * See `t1load.c' to see how data is loaded from the font file. + * + */ #include <ft2build.h> @@ -43,14 +43,14 @@ #include "t1errors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1parse +#define FT_COMPONENT t1parse /*************************************************************************/ @@ -169,21 +169,21 @@ } } - /******************************************************************/ - /* */ - /* Here a short summary of what is going on: */ - /* */ - /* When creating a new Type 1 parser, we try to locate and load */ - /* the base dictionary if this is possible (i.e., for PFB */ - /* files). Otherwise, we load the whole font into memory. */ - /* */ - /* When `loading' the base dictionary, we only setup pointers */ - /* in the case of a memory-based stream. Otherwise, we */ - /* allocate and load the base dictionary in it. */ - /* */ - /* parser->in_pfb is set if we are in a binary (`.pfb') font. */ - /* parser->in_memory is set if we have a memory stream. */ - /* */ + /******************************************************************* + * + * Here a short summary of what is going on: + * + * When creating a new Type 1 parser, we try to locate and load + * the base dictionary if this is possible (i.e., for PFB + * files). Otherwise, we load the whole font into memory. + * + * When `loading' the base dictionary, we only setup pointers + * in the case of a memory-based stream. Otherwise, we + * allocate and load the base dictionary in it. + * + * parser->in_pfb is set if we are in a binary (`.pfb') font. + * parser->in_memory is set if we have a memory stream. + */ /* try to compute the size of the base dictionary; */ /* look for a Postscript binary file tag, i.e., 0x8001 */ diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h index 4ac82ae913e..dab8fddc8b6 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1parse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1parse.h */ -/* */ -/* Type 1 parser (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1parse.h + * + * Type 1 parser (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1PARSE_H_ @@ -28,36 +28,45 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_ParserRec */ - /* */ - /* <Description> */ - /* A PS_ParserRec is an object used to parse a Type 1 fonts very */ - /* quickly. */ - /* */ - /* <Fields> */ - /* root :: The root parser. */ - /* */ - /* stream :: The current input stream. */ - /* */ - /* base_dict :: A pointer to the top-level dictionary. */ - /* */ - /* base_len :: The length in bytes of the top dictionary. */ - /* */ - /* private_dict :: A pointer to the private dictionary. */ - /* */ - /* private_len :: The length in bytes of the private dictionary. */ - /* */ - /* in_pfb :: A boolean. Indicates that we are handling a PFB */ - /* file. */ - /* */ - /* in_memory :: A boolean. Indicates a memory-based stream. */ - /* */ - /* single_block :: A boolean. Indicates that the private dictionary */ - /* is stored in lieu of the base dictionary. */ - /* */ + /************************************************************************** + * + * @Struct: + * T1_ParserRec + * + * @Description: + * A PS_ParserRec is an object used to parse a Type 1 fonts very + * quickly. + * + * @Fields: + * root :: + * The root parser. + * + * stream :: + * The current input stream. + * + * base_dict :: + * A pointer to the top-level dictionary. + * + * base_len :: + * The length in bytes of the top dictionary. + * + * private_dict :: + * A pointer to the private dictionary. + * + * private_len :: + * The length in bytes of the private dictionary. + * + * in_pfb :: + * A boolean. Indicates that we are handling a PFB + * file. + * + * in_memory :: + * A boolean. Indicates a memory-based stream. + * + * single_block :: + * A boolean. Indicates that the private dictionary + * is stored in lieu of the base dictionary. + */ typedef struct T1_ParserRec_ { PS_ParserRec root; diff --git a/src/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h b/src/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h index 43a65d88ea4..97f2dbe0cfa 100644 --- a/src/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h +++ b/src/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1tokens.h */ -/* */ -/* Type 1 tokenizer (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1tokens.h + * + * Type 1 tokenizer (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #undef FT_STRUCTURE diff --git a/src/src/java.desktop/share/native/liblcms/cmsxform.c b/src/src/java.desktop/share/native/liblcms/cmsxform.c index 77d54804a42..007f770b676 100644 --- a/src/src/java.desktop/share/native/liblcms/cmsxform.c +++ b/src/src/java.desktop/share/native/liblcms/cmsxform.c @@ -836,7 +836,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, // Save the day? (Ignore the warning) if (Plugin->OldXform) { - p->OldXform = (_cmsTransformFn) p->xform; + p->OldXform = (_cmsTransformFn)(void*) p->xform; p->xform = _cmsTransform2toTransformAdaptor; } diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES b/src/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES index 0ed6a118729..f0b0a9342c3 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/CHANGES @@ -6063,9 +6063,47 @@ Version 1.6.35 [July 15, 2018] Added missing parentheses to a macro definition (suggested by "irwir" in GitHub issue #216) -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit +Version 1.6.36 [December 1, 2018] + Optimized png_do_expand_palette for ARM processors. + Improved performance by around 10-22% on a recent ARM Chromebook. + (Contributed by Richard Townsend, ARM Holdings) + Fixed manipulation of machine-specific optimization options. + (Contributed by Vicki Pfau) + Used memcpy instead of manual pointer arithmetic on Intel SSE2. + (Contributed by Samuel Williams) + Fixed build errors with MSVC on ARM64. + (Contributed by Zhijie Liang) + Fixed detection of libm in CMakeLists. + (Contributed by Cameron Cawley) + Fixed incorrect creation of pkg-config file in CMakeLists. + (Contributed by Kyle Bentley) + Fixed the CMake build on Windows MSYS by avoiding symlinks. + Fixed a build warning on OpenBSD. + (Contributed by Theo Buehler) + Fixed various typos in comments. + (Contributed by "luz.paz") + Raised the minimum required CMake version from 3.0.2 to 3.1. + Removed yet more of the vestigial support for pre-ANSI C compilers. + Removed ancient makefiles for ancient systems that have been broken + across all previous libpng-1.6.x versions. + Removed the Y2K compliance statement and the export control + information. + Applied various code style and documentation fixes. + +Version 1.6.37 [April 14, 2019] + Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. + Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. + Fixed a memory leak in pngtest.c. + Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in + contrib/pngminus; refactor. + Changed the license of contrib/pngminus to MIT; refresh makefile and docs. + (Contributed by Willem van Schaik) + Fixed a typo in the libpng license v2. + (Contributed by Miguel Ojeda) + Added makefiles for AddressSanitizer-enabled builds. + Cleaned up various makefiles. + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net. +Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe). - -Glenn R-P +to subscribe. diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE b/src/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE index 6ee9c8f5548..e0c5b531cf5 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/LICENSE @@ -1,53 +1,82 @@ +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE +========================================= -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. +PNG Reference Library License version 2 +--------------------------------------- -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * Copyright (c) 1995-2019 The PNG Reference Library Authors. + * Copyright (c) 2018-2019 Cosmin Truta. + * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. + * Copyright (c) 1996-1997 Andreas Dilger. + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. -If you modify libpng you may insert additional notices immediately following -this sentence. +The software is supplied "as is", without warranty of any kind, +express or implied, including, without limitation, the warranties +of merchantability, fitness for a particular purpose, title, and +non-infringement. In no event shall the Copyright owners, or +anyone distributing the software, be liable for any damages or +other liability, whether in contract, tort or otherwise, arising +from, out of, or in connection with the software, or the use or +other dealings in the software, even if advised of the possibility +of such damage. -This code is released under the libpng license. +Permission is hereby granted to use, copy, modify, and distribute +this software, or portions hereof, for any purpose, without fee, +subject to the following restrictions: -libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you + use this software in a product, an acknowledgment in the product + documentation would be appreciated, but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + + +PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) +----------------------------------------------------------------------- + +libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are derived from libpng-1.0.6, and are distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors: - Simon-Pierre Cadieux - Eric S. Raymond - Mans Rullgard - Cosmin Truta - Gilles Vollant - James Yu - Mandar Sahastrabuddhe - Google Inc. - Vadim Barkov + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + Mandar Sahastrabuddhe + Google Inc. + Vadim Barkov and with the following additions to the disclaimer: - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. + There is no warranty against interference with your enjoyment of + the library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is + with the user. Some files in the "contrib" directory and some configure-generated -files that are distributed with libpng have other copyright owners and +files that are distributed with libpng have other copyright owners, and are released under other open source licenses. libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from libpng-0.96, and are distributed according to the same disclaimer and -license as libpng-0.96, with the following individuals added to the list -of Contributing Authors: +license as libpng-0.96, with the following individuals added to the +list of Contributing Authors: - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik libpng versions 0.89, June 1996, through 0.96, May 1997, are Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, @@ -55,14 +84,14 @@ and are distributed according to the same disclaimer and license as libpng-0.88, with the following individuals added to the list of Contributing Authors: - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner -Some files in the "scripts" directory have other copyright owners +Some files in the "scripts" directory have other copyright owners, but are released under this license. libpng versions 0.5, May 1995, through 0.88, January 1996, are @@ -71,63 +100,35 @@ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. For the purposes of this copyright and license, "Contributing Authors" is defined as the following set of individuals: - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing +Authors and Group 42, Inc. disclaim all warranties, expressed or +implied, including, without limitation, the warranties of +merchantability and of fitness for any purpose. The Contributing +Authors and Group 42, Inc. assume no liability for direct, indirect, +incidental, special, exemplary, or consequential damages, which may +result from the use of the PNG Reference Library, even if advised of +the possibility of such damage. Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions: - 1. The origin of this source code must not be misrepresented. - - 2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. - - 3. This Copyright notice may not be removed or altered from any - source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - -END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. - -TRADEMARK: - -The name "libpng" has not been registered by the Copyright owner -as a trademark in any jurisdiction. However, because libpng has -been distributed and maintained world-wide, continually since 1995, -the Copyright owner claims "common-law trademark protection" in any -jurisdiction where common-law trademark is recognized. - -OSI CERTIFICATION: - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is -a certification mark of the Open Source Initiative. OSI has not addressed -the additional disclaimers inserted at version 1.0.7. + 1. The origin of this source code must not be misrepresented. -EXPORT CONTROL: + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. -The Copyright owner believes that the Export Control Classification -Number (ECCN) for libpng is EAR99, which means not subject to export -controls or International Traffic in Arms Regulations (ITAR) because -it is open source, publicly available software, that does not contain -any encryption software. See the EAR, paragraphs 734.3(b)(3) and -734.7(b). + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -July 15, 2018 +The Contributing Authors and Group 42, Inc. specifically permit, +without fee, and encourage the use of this source code as a component +to supporting the PNG file format in commercial products. If you use +this source code in a product, acknowledgment is not required but would +be appreciated. diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/README b/src/src/java.desktop/share/native/libsplashscreen/libpng/README index f098b27f397..cfc1f0e3dc9 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/README +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/README @@ -1,15 +1,16 @@ -README for libpng version 1.6.35 - July 15, 2018 (shared library 16.0) -See the note about version numbers near the top of png.h +README for libpng version 1.6.37 - April 14, 2019 +================================================= +See the note about version numbers near the top of png.h. See INSTALL for instructions on how to install libpng. Libpng comes in several distribution formats. Get libpng-*.tar.gz or -libpng-*.tar.xz or if you want UNIX-style line endings in the text files, -or lpng*.7z or lpng*.zip if you want DOS-style line endings. +libpng-*.tar.xz or if you want UNIX-style line endings in the text +files, or lpng*.7z or lpng*.zip if you want DOS-style line endings. Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had +fact that it's the first release fool you. The libpng library has been +in extensive use and testing since mid-1995. By late 1997 it had finally gotten to the stage where there hadn't been significant changes to the API in some time, and people have a bad feeling about libraries with versions < 1.0. Version 1.0.0 was released in @@ -60,59 +61,37 @@ the library action on the detection of chunk CRC errors. It is possible to set different actions based on whether the CRC error occurred in a critical or an ancillary chunk. -The changes made to the library, and bugs fixed are based on discussions -on the PNG-implement mailing list and not on material submitted -privately to Guy, Andreas, or Glenn. They will forward any good -suggestions to the list. - -For a detailed description on using libpng, read libpng-manual.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h +For a detailed description on using libpng, read libpng-manual.txt. +For examples of libpng in a program, see example.c and pngtest.c. For +usage information and restrictions (what little they are) on libpng, +see png.h. For a description on using zlib (the compression library +used by libpng) and zlib's restrictions, see zlib.h I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. +compiler specific ones, but you may have to modify one for your own +needs. You should use zlib 1.0.4 or later to run this, but it MAY work with versions as old as zlib 0.95. Even so, there are bugs in older zlib versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. +some images. + +You should also note that zlib is a compression library that is useful +for more things than just PNG files. You can use zlib as a drop-in +replacement for fread() and fwrite(), if you are so inclined. -zlib should be available at the same place that libpng is, or at zlib.net. +zlib should be available at the same place that libpng is, or at +https://zlib.net. You may also want a copy of the PNG specification. It is available as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find these at http://www.libpng.org/pub/png/pngdocs.html . This code is currently being archived at libpng.sourceforge.io in the -[DOWNLOAD] area, and at http://libpng.download/src . If you -can't find it in any of those places, e-mail me, and I'll help you find it. - -I am not a lawyer, but I believe that the Export Control Classification -Number (ECCN) for libpng is EAR99, which means not subject to export -controls or International Traffic in Arms Regulations (ITAR) because it -is open source, publicly available software, that does not contain any -encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b). - -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG +[DOWNLOAD] area, and at http://libpng.download/src . + +This release, based in a large way on Glenn's, Guy's and Andreas' +earlier work, was created and will be supported by myself and the PNG development group. Send comments/corrections/commendations to png-mng-implement at @@ -120,34 +99,21 @@ lists.sourceforge.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement to subscribe). -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will -read mail addressed to the png-implement list, however. - -Please do not send general questions about PNG. Send them to -png-mng-misc at lists.sf.net (subscription required; visit +Send general questions about the PNG specification to png-mng-misc +at lists.sourceforge.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-misc to -subscribe). If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for twenty years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used immediately, -it may be used later. +subscribe). Files in this distribution: ANNOUNCE => Announcement of this version, with recent changes + AUTHORS => List of contributing authors CHANGES => Description of changes between libpng versions KNOWNBUG => List of known bugs and deficiencies LICENSE => License to use and redistribute libpng README => This file TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance + TRADEMARK => Trademark information example.c => Example code for using libpng functions libpng.3 => manual page for libpng (includes libpng-manual.txt) libpng-manual.txt => Description of libpng and its functions @@ -208,15 +174,10 @@ Files in this distribution: scripts => Directory containing scripts for building libpng: (see scripts/README.txt for the list of scripts) -Good luck, and happy coding. - --Glenn Randers-Pehrson (current maintainer, since 1998) - Internet: glennrp at users.sourceforge.net - --Andreas Eric Dilger (former maintainer, 1996-1997) - Internet: adilger at enel.ucalgary.ca - Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ +Good luck, and happy coding! --Guy Eric Schalnat (original author and former maintainer, 1995-1996) - (formerly of Group 42, Inc) - Internet: gschal at infinet.com + * Cosmin Truta (current maintainer, since 2018) + * Glenn Randers-Pehrson (former maintainer, 1998-2018) + * Andreas Eric Dilger (former maintainer, 1996-1997) + * Guy Eric Schalnat (original author and former maintainer, 1995-1996) + (formerly of Group 42, Inc.) diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/png.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/png.c index a471c76d060..3740c3cd214 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/png.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/png.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -42,7 +42,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_35 Your_png_h_is_not_version_1_6_35; +typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has @@ -764,7 +764,7 @@ png_save_int_32(png_bytep buf, png_int_32 i) int PNGAPI png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) { - static PNG_CONST char short_months[12][4] = + static const char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; @@ -842,20 +842,14 @@ png_get_copyright(png_const_structrp png_ptr) #ifdef PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT #else -# ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.35 - July 15, 2018" PNG_STRING_NEWLINE \ + "libpng version 1.6.37" PNG_STRING_NEWLINE \ + "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; -# else - return "libpng version 1.6.35 - July 15, 2018\ - Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson\ - Copyright (c) 1996-1997 Andreas Dilger\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; -# endif #endif } @@ -1149,7 +1143,7 @@ png_colorspace_set_gamma(png_const_structrp png_ptr, png_colorspacerp colorspace, png_fixed_point gAMA) { /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't - * occur. Since the fixed point representation is asymetrical it is + * occur. Since the fixed point representation is asymmetrical it is * possible for 1/gamma to overflow the limit of 21474 and this means the * gamma value must be at least 5/100000 and hence at most 20000.0. For * safety the limits here are a little narrower. The values are 0.00016 to @@ -3162,11 +3156,11 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size, /* The total output count (max) is now 4+precision */ /* Check for an exponent, if we don't need one we are - * done and just need to terminate the string. At - * this point exp_b10==(-1) is effectively a flag - it got - * to '-1' because of the decrement after outputting - * the decimal point above (the exponent required is - * *not* -1!) + * done and just need to terminate the string. At this + * point, exp_b10==(-1) is effectively a flag: it got + * to '-1' because of the decrement, after outputting + * the decimal point above. (The exponent required is + * *not* -1.) */ if (exp_b10 >= (-1) && exp_b10 <= 2) { @@ -4004,18 +3998,18 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value, */ static void png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) + unsigned int shift, png_fixed_point gamma_val) { /* Various values derived from 'shift': */ - PNG_CONST unsigned int num = 1U << (8U - shift); + unsigned int num = 1U << (8U - shift); #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED /* CSE the division and work round wacky GCC warnings (see the comments * in png_gamma_8bit_correct for where these come from.) */ - PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1); + double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1); #endif - PNG_CONST unsigned int max = (1U << (16U - shift))-1U; - PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); + unsigned int max = (1U << (16U - shift)) - 1U; + unsigned int max_by_2 = 1U << (15U - shift); unsigned int i; png_uint_16pp table = *ptable = @@ -4081,10 +4075,10 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, */ static void png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) + unsigned int shift, png_fixed_point gamma_val) { - PNG_CONST unsigned int num = 1U << (8U - shift); - PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + unsigned int num = 1U << (8U - shift); + unsigned int max = (1U << (16U - shift))-1U; unsigned int i; png_uint_32 last; @@ -4149,7 +4143,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, */ static void png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, - PNG_CONST png_fixed_point gamma_val) + png_fixed_point gamma_val) { unsigned int i; png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/png.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/png.h index d3beb21c04f..e5e87d3b818 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/png.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/png.h @@ -29,68 +29,105 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * libpng version 1.6.35, July 15, 2018 + * libpng version 1.6.37 - April 14, 2019 * + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * - * This code is released under the libpng license (See LICENSE, below) + * This code is released under the libpng license. (See LICENSE, below.) * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.35, July 15, 2018: - * Glenn Randers-Pehrson. + * libpng versions 0.97, January 1998, through 1.6.35, July 2018: + * Glenn Randers-Pehrson + * libpng versions 1.6.36, December 2018, through 1.6.37, April 2019: + * Cosmin Truta * See also "Contributing Authors", below. */ /* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE + * ========================================= + * + * PNG Reference Library License version 2 + * --------------------------------------- + * + * * Copyright (c) 1995-2019 The PNG Reference Library Authors. + * * Copyright (c) 2018-2019 Cosmin Truta. + * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. + * * Copyright (c) 1996-1997 Andreas Dilger. + * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + * + * The software is supplied "as is", without warranty of any kind, + * express or implied, including, without limitation, the warranties + * of merchantability, fitness for a particular purpose, title, and + * non-infringement. In no event shall the Copyright owners, or + * anyone distributing the software, be liable for any damages or + * other liability, whether in contract, tort or otherwise, arising + * from, out of, or in connection with the software, or the use or + * other dealings in the software, even if advised of the possibility + * of such damage. + * + * Permission is hereby granted to use, copy, modify, and distribute + * this software, or portions hereof, for any purpose, without fee, + * subject to the following restrictions: * - * If you modify libpng you may insert additional notices immediately following - * this sentence. + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you + * use this software in a product, an acknowledgment in the product + * documentation would be appreciated, but is not required. * - * This code is released under the libpng license. + * 2. Altered source versions must be plainly marked as such, and must + * not be misrepresented as being the original software. * - * libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are + * 3. This Copyright notice may not be removed or altered from any + * source or altered source distribution. + * + * + * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) + * ----------------------------------------------------------------------- + * + * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are * derived from libpng-1.0.6, and are distributed according to the same * disclaimer and license as libpng-1.0.6 with the following individuals * added to the list of Contributing Authors: * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Mans Rullgard - * Cosmin Truta - * Gilles Vollant - * James Yu - * Mandar Sahastrabuddhe - * Google Inc. - * Vadim Barkov + * Simon-Pierre Cadieux + * Eric S. Raymond + * Mans Rullgard + * Cosmin Truta + * Gilles Vollant + * James Yu + * Mandar Sahastrabuddhe + * Google Inc. + * Vadim Barkov * * and with the following additions to the disclaimer: * - * There is no warranty against interference with your enjoyment of the - * library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is with - * the user. + * There is no warranty against interference with your enjoyment of + * the library or against infringement. There is no warranty that our + * efforts or the library will fulfill any of your particular purposes + * or needs. This library is provided with all faults, and the entire + * risk of satisfactory quality, performance, accuracy, and effort is + * with the user. * * Some files in the "contrib" directory and some configure-generated - * files that are distributed with libpng have other copyright owners and + * files that are distributed with libpng have other copyright owners, and * are released under other open source licenses. * * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from * libpng-0.96, and are distributed according to the same disclaimer and - * license as libpng-0.96, with the following individuals added to the list - * of Contributing Authors: + * license as libpng-0.96, with the following individuals added to the + * list of Contributing Authors: * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik + * Tom Lane + * Glenn Randers-Pehrson + * Willem van Schaik * * libpng versions 0.89, June 1996, through 0.96, May 1997, are * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, @@ -98,14 +135,14 @@ * libpng-0.88, with the following individuals added to the list of * Contributing Authors: * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner + * John Bowler + * Kevin Bracey + * Sam Bushell + * Magnus Holmgren + * Greg Roelofs + * Tom Tanner * - * Some files in the "scripts" directory have other copyright owners + * Some files in the "scripts" directory have other copyright owners, * but are released under this license. * * libpng versions 0.5, May 1995, through 0.88, January 1996, are @@ -114,62 +151,49 @@ * For the purposes of this copyright and license, "Contributing Authors" * is defined as the following set of individuals: * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing Authors - * and Group 42, Inc. disclaim all warranties, expressed or implied, - * including, without limitation, the warranties of merchantability and of - * fitness for any purpose. The Contributing Authors and Group 42, Inc. - * assume no liability for direct, indirect, incidental, special, exemplary, - * or consequential damages, which may result from the use of the PNG - * Reference Library, even if advised of the possibility of such damage. + * Andreas Dilger + * Dave Martindale + * Guy Eric Schalnat + * Paul Schmidt + * Tim Wegner + * + * The PNG Reference Library is supplied "AS IS". The Contributing + * Authors and Group 42, Inc. disclaim all warranties, expressed or + * implied, including, without limitation, the warranties of + * merchantability and of fitness for any purpose. The Contributing + * Authors and Group 42, Inc. assume no liability for direct, indirect, + * incidental, special, exemplary, or consequential damages, which may + * result from the use of the PNG Reference Library, even if advised of + * the possibility of such damage. * * Permission is hereby granted to use, copy, modify, and distribute this * source code, or portions hereof, for any purpose, without fee, subject * to the following restrictions: * - * 1. The origin of this source code must not be misrepresented. + * 1. The origin of this source code must not be misrepresented. * - * 2. Altered versions must be plainly marked as such and must not - * be misrepresented as being the original source. + * 2. Altered versions must be plainly marked as such and must not + * be misrepresented as being the original source. * - * 3. This Copyright notice may not be removed or altered from any - * source or altered source distribution. + * 3. This Copyright notice may not be removed or altered from any + * source or altered source distribution. * - * The Contributing Authors and Group 42, Inc. specifically permit, without - * fee, and encourage the use of this source code as a component to - * supporting the PNG file format in commercial products. If you use this - * source code in a product, acknowledgment is not required but would be - * appreciated. + * The Contributing Authors and Group 42, Inc. specifically permit, + * without fee, and encourage the use of this source code as a component + * to supporting the PNG file format in commercial products. If you use + * this source code in a product, acknowledgment is not required but would + * be appreciated. * * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. * - * TRADEMARK: + * TRADEMARK + * ========= * - * The name "libpng" has not been registered by the Copyright owner + * The name "libpng" has not been registered by the Copyright owners * as a trademark in any jurisdiction. However, because libpng has * been distributed and maintained world-wide, continually since 1995, - * the Copyright owner claims "common-law trademark protection" in any + * the Copyright owners claim "common-law trademark protection" in any * jurisdiction where common-law trademark is recognized. - * - * OSI CERTIFICATION: - * - * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is - * a certification mark of the Open Source Initiative. OSI has not addressed - * the additional disclaimers inserted at version 1.0.7. - * - * EXPORT CONTROL: - * - * The Copyright owner believes that the Export Control Classification - * Number (ECCN) for libpng is EAR99, which means not subject to export - * controls or International Traffic in Arms Regulations (ITAR) because - * it is open source, publicly available software, that does not contain - * any encryption software. See the EAR, paragraphs 734.3(b)(3) and - * 734.7(b). */ /* @@ -235,23 +259,25 @@ * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) * 1.0.7 1 10007 (still compatible) * ... - * 1.0.19 10 10019 10.so.0.19[.0] + * 1.0.69 10 10069 10.so.0.69[.0] + * ... + * 1.2.59 13 10259 12.so.0.59[.0] * ... - * 1.2.59 13 10257 12.so.0.59[.0] + * 1.4.20 14 10420 14.so.0.20[.0] * ... - * 1.5.30 15 10527 15.so.15.30[.0] + * 1.5.30 15 10530 15.so.15.30[.0] * ... - * 1.6.35 16 10635 16.so.16.35[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcNN". + * 1.6.37 16 10637 16.so.16.37[.0] + * + * Henceforth the source version will match the shared-library major and + * minor numbers; the shared-library major version number will be used for + * changes in backward compatibility, as it is intended. + * The PNG_LIBPNG_VER macro, which is not used within libpng but is + * available for applications, is an unsigned integer of the form XYYZZ + * corresponding to the source version X.Y.Z (leading zeros in Y and Z). + * Beta versions were given the previous public release number plus a + * letter, until version 1.0.6j; from then on they were given the upcoming + * public release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled @@ -261,65 +287,8 @@ * in binary compatibility (e.g., when a new feature is added). * * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * <https://www.w3.org/TR/2003/REC-PNG-20031110/ - */ - -/* - * Y2K compliance in libpng: - * ========================= - * - * July 15, 2018 - * - * Since the PNG Development group is an ad-hoc body, we can't make - * an official declaration. - * - * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.6.35 are Y2K compliant. It is my belief that - * earlier versions were also Y2K compliant. - * - * Libpng only has two year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other, which is deprecated, - * holds the date in text format, and will hold years up to 9999. - * - * The integer is - * "png_uint_16 year" in png_time_struct. - * - * The string is - * "char time_buffer[29]" in png_struct. This is no longer used - * in libpng-1.6.x and will be removed from libpng-1.7.0. - * - * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123_buffer() in png.c - * (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and - * png_convert_to_rfc_1152() in error prior to libpng-0.98) - * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - * png_convert_from_time_t() in pngwrite.c - * png_get_tIME() in pngget.c - * png_handle_tIME() in pngrutil.c, called in pngread.c - * png_set_tIME() in pngset.c - * png_write_tIME() in pngwutil.c, called in pngwrite.c - * - * All handle dates properly in a Y2K environment. The - * png_convert_from_time_t() function calls gmtime() to convert from system - * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that libpng applications - * are not passing 4-digit years into the png_convert_to_rfc_1123_buffer() - * function, or that they are incorrectly passing only a 2-digit year - * instead of "year - 1900" into the png_convert_from_struct_tm() function, - * but this is not under our control. The libpng documentation has always - * stated that it works with 4-digit years, and the APIs have been - * documented as such. - * - * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - * integer to hold the year, and can hold years as large as 65535. - * - * zlib, upon which libpng depends, is also Y2K compliant. It contains - * no date-related code. - * - * Glenn Randers-Pehrson - * libpng maintainer - * PNG Development Group + * is available as a W3C Recommendation and as an ISO/IEC Standard; see + * <https://www.w3.org/TR/2003/REC-PNG-20031110/> */ #ifndef PNG_H @@ -337,8 +306,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.35" -#define PNG_HEADER_VERSION_STRING " libpng version 1.6.35 - July 15, 2018\n" +#define PNG_LIBPNG_VER_STRING "1.6.37" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -346,13 +315,12 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 35 +#define PNG_LIBPNG_VER_RELEASE 37 -/* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: +/* This should be zero for a public release, or non-zero for a + * development version. [Deprecated] */ - -#define PNG_LIBPNG_VER_BUILD 02 +#define PNG_LIBPNG_VER_BUILD 0 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -369,15 +337,16 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE -/* Careful here. At one time, Guy wanted to use 082, but that would be octal. - * We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only - * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release +/* Careful here. At one time, Guy wanted to use 082, but that + * would be octal. We must not include leading zeros. + * Versions 0.7 through 1.0.0 were in the range 0 to 100 here + * (only version 1.0.0 was mis-numbered 100 instead of 10000). + * From version 1.0.1 it is: + * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10635 /* 1.6.35 */ +#define PNG_LIBPNG_VER 10637 /* 1.6.37 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -487,7 +456,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_35; +typedef char* png_libpng_version_1_6_37; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -2041,12 +2010,12 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *exif)); PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr, - png_inforp info_ptr, const png_bytep exif)); + png_inforp info_ptr, png_bytep exif)); PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif)); PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr, - png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif)); + png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif)); #endif #ifdef PNG_gAMA_SUPPORTED @@ -2792,7 +2761,7 @@ typedef struct * * When the simplified API needs to convert between sRGB and linear colorspaces, * the actual sRGB transfer curve defined in the sRGB specification (see the - * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 + * article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2 * approximation used elsewhere in libpng. * * When an alpha channel is present it is expected to denote pixel coverage @@ -2995,7 +2964,7 @@ typedef struct * 'flags' field of png_image. */ #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 - /* This indicates the the RGB values of the in-memory bitmap do not + /* This indicates that the RGB values of the in-memory bitmap do not * correspond to the red, green and blue end-points defined by sRGB. */ diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h index b010164b130..e6c993b8573 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngconf.h @@ -22,18 +22,19 @@ * questions. */ -/* pngconf.h - machine configurable file for libpng +/* pngconf.h - machine-configurable file for libpng * * 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 and, per its terms, should not be removed: * - * libpng version 1.6.35, July 15, 2018 + * libpng version 1.6.37 * + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -85,14 +86,13 @@ #endif /* PNG_BUILDING_SYMBOL_TABLE */ -/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using - * PNG_NO_CONST; this is no longer supported except for data declarations which - * apparently still cause problems in 2011 on some compilers. +/* Prior to 1.6.0, it was possible to turn off 'const' in declarations, + * using PNG_NO_CONST. This is no longer supported. */ #define PNG_CONST const /* backward compatibility only */ -/* This controls optimization of the reading of 16-bit and 32-bit values - * from PNG files. It can be set on a per-app-file basis - it +/* This controls optimization of the reading of 16-bit and 32-bit + * values from PNG files. It can be set on a per-app-file basis: it * just changes whether a macro is used when the function is called. * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h index f65bb8a3e0f..8eb5400ea9a 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngdebug.h @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.8 [December 19, 2013] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c index 672fb35b0c9..623735f06f1 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngerror.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.31 [July 27, 2017] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -453,7 +453,7 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message) * if the character is invalid. */ #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) -static PNG_CONST char png_digit[16] = { +static const char png_digit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; @@ -913,7 +913,7 @@ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), PNG_NORETURN) { - const png_const_structrp png_ptr = png_nonconst_ptr; + png_const_structrp png_ptr = png_nonconst_ptr; png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); /* An error is always logged here, overwriting anything (typically a warning) @@ -948,7 +948,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), void /* PRIVATE */ PNGCBAPI png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message) { - const png_const_structrp png_ptr = png_nonconst_ptr; + png_const_structrp png_ptr = png_nonconst_ptr; png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); /* A warning is only logged if there is no prior warning or error. */ diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c index 79a036ceb59..4e5f6c962a5 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngget.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h index 4317f2a16bf..d241eaebffb 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pnginfo.h @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h index ab1341507d6..7cf81e122b7 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pnglibconf.h @@ -29,18 +29,16 @@ * THIS FILE WAS MODIFIED BY ORACLE, INC. */ -/* libpng STANDARD API DEFINITION */ - /* pnglibconf.h - library build configuration */ /* 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 and, per its terms, should not be removed: */ +/* libpng version 1.6.37 */ -/* libpng version 1.6.35, July 15, 2018 */ - -/* Copyright (c) 1998-2018 Glenn Randers-Pehrson */ +/* Copyright (c) 2018-2019 Cosmin Truta */ +/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ /* For conditions of distribution and use, see the disclaimer */ @@ -80,6 +78,8 @@ #define PNG_IO_STATE_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED +/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/ +/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/ #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED @@ -118,6 +118,7 @@ #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED +/*#undef PNG_READ_eXIf_SUPPORTED*/ #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED /*#undef PNG_READ_iCCP_SUPPORTED*/ @@ -187,6 +188,7 @@ /*#undef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED*/ /*#undef PNG_WRITE_bKGD_SUPPORTED*/ /*#undef PNG_WRITE_cHRM_SUPPORTED*/ +/*#undef PNG_WRITE_eXIf_SUPPORTED*/ /*#undef PNG_WRITE_gAMA_SUPPORTED*/ /*#undef PNG_WRITE_hIST_SUPPORTED*/ /*#undef PNG_WRITE_iCCP_SUPPORTED*/ @@ -204,6 +206,7 @@ /*#undef PNG_WRITE_zTXt_SUPPORTED*/ #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED +/*#undef PNG_eXIf_SUPPORTED*/ #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED @@ -241,7 +244,7 @@ #define PNG_USER_HEIGHT_MAX 8000 #define PNG_USER_WIDTH_MAX 8000 #define PNG_ZBUF_SIZE 8192 -#define PNG_ZLIB_VERNUM 0 +#define PNG_ZLIB_VERNUM 0 /* unknown */ #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1 diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c index 51c826a31e6..d5ad0735f37 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngmem.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c index 7506ff9b421..a98b2013256 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpread.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -1000,20 +1000,20 @@ png_read_push_finish_row(png_structrp png_ptr) /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h - static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; + static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ #endif diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h index b1f9994daef..5f704260305 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -202,7 +202,10 @@ # else /* !defined __ARM_NEON__ */ /* The 'intrinsics' code simply won't compile without this -mfpu=neon: */ -# define PNG_ARM_NEON_IMPLEMENTATION 2 +# if !defined(__aarch64__) + /* The assembler code currently does not work on ARM64 */ +# define PNG_ARM_NEON_IMPLEMENTATION 2 +# endif /* __aarch64__ */ # endif /* __ARM_NEON__ */ # endif /* !PNG_ARM_NEON_IMPLEMENTATION */ @@ -298,6 +301,7 @@ #endif + /* Is this a build of a DLL where compilation of the object modules requires * different preprocessor settings to those required for a simple library? If * so PNG_BUILD_DLL must be set. @@ -1564,10 +1568,10 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, #endif PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr, - const png_uint_32 chunk_name),PNG_EMPTY); + png_uint_32 chunk_name),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr, - const png_uint_32 chunk_length),PNG_EMPTY); + png_uint_32 chunk_length),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); @@ -2144,6 +2148,29 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2, PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr, png_const_charp key, png_bytep new_key), PNG_EMPTY); +#if PNG_ARM_NEON_IMPLEMENTATION == 1 +PNG_INTERNAL_FUNCTION(void, + png_riffle_palette_neon, + (png_structrp), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(int, + png_do_expand_palette_rgba8_neon, + (png_structrp, + png_row_infop, + png_const_bytep, + const png_bytepp, + const png_bytepp), + PNG_EMPTY); +PNG_INTERNAL_FUNCTION(int, + png_do_expand_palette_rgb8_neon, + (png_structrp, + png_row_infop, + png_const_bytep, + const png_bytepp, + const png_bytepp), + PNG_EMPTY); +#endif + /* Maintainer: Put new private prototypes here ^ */ #include "pngdebug.h" diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c index 6955be06c96..b558c5716f8 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngread.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -1022,6 +1022,12 @@ png_read_destroy(png_structrp png_ptr) png_ptr->chunk_list = NULL; #endif +#if defined(PNG_READ_EXPAND_SUPPORTED) && \ + defined(PNG_ARM_NEON_IMPLEMENTATION) + png_free(png_ptr, png_ptr->riffled_palette); + png_ptr->riffled_palette = NULL; +#endif + /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error * callbacks are still set at this point. They are required to complete the * destruction of the png_struct itself. @@ -1649,7 +1655,7 @@ png_image_skip_unused_chunks(png_structrp png_ptr) * errors (which are unfortunately quite common.) */ { - static PNG_CONST png_byte chunks_to_process[] = { + static const png_byte chunks_to_process[] = { 98, 75, 71, 68, '\0', /* bKGD */ 99, 72, 82, 77, '\0', /* cHRM */ 103, 65, 77, 65, '\0', /* gAMA */ @@ -1786,9 +1792,9 @@ png_create_colormap_entry(png_image_read_control *display, png_uint_32 alpha, int encoding) { png_imagep image = display->image; - const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? + int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? P_LINEAR : P_sRGB; - const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && + int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && (red != green || green != blue); if (ip > 255) @@ -1897,13 +1903,13 @@ png_create_colormap_entry(png_image_read_control *display, /* Store the value. */ { # ifdef PNG_FORMAT_AFIRST_SUPPORTED - const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && + int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; # else # define afirst 0 # endif # ifdef PNG_FORMAT_BGR_SUPPORTED - const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; + int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; # else # define bgr 0 # endif @@ -2113,11 +2119,11 @@ png_image_read_colormap(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, argument); - const png_imagep image = display->image; + png_imagep image = display->image; - const png_structrp png_ptr = image->opaque->png_ptr; - const png_uint_32 output_format = image->format; - const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ? + png_structrp png_ptr = image->opaque->png_ptr; + png_uint_32 output_format = image->format; + int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ? P_LINEAR : P_sRGB; unsigned int cmap_entries; @@ -2830,7 +2836,7 @@ png_image_read_colormap(png_voidp argument) unsigned int num_trans = png_ptr->num_trans; png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL; png_const_colorp colormap = png_ptr->palette; - const int do_background = trans != NULL && + int do_background = trans != NULL && (output_format & PNG_FORMAT_FLAG_ALPHA) == 0; unsigned int i; @@ -3974,7 +3980,7 @@ png_image_read_direct(png_voidp argument) */ if (linear != 0) { - PNG_CONST png_uint_16 le = 0x0001; + png_uint_16 le = 0x0001; if ((*(png_const_bytep) & le) != 0) png_set_swap(png_ptr); @@ -4136,7 +4142,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background, * original PNG format because it may not occur in the output PNG format * and libpng deals with the issues of reading the original. */ - const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); + unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); /* The following checks just the 'row_stride' calculation to ensure it * fits in a signed 32-bit value. Because channels/components can be @@ -4147,7 +4153,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background, if (image->width <= 0x7fffffffU/channels) /* no overflow */ { png_uint_32 check; - const png_uint_32 png_row_stride = image->width * channels; + png_uint_32 png_row_stride = image->width * channels; if (row_stride == 0) row_stride = (png_int_32)/*SAFE*/png_row_stride; diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c index 90d3abdb2ab..961d010df42 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrio.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c index e12d32d7c60..efe7135553a 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrtran.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -46,6 +46,17 @@ #include "pngpriv.h" +#ifdef PNG_ARM_NEON_IMPLEMENTATION +# if PNG_ARM_NEON_IMPLEMENTATION == 1 +# define PNG_ARM_NEON_INTRINSICS_AVAILABLE +# if defined(_MSC_VER) && defined(_M_ARM64) +# include <arm64_neon.h> +# else +# include <arm_neon.h> +# endif +# endif +#endif + #ifdef PNG_READ_SUPPORTED /* Set the action on getting a CRC error for an ancillary or critical chunk. */ @@ -1199,20 +1210,20 @@ png_init_palette_transformations(png_structrp png_ptr) png_ptr->palette[png_ptr->background.index].blue; #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) - { - if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) - { - /* Invert the alpha channel (in tRNS) unless the pixels are - * going to be expanded, in which case leave it for later - */ - int i, istop = png_ptr->num_trans; - - for (i=0; i<istop; i++) - png_ptr->trans_alpha[i] = (png_byte)(255 - - png_ptr->trans_alpha[i]); - } - } + if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) + { + if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) + { + /* Invert the alpha channel (in tRNS) unless the pixels are + * going to be expanded, in which case leave it for later + */ + int i, istop = png_ptr->num_trans; + + for (i = 0; i < istop; i++) + png_ptr->trans_alpha[i] = + (png_byte)(255 - png_ptr->trans_alpha[i]); + } + } #endif /* READ_INVERT_ALPHA */ } } /* background expand and (therefore) no alpha association. */ @@ -3014,7 +3025,6 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) */ static int png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) - { int rgb_error = 0; @@ -3023,12 +3033,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 && (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) { - PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - PNG_CONST png_uint_32 bc = 32768 - rc - gc; - PNG_CONST png_uint_32 row_width = row_info->width; - PNG_CONST int have_alpha = - (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; + png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + png_uint_32 bc = 32768 - rc - gc; + png_uint_32 row_width = row_info->width; + int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; if (row_info->bit_depth == 8) { @@ -4171,12 +4180,11 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) { if (row_info->bit_depth == 8) { - PNG_CONST png_bytep table = png_ptr->gamma_from_1; + png_bytep table = png_ptr->gamma_from_1; if (table != NULL) { - PNG_CONST int step = - (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; + int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; /* The alpha channel is the last component: */ row += step - 1; @@ -4190,13 +4198,12 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) else if (row_info->bit_depth == 16) { - PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1; - PNG_CONST int gamma_shift = png_ptr->gamma_shift; + png_uint_16pp table = png_ptr->gamma_16_from_1; + int gamma_shift = png_ptr->gamma_shift; if (table != NULL) { - PNG_CONST int step = - (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; + int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; /* The alpha channel is the last component: */ row += step - 2; @@ -4227,8 +4234,9 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) * upon whether you supply trans and num_trans. */ static void -png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) +png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info, + png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha, + int num_trans) { int shift, value; png_bytep sp, dp; @@ -4332,14 +4340,27 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, sp = row + (size_t)row_width - 1; dp = row + ((size_t)row_width << 2) - 1; - for (i = 0; i < row_width; i++) + i = 0; +#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE + if (png_ptr->riffled_palette != NULL) + { + /* The RGBA optimization works with png_ptr->bit_depth == 8 + * but sometimes row_info->bit_depth has been changed to 8. + * In these cases, the palette hasn't been riffled. + */ + i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row, + &sp, &dp); + } +#else + PNG_UNUSED(png_ptr) +#endif + + for (; i < row_width; i++) { if ((int)(*sp) >= num_trans) *dp-- = 0xff; - else *dp-- = trans_alpha[*sp]; - *dp-- = palette[*sp].blue; *dp-- = palette[*sp].green; *dp-- = palette[*sp].red; @@ -4356,8 +4377,15 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, { sp = row + (size_t)row_width - 1; dp = row + (size_t)(row_width * 3) - 1; + i = 0; +#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE + i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row, + &sp, &dp); +#else + PNG_UNUSED(png_ptr) +#endif - for (i = 0; i < row_width; i++) + for (; i < row_width; i++) { *dp-- = palette[*sp].blue; *dp-- = palette[*sp].green; @@ -4771,7 +4799,19 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) { if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) { - png_do_expand_palette(row_info, png_ptr->row_buf + 1, +#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE + if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8)) + { + if (png_ptr->riffled_palette == NULL) + { + /* Initialize the accelerated palette expansion. */ + png_ptr->riffled_palette = + (png_bytep)png_malloc(png_ptr, 256 * 4); + png_riffle_palette_neon(png_ptr); + } + } +#endif + png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1, png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); } diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c index bf316efc535..5c6244116af 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngrutil.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -1489,8 +1489,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { /* We have the ICC profile header; do the basic header checks. */ - const png_uint_32 profile_length = - png_get_uint_32(profile_header); + png_uint_32 profile_length = png_get_uint_32(profile_header); if (png_icc_check_length(png_ptr, &png_ptr->colorspace, keyword, profile_length) != 0) @@ -1507,8 +1506,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * profile. The header check has already validated * that none of this stuff will overflow. */ - const png_uint_32 tag_count = png_get_uint_32( - profile_header+128); + png_uint_32 tag_count = + png_get_uint_32(profile_header + 128); png_bytep profile = png_read_buffer(png_ptr, profile_length, 2/*silent*/); @@ -3160,7 +3159,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, */ void /* PRIVATE */ -png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name) +png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name) { int i; png_uint_32 cn=chunk_name; @@ -3179,7 +3178,7 @@ png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name) } void /* PRIVATE */ -png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) +png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length) { png_alloc_size_t limit = PNG_UINT_31_MAX; @@ -3391,7 +3390,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and * then pass: */ - static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = + static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = { /* Little-endian byte masks for PACKSWAP */ { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) }, @@ -3402,7 +3401,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* display_mask has only three entries for the odd passes, so index by * pass>>1. */ - static PNG_CONST png_uint_32 display_mask[2][3][3] = + static const png_uint_32 display_mask[2][3][3] = { /* Little-endian byte masks for PACKSWAP */ { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) }, @@ -3715,7 +3714,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Offset to next interlace block */ - static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) @@ -4357,16 +4356,16 @@ png_read_finish_row(png_structrp png_ptr) /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; png_debug(1, "in png_read_finish_row"); png_ptr->row_number++; @@ -4422,16 +4421,16 @@ png_read_start_row(png_structrp png_ptr) /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ - static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; /* Offset to next interlace block */ - static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; /* Start of interlace block in the y direction */ - static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; /* Offset to next interlace block in the y direction */ - static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; + static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; unsigned int max_pixel_depth; size_t row_bytes; diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c index 6802034f577..1b075795b65 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngset.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -165,7 +165,7 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, #ifdef PNG_eXIf_SUPPORTED void PNGAPI png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, - const png_bytep eXIf_buf) + png_bytep eXIf_buf) { png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1"); PNG_UNUSED(info_ptr) @@ -174,7 +174,7 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, void PNGAPI png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr, - const png_uint_32 num_exif, const png_bytep eXIf_buf) + png_uint_32 num_exif, png_bytep eXIf_buf) { int i; @@ -1427,7 +1427,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, /* Ignore all unknown chunks and all chunks recognized by * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND */ - static PNG_CONST png_byte chunks_to_ignore[] = { + static const png_byte chunks_to_ignore[] = { 98, 75, 71, 68, '\0', /* bKGD */ 99, 72, 82, 77, '\0', /* cHRM */ 101, 88, 73, 102, '\0', /* eXIf */ diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h index 62f1269003f..1f53e0534af 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -420,6 +420,12 @@ struct png_struct_def /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */ #endif +/* New member added in libpng-1.6.36 */ +#if defined(PNG_READ_EXPAND_SUPPORTED) && \ + defined(PNG_ARM_NEON_IMPLEMENTATION) + png_bytep riffled_palette; /* buffer for accelerated palette expansion */ +#endif + /* New member added in libpng-1.0.4 (renamed in 1.0.9) */ #if defined(PNG_MNG_FEATURES_SUPPORTED) /* Changed from png_byte to png_uint_32 at version 1.2.0 */ diff --git a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c index 2da23c8dbfb..89a62191b6f 100644 --- a/src/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c +++ b/src/src/java.desktop/share/native/libsplashscreen/libpng/pngtrans.c @@ -29,10 +29,10 @@ * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * - * Last changed in libpng 1.6.35 [July 15, 2018] + * Copyright (c) 2018 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * Copyright (c) 1996-1997 Andreas Dilger + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -373,7 +373,7 @@ png_do_swap(png_row_infop row_info, png_bytep row) #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static PNG_CONST png_byte onebppswaptable[256] = { +static const png_byte onebppswaptable[256] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, @@ -408,7 +408,7 @@ static PNG_CONST png_byte onebppswaptable[256] = { 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF }; -static PNG_CONST png_byte twobppswaptable[256] = { +static const png_byte twobppswaptable[256] = { 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, @@ -443,7 +443,7 @@ static PNG_CONST png_byte twobppswaptable[256] = { 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF }; -static PNG_CONST png_byte fourbppswaptable[256] = { +static const png_byte fourbppswaptable[256] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, diff --git a/src/src/java.desktop/unix/classes/sun/font/XRGlyphCache.java b/src/src/java.desktop/unix/classes/sun/font/XRGlyphCache.java index 125721bd531..f1444128712 100644 --- a/src/src/java.desktop/unix/classes/sun/font/XRGlyphCache.java +++ b/src/src/java.desktop/unix/classes/sun/font/XRGlyphCache.java @@ -114,6 +114,9 @@ public XRGlyphCacheEntry[] cacheGlyphs(GlyphList glyphList) { for (int i = 0; i < glyphList.getNumGlyphs(); i++) { XRGlyphCacheEntry glyph; + if (imgPtrs[i] == 0L) { + continue; + } // Find uncached glyphs and queue them for upload if ((glyph = getEntryForPointer(imgPtrs[i])) == null) { glyph = new XRGlyphCacheEntry(imgPtrs[i], glyphList); diff --git a/src/src/java.desktop/unix/classes/sun/font/XRTextRenderer.java b/src/src/java.desktop/unix/classes/sun/font/XRTextRenderer.java index e4ee3cf071e..07905e2e21b 100644 --- a/src/src/java.desktop/unix/classes/sun/font/XRTextRenderer.java +++ b/src/src/java.desktop/unix/classes/sun/font/XRTextRenderer.java @@ -88,6 +88,9 @@ protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) { for (int i = 0; i < gl.getNumGlyphs(); i++) { gl.setGlyphIndex(i); XRGlyphCacheEntry cacheEntry = cachedGlyphs[i]; + if (cacheEntry == null) { + continue; + } eltList.getGlyphs().addInt(cacheEntry.getGlyphID()); int glyphSet = cacheEntry.getGlyphSet(); diff --git a/src/src/java.desktop/unix/native/common/java2d/x11/X11FontScaler_md.c b/src/src/java.desktop/unix/native/common/java2d/x11/X11FontScaler_md.c index 745a65f53a3..2ab6f287b69 100644 --- a/src/src/java.desktop/unix/native/common/java2d/x11/X11FontScaler_md.c +++ b/src/src/java.desktop/unix/native/common/java2d/x11/X11FontScaler_md.c @@ -273,6 +273,7 @@ JNIEXPORT jlong JNICALL AWTFontGenerateImage(AWTFont pFont, AWTChar2b* xChar) { unsigned int imageSize; JNIEnv *env; + FONT_AWT_LOCK(); /* XTextExtents16(xFont, xChar, 1, &direction, &ascent, &descent, &xcs); */ XQueryTextExtents16(awt_display,xFont->fid, xChar, 1, @@ -280,8 +281,11 @@ JNIEXPORT jlong JNICALL AWTFontGenerateImage(AWTFont pFont, AWTChar2b* xChar) { width = xcs.rbearing - xcs.lbearing; height = xcs.ascent+xcs.descent; imageSize = width*height; - glyphInfo = (GlyphInfo*)malloc(sizeof(GlyphInfo)+imageSize); + if (glyphInfo == NULL) { + AWT_UNLOCK(); + return (jlong)(uintptr_t)NULL; + } glyphInfo->cellInfo = NULL; glyphInfo->width = width; glyphInfo->height = height; diff --git a/src/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c b/src/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c index 16860598c3a..f97295aea1e 100644 --- a/src/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c +++ b/src/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c @@ -1671,7 +1671,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledN { X11InputMethodData *pX11IMData = NULL; char * ret = NULL; -#if defined(_LP64) && !defined(_LITTLE_ENDIAN) +#if defined(__linux__) && defined(_LP64) && !defined(_LITTLE_ENDIAN) // XIMPreeditState value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib unsigned int state = XIMPreeditUnKnown; #else diff --git a/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c b/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c index f5cf4914ef8..a8f22166025 100644 --- a/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c +++ b/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c @@ -477,8 +477,7 @@ GtkApi* gtk3_load(JNIEnv *env, const char* lib_name) fp_gtk_fixed_new = dl_symbol("gtk_fixed_new"); fp_gtk_handle_box_new = dl_symbol("gtk_handle_box_new"); fp_gtk_image_new = dl_symbol("gtk_image_new"); - fp_gtk_hpaned_new = dl_symbol("gtk_hpaned_new"); - fp_gtk_vpaned_new = dl_symbol("gtk_vpaned_new"); + fp_gtk_paned_new = dl_symbol("gtk_paned_new"); fp_gtk_scale_new = dl_symbol("gtk_scale_new"); fp_gtk_hscrollbar_new = dl_symbol("gtk_hscrollbar_new"); fp_gtk_vscrollbar_new = dl_symbol("gtk_vscrollbar_new"); @@ -1081,7 +1080,7 @@ static GtkWidget *gtk3_get_widget(WidgetType widget_type) case SPLIT_PANE: if (init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE])) { - gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)(); + gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_paned_new)(GTK_ORIENTATION_HORIZONTAL); } result = gtk3_widgets[_GTK_HPANED_TYPE]; break; @@ -1314,7 +1313,7 @@ static GtkWidget *gtk3_get_widget(WidgetType widget_type) case VSPLIT_PANE_DIVIDER: if (init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE])) { - gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)(); + gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_paned_new)(GTK_ORIENTATION_VERTICAL); } result = gtk3_widgets[_GTK_VPANED_TYPE]; break; @@ -1434,6 +1433,10 @@ static GtkStyleContext* get_style(WidgetType widget_type, const gchar *detail) } else if (strcmp(detail, "option") == 0) { path = createWidgetPath (NULL); append_element(path, "radio"); + } else if (strcmp(detail, "paned") == 0) { + path = createWidgetPath (fp_gtk_style_context_get_path (widget_context)); + append_element(path, "paned"); + append_element(path, "separator"); } else { path = createWidgetPath (fp_gtk_style_context_get_path (widget_context)); append_element(path, detail); @@ -1832,22 +1835,30 @@ static void gtk3_paint_handle(WidgetType widget_type, GtkStateType state_type, { gtk3_widget = gtk3_get_widget(widget_type); - GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget); - - fp_gtk_style_context_save (context); + GtkStyleContext* context = get_style(widget_type, detail); GtkStateFlags flags = get_gtk_flags(state_type); fp_gtk_style_context_set_state(context, GTK_STATE_FLAG_PRELIGHT); - if (detail != 0) { + if (detail != 0 && !(strcmp(detail, "paned") == 0)) { transform_detail_string(detail, context); fp_gtk_style_context_add_class (context, "handlebox_bin"); } - fp_gtk_render_handle(context, cr, x, y, width, height); - fp_gtk_render_background(context, cr, x, y, width, height); + if (!(strcmp(detail, "paned") == 0)) { + fp_gtk_render_handle(context, cr, x, y, width, height); + fp_gtk_render_background(context, cr, x, y, width, height); + } else { + if (orientation == GTK_ORIENTATION_VERTICAL) { + fp_gtk_render_handle(context, cr, x+width/2, y, 2, height); + fp_gtk_render_background(context, cr, x+width/2, y, 2, height); + } else { + fp_gtk_render_handle(context, cr, x, y+height/2, width, 2); + fp_gtk_render_background(context, cr, x, y+height/2, width, 2); + } + } - fp_gtk_style_context_restore (context); + disposeOrRestoreContext(context); } static void gtk3_paint_hline(WidgetType widget_type, GtkStateType state_type, diff --git a/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h b/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h index 62a81252176..7ce0501ec59 100644 --- a/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h +++ b/src/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h @@ -163,6 +163,7 @@ typedef void GtkRange; typedef void GtkProgressBar; typedef void GtkProgress; typedef void GtkWidgetPath; +typedef void GtkPaned; /* Some real structures */ typedef struct @@ -502,8 +503,7 @@ static GtkWidget* (*fp_gtk_combo_box_entry_new)(); static GtkWidget* (*fp_gtk_entry_new)(); static GtkWidget* (*fp_gtk_fixed_new)(); static GtkWidget* (*fp_gtk_handle_box_new)(); -static GtkWidget* (*fp_gtk_hpaned_new)(); -static GtkWidget* (*fp_gtk_vpaned_new)(); +static GtkWidget* (*fp_gtk_paned_new)(GtkOrientation orientation); static GtkWidget* (*fp_gtk_scale_new)(GtkOrientation orientation, GtkAdjustment* adjustment); static GtkWidget* (*fp_gtk_hscrollbar_new)(GtkAdjustment* adjustment); diff --git a/src/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java index ad6b096132c..24bca7954bb 100644 --- a/src/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java @@ -27,6 +27,8 @@ import java.security.AccessController; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; import javax.print.DocFlavor; import javax.print.MultiDocPrintService; import javax.print.PrintService; @@ -47,9 +49,11 @@ public class PrintServiceLookupProvider extends PrintServiceLookup { private PrintService defaultPrintService; private String[] printers; /* excludes the default printer */ private PrintService[] printServices; /* includes the default printer */ - private static boolean pollServices = true; - private static final int DEFAULT_MINREFRESH = 240; // 4 minutes - private static int minRefreshTime = DEFAULT_MINREFRESH; + + private static final int DEFAULT_REFRESH_TIME = 240; // 4 minutes + private static final int MINIMUM_REFRESH_TIME = 120; // 2 minutes + private static final boolean pollServices; + private static final int refreshTime; static { /* The system property "sun.java2d.print.polling" @@ -58,12 +62,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup { */ String pollStr = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.java2d.print.polling")); - - if (pollStr != null) { - if (pollStr.equalsIgnoreCase("false")) { - pollServices = false; - } - } + pollServices = !("false".equalsIgnoreCase(pollStr)); /* The system property "sun.java2d.print.minRefreshTime" * can be used to specify minimum refresh time (in seconds) @@ -72,17 +71,9 @@ public class PrintServiceLookupProvider extends PrintServiceLookup { String refreshTimeStr = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction( "sun.java2d.print.minRefreshTime")); - - if (refreshTimeStr != null) { - try { - minRefreshTime = Integer.parseInt(refreshTimeStr); - } catch (NumberFormatException e) { - // ignore - } - if (minRefreshTime < DEFAULT_MINREFRESH) { - minRefreshTime = DEFAULT_MINREFRESH; - } - } + refreshTime = (refreshTimeStr != null) + ? getRefreshTime(refreshTimeStr) + : DEFAULT_REFRESH_TIME; java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<Void>() { @@ -93,6 +84,17 @@ public Void run() { }); } + private static int getRefreshTime(final String refreshTimeStr) { + try { + int minRefreshTime = Integer.parseInt(refreshTimeStr); + return (minRefreshTime < MINIMUM_REFRESH_TIME) + ? MINIMUM_REFRESH_TIME + : minRefreshTime; + } catch (NumberFormatException e) { + return DEFAULT_REFRESH_TIME; + } + } + /* The singleton win32 print lookup service. * Code that is aware of this field and wants to use it must first * see if its null, and if so instantiate it by calling a method such as @@ -398,60 +400,38 @@ scope of the query would be too big to handle(at times). count of printer status changes(add\remove) and based on it update the printers list. */ - class RemotePrinterChangeListener implements Runnable { - private String[] prevRemotePrinters; + class RemotePrinterChangeListener implements Comparator<String>, Runnable { RemotePrinterChangeListener() { } - private boolean doCompare(String[] str1, String[] str2) { - if (str1 == null && str2 == null) { - return false; - } else if (str1 == null || str2 == null) { - return true; - } - - if (str1.length != str2.length) { - return true; - } else { - for (int i = 0; i < str1.length; i++) { - for (int j = 0; j < str2.length; j++) { - // skip if both are nulls - if (str1[i] == null && str2[j] == null) { - continue; - } - - // return true if there is a 'difference' but - // no need to access the individual string - if (str1[i] == null || str2[j] == null) { - return true; - } - - // do comparison only if they are non-nulls - if (!str1[i].equals(str2[j])) { - return true; - } - } - } - } - - return false; + @Override + public int compare(String o1, String o2) { + return ((o1 == null) + ? ((o2 == null) ? 0 : 1) + : ((o2 == null) ? -1 : o1.compareTo(o2))); } @Override public void run() { // Init the list of remote printers - prevRemotePrinters = getRemotePrintersNames(); + String[] prevRemotePrinters = getRemotePrintersNames(); + if (prevRemotePrinters != null) { + Arrays.sort(prevRemotePrinters, this); + } while (true) { try { - Thread.sleep(minRefreshTime * 1000); + Thread.sleep(refreshTime * 1000); } catch (InterruptedException e) { break; } String[] currentRemotePrinters = getRemotePrintersNames(); - if (doCompare(prevRemotePrinters, currentRemotePrinters)) { + if (currentRemotePrinters != null) { + Arrays.sort(currentRemotePrinters, this); + } + if (!Arrays.equals(prevRemotePrinters, currentRemotePrinters)) { // The list of remote printers got updated, // so update the cached list printers which // includes both local and network printers diff --git a/src/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp b/src/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp index a847b838265..7ebd8965d13 100644 --- a/src/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp +++ b/src/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp @@ -1150,7 +1150,9 @@ D3DContext::UploadTileToTexture(D3DResource *pTextureRes, void *pixels, { #ifndef PtrAddBytes #define PtrAddBytes(p, b) ((void *) (((intptr_t) (p)) + (b))) -#define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, (y)*(yinc) + (x)*(xinc)) +#define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, \ + ((ptrdiff_t)(y))*(yinc) + \ + ((ptrdiff_t)(x))*(xinc)) #endif // PtrAddBytes HRESULT res = S_OK; diff --git a/src/src/java.instrument/share/native/libinstrument/InvocationAdapter.c b/src/src/java.instrument/share/native/libinstrument/InvocationAdapter.c index 2845bb5edb3..86c078f8418 100644 --- a/src/src/java.instrument/share/native/libinstrument/InvocationAdapter.c +++ b/src/src/java.instrument/share/native/libinstrument/InvocationAdapter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -558,32 +558,32 @@ eventHandlerVMInit( jvmtiEnv * jvmtienv, environment = getJPLISEnvironment(jvmtienv); /* process the premain calls on the all the JPL agents */ - if ( environment != NULL ) { - jthrowable outstandingException = NULL; - /* - * Add the jarfile to the system class path - */ - JPLISAgent * agent = environment->mAgent; - if (appendClassPath(agent, agent->mJarfile)) { - fprintf(stderr, "Unable to add %s to system class path - " - "the system class loader does not define the " - "appendToClassPathForInstrumentation method or the method failed\n", - agent->mJarfile); - free((void *)agent->mJarfile); - abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART); - } + if (environment == NULL) { + abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART ", getting JPLIS environment failed"); + } + jthrowable outstandingException = NULL; + /* + * Add the jarfile to the system class path + */ + JPLISAgent * agent = environment->mAgent; + if (appendClassPath(agent, agent->mJarfile)) { + fprintf(stderr, "Unable to add %s to system class path - " + "the system class loader does not define the " + "appendToClassPathForInstrumentation method or the method failed\n", + agent->mJarfile); free((void *)agent->mJarfile); - agent->mJarfile = NULL; - - outstandingException = preserveThrowable(jnienv); - success = processJavaStart( environment->mAgent, - jnienv); - restoreThrowable(jnienv, outstandingException); + abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART ", appending to system class path failed"); } + free((void *)agent->mJarfile); + agent->mJarfile = NULL; + + outstandingException = preserveThrowable(jnienv); + success = processJavaStart( environment->mAgent, jnienv); + restoreThrowable(jnienv, outstandingException); /* if we fail to start cleanly, bring down the JVM */ if ( !success ) { - abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART); + abortJVM(jnienv, JPLIS_ERRORMESSAGE_CANNOTSTART ", processJavaStart failed"); } } diff --git a/src/src/java.instrument/share/native/libinstrument/JPLISAgent.c b/src/src/java.instrument/share/native/libinstrument/JPLISAgent.c index b6485d23f53..3ca1d32cf0b 100644 --- a/src/src/java.instrument/share/native/libinstrument/JPLISAgent.c +++ b/src/src/java.instrument/share/native/libinstrument/JPLISAgent.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -389,17 +389,17 @@ processJavaStart( JPLISAgent * agent, */ /* - * First make our emergency fallback InternalError throwable. + * First make our fallback InternalError throwable. */ result = initializeFallbackError(jnienv); - jplis_assert(result); + jplis_assert_msg(result, "fallback init failed"); /* * Now make the InstrumentationImpl instance. */ if ( result ) { result = createInstrumentationImpl(jnienv, agent); - jplis_assert(result); + jplis_assert_msg(result, "instrumentation instance creation failed"); } @@ -409,7 +409,7 @@ processJavaStart( JPLISAgent * agent, */ if ( result ) { result = setLivePhaseEventHandlers(agent); - jplis_assert(result); + jplis_assert_msg(result, "setting of live phase VM handlers failed"); } /* @@ -419,6 +419,7 @@ processJavaStart( JPLISAgent * agent, result = startJavaAgent(agent, jnienv, agent->mAgentClassName, agent->mOptionsString, agent->mPremainCaller); + jplis_assert_msg(result, "agent load/premain call failed"); } /* diff --git a/src/src/java.management/share/classes/java/lang/management/ManagementFactory.java b/src/src/java.management/share/classes/java/lang/management/ManagementFactory.java index e41cf94ed9b..e65cbab93ea 100644 --- a/src/src/java.management/share/classes/java/lang/management/ManagementFactory.java +++ b/src/src/java.management/share/classes/java/lang/management/ManagementFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -872,12 +872,13 @@ private static Stream<String> getProxyNames(PlatformComponent<?> pc, public static Set<Class<? extends PlatformManagedObject>> getPlatformManagementInterfaces() { - return platformComponents() + // local variable required here; see JDK-8223553 + Stream<Class<? extends PlatformManagedObject>> pmos = platformComponents() .stream() .flatMap(pc -> pc.mbeanInterfaces().stream()) .filter(clazz -> PlatformManagedObject.class.isAssignableFrom(clazz)) - .map(clazz -> clazz.asSubclass(PlatformManagedObject.class)) - .collect(Collectors.toSet()); + .map(clazz -> clazz.asSubclass(PlatformManagedObject.class)); + return pmos.collect(Collectors.toSet()); } private static final String NOTIF_EMITTER = diff --git a/src/src/java.naming/share/classes/com/sun/jndi/ldap/BerDecoder.java b/src/src/java.naming/share/classes/com/sun/jndi/ldap/BerDecoder.java index ef03ca4d587..9ebc18fcac4 100644 --- a/src/src/java.naming/share/classes/com/sun/jndi/ldap/BerDecoder.java +++ b/src/src/java.naming/share/classes/com/sun/jndi/ldap/BerDecoder.java @@ -186,12 +186,16 @@ public int parseInt() throws DecodeException { *</pre></blockquote> */ private int parseIntWithTag(int tag) throws DecodeException { - - if (parseByte() != tag) { + // Ber could have been reset; + String s; + if (offset > 0) { + s = Integer.toString(buf[offset - 1] & 0xff); + } else { + s = "Empty tag"; + } throw new DecodeException("Encountered ASN.1 tag " + - Integer.toString(buf[offset - 1] & 0xff) + - " (expected tag " + Integer.toString(tag) + ")"); + s + " (expected tag " + Integer.toString(tag) + ")"); } int len = parseLength(); diff --git a/src/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java b/src/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java index 8411539089d..3ff448fc5c6 100644 --- a/src/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java @@ -408,65 +408,29 @@ LdapRequest writeRequest(BerEncoder ber, int msgId, /** * Reads a reply; waits until one is ready. */ - BerDecoder readReply(LdapRequest ldr) - throws IOException, NamingException { + BerDecoder readReply(LdapRequest ldr) throws IOException, NamingException { BerDecoder rber; - // Track down elapsed time to workaround spurious wakeups - long elapsedMilli = 0; - long elapsedNano = 0; - - while (((rber = ldr.getReplyBer()) == null) && - (readTimeout <= 0 || elapsedMilli < readTimeout)) - { - try { - // If socket closed, don't even try - synchronized (this) { - if (sock == null) { - throw new ServiceUnavailableException(host + ":" + port + - "; socket closed"); - } - } - synchronized (ldr) { - // check if condition has changed since our last check - rber = ldr.getReplyBer(); - if (rber == null) { - if (readTimeout > 0) { // Socket read timeout is specified - long beginNano = System.nanoTime(); - - // will be woken up before readTimeout if reply is - // available - ldr.wait(readTimeout - elapsedMilli); - elapsedNano += (System.nanoTime() - beginNano); - elapsedMilli += elapsedNano / 1000_000; - elapsedNano %= 1000_000; - - } else { - // no timeout is set so we wait infinitely until - // a response is received - // http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-ldap.html#PROP - ldr.wait(); - } - } else { - break; - } - } - } catch (InterruptedException ex) { - throw new InterruptedNamingException( - "Interrupted during LDAP operation"); - } + try { + // if no timeout is set so we wait infinitely until + // a response is received + // http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-ldap.html#PROP + rber = ldr.getReplyBer(readTimeout); + } catch (InterruptedException ex) { + throw new InterruptedNamingException( + "Interrupted during LDAP operation"); } - if ((rber == null) && (elapsedMilli >= readTimeout)) { + if (rber == null) { abandonRequest(ldr, null); - throw new NamingException("LDAP response read timed out, timeout used:" + throw new NamingException( + "LDAP response read timed out, timeout used:" + readTimeout + "ms." ); } return rber; } - //////////////////////////////////////////////////////////////////////////// // // Methods to add, find, delete, and abandon requests made to server @@ -660,14 +624,11 @@ void cleanup(Control[] reqCtls, boolean notifyParent) { if (nparent) { LdapRequest ldr = pendingRequests; while (ldr != null) { - - synchronized (ldr) { - ldr.notify(); + ldr.close(); ldr = ldr.next; } } } - } if (nparent) { parent.processConnectionClosure(); } @@ -755,7 +716,7 @@ synchronized private InputStream getInputStream() { * the safest thing to do is to shut it down. */ - private Object pauseLock = new Object(); // lock for reader to wait on while paused + private final Object pauseLock = new Object(); // lock for reader to wait on while paused private boolean paused = false; // paused state of reader /* diff --git a/src/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java b/src/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java index 6e7e3e6544b..ddea9d40b85 100644 --- a/src/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java +++ b/src/src/java.naming/share/classes/com/sun/jndi/ldap/LdapRequest.java @@ -29,55 +29,52 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import javax.naming.CommunicationException; +import java.util.concurrent.TimeUnit; final class LdapRequest { - LdapRequest next; // Set/read in synchronized Connection methods - int msgId; // read-only + private final static BerDecoder EOF = new BerDecoder(new byte[]{}, -1, 0); - private int gotten = 0; - private BlockingQueue<BerDecoder> replies; - private int highWatermark = -1; - private boolean cancelled = false; - private boolean pauseAfterReceipt = false; - private boolean completed = false; + LdapRequest next; // Set/read in synchronized Connection methods + final int msgId; // read-only - LdapRequest(int msgId, boolean pause) { - this(msgId, pause, -1); - } + private final BlockingQueue<BerDecoder> replies; + private volatile boolean cancelled; + private volatile boolean closed; + private volatile boolean completed; + private final boolean pauseAfterReceipt; LdapRequest(int msgId, boolean pause, int replyQueueCapacity) { this.msgId = msgId; this.pauseAfterReceipt = pause; if (replyQueueCapacity == -1) { - this.replies = new LinkedBlockingQueue<BerDecoder>(); + this.replies = new LinkedBlockingQueue<>(); } else { - this.replies = - new LinkedBlockingQueue<BerDecoder>(replyQueueCapacity); - highWatermark = (replyQueueCapacity * 80) / 100; // 80% capacity + this.replies = new LinkedBlockingQueue<>(8 * replyQueueCapacity / 10); } } - synchronized void cancel() { + void cancel() { cancelled = true; + replies.offer(EOF); + } - // Unblock reader of pending request - // Should only ever have at most one waiter - notify(); + synchronized void close() { + closed = true; + replies.offer(EOF); + } + + private boolean isClosed() { + return closed && (replies.size() == 0 || replies.peek() == EOF); } synchronized boolean addReplyBer(BerDecoder ber) { - if (cancelled) { + // check the closed boolean value here as we don't want anything + // to be added to the queue after close() has been called. + if (cancelled || closed) { return false; } - // Add a new reply to the queue of unprocessed replies. - try { - replies.put(ber); - } catch (InterruptedException e) { - // ignore - } - // peek at the BER buffer to check if it is a SearchResultDone PDU try { ber.parseSeq(null); @@ -88,33 +85,38 @@ synchronized boolean addReplyBer(BerDecoder ber) { } ber.reset(); - notify(); // notify anyone waiting for reply - /* - * If a queue capacity has been set then trigger a pause when the - * queue has filled to 80% capacity. Later, when the queue has drained - * then the reader gets unpaused. - */ - if (highWatermark != -1 && replies.size() >= highWatermark) { - return true; // trigger the pause + // Add a new reply to the queue of unprocessed replies. + try { + replies.put(ber); + } catch (InterruptedException e) { + // ignore } + return pauseAfterReceipt; } - synchronized BerDecoder getReplyBer() throws CommunicationException { + BerDecoder getReplyBer(long millis) throws CommunicationException, + InterruptedException { + if (cancelled) { + throw new CommunicationException("Request: " + msgId + + " cancelled"); + } + if (isClosed()) { + return null; + } + + BerDecoder result = millis > 0 ? + replies.poll(millis, TimeUnit.MILLISECONDS) : replies.take(); + if (cancelled) { throw new CommunicationException("Request: " + msgId + " cancelled"); } - /* - * Remove a reply if the queue is not empty. - * poll returns null if queue is empty. - */ - BerDecoder reply = replies.poll(); - return reply; + return result == EOF ? null : result; } - synchronized boolean hasSearchCompleted() { + boolean hasSearchCompleted() { return completed; } } diff --git a/src/src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java b/src/src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java index 63600a53876..3d60747fd1c 100644 --- a/src/src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java +++ b/src/src/java.net.http/share/classes/jdk/internal/net/http/ExchangeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,13 +26,14 @@ package jdk.internal.net.http; import java.io.IOException; +import java.net.http.HttpResponse; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -import java.util.function.Function; -import java.net.http.HttpResponse; + import jdk.internal.net.http.common.Logger; import jdk.internal.net.http.common.MinimalFuture; import jdk.internal.net.http.common.Utils; + import static java.net.http.HttpClient.Version.HTTP_1_1; /** @@ -88,8 +89,10 @@ final Exchange<T> getExchange() { CompletableFuture<Http2Connection> c2f = c2.getConnectionFor(request, exchange); if (debug.on()) debug.log("get: Trying to get HTTP/2 connection"); - return c2f.handle((h2c, t) -> createExchangeImpl(h2c, t, exchange, connection)) - .thenCompose(Function.identity()); + // local variable required here; see JDK-8223553 + CompletableFuture<CompletableFuture<? extends ExchangeImpl<U>>> fxi = + c2f.handle((h2c, t) -> createExchangeImpl(h2c, t, exchange, connection)); + return fxi.thenCompose(x->x); } } diff --git a/src/src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java b/src/src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java index 5d3fa4e91e6..8eed1872658 100644 --- a/src/src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java +++ b/src/src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java @@ -59,7 +59,6 @@ public final class RequestPublishers { private RequestPublishers() { } public static class ByteArrayPublisher implements BodyPublisher { - private volatile Flow.Publisher<ByteBuffer> delegate; private final int length; private final byte[] content; private final int offset; @@ -99,7 +98,7 @@ List<ByteBuffer> copy(byte[] content, int offset, int length) { @Override public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) { List<ByteBuffer> copy = copy(content, offset, length); - this.delegate = new PullPublisher<>(copy); + var delegate = new PullPublisher<>(copy); delegate.subscribe(subscriber); } @@ -111,7 +110,6 @@ public long contentLength() { // This implementation has lots of room for improvement. public static class IterablePublisher implements BodyPublisher { - private volatile Flow.Publisher<ByteBuffer> delegate; private final Iterable<byte[]> content; private volatile long contentLength; @@ -174,7 +172,7 @@ public Iterator<ByteBuffer> iterator() { @Override public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) { Iterable<ByteBuffer> iterable = this::iterator; - this.delegate = new PullPublisher<>(iterable); + var delegate = new PullPublisher<>(iterable); delegate.subscribe(subscriber); } diff --git a/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Skel.java b/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Skel.java index 6807a328b1d..c0a06f1f017 100644 --- a/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Skel.java +++ b/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Skel.java @@ -27,13 +27,8 @@ package sun.rmi.registry; import java.io.IOException; -import java.io.InputStream; -import java.rmi.AccessException; -import java.rmi.server.RemoteCall; -import sun.rmi.transport.Connection; import sun.rmi.transport.StreamRemoteCall; -import sun.rmi.transport.tcp.TCPConnection; /** * Skeleton to dispatch RegistryImpl methods. @@ -56,7 +51,7 @@ public java.rmi.server.Operation[] getOperations() { return operations.clone(); } - public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash) + public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall remoteCall, int opnum, long hash) throws java.lang.Exception { if (opnum < 0) { if (hash == 7583982177005850366L) { @@ -78,6 +73,7 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o } sun.rmi.registry.RegistryImpl server = (sun.rmi.registry.RegistryImpl) obj; + StreamRemoteCall call = (StreamRemoteCall) remoteCall; switch (opnum) { case 0: // bind(String, Remote) { @@ -90,7 +86,8 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o java.io.ObjectInput in = call.getInputStream(); $param_String_1 = (java.lang.String) in.readObject(); $param_Remote_2 = (java.rmi.Remote) in.readObject(); - } catch (java.io.IOException | java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); } finally { call.releaseInputStream(); @@ -123,7 +120,8 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o try { java.io.ObjectInput in = call.getInputStream(); $param_String_1 = (java.lang.String) in.readObject(); - } catch (java.io.IOException | java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); } finally { call.releaseInputStream(); @@ -149,7 +147,8 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o java.io.ObjectInput in = call.getInputStream(); $param_String_1 = (java.lang.String) in.readObject(); $param_Remote_2 = (java.rmi.Remote) in.readObject(); - } catch (java.io.IOException | java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | java.lang.ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); } finally { call.releaseInputStream(); @@ -172,7 +171,8 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o try { java.io.ObjectInput in = call.getInputStream(); $param_String_1 = (java.lang.String) in.readObject(); - } catch (java.io.IOException | java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); } finally { call.releaseInputStream(); diff --git a/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Stub.java b/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Stub.java index f8574869147..9f82b61331c 100644 --- a/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Stub.java +++ b/src/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl_Stub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -24,6 +24,11 @@ */ package sun.rmi.registry; + +import java.io.IOException; + +import sun.rmi.transport.StreamRemoteCall; + /** * Stubs to invoke RegistryImpl remote methods. * Originally generated from RMIC but frozen to match RegistryImpl_Skel. @@ -57,7 +62,7 @@ public RegistryImpl_Stub(java.rmi.server.RemoteRef ref) { public void bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2) throws java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + StreamRemoteCall call = (StreamRemoteCall)ref.newCall(this, operations, 0, interfaceHash); try { java.io.ObjectOutput out = call.getOutputStream(); out.writeObject($param_String_1); @@ -82,15 +87,14 @@ public void bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote public java.lang.String[] list() throws java.rmi.AccessException, java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + StreamRemoteCall call = (StreamRemoteCall)ref.newCall(this, operations, 1, interfaceHash); ref.invoke(call); java.lang.String[] $result; try { java.io.ObjectInput in = call.getInputStream(); $result = (java.lang.String[]) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling return", e); } finally { ref.done(call); @@ -109,7 +113,7 @@ public java.lang.String[] list() public java.rmi.Remote lookup(java.lang.String $param_String_1) throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash); + StreamRemoteCall call = (StreamRemoteCall)ref.newCall(this, operations, 2, interfaceHash); try { java.io.ObjectOutput out = call.getOutputStream(); out.writeObject($param_String_1); @@ -121,9 +125,8 @@ public java.rmi.Remote lookup(java.lang.String $param_String_1) try { java.io.ObjectInput in = call.getInputStream(); $result = (java.rmi.Remote) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling return", e); - } catch (java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling return", e); } finally { ref.done(call); @@ -144,7 +147,7 @@ public java.rmi.Remote lookup(java.lang.String $param_String_1) public void rebind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2) throws java.rmi.AccessException, java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash); + StreamRemoteCall call = (StreamRemoteCall)ref.newCall(this, operations, 3, interfaceHash); try { java.io.ObjectOutput out = call.getOutputStream(); out.writeObject($param_String_1); @@ -167,7 +170,7 @@ public void rebind(java.lang.String $param_String_1, java.rmi.Remote $param_Remo public void unbind(java.lang.String $param_String_1) throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash); + StreamRemoteCall call = (StreamRemoteCall)ref.newCall(this, operations, 4, interfaceHash); try { java.io.ObjectOutput out = call.getOutputStream(); out.writeObject($param_String_1); diff --git a/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Skel.java b/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Skel.java index f991a6e0530..1b413cffc19 100644 --- a/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Skel.java +++ b/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Skel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package sun.rmi.transport; +import java.io.IOException; + /** * Skeleton to dispatch DGC methods. * Originally generated by RMIC but frozen to match the stubs. @@ -43,12 +45,13 @@ public java.rmi.server.Operation[] getOperations() { return operations.clone(); } - public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash) + public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall remoteCall, int opnum, long hash) throws java.lang.Exception { if (hash != interfaceHash) throw new java.rmi.server.SkeletonMismatchException("interface hash mismatch"); sun.rmi.transport.DGCImpl server = (sun.rmi.transport.DGCImpl) obj; + StreamRemoteCall call = (StreamRemoteCall) remoteCall; switch (opnum) { case 0: // clean(ObjID[], long, VMID, boolean) { @@ -62,9 +65,8 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o $param_long_2 = in.readLong(); $param_VMID_3 = (java.rmi.dgc.VMID) in.readObject(); $param_boolean_4 = in.readBoolean(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); - } catch (java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); } finally { call.releaseInputStream(); @@ -88,9 +90,8 @@ public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int o $param_arrayOf_ObjID_1 = (java.rmi.server.ObjID[]) in.readObject(); $param_long_2 = in.readLong(); $param_Lease_3 = (java.rmi.dgc.Lease) in.readObject(); - } catch (java.io.IOException e) { - throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); - } catch (java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling arguments", e); } finally { call.releaseInputStream(); diff --git a/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java b/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java index cc44ff845a8..99880f3b3b0 100644 --- a/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java +++ b/src/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,16 +25,17 @@ package sun.rmi.transport; +import sun.rmi.transport.tcp.TCPConnection; + +import java.io.IOException; import java.io.ObjectInputFilter; -import java.io.ObjectInputStream; +import java.rmi.RemoteException; import java.rmi.dgc.Lease; import java.rmi.dgc.VMID; import java.rmi.server.UID; import java.security.AccessController; import java.security.PrivilegedAction; - -import sun.rmi.server.UnicastRef; -import sun.rmi.transport.tcp.TCPConnection; +import java.util.ArrayList; /** * Stubs to invoke DGC remote methods. @@ -72,7 +73,9 @@ public DGCImpl_Stub(java.rmi.server.RemoteRef ref) { public void clean(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_long_2, java.rmi.dgc.VMID $param_VMID_3, boolean $param_boolean_4) throws java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash); + StreamRemoteCall call = (StreamRemoteCall)ref.newCall((java.rmi.server.RemoteObject) this, + operations, 0, interfaceHash); + call.setObjectInputFilter(DGCImpl_Stub::leaseFilter); try { java.io.ObjectOutput out = call.getOutputStream(); out.writeObject($param_arrayOf_ObjID_1); @@ -97,7 +100,10 @@ public void clean(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_lo public java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_long_2, java.rmi.dgc.Lease $param_Lease_3) throws java.rmi.RemoteException { try { - java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash); + StreamRemoteCall call = + (StreamRemoteCall)ref.newCall((java.rmi.server.RemoteObject) this, + operations, 1, interfaceHash); + call.setObjectInputFilter(DGCImpl_Stub::leaseFilter); try { java.io.ObjectOutput out = call.getOutputStream(); out.writeObject($param_arrayOf_ObjID_1); @@ -108,26 +114,16 @@ public java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, } ref.invoke(call); java.rmi.dgc.Lease $result; - Connection connection = ((StreamRemoteCall) call).getConnection(); + Connection connection = call.getConnection(); try { java.io.ObjectInput in = call.getInputStream(); - - if (in instanceof ObjectInputStream) { - /** - * Set a filter on the stream for the return value. - */ - ObjectInputStream ois = (ObjectInputStream) in; - AccessController.doPrivileged((PrivilegedAction<Void>)() -> { - ois.setObjectInputFilter(DGCImpl_Stub::leaseFilter); - return null; - }); - } $result = (java.rmi.dgc.Lease) in.readObject(); - } catch (java.io.IOException | java.lang.ClassNotFoundException e) { + } catch (ClassCastException | IOException | ClassNotFoundException e) { if (connection instanceof TCPConnection) { // Modified to prevent re-use of the connection after an exception ((TCPConnection) connection).getChannel().free(connection, false); } + call.discardPendingRefs(); throw new java.rmi.UnmarshalException("error unmarshalling return", e); } finally { ref.done(call); @@ -146,6 +142,11 @@ public java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, * ObjectInputFilter to filter DGCClient return value (a Lease). * The list of acceptable classes is very short and explicit. * The depth and array sizes are limited. + * <p> + * The filter must accept normal and exception returns. + * A DGC server may throw exceptions that may have a cause + * and suppressed exceptions. + * Only exceptions in {@code java.base} and {@code java.rmi} are allowed. * * @param filterInfo access to class, arrayLength, etc. * @return {@link ObjectInputFilter.Status#ALLOWED} if allowed, @@ -172,7 +173,14 @@ private static ObjectInputFilter.Status leaseFilter(ObjectInputFilter.FilterInfo } return (clazz == UID.class || clazz == VMID.class || - clazz == Lease.class) + clazz == Lease.class || + (Throwable.class.isAssignableFrom(clazz) && + (Object.class.getModule() == clazz.getModule() || + RemoteException.class.getModule() == clazz.getModule())) || + clazz == StackTraceElement.class || + clazz == ArrayList.class || // for suppressed exceptions, if any + clazz == Object.class || + clazz.getName().equals("java.util.Collections$EmptyList")) ? ObjectInputFilter.Status.ALLOWED : ObjectInputFilter.Status.REJECTED; } diff --git a/src/src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java b/src/src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java index d0a0ced0404..2f1c981da5b 100644 --- a/src/src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java +++ b/src/src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInput; +import java.io.ObjectInputFilter; import java.io.ObjectOutput; import java.io.StreamCorruptedException; import java.rmi.RemoteException; @@ -36,6 +37,9 @@ import java.rmi.UnmarshalException; import java.rmi.server.ObjID; import java.rmi.server.RemoteCall; +import java.security.AccessController; +import java.security.PrivilegedAction; + import sun.rmi.runtime.Log; import sun.rmi.server.UnicastRef; import sun.rmi.transport.tcp.TCPEndpoint; @@ -50,6 +54,7 @@ public class StreamRemoteCall implements RemoteCall { private ConnectionInputStream in = null; private ConnectionOutputStream out = null; private Connection conn; + private ObjectInputFilter filter = null; private boolean resultStarted = false; private Exception serverException = null; @@ -123,6 +128,13 @@ public void releaseOutputStream() throws IOException { } } + public void setObjectInputFilter(ObjectInputFilter filter) { + if (in != null) { + throw new IllegalStateException("set filter must occur before calling getInputStream"); + } + this.filter = filter; + } + /** * Get the InputStream the stub/skeleton should get results/arguments * from. @@ -132,6 +144,12 @@ public ObjectInput getInputStream() throws IOException { Transport.transportLog.log(Log.VERBOSE, "getting input stream"); in = new ConnectionInputStream(conn.getInputStream()); + if (filter != null) { + AccessController.doPrivileged((PrivilegedAction<Void>) () -> { + in.setObjectInputFilter(filter); + return null; + }); + } } return in; } @@ -251,6 +269,7 @@ public void executeCall() throws Exception { try { ex = in.readObject(); } catch (Exception e) { + discardPendingRefs(); throw new UnmarshalException("Error unmarshaling return", e); } @@ -259,6 +278,7 @@ public void executeCall() throws Exception { if (ex instanceof Exception) { exceptionReceivedFromServer((Exception) ex); } else { + discardPendingRefs(); throw new UnmarshalException("Return type not Exception"); } // Exception is thrown before fallthrough can occur diff --git a/src/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c b/src/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c index dc95524eb09..a4a9d6c8f57 100644 --- a/src/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c +++ b/src/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c @@ -261,6 +261,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ int netypes; jint *etypes = NULL; + int proxy_flag = 0; /* Initialize the Kerberos 5 context */ err = krb5_init_context (&kcontext); @@ -273,6 +274,48 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ err = krb5_cc_set_flags (kcontext, ccache, flags); /* turn off OPENCLOSE */ } + // First round read. The proxy_impersonator config flag is not supported. + // This ccache will not be used if this flag exists. + if (!err) { + err = krb5_cc_start_seq_get (kcontext, ccache, &cursor); + } + + if (!err) { + while ((err = krb5_cc_next_cred (kcontext, ccache, &cursor, &creds)) == 0) { + char *serverName = NULL; + + if (!err) { + err = krb5_unparse_name (kcontext, creds.server, &serverName); + printiferr (err, "while unparsing server name"); + } + + if (!err) { + if (!strcmp(serverName, "krb5_ccache_conf_data/proxy_impersonator@X-CACHECONF:")) { + proxy_flag = 1; + } + } + + if (serverName != NULL) { krb5_free_unparsed_name (kcontext, serverName); } + + krb5_free_cred_contents (kcontext, &creds); + + if (proxy_flag) break; + } + + if (err == KRB5_CC_END) { err = 0; } + printiferr (err, "while retrieving a ticket"); + } + + if (!err) { + err = krb5_cc_end_seq_get (kcontext, ccache, &cursor); + printiferr (err, "while finishing ticket retrieval"); + } + + if (proxy_flag) { + goto outer_cleanup; + } + // End of first round read + if (!err) { err = krb5_cc_start_seq_get (kcontext, ccache, &cursor); } @@ -400,6 +443,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativ printiferr (err, "while finishing ticket retrieval"); } +outer_cleanup: if (!err) { flags = KRB5_TC_OPENCLOSE; /* restore OPENCLOSE mode */ err = krb5_cc_set_flags (kcontext, ccache, flags); diff --git a/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/JavaxSecurityAuthKerberosAccessImpl.java b/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/JavaxSecurityAuthKerberosAccessImpl.java index 9630c72eace..71cc0aa50ec 100644 --- a/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/JavaxSecurityAuthKerberosAccessImpl.java +++ b/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/JavaxSecurityAuthKerberosAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,6 @@ package javax.security.auth.kerberos; import sun.security.krb5.JavaxSecurityAuthKerberosAccess; -import sun.security.krb5.EncryptionKey; -import sun.security.krb5.PrincipalName; class JavaxSecurityAuthKerberosAccessImpl implements JavaxSecurityAuthKerberosAccess { @@ -35,4 +33,10 @@ public sun.security.krb5.internal.ktab.KeyTab keyTabTakeSnapshot( KeyTab ktab) { return ktab.takeSnapshot(); } + public KerberosTicket kerberosTicketGetProxy(KerberosTicket t) { + return t.proxy; + } + public void kerberosTicketSetProxy(KerberosTicket t, KerberosTicket p) { + t.proxy = p; + } } diff --git a/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java b/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java index aa14fe6b3b1..86135eb84ed 100644 --- a/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java +++ b/src/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,11 +29,13 @@ import java.util.Date; import java.util.Arrays; import java.net.InetAddress; +import java.util.Objects; import javax.crypto.SecretKey; import javax.security.auth.Refreshable; import javax.security.auth.Destroyable; import javax.security.auth.RefreshFailedException; import javax.security.auth.DestroyFailedException; + import sun.security.util.HexDumpEncoder; /** @@ -190,9 +192,14 @@ public class KerberosTicket implements Destroyable, Refreshable, * @serial */ - private InetAddress[] clientAddresses; + /** + * Evidence ticket if proxy_impersonator. This field can be accessed + * by KerberosSecrets. It's serialized. + */ + KerberosTicket proxy = null; + private transient boolean destroyed = false; /** @@ -703,6 +710,7 @@ public String toString() { "Renew Till = " + String.valueOf(renewTill) + "\n" + "Client Addresses " + (clientAddresses == null ? " Null " : caddrString.toString() + + (proxy == null ? "" : "\nwith a proxy ticket") + "\n")); } @@ -740,6 +748,10 @@ public int hashCode() { // clientAddress may be null, the array's hashCode is 0 result = result * 37 + Arrays.hashCode(clientAddresses); + + if (proxy != null) { + result = result * 37 + proxy.hashCode(); + } return result * 37 + Arrays.hashCode(flags); } @@ -812,6 +824,10 @@ public boolean equals(Object other) { } } + if (!Objects.equals(proxy, otherTicket.proxy)) { + return false; + } + return true; } diff --git a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java index 7cdfa2be422..d50603f2ab7 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java +++ b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -617,6 +617,8 @@ public final byte[] initSecContext(InputStream is, int mechTokenSize) if (myCred == null) { myCred = Krb5InitCredential.getInstance(caller, myName, GSSCredential.DEFAULT_LIFETIME); + myCred = Krb5ProxyCredential.tryImpersonation( + caller, (Krb5InitCredential)myCred); } else if (!myCred.isInitiatorCredential()) { throw new GSSException(errorCode, -1, "No TGT available"); @@ -653,8 +655,8 @@ public KerberosTicket run() throws Exception { // highly consider just calling: // Subject.getSubject // SubjectComber.find - // instead of Krb5Util.getTicket - return Krb5Util.getTicket( + // instead of Krb5Util.getServiceTicket + return Krb5Util.getServiceTicket( GSSCaller.CALLER_UNKNOWN, // since it's useSubjectCredsOnly here, // don't worry about the null diff --git a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java index 44a0c992a98..944dec09486 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java +++ b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -55,6 +55,7 @@ public class Krb5InitCredential private Krb5NameElement name; private Credentials krb5Credentials; + public KerberosTicket proxyTicket; private Krb5InitCredential(Krb5NameElement name, byte[] asn1Encoding, @@ -153,7 +154,7 @@ static Krb5InitCredential getInstance(GSSCaller caller, Krb5NameElement name, Krb5MechFactory.NT_GSS_KRB5_PRINCIPAL); } - return new Krb5InitCredential(name, + Krb5InitCredential result = new Krb5InitCredential(name, tgt.getEncoded(), tgt.getClient(), tgt.getServer(), @@ -165,6 +166,9 @@ static Krb5InitCredential getInstance(GSSCaller caller, Krb5NameElement name, tgt.getEndTime(), tgt.getRenewTill(), tgt.getClientAddresses()); + result.proxyTicket = KerberosSecrets.getJavaxSecurityAuthKerberosAccess(). + kerberosTicketGetProxy(tgt); + return result; } static Krb5InitCredential getInstance(Krb5NameElement name, @@ -333,9 +337,9 @@ private static KerberosTicket getTgt(GSSCaller caller, Krb5NameElement name, public KerberosTicket run() throws Exception { // It's OK to use null as serverPrincipal. TGT is almost // the first ticket for a principal and we use list. - return Krb5Util.getTicket( + return Krb5Util.getInitialTicket( realCaller, - clientPrincipal, null, acc); + clientPrincipal, acc); }}); } catch (PrivilegedActionException e) { GSSException ge = diff --git a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java index cc9626c14f7..d5cafea0445 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java +++ b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5MechFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -124,6 +124,8 @@ public GSSCredentialSpi getCredentialElement(GSSNameSpi name, usage == GSSCredential.INITIATE_AND_ACCEPT) { credElement = Krb5InitCredential.getInstance (caller, (Krb5NameElement) name, initLifetime); + credElement = Krb5ProxyCredential.tryImpersonation( + caller, (Krb5InitCredential)credElement); checkInitCredPermission ((Krb5NameElement) credElement.getName()); } else if (usage == GSSCredential.ACCEPT_ONLY) { diff --git a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java index 1d0217e9187..461e2481e5d 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java +++ b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -144,7 +144,7 @@ static Krb5NameElement getInstance(String gssNameStr, Oid gssNameType) return new Krb5NameElement(principalName, gssNameStr, gssNameType); } - static Krb5NameElement getInstance(PrincipalName principalName) { + public static Krb5NameElement getInstance(PrincipalName principalName) { return new Krb5NameElement(principalName, principalName.getName(), Krb5MechFactory.NT_GSS_KRB5_PRINCIPAL); diff --git a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5ProxyCredential.java b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5ProxyCredential.java index 4c5690b3942..8fbe93a5768 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5ProxyCredential.java +++ b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5ProxyCredential.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,17 @@ package sun.security.jgss.krb5; import org.ietf.jgss.*; +import sun.security.jgss.GSSCaller; import sun.security.jgss.spi.*; -import java.util.Date; + +import java.io.IOException; + +import sun.security.krb5.Credentials; +import sun.security.krb5.KrbException; import sun.security.krb5.internal.Ticket; +import javax.security.auth.kerberos.KerberosTicket; + /** * Implements the krb5 proxy credential element used in constrained * delegation. It is used in both impersonation (where there is no Kerberos 5 @@ -112,4 +119,24 @@ public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException { throw new GSSException(GSSException.FAILURE, -1, "Only an initiate credentials can impersonate"); } + + // Try to see if a default credential should act as an impersonator. + static Krb5CredElement tryImpersonation(GSSCaller caller, + Krb5InitCredential initiator) throws GSSException { + + try { + KerberosTicket proxy = initiator.proxyTicket; + if (proxy != null) { + Credentials proxyCreds = Krb5Util.ticketToCreds(proxy); + return new Krb5ProxyCredential(initiator, + Krb5NameElement.getInstance(proxyCreds.getClient()), + proxyCreds.getTicket()); + } else { + return initiator; + } + } catch (KrbException | IOException e) { + throw new GSSException(GSSException.DEFECTIVE_CREDENTIAL, -1, + "Cannot create proxy credential"); + } + } } diff --git a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Util.java b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Util.java index 31b54b72554..8f79df1e67d 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Util.java +++ b/src/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -139,11 +139,8 @@ public static KerberosTicket getTicketFromSubjectAndTgs(GSSCaller caller, /** * Retrieves the ticket corresponding to the client/server principal * pair from the Subject in the specified AccessControlContext. - * If the ticket can not be found in the Subject, and if - * useSubjectCredsOnly is false, then obtain ticket from - * a LoginContext. */ - static KerberosTicket getTicket(GSSCaller caller, + static KerberosTicket getServiceTicket(GSSCaller caller, String clientPrincipal, String serverPrincipal, AccessControlContext acc) throws LoginException { @@ -153,11 +150,31 @@ static KerberosTicket getTicket(GSSCaller caller, SubjectComber.find(accSubj, serverPrincipal, clientPrincipal, KerberosTicket.class); + return ticket; + } + + /** + * Retrieves the initial TGT corresponding to the client principal + * from the Subject in the specified AccessControlContext. + * If the ticket can not be found in the Subject, and if + * useSubjectCredsOnly is false, then obtain ticket from + * a LoginContext. + */ + static KerberosTicket getInitialTicket(GSSCaller caller, + String clientPrincipal, + AccessControlContext acc) throws LoginException { + + // Try to get ticket from acc's Subject + Subject accSubj = Subject.getSubject(acc); + KerberosTicket ticket = + SubjectComber.find(accSubj, null, clientPrincipal, + KerberosTicket.class); + // Try to get ticket from Subject obtained from GSSUtil if (ticket == null && !GSSUtil.useSubjectCredsOnly(caller)) { Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID); ticket = SubjectComber.find(subject, - serverPrincipal, clientPrincipal, KerberosTicket.class); + null, clientPrincipal, KerberosTicket.class); } return ticket; } diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java index 17ce0e9bb2c..fc2fed379f1 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -56,13 +56,23 @@ public class Credentials { KerberosTime endTime; KerberosTime renewTill; HostAddresses cAddr; - EncryptionKey serviceKey; AuthorizationData authzData; private static boolean DEBUG = Krb5.DEBUG; private static CredentialsCache cache; static boolean alreadyLoaded = false; private static boolean alreadyTried = false; + private Credentials proxy = null; + + public Credentials getProxy() { + return proxy; + } + + public Credentials setProxy(Credentials proxy) { + this.proxy = proxy; + return this; + } + // Read native ticket with session key type in the given list private static native Credentials acquireDefaultNativeCreds(int[] eTypes); @@ -336,20 +346,19 @@ public static Credentials acquireTGTFromCache(PrincipalName princ, return null; } - sun.security.krb5.internal.ccache.Credentials tgtCred = - ccache.getDefaultCreds(); + Credentials tgtCred = ccache.getInitialCreds(); if (tgtCred == null) { return null; } - if (EType.isSupported(tgtCred.getEType())) { - return tgtCred.setKrbCreds(); + if (EType.isSupported(tgtCred.key.getEType())) { + return tgtCred; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + - tgtCred.getEType()); + tgtCred.key.getEType()); } return null; } @@ -384,20 +393,19 @@ public static synchronized Credentials acquireDefaultCreds() { cache = CredentialsCache.getInstance(); } if (cache != null) { - sun.security.krb5.internal.ccache.Credentials temp = - cache.getDefaultCreds(); + Credentials temp = cache.getInitialCreds(); if (temp != null) { if (DEBUG) { System.out.println(">>> KrbCreds found the default ticket" + " granting ticket in credential cache."); } - if (EType.isSupported(temp.getEType())) { - result = temp.setKrbCreds(); + if (EType.isSupported(temp.key.getEType())) { + result = temp; } else { if (DEBUG) { System.out.println( ">>> unsupported key type found the default TGT: " + - temp.getEType()); + temp.key.getEType()); } } } @@ -474,10 +482,6 @@ public CredentialsCache getCache() { return cache; } - public EncryptionKey getServiceKey() { - return serviceKey; - } - /* * Prints out debug info. */ diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/JavaxSecurityAuthKerberosAccess.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/JavaxSecurityAuthKerberosAccess.java index 501e6b309a9..84ca79bc9b3 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/JavaxSecurityAuthKerberosAccess.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/JavaxSecurityAuthKerberosAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,8 @@ package sun.security.krb5; +import javax.security.auth.kerberos.KerberosTicket; import javax.security.auth.kerberos.KeyTab; -import sun.security.krb5.EncryptionKey; -import sun.security.krb5.PrincipalName; /** * An unsafe tunnel to get non-public access to classes in the @@ -39,4 +38,14 @@ public interface JavaxSecurityAuthKerberosAccess { */ public sun.security.krb5.internal.ktab.KeyTab keyTabTakeSnapshot( KeyTab ktab); + + /** + * Returns the proxy for a KerberosTicket. + */ + public KerberosTicket kerberosTicketGetProxy(KerberosTicket t); + + /** + * Sets the proxy for a KerberosTicket. + */ + public void kerberosTicketSetProxy(KerberosTicket t, KerberosTicket p); } diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java index bcaa342856c..cbd93e70742 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -187,7 +187,6 @@ protected static boolean isValidRealmString(String name) { return false; for (int i = 0; i < name.length(); i++) { if (name.charAt(i) == '/' || - name.charAt(i) == ':' || name.charAt(i) == '\0') { return false; } diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java index e4cd1f3a157..8ec1659cc08 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java @@ -325,16 +325,13 @@ boolean[] readFlags() throws IOException { } /** - * Reads the next cred in stream. - * @return the next cred, null if ticket or second_ticket unparseable. + * Reads the next cred or config entry in stream. + * @return the next cred or config entry, null if data unparseable. * - * Note: MIT krb5 1.8.1 might generate a config entry with server principal - * X-CACHECONF:/krb5_ccache_conf_data/fast_avail/krbtgt/REALM@REALM. The - * entry is used by KDC to inform the client that it support certain - * features. Its ticket is not a valid krb5 ticket and thus this method - * returns null. + * When data is unparseable, this method makes sure the correct number of + * bytes are consumed so it's safe to start reading the next element. */ - Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception { + Object readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception { PrincipalName cpname = null; try { cpname = readPrincipal(version); @@ -396,12 +393,23 @@ Credentials readCred(int version) throws IOException,RealmException, KrbApErrExc } try { + if (spname.getRealmString().equals("X-CACHECONF:")) { + String[] nameParts = spname.getNameStrings(); + if (nameParts[0].equals("krb5_ccache_conf_data")) { + return new CredentialsCache.ConfigEntry(nameParts[1], + nameParts.length > 2 ? new PrincipalName(nameParts[2]) : null, + ticketData); + } + } return new Credentials(cpname, spname, key, authtime, starttime, - endtime, renewTill, skey, tFlags, - addrs, auData, - ticketData != null ? new Ticket(ticketData) : null, - ticketData2 != null ? new Ticket(ticketData2) : null); + endtime, renewTill, skey, tFlags, + addrs, auData, + ticketData != null ? new Ticket(ticketData) : null, + ticketData2 != null ? new Ticket(ticketData2) : null); } catch (Exception e) { // If any of new Ticket(*) fails. + if (DEBUG) { + e.printStackTrace(System.out); + } return null; } } diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheOutputStream.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheOutputStream.java index dcc15e76d7d..cde9712bf3a 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheOutputStream.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CCacheOutputStream.java @@ -31,7 +31,6 @@ package sun.security.krb5.internal.ccache; import java.io.IOException; -import java.io.FileOutputStream; import java.io.OutputStream; import sun.security.krb5.internal.util.KrbDataOutputStream; import sun.security.krb5.*; @@ -98,6 +97,21 @@ public void addCreds(Credentials creds) throws IOException, Asn1Exception { writeTicket(creds.secondTicket); } + public void addConfigEntry(PrincipalName cname, CredentialsCache.ConfigEntry e) + throws IOException { + cname.writePrincipal(this); + e.getSName().writePrincipal(this); + write16(0); write16(0); write32(0); + write32(0); write32(0); write32(0); write32(0); + write8(0); + write32(0); + write32(0); + write32(0); + write32(e.getData().length); + write(e.getData()); + write32(0); + } + void writeTicket(Ticket t) throws IOException, Asn1Exception { if (t == null) { write32(0); diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/Credentials.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/Credentials.java index 7128545a25a..c62e6293ff7 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/Credentials.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/Credentials.java @@ -169,6 +169,18 @@ public PrincipalName getServicePrincipal() throws RealmException { return sname; } + public Ticket getTicket() throws RealmException { + return ticket; + } + + public PrincipalName getServicePrincipal2() throws RealmException { + return secondTicket == null ? null : secondTicket.sname; + } + + public PrincipalName getClientPrincipal() throws RealmException { + return cname; + } + public sun.security.krb5.Credentials setKrbCreds() { // Note: We will not pass authorizationData to s.s.k.Credentials. The // field in that class will be passed to Krb5Context as the return @@ -208,7 +220,15 @@ public int getEType() { return key.getEType(); } + public EncryptionKey getKey() { + return key; + } + public int getTktEType() { return ticket.encPart.getEType(); } + + public int getTktEType2() { + return (secondTicket == null) ? 0 : secondTicket.encPart.getEType(); + } } diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CredentialsCache.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CredentialsCache.java index 8c61ed395c0..9489b92389a 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CredentialsCache.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/CredentialsCache.java @@ -32,14 +32,9 @@ import sun.security.krb5.*; import sun.security.krb5.internal.*; -import java.util.StringTokenizer; -import java.util.Vector; + +import java.util.List; import java.io.IOException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.BufferedReader; -import java.io.InputStreamReader; /** * CredentialsCache stores credentials(tickets, session keys, etc) in a semi-permanent store @@ -120,6 +115,62 @@ public static String cacheName() { public abstract void save() throws IOException, KrbException; public abstract Credentials[] getCredsList(); public abstract Credentials getDefaultCreds(); + public abstract sun.security.krb5.Credentials getInitialCreds(); public abstract Credentials getCreds(PrincipalName sname); public abstract Credentials getCreds(LoginOptions options, PrincipalName sname); + public abstract void addConfigEntry(ConfigEntry e); + public abstract List<ConfigEntry> getConfigEntries(); + + public ConfigEntry getConfigEntry(String name) { + List<ConfigEntry> entries = getConfigEntries(); + if (entries != null) { + for (ConfigEntry e : entries) { + if (e.getName().equals(name)) { + return e; + } + } + } + return null; + } + + public static class ConfigEntry { + + public ConfigEntry(String name, PrincipalName princ, byte[] data) { + this.name = name; + this.princ = princ; + this.data = data; + } + + private final String name; + private final PrincipalName princ; + private final byte[] data; // not worth cloning + + public String getName() { + return name; + } + + public PrincipalName getPrinc() { + return princ; + } + + public byte[] getData() { + return data; + } + + @Override + public String toString() { + return name + (princ != null ? ("." + princ) : "") + + ": " + new String(data); + } + + public PrincipalName getSName() { + try { + return new PrincipalName("krb5_ccache_conf_data/" + name + + (princ != null ? ("/" + princ) : "") + + "@X-CACHECONF:"); + } catch (RealmException e) { + throw new AssertionError(e); + } + } + } } diff --git a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java index f22a1883c0b..69a60ecf359 100644 --- a/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java +++ b/src/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -35,6 +35,12 @@ import sun.security.krb5.*; import sun.security.krb5.internal.*; +import sun.security.util.SecurityProperties; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.StringTokenizer; import java.util.Vector; import java.io.IOException; @@ -181,9 +187,13 @@ synchronized void load(String name) throws IOException, KrbException { primaryPrincipal = p; credentialsList = new Vector<Credentials>(); while (cis.available() > 0) { - Credentials cred = cis.readCred(version); + Object cred = cis.readCred(version); if (cred != null) { - credentialsList.addElement(cred); + if (cred instanceof Credentials) { + credentialsList.addElement((Credentials)cred); + } else { + addConfigEntry((CredentialsCache.ConfigEntry)cred); + } } } } @@ -254,6 +264,9 @@ public synchronized void save() throws IOException, Asn1Exception { cos.addCreds(tmp[i]); } } + for (ConfigEntry e : getConfigEntries()) { + cos.addConfigEntry(primaryPrincipal, e); + } } } @@ -306,6 +319,17 @@ public Credentials getCreds(LoginOptions options, PrincipalName sname) { } } + private List<ConfigEntry> configEntries = new ArrayList<>(); + + @Override + public void addConfigEntry(ConfigEntry e) { + configEntries.add(e); + } + + @Override + public List<ConfigEntry> getConfigEntries() { + return Collections.unmodifiableList(configEntries); + } /** * Gets a credentials for a specified service. @@ -325,6 +349,81 @@ public Credentials getCreds(PrincipalName sname) { return null; } + public sun.security.krb5.Credentials getInitialCreds() { + + Credentials defaultCreds = getDefaultCreds(); + if (defaultCreds == null) { + return null; + } + sun.security.krb5.Credentials tgt = defaultCreds.setKrbCreds(); + + CredentialsCache.ConfigEntry entry = getConfigEntry("proxy_impersonator"); + if (entry == null) { + if (DEBUG) { + System.out.println("get normal credential"); + } + return tgt; + } + + boolean force; + String prop = SecurityProperties.privilegedGetOverridable( + "jdk.security.krb5.default.initiate.credential"); + if (prop == null) { + prop = "always-impersonate"; + } + switch (prop) { + case "no-impersonate": // never try impersonation + if (DEBUG) { + System.out.println("get normal credential"); + } + return tgt; + case "try-impersonate": + force = false; + break; + case "always-impersonate": + force = true; + break; + default: + throw new RuntimeException( + "Invalid jdk.security.krb5.default.initiate.credential"); + } + + try { + PrincipalName service = new PrincipalName( + new String(entry.getData(), StandardCharsets.UTF_8)); + if (!tgt.getClient().equals(service)) { + if (DEBUG) { + System.out.println("proxy_impersonator does not match service name"); + } + return force ? null : tgt; + } + PrincipalName client = getPrimaryPrincipal(); + Credentials proxy = null; + for (Credentials c : getCredsList()) { + if (c.getClientPrincipal().equals(client) + && c.getServicePrincipal().equals(service)) { + proxy = c; + break; + } + } + if (proxy == null) { + if (DEBUG) { + System.out.println("Cannot find evidence ticket in ccache"); + } + return force ? null : tgt; + } + if (DEBUG) { + System.out.println("Get proxied credential"); + } + return tgt.setProxy(proxy.setKrbCreds()); + } catch (KrbException e) { + if (DEBUG) { + System.out.println("Impersonation with ccache failed"); + } + return force ? null : tgt; + } + } + public Credentials getDefaultCreds() { Credentials[] list = getCredsList(); if (list == null) { diff --git a/src/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java b/src/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java index 95ba6e0d8c1..5a0c3bee077 100644 --- a/src/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java +++ b/src/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ package sun.security.krb5.internal.tools; import java.net.InetAddress; +import java.util.List; + import sun.security.krb5.*; import sun.security.krb5.internal.*; import sun.security.krb5.internal.ccache.*; @@ -249,6 +251,8 @@ void displayCache() { String endtime; String renewTill; String servicePrincipal; + PrincipalName servicePrincipal2; + String clientPrincipal; if (creds[i].getStartTime() != null) { starttime = format(creds[i].getStartTime()); } else { @@ -260,6 +264,18 @@ void displayCache() { System.out.println("[" + (i + 1) + "] " + " Service Principal: " + servicePrincipal); + servicePrincipal2 = + creds[i].getServicePrincipal2(); + if (servicePrincipal2 != null) { + System.out.println(" Second Service: " + + servicePrincipal2); + } + clientPrincipal = + creds[i].getClientPrincipal().toString(); + if (!clientPrincipal.equals(defaultPrincipal)) { + System.out.println(" Client Principal: " + + clientPrincipal); + } System.out.println(" Valid starting: " + starttime); System.out.println(" Expires: " + endtime); if (creds[i].getRenewTill() != null) { @@ -270,8 +286,15 @@ void displayCache() { if (options[0] == 'e') { String eskey = EType.toString(creds[i].getEType()); String etkt = EType.toString(creds[i].getTktEType()); - System.out.println(" EType (skey, tkt): " - + eskey + ", " + etkt); + if (creds[i].getTktEType2() == 0) { + System.out.println(" EType (skey, tkt): " + + eskey + ", " + etkt); + } else { + String etkt2 = EType.toString(creds[i].getTktEType2()); + System.out.println(" EType (skey, tkts): " + + eskey + ", " + etkt + + ", " + etkt2); + } } if (options[1] == 'f') { System.out.println(" Flags: " + @@ -310,6 +333,15 @@ void displayCache() { } else { System.out.println("\nNo entries found."); } + + List<CredentialsCache.ConfigEntry> configEntries + = cache.getConfigEntries(); + if (configEntries != null && !configEntries.isEmpty()) { + System.out.println("\nConfig entries:"); + for (CredentialsCache.ConfigEntry e : configEntries) { + System.out.println(" " + e); + } + } } void displayMessage(String target) { diff --git a/src/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java b/src/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java index bef95a458a8..575e54d68c9 100644 --- a/src/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java +++ b/src/src/java.security.sasl/share/classes/javax/security/sasl/Sasl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,12 @@ package javax.security.sasl; import javax.security.auth.callback.CallbackHandler; - +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.HashSet; @@ -38,6 +41,8 @@ import java.security.Provider; import java.security.Provider.Service; import java.security.Security; +import java.util.logging.Level; +import java.util.logging.Logger; /** * A static class for creating SASL clients and servers. @@ -65,6 +70,30 @@ * @author Rob Weltman */ public class Sasl { + + private static List<String> disabledMechanisms = new ArrayList<>(); + + static { + String prop = AccessController.doPrivileged( + (PrivilegedAction<String>) + () -> Security.getProperty("jdk.sasl.disabledMechanisms")); + + if (prop != null) { + for (String s : prop.split("\\s*,\\s*")) { + if (!s.isEmpty()) { + disabledMechanisms.add(s); + } + } + } + } + + private static final String SASL_LOGGER_NAME = "javax.security.sasl"; + + /** + * Logger for debug messages + */ + private static final Logger logger = Logger.getLogger(SASL_LOGGER_NAME); + // Cannot create one of these private Sasl() { } @@ -318,6 +347,9 @@ private Sasl() { * the preferred provider order for the specified algorithm. This * may be different than the order of providers returned by * {@link Security#getProviders() Security.getProviders()}. + * <p> + * If a mechanism is listed in the {@code jdk.sasl.disabledMechanisms} + * security property, it will be ignored and won't be negotiated. * * @param mechanisms The non-null list of mechanism names to try. Each is the * IANA-registered name of a SASL mechanism. (e.g. "GSSAPI", "CRAM-MD5"). @@ -381,6 +413,10 @@ public static SaslClient createSaslClient( "Mechanism name cannot be null"); } else if (mechName.length() == 0) { continue; + } else if (isDisabled(mechName)) { + logger.log(Level.FINE, + "Disabled " + mechName + " mechanism ignored"); + continue; } String type = "SaslClientFactory"; Provider[] provs = Security.getProviders(type + "." + mechName); @@ -468,6 +504,9 @@ private static Object loadFactory(Service service) * the preferred provider order for the specified algorithm. This * may be different than the order of providers returned by * {@link Security#getProviders() Security.getProviders()}. + * <p> + * If {@code mechanism} is listed in the {@code jdk.sasl.disabledMechanisms} + * security property, it will be ignored and this method returns {@code null}. * * @param mechanism The non-null mechanism name. It must be an * IANA-registered name of a SASL mechanism. (e.g. "GSSAPI", "CRAM-MD5"). @@ -521,6 +560,10 @@ private static Object loadFactory(Service service) throw new NullPointerException("Mechanism name cannot be null"); } else if (mechanism.length() == 0) { return null; + } else if (isDisabled(mechanism)) { + logger.log(Level.FINE, + "Disabled " + mechanism + " mechanism ignored"); + return null; } String type = "SaslServerFactory"; @@ -616,4 +659,8 @@ private static Set<Object> getFactories(String serviceName) { } return Collections.unmodifiableSet(result); } + + private static boolean isDisabled(String name) { + return disabledMechanisms.contains(name); + } } diff --git a/src/src/java.smartcardio/share/native/libj2pcsc/pcsc.c b/src/src/java.smartcardio/share/native/libj2pcsc/pcsc.c index 1510eb2c3ec..a55b0e7fddc 100644 --- a/src/src/java.smartcardio/share/native/libj2pcsc/pcsc.c +++ b/src/src/java.smartcardio/share/native/libj2pcsc/pcsc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -181,7 +181,7 @@ JNIEXPORT jobjectArray JNICALL Java_sun_security_smartcardio_PCSC_SCardListReade { SCARDCONTEXT context = (SCARDCONTEXT)jContext; LONG rv; - LPTSTR mszReaders = NULL; + LPSTR mszReaders = NULL; DWORD size = 0; jobjectArray result; @@ -220,7 +220,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_smartcardio_PCSC_SCardConnect { SCARDCONTEXT context = (SCARDCONTEXT)jContext; LONG rv; - LPCTSTR readerName; + LPCSTR readerName; SCARDHANDLE card = 0; DWORD proto = 0; diff --git a/src/src/java.smartcardio/unix/legal/pcsclite.md b/src/src/java.smartcardio/unix/legal/pcsclite.md index 380062df18a..42088c64314 100644 --- a/src/src/java.smartcardio/unix/legal/pcsclite.md +++ b/src/src/java.smartcardio/unix/legal/pcsclite.md @@ -1,10 +1,10 @@ -## PC/SC Lite for Suse Linux v1.1.1 +## PC/SC Lite v1.8.24 ### PC/SC Lite License <pre> -Copyright (c) 1999-2004 David Corcoran <corcoran@linuxnet.com> -Copyright (c) 1999-2004 Ludovic Rousseau <ludovic.rousseau (at) free.fr> +Copyright (c) 1999-2003 David Corcoran <corcoran@linuxnet.com> +Copyright (c) 2001-2011 Ludovic Rousseau <ludovic.rousseau@free.fr> All rights reserved. Redistribution and use in source and binary forms, with or without @@ -16,12 +16,7 @@ are met: 2. 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. -3. All advertising materials mentioning features or use of this software - must display the following acknowledgement: - This product includes software developed by: - David Corcoran <corcoran@linuxnet.com> - http://www.linuxnet.com (MUSCLE) -4. The name of the author may not be used to endorse or promote products +3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. Changes to this license can be made only by the copyright author with diff --git a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING index b1743ed007c..b3471ee09e4 100644 --- a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING +++ b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/COPYING @@ -1,4 +1,5 @@ -Copyright (c) 1999-2003 David Corcoran <corcoran@linuxnet.com> +Copyright (c) 1999-2003 David Corcoran <corcoran@musclecard.com> +Copyright (c) 2001-2011 Ludovic Rousseau <ludovic.rousseau@free.fr> All rights reserved. Redistribution and use in source and binary forms, with or without @@ -13,9 +14,6 @@ are met: 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. -Changes to this license can be made only by the copyright author with -explicit written consent. - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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. @@ -26,3 +24,72 @@ 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. + + +Some files are under GNU GPL v3 or any later version +- doc/example/pcsc_demo.c +- the files in src/spy/ +- the files in UnitaryTests/ + + Copyright (C) 2003-2014 Ludovic Rousseau + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + +Files src/auth.c and src/auth.h are: + * Copyright (C) 2013 Red Hat + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. 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. + * + * 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 HOLDER 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. + * + * Author: Nikos Mavrogiannopoulos <nmav@redhat.com> + + +Files src/simclist.c and src/simclist.h are: + * Copyright (c) 2007,2008,2009,2010,2011 Mij <mij@bitchx.it> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + diff --git a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h index 251d83de930..ee131c90407 100644 --- a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h +++ b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h @@ -1,374 +1,306 @@ /* - * This keeps a list of defines for pcsc-lite. - * - * MUSCLE SmartCard Development ( http://www.linuxnet.com ) + * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ ) * * Copyright (C) 1999-2004 - * David Corcoran <corcoran@linuxnet.com> + * David Corcoran <corcoran@musclecard.com> + * Copyright (C) 2002-2011 * Ludovic Rousseau <ludovic.rousseau@free.fr> + * Copyright (C) 2005 + * Martin Paljak <martin@paljak.pri.ee> * - * $Id: pcsclite.h.in,v 1.47 2004/08/24 21:46:57 rousseau Exp $ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. 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. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +/** + * @file + * @brief This keeps a list of defines for pcsc-lite. + * + * Error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx */ #ifndef __pcsclite_h__ #define __pcsclite_h__ -#ifndef __sun_jdk #include <wintypes.h> -#else -#include <sys/types.h> -#include <inttypes.h> -#ifdef BYTE -#error BYTE is already defined -#else - typedef unsigned char BYTE; -#endif /* End BYTE */ - - typedef unsigned char UCHAR; - typedef unsigned char *PUCHAR; - typedef unsigned short USHORT; - typedef unsigned long ULONG; - typedef void *LPVOID; - typedef short BOOL; - typedef unsigned long *PULONG; - typedef const void *LPCVOID; - typedef unsigned long DWORD; - typedef unsigned long *PDWORD; - typedef unsigned short WORD; - typedef long LONG; - typedef long RESPONSECODE; - typedef const char *LPCTSTR; - typedef const BYTE *LPCBYTE; - typedef BYTE *LPBYTE; - typedef DWORD *LPDWORD; - typedef char *LPTSTR; - -#endif #ifdef __cplusplus extern "C" { #endif -#ifdef WIN32 -#include <winscard.h> -#else -typedef long SCARDCONTEXT; +typedef LONG SCARDCONTEXT; /**< \p hContext returned by SCardEstablishContext() */ typedef SCARDCONTEXT *PSCARDCONTEXT; typedef SCARDCONTEXT *LPSCARDCONTEXT; -typedef long SCARDHANDLE; +typedef LONG SCARDHANDLE; /**< \p hCard returned by SCardConnect() */ typedef SCARDHANDLE *PSCARDHANDLE; typedef SCARDHANDLE *LPSCARDHANDLE; -#define MAX_ATR_SIZE 33 /* Maximum ATR size */ +#define MAX_ATR_SIZE 33 /**< Maximum ATR size */ -#ifndef __APPLE__ +/* Set structure elements aligment on bytes + * http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */ +#ifdef __APPLE__ +#pragma pack(1) +#endif typedef struct { - const char *szReader; - void *pvUserData; - unsigned long dwCurrentState; - unsigned long dwEventState; - unsigned long cbAtr; - unsigned char rgbAtr[MAX_ATR_SIZE]; + const char *szReader; + void *pvUserData; + DWORD dwCurrentState; + DWORD dwEventState; + DWORD cbAtr; + unsigned char rgbAtr[MAX_ATR_SIZE]; } -SCARD_READERSTATE_A; +SCARD_READERSTATE, *LPSCARD_READERSTATE; -typedef struct _SCARD_IO_REQUEST -{ - unsigned long dwProtocol; /* Protocol identifier */ - unsigned long cbPciLength; /* Protocol Control Inf Length */ -} -SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST; - -#else // __APPLE__ - -#pragma pack(1) +/** Protocol Control Information (PCI) */ typedef struct { - const char *szReader; - void *pvUserData; - uint32_t dwCurrentState; - uint32_t dwEventState; - uint32_t cbAtr; - unsigned char rgbAtr[MAX_ATR_SIZE]; -} -SCARD_READERSTATE_A; - -typedef struct _SCARD_IO_REQUEST -{ - uint32_t dwProtocol; /* Protocol identifier */ - uint32_t cbPciLength; /* Protocol Control Inf Length */ + unsigned long dwProtocol; /**< Protocol identifier */ + unsigned long cbPciLength; /**< Protocol Control Inf Length */ } SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST; -#pragma pack() - -#endif // __APPLE__ - -typedef SCARD_READERSTATE_A SCARD_READERSTATE, *PSCARD_READERSTATE_A, - *LPSCARD_READERSTATE_A; typedef const SCARD_IO_REQUEST *LPCSCARD_IO_REQUEST; -extern SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, - g_rgSCardRawPci; - -#define SCARD_PCI_T0 (&g_rgSCardT0Pci) -#define SCARD_PCI_T1 (&g_rgSCardT1Pci) -#define SCARD_PCI_RAW (&g_rgSCardRawPci) - -#define SCARD_S_SUCCESS 0x00000000 -#define SCARD_E_CANCELLED 0x80100002 -#define SCARD_E_CANT_DISPOSE 0x8010000E -#define SCARD_E_INSUFFICIENT_BUFFER 0x80100008 -#define SCARD_E_INVALID_ATR 0x80100015 -#define SCARD_E_INVALID_HANDLE 0x80100003 -#define SCARD_E_INVALID_PARAMETER 0x80100004 -#define SCARD_E_INVALID_TARGET 0x80100005 -#define SCARD_E_INVALID_VALUE 0x80100011 -#define SCARD_E_NO_MEMORY 0x80100006 -#define SCARD_F_COMM_ERROR 0x80100013 -#define SCARD_F_INTERNAL_ERROR 0x80100001 -#define SCARD_F_UNKNOWN_ERROR 0x80100014 -#define SCARD_F_WAITED_TOO_LONG 0x80100007 -#define SCARD_E_UNKNOWN_READER 0x80100009 -#define SCARD_E_TIMEOUT 0x8010000A -#define SCARD_E_SHARING_VIOLATION 0x8010000B -#define SCARD_E_NO_SMARTCARD 0x8010000C -#define SCARD_E_UNKNOWN_CARD 0x8010000D -#define SCARD_E_PROTO_MISMATCH 0x8010000F -#define SCARD_E_NOT_READY 0x80100010 -#define SCARD_E_SYSTEM_CANCELLED 0x80100012 -#define SCARD_E_NOT_TRANSACTED 0x80100016 -#define SCARD_E_READER_UNAVAILABLE 0x80100017 - -#define SCARD_W_UNSUPPORTED_CARD 0x80100065 -#define SCARD_W_UNRESPONSIVE_CARD 0x80100066 -#define SCARD_W_UNPOWERED_CARD 0x80100067 -#define SCARD_W_RESET_CARD 0x80100068 -#define SCARD_W_REMOVED_CARD 0x80100069 - -#define SCARD_E_PCI_TOO_SMALL 0x80100019 -#define SCARD_E_READER_UNSUPPORTED 0x8010001A -#define SCARD_E_DUPLICATE_READER 0x8010001B -#define SCARD_E_CARD_UNSUPPORTED 0x8010001C -#define SCARD_E_NO_SERVICE 0x8010001D -#define SCARD_E_SERVICE_STOPPED 0x8010001E - -#define SCARD_SCOPE_USER 0x0000 /* Scope in user space */ -#define SCARD_SCOPE_TERMINAL 0x0001 /* Scope in terminal */ -#define SCARD_SCOPE_SYSTEM 0x0002 /* Scope in system */ - -#define SCARD_PROTOCOL_UNSET 0x0000 /* protocol not set */ -#define SCARD_PROTOCOL_T0 0x0001 /* T=0 active protocol. */ -#define SCARD_PROTOCOL_T1 0x0002 /* T=1 active protocol. */ -#define SCARD_PROTOCOL_RAW 0x0004 /* Raw active protocol. */ -#define SCARD_PROTOCOL_T15 0x0008 /* T=15 protocol. */ - -#define SCARD_PROTOCOL_ANY (SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1) /* IFD determines prot. */ - -#define SCARD_SHARE_EXCLUSIVE 0x0001 /* Exclusive mode only */ -#define SCARD_SHARE_SHARED 0x0002 /* Shared mode only */ -#define SCARD_SHARE_DIRECT 0x0003 /* Raw mode only */ - -#define SCARD_LEAVE_CARD 0x0000 /* Do nothing on close */ -#define SCARD_RESET_CARD 0x0001 /* Reset on close */ -#define SCARD_UNPOWER_CARD 0x0002 /* Power down on close */ -#define SCARD_EJECT_CARD 0x0003 /* Eject on close */ - -#define SCARD_UNKNOWN 0x0001 /* Unknown state */ -#define SCARD_ABSENT 0x0002 /* Card is absent */ -#define SCARD_PRESENT 0x0004 /* Card is present */ -#define SCARD_SWALLOWED 0x0008 /* Card not powered */ -#define SCARD_POWERED 0x0010 /* Card is powered */ -#define SCARD_NEGOTIABLE 0x0020 /* Ready for PTS */ -#define SCARD_SPECIFIC 0x0040 /* PTS has been set */ - -#define SCARD_STATE_UNAWARE 0x0000 /* App wants status */ -#define SCARD_STATE_IGNORE 0x0001 /* Ignore this reader */ -#define SCARD_STATE_CHANGED 0x0002 /* State has changed */ -#define SCARD_STATE_UNKNOWN 0x0004 /* Reader unknown */ -#define SCARD_STATE_UNAVAILABLE 0x0008 /* Status unavailable */ -#define SCARD_STATE_EMPTY 0x0010 /* Card removed */ -#define SCARD_STATE_PRESENT 0x0020 /* Card inserted */ -#define SCARD_STATE_ATRMATCH 0x0040 /* ATR matches card */ -#define SCARD_STATE_EXCLUSIVE 0x0080 /* Exclusive Mode */ -#define SCARD_STATE_INUSE 0x0100 /* Shared Mode */ -#define SCARD_STATE_MUTE 0x0200 /* Unresponsive card */ -#define SCARD_STATE_UNPOWERED 0x0400 /* Unpowered card */ - -/* - * Tags for requesting card and reader attributes - */ - -#define SCARD_ATTR_VALUE(Class, Tag) ((((ULONG)(Class)) << 16) | ((ULONG)(Tag))) - -#define SCARD_CLASS_VENDOR_INFO 1 /* Vendor information definitions */ -#define SCARD_CLASS_COMMUNICATIONS 2 /* Communication definitions */ -#define SCARD_CLASS_PROTOCOL 3 /* Protocol definitions */ -#define SCARD_CLASS_POWER_MGMT 4 /* Power Management definitions */ -#define SCARD_CLASS_SECURITY 5 /* Security Assurance definitions */ -#define SCARD_CLASS_MECHANICAL 6 /* Mechanical characteristic definitions */ -#define SCARD_CLASS_VENDOR_DEFINED 7 /* Vendor specific definitions */ -#define SCARD_CLASS_IFD_PROTOCOL 8 /* Interface Device Protocol options */ -#define SCARD_CLASS_ICC_STATE 9 /* ICC State specific definitions */ -#define SCARD_CLASS_SYSTEM 0x7fff /* System-specific definitions */ - -#define SCARD_ATTR_VENDOR_NAME SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0100) -#define SCARD_ATTR_VENDOR_IFD_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0101) -#define SCARD_ATTR_VENDOR_IFD_VERSION SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0102) -#define SCARD_ATTR_VENDOR_IFD_SERIAL_NO SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0103) -#define SCARD_ATTR_CHANNEL_ID SCARD_ATTR_VALUE(SCARD_CLASS_COMMUNICATIONS, 0x0110) -#define SCARD_ATTR_ASYNC_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0120) -#define SCARD_ATTR_DEFAULT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0121) -#define SCARD_ATTR_MAX_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0122) -#define SCARD_ATTR_DEFAULT_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0123) -#define SCARD_ATTR_MAX_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0124) -#define SCARD_ATTR_MAX_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0125) -#define SCARD_ATTR_SYNC_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0126) -#define SCARD_ATTR_POWER_MGMT_SUPPORT SCARD_ATTR_VALUE(SCARD_CLASS_POWER_MGMT, 0x0131) -#define SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0140) -#define SCARD_ATTR_USER_AUTH_INPUT_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0142) -#define SCARD_ATTR_CHARACTERISTICS SCARD_ATTR_VALUE(SCARD_CLASS_MECHANICAL, 0x0150) - -#define SCARD_ATTR_CURRENT_PROTOCOL_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0201) -#define SCARD_ATTR_CURRENT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0202) -#define SCARD_ATTR_CURRENT_F SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0203) -#define SCARD_ATTR_CURRENT_D SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0204) -#define SCARD_ATTR_CURRENT_N SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0205) -#define SCARD_ATTR_CURRENT_W SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0206) -#define SCARD_ATTR_CURRENT_IFSC SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0207) -#define SCARD_ATTR_CURRENT_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0208) -#define SCARD_ATTR_CURRENT_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0209) -#define SCARD_ATTR_CURRENT_CWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020a) -#define SCARD_ATTR_CURRENT_EBC_ENCODING SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020b) -#define SCARD_ATTR_EXTENDED_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020c) - -#define SCARD_ATTR_ICC_PRESENCE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0300) -#define SCARD_ATTR_ICC_INTERFACE_STATUS SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0301) -#define SCARD_ATTR_CURRENT_IO_STATE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0302) -#define SCARD_ATTR_ATR_STRING SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0303) -#define SCARD_ATTR_ICC_TYPE_PER_ATR SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0304) - -#define SCARD_ATTR_ESC_RESET SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA000) -#define SCARD_ATTR_ESC_CANCEL SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA003) -#define SCARD_ATTR_ESC_AUTHREQUEST SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA005) -#define SCARD_ATTR_MAXINPUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA007) - -#define SCARD_ATTR_DEVICE_UNIT SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0001) -#define SCARD_ATTR_DEVICE_IN_USE SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0002) -#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0003) -#define SCARD_ATTR_DEVICE_SYSTEM_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0004) -#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0005) -#define SCARD_ATTR_DEVICE_SYSTEM_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0006) -#define SCARD_ATTR_SUPRESS_T1_IFS_REQUEST SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0007) - -#ifdef UNICODE -#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_W -#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_W -#else -#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_A -#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_A -#endif +extern const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci; +/* restore default structure elements alignment */ +#ifdef __APPLE__ +#pragma pack() #endif -/* PC/SC Lite specific extensions */ -#define SCARD_W_INSERTED_CARD 0x8010006A -#define SCARD_E_UNSUPPORTED_FEATURE 0x8010001F - -#define SCARD_SCOPE_GLOBAL 0x0003 /* Scope is global */ - -#define SCARD_RESET 0x0001 /* Card was reset */ -#define SCARD_INSERTED 0x0002 /* Card was inserted */ -#define SCARD_REMOVED 0x0004 /* Card was removed */ - -#define BLOCK_STATUS_RESUME 0x00FF /* Normal resume */ -#define BLOCK_STATUS_BLOCKING 0x00FA /* Function is blocking */ +#define SCARD_PCI_T0 (&g_rgSCardT0Pci) /**< protocol control information (PCI) for T=0 */ +#define SCARD_PCI_T1 (&g_rgSCardT1Pci) /**< protocol control information (PCI) for T=1 */ +#define SCARD_PCI_RAW (&g_rgSCardRawPci) /**< protocol control information (PCI) for RAW protocol */ -#define PCSCLITE_CONFIG_DIR "/etc" +/** + * @defgroup ErrorCodes ErrorCodes + * @brief Error code documentation + * + * The error codes descriptions are from + * http://msdn.microsoft.com/en-us/library/aa924526.aspx + */ +/** @ingroup ErrorCodes */ +#define SCARD_S_SUCCESS ((LONG)0x00000000) /**< No error was encountered. */ +/** @ingroup ErrorCodes */ +#define SCARD_F_INTERNAL_ERROR ((LONG)0x80100001) /**< An internal consistency check failed. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_CANCELLED ((LONG)0x80100002) /**< The action was cancelled by an SCardCancel request. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INVALID_HANDLE ((LONG)0x80100003) /**< The supplied handle was invalid. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INVALID_PARAMETER ((LONG)0x80100004) /**< One or more of the supplied parameters could not be properly interpreted. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INVALID_TARGET ((LONG)0x80100005) /**< Registry startup information is missing or invalid. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_MEMORY ((LONG)0x80100006) /**< Not enough memory available to complete this command. */ +/** @ingroup ErrorCodes */ +#define SCARD_F_WAITED_TOO_LONG ((LONG)0x80100007) /**< An internal consistency timer has expired. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INSUFFICIENT_BUFFER ((LONG)0x80100008) /**< The data buffer to receive returned data is too small for the returned data. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_UNKNOWN_READER ((LONG)0x80100009) /**< The specified reader name is not recognized. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_TIMEOUT ((LONG)0x8010000A) /**< The user-specified timeout value has expired. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_SHARING_VIOLATION ((LONG)0x8010000B) /**< The smart card cannot be accessed because of other connections outstanding. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_SMARTCARD ((LONG)0x8010000C) /**< The operation requires a Smart Card, but no Smart Card is currently in the device. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_UNKNOWN_CARD ((LONG)0x8010000D) /**< The specified smart card name is not recognized. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_CANT_DISPOSE ((LONG)0x8010000E) /**< The system could not dispose of the media in the requested manner. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_PROTO_MISMATCH ((LONG)0x8010000F) /**< The requested protocols are incompatible with the protocol currently in use with the smart card. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NOT_READY ((LONG)0x80100010) /**< The reader or smart card is not ready to accept commands. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INVALID_VALUE ((LONG)0x80100011) /**< One or more of the supplied parameters values could not be properly interpreted. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_SYSTEM_CANCELLED ((LONG)0x80100012) /**< The action was cancelled by the system, presumably to log off or shut down. */ +/** @ingroup ErrorCodes */ +#define SCARD_F_COMM_ERROR ((LONG)0x80100013) /**< An internal communications error has been detected. */ +/** @ingroup ErrorCodes */ +#define SCARD_F_UNKNOWN_ERROR ((LONG)0x80100014) /**< An internal error has been detected, but the source is unknown. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INVALID_ATR ((LONG)0x80100015) /**< An ATR obtained from the registry is not a valid ATR string. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NOT_TRANSACTED ((LONG)0x80100016) /**< An attempt was made to end a non-existent transaction. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_READER_UNAVAILABLE ((LONG)0x80100017) /**< The specified reader is not currently available for use. */ +/** @ingroup ErrorCodes */ +#define SCARD_P_SHUTDOWN ((LONG)0x80100018) /**< The operation has been aborted to allow the server application to exit. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_PCI_TOO_SMALL ((LONG)0x80100019) /**< The PCI Receive buffer was too small. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_READER_UNSUPPORTED ((LONG)0x8010001A) /**< The reader driver does not meet minimal requirements for support. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_DUPLICATE_READER ((LONG)0x8010001B) /**< The reader driver did not produce a unique reader name. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_CARD_UNSUPPORTED ((LONG)0x8010001C) /**< The smart card does not meet minimal requirements for support. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_SERVICE ((LONG)0x8010001D) /**< The Smart card resource manager is not running. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_SERVICE_STOPPED ((LONG)0x8010001E) /**< The Smart card resource manager has shut down. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_UNEXPECTED ((LONG)0x8010001F) /**< An unexpected card error has occurred. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_UNSUPPORTED_FEATURE ((LONG)0x8010001F) /**< This smart card does not support the requested feature. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_ICC_INSTALLATION ((LONG)0x80100020) /**< No primary provider can be found for the smart card. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_ICC_CREATEORDER ((LONG)0x80100021) /**< The requested order of object creation is not supported. */ +/** @ingroup ErrorCodes */ +/* #define SCARD_E_UNSUPPORTED_FEATURE ((LONG)0x80100022) / **< This smart card does not support the requested feature. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_DIR_NOT_FOUND ((LONG)0x80100023) /**< The identified directory does not exist in the smart card. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_FILE_NOT_FOUND ((LONG)0x80100024) /**< The identified file does not exist in the smart card. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_DIR ((LONG)0x80100025) /**< The supplied path does not represent a smart card directory. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_FILE ((LONG)0x80100026) /**< The supplied path does not represent a smart card file. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_ACCESS ((LONG)0x80100027) /**< Access is denied to this file. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_WRITE_TOO_MANY ((LONG)0x80100028) /**< The smart card does not have enough memory to store the information. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_BAD_SEEK ((LONG)0x80100029) /**< There was an error trying to set the smart card file object pointer. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_INVALID_CHV ((LONG)0x8010002A) /**< The supplied PIN is incorrect. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_UNKNOWN_RES_MNG ((LONG)0x8010002B) /**< An unrecognized error code was returned from a layered component. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_SUCH_CERTIFICATE ((LONG)0x8010002C) /**< The requested certificate does not exist. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_CERTIFICATE_UNAVAILABLE ((LONG)0x8010002D) /**< The requested certificate could not be obtained. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_READERS_AVAILABLE ((LONG)0x8010002E) /**< Cannot find a smart card reader. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_COMM_DATA_LOST ((LONG)0x8010002F) /**< A communications error with the smart card has been detected. Retry the operation. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_NO_KEY_CONTAINER ((LONG)0x80100030) /**< The requested key container does not exist on the smart card. */ +/** @ingroup ErrorCodes */ +#define SCARD_E_SERVER_TOO_BUSY ((LONG)0x80100031) /**< The Smart Card Resource Manager is too busy to complete this operation. */ + +/** @ingroup ErrorCodes */ +#define SCARD_W_UNSUPPORTED_CARD ((LONG)0x80100065) /**< The reader cannot communicate with the card, due to ATR string configuration conflicts. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_UNRESPONSIVE_CARD ((LONG)0x80100066) /**< The smart card is not responding to a reset. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_UNPOWERED_CARD ((LONG)0x80100067) /**< Power has been removed from the smart card, so that further communication is not possible. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_RESET_CARD ((LONG)0x80100068) /**< The smart card has been reset, so any shared state information is invalid. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_REMOVED_CARD ((LONG)0x80100069) /**< The smart card has been removed, so further communication is not possible. */ + +/** @ingroup ErrorCodes */ +#define SCARD_W_SECURITY_VIOLATION ((LONG)0x8010006A) /**< Access was denied because of a security violation. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_WRONG_CHV ((LONG)0x8010006B) /**< The card cannot be accessed because the wrong PIN was presented. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_CHV_BLOCKED ((LONG)0x8010006C) /**< The card cannot be accessed because the maximum number of PIN entry attempts has been reached. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_EOF ((LONG)0x8010006D) /**< The end of the smart card file has been reached. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_CANCELLED_BY_USER ((LONG)0x8010006E) /**< The user pressed "Cancel" on a Smart Card Selection Dialog. */ +/** @ingroup ErrorCodes */ +#define SCARD_W_CARD_NOT_AUTHENTICATED ((LONG)0x8010006F) /**< No PIN was presented to the smart card. */ + +#define SCARD_AUTOALLOCATE (DWORD)(-1) /**< see SCardFreeMemory() */ +#define SCARD_SCOPE_USER 0x0000 /**< Scope in user space */ +#define SCARD_SCOPE_TERMINAL 0x0001 /**< Scope in terminal */ +#define SCARD_SCOPE_SYSTEM 0x0002 /**< Scope in system */ +#define SCARD_SCOPE_GLOBAL 0x0003 /**< Scope is global */ + +#define SCARD_PROTOCOL_UNDEFINED 0x0000 /**< protocol not set */ +#define SCARD_PROTOCOL_UNSET SCARD_PROTOCOL_UNDEFINED /* backward compat */ +#define SCARD_PROTOCOL_T0 0x0001 /**< T=0 active protocol. */ +#define SCARD_PROTOCOL_T1 0x0002 /**< T=1 active protocol. */ +#define SCARD_PROTOCOL_RAW 0x0004 /**< Raw active protocol. */ +#define SCARD_PROTOCOL_T15 0x0008 /**< T=15 protocol. */ + +#define SCARD_PROTOCOL_ANY (SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1) /**< IFD determines prot. */ + +#define SCARD_SHARE_EXCLUSIVE 0x0001 /**< Exclusive mode only */ +#define SCARD_SHARE_SHARED 0x0002 /**< Shared mode only */ +#define SCARD_SHARE_DIRECT 0x0003 /**< Raw mode only */ + +#define SCARD_LEAVE_CARD 0x0000 /**< Do nothing on close */ +#define SCARD_RESET_CARD 0x0001 /**< Reset on close */ +#define SCARD_UNPOWER_CARD 0x0002 /**< Power down on close */ +#define SCARD_EJECT_CARD 0x0003 /**< Eject on close */ + +#define SCARD_UNKNOWN 0x0001 /**< Unknown state */ +#define SCARD_ABSENT 0x0002 /**< Card is absent */ +#define SCARD_PRESENT 0x0004 /**< Card is present */ +#define SCARD_SWALLOWED 0x0008 /**< Card not powered */ +#define SCARD_POWERED 0x0010 /**< Card is powered */ +#define SCARD_NEGOTIABLE 0x0020 /**< Ready for PTS */ +#define SCARD_SPECIFIC 0x0040 /**< PTS has been set */ + +#define SCARD_STATE_UNAWARE 0x0000 /**< App wants status */ +#define SCARD_STATE_IGNORE 0x0001 /**< Ignore this reader */ +#define SCARD_STATE_CHANGED 0x0002 /**< State has changed */ +#define SCARD_STATE_UNKNOWN 0x0004 /**< Reader unknown */ +#define SCARD_STATE_UNAVAILABLE 0x0008 /**< Status unavailable */ +#define SCARD_STATE_EMPTY 0x0010 /**< Card removed */ +#define SCARD_STATE_PRESENT 0x0020 /**< Card inserted */ +#define SCARD_STATE_ATRMATCH 0x0040 /**< ATR matches card */ +#define SCARD_STATE_EXCLUSIVE 0x0080 /**< Exclusive Mode */ +#define SCARD_STATE_INUSE 0x0100 /**< Shared Mode */ +#define SCARD_STATE_MUTE 0x0200 /**< Unresponsive card */ +#define SCARD_STATE_UNPOWERED 0x0400 /**< Unpowered card */ -#ifndef USE_IPCDIR -#define PCSCLITE_IPC_DIR "/var/run" -#else -#define PCSCLITE_IPC_DIR USE_IPCDIR +#ifndef INFINITE +#define INFINITE 0xFFFFFFFF /**< Infinite timeout */ #endif -#define PCSCLITE_READER_CONFIG PCSCLITE_CONFIG_DIR "/reader.conf" -#define PCSCLITE_PUBSHM_FILE PCSCLITE_IPC_DIR "/pcscd.pub" -#define PCSCLITE_CSOCK_NAME PCSCLITE_IPC_DIR "/pcscd.comm" +#define PCSCLITE_VERSION_NUMBER "1.8.24" /**< Current version */ +/** Maximum readers context (a slot is count as a reader) */ +#define PCSCLITE_MAX_READERS_CONTEXTS 16 -#define PCSCLITE_SVC_IDENTITY 0x01030000 /* Service ID */ - -#ifndef INFINITE -#define INFINITE 0xFFFFFFFF /* Infinite timeout */ -#endif -#define PCSCLITE_INFINITE_TIMEOUT 4320000 /* 50 day infinite t/o */ - -#define PCSCLITE_VERSION_NUMBER "1.2.9-beta7" /* Current version */ -#define PCSCLITE_CLIENT_ATTEMPTS 120 /* Attempts to reach sv */ -#define PCSCLITE_MCLIENT_ATTEMPTS 20 /* Attempts to reach sv */ -#define PCSCLITE_STATUS_POLL_RATE 400000 /* Status polling rate */ -#define PCSCLITE_MSG_KEY_LEN 16 /* App ID key length */ -#define PCSCLITE_RW_ATTEMPTS 100 /* Attempts to rd/wrt */ - -/* Maximum applications */ -#define PCSCLITE_MAX_APPLICATIONS 16 -/* Maximum contexts by application */ -#define PCSCLITE_MAX_APPLICATION_CONTEXTS 16 -/* Maximum of applications contexts that pcscd can accept */ -#define PCSCLITE_MAX_APPLICATIONS_CONTEXTS \ - PCSCLITE_MAX_APPLICATIONS * PCSCLITE_MAX_APPLICATION_CONTEXTS -/* Maximum channels on a reader context */ -#define PCSCLITE_MAX_READER_CONTEXT_CHANNELS 16 -/* Maximum channels on an application context */ -#define PCSCLITE_MAX_APPLICATION_CONTEXT_CHANNELS 16 -/* Maximum readers context (a slot is count as a reader) */ -#define PCSCLITE_MAX_READERS_CONTEXTS 16 - -/* PCSCLITE_MAX_READERS is deprecated - * use PCSCLITE_MAX_READERS_CONTEXTS instead */ -/* extern int PCSCLITE_MAX_READERS __attribute__ ((deprecated)); */ - -#define PCSCLITE_MAX_THREADS 16 /* Stat change threads */ -#define PCSCLITE_STATUS_WAIT 200000 /* Status Change Sleep */ -#define PCSCLITE_TRANSACTION_TIMEOUT 40 /* Transaction timeout */ -#define MAX_READERNAME 52 -#define MAX_LIBNAME 100 -#define MAX_DEVICENAME 255 +#define MAX_READERNAME 128 #ifndef SCARD_ATR_LENGTH -#define SCARD_ATR_LENGTH MAX_ATR_SIZE /* Maximum ATR size */ +#define SCARD_ATR_LENGTH MAX_ATR_SIZE /**< Maximum ATR size */ #endif -/* - * Enhanced messaging has been added to accommodate newer devices which have - * more advanced capabilities, such as dedicated secure co-processors which - * can stream and encrypt data over USB. In order to used enhanced messaging - * you must define PCSCLITE_ENHANCED_MESSAGING in the framework(library), - * the daemon, and your application - */ -#undef PCSCLITE_ENHANCED_MESSAGING -#ifndef PCSCLITE_ENHANCED_MESSAGING -#define PCSCLITE_MAX_MESSAGE_SIZE 2048 /* Transport msg len */ -#define MAX_BUFFER_SIZE 264 /* Maximum Tx/Rx Buffer */ -#define PCSCLITE_SERVER_ATTEMPTS 5 /* Attempts to reach cl */ -#else /* * The message and buffer sizes must be multiples of 16. * The max message size must be at least large enough - * to accommodate the transmit_struct + * to accomodate the transmit_struct */ -#define PCSCLITE_MAX_MESSAGE_SIZE (1<<17) /* enhanced (128K) msg len */ -#define MAX_BUFFER_SIZE (1<<15) /* enhanced (32K) Tx/Rx Buffer */ -#define PCSCLITE_SERVER_ATTEMPTS 200 /* To allow larger data reads/writes */ -#endif +#define MAX_BUFFER_SIZE 264 /**< Maximum Tx/Rx Buffer for short APDU */ +#define MAX_BUFFER_SIZE_EXTENDED (4 + 3 + (1<<16) + 3 + 2) /**< enhanced (64K + APDU + Lc + Le + SW) Tx/Rx Buffer */ /* * Gets a stringified error response */ -char *pcsc_stringify_error(long); +const char *pcsc_stringify_error(const LONG); #ifdef __cplusplus } diff --git a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h index 37d40bb85be..7da9d713e66 100644 --- a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h +++ b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h @@ -1,13 +1,38 @@ /* - * This handles smartcard reader communications. - * - * MUSCLE SmartCard Development ( http://www.linuxnet.com ) + * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ ) * * Copyright (C) 1999-2003 - * David Corcoran <corcoran@linuxnet.com> + * David Corcoran <corcoran@musclecard.com> + * Copyright (C) 2002-2009 * Ludovic Rousseau <ludovic.rousseau@free.fr> * - * $Id: winscard.h,v 1.13 2004/08/06 12:12:19 rousseau Exp $ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. 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. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +/** + * @file + * @brief This handles smart card reader communications. */ #ifndef __winscard_h__ @@ -20,71 +45,79 @@ extern "C" { #endif - LONG SCardEstablishContext(DWORD dwScope, - LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext); +#ifndef PCSC_API +#define PCSC_API +#endif - LONG SCardReleaseContext(SCARDCONTEXT hContext); + PCSC_API LONG SCardEstablishContext(DWORD dwScope, + /*@null@*/ LPCVOID pvReserved1, /*@null@*/ LPCVOID pvReserved2, + /*@out@*/ LPSCARDCONTEXT phContext); - LONG SCardSetTimeout(SCARDCONTEXT hContext, DWORD dwTimeout); + PCSC_API LONG SCardReleaseContext(SCARDCONTEXT hContext); - LONG SCardConnect(SCARDCONTEXT hContext, - LPCTSTR szReader, - DWORD dwShareMode, - DWORD dwPreferredProtocols, - LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); + PCSC_API LONG SCardIsValidContext(SCARDCONTEXT hContext); - LONG SCardReconnect(SCARDHANDLE hCard, - DWORD dwShareMode, - DWORD dwPreferredProtocols, - DWORD dwInitialization, LPDWORD pdwActiveProtocol); + PCSC_API LONG SCardConnect(SCARDCONTEXT hContext, + LPCSTR szReader, + DWORD dwShareMode, + DWORD dwPreferredProtocols, + /*@out@*/ LPSCARDHANDLE phCard, /*@out@*/ LPDWORD pdwActiveProtocol); - LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition); + PCSC_API LONG SCardReconnect(SCARDHANDLE hCard, + DWORD dwShareMode, + DWORD dwPreferredProtocols, + DWORD dwInitialization, /*@out@*/ LPDWORD pdwActiveProtocol); - LONG SCardBeginTransaction(SCARDHANDLE hCard); + PCSC_API LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition); - LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition); + PCSC_API LONG SCardBeginTransaction(SCARDHANDLE hCard); - LONG SCardCancelTransaction(SCARDHANDLE hCard); + PCSC_API LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition); - LONG SCardStatus(SCARDHANDLE hCard, - LPTSTR mszReaderNames, LPDWORD pcchReaderLen, - LPDWORD pdwState, - LPDWORD pdwProtocol, - LPBYTE pbAtr, LPDWORD pcbAtrLen); + PCSC_API LONG SCardStatus(SCARDHANDLE hCard, + /*@null@*/ /*@out@*/ LPSTR mszReaderName, + /*@null@*/ /*@out@*/ LPDWORD pcchReaderLen, + /*@null@*/ /*@out@*/ LPDWORD pdwState, + /*@null@*/ /*@out@*/ LPDWORD pdwProtocol, + /*@null@*/ /*@out@*/ LPBYTE pbAtr, + /*@null@*/ /*@out@*/ LPDWORD pcbAtrLen); - LONG SCardGetStatusChange(SCARDCONTEXT hContext, - DWORD dwTimeout, - LPSCARD_READERSTATE_A rgReaderStates, DWORD cReaders); + PCSC_API LONG SCardGetStatusChange(SCARDCONTEXT hContext, + DWORD dwTimeout, + SCARD_READERSTATE *rgReaderStates, DWORD cReaders); - LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, - LPCVOID pbSendBuffer, DWORD cbSendLength, - LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned); + PCSC_API LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, + LPCVOID pbSendBuffer, DWORD cbSendLength, + /*@out@*/ LPVOID pbRecvBuffer, DWORD cbRecvLength, + LPDWORD lpBytesReturned); - LONG SCardTransmit(SCARDHANDLE hCard, - LPCSCARD_IO_REQUEST pioSendPci, - LPCBYTE pbSendBuffer, DWORD cbSendLength, - LPSCARD_IO_REQUEST pioRecvPci, - LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength); + PCSC_API LONG SCardTransmit(SCARDHANDLE hCard, + const SCARD_IO_REQUEST *pioSendPci, + LPCBYTE pbSendBuffer, DWORD cbSendLength, + /*@out@*/ SCARD_IO_REQUEST *pioRecvPci, + /*@out@*/ LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength); - LONG SCardListReaderGroups(SCARDCONTEXT hContext, - LPTSTR mszGroups, LPDWORD pcchGroups); + PCSC_API LONG SCardListReaderGroups(SCARDCONTEXT hContext, + /*@out@*/ LPSTR mszGroups, LPDWORD pcchGroups); - LONG SCardListReaders(SCARDCONTEXT hContext, - LPCTSTR mszGroups, - LPTSTR mszReaders, LPDWORD pcchReaders); + PCSC_API LONG SCardListReaders(SCARDCONTEXT hContext, + /*@null@*/ /*@out@*/ LPCSTR mszGroups, + /*@null@*/ /*@out@*/ LPSTR mszReaders, + /*@out@*/ LPDWORD pcchReaders); - LONG SCardCancel(SCARDCONTEXT hContext); + PCSC_API LONG SCardFreeMemory(SCARDCONTEXT hContext, LPCVOID pvMem); - LONG SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, - LPDWORD pcbAttrLen); + PCSC_API LONG SCardCancel(SCARDCONTEXT hContext); - LONG SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, - DWORD cbAttrLen); + PCSC_API LONG SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, + /*@out@*/ LPBYTE pbAttr, LPDWORD pcbAttrLen); - void SCardUnload(void); + PCSC_API LONG SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, + LPCBYTE pbAttr, DWORD cbAttrLen); #ifdef __cplusplus } #endif #endif + diff --git a/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h new file mode 100644 index 00000000000..3770de20909 --- /dev/null +++ b/src/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h @@ -0,0 +1,115 @@ +/* + * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ ) + * + * Copyright (C) 1999 + * David Corcoran <corcoran@musclecard.com> + * Copyright (C) 2002-2011 + * Ludovic Rousseau <ludovic.rousseau@free.fr> + * +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. 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. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +/** + * @file + * @brief This keeps a list of Windows(R) types. + */ + +#ifndef __wintypes_h__ +#define __wintypes_h__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __APPLE__ + +#include <stdint.h> + +#ifndef BYTE + typedef uint8_t BYTE; +#endif + typedef uint8_t UCHAR; + typedef UCHAR *PUCHAR; + typedef uint16_t USHORT; + +#ifndef __COREFOUNDATION_CFPLUGINCOM__ + typedef uint32_t ULONG; + typedef void *LPVOID; + typedef int16_t BOOL; +#endif + + typedef ULONG *PULONG; + typedef const void *LPCVOID; + typedef uint32_t DWORD; + typedef DWORD *PDWORD; + typedef uint16_t WORD; + typedef int32_t LONG; + typedef const char *LPCSTR; + typedef const BYTE *LPCBYTE; + typedef BYTE *LPBYTE; + typedef DWORD *LPDWORD; + typedef char *LPSTR; + +#else + +#ifndef BYTE + typedef unsigned char BYTE; +#endif + typedef unsigned char UCHAR; + typedef UCHAR *PUCHAR; + typedef unsigned short USHORT; + +#ifndef __COREFOUNDATION_CFPLUGINCOM__ + typedef unsigned long ULONG; + typedef void *LPVOID; +#endif + + typedef const void *LPCVOID; + typedef unsigned long DWORD; + typedef DWORD *PDWORD; + typedef long LONG; + typedef const char *LPCSTR; + typedef const BYTE *LPCBYTE; + typedef BYTE *LPBYTE; + typedef DWORD *LPDWORD; + typedef char *LPSTR; + + /* these types were deprecated but still used by old drivers and + * applications. So just declare and use them. */ + typedef LPSTR LPTSTR; + typedef LPCSTR LPCTSTR; + + /* types unused by pcsc-lite */ + typedef short BOOL; + typedef unsigned short WORD; + typedef ULONG *PULONG; + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h b/src/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h index 4a8137595a2..db93c9cd93b 100644 --- a/src/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h +++ b/src/src/java.smartcardio/unix/native/libj2pcsc/pcsc_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,48 +23,49 @@ * questions. */ -typedef LONG (*FPTR_SCardEstablishContext)(ULONG dwScope, - const void *pvReserved1, - const void *pvReserved2, - LONG *phContext); - -typedef LONG (*FPTR_SCardConnect)(LONG hContext, - const char *szReader, - ULONG dwShareMode, - ULONG dwPreferredProtocols, - LONG *phCard, ULONG *pdwActiveProtocol); - -typedef LONG (*FPTR_SCardDisconnect)(LONG hCard, ULONG dwDisposition); - -typedef LONG (*FPTR_SCardStatus)(LONG hCard, - char *mszReaderNames, - ULONG *pcchReaderLen, - ULONG *pdwState, - ULONG *pdwProtocol, - unsigned char *pbAtr, ULONG *pcbAtrLen); - -typedef LONG (*FPTR_SCardGetStatusChange)(LONG hContext, - ULONG dwTimeout, - LPSCARD_READERSTATE_A rgReaderStates, ULONG cReaders); - -typedef LONG (*FPTR_SCardTransmit)(LONG hCard, - LPCSCARD_IO_REQUEST pioSendPci, - const unsigned char *pbSendBuffer, - ULONG cbSendLength, - LPSCARD_IO_REQUEST pioRecvPci, - unsigned char *pbRecvBuffer, ULONG *pcbRecvLength); - -typedef LONG (*FPTR_SCardListReaders)(LONG hContext, - const char *mszGroups, - char *mszReaders, ULONG *pcchReaders); - -typedef LONG (*FPTR_SCardBeginTransaction)(LONG hCard); - -typedef LONG (*FPTR_SCardEndTransaction)(LONG hCard, ULONG dwDisposition); - -typedef LONG (*FPTR_SCardControl)(LONG hCard, ULONG dwControlCode, - const void* pbSendBuffer, ULONG cbSendLength, const void* pbRecvBuffer, - ULONG pcbRecvLength, ULONG *lpBytesReturned); +typedef LONG (*FPTR_SCardEstablishContext)(DWORD dwScope, + LPCVOID pvReserved1, + LPCVOID pvReserved2, + LPSCARDCONTEXT phContext); + +typedef LONG (*FPTR_SCardConnect)(SCARDCONTEXT hContext, + LPCSTR szReader, + DWORD dwShareMode, + DWORD dwPreferredProtocols, + LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); + +typedef LONG (*FPTR_SCardDisconnect)(SCARDHANDLE hCard, DWORD dwDisposition); + +typedef LONG (*FPTR_SCardStatus)(SCARDHANDLE hCard, + LPSTR mszReaderNames, + LPDWORD pcchReaderLen, + LPDWORD pdwState, + LPDWORD pdwProtocol, + LPBYTE pbAtr, LPDWORD pcbAtrLen); + +typedef LONG (*FPTR_SCardGetStatusChange)(SCARDCONTEXT hContext, + DWORD dwTimeout, + SCARD_READERSTATE *rgReaderStates, DWORD cReaders); + +typedef LONG (*FPTR_SCardTransmit)(SCARDHANDLE hCard, + const SCARD_IO_REQUEST *pioSendPci, + LPCBYTE pbSendBuffer, + DWORD cbSendLength, + SCARD_IO_REQUEST *pioRecvPci, + LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength); + +typedef LONG (*FPTR_SCardListReaders)(SCARDCONTEXT hContext, + LPCSTR mszGroups, + LPSTR mszReaders, LPDWORD pcchReaders); + +typedef LONG (*FPTR_SCardBeginTransaction)(SCARDHANDLE hCard); + +typedef LONG (*FPTR_SCardEndTransaction)(SCARDHANDLE hCard, + DWORD dwDisposition); + +typedef LONG (*FPTR_SCardControl)(SCARDHANDLE hCard, DWORD dwControlCode, + LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, + DWORD pcbRecvLength, LPDWORD lpBytesReturned); #define CALL_SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext) \ ((scardEstablishContext)(dwScope, pvReserved1, pvReserved2, phContext)) diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java index 3650ed082c4..98e3dc35537 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java @@ -40,6 +40,7 @@ import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.w3c.dom.Text; public abstract class IntegrityHmac extends SignatureAlgorithmSpi { @@ -325,12 +326,13 @@ protected void engineGetContextFromElement(Element element) { throw new IllegalArgumentException("element null"); } - Text hmaclength = - XMLUtils.selectDsNodeText(element.getFirstChild(), Constants._TAG_HMACOUTPUTLENGTH, 0); - - if (hmaclength != null) { - this.HMACOutputLength = Integer.parseInt(hmaclength.getData()); - this.HMACOutputLengthSet = true; + Node n = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_HMACOUTPUTLENGTH, 0); + if (n != null) { + String hmacLength = XMLUtils.getFullTextChildrenFromNode(n); + if (hmacLength != null && !"".equals(hmacLength)) { + this.HMACOutputLength = Integer.parseInt(hmacLength); + this.HMACOutputLengthSet = true; + } } } diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java index 14633e48cc8..db41d7d17df 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java @@ -33,7 +33,6 @@ import java.security.SignatureException; import java.security.interfaces.DSAKey; import java.security.spec.AlgorithmParameterSpec; -import java.util.Base64; import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi; @@ -41,6 +40,7 @@ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.JavaUtils; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; public class SignatureDSA extends SignatureAlgorithmSpi { @@ -109,7 +109,7 @@ protected boolean engineVerify(byte[] signature) throws XMLSignatureException { try { if (LOG.isDebugEnabled()) { - LOG.debug("Called DSA.verify() on " + Base64.getMimeEncoder().encodeToString(signature)); + LOG.debug("Called DSA.verify() on " + XMLUtils.encodeToString(signature)); } byte[] jcebytes = JavaUtils.convertDsaXMLDSIGtoASN1(signature, diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java index d2afab16c63..40df4338f42 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java @@ -33,12 +33,12 @@ import java.security.Signature; import java.security.SignatureException; import java.security.spec.AlgorithmParameterSpec; -import java.util.Base64; import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi; import com.sun.org.apache.xml.internal.security.signature.XMLSignature; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; /** * @@ -132,7 +132,7 @@ protected boolean engineVerify(byte[] signature) throws XMLSignatureException { byte[] jcebytes = SignatureECDSA.convertXMLDSIGtoASN1(signature); if (LOG.isDebugEnabled()) { - LOG.debug("Called ECDSA.verify() on " + Base64.getMimeEncoder().encodeToString(signature)); + LOG.debug("Called ECDSA.verify() on " + XMLUtils.encodeToString(signature)); } return this.signatureAlgorithm.verify(jcebytes); diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java index 11cc71861d3..a2459351265 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java @@ -331,7 +331,7 @@ protected void handleParent(Element e, NameSpaceSymbTable ns) { ns.addMapping(NName, NValue, attribute); } } else if (XML_LANG_URI.equals(attribute.getNamespaceURI()) - && (!c14n11 || c14n11 && !"id".equals(NName))) { + && (!c14n11 || !"id".equals(NName))) { xmlattrStack.addXmlnsAttr(attribute); } } diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java index a873833f3d1..072940e5bfd 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java @@ -342,7 +342,7 @@ protected void outputAttributes(Element element, NameSpaceSymbTable ns, protected void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException { - if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty() || inclusiveNSSet.isEmpty()) { + if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty()) { return; } Document doc = null; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java index 4ba8c3f4587..f87058a1fdb 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java @@ -50,7 +50,6 @@ import com.sun.org.apache.xml.internal.security.transforms.Transforms; import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.ElementProxy; -import com.sun.org.apache.xml.internal.security.utils.EncryptionConstants; import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import org.w3c.dom.Attr; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java index 9a542e9853f..d30f504cf29 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java @@ -26,6 +26,7 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue; +import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.ECKeyValue; import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue; import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; @@ -107,9 +108,14 @@ public KeyValue(Document doc, PublicKey pk) { appendSelf(rsa); addReturnToSelf(); + } else if (pk instanceof java.security.interfaces.ECPublicKey) { + ECKeyValue ec = new ECKeyValue(getDocument(), pk); + + appendSelf(ec); + addReturnToSelf(); } else { String error = "The given PublicKey type " + pk + " is not supported. Only DSAPublicKey and " - + "RSAPublicKey types are currently supported"; + + "RSAPublicKey and ECPublicKey types are currently supported"; throw new IllegalArgumentException(error); } } diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java new file mode 100644 index 00000000000..ab591ebb455 --- /dev/null +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java @@ -0,0 +1,366 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.sun.org.apache.xml.internal.security.keys.content.keyvalues; + +import java.io.IOException; +import java.math.BigInteger; +import java.security.Key; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.PublicKey; +import java.security.interfaces.ECPublicKey; +import java.security.spec.ECField; +import java.security.spec.ECFieldFp; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; +import java.security.spec.ECPublicKeySpec; +import java.security.spec.EllipticCurve; +import java.security.spec.InvalidKeySpecException; +import java.util.Arrays; + +import javax.xml.crypto.MarshalException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.Text; + +import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; +import com.sun.org.apache.xml.internal.security.utils.Constants; +import com.sun.org.apache.xml.internal.security.utils.I18n; +import com.sun.org.apache.xml.internal.security.utils.Signature11ElementProxy; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; + +public class ECKeyValue extends Signature11ElementProxy implements KeyValueContent { + + /* Supported curve, secp256r1 */ + private static final Curve SECP256R1 = initializeCurve( + "secp256r1 [NIST P-256, X9.62 prime256v1]", + "1.2.840.10045.3.1.7", + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", + "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", + "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", + "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", + 1 + ); + + /* Supported curve secp384r1 */ + private static final Curve SECP384R1 = initializeCurve( + "secp384r1 [NIST P-384]", + "1.3.132.0.34", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC", + "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF", + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7", + "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973", + 1 + ); + + /* Supported curve secp521r1 */ + private static final Curve SECP521R1 = initializeCurve( + "secp521r1 [NIST P-521]", + "1.3.132.0.35", + "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC", + "0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00", + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66", + "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650", + "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409", + 1 + ); + + private static Curve initializeCurve(String name, String oid, + String sfield, String a, String b, + String x, String y, String n, int h) { + BigInteger p = bigInt(sfield); + ECField field = new ECFieldFp(p); + EllipticCurve curve = new EllipticCurve(field, bigInt(a), + bigInt(b)); + ECPoint g = new ECPoint(bigInt(x), bigInt(y)); + return new Curve(name, oid, curve, g, bigInt(n), h); + } + + + /** + * Constructor DSAKeyValue + * + * @param element + * @param baseURI + * @throws XMLSecurityException + */ + public ECKeyValue(Element element, String baseURI) throws XMLSecurityException { + super(element, baseURI); + } + + /** + * Constructor DSAKeyValue + * + * @param doc + * @param key + * @throws IllegalArgumentException + */ + public ECKeyValue(Document doc, Key key) throws IllegalArgumentException { + super(doc); + + addReturnToSelf(); + + if (key instanceof ECPublicKey) { + ECParameterSpec ecParams = ((ECPublicKey)key).getParams(); + + // NamedCurve + String oid = getCurveOid(ecParams); + if (oid == null) { + throw new IllegalArgumentException("Invalid ECParameterSpec"); + } + + Element namedCurveElement = XMLUtils.createElementInSignature11Space(getDocument(), "NamedCurve"); + namedCurveElement.setAttributeNS(null, "URI", "urn:oid:" + oid); + appendSelf(namedCurveElement); + addReturnToSelf(); + + // PublicKey + ECPoint ecPoint = ((ECPublicKey)key).getW(); + byte[] secPublicKey = encodePoint(ecPoint, ecParams.getCurve()); + String encoded = XMLUtils.encodeToString(secPublicKey); + Element publicKeyElement = XMLUtils.createElementInSignature11Space(getDocument(), "PublicKey"); + Text text = getDocument().createTextNode(encoded); + + publicKeyElement.appendChild(text); + + appendSelf(publicKeyElement); + addReturnToSelf(); + + } else { + Object[] exArgs = { Constants._TAG_ECKEYVALUE, key.getClass().getName() }; + + throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs)); + } + } + + /** {@inheritDoc} */ + public PublicKey getPublicKey() throws XMLSecurityException { + try { + ECParameterSpec ecParams = null; + Element curElem = getFirstChildElement(getElement()); + if (curElem == null) { + throw new MarshalException("KeyValue must contain at least one type"); + } + + if ("ECParameters".equals(curElem.getLocalName()) + && Constants.SignatureSpec11NS.equals(curElem.getNamespaceURI())) { + throw new UnsupportedOperationException + ("ECParameters not supported"); + } else if ("NamedCurve".equals(curElem.getLocalName()) + && Constants.SignatureSpec11NS.equals(curElem.getNamespaceURI())) { + String uri = null; + if (curElem.hasAttributeNS(null, "URI")) { + uri = curElem.getAttributeNS(null, "URI"); + } + // strip off "urn:oid" + if (uri.startsWith("urn:oid:")) { + String oid = uri.substring("urn:oid:".length()); + ecParams = getECParameterSpec(oid); + if (ecParams == null) { + throw new MarshalException("Invalid curve OID"); + } + } else { + throw new MarshalException("Invalid NamedCurve URI"); + } + } else { + throw new MarshalException("Invalid ECKeyValue"); + } + curElem = getNextSiblingElement(curElem, "PublicKey", Constants.SignatureSpec11NS); + ECPoint ecPoint = null; + + try { + String content = XMLUtils.getFullTextChildrenFromNode(curElem); + ecPoint = decodePoint(XMLUtils.decode(content), ecParams.getCurve()); + } catch (IOException ioe) { + throw new MarshalException("Invalid EC Point", ioe); + } + + ECPublicKeySpec spec = new ECPublicKeySpec(ecPoint, ecParams); + return KeyFactory.getInstance("EC").generatePublic(spec); + } catch (NoSuchAlgorithmException ex) { + throw new XMLSecurityException(ex); + } catch (InvalidKeySpecException ex) { + throw new XMLSecurityException(ex); + } catch (MarshalException ex) { + throw new XMLSecurityException(ex); + } + } + + /** {@inheritDoc} */ + public String getBaseLocalName() { + return Constants._TAG_ECKEYVALUE; + } + + private static Element getFirstChildElement(Node node) { + Node child = node.getFirstChild(); + while (child != null && child.getNodeType() != Node.ELEMENT_NODE) { + child = child.getNextSibling(); + } + return (Element)child; + } + + private static Element getNextSiblingElement(Node node, String localName, String namespaceURI) + throws MarshalException + { + return verifyElement(getNextSiblingElement(node), localName, namespaceURI); + } + + private static Element getNextSiblingElement(Node node) { + Node sibling = node.getNextSibling(); + while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE) { + sibling = sibling.getNextSibling(); + } + return (Element)sibling; + } + + private static Element verifyElement(Element elem, String localName, String namespaceURI) + throws MarshalException + { + if (elem == null) { + throw new MarshalException("Missing " + localName + " element"); + } + String name = elem.getLocalName(); + String namespace = elem.getNamespaceURI(); + if (!name.equals(localName) || namespace == null && namespaceURI != null + || namespace != null && !namespace.equals(namespaceURI)) { + throw new MarshalException("Invalid element name: " + + namespace + ":" + name + ", expected " + namespaceURI + ":" + localName); + } + return elem; + } + + private static String getCurveOid(ECParameterSpec params) { + // Check that the params represent one of the supported + // curves. If there is a match, return the object identifier + // of the curve. + Curve match; + if (matchCurve(params, SECP256R1)) { + match = SECP256R1; + } else if (matchCurve(params, SECP384R1)) { + match = SECP384R1; + } else if (matchCurve(params, SECP521R1)) { + match = SECP521R1; + } else { + return null; + } + return match.getObjectId(); + } + + private static boolean matchCurve(ECParameterSpec params, Curve curve) { + int fieldSize = params.getCurve().getField().getFieldSize(); + return curve.getCurve().getField().getFieldSize() == fieldSize + && curve.getCurve().equals(params.getCurve()) + && curve.getGenerator().equals(params.getGenerator()) + && curve.getOrder().equals(params.getOrder()) + && curve.getCofactor() == params.getCofactor(); + } + + private static ECPoint decodePoint(byte[] data, EllipticCurve curve) + throws IOException { + if (data.length == 0 || data[0] != 4) { + throw new IOException("Only uncompressed point format " + + "supported"); + } + // Per ANSI X9.62, an encoded point is a 1 byte type followed by + // ceiling(LOG base 2 field-size / 8) bytes of x and the same of y. + int n = (data.length - 1) / 2; + if (n != (curve.getField().getFieldSize() + 7) >> 3) { + throw new IOException("Point does not match field size"); + } + + byte[] xb = Arrays.copyOfRange(data, 1, 1 + n); + byte[] yb = Arrays.copyOfRange(data, n + 1, n + 1 + n); + + return new ECPoint(new BigInteger(1, xb), new BigInteger(1, yb)); + } + + private static byte[] encodePoint(ECPoint point, EllipticCurve curve) { + // get field size in bytes (rounding up) + int n = (curve.getField().getFieldSize() + 7) >> 3; + byte[] xb = trimZeroes(point.getAffineX().toByteArray()); + byte[] yb = trimZeroes(point.getAffineY().toByteArray()); + if (xb.length > n || yb.length > n) { + throw new RuntimeException("Point coordinates do not " + + "match field size"); + } + byte[] b = new byte[1 + (n << 1)]; + b[0] = 4; // uncompressed + System.arraycopy(xb, 0, b, n - xb.length + 1, xb.length); + System.arraycopy(yb, 0, b, b.length - yb.length, yb.length); + return b; + } + + private static byte[] trimZeroes(byte[] b) { + int i = 0; + while (i < b.length - 1 && b[i] == 0) { + i++; + } + if (i == 0) { + return b; + } + return Arrays.copyOfRange(b, i, b.length); + } + + private static ECParameterSpec getECParameterSpec(String oid) { + if (oid.equals(SECP256R1.getObjectId())) { + return SECP256R1; + } else if (oid.equals(SECP384R1.getObjectId())) { + return SECP384R1; + } else if (oid.equals(SECP521R1.getObjectId())) { + return SECP521R1; + } else { + return null; + } + } + + static final class Curve extends ECParameterSpec { + private final String name; + private final String oid; + + Curve(String name, String oid, EllipticCurve curve, + ECPoint g, BigInteger n, int h) { + super(curve, g, n, h); + this.name = name; + this.oid = oid; + } + + private String getName() { + return name; + } + + private String getObjectId() { + return oid; + } + } + + private static BigInteger bigInt(String s) { + return new BigInteger(s, 16); + } +} diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java index 1e4354ee76d..f49d31de3da 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java @@ -24,18 +24,18 @@ import java.security.cert.X509Certificate; import java.util.Arrays; -import java.util.Base64; import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Handles SubjectKeyIdentifier (SKI) for X.509v3. * - * @see <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/security/cert/X509Extension.html"> + * @see <A HREF="http://docs.oracle.com/javase/8/docs/api/java/security/cert/X509Extension.html"> * Interface X509Extension</A> */ public class XMLX509SKI extends SignatureElementProxy implements XMLX509DataContent { @@ -138,7 +138,7 @@ public static byte[] getSKIBytesFromCert(X509Certificate cert) System.arraycopy(extensionValue, 4, skidValue, 0, skidValue.length); if (LOG.isDebugEnabled()) { - LOG.debug("Base64 of SKI is " + Base64.getMimeEncoder().encodeToString(skidValue)); + LOG.debug("Base64 of SKI is " + XMLUtils.encodeToString(skidValue)); } return skidValue; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java index dc4bcd4515f..1b7c97a9303 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java @@ -33,6 +33,7 @@ import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DEREncodedKeyValueResolver; import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DSAKeyValueResolver; +import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.ECKeyValueResolver; import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.KeyInfoReferenceResolver; import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.RSAKeyValueResolver; import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.RetrievalMethodResolver; @@ -295,6 +296,7 @@ public static void registerDefaultResolvers() { keyResolverList.add(new KeyResolver(new DEREncodedKeyValueResolver())); keyResolverList.add(new KeyResolver(new KeyInfoReferenceResolver())); keyResolverList.add(new KeyResolver(new X509DigestResolver())); + keyResolverList.add(new KeyResolver(new ECKeyValueResolver())); resolverVector.addAll(keyResolverList); } diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/ECKeyValueResolver.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/ECKeyValueResolver.java new file mode 100644 index 00000000000..d3c1268e07b --- /dev/null +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/ECKeyValueResolver.java @@ -0,0 +1,97 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations; + +import java.security.PublicKey; +import java.security.cert.X509Certificate; + +import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; +import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.ECKeyValue; +import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi; +import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver; +import com.sun.org.apache.xml.internal.security.utils.Constants; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; +import org.w3c.dom.Element; + +public class ECKeyValueResolver extends KeyResolverSpi { + + private static final com.sun.org.slf4j.internal.Logger LOG = + com.sun.org.slf4j.internal.LoggerFactory.getLogger(ECKeyValueResolver.class); + + + /** + * Method engineResolvePublicKey + * + * @param element + * @param baseURI + * @param storage + * @return null if no {@link PublicKey} could be obtained + */ + public PublicKey engineLookupAndResolvePublicKey( + Element element, String baseURI, StorageResolver storage + ) { + if (element == null) { + return null; + } + Element ecKeyElement = null; + boolean isKeyValue = + XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYVALUE); + if (isKeyValue) { + ecKeyElement = + XMLUtils.selectDs11Node(element.getFirstChild(), Constants._TAG_ECKEYVALUE, 0); + } else if (XMLUtils.elementIsInSignature11Space(element, Constants._TAG_ECKEYVALUE)) { + // this trick is needed to allow the RetrievalMethodResolver to eat a + // ds:ECKeyValue directly (without KeyValue) + ecKeyElement = element; + } + + if (ecKeyElement == null) { + return null; + } + + try { + ECKeyValue ecKeyValue = new ECKeyValue(ecKeyElement, baseURI); + return ecKeyValue.getPublicKey(); + } catch (XMLSecurityException ex) { + LOG.debug(ex.getMessage(), ex); + //do nothing + } + + return null; + } + + + /** {@inheritDoc} */ + public X509Certificate engineLookupResolveX509Certificate( + Element element, String baseURI, StorageResolver storage + ) { + return null; + } + + /** {@inheritDoc} */ + public javax.crypto.SecretKey engineLookupAndResolveSecretKey( + Element element, String baseURI, StorageResolver storage + ) { + return null; + } +} diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java index b0b763ae24d..b29a6c49b1c 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java @@ -44,11 +44,12 @@ public class RSAKeyValueResolver extends KeyResolverSpi { public PublicKey engineLookupAndResolvePublicKey( Element element, String baseURI, StorageResolver storage ) { - LOG.debug("Can I resolve {}", element.getTagName()); if (element == null) { return null; } + LOG.debug("Can I resolve {}", element.getTagName()); + boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYVALUE); Element rsaKeyElement = null; if (isKeyValue) { diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java index beb533456cf..37be2b67792 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java @@ -35,12 +35,12 @@ import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509Certificate; import java.util.ArrayList; -import java.util.Base64; import java.util.Iterator; import java.util.List; import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolverException; import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolverSpi; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; /** * This {@link StorageResolverSpi} makes all raw (binary) {@link X509Certificate}s @@ -207,7 +207,7 @@ public static void main(String unused[]) throws Exception { System.out.println(); System.out.println("Base64(SKI())= \"" - + Base64.getMimeEncoder().encodeToString(ski) + "\""); + + XMLUtils.encodeToString(ski) + "\""); System.out.println("cert.getSerialNumber()= \"" + cert.getSerialNumber().toString() + "\""); System.out.println("cert.getSubjectX500Principal().getName()= \"" diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml index 29f8dfbab58..b95f6f088b0 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml @@ -643,6 +643,8 @@ DESCRIPTION="Uses an X509 SubjectName to retrieve a certificate from the storages" /> <Resolver JAVACLASS="com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509IssuerSerialResolver" DESCRIPTION="Uses an X509 IssuerName and IssuerSerial to retrieve a certificate from the storages" /> + <Resolver JAVACLASS="com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.ECKeyValueResolver" + DESCRIPTION="Can extract EC public keys" /> </KeyResolver> <PrefixMappings> @@ -665,5 +667,7 @@ prefix="ec" /> <PrefixMapping namespace="http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter" prefix="xx" /> + <PrefixMapping namespace="http://www.w3.org/2009/xmldsig11#" + prefix="dsig11" /> </PrefixMappings> </Configuration> diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java index 8afd3c8d308..6c550e26da1 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java @@ -23,7 +23,10 @@ package com.sun.org.apache.xml.internal.security.signature; import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -56,19 +59,24 @@ public class Manifest extends SignatureElementProxy { /** - * The maximum number of references per Manifest, if secure validation is enabled. + * The default maximum number of references per Manifest, if secure validation is enabled. */ public static final int MAXIMUM_REFERENCE_COUNT = 30; private static final com.sun.org.slf4j.internal.Logger LOG = com.sun.org.slf4j.internal.LoggerFactory.getLogger(Manifest.class); + private static Integer referenceCount = + AccessController.doPrivileged( + (PrivilegedAction<Integer>) () -> Integer.parseInt(System.getProperty("com.sun.org.apache.xml.internal.security.maxReferences", + Integer.toString(MAXIMUM_REFERENCE_COUNT)))); + /** Field references */ private List<Reference> references; private Element[] referencesEl; /** Field verificationResults[] */ - private boolean[] verificationResults; + private List<VerifiedReference> verificationResults; /** Field resolverProperties */ private Map<String, String> resolverProperties; @@ -135,8 +143,8 @@ public Manifest( I18n.translate("xml.WrongContent", exArgs)); } - if (secureValidation && le > MAXIMUM_REFERENCE_COUNT) { - Object exArgs[] = { le, MAXIMUM_REFERENCE_COUNT }; + if (secureValidation && le > referenceCount) { + Object exArgs[] = { le, referenceCount }; throw new XMLSecurityException("signature.tooManyReferences", exArgs); } @@ -317,13 +325,13 @@ public boolean verifyReferences(boolean followManifests) if (referencesEl.length == 0) { throw new XMLSecurityException("empty", new Object[]{"References are empty"}); } - if (secureValidation && referencesEl.length > MAXIMUM_REFERENCE_COUNT) { - Object exArgs[] = { referencesEl.length, MAXIMUM_REFERENCE_COUNT }; + if (secureValidation && referencesEl.length > referenceCount) { + Object exArgs[] = { referencesEl.length, referenceCount }; throw new XMLSecurityException("signature.tooManyReferences", exArgs); } - this.verificationResults = new boolean[referencesEl.length]; + this.verificationResults = new ArrayList<>(referencesEl.length); boolean verify = true; for (int i = 0; i < this.referencesEl.length; i++) { Reference currentRef = @@ -335,13 +343,13 @@ public boolean verifyReferences(boolean followManifests) try { boolean currentRefVerified = currentRef.verify(); - this.setVerificationResult(i, currentRefVerified); - if (!currentRefVerified) { verify = false; } LOG.debug("The Reference has Type {}", currentRef.getType()); + List<VerifiedReference> manifestReferences = Collections.emptyList(); + // was verification successful till now and do we want to verify the Manifest? if (verify && followManifests && currentRef.typeIsReferenceToManifest()) { LOG.debug("We have to follow a nested Manifest"); @@ -393,6 +401,8 @@ public boolean verifyReferences(boolean followManifests) } else { LOG.debug("The nested Manifest was valid (good)"); } + + manifestReferences = referencedManifest.getVerificationResults(); } catch (IOException ex) { throw new ReferenceNotInitializedException(ex); } catch (ParserConfigurationException ex) { @@ -401,6 +411,8 @@ public boolean verifyReferences(boolean followManifests) throw new ReferenceNotInitializedException(ex); } } + + verificationResults.add(new VerifiedReference(currentRefVerified, currentRef.getURI(), manifestReferences)); } catch (ReferenceNotInitializedException ex) { Object exArgs[] = { currentRef.getURI() }; @@ -413,20 +425,6 @@ public boolean verifyReferences(boolean followManifests) return verify; } - /** - * Method setVerificationResult - * - * @param index - * @param verify - */ - private void setVerificationResult(int index, boolean verify) { - if (this.verificationResults == null) { - this.verificationResults = new boolean[this.getLength()]; - } - - this.verificationResults[index] = verify; - } - /** * After verifying a {@link Manifest} or a {@link SignedInfo} using the * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods, @@ -455,14 +453,24 @@ public boolean getVerificationResult(int index) throws XMLSecurityException { } } - return this.verificationResults[index]; + return ((ArrayList<VerifiedReference>)verificationResults).get(index).isValid(); + } + + /** + * Get the list of verification result objects + */ + public List<VerifiedReference> getVerificationResults() { + if (verificationResults == null) { + return Collections.emptyList(); + } + return Collections.unmodifiableList(verificationResults); } /** * Adds Resource Resolver for retrieving resources at specified {@code URI} attribute * in {@code reference} element * - * @param resolver {@link ResourceResolver} can provide the implemenatin subclass of + * @param resolver {@link ResourceResolver} can provide the implementation subclass of * {@link ResourceResolverSpi} for retrieving resource. */ public void addResourceResolver(ResourceResolver resolver) { diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java index 6a01958f510..f716e35f185 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java @@ -26,7 +26,6 @@ import java.io.OutputStream; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.Base64; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -396,7 +395,7 @@ private void setDigestValueElement(byte[] digestValue) { n = n.getNextSibling(); } - String base64codedValue = Base64.getMimeEncoder().encodeToString(digestValue); + String base64codedValue = XMLUtils.encodeToString(digestValue); Text t = createText(base64codedValue); digestValueElement.appendChild(t); @@ -723,12 +722,17 @@ private byte[] calculateDigest(boolean validating) return getPreCalculatedDigest(input); } + cacheDereferencedElement(input); + MessageDigestAlgorithm mda = this.getMessageDigestAlgorithm(); mda.reset(); try (DigesterOutputStream diOs = new DigesterOutputStream(mda); OutputStream os = new UnsyncBufferedOutputStream(diOs)) { - XMLSignatureInput output = this.dereferenceURIandPerformTransforms(os); + + XMLSignatureInput output = this.getContentsAfterTransformation(input, os); + this.transformsOutput = output; + // if signing and c14n11 property == true explicitly add // C14N11 transform if needed if (Reference.useC14N11 && !validating && !output.isOutputStreamSet() @@ -772,7 +776,7 @@ private byte[] getPreCalculatedDigest(XMLSignatureInput input) throws ReferenceNotInitializedException { LOG.debug("Verifying element with pre-calculated digest"); String preCalculatedDigest = input.getPreCalculatedDigest(); - return Base64.getMimeDecoder().decode(preCalculatedDigest); + return XMLUtils.decode(preCalculatedDigest); } /** @@ -789,8 +793,8 @@ public byte[] getDigestValue() throws XMLSecurityException { "signature.Verification.NoSignatureElement", exArgs ); } - String content = XMLUtils.getFullTextChildrenFromElement(digestValueElement); - return Base64.getMimeDecoder().decode(content); + String content = XMLUtils.getFullTextChildrenFromNode(digestValueElement); + return XMLUtils.decode(content); } @@ -809,8 +813,8 @@ public boolean verify() if (!equal) { LOG.warn("Verification failed for URI \"" + this.getURI() + "\""); - LOG.warn("Expected Digest: " + Base64.getMimeEncoder().encodeToString(elemDig)); - LOG.warn("Actual Digest: " + Base64.getMimeEncoder().encodeToString(calcDig)); + LOG.warn("Expected Digest: " + XMLUtils.encodeToString(elemDig)); + LOG.warn("Actual Digest: " + XMLUtils.encodeToString(calcDig)); } else { LOG.debug("Verification successful for URI \"{}\"", this.getURI()); } diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/VerifiedReference.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/VerifiedReference.java new file mode 100644 index 00000000000..df9e3014669 --- /dev/null +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/VerifiedReference.java @@ -0,0 +1,64 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.sun.org.apache.xml.internal.security.signature; + +import java.util.Collections; +import java.util.List; + +/** + * Holds the result of a Reference validation. + */ +public class VerifiedReference { + + private final boolean valid; + private final String uri; + private final List<VerifiedReference> manifestReferences; + + /** + * @param valid Whether this Reference was successfully validated or not + * @param uri The URI of this Reference + * @param manifestReferences If this reference is a reference to a Manifest, this holds the list + * of verified referenes associated with this Manifest + */ + public VerifiedReference(boolean valid, String uri, List<VerifiedReference> manifestReferences) { + this.valid = valid; + this.uri = uri; + if (manifestReferences != null) { + this.manifestReferences = manifestReferences; + } else { + this.manifestReferences = Collections.emptyList(); + } + } + + public boolean isValid() { + return valid; + } + + public String getUri() { + return uri; + } + + public List<VerifiedReference> getManifestReferences() { + return Collections.unmodifiableList(manifestReferences); + } +} diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java index 7bf6fb25eae..e4c04b109a4 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java @@ -27,7 +27,6 @@ import java.security.Key; import java.security.PublicKey; import java.security.cert.X509Certificate; -import java.util.Base64; import javax.crypto.SecretKey; @@ -504,8 +503,8 @@ public SignedInfo getSignedInfo() { * @throws XMLSignatureException If there is no content */ public byte[] getSignatureValue() throws XMLSignatureException { - String content = XMLUtils.getFullTextChildrenFromElement(signatureValueElement); - return Base64.getMimeDecoder().decode(content); + String content = XMLUtils.getFullTextChildrenFromNode(signatureValueElement); + return XMLUtils.decode(content); } /** @@ -520,7 +519,7 @@ private void setSignatureValueElement(byte[] bytes) { signatureValueElement.removeChild(signatureValueElement.getFirstChild()); } - String base64codedValue = Base64.getMimeEncoder().encodeToString(bytes); + String base64codedValue = XMLUtils.encodeToString(bytes); if (base64codedValue.length() > 76 && !XMLUtils.ignoreLineBreaks()) { base64codedValue = "\n" + base64codedValue + "\n"; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java index 56aced38791..dc96b64a026 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.io.OutputStream; -import java.util.Base64; import javax.xml.parsers.ParserConfigurationException; @@ -109,12 +108,12 @@ protected XMLSignatureInput enginePerformTransform( StringBuilder sb = new StringBuilder(); traverseElement((Element)el, sb); if (os == null) { - byte[] decodedBytes = Base64.getMimeDecoder().decode(sb.toString()); + byte[] decodedBytes = XMLUtils.decode(sb.toString()); XMLSignatureInput output = new XMLSignatureInput(decodedBytes); output.setSecureValidation(secureValidation); return output; } - byte[] bytes = Base64.getMimeDecoder().decode(sb.toString()); + byte[] bytes = XMLUtils.decode(sb.toString()); os.write(bytes); XMLSignatureInput output = new XMLSignatureInput((byte[])null); output.setSecureValidation(secureValidation); @@ -125,17 +124,17 @@ protected XMLSignatureInput enginePerformTransform( if (input.isOctetStream() || input.isNodeSet()) { if (os == null) { byte[] base64Bytes = input.getBytes(); - byte[] decodedBytes = Base64.getMimeDecoder().decode(base64Bytes); + byte[] decodedBytes = XMLUtils.decode(base64Bytes); XMLSignatureInput output = new XMLSignatureInput(decodedBytes); output.setSecureValidation(secureValidation); return output; } if (input.isByteArray() || input.isNodeSet()) { - byte[] bytes = Base64.getMimeDecoder().decode(input.getBytes()); + byte[] bytes = XMLUtils.decode(input.getBytes()); os.write(bytes); } else { byte[] inputBytes = JavaUtils.getBytesFromStream(input.getOctetStreamReal()); - byte[] bytes = Base64.getMimeDecoder().decode(inputBytes); + byte[] bytes = XMLUtils.decode(inputBytes); os.write(bytes); } XMLSignatureInput output = new XMLSignatureInput((byte[])null); @@ -153,7 +152,7 @@ protected XMLSignatureInput enginePerformTransform( Element rootNode = doc.getDocumentElement(); StringBuilder sb = new StringBuilder(); traverseElement(rootNode, sb); - byte[] decodedBytes = Base64.getMimeDecoder().decode(sb.toString()); + byte[] decodedBytes = XMLUtils.decode(sb.toString()); XMLSignatureInput output = new XMLSignatureInput(decodedBytes); output.setSecureValidation(secureValidation); return output; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java index 6050f17c74c..19ca41da5fb 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java @@ -84,7 +84,10 @@ protected XMLSignatureInput enginePerformTransform( Element xsltElement = XMLUtils.selectNode(transformElement.getFirstChild(), XSLTSpecNS, "stylesheet", 0); - + if (xsltElement == null) { + xsltElement = + XMLUtils.selectNode(transformElement.getFirstChild(), XSLTSpecNS, "transform", 0); + } if (xsltElement == null) { Object exArgs[] = { "xslt:stylesheet", "Transform" }; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java index d386301a8e1..24b1d5a229a 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java @@ -30,6 +30,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.w3c.dom.Text; /** * Implements the parameters for a custom Transform which has a better performance @@ -204,7 +205,7 @@ private String getXStr(String type) { getElement().getFirstChild(), this.getBaseNamespace(), type, 0 ); - return XMLUtils.getFullTextChildrenFromElement(xElem); + return XMLUtils.getFullTextChildrenFromNode(xElem); } /** @@ -258,11 +259,23 @@ private Node getHereContextNode(String type) { return null; } - return XMLUtils.selectNodeText( + return selectNodeText( getFirstChild(), this.getBaseNamespace(), type, 0 ); } + private static Text selectNodeText(Node sibling, String uri, String nodeName, int number) { + Node n = XMLUtils.selectNode(sibling, uri, nodeName, number); + if (n == null) { + return null; + } + n = n.getFirstChild(); + while (n != null && n.getNodeType() != Node.TEXT_NODE) { + n = n.getNextSibling(); + } + return (Text)n; + } + /** * Method getHereContextNodeIncludeButSearch * diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java index 3e185bc7e5d..03a98635650 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java @@ -210,6 +210,9 @@ public final class Constants { /** Tag of Element J **/ public static final String _TAG_J = "J"; + /** Tag of Element ECKeyValue **/ + public static final String _TAG_ECKEYVALUE = "ECKeyValue"; + /** Tag of Element Seed **/ public static final String _TAG_SEED = "Seed"; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java index 2518ddf1620..623af38e1b8 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java @@ -24,7 +24,6 @@ import java.math.BigInteger; import java.util.concurrent.ConcurrentHashMap; -import java.util.Base64; import java.util.Map; import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; @@ -267,7 +266,7 @@ public void addBigIntegerElement(BigInteger bi, String localname) { Element e = XMLUtils.createElementInSignatureSpace(getDocument(), localname); byte[] bytes = XMLUtils.getBytes(bi, bi.bitLength()); - String encodedInt = Base64.getMimeEncoder().encodeToString(bytes); + String encodedInt = XMLUtils.encodeToString(bytes); Document doc = e.getOwnerDocument(); Text text = doc.createTextNode(encodedInt); @@ -292,7 +291,7 @@ protected void addReturnToSelf() { public void addBase64Element(byte[] bytes, String localname) { if (bytes != null) { Element el = XMLUtils.createElementInSignatureSpace(getDocument(), localname); - Text text = getDocument().createTextNode(Base64.getMimeEncoder().encodeToString(bytes)); + Text text = getDocument().createTextNode(XMLUtils.encodeToString(bytes)); el.appendChild(text); @@ -326,8 +325,8 @@ public void addTextElement(String text, String localname) { public void addBase64Text(byte[] bytes) { if (bytes != null) { Text t = XMLUtils.ignoreLineBreaks() - ? createText(Base64.getMimeEncoder().encodeToString(bytes)) - : createText("\n" + Base64.getMimeEncoder().encodeToString(bytes) + "\n"); + ? createText(XMLUtils.encodeToString(bytes)) + : createText("\n" + XMLUtils.encodeToString(bytes) + "\n"); appendSelf(t); } } @@ -367,11 +366,11 @@ public void addText(String text) { public BigInteger getBigIntegerFromChildElement( String localname, String namespace ) { - return new BigInteger(1, Base64.getMimeDecoder().decode( - XMLUtils.selectNodeText( - getFirstChild(), namespace, localname, 0 - ).getNodeValue() - )); + Node n = XMLUtils.selectNode(getFirstChild(), namespace, localname, 0); + if (n != null) { + return new BigInteger(1, XMLUtils.decode(XMLUtils.getFullTextChildrenFromNode(n))); + } + return null; } /** @@ -396,7 +395,7 @@ public String getTextFromChildElement(String localname, String namespace) { * @throws XMLSecurityException */ public byte[] getBytesFromTextChild() throws XMLSecurityException { - return Base64.getMimeDecoder().decode(getTextFromTextChild()); + return XMLUtils.decode(getTextFromTextChild()); } /** @@ -406,7 +405,7 @@ public byte[] getBytesFromTextChild() throws XMLSecurityException { * element */ public String getTextFromTextChild() { - return XMLUtils.getFullTextChildrenFromElement(getElement()); + return XMLUtils.getFullTextChildrenFromNode(getElement()); } /** @@ -498,8 +497,9 @@ private static void setNamespacePrefix(String namespace, String prefix) if (Constants.SignatureSpecNS.equals(namespace)) { XMLUtils.setDsPrefix(prefix); - } - if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) { + } else if (Constants.SignatureSpec11NS.equals(namespace)) { + XMLUtils.setDs11Prefix(prefix); + } else if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) { XMLUtils.setXencPrefix(prefix); } prefixMappings.put(namespace, prefix); @@ -519,6 +519,7 @@ public static void registerDefaultPrefixes() throws XMLSecurityException { setNamespacePrefix( "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter", "xx" ); + setNamespacePrefix("http://www.w3.org/2009/xmldsig11#", "dsig11"); } /** diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java index 31d666e59f8..6a5981f61cb 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java @@ -47,6 +47,13 @@ public Signature11ElementProxy(Document doc) { setDocument(doc); setElement(XMLUtils.createElementInSignature11Space(doc, this.getBaseLocalName())); + + String prefix = ElementProxy.getDefaultPrefix(getBaseNamespace()); + if (prefix == null || prefix.length() == 0) { + getElement().setAttributeNS(Constants.NamespaceSpecNS, "xmlns", getBaseNamespace()); + } else { + getElement().setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix, getBaseNamespace()); + } } /** diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java index 55c0f003701..edcf6520f25 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java @@ -254,16 +254,21 @@ public static void outputDOMc14nWithComments(Node contextNode, OutputStream os) } } + @Deprecated + public static String getFullTextChildrenFromElement(Element element) { + return getFullTextChildrenFromNode(element); + } + /** - * Method getFullTextChildrenFromElement + * Method getFullTextChildrenFromNode * - * @param element + * @param node * @return the string of children */ - public static String getFullTextChildrenFromElement(Element element) { + public static String getFullTextChildrenFromNode(Node node) { StringBuilder sb = new StringBuilder(); - Node child = element.getFirstChild(); + Node child = node.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.TEXT_NODE) { sb.append(((Text)child).getData()); @@ -682,7 +687,7 @@ public static Element selectNode(Node sibling, String uri, String nodeName, int while (sibling != null) { if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri) && sibling.getLocalName().equals(nodeName)) { - if (number == 0){ + if (number == 0) { return (Element)sibling; } number--; diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java index b6f32e85271..cfd605dd39d 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java @@ -97,7 +97,7 @@ private static <N> ResourceResolver internalGetInstance(ResourceResolverContext LOG.debug("check resolvability by class {}", resolverTmp.getClass().getName()); - if (resolverTmp != null && resolverTmp.canResolve(context)) { + if (resolverTmp.canResolve(context)) { // Check to see whether the Resolver is allowed if (context.secureValidation && (resolverTmp.resolverSpi instanceof ResolverLocalFilesystem diff --git a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java index 478ba414789..1018d193df5 100644 --- a/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java +++ b/src/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java @@ -33,9 +33,9 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; -import java.util.Base64; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; +import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverContext; import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException; import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi; @@ -57,7 +57,7 @@ * </PRE> * * @see <A HREF="http://www.javaworld.com/javaworld/javatips/jw-javatip42_p.html">Java Tip 42: Write Java apps that work with proxy-based firewalls</A> - * @see <A HREF="http://docs.oracle.com/javase/1.4.2/docs/guide/net/properties.html">SUN J2SE docs for network properties</A> + * @see <A HREF="https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html">JDK docs for network properties</A> * @see <A HREF="http://metalab.unc.edu/javafaq/javafaq.html#proxy">The JAVA FAQ Question 9.5: How do I make Java work with a proxy server?</A> */ public class ResolverDirectHTTP extends ResourceResolverSpi { @@ -122,7 +122,7 @@ public XMLSignatureInput engineResolveURI(ResourceResolverContext context) urlConnection = openConnection(url); String password = user + ":" + pass; - String encodedPassword = Base64.getMimeEncoder().encodeToString(password.getBytes(StandardCharsets.ISO_8859_1)); + String encodedPassword = XMLUtils.encodeToString(password.getBytes(StandardCharsets.ISO_8859_1)); // set authentication property in the http header urlConnection.setRequestProperty("Authorization", @@ -187,7 +187,7 @@ private URLConnection openConnection(URL url) throws IOException { if (proxyUser != null && proxyPass != null) { String password = proxyUser + ":" + proxyPass; - String authString = "Basic " + Base64.getMimeEncoder().encodeToString(password.getBytes(StandardCharsets.ISO_8859_1)); + String authString = "Basic " + XMLUtils.encodeToString(password.getBytes(StandardCharsets.ISO_8859_1)); urlConnection.setRequestProperty("Proxy-Authorization", authString); } diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java index 7378e93c63a..92025e679b0 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: ApacheCanonicalizer.java 1785016 2017-03-01 18:23:48Z coheigea $ + * $Id: ApacheCanonicalizer.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java index 4b3b5552a3d..5eb303b6dec 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: ApacheOctetStreamData.java 1667527 2015-03-18 12:54:20Z mullan $ + * $Id: ApacheOctetStreamData.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java index 7704dc1e28a..e1e6daa4c6d 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: ApacheTransform.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: ApacheTransform.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java index b64ce4eadbd..865f232abac 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMCanonicalXMLC14NMethod.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMCanonicalXMLC14NMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java index 4be0f51e0c5..a799f4bc284 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java @@ -1,3 +1,7 @@ +/* + * reserved comment block + * DO NOT REMOVE OR ALTER! + */ /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,7 +21,7 @@ * under the License. */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * $Id$ @@ -33,16 +37,16 @@ import org.w3c.dom.Text; /** - * A DOM-based representation of the XML <code>CryptoBinary</code> simple type + * A DOM-based representation of the XML {@code CryptoBinary} simple type * as defined in the W3C specification for XML-Signature Syntax and Processing. * The XML Schema Definition is defined as: * - * <xmp> + * <pre>{@code * <simpleType name="CryptoBinary"> * <restriction base = "base64Binary"> * </restriction> * </simpleType> - * </xmp> + * }</pre> * * @author Sean Mullan */ @@ -52,11 +56,11 @@ public final class DOMCryptoBinary extends DOMStructure { private final String value; /** - * Create a <code>DOMCryptoBinary</code> instance from the specified - * <code>BigInteger</code> + * Create a {@code DOMCryptoBinary} instance from the specified + * {@code BigInteger} * * @param bigNum the arbitrary-length integer - * @throws NullPointerException if <code>bigNum</code> is <code>null</code> + * @throws NullPointerException if {@code bigNum} is {@code null} */ public DOMCryptoBinary(BigInteger bigNum) { if (bigNum == null) { @@ -69,7 +73,7 @@ public DOMCryptoBinary(BigInteger bigNum) { } /** - * Creates a <code>DOMCryptoBinary</code> from a node. + * Creates a {@code DOMCryptoBinary} from a node. * * @param cbNode a CryptoBinary text node * @throws MarshalException if value cannot be decoded (invalid format) @@ -84,9 +88,9 @@ public DOMCryptoBinary(Node cbNode) throws MarshalException { } /** - * Returns the <code>BigInteger</code> that this object contains. + * Returns the {@code BigInteger} that this object contains. * - * @return the <code>BigInteger</code> that this object contains + * @return the {@code BigInteger} that this object contains */ public BigInteger getBigNum() { return bigNum; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java index 2731a5dc519..69d089f64ce 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMDigestMethod.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMDigestMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java index d920d8d1b95..5e4b3146ef1 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMEnvelopedTransform.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMEnvelopedTransform.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java index 708e4c1ca23..5a5bbef7a7f 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMExcC14NMethod.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMExcC14NMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java index 2675bb0381e..7a8fe971e94 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMHMACSignatureMethod.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMHMACSignatureMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java index 68b62f7dd10..507796d3d5b 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMKeyInfo.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMKeyInfo.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java index 287656c6cd8..637bb9c06de 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMKeyInfoFactory.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMKeyInfoFactory.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java index 7c11d9a562b..9ad4e063138 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMKeyName.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMKeyName.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java index 9cbeef636e2..87da6639bac 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java @@ -21,18 +21,13 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMKeyValue.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMKeyValue.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; -import javax.xml.crypto.*; -import javax.xml.crypto.dom.DOMCryptoContext; -import javax.xml.crypto.dsig.*; -import javax.xml.crypto.dsig.keyinfo.KeyValue; - import java.io.IOException; import java.math.BigInteger; import java.security.KeyException; @@ -55,6 +50,11 @@ import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; +import javax.xml.crypto.MarshalException; +import javax.xml.crypto.dom.DOMCryptoContext; +import javax.xml.crypto.dsig.XMLSignature; +import javax.xml.crypto.dsig.keyinfo.KeyValue; + import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -500,7 +500,7 @@ void marshalPublicKey(Node parent, Document doc, String dsPrefix, throw new MarshalException("Invalid ECParameterSpec"); } DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid); - String qname = (prefix == null || prefix.length() == 0) + String qname = prefix == null || prefix.length() == 0 ? "xmlns" : "xmlns:" + prefix; namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/", qname, XMLDSIG_11_XMLNS); @@ -554,7 +554,7 @@ ECPublicKey unmarshalKeyValue(Element kvtElem) ECPoint ecPoint = null; try { - String content = XMLUtils.getFullTextChildrenFromElement(curElem); + String content = XMLUtils.getFullTextChildrenFromNode(curElem); ecPoint = decodePoint(XMLUtils.decode(content), ecParams.getCurve()); } catch (IOException ioe) { diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java index 0800326e4c4..02d6f805e58 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMManifest.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMManifest.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java index 02c28933785..49466c5b46d 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMPGPData.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMPGPData.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; @@ -56,7 +56,7 @@ public final class DOMPGPData extends DOMStructure implements PGPData { * and optional list of external elements. * * @param keyPacket a PGP Key Material Packet as defined in section 5.5 of - * <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>. The + * <a href="https://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>. The * array is cloned to prevent subsequent modification. * @param other a list of {@link XMLStructure}s representing elements from * an external namespace. The list is defensively copied to prevent @@ -94,10 +94,10 @@ public DOMPGPData(byte[] keyPacket, List<? extends XMLStructure> other) { * optional key packet and list of external elements. * * @param keyId a PGP public key id as defined in section 11.2 of - * <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>. The + * <a href="https://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>. The * array is cloned to prevent subsequent modification. * @param keyPacket a PGP Key Material Packet as defined in section 5.5 of - * <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a> (may + * <a href="https://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a> (may * be {@code null}). The array is cloned to prevent subsequent * modification. * @param other a list of {@link XMLStructure}s representing elements from @@ -157,10 +157,10 @@ public DOMPGPData(Element pdElem) throws MarshalException { String localName = childElem.getLocalName(); String namespace = childElem.getNamespaceURI(); if ("PGPKeyID".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { - String content = XMLUtils.getFullTextChildrenFromElement(childElem); + String content = XMLUtils.getFullTextChildrenFromNode(childElem); pgpKeyId = XMLUtils.decode(content); } else if ("PGPKeyPacket".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { - String content = XMLUtils.getFullTextChildrenFromElement(childElem); + String content = XMLUtils.getFullTextChildrenFromNode(childElem); pgpKeyPacket = XMLUtils.decode(content); } else { other.add diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java index 6be6b19c8b4..c44224f2411 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Portions copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * =========================================================================== @@ -31,7 +31,7 @@ * =========================================================================== */ /* - * $Id: DOMReference.java 1803518 2017-07-31 11:02:52Z coheigea $ + * $Id: DOMReference.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; @@ -56,7 +56,6 @@ import org.jcp.xml.dsig.internal.DigesterOutputStream; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream; -import com.sun.org.apache.xml.internal.security.utils.XMLUtils; /** * DOM-based implementation of Reference. @@ -244,7 +243,7 @@ public DOMReference(Element refElem, XMLCryptoContext context, // unmarshal DigestValue Element dvElem = DOMUtils.getNextSiblingElement(dmElem, "DigestValue", XMLSignature.XMLNS); - String content = XMLUtils.getFullTextChildrenFromElement(dvElem); + String content = XMLUtils.getFullTextChildrenFromNode(dvElem); this.digestValue = XMLUtils.decode(content); // check for extra elements @@ -311,6 +310,7 @@ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) refElem = DOMUtils.createElement(ownerDoc, "Reference", XMLSignature.XMLNS, dsPrefix); + // set attributes DOMUtils.setAttributeID(refElem, "Id", id); DOMUtils.setAttribute(refElem, "URI", uri); @@ -341,7 +341,6 @@ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) if (digestValue != null) { digestValueElem.appendChild (ownerDoc.createTextNode(XMLUtils.encodeToString(digestValue))); - } refElem.appendChild(digestValueElem); diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java index 986bc506401..7838f70afc3 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Portions copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * =========================================================================== @@ -31,7 +31,7 @@ * =========================================================================== */ /* - * $Id: DOMRetrievalMethod.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMRetrievalMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java index c7004060a43..5b4fdb9af91 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMSignatureMethod.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMSignatureMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java index cec75bc4014..29e9dae6a4b 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMSignatureProperties.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMSignatureProperties.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java index cd2d92274a2..9e382ea01dd 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMSignatureProperty.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMSignatureProperty.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java index 7ea1b012c66..c60b38d495b 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMSignedInfo.java 1820179 2018-01-04 19:09:52Z mullan $ + * $Id: DOMSignedInfo.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java index c59f4253a83..b7045326876 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMStructure.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMStructure.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java index 6625dc1e45e..e7541ad1b96 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMTransform.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMTransform.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java index 944e15297fc..693c4c6a361 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMURIDereferencer.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMURIDereferencer.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java index 65cde4491cb..bddb12c58d4 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMUtils.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMUtils.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; @@ -92,7 +92,7 @@ public static String getQNameString(String prefix, String localName) { public static Element createElement(Document doc, String tag, String nsURI, String prefix) { - String qName = (prefix == null || prefix.length() == 0) + String qName = prefix == null || prefix.length() == 0 ? tag : prefix + ":" + tag; return doc.createElementNS(nsURI, qName); } diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java index be2badc80f0..95e52941689 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMX509Data.java 1789702 2017-03-31 15:15:04Z coheigea $ + * $Id: DOMX509Data.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; @@ -33,12 +33,13 @@ import java.security.cert.*; import java.util.*; -import javax.xml.crypto.*; +import javax.security.auth.x500.X500Principal; +import javax.xml.crypto.MarshalException; +import javax.xml.crypto.XMLStructure; import javax.xml.crypto.dom.DOMCryptoContext; -import javax.xml.crypto.dsig.*; +import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.keyinfo.X509Data; import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial; -import javax.security.auth.x500.X500Principal; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -115,7 +116,7 @@ public DOMX509Data(Element xdElem) throws MarshalException { } else if ("X509SubjectName".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { newContent.add(childElem.getFirstChild().getNodeValue()); } else if ("X509SKI".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { - String content = XMLUtils.getFullTextChildrenFromElement(childElem); + String content = XMLUtils.getFullTextChildrenFromNode(childElem); newContent.add(XMLUtils.decode(content)); } else if ("X509CRL".equals(localName) && XMLSignature.XMLNS.equals(namespace)) { newContent.add(unmarshalX509CRL(childElem)); @@ -132,6 +133,7 @@ public List<Object> getContent() { return content; } + @Override public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { @@ -241,7 +243,7 @@ private ByteArrayInputStream unmarshalBase64Binary(Element elem) if (cf == null) { cf = CertificateFactory.getInstance("X.509"); } - String content = XMLUtils.getFullTextChildrenFromElement(elem); + String content = XMLUtils.getFullTextChildrenFromNode(elem); return new ByteArrayInputStream(XMLUtils.decode(content)); } catch (CertificateException e) { throw new MarshalException("Cannot create CertificateFactory", e); diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java index 4b67197020e..a7c680a8daf 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMX509IssuerSerial.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMX509IssuerSerial.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java index 19ad23c3353..ddcdc64bd3f 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMXMLObject.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMXMLObject.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java index ec55afc406a..94df43a997f 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Portions copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * =========================================================================== @@ -31,7 +31,7 @@ * =========================================================================== */ /* - * $Id: DOMXMLSignature.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMXMLSignature.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; @@ -508,7 +508,7 @@ public class DOMSignatureValue extends DOMStructure throws MarshalException { // base64 decode signatureValue - String content = XMLUtils.getFullTextChildrenFromElement(sigValueElem); + String content = XMLUtils.getFullTextChildrenFromNode(sigValueElem); value = XMLUtils.decode(content); Attr attr = sigValueElem.getAttributeNodeNS(null, "Id"); @@ -612,6 +612,7 @@ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) throws MarshalException { + // create SignatureValue element sigValueElem = DOMUtils.createElement(ownerDoc, "SignatureValue", XMLSignature.XMLNS, dsPrefix); if (valueBase64 != null) { diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java index c2a128c598d..b2259b6c59a 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMXMLSignatureFactory.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMXMLSignatureFactory.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; @@ -255,8 +255,6 @@ public SignatureMethod newSignatureMethod(String algorithm, return new DOMSignatureMethod.SHA384withRSA(params); } else if (algorithm.equals(DOMSignatureMethod.RSA_SHA512)) { return new DOMSignatureMethod.SHA512withRSA(params); - } else if (algorithm.equals(DOMSignatureMethod.RSA_SHA512)) { - return new DOMSignatureMethod.SHA512withRSA(params); } else if (algorithm.equals(DOMSignatureMethod.RSA_RIPEMD160)) { return new DOMSignatureMethod.RIPEMD160withRSA(params); } else if (algorithm.equals(DOMSignatureMethod.RSA_SHA1_MGF1)) { diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java index 7216fabc97b..e73203db206 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java @@ -28,10 +28,10 @@ * =========================================================================== */ /* - * Portions copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMXPathFilter2Transform.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMXPathFilter2Transform.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java index 4fe111eadfc..fdc502d0e4f 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMXPathTransform.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMXPathTransform.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java index aa95719d86f..873513a1021 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java @@ -21,10 +21,10 @@ * under the License. */ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: DOMXSLTTransform.java 1788465 2017-03-24 15:10:51Z coheigea $ + * $Id: DOMXSLTTransform.java 1854026 2019-02-21 09:30:01Z coheigea $ */ package org.jcp.xml.dsig.internal.dom; diff --git a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java index fd78b694bf5..c17b2f55a62 100644 --- a/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java +++ b/src/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java @@ -28,10 +28,10 @@ * =========================================================================== */ /* - * Portions copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Portions copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. */ /* - * $Id: XMLDSigRI.java 1804972 2017-08-14 09:59:23Z coheigea $ + * $Id: XMLDSigRI.java 1833618 2018-06-15 17:36:20Z mullan $ */ package org.jcp.xml.dsig.internal.dom; @@ -123,7 +123,7 @@ public Object newInstance(Object ctrParamObj) } else if (algo.equals(Transform.XSLT)) { return new DOMXSLTTransform(); } - } + } } catch (Exception ex) { throw new NoSuchAlgorithmException("Error constructing " + type + " for " + algo + " using XMLDSig", ex); diff --git a/src/src/java.xml.crypto/share/legal/santuario.md b/src/src/java.xml.crypto/share/legal/santuario.md index 03dfdd5c492..afd418eed48 100644 --- a/src/src/java.xml.crypto/share/legal/santuario.md +++ b/src/src/java.xml.crypto/share/legal/santuario.md @@ -1,10 +1,10 @@ -## Apache Santuario v2.1.1 +## Apache Santuario v2.1.3 ### Apache Santuario Notice <pre> Apache Santuario - XML Security for Java - Copyright 1999-2018 The Apache Software Foundation + Copyright 1999-2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java index c421b750b91..c23477f3040 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -93,7 +93,7 @@ * @author Morten Jorgensen * @author G. Todd Miller * @author Santiago Pericas-Geertsen - * @LastModified: Nov 2017 + * @LastModified: Feb 2019 */ public final class TransformerImpl extends Transformer implements DOMCache, ErrorListener @@ -925,7 +925,7 @@ public void setOutputProperties(Properties properties) } } else { - _properties = _propertiesClone; + _properties = (Properties)_propertiesClone.clone(); } } diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java index 33823e22e5f..5894424ed6f 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -110,6 +110,7 @@ * @author Joe Kesselman, IBM * @author Andy Clark, IBM * @since PR-DOM-Level-1-19980818. + * @LastModified: Apr 2019 * */ public class AttrImpl @@ -140,8 +141,6 @@ public class AttrImpl // REVISIT: we are losing the type information in DOM during serialization transient Object type; - protected TextImpl textNode = null; - // // Constructors // @@ -192,14 +191,14 @@ protected void makeChildNode() { * NON-DOM * set the ownerDocument of this node and its children */ - void setOwnerDocument(CoreDocumentImpl doc) { + protected void setOwnerDocument(CoreDocumentImpl doc) { if (needsSyncChildren()) { synchronizeChildren(); } super.setOwnerDocument(doc); if (!hasStringValue()) { for (ChildNode child = (ChildNode) value; - child != null; child = child.nextSibling) { + child != null; child = child.nextSibling) { child.setOwnerDocument(doc); } } @@ -349,6 +348,8 @@ public void setValue(String newvalue) { Element ownerElement = getOwnerElement(); String oldvalue = ""; + TextImpl textNode = null; + if (needsSyncData()) { synchronizeData(); } @@ -363,13 +364,7 @@ public void setValue(String newvalue) { oldvalue = (String) value; // create an actual text node as our child so // that we can use it in the event - if (textNode == null) { - textNode = (TextImpl) - ownerDocument.createTextNode((String) value); - } - else { - textNode.data = (String) value; - } + textNode = (TextImpl) ownerDocument.createTextNode((String) value); value = textNode; textNode.isFirstChild(true); textNode.previousSibling = textNode; @@ -414,9 +409,16 @@ public void setValue(String newvalue) { // since we need to combine the remove and insert. isSpecified(true); if (ownerDocument.getMutationEvents()) { - // if there are any event handlers create a real node - internalInsertBefore(ownerDocument.createTextNode(newvalue), - null, true); + // if there are any event handlers create a real node or + // reuse the one we synthesized for the remove notifications + // if it exists. + if (textNode == null) { + textNode = (TextImpl) ownerDocument.createTextNode(newvalue); + } + else { + textNode.data = newvalue; + } + internalInsertBefore(textNode, null, true); hasStringValue(false); // notify document ownerDocument.modifiedAttrValue(this, oldvalue); @@ -1034,7 +1036,7 @@ public int getLength() { * NodeList method: Return the Nth immediate child of this node, or * null if the index is out of bounds. * @return org.w3c.dom.Node - * @param Index int + * @param index int */ public Node item(int index) { @@ -1076,12 +1078,12 @@ public boolean isEqualNode(Node arg) { * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom * - * @param ancestorNS + * @param typeNamespaceArg * The namspace of the ancestor type declaration - * @param ancestorName + * @param typeNameArg * The name of the ancestor type declaration - * @param type - * The reference type definition + * @param derivationMethod + * The derivation method * * @return boolean True if the type is derived by restriciton for the * reference type diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java index 0eba0744c27..09a5355072b 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java @@ -147,30 +147,6 @@ void rename(String namespaceURI, String qualifiedName) { setName(namespaceURI, qualifiedName); } - /** - * NON-DOM: resets this node and sets specified values for the node - * - * @param ownerDocument - * @param namespaceURI - * @param qualifiedName - * @param localName - */ - public void setValues (CoreDocumentImpl ownerDocument, - String namespaceURI, - String qualifiedName, - String localName){ - - super.textNode = null; - super.flags = 0; - isSpecified(true); - hasStringValue(true); - super.setOwnerDocument(ownerDocument); - this.localName = localName; - this.namespaceURI = namespaceURI; - super.name = qualifiedName; - super.value = null; - } - // // DOM2: Namespace methods // @@ -314,14 +290,14 @@ public String getTypeName() { * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom * - * @param ancestorNS + * @param typeNamespaceArg * The namspace of the ancestor type declaration - * @param ancestorName + * @param typeNameArg * The name of the ancestor type declaration - * @param type - * The reference type definition + * @param derivationMethod + * The derivation method * - * @return boolean True if the type is derived by restriciton for the + * @return boolean True if the type is derived by restriction for the * reference type */ public boolean isDerivedFrom(String typeNamespaceArg, diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ChildNode.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ChildNode.java index c8c2f3e2f83..cb2f609d562 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ChildNode.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ChildNode.java @@ -40,8 +40,6 @@ public abstract class ChildNode /** Serialization version. */ static final long serialVersionUID = -6112455738802414002L; - transient StringBuffer fBufferStr = null; - // // Data // diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java index b3c6a360fd8..130b169a8de 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -20,11 +20,18 @@ package com.sun.org.apache.xerces.internal.dom; import com.sun.org.apache.xerces.internal.impl.RevalidationHandler; +import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDProcessor; +import com.sun.org.apache.xerces.internal.impl.dtd.XML11DTDValidator; +import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDLoader; +import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator; +import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator; import com.sun.org.apache.xerces.internal.parsers.DOMParserImpl; import com.sun.org.apache.xerces.internal.parsers.DTDConfiguration; import com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration; +import com.sun.org.apache.xerces.internal.parsers.XML11DTDConfiguration; import com.sun.org.apache.xerces.internal.util.XMLChar; import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription; +import java.lang.ref.SoftReference; import org.w3c.dom.DOMException; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; @@ -51,21 +58,39 @@ * @xerces.internal * * @since PR-DOM-Level-1-19980818. + * @LastModified: Apr 2019 */ +@SuppressWarnings({"rawtypes", "unchecked"}) //SoftReference array public class CoreDOMImplementationImpl implements DOMImplementation, DOMImplementationLS { - // - // Data - // - // validators pool + // + // Data + // + + // validator pools private static final int SIZE = 2; - private RevalidationHandler validators[] = new RevalidationHandler[SIZE]; - private RevalidationHandler dtdValidators[] = new RevalidationHandler[SIZE]; - private int freeValidatorIndex = -1; - private int freeDTDValidatorIndex = -1; - private int currentSize = SIZE; + private SoftReference schemaValidators[] = new SoftReference[SIZE]; + private SoftReference xml10DTDValidators[] = new SoftReference[SIZE]; + private SoftReference xml11DTDValidators[] = new SoftReference[SIZE]; + + private int freeSchemaValidatorIndex = -1; + private int freeXML10DTDValidatorIndex = -1; + private int freeXML11DTDValidatorIndex = -1; + + private int schemaValidatorsCurrentSize = SIZE; + private int xml10DTDValidatorsCurrentSize = SIZE; + private int xml11DTDValidatorsCurrentSize = SIZE; + + private SoftReference xml10DTDLoaders[] = new SoftReference[SIZE]; + private SoftReference xml11DTDLoaders[] = new SoftReference[SIZE]; + + private int freeXML10DTDLoaderIndex = -1; + private int freeXML11DTDLoaderIndex = -1; + + private int xml10DTDLoaderCurrentSize = SIZE; + private int xml11DTDLoaderCurrentSize = SIZE; // Document and doctype counter. Used to assign order to documents and // doctypes without owners, on an demand basis. Used for @@ -74,8 +99,8 @@ public class CoreDOMImplementationImpl // static /** Dom implementation singleton. */ - static CoreDOMImplementationImpl singleton = - new CoreDOMImplementationImpl(); + static final CoreDOMImplementationImpl singleton = new CoreDOMImplementationImpl(); + // // Public methods // @@ -109,21 +134,25 @@ public boolean hasFeature(String feature, String version) { feature = feature.substring(1); } return (feature.equalsIgnoreCase("Core") - && (anyVersion - || version.equals("1.0") - || version.equals("2.0") - || version.equals("3.0"))) - || (feature.equalsIgnoreCase("XML") - && (anyVersion - || version.equals("1.0") - || version.equals("2.0") - || version.equals("3.0"))) - || (feature.equalsIgnoreCase("LS") - && (anyVersion - || version.equals("3.0"))) - || (feature.equalsIgnoreCase("ElementTraversal") - && (anyVersion - || version.equals("1.0"))); + && (anyVersion + || version.equals("1.0") + || version.equals("2.0") + || version.equals("3.0"))) + || (feature.equalsIgnoreCase("XML") + && (anyVersion + || version.equals("1.0") + || version.equals("2.0") + || version.equals("3.0"))) + || (feature.equalsIgnoreCase("XMLVersion") + && (anyVersion + || version.equals("1.0") + || version.equals("1.1"))) + || (feature.equalsIgnoreCase("LS") + && (anyVersion + || version.equals("3.0"))) + || (feature.equalsIgnoreCase("ElementTraversal") + && (anyVersion + || version.equals("1.0"))); } // hasFeature(String,String):boolean @@ -244,19 +273,26 @@ public Document createDocument( null); throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg); } - CoreDocumentImpl doc = new CoreDocumentImpl(doctype); - Element e = doc.createElementNS(namespaceURI, qualifiedName); - doc.appendChild(e); + CoreDocumentImpl doc = createDocument(doctype); + // If namespaceURI and qualifiedName are null return a Document with no document element. + if (qualifiedName != null || namespaceURI != null) { + Element e = doc.createElementNS(namespaceURI, qualifiedName); + doc.appendChild(e); + } return doc; } + protected CoreDocumentImpl createDocument(DocumentType doctype) { + return new CoreDocumentImpl(doctype); + } + /** * DOM Level 3 WD - Experimental. */ public Object getFeature(String feature, String version) { if (singleton.hasFeature(feature, version)) { - return singleton; - } + return singleton; + } return null; } @@ -304,7 +340,7 @@ public Object getFeature(String feature, String version) { * NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is * not supported. */ - public LSParser createLSParser(short mode, String schemaType) + public LSParser createLSParser(short mode, String schemaType) throws DOMException { if (mode != DOMImplementationLS.MODE_SYNCHRONOUS || (schemaType !=null && !"http://www.w3.org/2001/XMLSchema".equals(schemaType) && @@ -318,7 +354,7 @@ public LSParser createLSParser(short mode, String schemaType) } if (schemaType != null && schemaType.equals("http://www.w3.org/TR/REC-xml")) { - return new DOMParserImpl(new DTDConfiguration(), + return new DOMParserImpl(new XML11DTDConfiguration(), schemaType); } else { @@ -328,20 +364,20 @@ public LSParser createLSParser(short mode, String schemaType) } } - /** - * DOM Level 3 LS CR - Experimental. - * Create a new <code>LSSerializer</code> object. - * @return The newly created <code>LSSerializer</code> object. - * <p ><b>Note:</b> By default, the newly created - * <code>LSSerializer</code> has no <code>DOMErrorHandler</code>, - * i.e. the value of the <code>"error-handler"</code> configuration - * parameter is <code>null</code>. However, implementations may - * provide a default error handler at creation time. In that case, the - * initial value of the <code>"error-handler"</code> configuration - * parameter on the new created <code>LSSerializer</code> contains a - * reference to the default error handler. - */ - public LSSerializer createLSSerializer() { + /** + * DOM Level 3 LS CR - Experimental. + * Create a new <code>LSSerializer</code> object. + * @return The newly created <code>LSSerializer</code> object. + * <p ><b>Note:</b> By default, the newly created + * <code>LSSerializer</code> has no <code>DOMErrorHandler</code>, + * i.e. the value of the <code>"error-handler"</code> configuration + * parameter is <code>null</code>. However, implementations may + * provide a default error handler at creation time. In that case, the + * initial value of the <code>"error-handler"</code> configuration + * parameter on the new created <code>LSSerializer</code> contains a + * reference to the default error handler. + */ + public LSSerializer createLSSerializer() { return new com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl(); } @@ -358,68 +394,217 @@ public LSInput createLSInput() { // Protected methods // /** NON-DOM: retrieve validator. */ - synchronized RevalidationHandler getValidator(String schemaType) { - // REVISIT: implement retrieving DTD validator + synchronized RevalidationHandler getValidator(String schemaType, String xmlVersion) { if (schemaType == XMLGrammarDescription.XML_SCHEMA) { // create new validator - we should not attempt // to restrict the number of validation handlers being // requested - if(freeValidatorIndex < 0) { - return new com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator(); + while (freeSchemaValidatorIndex >= 0) { + // return first available validator + SoftReference ref = schemaValidators[freeSchemaValidatorIndex]; + RevalidationHandlerHolder holder = (RevalidationHandlerHolder) ref.get(); + if (holder != null && holder.handler != null) { + RevalidationHandler val = holder.handler; + holder.handler = null; + --freeSchemaValidatorIndex; + return val; + } + schemaValidators[freeSchemaValidatorIndex--] = null; } - // return first available validator - RevalidationHandler val = validators[freeValidatorIndex]; - validators[freeValidatorIndex--] = null; - return val; + return new XMLSchemaValidator(); } else if(schemaType == XMLGrammarDescription.XML_DTD) { - if(freeDTDValidatorIndex < 0) { - return new com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator(); + // return an instance of XML11DTDValidator + if ("1.1".equals(xmlVersion)) { + while (freeXML11DTDValidatorIndex >= 0) { + // return first available validator + SoftReference ref = xml11DTDValidators[freeXML11DTDValidatorIndex]; + RevalidationHandlerHolder holder = (RevalidationHandlerHolder) ref.get(); + if (holder != null && holder.handler != null) { + RevalidationHandler val = holder.handler; + holder.handler = null; + --freeXML11DTDValidatorIndex; + return val; + } + xml11DTDValidators[freeXML11DTDValidatorIndex--] = null; + } + return new XML11DTDValidator(); + } + // return an instance of XMLDTDValidator + else { + while (freeXML10DTDValidatorIndex >= 0) { + // return first available validator + SoftReference ref = xml10DTDValidators[freeXML10DTDValidatorIndex]; + RevalidationHandlerHolder holder = (RevalidationHandlerHolder) ref.get(); + if (holder != null && holder.handler != null) { + RevalidationHandler val = holder.handler; + holder.handler = null; + --freeXML10DTDValidatorIndex; + return val; + } + xml10DTDValidators[freeXML10DTDValidatorIndex--] = null; + } + return new XMLDTDValidator(); } - // return first available validator - RevalidationHandler val = dtdValidators[freeDTDValidatorIndex]; - dtdValidators[freeDTDValidatorIndex--] = null; - return val; } return null; } /** NON-DOM: release validator */ - synchronized void releaseValidator(String schemaType, - RevalidationHandler validator) { - // REVISIT: implement support for DTD validators as well - if(schemaType == XMLGrammarDescription.XML_SCHEMA) { - ++freeValidatorIndex; - if (validators.length == freeValidatorIndex ){ - // resize size of the validators - currentSize+=SIZE; - RevalidationHandler newarray[] = new RevalidationHandler[currentSize]; - System.arraycopy(validators, 0, newarray, 0, validators.length); - validators = newarray; - } - validators[freeValidatorIndex]=validator; - } - else if(schemaType == XMLGrammarDescription.XML_DTD) { - ++freeDTDValidatorIndex; - if (dtdValidators.length == freeDTDValidatorIndex ){ - // resize size of the validators - currentSize+=SIZE; - RevalidationHandler newarray[] = new RevalidationHandler[currentSize]; - System.arraycopy(dtdValidators, 0, newarray, 0, dtdValidators.length); - dtdValidators = newarray; - } - dtdValidators[freeDTDValidatorIndex]=validator; - } + synchronized void releaseValidator(String schemaType, String xmlVersion, + RevalidationHandler validator) { + if (schemaType == XMLGrammarDescription.XML_SCHEMA) { + ++freeSchemaValidatorIndex; + if (schemaValidators.length == freeSchemaValidatorIndex) { + // resize size of the validators + schemaValidatorsCurrentSize += SIZE; + SoftReference newarray[] = new SoftReference[schemaValidatorsCurrentSize]; + System.arraycopy(schemaValidators, 0, newarray, 0, schemaValidators.length); + schemaValidators = newarray; + } + SoftReference ref = schemaValidators[freeSchemaValidatorIndex]; + if (ref != null) { + RevalidationHandlerHolder holder = (RevalidationHandlerHolder) ref.get(); + if (holder != null) { + holder.handler = validator; + return; + } + } + schemaValidators[freeSchemaValidatorIndex] = new SoftReference(new RevalidationHandlerHolder(validator)); + } + else if (schemaType == XMLGrammarDescription.XML_DTD) { + // release an instance of XML11DTDValidator + if ("1.1".equals(xmlVersion)) { + ++freeXML11DTDValidatorIndex; + if (xml11DTDValidators.length == freeXML11DTDValidatorIndex) { + // resize size of the validators + xml11DTDValidatorsCurrentSize += SIZE; + SoftReference [] newarray = new SoftReference[xml11DTDValidatorsCurrentSize]; + System.arraycopy(xml11DTDValidators, 0, newarray, 0, xml11DTDValidators.length); + xml11DTDValidators = newarray; + } + SoftReference ref = xml11DTDValidators[freeXML11DTDValidatorIndex]; + if (ref != null) { + RevalidationHandlerHolder holder = (RevalidationHandlerHolder) ref.get(); + if (holder != null) { + holder.handler = validator; + return; + } + } + xml11DTDValidators[freeXML11DTDValidatorIndex] = new SoftReference(new RevalidationHandlerHolder(validator)); + } + // release an instance of XMLDTDValidator + else { + ++freeXML10DTDValidatorIndex; + if (xml10DTDValidators.length == freeXML10DTDValidatorIndex) { + // resize size of the validators + xml10DTDValidatorsCurrentSize += SIZE; + SoftReference [] newarray = new SoftReference[xml10DTDValidatorsCurrentSize]; + System.arraycopy(xml10DTDValidators, 0, newarray, 0, xml10DTDValidators.length); + xml10DTDValidators = newarray; + } + SoftReference ref = xml10DTDValidators[freeXML10DTDValidatorIndex]; + if (ref != null) { + RevalidationHandlerHolder holder = (RevalidationHandlerHolder) ref.get(); + if (holder != null) { + holder.handler = validator; + return; + } + } + xml10DTDValidators[freeXML10DTDValidatorIndex] = new SoftReference(new RevalidationHandlerHolder(validator)); + } + } } - /** NON-DOM: increment document/doctype counter */ - protected synchronized int assignDocumentNumber() { - return ++docAndDoctypeCounter; - } - /** NON-DOM: increment document/doctype counter */ - protected synchronized int assignDocTypeNumber() { - return ++docAndDoctypeCounter; - } + /** NON-DOM: retrieve DTD loader */ + synchronized final XMLDTDLoader getDTDLoader(String xmlVersion) { + // return an instance of XML11DTDProcessor + if ("1.1".equals(xmlVersion)) { + while (freeXML11DTDLoaderIndex >= 0) { + // return first available DTD loader + SoftReference ref = xml11DTDLoaders[freeXML11DTDLoaderIndex]; + XMLDTDLoaderHolder holder = (XMLDTDLoaderHolder) ref.get(); + if (holder != null && holder.loader != null) { + XMLDTDLoader val = holder.loader; + holder.loader = null; + --freeXML11DTDLoaderIndex; + return val; + } + xml11DTDLoaders[freeXML11DTDLoaderIndex--] = null; + } + return new XML11DTDProcessor(); + } + // return an instance of XMLDTDLoader + else { + while (freeXML10DTDLoaderIndex >= 0) { + // return first available DTD loader + SoftReference ref = xml10DTDLoaders[freeXML10DTDLoaderIndex]; + XMLDTDLoaderHolder holder = (XMLDTDLoaderHolder) ref.get(); + if (holder != null && holder.loader != null) { + XMLDTDLoader val = holder.loader; + holder.loader = null; + --freeXML10DTDLoaderIndex; + return val; + } + xml10DTDLoaders[freeXML10DTDLoaderIndex--] = null; + } + return new XMLDTDLoader(); + } + } + + /** NON-DOM: release DTD loader */ + synchronized final void releaseDTDLoader(String xmlVersion, XMLDTDLoader loader) { + // release an instance of XMLDTDLoader + if ("1.1".equals(xmlVersion)) { + ++freeXML11DTDLoaderIndex; + if (xml11DTDLoaders.length == freeXML11DTDLoaderIndex) { + // resize size of the DTD loaders + xml11DTDLoaderCurrentSize += SIZE; + SoftReference [] newarray = new SoftReference[xml11DTDLoaderCurrentSize]; + System.arraycopy(xml11DTDLoaders, 0, newarray, 0, xml11DTDLoaders.length); + xml11DTDLoaders = newarray; + } + SoftReference ref = xml11DTDLoaders[freeXML11DTDLoaderIndex]; + if (ref != null) { + XMLDTDLoaderHolder holder = (XMLDTDLoaderHolder) ref.get(); + if (holder != null) { + holder.loader = loader; + return; + } + } + xml11DTDLoaders[freeXML11DTDLoaderIndex] = new SoftReference(new XMLDTDLoaderHolder(loader)); + } + // release an instance of XMLDTDLoader + else { + ++freeXML10DTDLoaderIndex; + if (xml10DTDLoaders.length == freeXML10DTDLoaderIndex) { + // resize size of the DTD loaders + xml10DTDLoaderCurrentSize += SIZE; + SoftReference [] newarray = new SoftReference[xml10DTDLoaderCurrentSize]; + System.arraycopy(xml10DTDLoaders, 0, newarray, 0, xml10DTDLoaders.length); + xml10DTDLoaders = newarray; + } + SoftReference ref = xml10DTDLoaders[freeXML10DTDLoaderIndex]; + if (ref != null) { + XMLDTDLoaderHolder holder = (XMLDTDLoaderHolder) ref.get(); + if (holder != null) { + holder.loader = loader; + return; + } + } + xml10DTDLoaders[freeXML10DTDLoaderIndex] = new SoftReference(new XMLDTDLoaderHolder(loader)); + } + } + + /** NON-DOM: increment document/doctype counter */ + protected synchronized int assignDocumentNumber() { + return ++docAndDoctypeCounter; + } + + /** NON-DOM: increment document/doctype counter */ + protected synchronized int assignDocTypeNumber() { + return ++docAndDoctypeCounter; + } /* DOM Level 3 LS CR - Experimental. * @@ -427,11 +612,33 @@ protected synchronized int assignDocTypeNumber() { * <code>LSOutput.characterStream</code>, * <code>LSOutput.byteStream</code>, <code>LSOutput.systemId</code>, * <code>LSOutput.encoding</code> are null. - * @return The newly created output object. + */ + public LSOutput createLSOutput() { + return new DOMOutputImpl(); + } + + /** + * A holder for RevalidationHandlers. This allows us to reuse + * SoftReferences which haven't yet been cleared by the garbage + * collector. */ - public LSOutput createLSOutput() { - return new DOMOutputImpl(); - } + static final class RevalidationHandlerHolder { + RevalidationHandlerHolder(RevalidationHandler handler) { + this.handler = handler; + } + RevalidationHandler handler; + } + + /** + * A holder for XMLDTDLoaders. This allows us to reuse SoftReferences + * which haven't yet been cleared by the garbage collector. + */ + static final class XMLDTDLoaderHolder { + XMLDTDLoaderHolder(XMLDTDLoader loader) { + this.loader = loader; + } + XMLDTDLoader loader; + } } // class DOMImplementationImpl diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java index 2b981207a98..94a83e5e2bd 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -83,7 +83,7 @@ * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM * @since PR-DOM-Level-1-19980818. - * @LastModified: Nov 2017 + * @LastModified: Nov 2018 */ public class CoreDocumentImpl extends ParentNode implements Document { @@ -1797,6 +1797,11 @@ public Node adoptNode(Node source) { return null; } } + // Adopting from a deferred DOM into another deferred DOM + else if (otherImpl instanceof DeferredDOMImplementationImpl) { + // traverse the DOM and expand deferred nodes and then allow adoption + undeferChildren (node); + } } switch (node.getNodeType()) { diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java index f012ccca0c2..ab3dc578d5a 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings; import com.sun.org.apache.xerces.internal.util.PropertyState; import com.sun.org.apache.xerces.internal.util.SymbolTable; -import com.sun.org.apache.xerces.internal.utils.ObjectFactory; import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler; @@ -52,6 +51,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.StringTokenizer; import javax.xml.XMLConstants; import javax.xml.catalog.CatalogFeatures; import jdk.xml.internal.JdkXmlUtils; @@ -70,7 +70,7 @@ * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems. - * @LastModified: Oct 2017 + * @LastModified: Apr 2019 */ public class DOMConfigurationImpl extends ParserConfigurationSettings implements XMLParserConfiguration, DOMConfiguration { @@ -79,6 +79,9 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings // Constants // + protected static final String XML11_DATATYPE_VALIDATOR_FACTORY = + "com.sun.org.apache.xerces.internal.impl.dv.dtd.XML11DTDDVFactoryImpl"; + // feature identifiers /** Feature identifier: validation. */ @@ -101,12 +104,41 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings protected static final String NORMALIZE_DATA = Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE; + /** Feature identifier: send element default value via characters() */ + protected static final String SCHEMA_ELEMENT_DEFAULT = + Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT; + /** sending psvi in the pipeline */ protected static final String SEND_PSVI = Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI; - protected final static String DTD_VALIDATOR_FACTORY_PROPERTY = - Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY; + /** Feature: generate synthetic annotations */ + protected static final String GENERATE_SYNTHETIC_ANNOTATIONS = + Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE; + + /** Feature identifier: validate annotations */ + protected static final String VALIDATE_ANNOTATIONS = + Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATE_ANNOTATIONS_FEATURE; + + /** Feature identifier: honour all schemaLocations */ + protected static final String HONOUR_ALL_SCHEMALOCATIONS = + Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE; + + /** Feature identifier: use grammar pool only */ + protected static final String USE_GRAMMAR_POOL_ONLY = + Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; + + /** Feature identifier: load external DTD. */ + protected static final String DISALLOW_DOCTYPE_DECL_FEATURE = + Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE; + + /** Feature identifier: balance syntax trees. */ + protected static final String BALANCE_SYNTAX_TREES = + Constants.XERCES_FEATURE_PREFIX + Constants.BALANCE_SYNTAX_TREES; + + /** Feature identifier: warn on duplicate attribute definition. */ + protected static final String WARN_ON_DUPLICATE_ATTDEF = + Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE; /** Feature identifier: namespace growth */ protected static final String NAMESPACE_GROWTH = @@ -133,9 +165,9 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings protected static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY; - /** Property id: Grammar pool*/ + /** Property id: Grammar pool. */ protected static final String GRAMMAR_POOL = - Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY; + Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY; /** Property identifier: error handler. */ protected static final String ERROR_HANDLER = @@ -147,15 +179,31 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings /** Property identifier: JAXP schema language / DOM schema-type. */ protected static final String JAXP_SCHEMA_LANGUAGE = - Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE; + Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE; /** Property identifier: JAXP schema source/ DOM schema-location. */ protected static final String JAXP_SCHEMA_SOURCE = - Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE; + Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE; + + /** Property identifier: DTD validator. */ + protected final static String DTD_VALIDATOR_PROPERTY = + Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY; + + /** Property identifier: datatype validator factory. */ + protected static final String DTD_VALIDATOR_FACTORY_PROPERTY = + Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY; protected static final String VALIDATION_MANAGER = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY; + /** Property identifier: schema location. */ + protected static final String SCHEMA_LOCATION = + Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_LOCATION; + + /** Property identifier: no namespace schema location. */ + protected static final String SCHEMA_NONS_LOCATION = + Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION; + /** Property identifier: Schema DV Factory */ protected static final String SCHEMA_DV_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY; @@ -209,8 +257,18 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings protected final DOMErrorHandlerWrapper fErrorHandlerWrapper = new DOMErrorHandlerWrapper(); + /** Current Datatype validator factory. */ + protected DTDDVFactory fCurrentDVFactory; + + /** The XML 1.0 Datatype validator factory. */ + protected DTDDVFactory fDatatypeValidatorFactory; + + /** The XML 1.1 Datatype validator factory. **/ + protected DTDDVFactory fXML11DatatypeFactory; + // private data + private String fSchemaLocation = null; private DOMStringList fRecognizedParameters; @@ -256,7 +314,16 @@ protected DOMConfigurationImpl(SymbolTable symbolTable, SCHEMA_FULL_CHECKING, DYNAMIC_VALIDATION, NORMALIZE_DATA, + SCHEMA_ELEMENT_DEFAULT, SEND_PSVI, + GENERATE_SYNTHETIC_ANNOTATIONS, + VALIDATE_ANNOTATIONS, + HONOUR_ALL_SCHEMALOCATIONS, + USE_GRAMMAR_POOL_ONLY, + DISALLOW_DOCTYPE_DECL_FEATURE, + BALANCE_SYNTAX_TREES, + WARN_ON_DUPLICATE_ATTDEF, + PARSER_SETTINGS, NAMESPACE_GROWTH, TOLERATE_DUPLICATES, XMLConstants.USE_CATALOG, @@ -270,9 +337,19 @@ protected DOMConfigurationImpl(SymbolTable symbolTable, setFeature(SCHEMA_FULL_CHECKING, false); setFeature(DYNAMIC_VALIDATION, false); setFeature(NORMALIZE_DATA, false); + setFeature(SCHEMA_ELEMENT_DEFAULT, false); setFeature(XERCES_NAMESPACES, true); setFeature(SEND_PSVI, true); + setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false); + setFeature(VALIDATE_ANNOTATIONS, false); + setFeature(HONOUR_ALL_SCHEMALOCATIONS, false); + setFeature(USE_GRAMMAR_POOL_ONLY, false); + setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, false); + setFeature(BALANCE_SYNTAX_TREES, false); + setFeature(WARN_ON_DUPLICATE_ATTDEF, false); + setFeature(PARSER_SETTINGS, true); setFeature(NAMESPACE_GROWTH, false); + setFeature(TOLERATE_DUPLICATES, false); setFeature(XMLConstants.USE_CATALOG, JdkXmlUtils.USE_CATALOG_DEFAULT); setFeature(JdkXmlUtils.OVERRIDE_PARSER, JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); @@ -288,6 +365,9 @@ protected DOMConfigurationImpl(SymbolTable symbolTable, GRAMMAR_POOL, JAXP_SCHEMA_SOURCE, JAXP_SCHEMA_LANGUAGE, + SCHEMA_LOCATION, + SCHEMA_NONS_LOCATION, + DTD_VALIDATOR_PROPERTY, DTD_VALIDATOR_FACTORY_PROPERTY, SCHEMA_DV_FACTORY, SECURITY_MANAGER, @@ -321,7 +401,10 @@ protected DOMConfigurationImpl(SymbolTable symbolTable, setProperty(ERROR_REPORTER, fErrorReporter); addComponent(fErrorReporter); - setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, DTDDVFactory.getInstance()); + fDatatypeValidatorFactory = DTDDVFactory.getInstance(); + fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY); + fCurrentDVFactory = fDatatypeValidatorFactory; + setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory); XMLEntityManager manager = new XMLEntityManager(); setProperty(ENTITY_MANAGER, manager); @@ -348,8 +431,7 @@ protected DOMConfigurationImpl(SymbolTable symbolTable, if (fErrorReporter.getMessageFormatter("http://www.w3.org/TR/xml-schema-1") == null) { MessageFormatter xmft = null; try { - xmft = (MessageFormatter)( - ObjectFactory.newInstance("com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter", true)); + xmft = new com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter(); } catch (Exception exception){ } @@ -396,8 +478,8 @@ protected DOMConfigurationImpl(SymbolTable symbolTable, * has ended. If a client application wants to terminate * parsing early, it should throw an exception. * - * @param source The input source for the top-level of the - * XML document. + * @param inputSource The input source for the top-level of the + * XML document. * * @exception XNIException Any XNI exception, possibly wrapping * another exception. @@ -462,9 +544,7 @@ public XMLDTDContentModelHandler getDTDContentModelHandler() { * uninstall the currently installed resolver. */ public void setEntityResolver(XMLEntityResolver resolver) { - if (resolver !=null) { - fProperties.put(ENTITY_RESOLVER, resolver); - } + fProperties.put(ENTITY_RESOLVER, resolver); } // setEntityResolver(XMLEntityResolver) /** @@ -513,6 +593,26 @@ public XMLErrorHandler getErrorHandler() { return (XMLErrorHandler)fProperties.get(ERROR_HANDLER); } // getErrorHandler():XMLErrorHandler + /** + * Returns the state of a feature. + * + * @param featureId The feature identifier. + * @return true if the feature is supported + * + * @throws XMLConfigurationException Thrown for configuration error. + * In general, components should + * only throw this exception if + * it is <strong>really</strong> + * a critical error. + */ + public boolean getFeature(String featureId) + throws XMLConfigurationException { + if (featureId.equals(PARSER_SETTINGS)) { + return true; + } + return super.getFeature(featureId); + } + /** * Set the state of a feature. * @@ -576,8 +676,8 @@ public void setParameter(String name, Object value) throws DOMException { // REVISIT: Recognizes DOM L3 default features only. // Does not yet recognize Xerces features. - if(value instanceof Boolean){ - boolean state = ((Boolean)value).booleanValue(); + if(value instanceof Boolean){ + boolean state = ((Boolean)value).booleanValue(); if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) { features = (short) (state ? features | COMMENTS : features & ~COMMENTS); @@ -625,22 +725,12 @@ else if (name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS) || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION) ) { if (state) { // true is not supported - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "FEATURE_NOT_SUPPORTED", - new Object[] { name }); - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + throw newFeatureNotSupportedError(name); } } else if ( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) { if (!state) { // false is not supported - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "FEATURE_NOT_SUPPORTED", - new Object[] { name }); - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + throw newFeatureNotSupportedError(name); } } else if (name.equalsIgnoreCase(SEND_PSVI) ){ @@ -648,12 +738,7 @@ else if (name.equalsIgnoreCase(SEND_PSVI) ){ // because in this case we won't be able to retrieve element // default value. if (!state) { // false is not supported - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "FEATURE_NOT_SUPPORTED", - new Object[] { name }); - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + throw newFeatureNotSupportedError(name); } } else if (name.equalsIgnoreCase(Constants.DOM_PSVI)){ @@ -673,23 +758,16 @@ else if (name.equalsIgnoreCase(Constants.DOM_PSVI)){ } - if (!found || !(value instanceof Boolean)) { // set properties - found = true; + if (!found || !(value instanceof Boolean)) { // set properties + found = true; if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) { if (value instanceof DOMErrorHandler || value == null) { fErrorHandlerWrapper.setErrorHandler((DOMErrorHandler)value); setErrorHandler(fErrorHandlerWrapper); } - else { - // REVISIT: type mismatch - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "TYPE_MISMATCH_ERR", - new Object[] { name }); - throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + throw newTypeMismatchError(name); } } else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) { @@ -700,36 +778,45 @@ else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) { catch (XMLConfigurationException e) {} } else { - // REVISIT: type mismatch - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "TYPE_MISMATCH_ERR", - new Object[] { name }); - throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + throw newTypeMismatchError(name); } - } else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) { if (value instanceof String || value == null) { try { - // map DOM schema-location to JAXP schemaSource property - setProperty( - Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE, - value); + if (value == null) { + fSchemaLocation = null; + setProperty ( + Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE, + null); + } + else { + fSchemaLocation = (String) value; + // map DOM schema-location to JAXP schemaSource property + // tokenize location string + StringTokenizer t = new StringTokenizer(fSchemaLocation, " \n\t\r"); + if (t.hasMoreTokens()) { + List<String> locations = new ArrayList<>(); + locations.add(t.nextToken()); + while (t.hasMoreTokens()) { + locations.add (t.nextToken()); + } + setProperty ( + Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE, + locations.toArray(new String[locations.size()])); + } + else { + setProperty ( + Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE, + new String [] {(String) value}); + } + } } catch (XMLConfigurationException e) {} } else { - // REVISIT: type mismatch - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "TYPE_MISMATCH_ERR", - new Object[] { name }); - throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + throw newTypeMismatchError(name); } - } else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) { if (value instanceof String || value == null) { @@ -754,57 +841,43 @@ else if (value.equals(Constants.NS_DTD)) { catch (XMLConfigurationException e) {} } else { - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "TYPE_MISMATCH_ERR", - new Object[] { name }); - throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + throw newTypeMismatchError(name); } - } - else if (name.equalsIgnoreCase(SYMBOL_TABLE)){ + else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) { + if (value instanceof XMLEntityResolver || value == null) { + try { + setEntityResolver((XMLEntityResolver) value); + } + catch (XMLConfigurationException e) {} + } + else { + throw newTypeMismatchError(name); + } + } + else if (name.equalsIgnoreCase(SYMBOL_TABLE)) { // Xerces Symbol Table if (value instanceof SymbolTable){ setProperty(SYMBOL_TABLE, value); } else { - // REVISIT: type mismatch - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "TYPE_MISMATCH_ERR", - new Object[] { name }); - throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + throw newTypeMismatchError(name); } } - else if (name.equalsIgnoreCase (GRAMMAR_POOL)){ - if (value instanceof XMLGrammarPool){ + else if (name.equalsIgnoreCase (GRAMMAR_POOL)) { + if (value instanceof XMLGrammarPool || value == null) { setProperty(GRAMMAR_POOL, value); } else { - // REVISIT: type mismatch - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "TYPE_MISMATCH_ERR", - new Object[] { name }); - throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + throw newTypeMismatchError(name); } - } - else { + else { // REVISIT: check if this is a boolean parameter -- type mismatch should be thrown. //parameter is not recognized - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "FEATURE_NOT_FOUND", - new Object[] { name }); - throw new DOMException(DOMException.NOT_FOUND_ERR, msg); + throw newFeatureNotFoundError(name); } } - } @@ -878,23 +951,23 @@ else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) { return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE); } else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) { - return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE); + return fSchemaLocation; } - else if (name.equalsIgnoreCase(SYMBOL_TABLE)){ + else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) { + return getEntityResolver(); + } + else if (name.equalsIgnoreCase(SYMBOL_TABLE)) { return getProperty(SYMBOL_TABLE); } - else if (name.equalsIgnoreCase(GRAMMAR_POOL)){ + else if (name.equalsIgnoreCase(GRAMMAR_POOL)) { return getProperty(GRAMMAR_POOL); + } + else if (name.equalsIgnoreCase(SECURITY_MANAGER)) { + return getProperty(SECURITY_MANAGER); } else { - String msg = - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "FEATURE_NOT_FOUND", - new Object[] { name }); - throw new DOMException(DOMException.NOT_FOUND_ERR, msg); + throw newFeatureNotFoundError(name); } - } /** @@ -966,15 +1039,19 @@ else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) { } else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) { // REVISIT: should null value be supported? - //as of now we are only supporting W3C XML Schema - return ( (value instanceof String) && value.equals(Constants.NS_XMLSCHEMA) ) ? true : false ; + // as of now we are only supporting W3C XML Schema and DTD. + return ((value instanceof String) && + (value.equals(Constants.NS_XMLSCHEMA) || value.equals(Constants.NS_DTD))) ? true : false; + } + else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) { + return (value instanceof XMLEntityResolver) ? true : false; } - else if (name.equalsIgnoreCase(SYMBOL_TABLE)){ + else if (name.equalsIgnoreCase(SYMBOL_TABLE)) { // Xerces Symbol Table - return (value instanceof SymbolTable) ? true : false ; + return (value instanceof SymbolTable) ? true : false; } - else if (name.equalsIgnoreCase (GRAMMAR_POOL)){ - return (value instanceof XMLGrammarPool) ? true : false ; + else if (name.equalsIgnoreCase (GRAMMAR_POOL)) { + return (value instanceof XMLGrammarPool) ? true : false; } else { //false if the parameter is not recognized or the requested value is not supported. @@ -991,46 +1068,49 @@ else if (name.equalsIgnoreCase (GRAMMAR_POOL)){ * can be set by the application. Note that this list can also contain * parameter names defined outside this specification. */ - public DOMStringList getParameterNames() { - if (fRecognizedParameters == null){ + public DOMStringList getParameterNames() { + if (fRecognizedParameters == null){ List<String> parameters = new ArrayList<>(); - //Add DOM recognized parameters - //REVISIT: Would have been nice to have a list of - //recognized paramters. - parameters.add(Constants.DOM_COMMENTS); - parameters.add(Constants.DOM_DATATYPE_NORMALIZATION); - parameters.add(Constants.DOM_CDATA_SECTIONS); - parameters.add(Constants.DOM_ENTITIES); - parameters.add(Constants.DOM_SPLIT_CDATA); - parameters.add(Constants.DOM_NAMESPACES); - parameters.add(Constants.DOM_VALIDATE); - - parameters.add(Constants.DOM_INFOSET); - parameters.add(Constants.DOM_NORMALIZE_CHARACTERS); - parameters.add(Constants.DOM_CANONICAL_FORM); - parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA); - parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION); - parameters.add(Constants.DOM_WELLFORMED); - - parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS); - parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE); - - parameters.add(Constants.DOM_ERROR_HANDLER); - parameters.add(Constants.DOM_SCHEMA_TYPE); - parameters.add(Constants.DOM_SCHEMA_LOCATION); - parameters.add(Constants.DOM_RESOURCE_RESOLVER); - - //Add recognized xerces features and properties - parameters.add(GRAMMAR_POOL); - parameters.add(SYMBOL_TABLE); - parameters.add(SEND_PSVI); - - fRecognizedParameters = new DOMStringListImpl(parameters); - } + //Add DOM recognized parameters + //REVISIT: Would have been nice to have a list of + //recognized paramters. + parameters.add(Constants.DOM_COMMENTS); + parameters.add(Constants.DOM_DATATYPE_NORMALIZATION); + parameters.add(Constants.DOM_CDATA_SECTIONS); + parameters.add(Constants.DOM_ENTITIES); + parameters.add(Constants.DOM_SPLIT_CDATA); + parameters.add(Constants.DOM_NAMESPACES); + parameters.add(Constants.DOM_VALIDATE); + + parameters.add(Constants.DOM_INFOSET); + parameters.add(Constants.DOM_NORMALIZE_CHARACTERS); + parameters.add(Constants.DOM_CANONICAL_FORM); + parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA); + parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION); + parameters.add(Constants.DOM_WELLFORMED); + + parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS); + parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE); + + parameters.add(Constants.DOM_ERROR_HANDLER); + parameters.add(Constants.DOM_SCHEMA_TYPE); + parameters.add(Constants.DOM_SCHEMA_LOCATION); + parameters.add(Constants.DOM_RESOURCE_RESOLVER); + + //Add recognized xerces features and properties + parameters.add(ENTITY_RESOLVER); + parameters.add(GRAMMAR_POOL); + parameters.add(SECURITY_MANAGER); + parameters.add(SYMBOL_TABLE); + parameters.add(SEND_PSVI); + + fRecognizedParameters = new DOMStringListImpl(parameters); - return fRecognizedParameters; - }//getParameterNames + } + + return fRecognizedParameters; + }//getParameterNames // // Protected methods @@ -1061,6 +1141,7 @@ protected void reset() throws XNIException { * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the * requested feature is not known or supported. */ + @Override protected PropertyState checkProperty(String propertyId) throws XMLConfigurationException { @@ -1115,4 +1196,44 @@ protected ValidationManager createValidationManager(){ return new ValidationManager(); } -} // class XMLParser + protected final void setDTDValidatorFactory(String version) { + if ("1.1".equals(version)) { + if (fCurrentDVFactory != fXML11DatatypeFactory) { + fCurrentDVFactory = fXML11DatatypeFactory; + setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory); + } + } + else if (fCurrentDVFactory != fDatatypeValidatorFactory) { + fCurrentDVFactory = fDatatypeValidatorFactory; + setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory); + } + } + + private static DOMException newFeatureNotSupportedError(String name) { + String msg = + DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "FEATURE_NOT_SUPPORTED", + new Object[] { name }); + return new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); + } + + private static DOMException newFeatureNotFoundError(String name) { + String msg = + DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "FEATURE_NOT_FOUND", + new Object[] { name }); + return new DOMException(DOMException.NOT_FOUND_ERR, msg); + } + + private static DOMException newTypeMismatchError(String name) { + String msg = + DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "TYPE_MISMATCH_ERR", + new Object[] { name }); + return new DOMException(DOMException.TYPE_MISMATCH_ERR, msg); + } + +} // class DOMConfigurationImpl diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java index 3dacb16ee48..4903448394b 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,21 +22,17 @@ -import com.sun.org.apache.xerces.internal.dom.AbortException; import com.sun.org.apache.xerces.internal.impl.Constants; import com.sun.org.apache.xerces.internal.impl.RevalidationHandler; -import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar; -import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDDescription; +import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDLoader; import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator; import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; import com.sun.org.apache.xerces.internal.impl.xs.util.SimpleLocator; -import com.sun.org.apache.xerces.internal.parsers.XMLGrammarPreparser; import com.sun.org.apache.xerces.internal.util.AugmentationsImpl; import com.sun.org.apache.xerces.internal.util.NamespaceSupport; import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.util.XML11Char; import com.sun.org.apache.xerces.internal.util.XMLChar; -import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl; import com.sun.org.apache.xerces.internal.util.XMLSymbols; import com.sun.org.apache.xerces.internal.xni.Augmentations; import com.sun.org.apache.xerces.internal.xni.NamespaceContext; @@ -48,15 +44,12 @@ import com.sun.org.apache.xerces.internal.xni.XMLString; import com.sun.org.apache.xerces.internal.xni.XNIException; import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription; -import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent; import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; -import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; import com.sun.org.apache.xerces.internal.xs.AttributePSVI; import com.sun.org.apache.xerces.internal.xs.ElementPSVI; import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; import java.io.IOException; -import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.Vector; @@ -96,7 +89,7 @@ * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @LastModified: Nov 2017 + * @LastModified: Apr 2019 */ public class DOMNormalizer implements XMLDocumentHandler { @@ -155,7 +148,7 @@ public class DOMNormalizer implements XMLDocumentHandler { /** for setting the PSVI */ protected Node fCurrentNode = null; - private QName fAttrQName = new QName(); + private final QName fAttrQName = new QName(); // attribute value normalization final XMLString fNormalizedValue = new XMLString(new char[16], 0, 0); @@ -163,8 +156,11 @@ public class DOMNormalizer implements XMLDocumentHandler { //DTD validator private XMLDTDValidator fDTDValidator; - //Check if element content is all "ignorable whitespace" - private boolean allWhitespace = false; + /** Empty string to pass to the validator. **/ + public static final XMLString EMPTY_STRING = new XMLString(); + + // Check if element content is all "ignorable whitespace" + private boolean fAllWhitespace = false; // Constructor // @@ -177,24 +173,30 @@ public DOMNormalizer(){} * Normalizes document. * Note: reset() must be called before this method. */ - protected void normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl config) { + protected void normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl config) { + + fDocument = document; + fConfiguration = config; + fAllWhitespace = false; + fNamespaceValidation = false; - fDocument = document; - fConfiguration = config; + String xmlVersion = fDocument.getXmlVersion(); + String schemaType = null; + String [] schemaLocations = null; - // intialize and reset DOMNormalizer component - // - fSymbolTable = (SymbolTable) fConfiguration.getProperty(DOMConfigurationImpl.SYMBOL_TABLE); - // reset namespace context - fNamespaceContext.reset(); - fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING); + // intialize and reset DOMNormalizer component + // + fSymbolTable = (SymbolTable) fConfiguration.getProperty(DOMConfigurationImpl.SYMBOL_TABLE); + // reset namespace context + fNamespaceContext.reset(); + fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, null); - if ((fConfiguration.features & DOMConfigurationImpl.VALIDATE) != 0) { + if ((fConfiguration.features & DOMConfigurationImpl.VALIDATE) != 0) { String schemaLang = (String)fConfiguration.getProperty(DOMConfigurationImpl.JAXP_SCHEMA_LANGUAGE); - if(schemaLang != null && schemaLang.equals(Constants.NS_XMLSCHEMA)) { - fValidationHandler = - CoreDOMImplementationImpl.singleton.getValidator(XMLGrammarDescription.XML_SCHEMA); + if (schemaLang != null && schemaLang.equals(Constants.NS_XMLSCHEMA)) { + schemaType = XMLGrammarDescription.XML_SCHEMA; + fValidationHandler = CoreDOMImplementationImpl.singleton.getValidator(schemaType, xmlVersion); fConfiguration.setFeature(DOMConfigurationImpl.SCHEMA, true); fConfiguration.setFeature(DOMConfigurationImpl.SCHEMA_FULL_CHECKING, true); // report fatal error on DOM Level 1 nodes @@ -203,49 +205,74 @@ protected void normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl // check if we need to fill in PSVI fPSVI = ((fConfiguration.features & DOMConfigurationImpl.PSVI) !=0)?true:false; } + else { + schemaType = XMLGrammarDescription.XML_DTD; + if (schemaLang != null) { + schemaLocations = (String []) fConfiguration.getProperty(DOMConfigurationImpl.JAXP_SCHEMA_SOURCE); + } + fConfiguration.setDTDValidatorFactory(xmlVersion); + fValidationHandler = CoreDOMImplementationImpl.singleton.getValidator(schemaType, xmlVersion); + fPSVI = false; + } - fConfiguration.setFeature(DOMConfigurationImpl.XERCES_VALIDATION, true); + fConfiguration.setFeature(DOMConfigurationImpl.XERCES_VALIDATION, true); // reset ID table fDocument.clearIdentifiers(); - if(fValidationHandler != null) - // reset schema validator + if (fValidationHandler != null) { + // reset the validation handler ((XMLComponent) fValidationHandler).reset(fConfiguration); + } + } + else { + fValidationHandler = null; + } - } - - fErrorHandler = (DOMErrorHandler) fConfiguration.getParameter(Constants.DOM_ERROR_HANDLER); - if (fValidationHandler != null) { - fValidationHandler.setDocumentHandler(this); - fValidationHandler.startDocument( + fErrorHandler = (DOMErrorHandler) fConfiguration.getParameter(Constants.DOM_ERROR_HANDLER); + if (fValidationHandler != null) { + fValidationHandler.setDocumentHandler(this); + fValidationHandler.startDocument( new SimpleLocator(fDocument.fDocumentURI, fDocument.fDocumentURI, - -1, -1 ), fDocument.encoding, fNamespaceContext, null); - - } - try { - Node kid, next; - for (kid = fDocument.getFirstChild(); kid != null; kid = next) { - next = kid.getNextSibling(); - kid = normalizeNode(kid); - if (kid != null) { // don't advance - next = kid; - } - } + -1, -1 ), fDocument.encoding, fNamespaceContext, null); + fValidationHandler.xmlDecl(fDocument.getXmlVersion(), + fDocument.getXmlEncoding(), fDocument.getXmlStandalone() ? "yes" : "no", null); + } + try { + if (schemaType == XMLGrammarDescription.XML_DTD) { + processDTD(xmlVersion, schemaLocations != null ? schemaLocations[0] : null); + } - // release resources - if (fValidationHandler != null) { - fValidationHandler.endDocument(null); - CoreDOMImplementationImpl.singleton.releaseValidator( - XMLGrammarDescription.XML_SCHEMA, fValidationHandler); - fValidationHandler = null; - } - } catch (AbortException e) { - return; + Node kid, next; + for (kid = fDocument.getFirstChild(); kid != null; kid = next) { + next = kid.getNextSibling(); + kid = normalizeNode(kid); + if (kid != null) { // don't advance + next = kid; } + } + // release resources + if (fValidationHandler != null) { + fValidationHandler.endDocument(null); + fValidationHandler.setDocumentHandler(null); + CoreDOMImplementationImpl.singleton.releaseValidator(schemaType, xmlVersion, fValidationHandler); + fValidationHandler = null; + } } - + catch (RuntimeException e) { + // release resources + if (fValidationHandler != null) { + fValidationHandler.setDocumentHandler(null); + CoreDOMImplementationImpl.singleton.releaseValidator(schemaType, xmlVersion, fValidationHandler); + fValidationHandler = null; + } + if (e instanceof AbortException) { + return; // processing aborted by the user + } + throw e; // otherwise re-throw. + } + } /** * @@ -273,16 +300,7 @@ protected Node normalizeNode (Node node){ if (DEBUG_ND) { System.out.println("==>normalizeNode:{doctype}"); } - DocumentTypeImpl docType = (DocumentTypeImpl)node; - fDTDValidator = (XMLDTDValidator)CoreDOMImplementationImpl.singleton.getValidator(XMLGrammarDescription.XML_DTD); - fDTDValidator.setDocumentHandler(this); - fConfiguration.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY, createGrammarPool(docType)); - fDTDValidator.reset(fConfiguration); - fDTDValidator.startDocument( - new SimpleLocator(fDocument.fDocumentURI, fDocument.fDocumentURI, - -1, -1 ), fDocument.encoding, fNamespaceContext, null); - fDTDValidator.doctypeDecl(docType.getName(), docType.getPublicId(), docType.getSystemId(), null); - //REVISIT: well-formness encoding info + // REVISIT: well-formedness encoding info break; } @@ -297,7 +315,7 @@ protected Node normalizeNode (Node node){ if ( ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) && fDocument.isXMLVersionChanged()){ if (fNamespaceValidation){ - wellformed = CoreDocumentImpl.isValidQName(node.getPrefix() , node.getLocalName(), fDocument.isXML11Version()) ; + wellformed = CoreDocumentImpl.isValidQName(node.getPrefix() , node.getLocalName(), fDocument.isXML11Version()); } else { wellformed = CoreDocumentImpl.isXMLName(node.getNodeName() , fDocument.isXML11Version()); @@ -329,13 +347,21 @@ protected Node normalizeNode (Node node){ // remove default attributes namespaceFixUp(elem, attributes); - if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0 && attributes != null ) { - for (int i = 0; i < attributes.getLength(); ++i) { - Attr att = (Attr)attributes.getItem(i); - if (XMLSymbols.PREFIX_XMLNS.equals(att.getPrefix()) || - XMLSymbols.PREFIX_XMLNS.equals(att.getName())) { - elem.removeAttributeNode(att); - --i; + if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0) { + // Namespace declarations may have been added by namespace fix-up. Need + // to fetch the AttributeMap again if it contained no attributes prior + // to namespace fix-up. + if (attributes == null) { + attributes = (elem.hasAttributes()) ? (AttributeMap) elem.getAttributes() : null; + } + if (attributes != null) { + for (int i = 0; i < attributes.getLength(); ++i) { + Attr att = (Attr)attributes.getItem(i); + if (XMLSymbols.PREFIX_XMLNS.equals(att.getPrefix()) || + XMLSymbols.PREFIX_XMLNS.equals(att.getName())) { + elem.removeAttributeNode(att); + --i; + } } } } @@ -347,16 +373,21 @@ protected Node normalizeNode (Node node){ //removeDefault(attr, attributes); attr.normalize(); if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0)){ - isAttrValueWF(fErrorHandler, fError, fLocator, attributes, (AttrImpl)attr, attr.getValue(), fDocument.isXML11Version()); - if (fDocument.isXMLVersionChanged()){ - wellformed=CoreDocumentImpl.isXMLName(node.getNodeName() , fDocument.isXML11Version()); - if (!wellformed){ - String msg = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "wf-invalid-character-in-node-name", - new Object[]{"Attr",node.getNodeName()}); - reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR, - "wf-invalid-character-in-node-name"); + isAttrValueWF(fErrorHandler, fError, fLocator, attributes, attr, attr.getValue(), fDocument.isXML11Version()); + if (fDocument.isXMLVersionChanged()) { + if (fNamespaceValidation){ + wellformed = CoreDocumentImpl.isValidQName(node.getPrefix(), node.getLocalName(), fDocument.isXML11Version()); + } + else { + wellformed = CoreDocumentImpl.isXMLName(node.getNodeName(), fDocument.isXML11Version()); + } + if (!wellformed) { + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "wf-invalid-character-in-node-name", + new Object[]{"Attr",node.getNodeName()}); + reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR, + "wf-invalid-character-in-node-name"); } } } @@ -379,26 +410,12 @@ protected Node normalizeNode (Node node){ fValidationHandler.startElement(fQName, fAttrProxy, null); } - if (fDTDValidator != null) { - // REVISIT: possible solutions to discard default content are: - // either we pass some flag to XML Schema validator - // or rely on the PSVI information. - fAttrProxy.setAttributes(attributes, fDocument, elem); - updateQName(elem, fQName); // updates global qname - // set error node in the dom error wrapper - // so if error occurs we can report an error node - fConfiguration.fErrorHandlerWrapper.fCurrentNode = node; - fCurrentNode = node; - // call re-validation handler - fDTDValidator.startElement(fQName, fAttrProxy, null); - } - // normalize children Node kid, next; for (kid = elem.getFirstChild(); kid != null; kid = next) { next = kid.getNextSibling(); kid = normalizeNode(kid); - if (kid !=null) { + if (kid != null) { next = kid; // don't advance } } @@ -412,7 +429,6 @@ protected Node normalizeNode (Node node){ } - if (fValidationHandler != null) { updateQName(elem, fQName); // updates global qname // @@ -423,16 +439,6 @@ protected Node normalizeNode (Node node){ fValidationHandler.endElement(fQName, null); } - if (fDTDValidator != null) { - updateQName(elem, fQName); // updates global qname - // - // set error node in the dom error wrapper - // so if error occurs we can report an error node - fConfiguration.fErrorHandlerWrapper.fCurrentNode = node; - fCurrentNode = node; - fDTDValidator.endElement(fQName, null); - } - // pop namespace context fNamespaceContext.popContext(); @@ -465,6 +471,13 @@ protected Node normalizeNode (Node node){ // of the document isCommentWF(fErrorHandler, fError, fLocator, commentdata, fDocument.isXML11Version()); } + if (fValidationHandler != null) { + // Don't bother filling an XMLString with the text of the comment. + // We only send the comment event to the validator handler so that + // when the schema-type is DTD an error will be reported for a + // comment appearing in EMPTY content. + fValidationHandler.comment(EMPTY_STRING, null); + } }//end-else if comment node is not to be removed. break; } @@ -531,16 +544,6 @@ protected Node normalizeNode (Node node){ fValidationHandler.characterData(node.getNodeValue(), null); fValidationHandler.endCDATA(null); } - - if (fDTDValidator != null) { - // set error node in the dom error wrapper - // so if error occurs we can report an error node - fConfiguration.fErrorHandlerWrapper.fCurrentNode = node; - fCurrentNode = node; - fDTDValidator.startCDATA(null); - fDTDValidator.characterData(node.getNodeValue(), null); - fDTDValidator.endCDATA(null); - } String value = node.getNodeValue(); if ((fConfiguration.features & DOMConfigurationImpl.SPLITCDATA) != 0) { @@ -605,42 +608,37 @@ else if (fDocument.errorChecking) { short nextType = (next != null)?next.getNodeType():-1; if (nextType == -1 || !(((fConfiguration.features & DOMConfigurationImpl.ENTITIES) == 0 && - nextType == Node.ENTITY_NODE) || - ((fConfiguration.features & DOMConfigurationImpl.COMMENTS) == 0 && - nextType == Node.COMMENT_NODE) || - ((fConfiguration.features & DOMConfigurationImpl.CDATA) == 0) && - nextType == Node.CDATA_SECTION_NODE)) { - if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) ){ - isXMLCharWF(fErrorHandler, fError, fLocator, node.getNodeValue(), fDocument.isXML11Version()); - } - if (fValidationHandler != null) { - fConfiguration.fErrorHandlerWrapper.fCurrentNode = node; - fCurrentNode = node; - fValidationHandler.characterData(node.getNodeValue(), null); - if (DEBUG_ND) { - System.out.println("=====>characterData(),"+nextType); - - } - } - if (fDTDValidator != null) { - fConfiguration.fErrorHandlerWrapper.fCurrentNode = node; - fCurrentNode = node; - fDTDValidator.characterData(node.getNodeValue(), null); - if (DEBUG_ND) { - System.out.println("=====>characterData(),"+nextType); - - } - if(allWhitespace) { - allWhitespace = false; - ((TextImpl)node).setIgnorableWhitespace(true); - } - } + nextType == Node.ENTITY_NODE) || + ((fConfiguration.features & DOMConfigurationImpl.COMMENTS) == 0 && + nextType == Node.COMMENT_NODE) || + ((fConfiguration.features & DOMConfigurationImpl.CDATA) == 0) && + nextType == Node.CDATA_SECTION_NODE)) { + if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) ){ + isXMLCharWF(fErrorHandler, fError, fLocator, node.getNodeValue(), fDocument.isXML11Version()); + } + if (fValidationHandler != null) { + fConfiguration.fErrorHandlerWrapper.fCurrentNode = node; + fCurrentNode = node; + fValidationHandler.characterData(node.getNodeValue(), null); + if (!fNamespaceValidation) { + if (fAllWhitespace) { + fAllWhitespace = false; + ((TextImpl)node).setIgnorableWhitespace(true); + } + else { + ((TextImpl)node).setIgnorableWhitespace(false); + } + } + if (DEBUG_ND) { + System.out.println("=====>characterData(),"+nextType); + } + } } else { - if (DEBUG_ND) { - System.out.println("=====>don't send characters(),"+nextType); + if (DEBUG_ND) { + System.out.println("=====>don't send characters(),"+nextType); - } + } } } break; @@ -674,42 +672,66 @@ else if (fDocument.errorChecking) { //which may not be valid XML character isXMLCharWF(fErrorHandler, fError, fLocator, pinode.getData(), fDocument.isXML11Version()); } + + if (fValidationHandler != null) { + // Don't bother filling an XMLString with the data section of the + // processing instruction. We only send the processing instruction + // event to the validator handler so that when the schema-type is + // DTD an error will be reported for a processing instruction + // appearing in EMPTY content. + fValidationHandler.processingInstruction(((ProcessingInstruction) node).getTarget(), EMPTY_STRING, null); + } }//end case Node.PROCESSING_INSTRUCTION_NODE }//end of switch return null; }//normalizeNode - private XMLGrammarPool createGrammarPool(DocumentTypeImpl docType) { - - XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl(); + private void processDTD(String xmlVersion, String schemaLocation) { - XMLGrammarPreparser preParser = new XMLGrammarPreparser(fSymbolTable); - preParser.registerPreparser(XMLGrammarDescription.XML_DTD, null); - preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); - preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, true); - preParser.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY, pool); + String rootName = null; + String publicId = null; + String systemId = schemaLocation; + String baseSystemId = fDocument.getDocumentURI(); + String internalSubset = null; - String internalSubset = docType.getInternalSubset(); - XMLInputSource is = new XMLInputSource(docType.getPublicId(), docType.getSystemId(), null, false); + DocumentType docType = fDocument.getDoctype(); + if (docType != null) { + rootName = docType.getName(); + publicId = docType.getPublicId(); + if (systemId == null || systemId.length() == 0) { + systemId = docType.getSystemId(); + } + internalSubset = docType.getInternalSubset(); + } + // If the DOM doesn't have a DocumentType node we may still + // be able to fetch a DTD if the application provided a URI + else { + Element elem = fDocument.getDocumentElement(); + if (elem == null) return; + rootName = elem.getNodeName(); + if (systemId == null || systemId.length() == 0) return; + } - if(internalSubset != null) - is.setCharacterStream(new StringReader(internalSubset)); + XMLDTDLoader loader = null; try { - DTDGrammar g = (DTDGrammar)preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is); - ((XMLDTDDescription)g.getGrammarDescription()).setRootName(docType.getName()); - is.setCharacterStream(null); - g = (DTDGrammar)preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is); - ((XMLDTDDescription)g.getGrammarDescription()).setRootName(docType.getName()); - - } catch (XNIException e) { - } catch (IOException e) { + fValidationHandler.doctypeDecl(rootName, publicId, systemId, null); + loader = CoreDOMImplementationImpl.singleton.getDTDLoader(xmlVersion); + loader.setFeature(DOMConfigurationImpl.XERCES_VALIDATION, true); + loader.setEntityResolver(fConfiguration.getEntityResolver()); + loader.setErrorHandler(fConfiguration.getErrorHandler()); + loader.loadGrammarWithContext((XMLDTDValidator) fValidationHandler, rootName, + publicId, systemId, baseSystemId, internalSubset); } - - return pool; - } - - + // REVISIT: Should probably report this exception to the error handler. + catch (IOException e) { + } + finally { + if (loader != null) { + CoreDOMImplementationImpl.singleton.releaseDTDLoader(xmlVersion, loader); + } + } + } // processDTD(String, String) protected final void expandEntityRef (Node parent, Node reference){ Node kid, next; @@ -740,30 +762,15 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute // // ------------------------------------ - String value, name, uri, prefix; + String value, uri, prefix; if (attributes != null) { // Record all valid local declarations for (int k = 0; k < attributes.getLength(); ++k) { Attr attr = (Attr)attributes.getItem(k); - - //do the name check only when version of the document was changed & - //application has set the value of well-formed features to true - if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0) && - fDocument.isXMLVersionChanged()) { - //checkQName does checking based on the version of the document - fDocument.checkQName(attr.getPrefix() , attr.getLocalName()) ; - } - uri = attr.getNamespaceURI(); if (uri != null && uri.equals(NamespaceContext.XMLNS_URI)) { // namespace attribute - - // "namespace-declarations" == false; Discard all namespace declaration attributes - if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0) { - continue; - } - value = attr.getNodeValue(); if (value == null) { value=XMLSymbols.EMPTY_STRING; @@ -798,7 +805,7 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute } else { // (localpart == fXmlnsSymbol && prefix == fEmptySymbol) -- xmlns // empty prefix is always bound ("" or some string) value = fSymbolTable.addSymbol(value); - fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value); + fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? value : null); //removeDefault (attr, attributes); continue; } @@ -826,12 +833,7 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute uri = element.getNamespaceURI(); prefix = element.getPrefix(); - - // "namespace-declarations" == false? Discard all namespace declaration attributes - if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0) { - // no namespace declaration == no namespace URI, semantics are to keep prefix - uri = null; - } else if (uri != null) { // Element has a namespace + if (uri != null) { // Element has a namespace uri = fSymbolTable.addSymbol(uri); prefix = (prefix == null || prefix.length() == 0) ? XMLSymbols.EMPTY_STRING :fSymbolTable.addSymbol(prefix); @@ -870,8 +872,8 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute // undeclare default namespace declaration (before that element // bound to non-zero length uir), but adding xmlns="" decl addNamespaceDecl (XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING, element); - fLocalNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING); - fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING); + fLocalNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, null); + fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, null); } } } @@ -894,12 +896,35 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute // normalize attribute value attr.normalize(); value = attr.getValue(); - name = attr.getNodeName(); uri = attr.getNamespaceURI(); // make sure that value is never null. if (value == null) { - value=XMLSymbols.EMPTY_STRING; + value = XMLSymbols.EMPTY_STRING; + } + + //--------------------------------------- + // check if value of the attribute is namespace well-formed + //--------------------------------------- + if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0)) { + isAttrValueWF(fErrorHandler, fError, fLocator, attributes, attr, value, fDocument.isXML11Version()); + if (fDocument.isXMLVersionChanged()) { + boolean wellformed; + if (fNamespaceValidation){ + wellformed = CoreDocumentImpl.isValidQName(attr.getPrefix(), attr.getLocalName(), fDocument.isXML11Version()); + } + else { + wellformed = CoreDocumentImpl.isXMLName(attr.getNodeName(), fDocument.isXML11Version()); + } + if (!wellformed) { + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "wf-invalid-character-in-node-name", + new Object[]{"Attr", attr.getNodeName()}); + reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR, + "wf-invalid-character-in-node-name"); + } + } } if (uri != null) { // attribute has namespace !=null @@ -916,23 +941,6 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute if (uri != null && uri.equals(NamespaceContext.XMLNS_URI)) { continue; } - //--------------------------------------- - // check if value of the attribute is namespace well-formed - //--------------------------------------- - if (fDocument.errorChecking && ((fConfiguration.features & DOMConfigurationImpl.WELLFORMED) != 0)) { - isAttrValueWF(fErrorHandler, fError, fLocator, attributes, (AttrImpl)attr, attr.getValue(), fDocument.isXML11Version()); - if (fDocument.isXMLVersionChanged()){ - boolean wellformed=CoreDocumentImpl.isXMLName(attr.getNodeName() , fDocument.isXML11Version()); - if (!wellformed){ - String msg = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "wf-invalid-character-in-node-name", - new Object[]{"Attribute", attr.getNodeName()}); - reportDOMError(fErrorHandler, fError, fLocator, msg, DOMError.SEVERITY_ERROR, - "wf-invalid-character-in-node-name"); - } - } - } // --------------------------------------- // remove default attributes @@ -948,7 +956,6 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute // reset id-attributes ((AttrImpl)attr).setIdAttribute(false); - uri = fSymbolTable.addSymbol(uri); // find if for this prefix a URI was already declared @@ -962,7 +969,6 @@ protected final void namespaceFixUp (ElementImpl element, AttributeMap attribute // conflict: attribute has a prefix that conficlicts with a binding // already active in scope - name = attr.getNodeName(); // Find if any prefix for attributes namespace URI is available // in the scope String declaredPrefix = fNamespaceContext.getPrefix(uri); @@ -1447,8 +1453,8 @@ protected final class XMLAttributesProxy protected CoreDocumentImpl fDocument; protected ElementImpl fElement; - protected final Vector<Augmentations> fAugmentations = new Vector<>(5); - + protected Vector<String> fDTDTypes = new Vector<>(5); + protected Vector<Augmentations> fAugmentations = new Vector<>(5); public void setAttributes(AttributeMap attributes, CoreDocumentImpl doc, ElementImpl elem) { fDocument = doc; @@ -1456,7 +1462,7 @@ public void setAttributes(AttributeMap attributes, CoreDocumentImpl doc, Element fElement = elem; if (attributes != null) { int length = attributes.getLength(); - + fDTDTypes.setSize(length); fAugmentations.setSize(length); // REVISIT: this implementation does not store any value in augmentations // and basically not keeping augs in parallel to attributes map @@ -1464,34 +1470,37 @@ public void setAttributes(AttributeMap attributes, CoreDocumentImpl doc, Element for (int i = 0; i < length; i++) { fAugmentations.setElementAt(new AugmentationsImpl(), i); } - } else { + } + else { + fDTDTypes.setSize(0); fAugmentations.setSize(0); } } - /** + /** * This method adds default declarations * @see com.sun.org.apache.xerces.internal.xni.XMLAttributes#addAttribute(QName, String, String) - */ - public int addAttribute(QName qname, String attrType, String attrValue) { - int index = fElement.getXercesAttribute(qname.uri, qname.localpart); - // add defaults to the tree - if (index < 0) { + */ + public int addAttribute(QName qname, String attrType, String attrValue) { + int index = fElement.getXercesAttribute(qname.uri, qname.localpart); + // add defaults to the tree + if (index < 0) { // the default attribute was removed by a user and needed to // be added back - AttrImpl attr = (AttrImpl) - ((CoreDocumentImpl) fElement.getOwnerDocument()).createAttributeNS( - qname.uri, - qname.rawname, - qname.localpart); + AttrImpl attr = (AttrImpl) + ((CoreDocumentImpl) fElement.getOwnerDocument()).createAttributeNS( + qname.uri, + qname.rawname, + qname.localpart); // REVISIT: the following should also update ID table attr.setNodeValue(attrValue); index = fElement.setXercesAttributeNode(attr); + fDTDTypes.insertElementAt(attrType, index); fAugmentations.insertElementAt(new AugmentationsImpl(), index); attr.setSpecified(false); - } - else { + } + else { // default attribute is in the tree // we don't need to do anything since prefix was already fixed // at the namespace fixup time and value must be same value, otherwise @@ -1500,7 +1509,7 @@ public int addAttribute(QName qname, String attrType, String attrValue) { } return index; - } + } public void removeAllAttributes(){ @@ -1523,41 +1532,58 @@ public int getIndex(String qName){ return -1; } - public int getIndex(String uri, String localPart){ + public int getIndex(String uri, String localPart) { // REVISIT: implement return -1; } - public void setName(int attrIndex, QName attrName){ + public void setName(int attrIndex, QName attrName) { // REVISIT: implement } - public void getName(int attrIndex, QName attrName){ - if (fAttributes !=null) { + public void getName(int attrIndex, QName attrName) { + if (fAttributes != null) { updateQName((Node)fAttributes.getItem(attrIndex), attrName); } } - public String getPrefix(int index){ - // REVISIT: implement + public String getPrefix(int index) { + if (fAttributes != null) { + Node node = (Node) fAttributes.getItem(index); + String prefix = node.getPrefix(); + prefix = (prefix != null && prefix.length() != 0) ? fSymbolTable.addSymbol(prefix) : null; + return prefix; + } return null; } - - public String getURI(int index){ - // REVISIT: implement + public String getURI(int index) { + if (fAttributes != null) { + Node node = (Node) fAttributes.getItem(index); + String namespace = node.getNamespaceURI(); + namespace = (namespace != null) ? fSymbolTable.addSymbol(namespace) : null; + return namespace; + } return null; } - public String getLocalName(int index){ - // REVISIT: implement + public String getLocalName(int index) { + if (fAttributes != null) { + Node node = (Node) fAttributes.getItem(index); + String localName = node.getLocalName(); + localName = (localName != null) ? fSymbolTable.addSymbol(localName) : null; + return localName; + } return null; } - - public String getQName(int index){ - // REVISIT: implement + public String getQName(int index) { + if (fAttributes != null) { + Node node = (Node) fAttributes.getItem(index); + String rawname = fSymbolTable.addSymbol(node.getNodeName()); + return rawname; + } return null; } @@ -1566,27 +1592,31 @@ public QName getQualifiedName(int index){ return null; } - public void setType(int attrIndex, String attrType){ - // REVISIT: implement + public void setType(int attrIndex, String attrType) { + fDTDTypes.setElementAt(attrType, attrIndex); } - - public String getType(int index){ - return "CDATA"; + public String getType(int index) { + String type = fDTDTypes.elementAt(index); + return (type != null) ? getReportableType(type) : "CDATA"; } - - public String getType(String qName){ + public String getType(String qName) { return "CDATA"; } - - public String getType(String uri, String localName){ + public String getType(String uri, String localName) { return "CDATA"; } + private String getReportableType(String type) { + if (type.charAt(0) == '(') { + return "NMTOKEN"; + } + return type; + } - public void setValue(int attrIndex, String attrValue){ + public void setValue(int attrIndex, String attrValue) { // REVISIT: is this desired behaviour? // The values are updated in the case datatype-normalization is turned on // in this case we need to make sure that specified attributes stay specified @@ -1609,13 +1639,11 @@ public String getValue(int index){ } - public String getValue(String qName){ // REVISIT: implement return null; } - public String getValue(String uri, String localName){ if (fAttributes != null) { Node node = fAttributes.getNamedItemNS(uri, localName); @@ -1624,19 +1652,16 @@ public String getValue(String uri, String localName){ return null; } - public void setNonNormalizedValue(int attrIndex, String attrValue){ // REVISIT: implement } - public String getNonNormalizedValue(int attrIndex){ // REVISIT: implement return null; } - public void setSpecified(int attrIndex, boolean specified){ AttrImpl attr = (AttrImpl)fAttributes.getItem(attrIndex); attr.setSpecified(specified); @@ -1788,58 +1813,85 @@ public void processingInstruction(String target, XMLString data, Augmentations a * @exception XNIException * Thrown by handler to signal an error. */ - public void startElement(QName element, XMLAttributes attributes, Augmentations augs) - throws XNIException { - Element currentElement = (Element) fCurrentNode; - int attrCount = attributes.getLength(); + public void startElement(QName element, XMLAttributes attributes, Augmentations augs) + throws XNIException { + Element currentElement = (Element) fCurrentNode; + int attrCount = attributes.getLength(); if (DEBUG_EVENTS) { System.out.println("==>startElement: " +element+ - " attrs.length="+attrCount); + " attrs.length="+attrCount); } - for (int i = 0; i < attrCount; i++) { - attributes.getName(i, fAttrQName); - Attr attr = null; + for (int i = 0; i < attrCount; i++) { + attributes.getName(i, fAttrQName); + Attr attr = null; - attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart); + attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart); + if (attr == null) { + // Must be a non-namespace aware DOM Level 1 node. + attr = currentElement.getAttributeNode(fAttrQName.rawname); + } AttributePSVI attrPSVI = - (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI); + (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI); - if (attrPSVI != null) { + if (attrPSVI != null) { //REVISIT: instead we should be using augmentations: // to set/retrieve Id attributes XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition(); boolean id = false; - if (decl != null){ + if (decl != null) { id = ((XSSimpleType)decl).isIDType(); - } else{ + } + else { decl = attrPSVI.getTypeDefinition(); - if (decl !=null){ - id = ((XSSimpleType)decl).isIDType(); + if (decl != null) { + id = ((XSSimpleType)decl).isIDType(); } } - if (id){ + if (id) { ((ElementImpl)currentElement).setIdAttributeNode(attr, true); } - if (fPSVI) { - ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI); - } - if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) { - // datatype-normalization - // NOTE: The specified value MUST be set after we set - // the node value because that turns the "specified" - // flag to "true" which may overwrite a "false" - // value from the attribute list. - boolean specified = attr.getSpecified(); - attr.setValue(attrPSVI.getSchemaValue().getNormalizedValue()); - if (!specified) { - ((AttrImpl) attr).setSpecified(specified); - } - } + if (fPSVI) { + ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI); + } + + // Updating the TypeInfo for this attribute. + ((AttrImpl) attr).setType(decl); + + if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) { + // datatype-normalization + // NOTE: The specified value MUST be set after we set + // the node value because that turns the "specified" + // flag to "true" which may overwrite a "false" + // value from the attribute list. + final String normalizedValue = attrPSVI.getSchemaValue().getNormalizedValue(); + if (normalizedValue != null) { + boolean specified = attr.getSpecified(); + attr.setValue(normalizedValue); + if (!specified) { + ((AttrImpl) attr).setSpecified(specified); } + } + } + } + else { // DTD + String type = null; + boolean isDeclared = Boolean.TRUE.equals(attributes.getAugmentations(i).getItem (Constants.ATTRIBUTE_DECLARED)); + // For DOM Level 3 TypeInfo, the type name must + // be null if this attribute has not been declared + // in the DTD. + if (isDeclared) { + type = attributes.getType(i); + if ("ID".equals (type)) { + ((ElementImpl) currentElement).setIdAttributeNode(attr, true); + } } + // Updating the TypeInfo for this attribute. + ((AttrImpl) attr).setType(type); + } } + } /** @@ -1948,7 +2000,7 @@ public void characters(XMLString text, Augmentations augs) throws XNIException{ * Thrown by handler to signal an error. */ public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException{ - allWhitespace = true; + fAllWhitespace = true; } /** @@ -1960,38 +2012,51 @@ public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIEx * @exception XNIException * Thrown by handler to signal an error. */ - public void endElement(QName element, Augmentations augs) throws XNIException { - if (DEBUG_EVENTS) { - System.out.println("==>endElement: " + element); - } + public void endElement(QName element, Augmentations augs) throws XNIException { + if (DEBUG_EVENTS) { + System.out.println("==>endElement: " + element); + } - if(augs != null) { - ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI); - if (elementPSVI != null) { - ElementImpl elementNode = (ElementImpl) fCurrentNode; - if (fPSVI) { - ((PSVIElementNSImpl) fCurrentNode).setPSVI(elementPSVI); - } - // include element default content (if one is available) - String normalizedValue = elementPSVI.getSchemaValue().getNormalizedValue(); - if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) { + if (augs != null) { + ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI); + if (elementPSVI != null) { + ElementImpl elementNode = (ElementImpl) fCurrentNode; + if (fPSVI) { + ((PSVIElementNSImpl) fCurrentNode).setPSVI(elementPSVI); + } + // Updating the TypeInfo for this element. + if (elementNode instanceof ElementNSImpl) { + XSTypeDefinition type = elementPSVI.getMemberTypeDefinition(); + if (type == null) { + type = elementPSVI.getTypeDefinition(); + } + ((ElementNSImpl) elementNode).setType(type); + } + // include element default content (if one is available) + String normalizedValue = elementPSVI.getSchemaValue().getNormalizedValue(); + if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) { if (normalizedValue !=null) - elementNode.setTextContent(normalizedValue); - } - else { - // NOTE: this is a hack: it is possible that DOM had an empty element - // and validator sent default value using characters(), which we don't - // implement. Thus, here we attempt to add the default value. - String text = elementNode.getTextContent(); - if (text.length() == 0) { - // default content could be provided + elementNode.setTextContent(normalizedValue); + } + else { + // NOTE: this is a hack: it is possible that DOM had an empty element + // and validator sent default value using characters(), which we don't + // implement. Thus, here we attempt to add the default value. + String text = elementNode.getTextContent(); + if (text.length() == 0) { + // default content could be provided if (normalizedValue !=null) elementNode.setTextContent(normalizedValue); - } - } + } } + return; + } } + // DTD; elements have no type. + if (fCurrentNode instanceof ElementNSImpl) { + ((ElementNSImpl) fCurrentNode).setType(null); } + } /** diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java index c8cc9c2bcd9..e9b2fb37337 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java @@ -69,7 +69,7 @@ public class DeferredDocumentImpl // protected /** Chunk shift. */ - protected static final int CHUNK_SHIFT = 8; // 2^8 = 256 + protected static final int CHUNK_SHIFT = 11; // 2^11 = 2k /** Chunk size. */ protected static final int CHUNK_SIZE = (1 << CHUNK_SHIFT); @@ -78,7 +78,7 @@ public class DeferredDocumentImpl protected static final int CHUNK_MASK = CHUNK_SIZE - 1; /** Initial chunk size. */ - protected static final int INITIAL_CHUNK_COUNT = (1 << (13 - CHUNK_SHIFT)); // 32 + protected static final int INITIAL_CHUNK_COUNT = (1 << (16 - CHUNK_SHIFT)); // 2^16 = 64k // // Data diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java index 6bec51bbca8..ca2a5b198ed 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/DocumentTypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -56,6 +56,7 @@ * @author Joe Kesselman, IBM * @author Andy Clark, IBM * @since PR-DOM-Level-1-19980818. + * @LastModified: Apr 2019 */ public class DocumentTypeImpl extends ParentNode @@ -324,7 +325,7 @@ public boolean isEqualNode(Node arg) { Node entNode2 = argEntities.getNamedItem(entNode1.getNodeName()); - if (!((NodeImpl) entNode1).isEqualNode((NodeImpl) entNode2)) + if (!((NodeImpl) entNode1).isEqualNode(entNode2)) return false; } } @@ -344,7 +345,7 @@ public boolean isEqualNode(Node arg) { Node noteNode2 = argNotations.getNamedItem(noteNode1.getNodeName()); - if (!((NodeImpl) noteNode1).isEqualNode((NodeImpl) noteNode2)) + if (!((NodeImpl) noteNode1).isEqualNode(noteNode2)) return false; } } @@ -357,7 +358,7 @@ public boolean isEqualNode(Node arg) { * NON-DOM * set the ownerDocument of this node and its children */ - void setOwnerDocument(CoreDocumentImpl doc) { + protected void setOwnerDocument(CoreDocumentImpl doc) { super.setOwnerDocument(doc); entities.setOwnerDocument(doc); notations.setOwnerDocument(doc); diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementImpl.java index 35c3e81698d..a71e7088f81 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementImpl.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -55,38 +54,33 @@ * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM * @since PR-DOM-Level-1-19980818. + * @LastModified: Apr 2019 */ public class ElementImpl - extends ParentNode - implements Element, ElementTraversal, TypeInfo { + extends ParentNode + implements Element, ElementTraversal, TypeInfo { // // Constants // - /** - * Serialization version. - */ + + /** Serialization version. */ static final long serialVersionUID = 3717253516652722278L; // // Data // - /** - * Element name. - */ + /** Element name. */ protected String name; - /** - * Attributes. - */ + /** Attributes. */ protected AttributeMap attributes; // // Constructors // - /** - * Factory constructor. - */ + + /** Factory constructor. */ public ElementImpl(CoreDocumentImpl ownerDoc, String name) { super(ownerDoc); this.name = name; @@ -94,8 +88,7 @@ public ElementImpl(CoreDocumentImpl ownerDoc, String name) { } // for ElementNSImpl - protected ElementImpl() { - } + protected ElementImpl() {} // Support for DOM Level 3 renameNode method. // Note: This only deals with part of the pb. CoreDocumentImpl @@ -109,9 +102,9 @@ void rename(String name) { if (colon1 != -1) { String msg = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "NAMESPACE_ERR", - null); + DOMMessageFormatter.DOM_DOMAIN, + "NAMESPACE_ERR", + null); throw new DOMException(DOMException.NAMESPACE_ERR, msg); } if (!CoreDocumentImpl.isXMLName(name, ownerDocument.isXML11Version())) { @@ -287,7 +280,7 @@ public String getAttribute(String name) { if (attributes == null) { return ""; } - Attr attr = (Attr) (attributes.getNamedItem(name)); + Attr attr = (Attr)(attributes.getNamedItem(name)); return (attr == null) ? "" : attr.getValue(); } // getAttribute(String):String @@ -307,7 +300,7 @@ public Attr getAttributeNode(String name) { if (attributes == null) { return null; } - return (Attr) attributes.getNamedItem(name); + return (Attr)attributes.getNamedItem(name); } // getAttributeNode(String):Attr @@ -453,7 +446,7 @@ public void removeAttribute(String name) { * readonly. */ public Attr removeAttributeNode(Attr oldAttr) - throws DOMException { + throws DOMException { if (ownerDocument.errorChecking && isReadOnly()) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); @@ -491,36 +484,35 @@ public Attr removeAttributeNode(Attr oldAttr) * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if the node is * readonly. */ - public void setAttribute(String name, String value) { - - if (ownerDocument.errorChecking && isReadOnly()) { - String msg - = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "NO_MODIFICATION_ALLOWED_ERR", - null); - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); - } + public void setAttribute(String name, String value) { + + if (ownerDocument.errorChecking && isReadOnly()) { + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "NO_MODIFICATION_ALLOWED_ERR", + null); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); + } - if (needsSyncData()) { - synchronizeData(); - } + if (needsSyncData()) { + synchronizeData(); + } - Attr newAttr = getAttributeNode(name); - if (newAttr == null) { - newAttr = getOwnerDocument().createAttribute(name); + Attr newAttr = getAttributeNode(name); + if (newAttr == null) { + newAttr = getOwnerDocument().createAttribute(name); - if (attributes == null) { - attributes = new AttributeMap(this, null); - } + if (attributes == null) { + attributes = new AttributeMap(this, null); + } - newAttr.setNodeValue(value); - attributes.setNamedItem(newAttr); - } else { - newAttr.setNodeValue(value); - } + newAttr.setNodeValue(value); + attributes.setNamedItem(newAttr); + } else { + newAttr.setNodeValue(value); + } - } // setAttribute(String,String) + } // setAttribute(String,String) /** * Add a new attribute/value pair, or replace the value of the existing @@ -546,13 +538,13 @@ public Attr setAttributeNode(Attr newAttr) if (isReadOnly()) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException( - DOMException.NO_MODIFICATION_ALLOWED_ERR, - msg); + DOMException.NO_MODIFICATION_ALLOWED_ERR, + msg); } if (newAttr.getOwnerDocument() != ownerDocument) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null); - throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg); + throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg); } } @@ -589,7 +581,7 @@ public String getAttributeNS(String namespaceURI, String localName) { return ""; } - Attr attr = (Attr) (attributes.getNamedItemNS(namespaceURI, localName)); + Attr attr = (Attr)(attributes.getNamedItemNS(namespaceURI, localName)); return (attr == null) ? "" : attr.getValue(); } // getAttributeNS(String,String):String @@ -633,41 +625,38 @@ public String getAttributeNS(String namespaceURI, String localName) { * @since WD-DOM-Level-2-19990923 */ public void setAttributeNS(String namespaceURI, String qualifiedName, - String value) { - if (ownerDocument.errorChecking && isReadOnly()) { - String msg - = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "NO_MODIFICATION_ALLOWED_ERR", - null); - throw new DOMException( - DOMException.NO_MODIFICATION_ALLOWED_ERR, - msg); - } - if (needsSyncData()) { - synchronizeData(); - } - int index = qualifiedName.indexOf(':'); - String prefix, localName; - if (index < 0) { - prefix = null; - localName = qualifiedName; - } else { - prefix = qualifiedName.substring(0, index); - localName = qualifiedName.substring(index + 1); - } - Attr newAttr = getAttributeNodeNS(namespaceURI, localName); - if (newAttr == null) { + String value) { + if (ownerDocument.errorChecking && isReadOnly()) { + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, + "NO_MODIFICATION_ALLOWED_ERR", + null); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); + } + if (needsSyncData()) { + synchronizeData(); + } + int index = qualifiedName.indexOf(':'); + String prefix, localName; + if (index < 0) { + prefix = null; + localName = qualifiedName; + } else { + prefix = qualifiedName.substring(0, index); + localName = qualifiedName.substring(index + 1); + } + Attr newAttr = getAttributeNodeNS(namespaceURI, localName); + if (newAttr == null) { // REVISIT: this is not efficient, we are creating twice the same // strings for prefix and localName. - newAttr = getOwnerDocument().createAttributeNS( - namespaceURI, - qualifiedName); - if (attributes == null) { - attributes = new AttributeMap(this, null); - } - newAttr.setNodeValue(value); - attributes.setNamedItemNS(newAttr); + newAttr = getOwnerDocument().createAttributeNS( + namespaceURI, + qualifiedName); + if (attributes == null) { + attributes = new AttributeMap(this, null); + } + newAttr.setNodeValue(value); + attributes.setNamedItemNS(newAttr); } else { if (newAttr instanceof AttrNSImpl){ @@ -693,12 +682,12 @@ public void setAttributeNS(String namespaceURI, String qualifiedName, // This case is not defined by the DOM spec, we choose // to create a new attribute in this case and remove an old one from the tree // note this might cause events to be propagated or user data to be lost - newAttr = new AttrNSImpl((CoreDocumentImpl)getOwnerDocument(), namespaceURI, qualifiedName, localName); + newAttr = ((CoreDocumentImpl)getOwnerDocument()).createAttributeNS(namespaceURI, qualifiedName, localName); attributes.setNamedItemNS(newAttr); } - newAttr.setNodeValue(value); - } + newAttr.setNodeValue(value); + } } // setAttributeNS(String,String,String) @@ -753,7 +742,7 @@ public Attr getAttributeNodeNS(String namespaceURI, String localName) { if (attributes == null) { return null; } - return (Attr) attributes.getNamedItemNS(namespaceURI, localName); + return (Attr)attributes.getNamedItemNS(namespaceURI, localName); } // getAttributeNodeNS(String,String):Attr @@ -788,9 +777,9 @@ public Attr setAttributeNodeNS(Attr newAttr) if (ownerDocument.errorChecking) { if (isReadOnly()) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); - throw new DOMException( - DOMException.NO_MODIFICATION_ALLOWED_ERR, - msg); + throw new DOMException( + DOMException.NO_MODIFICATION_ALLOWED_ERR, + msg); } if (newAttr.getOwnerDocument() != ownerDocument) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null); @@ -807,8 +796,8 @@ public Attr setAttributeNodeNS(Attr newAttr) } // setAttributeNodeNS(Attr):Attr /** - * NON-DOM: sets attribute node for this element - */ + * NON-DOM: sets attribute node for this element + */ protected int setXercesAttributeNode(Attr attr) { if (needsSyncData()) { @@ -823,8 +812,8 @@ protected int setXercesAttributeNode(Attr attr) { } /** - * NON-DOM: get inded of an attribute - */ + * NON-DOM: get inded of an attribute + */ protected int getXercesAttribute(String namespaceURI, String localName) { if (needsSyncData()) { @@ -879,7 +868,7 @@ public boolean hasAttributeNS(String namespaceURI, String localName) { * @since WD-DOM-Level-2-19990923 */ public NodeList getElementsByTagNameNS(String namespaceURI, - String localName) { + String localName) { return new DeepNodeListImpl(this, namespaceURI, localName); } @@ -911,7 +900,7 @@ public boolean isEqualNode(Node arg) { } } else { Node n2 = map2.getNamedItemNS(n1.getNamespaceURI(), - n1.getLocalName()); + n1.getLocalName()); if (n2 == null || !((NodeImpl) n1).isEqualNode(n2)) { return false; } @@ -930,14 +919,15 @@ public void setIdAttributeNode(Attr at, boolean makeId) { } if (ownerDocument.errorChecking) { if (isReadOnly()) { - String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException( - DOMException.NO_MODIFICATION_ALLOWED_ERR, - msg); + DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); } if (at.getOwnerElement() != this) { - String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); throw new DOMException(DOMException.NOT_FOUND_ERR, msg); } } @@ -959,22 +949,21 @@ public void setIdAttribute(String name, boolean makeId) { Attr at = getAttributeNode(name); if (at == null) { - String msg = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "NOT_FOUND_ERR", null); + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); throw new DOMException(DOMException.NOT_FOUND_ERR, msg); - } + } if (ownerDocument.errorChecking) { if (isReadOnly()) { - String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); - throw new DOMException( - DOMException.NO_MODIFICATION_ALLOWED_ERR, - msg); + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); } if (at.getOwnerElement() != this) { - String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); throw new DOMException(DOMException.NOT_FOUND_ERR, msg); } } @@ -991,7 +980,7 @@ public void setIdAttribute(String name, boolean makeId) { * DOM Level 3: register the given attribute node as an ID attribute */ public void setIdAttributeNS(String namespaceURI, String localName, - boolean makeId) { + boolean makeId) { if (needsSyncData()) { synchronizeData(); } @@ -1002,19 +991,18 @@ public void setIdAttributeNS(String namespaceURI, String localName, Attr at = getAttributeNodeNS(namespaceURI, localName); if (at == null) { - String msg = DOMMessageFormatter.formatMessage( - DOMMessageFormatter.DOM_DOMAIN, - "NOT_FOUND_ERR", null); + String msg = DOMMessageFormatter.formatMessage( + DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); throw new DOMException(DOMException.NOT_FOUND_ERR, msg); - } + } - if (ownerDocument.errorChecking) { + if (ownerDocument.errorChecking) { if (isReadOnly()) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException( - DOMException.NO_MODIFICATION_ALLOWED_ERR, - msg); + DOMException.NO_MODIFICATION_ALLOWED_ERR, + msg); } if (at.getOwnerElement() != this) { @@ -1029,14 +1017,14 @@ public void setIdAttributeNS(String namespaceURI, String localName, } else { ownerDocument.putIdentifier(at.getValue(), this); } - } + } /** * @see org.w3c.dom.TypeInfo#getTypeName() */ - public String getTypeName() { + public String getTypeName() { return null; - } + } /** * @see org.w3c.dom.TypeInfo#getTypeNamespace() @@ -1059,17 +1047,16 @@ public String getTypeNamespace() { * reference type */ public boolean isDerivedFrom(String typeNamespaceArg, - String typeNameArg, - int derivationMethod) { + String typeNameArg, + int derivationMethod) { return false; } - /** - * Method getSchemaTypeInfo. - * - * @return TypeInfo - */ + /** + * Method getSchemaTypeInfo. + * @return TypeInfo + */ public TypeInfo getSchemaTypeInfo() { if (needsSyncData()) { synchronizeData(); @@ -1159,8 +1146,7 @@ protected NamedNodeMapImpl getDefaultAttributes() { if (doctype == null) { return null; } - ElementDefinitionImpl eldef - = (ElementDefinitionImpl) doctype.getElements() + ElementDefinitionImpl eldef = (ElementDefinitionImpl)doctype.getElements() .getNamedItem(getNodeName()); if (eldef == null) { return null; diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java index 6a76152555d..ea1a49d5a24 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java @@ -86,13 +86,13 @@ protected ElementNSImpl(CoreDocumentImpl ownerDocument, private void setName(String namespaceURI, String qname) { - String prefix; - // DOM Level 3: namespace URI is never empty string. - this.namespaceURI = namespaceURI; - if (namespaceURI != null) { + String prefix; + // DOM Level 3: namespace URI is never empty string. + this.namespaceURI = namespaceURI; + if (namespaceURI != null) { //convert the empty string to 'null' - this.namespaceURI = (namespaceURI.length() == 0) ? null : namespaceURI; - } + this.namespaceURI = (namespaceURI.length() == 0) ? null : namespaceURI; + } int colon1, colon2 ; @@ -190,37 +190,6 @@ void rename(String namespaceURI, String qualifiedName) reconcileDefaultAttributes(); } - /** - * NON-DOM: resets this node and sets specified values for the node - * - * @param ownerDocument - * @param namespaceURI - * @param qualifiedName - * @param localName - */ - protected void setValues (CoreDocumentImpl ownerDocument, - String namespaceURI, String qualifiedName, - String localName){ - - // remove children first - firstChild = null; - previousSibling = null; - nextSibling = null; - fNodeListCache = null; - - // set owner document - attributes = null; - super.flags = 0; - setOwnerDocument(ownerDocument); - - // synchronizeData will initialize attributes - needsSyncData(true); - super.name = qualifiedName; - this.localName = localName; - this.namespaceURI = namespaceURI; - - } - // // Node methods // @@ -340,88 +309,13 @@ public String getLocalName() return localName; } - - /** - * DOM Level 3 WD - Experimental. - * Retrieve baseURI + /** + * NON-DOM + * Returns the xml:base attribute. */ - public String getBaseURI() { - - if (needsSyncData()) { - synchronizeData(); - } - // Absolute base URI is computed according to XML Base (http://www.w3.org/TR/xmlbase/#granularity) - - // 1. the base URI specified by an xml:base attribute on the element, if one exists - - if (attributes != null) { - Attr attrNode = (Attr)attributes.getNamedItemNS("http://www.w3.org/XML/1998/namespace", "base"); - if (attrNode != null) { - String uri = attrNode.getNodeValue(); - if (uri.length() != 0 ) {// attribute value is always empty string - try { - uri = new URI(uri).toString(); - } - catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e) { - // This may be a relative URI. - - // Start from the base URI of the parent, or if this node has no parent, the owner node. - NodeImpl parentOrOwner = (parentNode() != null) ? parentNode() : ownerNode; - - // Make any parentURI into a URI object to use with the URI(URI, String) constructor. - String parentBaseURI = (parentOrOwner != null) ? parentOrOwner.getBaseURI() : null; - - if (parentBaseURI != null) { - try { - uri = new URI(new URI(parentBaseURI), uri).toString(); - } - catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException ex){ - // This should never happen: parent should have checked the URI and returned null if invalid. - return null; - } - return uri; - } - // REVISIT: what should happen in this case? - return null; - } - return uri; - } - } - } - - //2.the base URI of the element's parent element within the document or external entity, - //if one exists - String parentElementBaseURI = (this.parentNode() != null) ? this.parentNode().getBaseURI() : null ; - //base URI of parent element is not null - if(parentElementBaseURI != null){ - try { - //return valid absolute base URI - return new URI(parentElementBaseURI).toString(); - } - catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){ - // REVISIT: what should happen in this case? - return null; - } - } - //3. the base URI of the document entity or external entity containing the element - - String baseURI = (this.ownerNode != null) ? this.ownerNode.getBaseURI() : null ; - - if(baseURI != null){ - try { - //return valid absolute base URI - return new URI(baseURI).toString(); - } - catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){ - // REVISIT: what should happen in this case? - return null; - } - } - - return null; - - } - + protected Attr getXMLBaseAttribute() { + return (Attr) attributes.getNamedItemNS("http://www.w3.org/XML/1998/namespace", "base"); + } // getXMLBaseAttribute():Attr /** * @see org.w3c.dom.TypeInfo#getTypeName() @@ -452,12 +346,12 @@ public String getTypeNamespace() { * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom * - * @param ancestorNS + * @param typeNamespaceArg * The namspace of the ancestor type declaration - * @param ancestorName + * @param typeNameArg * The name of the ancestor type declaration - * @param type - * The reference type definition + * @param derivationMethod + * The derivation method * * @return boolean True if the type is derived by restriciton for the * reference type diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java index d158f18170b..e0f808dbd83 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/NodeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -27,6 +27,7 @@ import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; +import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -78,6 +79,7 @@ * @author Arnaud Le Hors, IBM * @author Joe Kesselman, IBM * @since PR-DOM-Level-1-19980818. + * @LastModified: Apr 2019 */ public abstract class NodeImpl implements Node, NodeList, EventTarget, Cloneable, Serializable{ @@ -122,15 +124,6 @@ public abstract class NodeImpl */ public static final short TREE_POSITION_DISCONNECTED = 0x00; - - // DocumentPosition - public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01; - public static final short DOCUMENT_POSITION_PRECEDING = 0x02; - public static final short DOCUMENT_POSITION_FOLLOWING = 0x04; - public static final short DOCUMENT_POSITION_CONTAINS = 0x08; - public static final short DOCUMENT_POSITION_IS_CONTAINED = 0x10; - public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; - /** Serialization version. */ static final long serialVersionUID = -6316591992167219696L; @@ -324,7 +317,7 @@ CoreDocumentImpl ownerDocument() { * NON-DOM * set the ownerDocument of this node */ - void setOwnerDocument(CoreDocumentImpl doc) { + protected void setOwnerDocument(CoreDocumentImpl doc) { if (needsSyncData()) { synchronizeData(); } @@ -559,7 +552,7 @@ public int getLength() { * @see ParentNode * * @return org.w3c.dom.Node - * @param Index int + * @param index int */ public Node item(int index) { return null; @@ -976,9 +969,7 @@ public short compareDocumentPosition(Node other) throws DOMException { return 0; // check if other is from a different implementation - try { - NodeImpl node = (NodeImpl) other; - } catch (ClassCastException e) { + if (other != null && !(other instanceof NodeImpl)) { // other comes from a different implementation String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null); @@ -1041,7 +1032,7 @@ public short compareDocumentPosition(Node other) throws DOMException { otherDepth +=1; if (node == this) // The other node is a descendent of the reference node. - return (DOCUMENT_POSITION_IS_CONTAINED | + return (DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING); otherAncestor = node; } @@ -1131,7 +1122,7 @@ else if (thisOwnerDoc!=null && thisOwnerDoc==otherOwnerDoc) case Node.NOTATION_NODE: case Node.ENTITY_NODE: { DocumentType container = thisOwnerDoc.getDoctype(); - if (container == this) return (DOCUMENT_POSITION_IS_CONTAINED | + if (container == this) return (DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING); otherNode = otherAncestor = thisOwnerDoc; break; @@ -1139,7 +1130,7 @@ else if (thisOwnerDoc!=null && thisOwnerDoc==otherOwnerDoc) case Node.DOCUMENT_TYPE_NODE: { if (thisNode == otherOwnerDoc) return (DOCUMENT_POSITION_FOLLOWING | - DOCUMENT_POSITION_IS_CONTAINED); + DOCUMENT_POSITION_CONTAINED_BY); else if (otherOwnerDoc!=null && thisOwnerDoc==otherOwnerDoc) return (DOCUMENT_POSITION_PRECEDING); break; @@ -1153,7 +1144,7 @@ else if (otherOwnerDoc!=null && thisOwnerDoc==otherOwnerDoc) // The other node is a descendent of the reference // node's element return DOCUMENT_POSITION_FOLLOWING | - DOCUMENT_POSITION_IS_CONTAINED; + DOCUMENT_POSITION_CONTAINED_BY; otherAncestor = node; } @@ -1302,8 +1293,8 @@ public String getTextContent() throws DOMException { return getNodeValue(); // overriden in some subclasses } - // internal method taking a StringBuffer in parameter - void getTextContent(StringBuffer buf) throws DOMException { + // internal method taking a StringBuilder in parameter + void getTextContent(StringBuilder buf) throws DOMException { String content = getNodeValue(); if (content != null) { buf.append(content); @@ -1425,7 +1416,11 @@ public boolean isDefaultNamespace(String namespaceURI){ return false; } case Node.DOCUMENT_NODE:{ - return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI); + Element docElement = ((Document)this).getDocumentElement(); + if (docElement != null) { + return docElement.isDefaultNamespace(namespaceURI); + } + return false; } case Node.ENTITY_NODE : @@ -1475,12 +1470,15 @@ public String lookupPrefix(String namespaceURI){ switch (type) { case Node.ELEMENT_NODE: { - - String namespace = this.getNamespaceURI(); // to flip out children + this.getNamespaceURI(); // to flip out children return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); } case Node.DOCUMENT_NODE:{ - return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); + Element docElement = ((Document)this).getDocumentElement(); + if (docElement != null) { + return docElement.lookupPrefix(namespaceURI); + } + return null; } case Node.ENTITY_NODE : @@ -1511,8 +1509,8 @@ public String lookupPrefix(String namespaceURI){ * Look up the namespace URI associated to the given prefix, starting from this node. * Use lookupNamespaceURI(null) to lookup the default namespace * - * @param namespaceURI - * @return th URI for the namespace + * @param specifiedPrefix + * @return the URI for the namespace * @since DOM Level 3 */ public String lookupNamespaceURI(String specifiedPrefix) { @@ -1537,20 +1535,20 @@ public String lookupNamespaceURI(String specifiedPrefix) { int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); - String attrPrefix = attr.getPrefix(); - String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { + String attrPrefix = attr.getPrefix(); + String value = attr.getNodeValue(); // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) { // default namespace - return value; + return value.length() > 0 ? value : null; } else if (attrPrefix !=null && attrPrefix.equals("xmlns") && attr.getLocalName().equals(specifiedPrefix)) { // non default namespace - return value; + return value.length() > 0 ? value : null; } } } @@ -1565,7 +1563,11 @@ public String lookupNamespaceURI(String specifiedPrefix) { } case Node.DOCUMENT_NODE : { - return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix); + Element docElement = ((Document)this).getDocumentElement(); + if (docElement != null) { + return docElement.lookupNamespaceURI(specifiedPrefix); + } + return null; } case Node.ENTITY_NODE : case Node.NOTATION_NODE: @@ -1591,15 +1593,14 @@ public String lookupNamespaceURI(String specifiedPrefix) { } } - - Node getElementAncestor (Node currentNode){ + Node getElementAncestor(Node currentNode) { Node parent = currentNode.getParentNode(); - if (parent != null) { + while (parent != null) { short type = parent.getNodeType(); if (type == Node.ELEMENT_NODE) { return parent; } - return getElementAncestor(parent); + parent = parent.getParentNode(); } return null; } @@ -1624,10 +1625,10 @@ String lookupNamespacePrefix(String namespaceURI, ElementImpl el){ int length = map.getLength(); for (int i=0;i<length;i++) { Node attr = map.item(i); - String attrPrefix = attr.getPrefix(); - String value = attr.getNodeValue(); namespace = attr.getNamespaceURI(); if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { + String attrPrefix = attr.getPrefix(); + String value = attr.getNodeValue(); // DOM Level 2 nodes if (((attr.getNodeName().equals("xmlns")) || (attrPrefix !=null && attrPrefix.equals("xmlns")) && @@ -1687,9 +1688,6 @@ String lookupNamespacePrefix(String namespaceURI, ElementImpl el){ * <code>Text</code> nodes, as well as any user data or event listeners * registered on the nodes. * @param arg The node to compare equality with. - * @param deep If <code>true</code>, recursively compare the subtrees; if - * <code>false</code>, compare only the nodes themselves (and its - * attributes, if it is an <code>Element</code>). * @return If the nodes, and possibly subtrees are equal, * <code>true</code> otherwise <code>false</code>. * @since DOM Level 3 diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/PSVIDOMImplementationImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/PSVIDOMImplementationImpl.java index 2fae8652ef5..9a74c607d3b 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/PSVIDOMImplementationImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/PSVIDOMImplementationImpl.java @@ -21,11 +21,8 @@ package com.sun.org.apache.xerces.internal.dom; -import org.w3c.dom.DOMException; import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; /** * The DOMImplementation class is description of a particular @@ -40,7 +37,7 @@ * * @since PR-DOM-Level-1-19980818. */ -public class PSVIDOMImplementationImpl extends CoreDOMImplementationImpl { +public class PSVIDOMImplementationImpl extends DOMImplementationImpl { // // Data @@ -49,7 +46,7 @@ public class PSVIDOMImplementationImpl extends CoreDOMImplementationImpl { // static /** Dom implementation singleton. */ - static PSVIDOMImplementationImpl singleton = new PSVIDOMImplementationImpl(); + static final PSVIDOMImplementationImpl singleton = new PSVIDOMImplementationImpl(); // // Public methods @@ -84,42 +81,12 @@ public boolean hasFeature(String feature, String version) { feature.equalsIgnoreCase("psvi"); } // hasFeature(String,String):boolean - /** - * Introduced in DOM Level 2. <p> - * - * Creates an XML Document object of the specified type with its document - * element. - * - * @param namespaceURI The namespace URI of the document - * element to create, or null. - * @param qualifiedName The qualified name of the document - * element to create. - * @param doctype The type of document to be created or null.<p> - * - * When doctype is not null, its - * Node.ownerDocument attribute is set to - * the document being created. - * @return Document A new Document object. - * @throws DOMException WRONG_DOCUMENT_ERR: Raised if doctype has - * already been used with a different document. - * @since WD-DOM-Level-2-19990923 - */ - public Document createDocument(String namespaceURI, - String qualifiedName, - DocumentType doctype) - throws DOMException - { - if (doctype != null && doctype.getOwnerDocument() != null) { - throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, - DOMMessageFormatter.formatMessage( - DOMMessageFormatter.XML_DOMAIN, - "WRONG_DOCUMENT_ERR", null)); - } - DocumentImpl doc = new PSVIDocumentImpl(doctype); - Element e = doc.createElementNS( namespaceURI, qualifiedName); - doc.appendChild(e); - return doc; - } + // + // Protected methods + // + protected CoreDocumentImpl createDocument(DocumentType doctype) { + return new PSVIDocumentImpl(doctype); + } -} // class DOMImplementationImpl +} // class PSVIDOMImplementationImpl diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ParentNode.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ParentNode.java index 3949063a5ab..342b4b7ea3e 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ParentNode.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/ParentNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -68,6 +68,7 @@ * @author Arnaud Le Hors, IBM * @author Joe Kesselman, IBM * @author Andy Clark, IBM + * @LastModified: Apr 2019 */ public abstract class ParentNode extends ChildNode { @@ -174,18 +175,16 @@ CoreDocumentImpl ownerDocument() { * NON-DOM * set the ownerDocument of this node and its children */ - void setOwnerDocument(CoreDocumentImpl doc) { + protected void setOwnerDocument(CoreDocumentImpl doc) { if (needsSyncChildren()) { synchronizeChildren(); } - for (ChildNode child = firstChild; - child != null; child = child.nextSibling) { - child.setOwnerDocument(doc); - } - /* setting the owner document of self, after it's children makes the - data of children available to the new document. */ super.setOwnerDocument(doc); ownerDocument = doc; + for (ChildNode child = firstChild; + child != null; child = child.nextSibling) { + child.setOwnerDocument(doc); + } } /** @@ -368,16 +367,14 @@ Node internalInsertBefore(Node newChild, Node refChild, boolean replace) // Prevent cycles in the tree // newChild cannot be ancestor of this Node, // and actually cannot be this - if (ownerDocument.ancestorChecking) { - boolean treeSafe = true; - for (NodeImpl a = this; treeSafe && a != null; a = a.parentNode()) - { - treeSafe = newChild != a; - } - if(!treeSafe) { - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, - DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null)); - } + boolean treeSafe = true; + for (NodeImpl a = this; treeSafe && a != null; a = a.parentNode()) + { + treeSafe = newChild != a; + } + if(!treeSafe) { + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, + DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null)); } } @@ -509,6 +506,9 @@ Node internalRemoveChild(Node oldChild, boolean replace) // notify document ownerDocument.removingNode(this, oldInternal, replace); + // Save previous sibling for normalization checking. + final ChildNode oldPreviousSibling = oldInternal.previousSibling(); + // update cached length if we have any if (fNodeListCache != null) { if (fNodeListCache.fLength != -1) { @@ -519,7 +519,7 @@ Node internalRemoveChild(Node oldChild, boolean replace) // move the cache to its (soon former) previous sibling if (fNodeListCache.fChild == oldInternal) { fNodeListCache.fChildIndex--; - fNodeListCache.fChild = oldInternal.previousSibling(); + fNodeListCache.fChild = oldPreviousSibling; } else { // otherwise just invalidate the cache fNodeListCache.fChildIndex = -1; @@ -550,9 +550,6 @@ Node internalRemoveChild(Node oldChild, boolean replace) } } - // Save previous sibling for normalization checking. - ChildNode oldPreviousSibling = oldInternal.previousSibling(); - // Remove oldInternal's references to tree oldInternal.ownerNode = ownerDocument; oldInternal.isOwned(false); @@ -624,20 +621,15 @@ public String getTextContent() throws DOMException { if (next == null) { return hasTextContent(child) ? ((NodeImpl) child).getTextContent() : ""; } - if (fBufferStr == null){ - fBufferStr = new StringBuffer(); - } - else { - fBufferStr.setLength(0); - } - getTextContent(fBufferStr); - return fBufferStr.toString(); + StringBuilder buf = new StringBuilder(); + getTextContent(buf); + return buf.toString(); } return ""; } - // internal method taking a StringBuffer in parameter - void getTextContent(StringBuffer buf) throws DOMException { + // internal method taking a StringBuilder in parameter + void getTextContent(StringBuilder buf) throws DOMException { Node child = getFirstChild(); while (child != null) { if (hasTextContent(child)) { @@ -684,6 +676,9 @@ public void setTextContent(String textContent) private int nodeListGetLength() { if (fNodeListCache == null) { + if (needsSyncChildren()) { + synchronizeChildren(); + } // get rid of trivial cases if (firstChild == null) { return 0; @@ -733,6 +728,9 @@ public int getLength() { private Node nodeListItem(int index) { if (fNodeListCache == null) { + if (needsSyncChildren()) { + synchronizeChildren(); + } // get rid of trivial case if (firstChild == lastChild()) { return index == 0 ? firstChild : null; @@ -870,7 +868,7 @@ public boolean isEqualNode(Node arg) { Node child1 = getFirstChild(); Node child2 = arg.getFirstChild(); while (child1 != null && child2 != null) { - if (!((NodeImpl) child1).isEqualNode(child2)) { + if (!child1.isEqualNode(child2)) { return false; } child1 = child1.getNextSibling(); @@ -997,7 +995,7 @@ void checkNormalizationAfterRemove(ChildNode previousSibling) { /** Serialize object. */ private void writeObject(ObjectOutputStream out) throws IOException { - // synchronize chilren + // synchronize children if (needsSyncChildren()) { synchronizeChildren(); } @@ -1022,7 +1020,7 @@ private void readObject(ObjectInputStream ois) /* * a class to store some user data along with its handler */ - protected class UserDataRecord implements Serializable { + class UserDataRecord implements Serializable { /** Serialization version. */ private static final long serialVersionUID = 3258126977134310455L; diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/TextImpl.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/TextImpl.java index 19cb05dd0fc..028c3e610f4 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/TextImpl.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/TextImpl.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -42,6 +41,7 @@ * @xerces.internal * * @since PR-DOM-Level-1-19980818. + * @LastModified: Apr 2019 */ public class TextImpl extends CharacterDataImpl @@ -146,37 +146,32 @@ public String getWholeText(){ synchronizeData(); } - if (fBufferStr == null){ - fBufferStr = new StringBuffer(); - } - else { - fBufferStr.setLength(0); - } + StringBuilder buffer = new StringBuilder(); if (data != null && data.length() != 0) { - fBufferStr.append(data); + buffer.append(data); } - //concatenate text of logically adjacent text nodes to the left of this node in the tree - getWholeTextBackward(this.getPreviousSibling(), fBufferStr, this.getParentNode()); - String temp = fBufferStr.toString(); + // concatenate text of logically adjacent text nodes to the left of this node in the tree + getWholeTextBackward(this.getPreviousSibling(), buffer, this.getParentNode()); + String temp = buffer.toString(); - //clear buffer - fBufferStr.setLength(0); + // clear buffer + buffer.setLength(0); - //concatenate text of logically adjacent text nodes to the right of this node in the tree - getWholeTextForward(this.getNextSibling(), fBufferStr, this.getParentNode()); + // concatenate text of logically adjacent text nodes to the right of this node in the tree + getWholeTextForward(this.getNextSibling(), buffer, this.getParentNode()); - return temp + fBufferStr.toString(); + return temp + buffer.toString(); } /** - * internal method taking a StringBuffer in parameter and inserts the + * internal method taking a StringBuilder in parameter and inserts the * text content at the start of the buffer * * @param buf */ - protected void insertTextContent(StringBuffer buf) throws DOMException { + protected void insertTextContent(StringBuilder buf) throws DOMException { String content = getNodeValue(); if (content != null) { buf.insert(0, content); @@ -193,7 +188,7 @@ protected void insertTextContent(StringBuffer buf) throws DOMException { * other than EntityRef, Text, CDATA is encountered, otherwise * return false */ - private boolean getWholeTextForward(Node node, StringBuffer buffer, Node parent){ + private boolean getWholeTextForward(Node node, StringBuilder buffer, Node parent){ // boolean to indicate whether node is a child of an entity reference boolean inEntRef = false; @@ -240,7 +235,7 @@ else if (type == Node.TEXT_NODE || * other than EntityRef, Text, CDATA is encountered, otherwise * return false */ - private boolean getWholeTextBackward(Node node, StringBuffer buffer, Node parent){ + private boolean getWholeTextBackward(Node node, StringBuilder buffer, Node parent){ // boolean to indicate whether node is a child of an entity reference boolean inEntRef = false; diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index e13fa8fbfa9..38c32f1c489 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,6 +22,7 @@ import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader; import com.sun.org.apache.xerces.internal.impl.io.UCSReader; +import com.sun.org.apache.xerces.internal.impl.io.UTF16Reader; import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader; import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager; @@ -89,7 +90,7 @@ * @author K.Venugopal SUN Microsystems * @author Neeraj Bajaj SUN Microsystems * @author Sunitha Reddy SUN Microsystems - * @LastModified: Oct 2017 + * @LastModified: Apr 2019 */ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { @@ -412,9 +413,6 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { /** Augmentations for entities. */ private final Augmentations fEntityAugs = new AugmentationsImpl(); - /** Pool of character buffers. */ - private CharacterBufferPool fBufferPool = new CharacterBufferPool(fBufferSize, DEFAULT_INTERNAL_BUFFER_SIZE); - /** indicate whether Catalog should be used for resolving external resources */ private boolean fUseCatalog = true; CatalogFeatures fCatalogFeatures; @@ -694,7 +692,8 @@ public String setupCurrentEntity(boolean reference, String name, XMLInputSource } // wrap this stream in RewindableInputStream - stream = new RewindableInputStream(stream); + RewindableInputStream rewindableStream = new RewindableInputStream(stream); + stream = rewindableStream; // perform auto-detect of encoding if necessary if (encoding == null) { @@ -702,27 +701,30 @@ public String setupCurrentEntity(boolean reference, String name, XMLInputSource final byte[] b4 = new byte[4]; int count = 0; for (; count<4; count++ ) { - b4[count] = (byte)stream.read(); + b4[count] = (byte)rewindableStream.readAndBuffer(); } if (count == 4) { - Object [] encodingDesc = getEncodingName(b4, count); - encoding = (String)(encodingDesc[0]); - isBigEndian = (Boolean)(encodingDesc[1]); - + final EncodingInfo info = getEncodingInfo(b4, count); + encoding = info.autoDetectedEncoding; + final String readerEncoding = info.readerEncoding; + isBigEndian = info.isBigEndian; stream.reset(); - // Special case UTF-8 files with BOM created by Microsoft - // tools. It's more efficient to consume the BOM than make - // the reader perform extra checks. -Ac - if (count > 2 && encoding.equals("UTF-8")) { - int b0 = b4[0] & 0xFF; - int b1 = b4[1] & 0xFF; - int b2 = b4[2] & 0xFF; - if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) { - // ignore first three bytes... + if (info.hasBOM) { + // Special case UTF-8 files with BOM created by Microsoft + // tools. It's more efficient to consume the BOM than make + // the reader perform extra checks. -Ac + if (EncodingInfo.STR_UTF8.equals(readerEncoding)) { + // UTF-8 BOM: 0xEF 0xBB 0xBF stream.skip(3); } + // It's also more efficient to consume the UTF-16 BOM. + else if (EncodingInfo.STR_UTF16.equals(readerEncoding)) { + // UTF-16 BE BOM: 0xFE 0xFF + // UTF-16 LE BOM: 0xFF 0xFE + stream.skip(2); + } } - reader = createReader(stream, encoding, isBigEndian); + reader = createReader(stream, readerEncoding, isBigEndian); } else { reader = createReader(stream, encoding, isBigEndian); } @@ -733,11 +735,11 @@ public String setupCurrentEntity(boolean reference, String name, XMLInputSource encoding = encoding.toUpperCase(Locale.ENGLISH); // If encoding is UTF-8, consume BOM if one is present. - if (encoding.equals("UTF-8")) { + if (EncodingInfo.STR_UTF8.equals(encoding)) { final int[] b3 = new int[3]; int count = 0; for (; count < 3; ++count) { - b3[count] = stream.read(); + b3[count] = rewindableStream.readAndBuffer(); if (b3[count] == -1) break; } @@ -750,56 +752,51 @@ public String setupCurrentEntity(boolean reference, String name, XMLInputSource stream.reset(); } } - // If encoding is UTF-16, we still need to read the first four bytes - // in order to discover the byte order. - else if (encoding.equals("UTF-16")) { + // If encoding is UTF-16, we still need to read the first + // four bytes, in order to discover the byte order. + else if (EncodingInfo.STR_UTF16.equals(encoding)) { final int[] b4 = new int[4]; int count = 0; for (; count < 4; ++count) { - b4[count] = stream.read(); + b4[count] = rewindableStream.readAndBuffer(); if (b4[count] == -1) break; } stream.reset(); - - String utf16Encoding = "UTF-16"; if (count >= 2) { final int b0 = b4[0]; final int b1 = b4[1]; if (b0 == 0xFE && b1 == 0xFF) { // UTF-16, big-endian - utf16Encoding = "UTF-16BE"; isBigEndian = Boolean.TRUE; + stream.skip(2); } else if (b0 == 0xFF && b1 == 0xFE) { // UTF-16, little-endian - utf16Encoding = "UTF-16LE"; isBigEndian = Boolean.FALSE; + stream.skip(2); } else if (count == 4) { final int b2 = b4[2]; final int b3 = b4[3]; if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) { // UTF-16, big-endian, no BOM - utf16Encoding = "UTF-16BE"; isBigEndian = Boolean.TRUE; } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) { // UTF-16, little-endian, no BOM - utf16Encoding = "UTF-16LE"; isBigEndian = Boolean.FALSE; } } } - reader = createReader(stream, utf16Encoding, isBigEndian); } // If encoding is UCS-4, we still need to read the first four bytes // in order to discover the byte order. - else if (encoding.equals("ISO-10646-UCS-4")) { + else if (EncodingInfo.STR_UCS4.equals(encoding)) { final int[] b4 = new int[4]; int count = 0; for (; count < 4; ++count) { - b4[count] = stream.read(); + b4[count] = rewindableStream.readAndBuffer(); if (b4[count] == -1) break; } @@ -819,11 +816,11 @@ else if (b4[0] == 0x3C && b4[1] == 0x00 && b4[2] == 0x00 && b4[3] == 0x00) { } // If encoding is UCS-2, we still need to read the first four bytes // in order to discover the byte order. - else if (encoding.equals("ISO-10646-UCS-2")) { + else if (EncodingInfo.STR_UCS2.equals(encoding)) { final int[] b4 = new int[4]; int count = 0; for (; count < 4; ++count) { - b4[count] = stream.read(); + b4[count] = rewindableStream.readAndBuffer(); if (b4[count] == -1) break; } @@ -855,7 +852,7 @@ else if (b4[0] == 0x3C && b4[1] == 0x00 && b4[2] == 0x3F && b4[3] == 0x00) { // We've seen a new Reader. // Push it on the stack so we can close it later. - //fOwnReaders.add(reader); + fReaderStack.push(reader); // push entity on stack if (fCurrentEntity != null) { @@ -1444,16 +1441,21 @@ public Entity.ScannedEntity getTopLevelEntity() { (fEntityStack.empty() ? null : fEntityStack.get(0)); } + // A stack containing all the open readers + protected Stack<Reader> fReaderStack = new Stack<>(); /** * Close all opened InputStreams and Readers opened by this parser. */ public void closeReaders() { - /** this call actually does nothing, readers are closed in the endEntity method - * through the current entity. - * The change seems to have happened during the jdk6 development with the - * addition of StAX - **/ + // close all readers + while (!fReaderStack.isEmpty()) { + try { + (fReaderStack.pop()).close(); + } catch (IOException e) { + // ignore + } + } } public void endEntity() throws IOException, XNIException { @@ -1487,6 +1489,13 @@ public void endEntity() throws IOException, XNIException { } } + // REVISIT: We should never encounter underflow if the calls + // to startEntity and endEntity are balanced, but guard + // against the EmptyStackException for now. -- mrglavas + if (!fReaderStack.isEmpty()) { + fReaderStack.pop(); + } + if (fEntityHandler != null) { //so this is the last opened entity, signal it to current fEntityHandler using Augmentation if(entity == null){ @@ -1786,7 +1795,6 @@ public void setProperty(String propertyId, Object value){ bufferSize.intValue() > DEFAULT_XMLDECL_BUFFER_SIZE) { fBufferSize = bufferSize.intValue(); fEntityScanner.setBufferSize(fBufferSize); - fBufferPool.setExternalBufferSize(fBufferSize); } } if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() && @@ -2413,14 +2421,12 @@ private static String expandSystemIdStrictOff1(String systemId, String baseSyste * * @param b4 The first four bytes of the input. * @param count The number of bytes actually read. - * @return a 2-element array: the first element, an IANA-encoding string, - * the second element a Boolean which is true iff the document is big endian, false - * if it's little-endian, and null if the distinction isn't relevant. + * @return an instance of EncodingInfo which represents the auto-detected encoding. */ - protected Object[] getEncodingName(byte[] b4, int count) { + protected EncodingInfo getEncodingInfo(byte[] b4, int count) { if (count < 2) { - return defaultEncoding; + return EncodingInfo.UTF_8; } // UTF-16, with BOM @@ -2428,69 +2434,70 @@ protected Object[] getEncodingName(byte[] b4, int count) { int b1 = b4[1] & 0xFF; if (b0 == 0xFE && b1 == 0xFF) { // UTF-16, big-endian - return new Object [] {"UTF-16BE", true}; + return EncodingInfo.UTF_16_BIG_ENDIAN_WITH_BOM; } if (b0 == 0xFF && b1 == 0xFE) { // UTF-16, little-endian - return new Object [] {"UTF-16LE", false}; + return EncodingInfo.UTF_16_LITTLE_ENDIAN_WITH_BOM; } // default to UTF-8 if we don't have enough bytes to make a // good determination of the encoding if (count < 3) { - return defaultEncoding; + return EncodingInfo.UTF_8; } // UTF-8 with a BOM int b2 = b4[2] & 0xFF; if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) { - return defaultEncoding; + return EncodingInfo.UTF_8_WITH_BOM; } // default to UTF-8 if we don't have enough bytes to make a // good determination of the encoding if (count < 4) { - return defaultEncoding; + return EncodingInfo.UTF_8; } // other encodings int b3 = b4[3] & 0xFF; if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) { // UCS-4, big endian (1234) - return new Object [] {"ISO-10646-UCS-4", true}; + return EncodingInfo.UCS_4_BIG_ENDIAN; } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) { // UCS-4, little endian (4321) - return new Object [] {"ISO-10646-UCS-4", false}; + return EncodingInfo.UCS_4_LITTLE_ENDIAN; } if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) { // UCS-4, unusual octet order (2143) // REVISIT: What should this be? - return new Object [] {"ISO-10646-UCS-4", null}; + return EncodingInfo.UCS_4_UNUSUAL_BYTE_ORDER; } if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) { // UCS-4, unusual octect order (3412) // REVISIT: What should this be? - return new Object [] {"ISO-10646-UCS-4", null}; + return EncodingInfo.UCS_4_UNUSUAL_BYTE_ORDER; } if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) { // UTF-16, big-endian, no BOM // (or could turn out to be UCS-2... // REVISIT: What should this be? - return new Object [] {"UTF-16BE", true}; + return EncodingInfo.UTF_16_BIG_ENDIAN; } if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) { // UTF-16, little-endian, no BOM // (or could turn out to be UCS-2... - return new Object [] {"UTF-16LE", false}; + return EncodingInfo.UTF_16_LITTLE_ENDIAN; } if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) { // EBCDIC // a la xerces1, return CP037 instead of EBCDIC here - return new Object [] {"CP037", null}; + return EncodingInfo.EBCDIC; } - return defaultEncoding; + // default encoding + return EncodingInfo.UTF_8; } // getEncodingName(byte[],int):Object[] @@ -2505,95 +2512,95 @@ protected Object[] getEncodingName(byte[] b4, int count) { * encoding name may be a Java encoding name; * otherwise, it is an ianaEncoding name. * @param isBigEndian For encodings (like uCS-4), whose names cannot - * specify a byte order, this tells whether the order is bigEndian. null menas - * unknown or not relevant. + * specify a byte order, this tells whether the order + * is bigEndian. null if unknown or irrelevant. * * @return Returns a reader. */ protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian) - throws IOException { - - // normalize encoding name - if (encoding == null) { - encoding = "UTF-8"; - } + throws IOException { - // try to use an optimized reader - String ENCODING = encoding.toUpperCase(Locale.ENGLISH); - if (ENCODING.equals("UTF-8")) { - if (DEBUG_ENCODINGS) { - System.out.println("$$$ creating UTF8Reader"); - } - return new UTF8Reader(inputStream, fBufferSize, fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), fErrorReporter.getLocale() ); - } - if (ENCODING.equals("US-ASCII")) { - if (DEBUG_ENCODINGS) { - System.out.println("$$$ creating ASCIIReader"); - } - return new ASCIIReader(inputStream, fBufferSize, fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), fErrorReporter.getLocale()); - } - if(ENCODING.equals("ISO-10646-UCS-4")) { - if(isBigEndian != null) { - boolean isBE = isBigEndian.booleanValue(); - if(isBE) { - return new UCSReader(inputStream, UCSReader.UCS4BE); + String enc = (encoding != null) ? encoding : EncodingInfo.STR_UTF8; + enc = enc.toUpperCase(Locale.ENGLISH); + MessageFormatter f = fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN); + Locale l = fErrorReporter.getLocale(); + switch (enc) { + case EncodingInfo.STR_UTF8: + return new UTF8Reader(inputStream, fBufferSize, f, l); + case EncodingInfo.STR_UTF16: + if (isBigEndian != null) { + return new UTF16Reader(inputStream, fBufferSize, isBigEndian, f, l); + } + break; + case EncodingInfo.STR_UTF16BE: + return new UTF16Reader(inputStream, fBufferSize, true, f, l); + case EncodingInfo.STR_UTF16LE: + return new UTF16Reader(inputStream, fBufferSize, false, f, l); + case EncodingInfo.STR_UCS4: + if(isBigEndian != null) { + if(isBigEndian) { + return new UCSReader(inputStream, UCSReader.UCS4BE); + } else { + return new UCSReader(inputStream, UCSReader.UCS4LE); + } } else { - return new UCSReader(inputStream, UCSReader.UCS4LE); + fErrorReporter.reportError(this.getEntityScanner(), + XMLMessageFormatter.XML_DOMAIN, + "EncodingByteOrderUnsupported", + new Object[] { encoding }, + XMLErrorReporter.SEVERITY_FATAL_ERROR); } - } else { - fErrorReporter.reportError(this.getEntityScanner(),XMLMessageFormatter.XML_DOMAIN, - "EncodingByteOrderUnsupported", - new Object[] { encoding }, - XMLErrorReporter.SEVERITY_FATAL_ERROR); - } - } - if(ENCODING.equals("ISO-10646-UCS-2")) { - if(isBigEndian != null) { // sould never happen with this encoding... - boolean isBE = isBigEndian.booleanValue(); - if(isBE) { - return new UCSReader(inputStream, UCSReader.UCS2BE); + break; + case EncodingInfo.STR_UCS2: + if(isBigEndian != null) { + if(isBigEndian) { + return new UCSReader(inputStream, UCSReader.UCS2BE); + } else { + return new UCSReader(inputStream, UCSReader.UCS2LE); + } } else { - return new UCSReader(inputStream, UCSReader.UCS2LE); + fErrorReporter.reportError(this.getEntityScanner(), + XMLMessageFormatter.XML_DOMAIN, + "EncodingByteOrderUnsupported", + new Object[] { encoding }, + XMLErrorReporter.SEVERITY_FATAL_ERROR); } - } else { - fErrorReporter.reportError(this.getEntityScanner(),XMLMessageFormatter.XML_DOMAIN, - "EncodingByteOrderUnsupported", - new Object[] { encoding }, - XMLErrorReporter.SEVERITY_FATAL_ERROR); - } + break; } // check for valid name boolean validIANA = XMLChar.isValidIANAEncoding(encoding); boolean validJava = XMLChar.isValidJavaEncoding(encoding); if (!validIANA || (fAllowJavaEncodings && !validJava)) { - fErrorReporter.reportError(this.getEntityScanner(),XMLMessageFormatter.XML_DOMAIN, + fErrorReporter.reportError(this.getEntityScanner(), + XMLMessageFormatter.XML_DOMAIN, "EncodingDeclInvalid", new Object[] { encoding }, XMLErrorReporter.SEVERITY_FATAL_ERROR); - // NOTE: AndyH suggested that, on failure, we use ISO Latin 1 - // because every byte is a valid ISO Latin 1 character. - // It may not translate correctly but if we failed on - // the encoding anyway, then we're expecting the content - // of the document to be bad. This will just prevent an - // invalid UTF-8 sequence to be detected. This is only - // important when continue-after-fatal-error is turned - // on. -Ac + // NOTE: AndyH suggested that, on failure, we use ISO Latin 1 + // because every byte is a valid ISO Latin 1 character. + // It may not translate correctly but if we failed on + // the encoding anyway, then we're expecting the content + // of the document to be bad. This will just prevent an + // invalid UTF-8 sequence to be detected. This is only + // important when continue-after-fatal-error is turned + // on. -Ac encoding = "ISO-8859-1"; } // try to use a Java reader - String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING); + String javaEncoding = EncodingMap.getIANA2JavaMapping(enc); if (javaEncoding == null) { - if(fAllowJavaEncodings) { + if (fAllowJavaEncodings) { javaEncoding = encoding; } else { - fErrorReporter.reportError(this.getEntityScanner(),XMLMessageFormatter.XML_DOMAIN, + fErrorReporter.reportError(this.getEntityScanner(), + XMLMessageFormatter.XML_DOMAIN, "EncodingDeclInvalid", new Object[] { encoding }, XMLErrorReporter.SEVERITY_FATAL_ERROR); - // see comment above. - javaEncoding = "ISO8859_1"; + // see comment above. + javaEncoding = "ISO8859_1"; } } if (DEBUG_ENCODINGS) { @@ -2886,108 +2893,78 @@ final void print() { } // print() /** - * Buffer used in entity manager to reuse character arrays instead - * of creating new ones every time. - * - * @xerces.internal - * - * @author Ankit Pasricha, IBM - */ - private static class CharacterBuffer { - - /** character buffer */ - private char[] ch; - - /** whether the buffer is for an external or internal scanned entity */ - private boolean isExternal; - - public CharacterBuffer(boolean isExternal, int size) { - this.isExternal = isExternal; - ch = new char[size]; - } - } - - - /** - * Stores a number of character buffers and provides it to the entity - * manager to use when an entity is seen. + * Information about auto-detectable encodings. * * @xerces.internal * - * @author Ankit Pasricha, IBM + * @author Michael Glavassevich, IBM */ - private static class CharacterBufferPool { - - private static final int DEFAULT_POOL_SIZE = 3; - - private CharacterBuffer[] fInternalBufferPool; - private CharacterBuffer[] fExternalBufferPool; - - private int fExternalBufferSize; - private int fInternalBufferSize; - private int poolSize; - - private int fInternalTop; - private int fExternalTop; - - public CharacterBufferPool(int externalBufferSize, int internalBufferSize) { - this(DEFAULT_POOL_SIZE, externalBufferSize, internalBufferSize); - } - - public CharacterBufferPool(int poolSize, int externalBufferSize, int internalBufferSize) { - fExternalBufferSize = externalBufferSize; - fInternalBufferSize = internalBufferSize; - this.poolSize = poolSize; - init(); - } - - /** Initializes buffer pool. **/ - private void init() { - fInternalBufferPool = new CharacterBuffer[poolSize]; - fExternalBufferPool = new CharacterBuffer[poolSize]; - fInternalTop = -1; - fExternalTop = -1; - } - - /** Retrieves buffer from pool. **/ - public CharacterBuffer getBuffer(boolean external) { - if (external) { - if (fExternalTop > -1) { - return fExternalBufferPool[fExternalTop--]; - } - else { - return new CharacterBuffer(true, fExternalBufferSize); - } - } - else { - if (fInternalTop > -1) { - return fInternalBufferPool[fInternalTop--]; - } - else { - return new CharacterBuffer(false, fInternalBufferSize); - } - } - } - - /** Returns buffer to pool. **/ - public void returnToPool(CharacterBuffer buffer) { - if (buffer.isExternal) { - if (fExternalTop < fExternalBufferPool.length - 1) { - fExternalBufferPool[++fExternalTop] = buffer; - } - } - else if (fInternalTop < fInternalBufferPool.length - 1) { - fInternalBufferPool[++fInternalTop] = buffer; - } - } - - /** Sets the size of external buffers and dumps the old pool. **/ - public void setExternalBufferSize(int bufferSize) { - fExternalBufferSize = bufferSize; - fExternalBufferPool = new CharacterBuffer[poolSize]; - fExternalTop = -1; - } - } + private static class EncodingInfo { + public static final String STR_UTF8 = "UTF-8"; + public static final String STR_UTF16 = "UTF-16"; + public static final String STR_UTF16BE = "UTF-16BE"; + public static final String STR_UTF16LE = "UTF-16LE"; + public static final String STR_UCS4 = "ISO-10646-UCS-4"; + public static final String STR_UCS2 = "ISO-10646-UCS-2"; + public static final String STR_CP037 = "CP037"; + + /** UTF-8 **/ + public static final EncodingInfo UTF_8 = + new EncodingInfo(STR_UTF8, null, false); + + /** UTF-8, with BOM **/ + public static final EncodingInfo UTF_8_WITH_BOM = + new EncodingInfo(STR_UTF8, null, true); + + /** UTF-16, big-endian **/ + public static final EncodingInfo UTF_16_BIG_ENDIAN = + new EncodingInfo(STR_UTF16BE, STR_UTF16, Boolean.TRUE, false); + + /** UTF-16, big-endian with BOM **/ + public static final EncodingInfo UTF_16_BIG_ENDIAN_WITH_BOM = + new EncodingInfo(STR_UTF16BE, STR_UTF16, Boolean.TRUE, true); + + /** UTF-16, little-endian **/ + public static final EncodingInfo UTF_16_LITTLE_ENDIAN = + new EncodingInfo(STR_UTF16LE, STR_UTF16, Boolean.FALSE, false); + + /** UTF-16, little-endian with BOM **/ + public static final EncodingInfo UTF_16_LITTLE_ENDIAN_WITH_BOM = + new EncodingInfo(STR_UTF16LE, STR_UTF16, Boolean.FALSE, true); + + /** UCS-4, big-endian **/ + public static final EncodingInfo UCS_4_BIG_ENDIAN = + new EncodingInfo(STR_UCS4, Boolean.TRUE, false); + + /** UCS-4, little-endian **/ + public static final EncodingInfo UCS_4_LITTLE_ENDIAN = + new EncodingInfo(STR_UCS4, Boolean.FALSE, false); + + /** UCS-4, unusual byte-order (2143) or (3412) **/ + public static final EncodingInfo UCS_4_UNUSUAL_BYTE_ORDER = + new EncodingInfo(STR_UCS4, null, false); + + /** EBCDIC **/ + public static final EncodingInfo EBCDIC = new EncodingInfo(STR_CP037, null, false); + + public final String autoDetectedEncoding; + public final String readerEncoding; + public final Boolean isBigEndian; + public final boolean hasBOM; + + private EncodingInfo(String autoDetectedEncoding, Boolean isBigEndian, boolean hasBOM) { + this(autoDetectedEncoding, autoDetectedEncoding, isBigEndian, hasBOM); + } // <init>(String,Boolean,boolean) + + private EncodingInfo(String autoDetectedEncoding, String readerEncoding, + Boolean isBigEndian, boolean hasBOM) { + this.autoDetectedEncoding = autoDetectedEncoding; + this.readerEncoding = readerEncoding; + this.isBigEndian = isBigEndian; + this.hasBOM = hasBOM; + } // <init>(String,String,Boolean,boolean) + + } // class EncodingInfo /** * This class wraps the byte inputstreams we're presented with. @@ -3040,20 +3017,13 @@ public void rewind() { fOffset = fStartOffset; } - public int read() throws IOException { - int b = 0; - if (fOffset < fLength) { - return fData[fOffset++] & 0xff; - } - if (fOffset == fEndOffset) { - return -1; - } + public int readAndBuffer() throws IOException { if (fOffset == fData.length) { byte[] newData = new byte[fOffset << 1]; System.arraycopy(fData, 0, newData, 0, fOffset); fData = newData; } - b = fInputStream.read(); + final int b = fInputStream.read(); if (b == -1) { fEndOffset = fOffset; return -1; @@ -3063,18 +3033,27 @@ public int read() throws IOException { return b & 0xff; } + public int read() throws IOException { + if (fOffset < fLength) { + return fData[fOffset++] & 0xff; + } + if (fOffset == fEndOffset) { + return -1; + } + if (fCurrentEntity.mayReadChunks) { + return fInputStream.read(); + } + return readAndBuffer(); + } + public int read(byte[] b, int off, int len) throws IOException { - int bytesLeft = fLength - fOffset; + final int bytesLeft = fLength - fOffset; if (bytesLeft == 0) { if (fOffset == fEndOffset) { return -1; } - /** - * //System.out.println("fCurrentEntitty = " + fCurrentEntity ); - * //System.out.println("fInputStream = " + fInputStream ); - * // better get some more for the voracious reader... */ - + // read a block of data as requested if(fCurrentEntity.mayReadChunks || !fCurrentEntity.xmlDeclChunkRead) { if (!fCurrentEntity.xmlDeclChunkRead) @@ -3084,15 +3063,13 @@ public int read(byte[] b, int off, int len) throws IOException { } return fInputStream.read(b, off, len); } - - int returnedVal = read(); - if(returnedVal == -1) { - fEndOffset = fOffset; - return -1; + int returnedVal = readAndBuffer(); + if (returnedVal == -1) { + fEndOffset = fOffset; + return -1; } b[off] = (byte)returnedVal; return 1; - } if (len < bytesLeft) { if (len <= 0) { @@ -3108,8 +3085,7 @@ public int read(byte[] b, int off, int len) throws IOException { return len; } - public long skip(long n) - throws IOException { + public long skip(long n) throws IOException { int bytesLeft; if (n <= 0) { return 0; @@ -3130,7 +3106,7 @@ public long skip(long n) return bytesLeft; } n -= bytesLeft; - /* + /* * In a manner of speaking, when this class isn't permitting more * than one byte at a time to be read, it is "blocking". The * available() method should indicate how much can be read without @@ -3142,13 +3118,13 @@ public long skip(long n) } public int available() throws IOException { - int bytesLeft = fLength - fOffset; + final int bytesLeft = fLength - fOffset; if (bytesLeft == 0) { if (fOffset == fEndOffset) { return -1; } return fCurrentEntity.mayReadChunks ? fInputStream.available() - : 0; + : 0; } return bytesLeft; } @@ -3159,7 +3135,6 @@ public void mark(int howMuch) { public void reset() { fOffset = fMark; - //test(); } public boolean markSupported() { diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/TypeValidator.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/TypeValidator.java index a6061e04f85..59504ec0bd4 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/TypeValidator.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/TypeValidator.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -23,6 +22,8 @@ import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; +import com.sun.org.apache.xerces.internal.util.XMLChar; +import jdk.xml.internal.SecuritySupport; /** * All primitive types plus ID/IDREF/ENTITY/INTEGER are derived from this abstract @@ -35,9 +36,14 @@ * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * + * @LastModified: Apr 2019 */ public abstract class TypeValidator { + private static final boolean USE_CODE_POINT_COUNT_FOR_STRING_LENGTH = + Boolean.parseBoolean(SecuritySupport.getSystemProperty( + "com.sun.org.apache.xerces.internal.impl.dv.xs.useCodePointCountForStringLength", "false")); + // which facets are allowed for this type public abstract short getAllowedFacets(); @@ -82,7 +88,14 @@ public int compare(Object value1, Object value2) { // get the length of the value // the parameters are in compiled form (from getActualValue) public int getDataLength(Object value) { - return (value instanceof String) ? ((String)value).length() : -1; + if (value instanceof String) { + final String str = (String)value; + if (!USE_CODE_POINT_COUNT_FOR_STRING_LENGTH) { + return str.length(); + } + return getCodePointLength(str); + } + return -1; } // get the number of digits of the value @@ -97,6 +110,25 @@ public int getFractionDigits(Object value) { return -1; } + // Returns the length of the string in Unicode code points. + private int getCodePointLength(String value) { + // Count the number of surrogate pairs, and subtract them from + // the total length. + final int len = value.length(); + int surrogatePairCount = 0; + for (int i = 0; i < len - 1; ++i) { + if (XMLChar.isHighSurrogate(value.charAt(i))) { + if (XMLChar.isLowSurrogate(value.charAt(++i))) { + ++surrogatePairCount; + } + else { + --i; + } + } + } + return len - surrogatePairCount; + } + // check whether the character is in the range 0x30 ~ 0x39 public static final boolean isDigit(char ch) { return ch >= '0' && ch <= '9'; diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties index 423728021cf..10a800d04ec 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties @@ -39,7 +39,6 @@ cvc-complex-type.2.4.b = cvc-complex-type.2.4.b: The content of element ''{0}'' is not complete. One of ''{1}'' is expected. cvc-complex-type.2.4.c = cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ''{0}''. cvc-complex-type.2.4.d = cvc-complex-type.2.4.d: Invalid content was found starting with element ''{0}''. No child element is expected at this point. - cvc-complex-type.2.4.d.1 = cvc-complex-type.2.4.d: Invalid content was found starting with element ''{0}''. No child element ''{1}'' is expected at this point. cvc-complex-type.2.4.e = cvc-complex-type.2.4.e: ''{0}'' can occur a maximum of ''{2}'' times in the current sequence. This limit was exceeded. At this point one of ''{1}'' is expected. cvc-complex-type.2.4.f = cvc-complex-type.2.4.f: ''{0}'' can occur a maximum of ''{1}'' times in the current sequence. This limit was exceeded. No child element is expected at this point. cvc-complex-type.2.4.g = cvc-complex-type.2.4.g: Invalid content was found starting with element ''{0}''. ''{1}'' is expected to occur a minimum of ''{2}'' times in the current sequence. One more instance is required to satisfy this constraint. @@ -103,7 +102,7 @@ src-ct.1 = src-ct.1: Complex Type Definition Representation Error for type ''{0}''. When <complexContent> is used, the base type must be a complexType. ''{1}'' is a simpleType. src-ct.2.1 = src-ct.2.1: Complex Type Definition Representation Error for type ''{0}''. When <simpleContent> is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type. ''{1}'' satisfies none of these conditions. src-ct.2.2 = src-ct.2.2: Complex Type Definition Representation Error for type ''{0}''. When a complexType with simpleContent restricts a complexType with mixed content and emptiable particle, then there must be a <simpleType> among the children of <restriction>. - src-ct.4 = src-ct.4: Complex Type Definition Representation Error for type ''{0}''. The intersection of wildcards is not expressible. + src-ct.4 = src-ct.4: Complex Type Definition Representation Error for type ''{0}''. The intersection of wildcards is not expressible. src-ct.5 = src-ct.5: Complex Type Definition Representation Error for type ''{0}''. The union of wildcards is not expressible. src-element.1 = src-element.1: The properties ''default'' and ''fixed'' cannot both be present in element declaration ''{0}''. Use only one of them. src-element.2.1 = src-element.2.1: : One of 'ref' or 'name' must be present in a local element declaration. @@ -234,14 +233,14 @@ rcase-MapAndSum.2 = rcase-MapAndSum.2: Group''s occurrence range, ({0},{1}), is not a valid restriction of base group''s occurrence range, ({2},{3}). rcase-NameAndTypeOK.1 = rcase-NameAndTypeOK.1: Elements have names and target namespaces which are not the same: Element ''{0}'' in namespace ''{1}'' and element ''{2}'' in namespace ''{3}''. rcase-NameAndTypeOK.2 = rcase-NameAndTypeOK.2: Error for the particle whose '{'term'}' is the element declaration ''{0}''. The element declaration''s '{'nillable'}' is true, but the corresponding particle in the base type has an element declaration whose '{'nillable'}' is false. - rcase-NameAndTypeOK.3 = rcase-NameAndTypeOK.3: Error for the particle whose '{'term'}' is the element declaration ''{0}''. Its occurrence range, ({1},{2}), is not a valid restriction of the range, ({3},{4}, of the corresponding particle in the base type. + rcase-NameAndTypeOK.3 = rcase-NameAndTypeOK.3: Error for the particle whose '{'term'}' is the element declaration ''{0}''. Its occurrence range, ({1},{2}), is not a valid restriction of the range, ({3},{4}), of the corresponding particle in the base type. rcase-NameAndTypeOK.4.a = rcase-NameAndTypeOK.4.a: Element ''{0}'' is not fixed, but the corresponding element in the base type is fixed with value ''{1}''. rcase-NameAndTypeOK.4.b = rcase-NameAndTypeOK.4.b: Element ''{0}'' is fixed with value ''{1}'', but the corresponding element in the base type is fixed with value ''{2}''. rcase-NameAndTypeOK.5 = rcase-NameAndTypeOK.5: Identity constraints for element ''{0}'' are not a subset of those in base. rcase-NameAndTypeOK.6 = rcase-NameAndTypeOK.6: The disallowed substitutions for element ''{0}'' are not a superset of those in the base. rcase-NameAndTypeOK.7 = rcase-NameAndTypeOK.7: The type of element ''{0}'', ''{1}'', is not derived from the type of the base element, ''{2}''. rcase-NSCompat.1 = rcase-NSCompat.1: Element ''{0}'' has a namespace ''{1}'' which is not allowed by the wildcard in the base. - rcase-NSCompat.2 = rcase-NSCompat.2: Error for the particle whose '{'term'}' is the element declaration ''{0}''. Its occurrence range, ({1},{2}), is not a valid restriction of the range, ({3},{4}, of the corresponding particle in the base type. + rcase-NSCompat.2 = rcase-NSCompat.2: Error for the particle whose '{'term'}' is the element declaration ''{0}''. Its occurrence range, ({1},{2}), is not a valid restriction of the range, ({3},{4}), of the corresponding particle in the base type. rcase-NSRecurseCheckCardinality.1 = rcase-NSRecurseCheckCardinality.1: There is not a complete functional mapping between the particles. rcase-NSRecurseCheckCardinality.2 = rcase-NSRecurseCheckCardinality.2: Group''s occurrence range, ({0},{1}), is not a valid restriction of base wildcard''s range, ({2},{3}). rcase-NSSubset.1 = rcase-NSSubset.1: Wildcard is not a subset of corresponding wildcard in base. @@ -286,15 +285,15 @@ EmptyTargetNamespace = EmptyTargetNamespace: In schema document ''{0}'', the value of the ''targetNamespace'' attribute cannot be an empty string. FacetValueFromBase = FacetValueFromBase: In the declaration of type ''{0}'', value ''{1}'' of facet ''{2}'' must be from the value space of the base type, ''{3}''. FixedFacetValue = FixedFacetValue: In the definition of {3}, the value ''{1}'' for the facet ''{0}'' is invalid, because the value for ''{0}'' has been set to ''{2}'' in one of the ancestor types, and '{'fixed'}' = true. - InvalidRegex = InvalidRegex: Pattern value ''{0}'' is not a valid regular expression. The reported error was: ''{1}'' at column ''{2}''. - MaxOccurLimit = Current configuration of the parser doesn''t allow a maxOccurs attribute value to be set greater than the value {0}. + InvalidRegex = InvalidRegex: Pattern value ''{0}'' is not a valid regular expression. The reported error was: ''{1}''. + MaxOccurLimit = Current configuration of the parser doesn''t allow the expansion of a content model for a complex type to contain more than {0} nodes. PublicSystemOnNotation = PublicSystemOnNotation: At least one of ''public'' and ''system'' must appear in element ''notation''. SchemaLocation = SchemaLocation: schemaLocation value = ''{0}'' must have even number of URI''s. TargetNamespace.1 = TargetNamespace.1: Expecting namespace ''{0}'', but the target namespace of the schema document is ''{1}''. TargetNamespace.2 = TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of ''{1}''. UndeclaredEntity = UndeclaredEntity: Entity ''{0}'' is not declared. UndeclaredPrefix = UndeclaredPrefix: Cannot resolve ''{0}'' as a QName: the prefix ''{1}'' is not declared. - + FacetsContradict = FacetsContradict: For simpleType definition ''{2}'', the enumeration value ''{0}'' contradicts with value of ''{1}'' facet. # JAXP 1.2 schema source property errors diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java index fa8e287f355..f5daf3e366b 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java @@ -23,6 +23,8 @@ import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; import com.sun.org.apache.xerces.internal.impl.dv.XSFacets; import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; +import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; +import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl; import com.sun.org.apache.xerces.internal.impl.validation.ValidationState; import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar; import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols; @@ -42,6 +44,7 @@ import com.sun.org.apache.xerces.internal.xni.QName; import com.sun.org.apache.xerces.internal.xs.XSAttributeUse; import com.sun.org.apache.xerces.internal.xs.XSObjectList; +import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition; import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; import java.util.ArrayList; import java.util.List; @@ -280,6 +283,7 @@ static final class FacetInfo { } FacetInfo traverseFacets(Element content, + XSTypeDefinition typeDef, XSSimpleType baseValidator, XSDocumentInfo schemaDoc) { @@ -293,6 +297,9 @@ FacetInfo traverseFacets(Element content, List<NamespaceContext> enumNSDecls = hasQName ? new ArrayList<>() : null; int currentFacet = 0; xsFacets.reset(); + boolean seenPattern = false; + Element contextNode = (Element)content.getParentNode(); + boolean hasLengthFacet = false, hasMinLengthFacet = false, hasMaxLengthFacet = false; while (content != null) { // General Attribute Checking Object[] attrs = null; @@ -364,7 +371,6 @@ FacetInfo traverseFacets(Element content, } } else if (facet.equals(SchemaSymbols.ELT_PATTERN)) { - facetsPresent |= XSSimpleType.FACET_PATTERN; attrs = fAttrChecker.checkAttributes(content, false, schemaDoc); String patternVal = (String)attrs[XSAttributeChecker.ATTIDX_VALUE]; // The facet can't be used if the value is missing. Ignore @@ -376,6 +382,7 @@ else if (facet.equals(SchemaSymbols.ELT_PATTERN)) { continue; } + seenPattern = true; if (fPattern.length() == 0) { fPattern.append(patternVal); } else { @@ -477,9 +484,11 @@ else if (facet.equals(SchemaSymbols.ELT_LENGTH)) { switch (currentFacet) { case XSSimpleType.FACET_MINLENGTH: xsFacets.minLength = ((XInt)attrs[XSAttributeChecker.ATTIDX_VALUE]).intValue(); + hasMinLengthFacet = true; break; case XSSimpleType.FACET_MAXLENGTH: xsFacets.maxLength = ((XInt)attrs[XSAttributeChecker.ATTIDX_VALUE]).intValue(); + hasMaxLengthFacet = true; break; case XSSimpleType.FACET_MAXEXCLUSIVE: xsFacets.maxExclusive = (String)attrs[XSAttributeChecker.ATTIDX_VALUE]; @@ -504,6 +513,7 @@ else if (facet.equals(SchemaSymbols.ELT_LENGTH)) { break; case XSSimpleType.FACET_LENGTH: xsFacets.length = ((XInt)attrs[XSAttributeChecker.ATTIDX_VALUE]).intValue(); + hasLengthFacet = true; break; } @@ -566,16 +576,148 @@ else if (facet.equals(SchemaSymbols.ELT_LENGTH)) { xsFacets.enumNSDecls = enumNSDecls; xsFacets.enumAnnotations = enumAnnotations; } - if ((facetsPresent & XSSimpleType.FACET_PATTERN) != 0) { + if (seenPattern) { + facetsPresent |= XSSimpleType.FACET_PATTERN; xsFacets.pattern = fPattern.toString(); xsFacets.patternAnnotations = patternAnnotations; } fPattern.setLength(0); + // check if length, minLength and maxLength facets contradict with enumeration facets. + // currently considers the case when the baseValidator is a built-in type. + if (enumData != null) { + if (hasLengthFacet) { + checkEnumerationAndLengthInconsistency(baseValidator, enumData, contextNode, getSchemaTypeName(typeDef)); + } + if (hasMinLengthFacet) { + checkEnumerationAndMinLengthInconsistency(baseValidator, enumData, contextNode, getSchemaTypeName(typeDef)); + } + if (hasMaxLengthFacet) { + checkEnumerationAndMaxLengthInconsistency(baseValidator, enumData, contextNode, getSchemaTypeName(typeDef)); + } + } + return new FacetInfo(xsFacets, content, facetsPresent, facetsFixed); } + /* + * Get name of an XSD type definition as a string value (which will typically be the value of "name" attribute of a + * type definition, or an internal name determined by the validator for anonymous types). + */ + public static String getSchemaTypeName(XSTypeDefinition typeDefn) { + + String typeNameStr = ""; + if (typeDefn instanceof XSSimpleTypeDefinition) { + typeNameStr = ((XSSimpleTypeDecl) typeDefn).getTypeName(); + } + else { + typeNameStr = ((XSComplexTypeDecl) typeDefn).getTypeName(); + } + + return typeNameStr; + + } // getSchemaTypeName + + /* + * Check whether values of xs:maxLength and xs:enumeration are consistent. Report a warning message if they are not. + */ + private void checkEnumerationAndMaxLengthInconsistency(XSSimpleType baseValidator, List<String> enumData, Element contextNode, String typeName) { + if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(baseValidator.getNamespace()) && + SchemaSymbols.ATTVAL_HEXBINARY.equals(baseValidator.getName())) { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + if (enumVal.length() / 2 > xsFacets.maxLength) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_MAXLENGTH, typeName}, contextNode); + } + } + } + else if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(baseValidator.getNamespace()) && + SchemaSymbols.ATTVAL_BASE64BINARY.equals(baseValidator.getName())) { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + byte[] decodedVal = Base64.decode(enumVal); + if (decodedVal != null && (new String(decodedVal)).length() > xsFacets.maxLength) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_MAXLENGTH, typeName}, contextNode); + } + } + } + else { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + if (enumVal.length() > xsFacets.maxLength) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_MAXLENGTH, typeName}, contextNode); + } + } + } + } // checkEnumerationAndMaxLengthInconsistency + + /* + * Check whether values of xs:minLength and xs:enumeration are consistent. Report a warning message if they are not. + */ + private void checkEnumerationAndMinLengthInconsistency(XSSimpleType baseValidator, List<String> enumData, Element contextNode, String typeName) { + if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(baseValidator.getNamespace()) && + SchemaSymbols.ATTVAL_HEXBINARY.equals(baseValidator.getName())) { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + if (enumVal.length() / 2 < xsFacets.minLength) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_MINLENGTH, typeName}, contextNode); + } + } + } + else if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(baseValidator.getNamespace()) && + SchemaSymbols.ATTVAL_BASE64BINARY.equals(baseValidator.getName())) { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + byte[] decodedVal = Base64.decode(enumVal); + if (decodedVal != null && (new String(decodedVal)).length() < xsFacets.minLength) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_MINLENGTH, typeName}, contextNode); + } + } + } + else { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + if (enumVal.length() < xsFacets.minLength) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_MINLENGTH, typeName}, contextNode); + } + } + } + } // checkEnumerationAndMinLengthInconsistency + + /* + * Check whether values of xs:length and xs:enumeration are consistent. Report a warning message if they are not. + */ + private void checkEnumerationAndLengthInconsistency(XSSimpleType baseValidator, List<String> enumData, Element contextNode, String typeName) { + if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(baseValidator.getNamespace()) && + SchemaSymbols.ATTVAL_HEXBINARY.equals(baseValidator.getName())) { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + if (enumVal.length() / 2 != xsFacets.length) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_LENGTH, typeName}, contextNode); + } + } + } + else if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(baseValidator.getNamespace()) && + SchemaSymbols.ATTVAL_BASE64BINARY.equals(baseValidator.getName())) { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + byte[] decodedVal = Base64.decode(enumVal); + if (decodedVal != null && (new String(decodedVal)).length() != xsFacets.length) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_LENGTH, typeName}, contextNode); + } + } + } + else { + for (int enumIdx = 0; enumIdx < enumData.size(); enumIdx++) { + String enumVal = (enumData.get(enumIdx)); + if (enumVal.length() != xsFacets.length) { + reportSchemaWarning("FacetsContradict", new Object[]{enumVal, SchemaSymbols.ELT_LENGTH, typeName}, contextNode); + } + } + } + } // checkEnumerationAndLengthInconsistency + // return whether QName/NOTATION is part of the given type private boolean containsQName(XSSimpleType type) { @@ -724,6 +866,10 @@ void reportSchemaError (String key, Object[] args, Element ele) { fSchemaHandler.reportSchemaError(key, args, ele); } + void reportSchemaWarning (String key, Object[] args, Element ele) { + fSchemaHandler.reportSchemaWarning(key, args, ele); + } + /** * Element/Attribute traversers call this method to check whether * the type is NOTATION without enumeration facet diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java index 7e8f96e3499..fb059b0b51a 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -62,7 +62,7 @@ * </complexType> * * @xerces.internal - * + * @LastModified: Apr 2019 */ class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser { @@ -574,7 +574,7 @@ else if (fDerivedBy == XSConstants.DERIVATION_RESTRICTION && short fixedFacets = 0 ; if (simpleContent!=null) { - FacetInfo fi = traverseFacets(simpleContent, baseValidator, schemaDoc); + FacetInfo fi = traverseFacets(simpleContent, fComplexTypeDecl, baseValidator, schemaDoc); attrNode = fi.nodeAfterFacets; facetData = fi.facetdata; presentFacets = fi.fPresentFacets; @@ -1193,9 +1193,6 @@ private void handleComplexTypeError(String messageId,Object[] args, // REVISIT: do we need to remove all attribute uses already added into // the attribute group? maybe it's ok to leave them there. -SG fAttrGrp.fAttributeWC = getErrorWildcard(); - - return; - } private void contentBackup() { diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java index d9898b2157a..542c2d10417 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -60,6 +60,7 @@ import com.sun.org.apache.xerces.internal.util.SymbolHash; import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException; +import com.sun.org.apache.xerces.internal.util.XMLChar; import com.sun.org.apache.xerces.internal.util.XMLSymbols; import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; @@ -129,7 +130,7 @@ * @author Neil Graham, IBM * @author Pavani Mukthipudi, Sun Microsystems * - * @LastModified: Nov 2017 + * @LastModified: Apr 2019 */ @SuppressWarnings("deprecation") //org.xml.sax.helpers.XMLReaderFactory public class XSDHandler { @@ -591,10 +592,27 @@ else if (is instanceof XSInputSource) { } //is instanceof XMLInputSource if (schemaRoot == null) { - // something went wrong right off the hop if (is instanceof XSInputSource) { - return fGrammarBucket.getGrammar(desc.getTargetNamespace()); + // Need to return a grammar. If the XSInputSource has a list + // of grammar objects, then get the first one and return it. + // If it has a list of components, then get the grammar that + // contains the first component and return it. + // If we return null, the XMLSchemaLoader will think nothing + // was loaded, and will not try to put the grammar objects + // into the grammar pool. + XSInputSource xsinput = (XSInputSource)is; + SchemaGrammar[] grammars = xsinput.getGrammars(); + if (grammars != null && grammars.length > 0) { + grammar = fGrammarBucket.getGrammar(grammars[0].getTargetNamespace()); + } + else { + XSObject[] components = xsinput.getComponents(); + if (components != null && components.length > 0) { + grammar = fGrammarBucket.getGrammar(components[0].getNamespace()); + } + } } + // something went wrong right off the hop return grammar; } @@ -1299,6 +1317,7 @@ else if (DOMUtil.getLocalName(globalComp).equals(SchemaSymbols.ELT_REDEFINE)) { String qName = currSchemaDoc.fTargetNamespace == null ? ","+lName: currSchemaDoc.fTargetNamespace +","+lName; + qName = XMLChar.trim(qName); String componentType = DOMUtil.getLocalName(redefineComp); if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) { checkForDuplicateNames(qName, ATTRIBUTEGROUP_TYPE, fUnparsedAttributeGroupRegistry, fUnparsedAttributeGroupRegistrySub, redefineComp, currSchemaDoc); @@ -1343,6 +1362,7 @@ else if (componentType.equals(SchemaSymbols.ELT_GROUP)) { String qName = currSchemaDoc.fTargetNamespace == null? ","+lName: currSchemaDoc.fTargetNamespace +","+lName; + qName = XMLChar.trim(qName); String componentType = DOMUtil.getLocalName(globalComp); if (componentType.equals(SchemaSymbols.ELT_ATTRIBUTE)) { @@ -2466,9 +2486,15 @@ private Element getSchemaDocument(String schemaNamespace, StAXInputSource schema return getSchemaDocument0(key, schemaId, schemaElement); } catch (XMLStreamException e) { - StAXLocationWrapper slw = new StAXLocationWrapper(); - slw.setLocation(e.getLocation()); - throw new XMLParseException(slw, e.getMessage(), e); + Throwable t = e.getNestedException(); + if (t instanceof IOException) { + exception = (IOException) t; + } + else { + StAXLocationWrapper slw = new StAXLocationWrapper(); + slw.setLocation(e.getLocation()); + throw new XMLParseException(slw, e.getMessage(), e); + } } catch (IOException e) { exception = e; @@ -2741,16 +2767,29 @@ private void addNewGrammarLocations(SchemaGrammar srcGrammar, SchemaGrammar dstG @SuppressWarnings("unchecked") private void addNewImportedGrammars(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) { - final ArrayList<SchemaGrammar> igs1 = (ArrayList<SchemaGrammar>)srcGrammar.getImportedGrammars(); - if (igs1 != null) { - ArrayList<SchemaGrammar> igs2 = (ArrayList<SchemaGrammar>)dstGrammar.getImportedGrammars(); - - if (igs2 == null) { - igs2 = (ArrayList<SchemaGrammar>)igs1.clone(); - dstGrammar.setImportedGrammars(igs2); - } - else { - updateImportList(igs1, igs2); + final ArrayList<SchemaGrammar> src = (ArrayList<SchemaGrammar>)srcGrammar.getImportedGrammars(); + if (src != null) { + ArrayList<SchemaGrammar> dst = (ArrayList<SchemaGrammar>)dstGrammar.getImportedGrammars(); + if (dst == null) { + dst = new ArrayList<>(); + dstGrammar.setImportedGrammars(dst); + } + for (SchemaGrammar sg :src) { + // Can't use the object from the source import list directly. + // It's possible there is already a grammar with the same + // namespace in the bucket but a different object. + // This can happen if the bucket has grammar A1, and we try + // to add B and A2, where A2 imports B. When B is added, we + // create a new object B' and store it in the bucket. Then we + // try to merge A2 and A1. We can't use B. Need to get B' from + // the bucket and store it in A's import list. + SchemaGrammar sg1 = fGrammarBucket.getGrammar(sg.getTargetNamespace()); + if (sg1 != null) { + sg = sg1; + } + if (!containedImportedGrammar(dst, sg)) { + dst.add(sg); + } } } } @@ -3162,7 +3201,7 @@ private void expandRelatedModelGroupComponents(XSModelGroup modelGroup, List<XSO private void addRelatedType(XSTypeDefinition type, List<XSObject> componentList, String namespace, Map<String, List<String>> dependencies) { if (!type.getAnonymous()) { - if (!type.getNamespace().equals(SchemaSymbols.URI_SCHEMAFORSCHEMA)) { //REVISIT - do we use == instead + if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(type.getNamespace())) { //REVISIT - do we use == instead if (!componentList.contains(type)) { final List<String> importedNamespaces = findDependentNamespaces(namespace, dependencies); addNamespaceDependency(namespace, type.getNamespace(), importedNamespaces); diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java index a9648915d20..12eca0314a5 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java @@ -395,7 +395,7 @@ else if (union) { } // now traverse facets, if it's derived by restriction if (restriction && content != null) { - FacetInfo fi = traverseFacets(content, baseValidator, schemaDoc); + FacetInfo fi = traverseFacets(content, newDecl, baseValidator, schemaDoc); content = fi.nodeAfterFacets; try { diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java index 7eca1d312da..377bb108750 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -23,11 +23,11 @@ import com.sun.org.apache.xerces.internal.impl.Constants; import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager; import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; +import java.util.List; import java.util.Map; -import java.util.Set; /** * This class implements the basic operations for managing parser @@ -42,6 +42,7 @@ * * @author Andy Clark, IBM * + * @LastModified: Apr 2019 */ public class ParserConfigurationSettings implements XMLComponentManager { @@ -56,13 +57,13 @@ public class ParserConfigurationSettings // data /** Recognized properties. */ - protected Set<String> fRecognizedProperties; + protected List<String> fRecognizedProperties; /** Properties. */ protected Map<String, Object> fProperties; /** Recognized features. */ - protected Set<String> fRecognizedFeatures; + protected List<String> fRecognizedFeatures; /** Features. */ protected Map<String, Boolean> fFeatures; @@ -86,8 +87,8 @@ public ParserConfigurationSettings() { public ParserConfigurationSettings(XMLComponentManager parent) { // create storage for recognized features and properties - fRecognizedFeatures = new HashSet<>(); - fRecognizedProperties = new HashSet<>(); + fRecognizedFeatures = new ArrayList<>(); + fRecognizedProperties = new ArrayList<>(); // create table for features and properties fFeatures = new HashMap<>(); @@ -195,7 +196,7 @@ public void setProperty(String propertyId, Object value) * a critical error. */ @Override - public final boolean getFeature(String featureId) + public boolean getFeature(String featureId) throws XMLConfigurationException { FeatureState state = getFeatureState(featureId); @@ -222,7 +223,7 @@ public FeatureState getFeatureState(String featureId) { FeatureState checkState = checkFeature(featureId); if (checkState.isExceptional()) { return checkState; - } + } return FeatureState.is(false); } return FeatureState.is(state); @@ -241,7 +242,7 @@ public FeatureState getFeatureState(String featureId) { * a critical error. */ @Override - public final Object getProperty(String propertyId) + public Object getProperty(String propertyId) throws XMLConfigurationException { PropertyState state = getPropertyState(propertyId); @@ -270,7 +271,7 @@ public PropertyState getPropertyState(String propertyId) { PropertyState state = checkProperty(propertyId); if (state.isExceptional()) { return state; - } + } } return PropertyState.is(propertyValue); @@ -325,7 +326,7 @@ protected PropertyState checkProperty(String propertyId) PropertyState state = fParentSettings.getPropertyState(propertyId); if (state.isExceptional()) { return state; - } + } } else { return PropertyState.NOT_RECOGNIZED; diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/XPath.java b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/XPath.java index 8a2c5b813be..f6102777054 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/XPath.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/XPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -40,7 +40,7 @@ * The XPath class wraps an expression object and provides general services * for execution of that expression. * @xsl.usage advanced - * @LastModified: Oct 2017 + * @LastModified: May 2019 */ public class XPath implements Serializable, ExpressionOwner { @@ -179,10 +179,12 @@ public XPath( else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver); else - throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type); + throw new RuntimeException(XSLMessages.createXPATHMessage( + XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, + new Object[]{Integer.toString(type)})); // System.out.println("----------------"); - Expression expr = compiler.compile(0); + Expression expr = compiler.compileExpression(0); // System.out.println("expr: "+expr); this.setExpression(expr); @@ -234,7 +236,7 @@ else if (MATCH == type) //"Can not deal with XPath type: " + type); // System.out.println("----------------"); - Expression expr = compiler.compile(0); + Expression expr = compiler.compileExpression(0); // System.out.println("expr: "+expr); this.setExpression(expr); diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/FilterExprWalker.java b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/FilterExprWalker.java index 2f61f070216..1ab4d9653a6 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/FilterExprWalker.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/FilterExprWalker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -37,7 +37,7 @@ * Walker for the OP_VARIABLE, or OP_EXTFUNCTION, or OP_FUNCTION, or OP_GROUP, * op codes. * @see <a href="http://www.w3.org/TR/xpath#NT-FilterExpr">XPath FilterExpr descriptions</a> - * @LastModified: Oct 2017 + * @LastModified: May 2019 */ public class FilterExprWalker extends AxesWalker { @@ -77,7 +77,7 @@ public void init(Compiler compiler, int opPos, int stepType) m_mustHardReset = true; case OpCodes.OP_GROUP : case OpCodes.OP_VARIABLE : - m_expr = compiler.compile(opPos); + m_expr = compiler.compileExpression(opPos); m_expr.exprSetParent(this); //if((OpCodes.OP_FUNCTION == stepType) && (m_expr instanceof com.sun.org.apache.xalan.internal.templates.FuncKey)) if(m_expr instanceof com.sun.org.apache.xpath.internal.operations.Variable) @@ -87,7 +87,7 @@ public void init(Compiler compiler, int opPos, int stepType) } break; default : - m_expr = compiler.compile(opPos + 2); + m_expr = compiler.compileExpression(opPos + 2); m_expr.exprSetParent(this); } // if(m_expr instanceof WalkingIterator) diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java index fe3756060b4..2120541a6f6 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -41,7 +41,7 @@ * which are built from the opcode map output, and an analysis engine * for the location path expressions in order to provide optimization hints. * - * @LastModified: Oct 2017 + * @LastModified: May 2019 */ public class WalkerFactory { @@ -1008,10 +1008,10 @@ private static StepPattern createDefaultStepPattern( case OpCodes.OP_EXTFUNCTION : case OpCodes.OP_FUNCTION : case OpCodes.OP_GROUP : - expr = compiler.compile(opPos); + expr = compiler.compileExpression(opPos); break; default : - expr = compiler.compile(opPos + 2); + expr = compiler.compileExpression(opPos + 2); } axis = Axis.FILTEREDLIST; diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Compiler.java b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Compiler.java index 4d0c68f315b..1b6ad648eb9 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Compiler.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Compiler.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -70,9 +69,12 @@ * of operation codes (op map) and then builds from that into an Expression * tree. * @xsl.usage advanced + * @LastModified: May 2019 */ public class Compiler extends OpMap { + // count the number of operations or calls to compileOperation + int countOp; /** * Construct a Compiler object with a specific ErrorListener and @@ -106,15 +108,40 @@ public Compiler() /** * Execute the XPath object from a given opcode position. + * + * Note that this method is added so that when StackOverflowError is caught + * the address space can be freed to this point allowing further activities + * such as reporting the error. + * * @param opPos The current position in the xpath.m_opMap array. * @return The result of the XPath. * * @throws TransformerException if there is a syntax or other error. * @xsl.usage advanced */ - public Expression compile(int opPos) throws TransformerException - { + public Expression compileExpression(int opPos) throws TransformerException + { + try { + countOp = 0; + return compile(opPos); + } catch (StackOverflowError sof) { + error(XPATHErrorResources.ER_COMPILATION_TOO_MANY_OPERATION, new Object[]{countOp}); + } + return null; + } + /** + * This method handles the actual compilation process. It is called from the + * compileExpression method as well as the subsequent processes. See the note + * for compileExpression. + * + * @param opPos The current position in the xpath.m_opMap array. + * @return The result of the XPath. + * + * @throws TransformerException if there is a syntax or other error. + */ + private Expression compile(int opPos) throws TransformerException + { int op = getOp(opPos); Expression expr = null; @@ -210,6 +237,7 @@ public Expression compile(int opPos) throws TransformerException private Expression compileOperation(Operation operation, int opPos) throws TransformerException { + ++countOp; int leftPos = getFirstChildPos(opPos); int rightPos = getNextOpPos(leftPos); diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/XPathParser.java b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/XPathParser.java index 54b9ff3d695..dcf044593b0 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/XPathParser.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/XPathParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -34,6 +34,7 @@ * Tokenizes and parses XPath expressions. This should really be named * XPathParserImpl, and may be renamed in the future. * @xsl.usage general + * @LastModified: May 2019 */ public class XPathParser { @@ -71,6 +72,9 @@ public class XPathParser protected final static int FILTER_MATCH_PRIMARY = 1; protected final static int FILTER_MATCH_PREDICATES = 2; + // counts open predicates + private int countPredicate; + /** * The parser constructor. */ @@ -157,6 +161,9 @@ public void initXPath( } else throw e; + } catch (StackOverflowError sof) { + error(XPATHErrorResources.ER_PREDICATE_TOO_MANY_OPEN, + new Object[]{m_token, m_queueMark, countPredicate}); } compiler.shrink(); @@ -190,7 +197,12 @@ public void initMatchPattern( m_ops.setOp(OpMap.MAPINDEX_LENGTH, 2); nextToken(); - Pattern(); + try { + Pattern(); + } catch (StackOverflowError sof) { + error(XPATHErrorResources.ER_PREDICATE_TOO_MANY_OPEN, + new Object[]{m_token, m_queueMark, countPredicate}); + } if (null != m_token) { @@ -741,7 +753,7 @@ void appendOp(int length, int op) */ protected void Expr() throws javax.xml.transform.TransformerException { - OrExpr(); + OrExpr(); } /** @@ -1883,11 +1895,12 @@ protected void NodeTest(int axesType) throws javax.xml.transform.TransformerExce */ protected void Predicate() throws javax.xml.transform.TransformerException { - if (tokenIs('[')) { + countPredicate++; nextToken(); PredicateExpr(); + countPredicate--; consumeExpected(']'); } } diff --git a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java index 5fca3457283..54e4fe7b646 100644 --- a/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java +++ b/src/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/res/XPATHErrorResources.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -32,6 +31,7 @@ * Also you need to update the count of messages(MAX_CODE)or * the count of warnings(MAX_WARNING) [ Information purpose only] * @xsl.usage advanced + * @LastModified: May 2019 */ public class XPATHErrorResources extends ListResourceBundle { @@ -150,6 +150,10 @@ public class XPATHErrorResources extends ListResourceBundle "ER_FOUND_COMMA_BUT_NO_FOLLOWING_ARG"; public static final String ER_PREDICATE_ILLEGAL_SYNTAX = "ER_PREDICATE_ILLEGAL_SYNTAX"; + public static final String ER_PREDICATE_TOO_MANY_OPEN = + "ER_PREDICATE_TOO_MANY_OPEN"; + public static final String ER_COMPILATION_TOO_MANY_OPERATION = + "ER_COMPILATION_TOO_MANY_OPERATION"; public static final String ER_ILLEGAL_AXIS_NAME = "ER_ILLEGAL_AXIS_NAME"; public static final String ER_UNKNOWN_NODETYPE = "ER_UNKNOWN_NODETYPE"; public static final String ER_PATTERN_LITERAL_NEEDS_BE_QUOTED = @@ -464,6 +468,12 @@ public class XPATHErrorResources extends ListResourceBundle { ER_PREDICATE_ILLEGAL_SYNTAX, "'..[predicate]' or '.[predicate]' is illegal syntax. Use 'self::node()[predicate]' instead."}, + { ER_PREDICATE_TOO_MANY_OPEN, + "Stack overflow while parsing {0} at {1}. Too many open predicates({2})."}, + + { ER_COMPILATION_TOO_MANY_OPERATION, + "Stack overflow while compiling the expression. Too many operations({0})."}, + { ER_ILLEGAL_AXIS_NAME, "illegal axis name: {0}"}, diff --git a/src/src/java.xml/share/legal/xerces.md b/src/src/java.xml/share/legal/xerces.md index ff0167bc835..d09141b1be9 100644 --- a/src/src/java.xml/share/legal/xerces.md +++ b/src/src/java.xml/share/legal/xerces.md @@ -1,14 +1,14 @@ -## Apache Xerces v2.11.0 +## Apache Xerces v2.12.0 ### Apache Xerces Notice <pre> ========================================================================= - == NOTICE file corresponding to section 4(d) of the Apache License, == - == Version 2.0, in this case for the Apache Xerces Java distribution. == + == NOTICE file corresponding to section 4(d) of the Apache License, == + == Version 2.0, in this case for the Apache Xerces Java distribution. == ========================================================================= Apache Xerces Java - Copyright 1999-2010 The Apache Software Foundation + Copyright 1999-2018 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). Portions of this software were originally based on the following: diff --git a/src/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java b/src/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java index 305e267059a..764cd44b43a 100644 --- a/src/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java +++ b/src/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java @@ -160,7 +160,7 @@ public AccessBridge() { Thread abthread = new Thread(new dllRunner()); abthread.setDaemon(true); abthread.start(); - debugString("AccessBridge started"); + debugString("[INFO]:AccessBridge started"); } /* @@ -178,7 +178,7 @@ public void run() { private class shutdownHook implements Runnable { public void run() { - debugString("***** shutdownHook: shutting down..."); + debugString("[INFO]:***** shutdownHook: shutting down..."); javaShutdown(); } } @@ -297,7 +297,7 @@ private void initHWNDcalls() { try { componentParemter[0] = Class.forName("java.awt.Component"); } catch (ClassNotFoundException e) { - debugString("Exception: " + e.toString()); + debugString("[ERROR]:Exception: " + e.toString()); } toolkit = Toolkit.getDefaultToolkit(); return; @@ -386,12 +386,12 @@ private boolean isJavaWindow(int nativeHandle) { */ private void saveContextToWindowHandleMapping(AccessibleContext ac, int nativeHandle) { - debugString("saveContextToWindowHandleMapping..."); + debugString("[INFO]:saveContextToWindowHandleMapping..."); if (ac == null) { return; } if (! contextToWindowHandleMap.containsKey(ac)) { - debugString("saveContextToWindowHandleMapping: ac = "+ac+"; handle = "+nativeHandle); + debugString("[INFO]: saveContextToWindowHandleMapping: ac = "+ac+"; handle = "+nativeHandle); contextToWindowHandleMap.put(ac, nativeHandle); } } @@ -434,7 +434,7 @@ public AccessibleContext call() throws Exception { * returns 0 on error */ private int getNativeWindowHandleFromContext(AccessibleContext ac) { - debugString("getNativeWindowHandleFromContext: ac = "+ac); + debugString("[INFO]: getNativeWindowHandleFromContext: ac = "+ac); try { return contextToWindowHandleMap.get(ac); } catch (Exception ex) { @@ -515,7 +515,7 @@ public AccessibleContext call() throws Exception { */ private AccessibleContext getAccessibleContextAt_1(final int x, final int y, final AccessibleContext parent) { - debugString(" : getAccessibleContextAt_1 called"); + debugString("[INFO]: getAccessibleContextAt_1 called"); debugString(" -> x = " + x + " y = " + y + " parent = " + parent); if (parent == null) return null; @@ -563,7 +563,7 @@ public AccessibleContext call() throws Exception { */ private AccessibleContext getAccessibleContextAt_2(final int x, final int y, AccessibleContext parent) { - debugString("getAccessibleContextAt_2 called"); + debugString("[INFO]: getAccessibleContextAt_2 called"); debugString(" -> x = " + x + " y = " + y + " parent = " + parent); return InvocationUtils.invokeAndWait(new Callable<AccessibleContext>() { @@ -573,7 +573,7 @@ public AccessibleContext call() throws Exception { if (a != null) { AccessibleContext childAC = a.getAccessibleContext(); if (childAC != null) { - debugString(" returning childAC = " + childAC); + debugString("[INFO]: returning childAC = " + childAC); return childAC; } } @@ -608,7 +608,7 @@ public AccessibleContext call() throws Exception { * returns the AccessibleName from an AccessibleContext */ private String getAccessibleNameFromContext(final AccessibleContext ac) { - debugString("***** ac = "+ac.getClass()); + debugString("[INFO]: ***** ac = "+ac.getClass()); if (ac != null) { String s = InvocationUtils.invokeAndWait(new Callable<String>() { @Override @@ -618,13 +618,13 @@ public String call() throws Exception { }, ac); if (s != null) { references.increment(s); - debugString("Returning AccessibleName from Context: " + s); + debugString("[INFO]: Returning AccessibleName from Context: " + s); return s; } else { return null; } } else { - debugString("getAccessibleNameFromContext; ac = null!"); + debugString("[INFO]: getAccessibleNameFromContext; ac = null!"); return null; } } @@ -649,7 +649,7 @@ public String call() throws Exception { } }, ac); if ( ( null != nameString ) && ( 0 != nameString.length () ) ) { - debugString ("bk -- The Virtual Accessible Name was obtained from AccessibleContext::getAccessibleName."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from AccessibleContext::getAccessibleName."); references.increment (nameString); return nameString; } @@ -660,12 +660,12 @@ public String call() throws Exception { } }, ac); if ( ( null != descriptionString ) && ( 0 != descriptionString.length () ) ) { - debugString ("bk -- The Virtual Accessible Name was obtained from AccessibleContext::getAccessibleDescription."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from AccessibleContext::getAccessibleDescription."); references.increment (descriptionString); return descriptionString; } - debugString ("The Virtual Accessible Name was not found using AccessibleContext::getAccessibleDescription. or getAccessibleName"); + debugString ("[WARN]: The Virtual Accessible Name was not found using AccessibleContext::getAccessibleDescription. or getAccessibleName"); /* Step 2: ======= @@ -702,7 +702,7 @@ public AccessibleRole call() throws Exception { } if (false == bExtendedSearch) { - debugString ("bk -- getVirtualAccessibleNameFromContext will not use the extended name search algorithm. role = " + ( role != null ? role.toDisplayString(Locale.US) : "null") ); + debugString ("[INFO]: bk -- getVirtualAccessibleNameFromContext will not use the extended name search algorithm. role = " + ( role != null ? role.toDisplayString(Locale.US) : "null") ); /* Step 3: ======= @@ -735,7 +735,7 @@ public Integer call() throws Exception { }, ac); String text = getAccessibleTextRangeFromContext (ac, 0, charCount); if (null != text) { - debugString ("bk -- The Virtual Accessible Name was obtained from the Accessible Text of the LABEL object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from the Accessible Text of the LABEL object."); references.increment (text); return text; } @@ -743,7 +743,7 @@ public Integer call() throws Exception { /* Does the label support the Accessible Icon Interface? */ - debugString ("bk -- Attempting to obtain the Virtual Accessible Name from the Accessible Icon information."); + debugString ("[INFO]: bk -- Attempting to obtain the Virtual Accessible Name from the Accessible Icon information."); final AccessibleIcon [] ai = InvocationUtils.invokeAndWait(new Callable<AccessibleIcon[]>() { @Override public AccessibleIcon[] call() throws Exception { @@ -758,7 +758,7 @@ public String call() throws Exception { } }, ac); if (iconDescription != null){ - debugString ("bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the LABEL object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the LABEL object."); references.increment (iconDescription); return iconDescription; } @@ -780,7 +780,7 @@ public Integer call() throws Exception { } }, ac); final AccessibleContext acTableCell = getAccessibleChildFromContext (parentContext, indexInParent); - debugString ("bk -- Making a second attempt to obtain the Virtual Accessible Name from the Accessible Icon information for the Table Cell."); + debugString ("[INFO]: bk -- Making a second attempt to obtain the Virtual Accessible Name from the Accessible Icon information for the Table Cell."); if (acTableCell != null) { final AccessibleIcon [] aiRet =InvocationUtils.invokeAndWait(new Callable<AccessibleIcon[]>() { @Override @@ -796,7 +796,7 @@ public String call() throws Exception { } }, ac); if (iconDescription != null){ - debugString ("bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the Table Cell object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the Table Cell object."); references.increment (iconDescription); return iconDescription; } @@ -810,7 +810,7 @@ public String call() throws Exception { /* Does the button support the Accessible Icon Interface? */ - debugString ("bk -- Attempting to obtain the Virtual Accessible Name from the Accessible Icon information."); + debugString ("[INFO]: bk -- Attempting to obtain the Virtual Accessible Name from the Accessible Icon information."); final AccessibleIcon [] ai = InvocationUtils.invokeAndWait(new Callable<AccessibleIcon[]>() { @Override public AccessibleIcon[] call() throws Exception { @@ -825,7 +825,7 @@ public String call() throws Exception { } }, ac); if (iconDescription != null){ - debugString ("bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the TOGGLE_BUTTON or PUSH_BUTTON object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the TOGGLE_BUTTON or PUSH_BUTTON object."); references.increment (iconDescription); return iconDescription; } @@ -905,7 +905,7 @@ public String call() throws Exception { if ( (AccessibleRole.SLIDER == role) && (AccessibleRole.PANEL == parentRole) && (null != parentName) ) { - debugString ("bk -- The Virtual Accessible Name was obtained from the Accessible Name of the SLIDER object's parent object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from the Accessible Name of the SLIDER object's parent object."); references.increment (parentName); return parentName; } @@ -922,11 +922,11 @@ public String call() throws Exception { (AccessibleRole.COMBO_BOX == parentRole) ) { bIsEditCombo = true; if (null != parentName) { - debugString ("bk -- The Virtual Accessible Name for this Edit Combo box was obtained from the Accessible Name of the object's parent object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name for this Edit Combo box was obtained from the Accessible Name of the object's parent object."); references.increment (parentName); return parentName; } else if (null != parentDescription) { - debugString ("bk -- The Virtual Accessible Name for this Edit Combo box was obtained from the Accessible Description of the object's parent object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name for this Edit Combo box was obtained from the Accessible Description of the object's parent object."); references.increment (parentDescription); return parentDescription; } @@ -969,11 +969,11 @@ public AccessibleRelationSet call() throws Exception { String labelName = labelContext.getAccessibleName (); String labelDescription = labelContext.getAccessibleDescription (); if (null != labelName) { - debugString ("bk -- The Virtual Accessible Name was obtained using the LABELED_BY AccessibleRelation -- Name Case."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained using the LABELED_BY AccessibleRelation -- Name Case."); references.increment (labelName); return labelName; } else if (null != labelDescription) { - debugString ("bk -- The Virtual Accessible Name was obtained using the LABELED_BY AccessibleRelation -- Description Case."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained using the LABELED_BY AccessibleRelation -- Description Case."); references.increment (labelDescription); return labelDescription; } @@ -1068,7 +1068,7 @@ public String call() throws Exception { } }, ac); if ( null != childName ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned to the left of the object."); references.increment (childName); return childName; } @@ -1079,7 +1079,7 @@ public String call() throws Exception { } }, ac); if ( null != childDescription ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned to the left of the object."); references.increment (childDescription); return childDescription; } @@ -1092,7 +1092,7 @@ public String call() throws Exception { } }, ac); if ( null != childName ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned above the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned above the object."); references.increment (childName); return childName; } @@ -1103,7 +1103,7 @@ public String call() throws Exception { } }, ac); if ( null != childDescription ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned above the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned above the object."); references.increment (childDescription); return childDescription; } @@ -1151,7 +1151,7 @@ public String call() throws Exception { } }, ac); if ( null != childName ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned to the left of the object."); references.increment (childName); return childName; } @@ -1162,7 +1162,7 @@ public String call() throws Exception { } }, ac); if ( null != childDescription ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned to the left of the object."); references.increment (childDescription); return childDescription; } @@ -1175,7 +1175,7 @@ public String call() throws Exception { } }, ac); if ( null != childName ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned above the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned above the object."); references.increment (childName); return childName; } @@ -1186,7 +1186,7 @@ public String call() throws Exception { } }, ac); if ( null != childDescription ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned above the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned above the object."); references.increment (childDescription); return childDescription; } @@ -1248,7 +1248,7 @@ public String call() throws Exception { } }, ac); if ( null != childName ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Name of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); references.increment (childName); return childName; } @@ -1259,7 +1259,7 @@ public String call() throws Exception { } }, ac); if ( null != childDescription ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Description of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); references.increment (childDescription); return childDescription; } @@ -1308,7 +1308,7 @@ public String call() throws Exception { } }, ac); if ( null != childName ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Name of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); references.increment (childName); return childName; } @@ -1319,7 +1319,7 @@ public String call() throws Exception { } }, ac); if ( null != childDescription ) { - debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); + debugString ("[INFO]: bk -- The Virtual Accessible Name was obtained from Accessible Description of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object."); references.increment (childDescription); return childDescription; } @@ -1332,7 +1332,7 @@ public String call() throws Exception { } return null; } else { - debugString ("AccessBridge::getVirtualAccessibleNameFromContext error - ac == null."); + debugString ("[ERROR]: AccessBridge::getVirtualAccessibleNameFromContext error - ac == null."); return null; } } @@ -1350,11 +1350,11 @@ public String call() throws Exception { }, ac); if (s != null) { references.increment(s); - debugString("Returning AccessibleDescription from Context: " + s); + debugString("[INFO]: Returning AccessibleDescription from Context: " + s); return s; } } else { - debugString("getAccessibleDescriptionFromContext; ac = null"); + debugString("[ERROR]: getAccessibleDescriptionFromContext; ac = null"); } return null; } @@ -1374,12 +1374,12 @@ public AccessibleRole call() throws Exception { String s = role.toDisplayString(Locale.US); if (s != null) { references.increment(s); - debugString("Returning AccessibleRole from Context: " + s); + debugString("[INFO]: Returning AccessibleRole from Context: " + s); return s; } } } else { - debugString("getAccessibleRoleStringFromContext; ac = null"); + debugString("[ERROR]: getAccessibleRoleStringFromContext; ac = null"); } return null; } @@ -1418,12 +1418,12 @@ public AccessibleStateSet call() throws Exception { s += AccessibleState.MANAGES_DESCENDANTS.toDisplayString(Locale.US); } references.increment(s); - debugString("Returning AccessibleStateSet from Context: " + s); + debugString("[INFO]: Returning AccessibleStateSet from Context: " + s); return s; } } } else { - debugString("getAccessibleStatesStringFromContext; ac = null"); + debugString("[ERROR]: getAccessibleStatesStringFromContext; ac = null"); } return null; } @@ -1449,11 +1449,11 @@ public AccessibleStateSet call() throws Exception { } } references.increment(s); - debugString("Returning AccessibleStateSet en_US from Context: " + s); + debugString("[INFO]: Returning AccessibleStateSet en_US from Context: " + s); return s; } } - debugString("getAccessibleStatesStringFromContext; ac = null"); + debugString("[ERROR]: getAccessibleStatesStringFromContext; ac = null"); return null; } @@ -1607,11 +1607,11 @@ private int getAccessibleXcoordFromContext(AccessibleContext ac) { if (ac != null) { Rectangle r = getAccessibleBoundsOnScreenFromContext(ac); if (r != null) { - debugString(" - Returning Accessible x coord from Context: " + r.x); + debugString("[INFO]: Returning Accessible x coord from Context: " + r.x); return r.x; } } else { - debugString("getAccessibleXcoordFromContext ac = null"); + debugString("[ERROR]: getAccessibleXcoordFromContext ac = null"); } return -1; } @@ -1620,14 +1620,14 @@ private int getAccessibleXcoordFromContext(AccessibleContext ac) { * returns the AccessibleComponent y-coord from an AccessibleContext */ private int getAccessibleYcoordFromContext(AccessibleContext ac) { - debugString("getAccessibleYcoordFromContext() called"); + debugString("[INFO]: getAccessibleYcoordFromContext() called"); if (ac != null) { Rectangle r = getAccessibleBoundsOnScreenFromContext(ac); if (r != null) { return r.y; } } else { - debugString("getAccessibleYcoordFromContext; ac = null"); + debugString("[ERROR]: getAccessibleYcoordFromContext; ac = null"); } return -1; } @@ -1642,7 +1642,7 @@ private int getAccessibleHeightFromContext(AccessibleContext ac) { return r.height; } } else { - debugString("getAccessibleHeightFromContext; ac = null"); + debugString("[ERROR]: getAccessibleHeightFromContext; ac = null"); } return -1; } @@ -1657,7 +1657,7 @@ private int getAccessibleWidthFromContext(AccessibleContext ac) { return r.width; } } else { - debugString("getAccessibleWidthFromContext; ac = null"); + debugString("[ERROR]: getAccessibleWidthFromContext; ac = null"); } return -1; } @@ -1672,11 +1672,11 @@ private AccessibleComponent getAccessibleComponentFromContext(AccessibleContext return ac.getAccessibleComponent(); }, ac); if (acmp != null) { - debugString("Returning AccessibleComponent Context"); + debugString("[INFO]: Returning AccessibleComponent Context"); return acmp; } } else { - debugString("getAccessibleComponentFromContext; ac = null"); + debugString("[ERROR]: getAccessibleComponentFromContext; ac = null"); } return null; } @@ -1685,7 +1685,7 @@ private AccessibleComponent getAccessibleComponentFromContext(AccessibleContext * returns the AccessibleAction from an AccessibleContext */ private AccessibleAction getAccessibleActionFromContext(final AccessibleContext ac) { - debugString("Returning AccessibleAction Context"); + debugString("[INFO]: Returning AccessibleAction Context"); return ac == null ? null : InvocationUtils.invokeAndWait(new Callable<AccessibleAction>() { @Override public AccessibleAction call() throws Exception { @@ -1737,7 +1737,7 @@ public AccessibleValue call() throws Exception { * XXX */ private Rectangle getCaretLocation(final AccessibleContext ac) { - debugString("getCaretLocation"); + debugString("[INFO]: getCaretLocation"); if (ac==null) return null; return InvocationUtils.invokeAndWait(new Callable<Rectangle>() { @@ -1858,7 +1858,7 @@ public Integer call() throws Exception { */ private int getAccessibleIndexAtPointFromContext(final AccessibleContext ac, final int x, final int y) { - debugString("getAccessibleIndexAtPointFromContext: x = "+x+"; y = "+y); + debugString("[INFO]: getAccessibleIndexAtPointFromContext: x = "+x+"; y = "+y); if (ac==null) return -1; return InvocationUtils.invokeAndWait(new Callable<Integer>() { @@ -1912,7 +1912,7 @@ public String call() throws Exception { return s; } } else { - debugString("getAccessibleLetterAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleLetterAtIndexFromContext; ac = null"); } return null; } @@ -1935,7 +1935,7 @@ public String call() throws Exception { return s; } } else { - debugString("getAccessibleWordAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleWordAtIndexFromContext; ac = null"); } return null; } @@ -1958,7 +1958,7 @@ public String call() throws Exception { return s; } } else { - debugString("getAccessibleSentenceAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleSentenceAtIndexFromContext; ac = null"); } return null; } @@ -2016,7 +2016,7 @@ public String call() throws Exception { return s; } } else { - debugString("getAccessibleTextSelectedTextFromContext; ac = null"); + debugString("[ERROR]: getAccessibleTextSelectedTextFromContext; ac = null"); } return null; } @@ -2277,7 +2277,7 @@ private int getAccessibleXcoordTextRectAtIndexFromContext(AccessibleContext ac, return r.x; } } else { - debugString("getAccessibleXcoordTextRectAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleXcoordTextRectAtIndexFromContext; ac = null"); } return -1; } @@ -2292,7 +2292,7 @@ private int getAccessibleYcoordTextRectAtIndexFromContext(AccessibleContext ac, return r.y; } } else { - debugString("getAccessibleYcoordTextRectAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleYcoordTextRectAtIndexFromContext; ac = null"); } return -1; } @@ -2307,7 +2307,7 @@ private int getAccessibleHeightTextRectAtIndexFromContext(AccessibleContext ac, return r.height; } } else { - debugString("getAccessibleHeightTextRectAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleHeightTextRectAtIndexFromContext; ac = null"); } return -1; } @@ -2322,7 +2322,7 @@ private int getAccessibleWidthTextRectAtIndexFromContext(AccessibleContext ac, i return r.width; } } else { - debugString("getAccessibleWidthTextRectAtIndexFromContext; ac = null"); + debugString("[ERROR]: getAccessibleWidthTextRectAtIndexFromContext; ac = null"); } return -1; } @@ -2336,7 +2336,7 @@ private boolean getBoldFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.isBold(as); } else { - debugString("getBoldFromAttributeSet; as = null"); + debugString("[ERROR]: getBoldFromAttributeSet; as = null"); } return false; } @@ -2348,7 +2348,7 @@ private boolean getItalicFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.isItalic(as); } else { - debugString("getItalicFromAttributeSet; as = null"); + debugString("[ERROR]: getItalicFromAttributeSet; as = null"); } return false; } @@ -2360,7 +2360,7 @@ private boolean getUnderlineFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.isUnderline(as); } else { - debugString("getUnderlineFromAttributeSet; as = null"); + debugString("[ERROR]: getUnderlineFromAttributeSet; as = null"); } return false; } @@ -2372,7 +2372,7 @@ private boolean getStrikethroughFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.isStrikeThrough(as); } else { - debugString("getStrikethroughFromAttributeSet; as = null"); + debugString("[ERROR]: getStrikethroughFromAttributeSet; as = null"); } return false; } @@ -2384,7 +2384,7 @@ private boolean getSuperscriptFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.isSuperscript(as); } else { - debugString("getSuperscriptFromAttributeSet; as = null"); + debugString("[ERROR]: getSuperscriptFromAttributeSet; as = null"); } return false; } @@ -2396,7 +2396,7 @@ private boolean getSubscriptFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.isSubscript(as); } else { - debugString("getSubscriptFromAttributeSet; as = null"); + debugString("[ERROR]: getSubscriptFromAttributeSet; as = null"); } return false; } @@ -2412,7 +2412,7 @@ private String getBackgroundColorFromAttributeSet(AttributeSet as) { return s; } } else { - debugString("getBackgroundColorFromAttributeSet; as = null"); + debugString("[ERROR]: getBackgroundColorFromAttributeSet; as = null"); } return null; } @@ -2428,7 +2428,7 @@ private String getForegroundColorFromAttributeSet(AttributeSet as) { return s; } } else { - debugString("getForegroundColorFromAttributeSet; as = null"); + debugString("[ERROR]: getForegroundColorFromAttributeSet; as = null"); } return null; } @@ -2444,7 +2444,7 @@ private String getFontFamilyFromAttributeSet(AttributeSet as) { return s; } } else { - debugString("getFontFamilyFromAttributeSet; as = null"); + debugString("[ERROR]: getFontFamilyFromAttributeSet; as = null"); } return null; } @@ -2456,7 +2456,7 @@ private int getFontSizeFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getFontSize(as); } else { - debugString("getFontSizeFromAttributeSet; as = null"); + debugString("[ERROR]: getFontSizeFromAttributeSet; as = null"); } return -1; } @@ -2468,7 +2468,7 @@ private int getAlignmentFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getAlignment(as); } else { - debugString("getAlignmentFromAttributeSet; as = null"); + debugString("[ERROR]: getAlignmentFromAttributeSet; as = null"); } return -1; } @@ -2480,7 +2480,7 @@ private int getBidiLevelFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getBidiLevel(as); } else { - debugString("getBidiLevelFromAttributeSet; as = null"); + debugString("[ERROR]: getBidiLevelFromAttributeSet; as = null"); } return -1; } @@ -2493,7 +2493,7 @@ private float getFirstLineIndentFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getFirstLineIndent(as); } else { - debugString("getFirstLineIndentFromAttributeSet; as = null"); + debugString("[ERROR]: getFirstLineIndentFromAttributeSet; as = null"); } return -1; } @@ -2505,7 +2505,7 @@ private float getLeftIndentFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getLeftIndent(as); } else { - debugString("getLeftIndentFromAttributeSet; as = null"); + debugString("[ERROR]: getLeftIndentFromAttributeSet; as = null"); } return -1; } @@ -2517,7 +2517,7 @@ private float getRightIndentFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getRightIndent(as); } else { - debugString("getRightIndentFromAttributeSet; as = null"); + debugString("[ERROR]: getRightIndentFromAttributeSet; as = null"); } return -1; } @@ -2529,7 +2529,7 @@ private float getLineSpacingFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getLineSpacing(as); } else { - debugString("getLineSpacingFromAttributeSet; as = null"); + debugString("[ERROR]: getLineSpacingFromAttributeSet; as = null"); } return -1; } @@ -2541,7 +2541,7 @@ private float getSpaceAboveFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getSpaceAbove(as); } else { - debugString("getSpaceAboveFromAttributeSet; as = null"); + debugString("[ERROR]: getSpaceAboveFromAttributeSet; as = null"); } return -1; } @@ -2553,7 +2553,7 @@ private float getSpaceBelowFromAttributeSet(AttributeSet as) { if (as != null) { return StyleConstants.getSpaceBelow(as); } else { - debugString("getSpaceBelowFromAttributeSet; as = null"); + debugString("[ERROR]: getSpaceBelowFromAttributeSet; as = null"); } return -1; } @@ -2702,7 +2702,7 @@ public Number call() throws Exception { } } } else { - debugString("getCurrentAccessibleValueFromContext; ac = null"); + debugString("[ERROR]: getCurrentAccessibleValueFromContext; ac = null"); } return null; } @@ -2730,7 +2730,7 @@ public Number call() throws Exception { } } } else { - debugString("getMaximumAccessibleValueFromContext; ac = null"); + debugString("[ERROR]: getMaximumAccessibleValueFromContext; ac = null"); } return null; } @@ -2758,7 +2758,7 @@ public Number call() throws Exception { } } } else { - debugString("getMinimumAccessibleValueFromContext; ac = null"); + debugString("[ERROR]: getMinimumAccessibleValueFromContext; ac = null"); } return null; } @@ -2941,7 +2941,7 @@ private AccessibleContext getContextFromAccessibleTable(AccessibleTable at) { * returns the row count for an AccessibleTable */ private int getAccessibleTableRowCount(final AccessibleContext ac) { - debugString("##### getAccessibleTableRowCount"); + debugString("[INFO]: ##### getAccessibleTableRowCount"); return InvocationUtils.invokeAndWait(new Callable<Integer>() { @Override public Integer call() throws Exception { @@ -2960,7 +2960,7 @@ public Integer call() throws Exception { * returns the column count for an AccessibleTable */ private int getAccessibleTableColumnCount(final AccessibleContext ac) { - debugString("##### getAccessibleTableColumnCount"); + debugString("[INFO]: ##### getAccessibleTableColumnCount"); return InvocationUtils.invokeAndWait(new Callable<Integer>() { @Override public Integer call() throws Exception { @@ -2980,7 +2980,7 @@ public Integer call() throws Exception { */ private AccessibleContext getAccessibleTableCellAccessibleContext(final AccessibleTable at, final int row, final int column) { - debugString("getAccessibleTableCellAccessibleContext: at = "+at.getClass()); + debugString("[INFO]: getAccessibleTableCellAccessibleContext: at = "+at.getClass()); if (at == null) return null; return InvocationUtils.invokeAndWait(new Callable<AccessibleContext>() { @Override @@ -3025,7 +3025,7 @@ public AccessibleContext call() throws Exception { * returns the index of a cell at a given row and column in an AccessibleTable */ private int getAccessibleTableCellIndex(final AccessibleTable at, int row, int column) { - debugString("##### getAccessibleTableCellIndex: at="+at); + debugString("[INFO]: ##### getAccessibleTableCellIndex: at="+at); if (at != null) { int cellIndex = row * InvocationUtils.invokeAndWait(new Callable<Integer>() { @@ -3035,10 +3035,10 @@ public Integer call() throws Exception { } }, getContextFromAccessibleTable(at)) + column; - debugString(" ##### getAccessibleTableCellIndex="+cellIndex); + debugString("[INFO]: ##### getAccessibleTableCellIndex="+cellIndex); return cellIndex; } - debugString(" ##### getAccessibleTableCellIndex FAILED"); + debugString("[ERROR]: ##### getAccessibleTableCellIndex FAILED"); return -1; } @@ -3046,7 +3046,7 @@ public Integer call() throws Exception { * returns the row extent of a cell at a given row and column in an AccessibleTable */ private int getAccessibleTableCellRowExtent(final AccessibleTable at, final int row, final int column) { - debugString("##### getAccessibleTableCellRowExtent"); + debugString("[INFO]: ##### getAccessibleTableCellRowExtent"); if (at != null) { int rowExtent = InvocationUtils.invokeAndWait(new Callable<Integer>() { @Override @@ -3055,10 +3055,10 @@ public Integer call() throws Exception { } }, getContextFromAccessibleTable(at)); - debugString(" ##### getAccessibleTableCellRowExtent="+rowExtent); + debugString("[INFO]: ##### getAccessibleTableCellRowExtent="+rowExtent); return rowExtent; } - debugString(" ##### getAccessibleTableCellRowExtent FAILED"); + debugString("[ERROR]: ##### getAccessibleTableCellRowExtent FAILED"); return -1; } @@ -3066,7 +3066,7 @@ public Integer call() throws Exception { * returns the column extent of a cell at a given row and column in an AccessibleTable */ private int getAccessibleTableCellColumnExtent(final AccessibleTable at, final int row, final int column) { - debugString("##### getAccessibleTableCellColumnExtent"); + debugString("[INFO]: ##### getAccessibleTableCellColumnExtent"); if (at != null) { int columnExtent = InvocationUtils.invokeAndWait(new Callable<Integer>() { @Override @@ -3075,10 +3075,10 @@ public Integer call() throws Exception { } }, getContextFromAccessibleTable(at)); - debugString(" ##### getAccessibleTableCellColumnExtent="+columnExtent); + debugString("[INFO]: ##### getAccessibleTableCellColumnExtent="+columnExtent); return columnExtent; } - debugString(" ##### getAccessibleTableCellColumnExtent FAILED"); + debugString("[ERROR]: ##### getAccessibleTableCellColumnExtent FAILED"); return -1; } @@ -3087,7 +3087,7 @@ public Integer call() throws Exception { */ private boolean isAccessibleTableCellSelected(final AccessibleTable at, final int row, final int column) { - debugString("##### isAccessibleTableCellSelected: ["+row+"]["+column+"]"); + debugString("[INFO]: ##### isAccessibleTableCellSelected: ["+row+"]["+column+"]"); if (at == null) return false; return InvocationUtils.invokeAndWait(new Callable<Boolean>() { @@ -3114,7 +3114,7 @@ public Boolean call() throws Exception { * AccessibleTable */ private AccessibleTable getAccessibleTableRowHeader(final AccessibleContext ac) { - debugString(" ##### getAccessibleTableRowHeader called"); + debugString("[INFO]: ##### getAccessibleTableRowHeader called"); AccessibleTable at = InvocationUtils.invokeAndWait(new Callable<AccessibleTable>() { @Override public AccessibleTable call() throws Exception { @@ -3138,7 +3138,7 @@ public AccessibleTable call() throws Exception { * AccessibleTable */ private AccessibleTable getAccessibleTableColumnHeader(final AccessibleContext ac) { - debugString("##### getAccessibleTableColumnHeader"); + debugString("[INFO]: ##### getAccessibleTableColumnHeader"); if (ac == null) return null; AccessibleTable at = InvocationUtils.invokeAndWait(new Callable<AccessibleTable>() { @@ -3177,7 +3177,7 @@ public AccessibleTable call() throws Exception { */ private int getAccessibleTableRowHeaderRowCount(AccessibleContext ac) { - debugString(" ##### getAccessibleTableRowHeaderRowCount called"); + debugString("[INFO]: ##### getAccessibleTableRowHeaderRowCount called"); if (ac != null) { final AccessibleTable atRowHeader = getAccessibleTableRowHeader(ac); if (atRowHeader != null) { @@ -3200,7 +3200,7 @@ public Integer call() throws Exception { * the row header in an AccessibleTable */ private int getAccessibleTableRowHeaderColumnCount(AccessibleContext ac) { - debugString(" ##### getAccessibleTableRowHeaderColumnCount called"); + debugString("[INFO]: ##### getAccessibleTableRowHeaderColumnCount called"); if (ac != null) { final AccessibleTable atRowHeader = getAccessibleTableRowHeader(ac); if (atRowHeader != null) { @@ -3215,7 +3215,7 @@ public Integer call() throws Exception { }, ac); } } - debugString(" ##### getAccessibleTableRowHeaderColumnCount FAILED"); + debugString("[ERROR]: ##### getAccessibleTableRowHeaderColumnCount FAILED"); return -1; } @@ -3225,7 +3225,7 @@ public Integer call() throws Exception { */ private int getAccessibleTableColumnHeaderRowCount(AccessibleContext ac) { - debugString("##### getAccessibleTableColumnHeaderRowCount"); + debugString("[INFO]: ##### getAccessibleTableColumnHeaderRowCount"); if (ac != null) { final AccessibleTable atColumnHeader = getAccessibleTableColumnHeader(ac); if (atColumnHeader != null) { @@ -3240,7 +3240,7 @@ public Integer call() throws Exception { }, ac); } } - debugString(" ##### getAccessibleTableColumnHeaderRowCount FAILED"); + debugString("[ERROR]: ##### getAccessibleTableColumnHeaderRowCount FAILED"); return -1; } @@ -3250,7 +3250,7 @@ public Integer call() throws Exception { */ private int getAccessibleTableColumnHeaderColumnCount(AccessibleContext ac) { - debugString("##### getAccessibleTableColumnHeaderColumnCount"); + debugString("[ERROR]: ##### getAccessibleTableColumnHeaderColumnCount"); if (ac != null) { final AccessibleTable atColumnHeader = getAccessibleTableColumnHeader(ac); if (atColumnHeader != null) { @@ -3265,7 +3265,7 @@ public Integer call() throws Exception { }, ac); } } - debugString(" ##### getAccessibleTableColumnHeaderColumnCount FAILED"); + debugString("[ERROR]: ##### getAccessibleTableColumnHeaderColumnCount FAILED"); return -1; } @@ -3532,7 +3532,7 @@ public Integer call() throws Exception { */ private AccessibleContext getAccessibleRelationTarget(final AccessibleContext ac, final int i, final int j) { - debugString("***** getAccessibleRelationTarget"); + debugString("[INFO]: ***** getAccessibleRelationTarget"); return InvocationUtils.invokeAndWait(new Callable<AccessibleContext>() { @Override public AccessibleContext call() throws Exception { @@ -3565,7 +3565,7 @@ public AccessibleContext call() throws Exception { * Returns the AccessibleHypertext */ private AccessibleHypertext getAccessibleHypertext(final AccessibleContext ac) { - debugString("getAccessibleHyperlink"); + debugString("[INFO]: getAccessibleHyperlink"); if (ac==null) return null; AccessibleHypertext hypertext = InvocationUtils.invokeAndWait(new Callable<AccessibleHypertext>() { @@ -3586,7 +3586,7 @@ public AccessibleHypertext call() throws Exception { * Returns the number of AccessibleHyperlinks */ private int getAccessibleHyperlinkCount(AccessibleContext ac) { - debugString("getAccessibleHyperlinkCount"); + debugString("[INFO]: getAccessibleHyperlinkCount"); if (ac == null) { return 0; } @@ -3607,7 +3607,7 @@ public Integer call() throws Exception { * Returns the hyperlink at the specified index */ private AccessibleHyperlink getAccessibleHyperlink(final AccessibleHypertext hypertext, final int i) { - debugString("getAccessibleHyperlink"); + debugString("[INFO]: getAccessibleHyperlink"); if (hypertext == null) { return null; } @@ -3639,7 +3639,7 @@ public AccessibleHyperlink call() throws Exception { * Returns the hyperlink object description */ private String getAccessibleHyperlinkText(final AccessibleHyperlink link) { - debugString("getAccessibleHyperlinkText"); + debugString("[INFO]: getAccessibleHyperlinkText"); if (link == null) { return null; } @@ -3659,7 +3659,7 @@ public String call() throws Exception { * Returns the hyperlink URL */ private String getAccessibleHyperlinkURL(final AccessibleHyperlink link) { - debugString("getAccessibleHyperlinkURL"); + debugString("[INFO]: getAccessibleHyperlinkURL"); if (link == null) { return null; } @@ -3680,7 +3680,7 @@ public String call() throws Exception { * Returns the start index of the hyperlink text */ private int getAccessibleHyperlinkStartIndex(final AccessibleHyperlink link) { - debugString("getAccessibleHyperlinkStartIndex"); + debugString("[INFO]: getAccessibleHyperlinkStartIndex"); if (link == null) { return -1; } @@ -3696,7 +3696,7 @@ public Integer call() throws Exception { * Returns the end index of the hyperlink text */ private int getAccessibleHyperlinkEndIndex(final AccessibleHyperlink link) { - debugString("getAccessibleHyperlinkEndIndex"); + debugString("[INFO]: getAccessibleHyperlinkEndIndex"); if (link == null) { return -1; } @@ -3714,7 +3714,7 @@ public Integer call() throws Exception { * is no hyperlink associated with this index. */ private int getAccessibleHypertextLinkIndex(final AccessibleHypertext hypertext, final int charIndex) { - debugString("getAccessibleHypertextLinkIndex: charIndex = "+charIndex); + debugString("[INFO]: getAccessibleHypertextLinkIndex: charIndex = "+charIndex); if (hypertext == null) { return -1; } @@ -3724,7 +3724,7 @@ public Integer call() throws Exception { return hypertext.getLinkIndex(charIndex); } }, hyperTextContextMap.get(hypertext)); - debugString("getAccessibleHypertextLinkIndex returning "+linkIndex); + debugString("[INFO]: getAccessibleHypertextLinkIndex returning "+linkIndex); return linkIndex; } @@ -3743,7 +3743,7 @@ public Boolean call() throws Exception { return link.doAccessibleAction(0); } }, ac); - debugString("activateAccessibleHyperlink: returning = "+retval); + debugString("[INFO]: activateAccessibleHyperlink: returning = "+retval); return retval; } @@ -3871,17 +3871,17 @@ private char getKeyChar(KeyStroke keyStroke) { int fKey = fKeyNumber(keyStroke); if (fKey != 0) { // return 0x00000001 through 0x00000018 - debugString(" Shortcut is: F" + fKey); + debugString("[INFO]: Shortcut is: F" + fKey); return (char)fKey; } // If the accelerator is a control character, return it int keyCode = controlCode(keyStroke); if (keyCode != 0) { - debugString(" Shortcut is control character: " + Integer.toHexString(keyCode)); + debugString("[INFO]: Shortcut is control character: " + Integer.toHexString(keyCode)); return (char)keyCode; } String keyText = KeyEvent.getKeyText(keyStroke.getKeyCode()); - debugString(" Shortcut is: " + keyText); + debugString("[INFO]: Shortcut is: " + keyText); if (keyText != null || keyText.length() > 0) { CharSequence seq = keyText.subSequence(0, 1); if (seq != null || seq.length() > 0) { @@ -3897,7 +3897,7 @@ private char getKeyChar(KeyStroke keyStroke) { private int getModifiers(KeyStroke keyStroke) { if (keyStroke == null) return 0; - debugString("In AccessBridge.getModifiers"); + debugString("[INFO]: In AccessBridge.getModifiers"); // modifiers is a bit strip where bits 0-7 indicate a traditional modifier // such as Ctrl/Alt/Shift, bit 8 indicates an F key shortcut, and bit 9 indicates // a control code shortcut such as the delete key. @@ -3924,15 +3924,15 @@ private int getModifiers(KeyStroke keyStroke) { // 0-3 are shift, ctrl, meta, alt // 4-7 are for Solaris workstations (though not being used) if (text.startsWith("met")) { - debugString(" found meta"); + debugString("[INFO]: found meta"); modifiers |= ActionEvent.META_MASK; } if (text.startsWith("ctr")) { - debugString(" found ctrl"); + debugString("[INFO]: found ctrl"); modifiers |= ActionEvent.CTRL_MASK; } if (text.startsWith("alt")) { - debugString(" found alt"); + debugString("[INFO]: found alt"); modifiers |= ActionEvent.ALT_MASK; } if (text.startsWith("shi")) { @@ -3940,7 +3940,7 @@ private int getModifiers(KeyStroke keyStroke) { modifiers |= ActionEvent.SHIFT_MASK; } } - debugString(" returning modifiers: 0x" + Integer.toHexString(modifiers)); + debugString("[INFO]: returning modifiers: 0x" + Integer.toHexString(modifiers)); return modifiers; } @@ -4019,7 +4019,7 @@ private int getAccessibleKeyBindingModifiers(AccessibleContext ac, int index) { * return the number of icons associated with this context */ private int getAccessibleIconsCount(final AccessibleContext ac) { - debugString("getAccessibleIconsCount"); + debugString("[INFO]: getAccessibleIconsCount"); if (ac == null) { return 0; } @@ -4039,7 +4039,7 @@ public Integer call() throws Exception { * return icon description at the specified index */ private String getAccessibleIconDescription(final AccessibleContext ac, final int index) { - debugString("getAccessibleIconDescription: index = "+index); + debugString("[INFO]: getAccessibleIconDescription: index = "+index); if (ac == null) { return null; } @@ -4059,7 +4059,7 @@ public String call() throws Exception { * return icon height at the specified index */ private int getAccessibleIconHeight(final AccessibleContext ac, final int index) { - debugString("getAccessibleIconHeight: index = "+index); + debugString("[INFO]: getAccessibleIconHeight: index = "+index); if (ac == null) { return 0; } @@ -4079,7 +4079,7 @@ public Integer call() throws Exception { * return icon width at the specified index */ private int getAccessibleIconWidth(final AccessibleContext ac, final int index) { - debugString("getAccessibleIconWidth: index = "+index); + debugString("[INFO]: getAccessibleIconWidth: index = "+index); if (ac == null) { return 0; } @@ -4101,7 +4101,7 @@ public Integer call() throws Exception { * return the number of icons associated with this context */ private int getAccessibleActionsCount(final AccessibleContext ac) { - debugString("getAccessibleActionsCount"); + debugString("[INFO]: getAccessibleActionsCount"); if (ac == null) { return 0; } @@ -4120,7 +4120,7 @@ public Integer call() throws Exception { * return icon description at the specified index */ private String getAccessibleActionName(final AccessibleContext ac, final int index) { - debugString("getAccessibleActionName: index = "+index); + debugString("[INFO]: getAccessibleActionName: index = "+index); if (ac == null) { return null; } @@ -4139,7 +4139,7 @@ public String call() throws Exception { * return icon description at the specified index */ private boolean doAccessibleActions(final AccessibleContext ac, final String name) { - debugString("doAccessibleActions: action name = "+name); + debugString("[INFO]: doAccessibleActions: action name = "+name); if (ac == null || name == null) { return false; } @@ -4177,14 +4177,14 @@ public Boolean call() throws Exception { * Returns whether successful. */ private boolean setTextContents(final AccessibleContext ac, final String text) { - debugString("setTextContents: ac = "+ac+"; text = "+text); + debugString("[INFO]: setTextContents: ac = "+ac+"; text = "+text); if (! (ac instanceof AccessibleEditableText)) { - debugString(" ac not instanceof AccessibleEditableText: "+ac); + debugString("[WARN]: ac not instanceof AccessibleEditableText: "+ac); return false; } if (text == null) { - debugString(" text is null"); + debugString("[WARN]: text is null"); return false; } @@ -4221,7 +4221,7 @@ private AccessibleContext getInternalFrame (AccessibleContext ac) { * (AccessibleContext)0 on error. */ private AccessibleContext getTopLevelObject (final AccessibleContext ac) { - debugString("getTopLevelObject; ac = "+ac); + debugString("[INFO]: getTopLevelObject; ac = "+ac); if (ac == null) { return null; } @@ -4258,8 +4258,7 @@ public AccessibleContext call() throws Exception { */ private AccessibleContext getParentWithRole (final AccessibleContext ac, final String roleName) { - debugString("getParentWithRole; ac = "+ac); - debugString("role = "+roleName); + debugString("[INFO]: getParentWithRole; ac = "+ac + "\n role = "+roleName); if (ac == null || roleName == null) { return null; } @@ -4315,7 +4314,7 @@ private AccessibleContext getParentWithRoleElseRoot (AccessibleContext ac, * Returns -1 on error. */ private int getObjectDepth(final AccessibleContext ac) { - debugString("getObjectDepth: ac = "+ac); + debugString("[INFO]: getObjectDepth: ac = "+ac); if (ac == null) { return -1; @@ -4344,7 +4343,7 @@ public Integer call() throws Exception { * Returns (AccessibleContext)0 on error. */ private AccessibleContext getActiveDescendent (final AccessibleContext ac) { - debugString("getActiveDescendent: ac = "+ac); + debugString("[INFO]: getActiveDescendent: ac = "+ac); if (ac == null) { return null; } @@ -4412,7 +4411,7 @@ public AccessibleContext call() throws Exception { * Bug ID 4916682 - Implement JAWS AccessibleName policy */ private String getJAWSAccessibleName(final AccessibleContext ac) { - debugString("getJAWSAccessibleName"); + debugString("[INFO]: getJAWSAccessibleName"); if (ac == null) { return null; } @@ -4431,7 +4430,7 @@ public String call() throws Exception { * Bug ID 4944757 - requestFocus method needed */ private boolean requestFocus(final AccessibleContext ac) { - debugString("requestFocus"); + debugString("[INFO]: requestFocus"); if (ac == null) { return false; } @@ -4456,7 +4455,7 @@ public Boolean call() throws Exception { * Bug ID 4944758 - selectTextRange method needed */ private boolean selectTextRange(final AccessibleContext ac, final int startIndex, final int endIndex) { - debugString("selectTextRange: start = "+startIndex+"; end = "+endIndex); + debugString("[INFO]: selectTextRange: start = "+startIndex+"; end = "+endIndex); if (ac == null) { return false; } @@ -4482,7 +4481,7 @@ public Boolean call() throws Exception { * Bug ID 4944770 - setCaretPosition method needed */ private boolean setCaretPosition(final AccessibleContext ac, final int position) { - debugString("setCaretPosition: position = "+position); + debugString("[INFO]: setCaretPosition: position = "+position); if (ac == null) { return false; } @@ -4510,13 +4509,13 @@ public Boolean call() throws Exception { private boolean _foundVisibleChild; private int getVisibleChildrenCount(AccessibleContext ac) { - debugString("getVisibleChildrenCount"); + debugString("[INFO]: getVisibleChildrenCount"); if (ac == null) { return -1; } _visibleChildrenCount = 0; _getVisibleChildrenCount(ac); - debugString(" _visibleChildrenCount = "+_visibleChildrenCount); + debugString("[INFO]: _visibleChildrenCount = "+_visibleChildrenCount); return _visibleChildrenCount; } @@ -4656,7 +4655,7 @@ public Integer call() throws Exception { * Bug ID 4944762- getVisibleChildren for list-like components needed */ private AccessibleContext getVisibleChild(AccessibleContext ac, int index) { - debugString("getVisibleChild: index = "+index); + debugString("[INFO]: getVisibleChild: index = "+index); if (ac == null) { return null; } @@ -4666,7 +4665,7 @@ private AccessibleContext getVisibleChild(AccessibleContext ac, int index) { _getVisibleChild(ac, index); if (_visibleChild != null) { - debugString( " getVisibleChild: found child = " + + debugString( "[INFO]: getVisibleChild: found child = " + InvocationUtils.invokeAndWait(new Callable<String>() { @Override public String call() throws Exception { @@ -4855,7 +4854,7 @@ String dump() { */ void increment(Object o) { if (o == null){ - debugString("ObjectReferences::increment - Passed in object is null"); + debugString("[WARN]: ObjectReferences::increment - Passed in object is null"); return; } @@ -4876,10 +4875,10 @@ void decrement(Object o) { if (aRef.value == 0) { refs.remove(o); } else if (aRef.value < 0) { - debugString("ERROR: decrementing reference count below 0"); + debugString("[ERROR]: decrementing reference count below 0"); } } else { - debugString("ERROR: object to decrement not in ObjectReferences table"); + debugString("[ERROR]: object to decrement not in ObjectReferences table"); } } @@ -5214,7 +5213,7 @@ void removeAccessibilityEventNotification(long type) { // This is invoked on the EDT , as public void propertyChange(PropertyChangeEvent e) { - accessBridge.debugString("propertyChange(" + e.toString() + ") called"); + accessBridge.debugString("[INFO]: propertyChange(" + e.toString() + ") called"); if (e != null && (accessibilityEventMask & PROPERTY_EVENTS) != 0) { Object o = e.getSource(); @@ -5232,7 +5231,7 @@ public void propertyChange(PropertyChangeEvent e) { if (ac != null) { InvocationUtils.registerAccessibleContext(ac, AppContext.getAppContext()); - accessBridge.debugString("AccessibleContext: " + ac); + accessBridge.debugString("[INFO]: AccessibleContext: " + ac); String propertyName = e.getPropertyName(); if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_CARET_PROPERTY) == 0) { @@ -5245,8 +5244,7 @@ public void propertyChange(PropertyChangeEvent e) { if (e.getNewValue() instanceof Integer) { newValue = ((Integer) e.getNewValue()).intValue(); } - accessBridge.debugString(" - about to call propertyCaretChange()"); - accessBridge.debugString(" old value: " + oldValue + "new value: " + newValue); + accessBridge.debugString("[INFO]: - about to call propertyCaretChange() old value: " + oldValue + "new value: " + newValue); accessBridge.propertyCaretChange(e, ac, oldValue, newValue); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY) == 0) { @@ -5259,8 +5257,7 @@ public void propertyChange(PropertyChangeEvent e) { if (e.getNewValue() != null) { newValue = e.getNewValue().toString(); } - accessBridge.debugString(" - about to call propertyDescriptionChange()"); - accessBridge.debugString(" old value: " + oldValue + "new value: " + newValue); + accessBridge.debugString("[INFO]: - about to call propertyDescriptionChange() old value: " + oldValue + "new value: " + newValue); accessBridge.propertyDescriptionChange(e, ac, oldValue, newValue); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_NAME_PROPERTY) == 0) { @@ -5273,12 +5270,11 @@ public void propertyChange(PropertyChangeEvent e) { if (e.getNewValue() != null) { newValue = e.getNewValue().toString(); } - accessBridge.debugString(" - about to call propertyNameChange()"); - accessBridge.debugString(" old value: " + oldValue + " new value: " + newValue); + accessBridge.debugString("[INFO]: - about to call propertyNameChange() old value: " + oldValue + " new value: " + newValue); accessBridge.propertyNameChange(e, ac, oldValue, newValue); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY) == 0) { - accessBridge.debugString(" - about to call propertySelectionChange() " + ac + " " + Thread.currentThread() + " " + e.getSource()); + accessBridge.debugString("[INFO]: - about to call propertySelectionChange() " + ac + " " + Thread.currentThread() + " " + e.getSource()); accessBridge.propertySelectionChange(e, ac); @@ -5296,11 +5292,11 @@ public void propertyChange(PropertyChangeEvent e) { newValue = newState.toDisplayString(Locale.US); } - accessBridge.debugString(" - about to call propertyStateChange()"); + accessBridge.debugString("[INFO]: - about to call propertyStateChange()"); accessBridge.propertyStateChange(e, ac, oldValue, newValue); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY) == 0) { - accessBridge.debugString(" - about to call propertyTextChange()"); + accessBridge.debugString("[INFO]: - about to call propertyTextChange()"); accessBridge.propertyTextChange(e, ac); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_VALUE_PROPERTY) == 0) { // strings 'cause of floating point, etc. @@ -5313,7 +5309,7 @@ public void propertyChange(PropertyChangeEvent e) { if (e.getNewValue() != null) { newValue = e.getNewValue().toString(); } - accessBridge.debugString(" - about to call propertyDescriptionChange()"); + accessBridge.debugString("[INFO]: - about to call propertyDescriptionChange()"); accessBridge.propertyValueChange(e, ac, oldValue, newValue); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY) == 0) { @@ -5332,8 +5328,7 @@ public void propertyChange(PropertyChangeEvent e) { newAC = (AccessibleContext) e.getNewValue(); InvocationUtils.registerAccessibleContext(newAC, AppContext.getAppContext()); } - accessBridge.debugString(" - about to call propertyChildChange()"); - accessBridge.debugString(" old AC: " + oldAC + "new AC: " + newAC); + accessBridge.debugString("[INFO]: - about to call propertyChildChange() old AC: " + oldAC + "new AC: " + newAC); accessBridge.propertyChildChange(e, ac, oldAC, newAC); } else if (propertyName.compareTo(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0) { @@ -5396,10 +5391,7 @@ private void handleActiveDescendentEvent(PropertyChangeEvent e, } prevAC = newAC; - accessBridge.debugString(" - about to call propertyActiveDescendentChange()"); - accessBridge.debugString(" AC: " + ac); - accessBridge.debugString(" old AC: " + oldAC + "new AC: " + newAC); - + accessBridge.debugString("[INFO]: - about to call propertyActiveDescendentChange() AC: " + ac + " old AC: " + oldAC + "new AC: " + newAC); InvocationUtils.registerAccessibleContext(oldAC, AppContext.getAppContext()); InvocationUtils.registerAccessibleContext(newAC, AppContext.getAppContext()); accessBridge.propertyActiveDescendentChange(e, ac, oldAC, newAC); @@ -5444,10 +5436,9 @@ private void processFocusGained() { // This is a popup with an item selected FocusEvent e = new FocusEvent(last, FocusEvent.FOCUS_GAINED); - accessBridge.debugString(" - about to call focusGained()"); AccessibleContext focusedAC = last.getAccessibleContext(); InvocationUtils.registerAccessibleContext(focusedAC, SunToolkit.targetToAppContext(last)); - accessBridge.debugString(" AC: " + focusedAC); + accessBridge.debugString("[INFO]: - about to call focusGained() AC: " + focusedAC); accessBridge.focusGained(e, focusedAC); } } @@ -5456,10 +5447,9 @@ private void processFocusGained() { if (focusOwner instanceof Accessible) { FocusEvent e = new FocusEvent(focusOwner, FocusEvent.FOCUS_GAINED); - accessBridge.debugString(" - about to call focusGained()"); AccessibleContext focusedAC = focusOwner.getAccessibleContext(); InvocationUtils.registerAccessibleContext(focusedAC, SunToolkit.targetToAppContext(focusOwner)); - accessBridge.debugString(" AC: " + focusedAC); + accessBridge.debugString("[INFO]: - about to call focusGained() AC: " + focusedAC); accessBridge.focusGained(e, focusedAC); } } @@ -5469,8 +5459,7 @@ public void focusLost(FocusEvent e) { if (e != null && (javaEventMask & FOCUS_LOST_EVENTS) != 0) { Accessible a = Translator.getAccessible(e.getSource()); if (a != null) { - accessBridge.debugString(" - about to call focusLost()"); - accessBridge.debugString(" AC: " + a.getAccessibleContext()); + accessBridge.debugString("[INFO]: - about to call focusLost() AC: " + a.getAccessibleContext()); AccessibleContext context = a.getAccessibleContext(); InvocationUtils.registerAccessibleContext(context, AppContext.getAppContext()); accessBridge.focusLost(e, context); @@ -6173,7 +6162,7 @@ private class AccessibleJTreeNode extends AccessibleContext isLeaf = treeModel.isLeaf(obj); } } - debugString("AccessibleJTreeNode: name = "+getAccessibleName()+"; TreePath = "+p+"; parent = "+ap); + debugString("[INFO]: AccessibleJTreeNode: name = "+getAccessibleName()+"; TreePath = "+p+"; parent = "+ap); } private TreePath getChildTreePath(int i) { @@ -6213,14 +6202,14 @@ private AccessibleContext getCurrentAccessibleContext() { } private Component getCurrentComponent() { - debugString("AccessibleJTreeNode: getCurrentComponent"); + debugString("[INFO]: AccessibleJTreeNode: getCurrentComponent"); // is the object visible? // if so, get row, selected, focus & leaf state, // and then get the renderer component and return it if (tree != null && tree.isVisible(path)) { TreeCellRenderer r = tree.getCellRenderer(); if (r == null) { - debugString(" returning null 1"); + debugString("[WARN]: returning null 1"); return null; } TreeUI ui = tree.getUI(); @@ -6232,11 +6221,11 @@ private Component getCurrentComponent() { Component retval = r.getTreeCellRendererComponent(tree, obj, selected, expanded, isLeaf, row, hasFocus); - debugString(" returning = "+retval.getClass()); + debugString("[INFO]: returning = "+retval.getClass()); return retval; } } - debugString(" returning null 2"); + debugString("[WARN]: returning null 2"); return null; } @@ -6249,13 +6238,13 @@ private Component getCurrentComponent() { * object does not have a name */ public String getAccessibleName() { - debugString("AccessibleJTreeNode: getAccessibleName"); + debugString("[INFO]: AccessibleJTreeNode: getAccessibleName"); AccessibleContext ac = getCurrentAccessibleContext(); if (ac != null) { String name = ac.getAccessibleName(); if ((name != null) && (!name.isEmpty())) { String retval = ac.getAccessibleName(); - debugString(" returning "+retval); + debugString("[INFO]: returning "+retval); return retval; } else { return null; diff --git a/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp b/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp index f41125d8c08..4bf96669574 100644 --- a/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp +++ b/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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,19 +31,62 @@ #include <stdarg.h> #include <stdio.h> #include <windows.h> +#include <cstdlib> +#include <chrono> +#include <cstring> #ifdef __cplusplus extern "C" { #endif +static FILE* logFP = nullptr; + +void initializeFileLogger(char * fileName) { + auto var = "JAVA_ACCESSBRIDGE_LOGDIR"; + const auto envfilePath = getenv(var); + if (envfilePath != nullptr && fileName != nullptr) { + auto envFilePathLength = strlen(envfilePath); + auto fileNameLength = strlen(fileName); + auto filePathSize = envFilePathLength + 1 + fileNameLength + 5; //1 for "/", 5 for ".log" and 0; + auto filePath = new char[filePathSize]; + memset(filePath, 0, filePathSize*sizeof(char)); + memcpy(filePath, envfilePath, envFilePathLength*sizeof(char)); + filePath[envFilePathLength] = '/'; + memcpy(filePath + envFilePathLength + 1, fileName, fileNameLength*sizeof(char)); + memcpy(filePath + envFilePathLength + 1 + fileNameLength, ".log", 4*sizeof(char)); + + logFP = fopen(filePath, "w"); + if (logFP == nullptr) { + printf("\n%s\n", filePath); + PrintDebugString("Could not open file %s", filePath); + } + + delete [] filePath; + } +} + +void finalizeFileLogger() { + if (logFP) { + fclose(logFP); + logFP = nullptr; + } +} + +auto getTimeStamp() -> long long { + using namespace std::chrono; + auto timeNow = duration_cast<milliseconds>(steady_clock::now().time_since_epoch()); + + return timeNow.count(); +} + /** * print a GetLastError message */ char *printError(char *msg) { - LPVOID lpMsgBuf = NULL; - static char retbuf[256]; + LPVOID lpMsgBuf = nullptr; + static char retbuf[256] = {0}; - if (msg != NULL) { + if (msg != nullptr) { strncpy((char *)retbuf, msg, sizeof(retbuf)); // if msg text is >= 256 ensure buffer is null terminated retbuf[255] = '\0'; @@ -52,18 +95,18 @@ char *printError(char *msg) { FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, - NULL )) + nullptr)) { PrintDebugString(" %s: FormatMessage failed", msg); } else { PrintDebugString(" %s: %s", msg, (char *)lpMsgBuf); } - if (lpMsgBuf != NULL) { + if (lpMsgBuf != nullptr) { strncat((char *)retbuf, ": ", sizeof(retbuf) - strlen(retbuf) - 1); strncat((char *)retbuf, (char *)lpMsgBuf, sizeof(retbuf) - strlen(retbuf) - 1); } @@ -76,7 +119,7 @@ char *printError(char *msg) { */ void PrintDebugString(char *msg, ...) { #ifdef DEBUGGING_ON - char buf[1024]; + char buf[1024] = {0}; va_list argprt; va_start(argprt, msg); // set up argptr @@ -89,6 +132,14 @@ char *printError(char *msg) { printf("\r\n"); #endif #endif + if (logFP) { + fprintf(logFP, "[%llu] ", getTimeStamp()); + va_list args; + va_start(args, msg); + vfprintf(logFP, msg, args); + va_end(args); + fprintf(logFP, "\r\n"); + } } /** @@ -96,7 +147,7 @@ char *printError(char *msg) { */ void PrintJavaDebugString2(char *msg, ...) { #ifdef JAVA_DEBUGGING_ON - char buf[1024]; + char buf[1024] = {0}; va_list argprt; va_start(argprt, msg); // set up argptr @@ -109,13 +160,21 @@ char *printError(char *msg) { printf("\r\n"); #endif #endif + if (logFP) { + fprintf(logFP, "[%llu] ", getTimeStamp()); + va_list args; + va_start(args, msg); + vfprintf(logFP, msg, args); + va_end(args); + fprintf(logFP, "\r\n"); + } } /** * Wide version of the method to send debugging info to the appropriate place */ void wPrintDebugString(wchar_t *msg, ...) { #ifdef DEBUGGING_ON - char buf[1024]; + char buf[1024] = {0}; char charmsg[256]; va_list argprt; @@ -130,6 +189,14 @@ char *printError(char *msg) { printf("\r\n"); #endif #endif + if (logFP) { + fprintf(logFP, "[%llu] ", getTimeStamp()); + va_list args; + va_start(args, msg); + vfwprintf(logFP, msg, args); + va_end(args); + fprintf(logFP, "\r\n"); + } } /** @@ -137,8 +204,8 @@ char *printError(char *msg) { */ void wPrintJavaDebugString(wchar_t *msg, ...) { #ifdef JAVA_DEBUGGING_ON - char buf[1024]; - char charmsg[256]; + char buf[1024] = {0}; + char charmsg[256] = {0}; va_list argprt; va_start(argprt, msg); // set up argptr @@ -152,6 +219,14 @@ char *printError(char *msg) { printf("\r\n"); #endif #endif + if (logFP) { + fprintf(logFP, "[%llu] ", getTimeStamp()); + va_list args; + va_start(args, msg); + vfwprintf(logFP, msg, args); + va_end(args); + fprintf(logFP, "\r\n"); + } } #ifdef __cplusplus } diff --git a/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h b/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h index 1ac7426d6e0..92459d30789 100644 --- a/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h +++ b/src/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -54,6 +54,8 @@ extern "C" { void PrintJavaDebugString(char *msg, ...); void wPrintJavaDebugString(wchar_t *msg, ...); void wPrintDebugString(wchar_t *msg, ...); + void initializeFileLogger(char * fileName); + void finalizeFileLogger(); #ifdef __cplusplus } diff --git a/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeATInstance.cpp b/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeATInstance.cpp index e62eb1c983c..935c0180635 100644 --- a/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeATInstance.cpp +++ b/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeATInstance.cpp @@ -53,17 +53,17 @@ AccessBridgeATInstance::AccessBridgeATInstance(HWND ourABWindow, HWND winABWindo * AccessBridgeATInstance descructor */ AccessBridgeATInstance::~AccessBridgeATInstance() { - PrintDebugString("\r\nin AccessBridgeATInstance::~AccessBridgeATInstance"); + PrintDebugString("[INFO]: in AccessBridgeATInstance::~AccessBridgeATInstance"); // if IPC memory mapped file view is valid, unmap it if (memoryMappedView != (char *) 0) { - PrintDebugString(" unmapping memoryMappedView; view = %p", memoryMappedView); + PrintDebugString("[INFO]: unmapping memoryMappedView; view = %p", memoryMappedView); UnmapViewOfFile(memoryMappedView); memoryMappedView = (char *) 0; } // if IPC memory mapped file handle map is open, close it if (memoryMappedFileMapHandle != (HANDLE) 0) { - PrintDebugString(" closing memoryMappedFileMapHandle; handle = %p", memoryMappedFileMapHandle); + PrintDebugString("[INFO]: closing memoryMappedFileMapHandle; handle = %p", memoryMappedFileMapHandle); CloseHandle(memoryMappedFileMapHandle); memoryMappedFileMapHandle = (HANDLE) 0; } @@ -87,7 +87,7 @@ LRESULT AccessBridgeATInstance::initiateIPC() { DWORD errorCode; - PrintDebugString("\r\nIn AccessBridgeATInstance::initiateIPC()"); + PrintDebugString("[INFO]: In AccessBridgeATInstance::initiateIPC()"); // open Windows-initiated IPC filemap & map it to a ptr @@ -95,10 +95,10 @@ AccessBridgeATInstance::initiateIPC() { FALSE, memoryMappedFileName); if (memoryMappedFileMapHandle == NULL) { errorCode = GetLastError(); - PrintDebugString(" Failed to CreateFileMapping for %s, error: %X", memoryMappedFileName, errorCode); + PrintDebugString("[ERROR]: Failed to CreateFileMapping for %s, error: %X", memoryMappedFileName, errorCode); return errorCode; } else { - PrintDebugString(" CreateFileMapping worked - filename: %s", memoryMappedFileName); + PrintDebugString("[INFO]: CreateFileMapping worked - filename: %s", memoryMappedFileName); } memoryMappedView = (char *) MapViewOfFile(memoryMappedFileMapHandle, @@ -106,20 +106,20 @@ AccessBridgeATInstance::initiateIPC() { 0, 0, 0); if (memoryMappedView == NULL) { errorCode = GetLastError(); - PrintDebugString(" Failed to MapViewOfFile for %s, error: %X", memoryMappedFileName, errorCode); + PrintDebugString("[ERROR]: Failed to MapViewOfFile for %s, error: %X", memoryMappedFileName, errorCode); return errorCode; } else { - PrintDebugString(" MapViewOfFile worked - view: %p", memoryMappedView); + PrintDebugString("[INFO]: MapViewOfFile worked - view: %p", memoryMappedView); } // look for the JavaDLL's answer to see if it could read the file if (strcmp(memoryMappedView, AB_MEMORY_MAPPED_FILE_OK_QUERY) != 0) { - PrintDebugString(" JavaVM failed to write to memory mapped file %s", + PrintDebugString("[ERROR]: JavaVM failed to write to memory mapped file %s", memoryMappedFileName); return -1; } else { - PrintDebugString(" JavaVM successfully wrote to file!"); + PrintDebugString("[INFO]: JavaVM successfully wrote to file!"); } @@ -213,8 +213,8 @@ static void do_event(char *buffer, int bufsize,HWND ourAccessBridgeWindow,HWND w LRESULT AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eventID) { - PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() eventID = %X", eventID); - PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() (using PostMessage) eventID = %X", eventID); + PrintDebugString("[INFO]: AccessBridgeATInstance::sendJavaEventPackage() eventID = %X", eventID); + PrintDebugString("[INFO]: AccessBridgeATInstance::sendJavaEventPackage() (using PostMessage) eventID = %X", eventID); if (eventID & javaEventMask) { do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow); @@ -234,7 +234,7 @@ AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eve LRESULT AccessBridgeATInstance::sendAccessibilityEventPackage(char *buffer, int bufsize, long eventID) { - PrintDebugString("AccessBridgeATInstance::sendAccessibilityEventPackage() eventID = %X", eventID); + PrintDebugString("[INFO]: AccessBridgeATInstance::sendAccessibilityEventPackage() eventID = %X", eventID); if (eventID & accessibilityEventMask) { do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow); diff --git a/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeJavaEntryPoints.cpp b/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeJavaEntryPoints.cpp index c1054b48f76..5386e4afdd3 100644 --- a/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeJavaEntryPoints.cpp +++ b/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeJavaEntryPoints.cpp @@ -40,7 +40,7 @@ AccessBridgeJavaEntryPoints::AccessBridgeJavaEntryPoints(JNIEnv *jniEnvironment, jobject bridgeObject) { jniEnv = jniEnvironment; accessBridgeObject = (jobject)bridgeObject; - PrintDebugString("AccessBridgeJavaEntryPoints(%p, %p) called", jniEnv, accessBridgeObject); + PrintDebugString("[INFO]: AccessBridgeJavaEntryPoints(%p, %p) called", jniEnv, accessBridgeObject); } @@ -56,15 +56,13 @@ AccessBridgeJavaEntryPoints::~AccessBridgeJavaEntryPoints() { #define FIND_CLASS(classRef, className) \ localClassRef = jniEnv->FindClass(className); \ if (localClassRef == (jclass) 0) { \ - PrintDebugString(" Error! FindClass(%s) failed!", className); \ - PrintDebugString(" -> jniEnv = %p", jniEnv); \ + PrintDebugString("[ERROR]: FindClass(%s) failed! -> jniEnv = %p", className, jniEnv); \ return FALSE; \ } \ classRef = (jclass) jniEnv->NewGlobalRef(localClassRef); \ jniEnv->DeleteLocalRef(localClassRef); \ if (classRef == (jclass) 0) { \ - PrintDebugString(" Error! FindClass(%s) failed!", className); \ - PrintDebugString(" -> (ran out of RAM)"); \ + PrintDebugString("[ERROR]: FindClass(%s) failed! -> (ran out of RAM)", className); \ return FALSE; \ } @@ -72,14 +70,13 @@ AccessBridgeJavaEntryPoints::~AccessBridgeJavaEntryPoints() { #define FIND_METHOD(methodID, classRef, methodString, methodSignature); \ methodID = jniEnv->GetMethodID(classRef, methodString, methodSignature); \ if (methodID == (jmethodID) 0) { \ - PrintDebugString(" Error! GetMethodID(%s) failed!", methodString); \ - PrintDebugString(" -> jniEnv = %p; classRef = %p", jniEnv, classRef); \ + PrintDebugString("[ERROR]: GetMethodID(%s) failed! -> jniEnv = %p; classRef = %p", methodString, jniEnv, classRef); \ return FALSE; \ } #define EXCEPTION_CHECK(situationDescription, returnVal) \ if (exception = jniEnv->ExceptionOccurred()) { \ - PrintDebugString("\r\n *** Exception occured while doing: %s; returning %d", situationDescription, returnVal); \ + PrintDebugString("[ERROR]: *** Exception occured while doing: %s; returning %d", situationDescription, returnVal); \ jniEnv->ExceptionDescribe(); \ jniEnv->ExceptionClear(); \ return (returnVal); \ @@ -87,7 +84,7 @@ AccessBridgeJavaEntryPoints::~AccessBridgeJavaEntryPoints() { #define EXCEPTION_CHECK_VOID(situationDescription) \ if (exception = jniEnv->ExceptionOccurred()) { \ - PrintDebugString("\r\n *** Exception occured while doing: %s", situationDescription); \ + PrintDebugString("[ERROR]: *** Exception occured while doing: %s", situationDescription); \ jniEnv->ExceptionDescribe(); \ jniEnv->ExceptionClear(); \ return; \ @@ -101,7 +98,7 @@ BOOL AccessBridgeJavaEntryPoints::BuildJavaEntryPoints() { jclass localClassRef; - PrintDebugString("Calling BuildJavaEntryPoints():"); + PrintDebugString("[INFO]: Calling BuildJavaEntryPoints():"); FIND_CLASS(bridgeClass, "com/sun/java/accessibility/internal/AccessBridge"); @@ -880,14 +877,14 @@ AccessBridgeJavaEntryPoints::isJavaWindow(jint window) { jthrowable exception; BOOL returnVal; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::isJavaWindow(%X):", window); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::isJavaWindow(%X):", window); if (isJavaWindowMethod != (jmethodID) 0) { returnVal = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, isJavaWindowMethod, window); EXCEPTION_CHECK("Getting isJavaWindow - call to CallBooleanMethod()", FALSE); return returnVal; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or isJavaWindowMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or isJavaWindowMethod == 0"); return FALSE; } } @@ -903,12 +900,12 @@ AccessBridgeJavaEntryPoints::isSameObject(jobject obj1, jobject obj2) { jthrowable exception; BOOL returnVal; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::isSameObject(%p %p):", obj1, obj2); + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::isSameObject(%p %p):", obj1, obj2); returnVal = (BOOL) jniEnv->IsSameObject((jobject)obj1, (jobject)obj2); EXCEPTION_CHECK("Calling IsSameObject", FALSE); - PrintDebugString("\r\n isSameObject returning %d", returnVal); + PrintDebugString("[INFO]: isSameObject returning %d", returnVal); return returnVal; } @@ -924,7 +921,7 @@ AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(jint window) { jobject globalRef; jthrowable exception; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(%X):", window); + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(%X):", window); if (getAccessibleContextFromHWNDMethod != (jmethodID) 0) { returnedAccessibleContext = @@ -935,7 +932,7 @@ AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(jint window) { EXCEPTION_CHECK("Getting AccessibleContextFromHWND - call to CallObjectMethod()", (jobject) 0); return globalRef; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getAccessibleContextFromHWNDMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getAccessibleContextFromHWNDMethod == 0"); return (jobject) 0; } } @@ -951,17 +948,17 @@ AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(jobject accessibleCont jthrowable exception; HWND rHWND; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(%X):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(%X):", accessibleContext); if (getHWNDFromAccessibleContextMethod != (jmethodID) 0) { rHWND = (HWND)jniEnv->CallIntMethod(accessBridgeObject, getHWNDFromAccessibleContextMethod, accessibleContext); EXCEPTION_CHECK("Getting HWNDFromAccessibleContext - call to CallIntMethod()", (HWND)0); - PrintDebugString("\r\n rHWND = %X", rHWND); + PrintDebugString("[INFO]: rHWND = %X", rHWND); return rHWND; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getHWNDFromAccessibleContextMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getHWNDFromAccessibleContextMethod == 0"); return (HWND)0; } } @@ -977,7 +974,7 @@ AccessBridgeJavaEntryPoints::setTextContents(const jobject accessibleContext, co jthrowable exception; BOOL result = FALSE; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::setTextContents(%p, %ls):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::setTextContents(%p, %ls):", accessibleContext, text); if (setTextContentsMethod != (jmethodID) 0) { @@ -985,7 +982,7 @@ AccessBridgeJavaEntryPoints::setTextContents(const jobject accessibleContext, co // create a Java String for the text jstring textString = jniEnv->NewString(text, (jsize)wcslen(text)); if (textString == 0) { - PrintDebugString("\r NewString failed"); + PrintDebugString("[ERROR]: NewString failed"); return FALSE; } @@ -993,10 +990,10 @@ AccessBridgeJavaEntryPoints::setTextContents(const jobject accessibleContext, co setTextContentsMethod, accessibleContext, textString); EXCEPTION_CHECK("setTextContents - call to CallBooleanMethod()", FALSE); - PrintDebugString("\r\n result = %d", result); + PrintDebugString("[INFO]: result = %d", result); return result; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or setTextContentsMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or setTextContentsMethod == 0"); return result; } } @@ -1014,14 +1011,14 @@ AccessBridgeJavaEntryPoints::getParentWithRole(const jobject accessibleContext, jthrowable exception; jobject rAccessibleContext; - PrintDebugString("In AccessBridgeJavaEntryPoints::getParentWithRole(%p):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getParentWithRole(%p):", accessibleContext); if (getParentWithRoleMethod != (jmethodID) 0) { // create a Java String for the role jstring roleName = jniEnv->NewString(role, (jsize)wcslen(role)); if (roleName == 0) { - PrintDebugString(" NewString failed"); + PrintDebugString("[ERROR]: NewString failed"); return FALSE; } @@ -1029,14 +1026,14 @@ AccessBridgeJavaEntryPoints::getParentWithRole(const jobject accessibleContext, getParentWithRoleMethod, accessibleContext, roleName); EXCEPTION_CHECK("Getting ParentWithRole - call to CallObjectMethod()", (AccessibleContext)0); - PrintDebugString(" rAccessibleContext = %p", rAccessibleContext); + PrintDebugString("[INFO]: rAccessibleContext = %p", rAccessibleContext); jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext); EXCEPTION_CHECK("Getting ParentWithRole - call to NewGlobalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", rAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getParentWithRoleMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getParentWithRoleMethod == 0"); return 0; } } @@ -1052,7 +1049,7 @@ AccessBridgeJavaEntryPoints::getTopLevelObject(const jobject accessibleContext) jthrowable exception; jobject rAccessibleContext; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getTopLevelObject(%p):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getTopLevelObject(%p):", accessibleContext); if (getTopLevelObjectMethod != (jmethodID) 0) { @@ -1060,14 +1057,14 @@ AccessBridgeJavaEntryPoints::getTopLevelObject(const jobject accessibleContext) getTopLevelObjectMethod, accessibleContext); EXCEPTION_CHECK("Getting TopLevelObject - call to CallObjectMethod()", FALSE); - PrintDebugString("\r\n rAccessibleContext = %p", rAccessibleContext); + PrintDebugString("[INFO]: rAccessibleContext = %p", rAccessibleContext); jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext); EXCEPTION_CHECK("Getting TopLevelObject - call to NewGlobalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", rAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getTopLevelObjectMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getTopLevelObjectMethod == 0"); return 0; } } @@ -1083,7 +1080,7 @@ AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(const jobject accessibleC jthrowable exception; jobject rAccessibleContext; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(%p):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(%p):", accessibleContext); if (getParentWithRoleElseRootMethod != (jmethodID) 0) { @@ -1091,7 +1088,7 @@ AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(const jobject accessibleC // create a Java String for the role jstring roleName = jniEnv->NewString(role, (jsize)wcslen(role)); if (roleName == 0) { - PrintDebugString("\r NewString failed"); + PrintDebugString("[ERROR]: NewString failed"); return FALSE; } @@ -1099,14 +1096,14 @@ AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(const jobject accessibleC getParentWithRoleElseRootMethod, accessibleContext, roleName); EXCEPTION_CHECK("Getting ParentWithRoleElseRoot - call to CallObjectMethod()", (AccessibleContext)0); - PrintDebugString(" rAccessibleContext = %p", rAccessibleContext); + PrintDebugString("[INFO]: rAccessibleContext = %p", rAccessibleContext); jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext); EXCEPTION_CHECK("Getting ParentWithRoleElseRoot - call to NewGlobalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", rAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getParentWithRoleElseRootMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getParentWithRoleElseRootMethod == 0"); return 0; } } @@ -1121,7 +1118,7 @@ AccessBridgeJavaEntryPoints::getObjectDepth(const jobject accessibleContext) { jthrowable exception; jint rResult; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getObjectDepth(%p):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getObjectDepth(%p):", accessibleContext); if (getObjectDepthMethod != (jmethodID) 0) { @@ -1129,10 +1126,10 @@ AccessBridgeJavaEntryPoints::getObjectDepth(const jobject accessibleContext) { getObjectDepthMethod, accessibleContext); EXCEPTION_CHECK("Getting ObjectDepth - call to CallIntMethod()", -1); - PrintDebugString("\r\n rResult = %d", rResult); + PrintDebugString("[INFO]: rResult = %d", rResult); return rResult; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getObjectDepthMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getObjectDepthMethod == 0"); return -1; } } @@ -1148,7 +1145,7 @@ AccessBridgeJavaEntryPoints::getActiveDescendent(const jobject accessibleContext jthrowable exception; jobject rAccessibleContext; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getActiveDescendent(%p):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getActiveDescendent(%p):", accessibleContext); if (getActiveDescendentMethod != (jmethodID) 0) { @@ -1156,14 +1153,14 @@ AccessBridgeJavaEntryPoints::getActiveDescendent(const jobject accessibleContext getActiveDescendentMethod, accessibleContext); EXCEPTION_CHECK("Getting ActiveDescendent - call to CallObjectMethod()", (AccessibleContext)0); - PrintDebugString("\r\n rAccessibleContext = %p", rAccessibleContext); + PrintDebugString("[INFO]: rAccessibleContext = %p", rAccessibleContext); jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext); EXCEPTION_CHECK("Getting ActiveDescendant - call to NewGlobalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", rAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getActiveDescendentMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getActiveDescendentMethod == 0"); return (AccessibleContext)0; } } @@ -1204,7 +1201,7 @@ AccessBridgeJavaEntryPoints::getVirtualAccessibleName ( const wchar_t * stringBytes = NULL; jthrowable exception = NULL; jsize length = 0; - PrintDebugString("\r\n getVirtualAccessibleName called."); + PrintDebugString("[INFO]: getVirtualAccessibleName called."); if (getVirtualAccessibleNameFromContextMethod != (jmethodID) 0) { js = (jstring) jniEnv->CallObjectMethod ( @@ -1231,12 +1228,12 @@ AccessBridgeJavaEntryPoints::getVirtualAccessibleName ( } else { - PrintDebugString(" Accessible Name is null."); + PrintDebugString("[INFO]: Accessible Name is null."); } } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or getVirtualAccessibleNameFromContextMethod == 0"); + PrintDebugString("[INFO]: either jniEnv == 0 or getVirtualAccessibleNameFromContextMethod == 0"); return FALSE; } if ( 0 != name [0] ) @@ -1258,7 +1255,7 @@ AccessBridgeJavaEntryPoints::requestFocus(const jobject accessibleContext) { jthrowable exception; BOOL result = FALSE; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::requestFocus(%p):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::requestFocus(%p):", accessibleContext); if (requestFocusMethod != (jmethodID) 0) { @@ -1266,10 +1263,10 @@ AccessBridgeJavaEntryPoints::requestFocus(const jobject accessibleContext) { requestFocusMethod, accessibleContext); EXCEPTION_CHECK("requestFocus - call to CallBooleanMethod()", FALSE); - PrintDebugString("\r\n result = %d", result); + PrintDebugString("[INFO]: result = %d", result); return result; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or requestFocusMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or requestFocusMethod == 0"); return result; } } @@ -1286,7 +1283,7 @@ AccessBridgeJavaEntryPoints::selectTextRange(const jobject accessibleContext, in jthrowable exception; BOOL result = FALSE; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::selectTextRange(%p start = %d end = %d):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::selectTextRange(%p start = %d end = %d):", accessibleContext, startIndex, endIndex); if (selectTextRangeMethod != (jmethodID) 0) { @@ -1295,10 +1292,10 @@ AccessBridgeJavaEntryPoints::selectTextRange(const jobject accessibleContext, in accessibleContext, startIndex, endIndex); EXCEPTION_CHECK("selectTextRange - call to CallBooleanMethod()", FALSE); - PrintDebugString("\r\n result = %d", result); + PrintDebugString("[INFO]: result = %d", result); return result; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or selectTextRangeMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or selectTextRangeMethod == 0"); return result; } } @@ -1355,7 +1352,7 @@ AccessBridgeJavaEntryPoints::getTextAttributesInRange(const jobject accessibleCo jsize length; BOOL result = FALSE; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getTextAttributesInRange(%p start = %d end = %d):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getTextAttributesInRange(%p start = %d end = %d):", accessibleContext, startIndex, endIndex); *len = 0; @@ -1370,12 +1367,12 @@ AccessBridgeJavaEntryPoints::getTextAttributesInRange(const jobject accessibleCo AccessibleTextAttributesInfo test_attributes = *attributes; // Get the full test_attributes string at i if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) { - PrintDebugString(" Getting full test_attributes string from Context..."); + PrintDebugString("[INFO]: Getting full test_attributes string from Context..."); js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleAttributesAtIndexFromContextMethod, accessibleContext, i); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE); @@ -1389,16 +1386,16 @@ AccessBridgeJavaEntryPoints::getTextAttributesInRange(const jobject accessibleCo jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Text attributes = %ls", test_attributes.fullAttributesString); + wPrintDebugString(L"[INFO]: Accessible Text attributes = %ls", test_attributes.fullAttributesString); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Text attributes is null."); + PrintDebugString("[WARN]: Accessible Text attributes is null."); test_attributes.fullAttributesString[0] = (wchar_t) 0; return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0"); return FALSE; } @@ -1421,14 +1418,14 @@ int AccessBridgeJavaEntryPoints::getVisibleChildrenCount(const jobject accessibleContext) { jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getVisibleChildrenCount(%p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getVisibleChildrenCount(%p)", accessibleContext); // get the visible children count int numChildren = jniEnv->CallIntMethod(accessBridgeObject, getVisibleChildrenCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting visible children count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### visible children count = %d", numChildren); + PrintDebugString("[INFO]: ##### visible children count = %d", numChildren); return numChildren; } @@ -1448,14 +1445,14 @@ BOOL AccessBridgeJavaEntryPoints::getVisibleChildren(const jobject accessibleCon jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getVisibleChildren(%p, startIndex = %d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getVisibleChildren(%p, startIndex = %d)", accessibleContext, nStartIndex); // get the visible children count int numChildren = jniEnv->CallIntMethod(accessBridgeObject, getVisibleChildrenCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting visible children count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### visible children count = %d", numChildren); + PrintDebugString("[INFO]: ##### visible children count = %d", numChildren); if (nStartIndex >= numChildren) { return FALSE; @@ -1464,7 +1461,7 @@ BOOL AccessBridgeJavaEntryPoints::getVisibleChildren(const jobject accessibleCon // get the visible children int bufIndex = 0; for (int i = nStartIndex; (i < numChildren) && (i < nStartIndex + MAX_VISIBLE_CHILDREN); i++) { - PrintDebugString(" getting visible child %d ...", i); + PrintDebugString("[INFO]: getting visible child %d ...", i); // get the visible child at index i jobject ac = jniEnv->CallObjectMethod(accessBridgeObject, getVisibleChildMethod, @@ -1473,13 +1470,13 @@ BOOL AccessBridgeJavaEntryPoints::getVisibleChildren(const jobject accessibleCon jobject globalRef = jniEnv->NewGlobalRef(ac); EXCEPTION_CHECK("##### getVisibleChildMethod - call to NewGlobalRef()", FALSE); visibleChildrenInfo->children[bufIndex] = (JOBJECT64)globalRef; - PrintDebugString(" ##### visible child = %p", globalRef); + PrintDebugString("[INFO]: ##### visible child = %p", globalRef); bufIndex++; } visibleChildrenInfo->returnedChildrenCount = bufIndex; - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getVisibleChildren succeeded"); + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getVisibleChildren succeeded"); return TRUE; } @@ -1494,7 +1491,7 @@ AccessBridgeJavaEntryPoints::setCaretPosition(const jobject accessibleContext, i jthrowable exception; BOOL result = FALSE; - PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::setCaretPostion(%p position = %d):", + PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::setCaretPostion(%p position = %d):", accessibleContext, position); if (setCaretPositionMethod != (jmethodID) 0) { @@ -1502,10 +1499,10 @@ AccessBridgeJavaEntryPoints::setCaretPosition(const jobject accessibleContext, i setCaretPositionMethod, accessibleContext, position); EXCEPTION_CHECK("setCaretPostion - call to CallBooleanMethod()", FALSE); - PrintDebugString("\r\n result = %d", result); + PrintDebugString("[ERROR]: result = %d", result); return result; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or setCaretPositionMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or setCaretPositionMethod == 0"); return result; } } @@ -1525,19 +1522,19 @@ AccessBridgeJavaEntryPoints::getVersionInfo(AccessBridgeVersionInfo *info) { jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getVersionInfo():"); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getVersionInfo():"); if (getJavaVersionPropertyMethod != (jmethodID) 0) { js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject, getJavaVersionPropertyMethod); EXCEPTION_CHECK("Getting JavaVersionProperty - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { length = jniEnv->GetStringLength(js); stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); if (stringBytes == NULL) { if (!jniEnv->ExceptionCheck()) { - PrintDebugString("\r\n *** Exception when getting JavaVersionProperty - call to GetStringChars"); + PrintDebugString("[ERROR]: *** Exception when getting JavaVersionProperty - call to GetStringChars"); jniEnv->ExceptionDescribe(); jniEnv->ExceptionClear(); } @@ -1572,12 +1569,12 @@ AccessBridgeJavaEntryPoints::getVersionInfo(AccessBridgeVersionInfo *info) { jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting JavaVersionProperty - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Java version is null."); + PrintDebugString("[WARN]: Java version is null."); info->VMversion[0] = (wchar_t) 0; return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getJavaVersionPropertyMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getJavaVersionPropertyMethod == 0"); return FALSE; } @@ -1594,15 +1591,15 @@ BOOL AccessBridgeJavaEntryPoints::verifyAccessibleText(jobject obj) { BOOL retval; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::verifyAccessibleText"); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::verifyAccessibleText"); if (jniEnv->GetJavaVM(&vm) != 0) { - PrintDebugString(" Error! No Java VM"); + PrintDebugString("[ERROR]: No Java VM"); return FALSE; } if (obj == (jobject)0) { - PrintDebugString(" Error! Null jobject"); + PrintDebugString("[ERROR]: Null jobject"); return FALSE; } @@ -1612,16 +1609,16 @@ BOOL AccessBridgeJavaEntryPoints::verifyAccessibleText(jobject obj) { getAccessibleTextFromContextMethod, (jobject)obj); EXCEPTION_CHECK("Getting AccessibleText - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleText = %p", returnedJobject); + PrintDebugString("[ERROR]: AccessibleText = %p", returnedJobject); retval = returnedJobject != (jobject) 0; jniEnv->DeleteLocalRef(returnedJobject); EXCEPTION_CHECK("Getting AccessibleText - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextFromContextMethod == 0"); return FALSE; } if (retval == FALSE) { - PrintDebugString(" Error! jobject is not an AccessibleText"); + PrintDebugString("[ERROR]: jobject is not an AccessibleText"); } return retval; } @@ -1646,7 +1643,7 @@ AccessBridgeJavaEntryPoints::getAccessibleContextAt(jint x, jint y, jobject acce jobject globalRef; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleContextAt(%d, %d, %p):", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleContextAt(%d, %d, %p):", x, y, accessibleContext); if (getAccessibleContextAtMethod != (jmethodID) 0) { @@ -1656,11 +1653,11 @@ AccessBridgeJavaEntryPoints::getAccessibleContextAt(jint x, jint y, jobject acce EXCEPTION_CHECK("Getting AccessibleContextAt - call to CallObjectMethod()", FALSE); globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleContextAt - call to NewGlobalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleContextAtMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleContextAtMethod == 0"); return (jobject) 0; } } @@ -1681,7 +1678,7 @@ AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus() { jobject globalRef; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus()"); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus()"); if (getAccessibleContextWithFocusMethod != (jmethodID) 0) { returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject, @@ -1689,11 +1686,11 @@ AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus() { EXCEPTION_CHECK("Getting AccessibleContextWithFocus - call to CallObjectMethod()", FALSE); globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleContextWithFocus - call to NewGlobalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either jniEnv == 0 or getAccessibleContextWithFocusMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or getAccessibleContextWithFocusMethod == 0"); return (jobject) 0; } } @@ -1718,12 +1715,12 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jthrowable exception; jsize length; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleContextInfo(%p):", accessibleContext); + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleContextInfo(%p):", accessibleContext); ZeroMemory(info, sizeof(AccessibleContextInfo)); if (accessibleContext == (jobject) 0) { - PrintDebugString(" passed in AccessibleContext == null! (oops)"); + PrintDebugString("[WARN]: passed in AccessibleContext == null! (oops)"); return (FALSE); } @@ -1746,15 +1743,15 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Name = %ls", info->name); + wPrintDebugString(L"[INFO]: Accessible Name = %ls", info->name); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Name is null."); + PrintDebugString("[WARN]: Accessible Name is null."); info->name[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleNameFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleNameFromContextMethod == 0"); return FALSE; } @@ -1778,15 +1775,15 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Description = %ls", info->description); + wPrintDebugString(L"[INFO]: Accessible Description = %ls", info->description); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Description is null."); + PrintDebugString("[WARN]: Accessible Description is null."); info->description[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleDescriptionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleDescriptionFromContextMethod == 0"); return FALSE; } @@ -1810,15 +1807,15 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleRole - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Role = %ls", info->role); + wPrintDebugString(L"[INFO]: Accessible Role = %ls", info->role); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleRole - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Role is null."); + PrintDebugString("[WARN]: Accessible Role is null."); info->role[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleRoleStringFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleRoleStringFromContextMethod == 0"); return FALSE; } @@ -1842,15 +1839,15 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Role en_US = %ls", info->role_en_US); + wPrintDebugString(L"[INFO]: Accessible Role en_US = %ls", info->role_en_US); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Role en_US is null."); + PrintDebugString("[WARN]: Accessible Role en_US is null."); info->role[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleRoleStringFromContext_en_USMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleRoleStringFromContext_en_USMethod == 0"); return FALSE; } @@ -1873,15 +1870,15 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleState - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible States = %ls", info->states); + wPrintDebugString(L"[INFO]: Accessible States = %ls", info->states); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleState - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible States is null."); + PrintDebugString("[WARN]: Accessible States is null."); info->states[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleStatesStringFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleStatesStringFromContextMethod == 0"); return FALSE; } @@ -1904,15 +1901,15 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible States en_US = %ls", info->states_en_US); + wPrintDebugString(L"[INFO]: Accessible States en_US = %ls", info->states_en_US); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleState_en_US - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible States en_US is null."); + PrintDebugString("[WARN]: Accessible States en_US is null."); info->states[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleStatesStringFromContext_en_USMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleStatesStringFromContext_en_USMethod == 0"); return FALSE; } @@ -1923,14 +1920,14 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleIndexInParentFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleIndexInParent - call to CallIntMethod()", FALSE); - PrintDebugString(" Index in Parent = %d", info->indexInParent); + PrintDebugString("[INFO]: Index in Parent = %d", info->indexInParent); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleIndexInParentFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleIndexInParentFromContextMethod == 0"); return FALSE; } - PrintDebugString("*** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %p ***", + PrintDebugString("[INFO]: *** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %p ***", jniEnv, accessBridgeObject, accessibleContext); // Get the children count @@ -1939,13 +1936,13 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleChildrenCountFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleChildrenCount - call to CallIntMethod()", FALSE); - PrintDebugString(" Children count = %d", info->childrenCount); + PrintDebugString("[INFO]: Children count = %d", info->childrenCount); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleChildrenCountFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleChildrenCountFromContextMethod == 0"); return FALSE; } - PrintDebugString("*** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %X ***", + PrintDebugString("[INFO]: *** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %X ***", jniEnv, accessBridgeObject, accessibleContext); @@ -1955,13 +1952,13 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleXcoordFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleXcoord - call to CallIntMethod()", FALSE); - PrintDebugString(" X coord = %d", info->x); + PrintDebugString("[INFO]: X coord = %d", info->x); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleXcoordFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleXcoordFromContextMethod == 0"); return FALSE; } - PrintDebugString("*** jniEnv: %X; accessBridgeObject: %X; AccessibleContext: %p ***", + PrintDebugString("[INFO]: *** jniEnv: %X; accessBridgeObject: %X; AccessibleContext: %p ***", jniEnv, accessBridgeObject, accessibleContext); @@ -1971,9 +1968,9 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleYcoordFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleYcoord - call to CallIntMethod()", FALSE); - PrintDebugString(" Y coord = %d", info->y); + PrintDebugString("[INFO]: Y coord = %d", info->y); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleYcoordFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleYcoordFromContextMethod == 0"); return FALSE; } @@ -1983,9 +1980,9 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleWidthFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleWidth - call to CallIntMethod()", FALSE); - PrintDebugString(" Width = %d", info->width); + PrintDebugString("[INFO]: Width = %d", info->width); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleWidthFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleWidthFromContextMethod == 0"); return FALSE; } @@ -1995,9 +1992,9 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleHeightFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleHeight - call to CallIntMethod()", FALSE); - PrintDebugString(" Height = %d", info->height); + PrintDebugString("[INFO]: Height = %d", info->height); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleHeightFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleHeightFromContextMethod == 0"); return FALSE; } @@ -2007,12 +2004,12 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleComponentFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleComponent - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleComponent = %p", returnedJobject); + PrintDebugString("[INFO]: AccessibleComponent = %p", returnedJobject); info->accessibleComponent = (returnedJobject != (jobject) 0 ? TRUE : FALSE); jniEnv->DeleteLocalRef(returnedJobject); EXCEPTION_CHECK("Getting AccessibleComponent - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleComponentFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleComponentFromContextMethod == 0"); return FALSE; } @@ -2022,12 +2019,12 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleActionFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleAction - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleAction = %p", returnedJobject); + PrintDebugString("[INFO]: AccessibleAction = %p", returnedJobject); info->accessibleAction = (returnedJobject != (jobject) 0 ? TRUE : FALSE); jniEnv->DeleteLocalRef(returnedJobject); EXCEPTION_CHECK("Getting AccessibleAction - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleActionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleActionFromContextMethod == 0"); return FALSE; } @@ -2037,24 +2034,24 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleSelectionFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleSelection - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleSelection = %p", returnedJobject); + PrintDebugString("[INFO]: AccessibleSelection = %p", returnedJobject); info->accessibleSelection = (returnedJobject != (jobject) 0 ? TRUE : FALSE); jniEnv->DeleteLocalRef(returnedJobject); EXCEPTION_CHECK("Getting AccessibleSelection - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleSelectionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleSelectionFromContextMethod == 0"); return FALSE; } // Get the AccessibleTable if (getAccessibleTableFromContextMethod != (jmethodID) 0) { - PrintDebugString("##### Calling getAccessibleTableFromContextMethod ..."); + PrintDebugString("[INFO]: ##### Calling getAccessibleTableFromContextMethod ..."); returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleTableFromContextMethod, accessibleContext); - PrintDebugString("##### ... Returned from getAccessibleTableFromContextMethod"); + PrintDebugString("[INFO]: ##### ... Returned from getAccessibleTableFromContextMethod"); EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE); - PrintDebugString(" ##### AccessibleTable = %p", returnedJobject); + PrintDebugString("[INFO]: ##### AccessibleTable = %p", returnedJobject); if (returnedJobject != (jobject) 0) { info->accessibleInterfaces |= cAccessibleTableInterface; } @@ -2072,7 +2069,7 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, */ } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableFromContextMethod == 0"); return FALSE; } @@ -2082,12 +2079,12 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleTextFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleText - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleText = %p", returnedJobject); + PrintDebugString("[INFO]: AccessibleText = %p", returnedJobject); info->accessibleText = (returnedJobject != (jobject) 0 ? TRUE : FALSE); jniEnv->DeleteLocalRef(returnedJobject); EXCEPTION_CHECK("Getting AccessibleText - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextFromContextMethod == 0"); return FALSE; } @@ -2097,14 +2094,14 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleValueFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleValue - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleValue = %p", returnedJobject); + PrintDebugString("[INFO]: AccessibleValue = %p", returnedJobject); if (returnedJobject != (jobject) 0) { info->accessibleInterfaces |= cAccessibleValueInterface; } jniEnv->DeleteLocalRef(returnedJobject); EXCEPTION_CHECK("Getting AccessibleValue - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleValueFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleValueFromContextMethod == 0"); return FALSE; } @@ -2120,7 +2117,7 @@ AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, getAccessibleHypertextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleHypertext - call to CallObjectMethod()", FALSE); - PrintDebugString(" AccessibleHypertext = %p", + PrintDebugString("[INFO]: AccessibleHypertext = %p", returnedJobject); if (returnedJobject != (jobject) 0) { info->accessibleInterfaces |= cAccessibleHypertextInterface; @@ -2161,7 +2158,7 @@ AccessBridgeJavaEntryPoints::getAccessibleChildFromContext(jobject accessibleCon jobject globalRef; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleChildContext(%p, %d):", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleChildContext(%p, %d):", accessibleContext, childIndex); if (getAccessibleChildFromContextMethod != (jmethodID) 0) { @@ -2173,11 +2170,11 @@ AccessBridgeJavaEntryPoints::getAccessibleChildFromContext(jobject accessibleCon EXCEPTION_CHECK("Getting AccessibleChild - call to NewGlobalRef()", FALSE); jniEnv->DeleteLocalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleChild - call to DeleteLocalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleChildContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleChildContextMethod == 0"); return (jobject) 0; } } @@ -2193,7 +2190,7 @@ AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(jobject accessibleCo jobject globalRef; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(%p):", accessibleContext); if (getAccessibleParentFromContextMethod != (jmethodID) 0) { returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject, @@ -2204,11 +2201,11 @@ AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(jobject accessibleCo EXCEPTION_CHECK("Getting AccessibleParent - call to NewGlobalRef()", FALSE); jniEnv->DeleteLocalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleParent - call to DeleteLocalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleParentFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleParentFromContextMethod == 0"); return (jobject) 0; } } @@ -2222,7 +2219,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableInfo(jobject accessibleContext, jthrowable exception; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo(%p):", + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo(%p):", accessibleContext); // get the table row count @@ -2231,9 +2228,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableInfo(jobject accessibleContext, getAccessibleTableRowCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting AccessibleTableRowCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table row count = %d", tableInfo->rowCount); + PrintDebugString("[INFO]: ##### table row count = %d", tableInfo->rowCount); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleRowCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleRowCountMethod == 0"); return FALSE; } @@ -2243,43 +2240,43 @@ AccessBridgeJavaEntryPoints::getAccessibleTableInfo(jobject accessibleContext, getAccessibleTableColumnCountMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleTableColumnCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table column count = %d", tableInfo->columnCount); + PrintDebugString("[INFO]: ##### table column count = %d", tableInfo->columnCount); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableColumnCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnCountMethod == 0"); return FALSE; } // get the AccessibleTable if (getAccessibleTableFromContextMethod != (jmethodID) 0) { - PrintDebugString("##### Calling getAccessibleTableFromContextMethod ..."); + PrintDebugString("[INFO]: ##### Calling getAccessibleTableFromContextMethod ..."); jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleTableFromContextMethod, accessibleContext); - PrintDebugString("##### ... Returned from getAccessibleTableFromContextMethod"); + PrintDebugString("[INFO]: ##### ... Returned from getAccessibleTableFromContextMethod"); EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE); jobject globalRef = jniEnv->NewGlobalRef(accTable); EXCEPTION_CHECK("##### Getting AccessibleTable - call to NewGlobalRef()", FALSE); tableInfo->accessibleTable = (JOBJECT64)globalRef; - PrintDebugString(" ##### accessibleTable = %p", globalRef); + PrintDebugString("[INFO]: ##### accessibleTable = %p", globalRef); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableFromContextMethod == 0"); return FALSE; } // cache the AccessibleContext if (getContextFromAccessibleTableMethod != (jmethodID) 0) { - PrintDebugString("##### Calling getContextFromAccessibleTable Method ..."); + PrintDebugString("[INFO]: ##### Calling getContextFromAccessibleTable Method ..."); jobject ac = jniEnv->CallObjectMethod(accessBridgeObject, getContextFromAccessibleTableMethod, accessibleContext); - PrintDebugString("##### ... Returned from getContextFromAccessibleTable Method"); + PrintDebugString("[INFO]: ##### ... Returned from getContextFromAccessibleTable Method"); EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE); jobject globalRef = jniEnv->NewGlobalRef(ac); EXCEPTION_CHECK("##### Getting AccessibleTable - call to NewGlobalRef()", FALSE); tableInfo->accessibleContext = (JOBJECT64)globalRef; - PrintDebugString(" ##### accessibleContext = %p", globalRef); + PrintDebugString("[INFO]: ##### accessibleContext = %p", globalRef); } else { - PrintDebugString(" ##### Error! either env == 0 or getContextFromAccessibleTable Method == 0"); + PrintDebugString("[ERROR]: either env == 0 or getContextFromAccessibleTable Method == 0"); return FALSE; } @@ -2287,7 +2284,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableInfo(jobject accessibleContext, tableInfo->caption = NULL; tableInfo->summary = NULL; - PrintDebugString("##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo succeeded"); + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo succeeded"); return TRUE; } @@ -2297,7 +2294,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, jthrowable exception; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(%p): row=%d, column=%d", + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(%p): row=%d, column=%d", accessibleTable, row, column); // FIX @@ -2312,9 +2309,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, getAccessibleTableCellIndexMethod, accessibleTable, row, column); EXCEPTION_CHECK("##### Getting AccessibleTableCellIndex - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table cell index = %d", tableCellInfo->index); + PrintDebugString("[INFO]: ##### table cell index = %d", tableCellInfo->index); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableCellIndexMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellIndexMethod == 0"); return FALSE; } @@ -2324,9 +2321,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, getAccessibleTableCellRowExtentMethod, accessibleTable, row, column); EXCEPTION_CHECK("##### Getting AccessibleTableCellRowExtentCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table cell row extent = %d", tableCellInfo->rowExtent); + PrintDebugString("[INFO]: ##### table cell row extent = %d", tableCellInfo->rowExtent); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableCellRowExtentMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellRowExtentMethod == 0"); return FALSE; } @@ -2336,9 +2333,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, getAccessibleTableCellColumnExtentMethod, accessibleTable, row, column); EXCEPTION_CHECK("##### Getting AccessibleTableCellColumnExtentCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table cell column extent = %d", tableCellInfo->columnExtent); + PrintDebugString("[INFO]: ##### table cell column extent = %d", tableCellInfo->columnExtent); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableCellColumnExtentMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellColumnExtentMethod == 0"); return FALSE; } @@ -2348,9 +2345,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, isAccessibleTableCellSelectedMethod, accessibleTable, row, column); EXCEPTION_CHECK("##### Getting isAccessibleTableCellSelected - call to CallBooleanMethod()", FALSE); - PrintDebugString(" ##### table cell isSelected = %d", tableCellInfo->isSelected); + PrintDebugString("[INFO]: ##### table cell isSelected = %d", tableCellInfo->isSelected); } else { - PrintDebugString(" ##### Error! either env == 0 or isAccessibleTableCellSelectedMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or isAccessibleTableCellSelectedMethod == 0"); return FALSE; } @@ -2363,13 +2360,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, jobject globalRef = jniEnv->NewGlobalRef(tableCellAC); EXCEPTION_CHECK("##### Getting AccessibleTableCellAccessibleContext - call to NewGlobalRef()", FALSE); tableCellInfo->accessibleContext = (JOBJECT64)globalRef; - PrintDebugString(" ##### table cell AccessibleContext = %p", globalRef); + PrintDebugString("[INFO]: ##### table cell AccessibleContext = %p", globalRef); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableCellAccessibleContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellAccessibleContextMethod == 0"); return FALSE; } - PrintDebugString(" ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo succeeded"); + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo succeeded"); return TRUE; } @@ -2378,7 +2375,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, Acces jthrowable exception; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(%p):", + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(%p):", acParent); // get the header row count @@ -2387,9 +2384,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, Acces getAccessibleTableRowHeaderRowCountMethod, acParent); EXCEPTION_CHECK("##### Getting AccessibleTableRowHeaderRowCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table row count = %d", tableInfo->rowCount); + PrintDebugString("[INFO]: ##### table row count = %d", tableInfo->rowCount); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleRowHeaderRowCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleRowHeaderRowCountMethod == 0"); return FALSE; } @@ -2399,9 +2396,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, Acces getAccessibleTableRowHeaderColumnCountMethod, acParent); EXCEPTION_CHECK("Getting AccessibleTableRowHeaderColumnCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table column count = %d", tableInfo->columnCount); + PrintDebugString("[INFO]: ##### table column count = %d", tableInfo->columnCount); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableRowHeaderColumnCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowHeaderColumnCountMethod == 0"); return FALSE; } @@ -2414,9 +2411,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, Acces jobject globalRef = jniEnv->NewGlobalRef(accTable); EXCEPTION_CHECK("##### Getting AccessibleTableRowHeader - call to NewGlobalRef()", FALSE); tableInfo->accessibleTable = (JOBJECT64)globalRef; - PrintDebugString(" ##### row header AccessibleTable = %p", globalRef); + PrintDebugString("[INFO]: ##### row header AccessibleTable = %p", globalRef); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableRowHeaderMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowHeaderMethod == 0"); return FALSE; } @@ -2425,7 +2422,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, Acces tableInfo->summary = NULL; tableInfo->accessibleContext = NULL; - PrintDebugString(" ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader succeeded"); + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader succeeded"); return TRUE; } @@ -2433,7 +2430,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, AccessibleTableInfo *tableInfo) { jthrowable exception; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(%p):", + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(%p):", acParent); // get the header row count @@ -2442,9 +2439,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, Ac getAccessibleTableColumnHeaderRowCountMethod, acParent); EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeaderRowCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table row count = %d", tableInfo->rowCount); + PrintDebugString("[INFO]: ##### table row count = %d", tableInfo->rowCount); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleColumnHeaderRowCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleColumnHeaderRowCountMethod == 0"); return FALSE; } @@ -2454,9 +2451,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, Ac getAccessibleTableColumnHeaderColumnCountMethod, acParent); EXCEPTION_CHECK("Getting AccessibleTableColumnHeaderColumnCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table column count = %d", tableInfo->columnCount); + PrintDebugString("[INFO]: ##### table column count = %d", tableInfo->columnCount); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableColumnHeaderColumnCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnHeaderColumnCountMethod == 0"); return FALSE; } // get the header AccessibleTable @@ -2468,9 +2465,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, Ac jobject globalRef = jniEnv->NewGlobalRef(accTable); EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeader - call to NewGlobalRef()", FALSE); tableInfo->accessibleTable = (JOBJECT64)globalRef; - PrintDebugString(" ##### column header AccessibleTable = %p", globalRef); + PrintDebugString("[INFO]: ##### column header AccessibleTable = %p", globalRef); } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableColumnHeaderMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnHeaderMethod == 0"); return FALSE; } @@ -2479,7 +2476,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, Ac tableInfo->summary = NULL; tableInfo->accessibleContext = NULL; - PrintDebugString(" ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader succeeded"); + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader succeeded"); return TRUE; } @@ -2490,7 +2487,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(jobject acParent, jobject globalRef; jthrowable exception; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(%p):", + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(%p):", acParent); if (getAccessibleTableRowDescriptionMethod != (jmethodID) 0) { @@ -2502,11 +2499,11 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(jobject acParent, EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to NewGlobalRef()", FALSE); jniEnv->DeleteLocalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to DeleteLocalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTableRowDescriptionMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowDescriptionMethod == 0"); return (jobject) 0; } } @@ -2518,7 +2515,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(jobject acParen jobject globalRef; jthrowable exception; - PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(%p):", + PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(%p):", acParent); if (getAccessibleTableColumnDescriptionMethod != (jmethodID) 0) { @@ -2531,11 +2528,11 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(jobject acParen EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to NewGlobalRef()", FALSE); jniEnv->DeleteLocalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to DeleteLocalRef()", FALSE); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTableColumnDescriptionMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnDescriptionMethod == 0"); return (jobject) 0; } } @@ -2546,7 +2543,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(jobject accessi jthrowable exception; jint count; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(%p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(%p)", accessibleTable); // Get the table row selection count @@ -2555,14 +2552,14 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(jobject accessi getAccessibleTableRowSelectionCountMethod, accessibleTable); EXCEPTION_CHECK("##### Getting AccessibleTableRowSelectionCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table row selection count = %d", count); + PrintDebugString("[INFO]: ##### table row selection count = %d", count); return count; } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableRowSelectionCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowSelectionCountMethod == 0"); return 0; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount failed"); + PrintDebugString("[ERROR]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount failed"); return 0; } @@ -2571,7 +2568,7 @@ AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(jobject accessibleTabl jthrowable exception; BOOL result; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(%p, %d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(%p, %d)", accessibleTable, row); if (isAccessibleTableRowSelectedMethod != (jmethodID) 0) { @@ -2579,14 +2576,14 @@ AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(jobject accessibleTabl isAccessibleTableRowSelectedMethod, accessibleTable, row); EXCEPTION_CHECK("##### Getting isAccessibleTableRowSelected - call to CallBooleanMethod()", FALSE); - PrintDebugString(" ##### table row isSelected = %d", result); + PrintDebugString("[INFO]: ##### table row isSelected = %d", result); return result; } else { - PrintDebugString(" ##### Error! either env == 0 or isAccessibleTableRowSelectedMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or isAccessibleTableRowSelectedMethod == 0"); return FALSE; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected failed"); + PrintDebugString("[ERROR]: AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected failed"); return FALSE; } @@ -2596,7 +2593,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(jobject accessibleT jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(%p, %d %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(%p, %d %p)", accessibleTable, count, selections); if (getAccessibleTableRowSelectionsMethod == (jmethodID) 0) { @@ -2610,10 +2607,10 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(jobject accessibleT accessibleTable, i); EXCEPTION_CHECK("##### Getting AccessibleTableRowSelections - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table row selection[%d] = %d", i, selections[i]); + PrintDebugString("[INFO]: ##### table row selection[%d] = %d", i, selections[i]); } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections succeeded"); + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections succeeded"); return TRUE; } @@ -2624,7 +2621,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(jobject acce jthrowable exception; jint count; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(%p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(%p)", accessibleTable); // Get the table column selection count @@ -2633,14 +2630,14 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(jobject acce getAccessibleTableColumnSelectionCountMethod, accessibleTable); EXCEPTION_CHECK("##### Getting AccessibleTableColumnSelectionCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table column selection count = %d", count); + PrintDebugString("[INFO]: ##### table column selection count = %d", count); return count; } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleRowCountMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleRowCountMethod == 0"); return 0; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount failed"); + PrintDebugString("[ERROR]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount failed"); return 0; } @@ -2649,7 +2646,7 @@ AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(jobject accessibleT jthrowable exception; BOOL result; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(%p, %d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(%p, %d)", accessibleTable, column); if (isAccessibleTableColumnSelectedMethod != (jmethodID) 0) { @@ -2657,14 +2654,14 @@ AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(jobject accessibleT isAccessibleTableColumnSelectedMethod, accessibleTable, column); EXCEPTION_CHECK("##### Getting isAccessibleTableColumnSelected - call to CallBooleanMethod()", FALSE); - PrintDebugString(" ##### table column isSelected = %d", result); + PrintDebugString("[INFO]: ##### table column isSelected = %d", result); return result; } else { - PrintDebugString(" ##### Error! either env == 0 or isAccessibleTableColumnSelectedMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or isAccessibleTableColumnSelectedMethod == 0"); return FALSE; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected failed"); + PrintDebugString("[ERROR]: ##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected failed"); return FALSE; } @@ -2673,7 +2670,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(jobject accessib jint *selections) { jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(%p, %d, %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(%p, %d, %p)", accessibleTable, count, selections); if (getAccessibleTableColumnSelectionsMethod == (jmethodID) 0) { @@ -2687,10 +2684,10 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(jobject accessib accessibleTable, i); EXCEPTION_CHECK("##### Getting AccessibleTableColumnSelections - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table Column selection[%d] = %d", i, selections[i]); + PrintDebugString("[INFO]: ##### table Column selection[%d] = %d", i, selections[i]); } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections succeeded"); + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections succeeded"); return TRUE; } @@ -2700,7 +2697,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRow(jobject accessibleTable, jint jthrowable exception; jint result; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableRow(%p, index=%d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRow(%p, index=%d)", accessibleTable, index); if (getAccessibleTableRowMethod != (jmethodID) 0) { @@ -2708,14 +2705,14 @@ AccessBridgeJavaEntryPoints::getAccessibleTableRow(jobject accessibleTable, jint getAccessibleTableRowMethod, accessibleTable, index); EXCEPTION_CHECK("##### Getting AccessibleTableRow - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table row = %d", result); + PrintDebugString("[INFO]: ##### table row = %d", result); return result; } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableRowMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowMethod == 0"); return -1; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableRow failed"); + PrintDebugString("[ERROR]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRow failed"); return -1; } @@ -2724,7 +2721,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumn(jobject accessibleTable, j jthrowable exception; jint result; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn(%p, index=%d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn(%p, index=%d)", accessibleTable, index); if (getAccessibleTableColumnMethod != (jmethodID) 0) { @@ -2732,14 +2729,14 @@ AccessBridgeJavaEntryPoints::getAccessibleTableColumn(jobject accessibleTable, j getAccessibleTableColumnMethod, accessibleTable, index); EXCEPTION_CHECK("##### Getting AccessibleTableColumn - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table column = %d", result); + PrintDebugString("[INFO]: ##### table column = %d", result); return result; } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableColumnMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnMethod == 0"); return -1; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn failed"); + PrintDebugString("[ERROR]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn failed"); return -1; } @@ -2748,7 +2745,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTableIndex(jobject accessibleTable, ji jthrowable exception; jint result; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex(%p, row=%d, col=%d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex(%p, row=%d, col=%d)", accessibleTable, row, column); if (getAccessibleTableIndexMethod != (jmethodID) 0) { @@ -2756,14 +2753,14 @@ AccessBridgeJavaEntryPoints::getAccessibleTableIndex(jobject accessibleTable, ji getAccessibleTableIndexMethod, accessibleTable, row, column); EXCEPTION_CHECK("##### Getting getAccessibleTableIndex - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### table index = %d", result); + PrintDebugString("[INFO]: ##### table index = %d", result); return result; } else { - PrintDebugString(" ##### Error! either env == 0 or getAccessibleTableIndexMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableIndexMethod == 0"); return -1; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex failed"); + PrintDebugString("[ERROR]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex failed"); return -1; } @@ -2780,7 +2777,7 @@ AccessBridgeJavaEntryPoints::getAccessibleRelationSet(jobject accessibleContext, const wchar_t *stringBytes; jsize length; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet(%p, %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet(%p, %p)", accessibleContext, relationSet); if (getAccessibleRelationCountMethod == (jmethodID) 0 || @@ -2795,7 +2792,7 @@ AccessBridgeJavaEntryPoints::getAccessibleRelationSet(jobject accessibleContext, getAccessibleRelationCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting AccessibleRelationCount - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### AccessibleRelation count = %d", relationSet->relationCount); + PrintDebugString("[INFO]: ##### AccessibleRelation count = %d", relationSet->relationCount); // Get the relation set @@ -2820,11 +2817,11 @@ AccessBridgeJavaEntryPoints::getAccessibleRelationSet(jobject accessibleContext, // jniEnv->CallVoidMethod(accessBridgeObject, // decrementReferenceMethod, js); //EXCEPTION_CHECK("Getting AccessibleRelation key - call to CallVoidMethod()", FALSE); - PrintDebugString("##### AccessibleRelation key = %ls", relationSet->relations[i].key ); + PrintDebugString("[INFO]: ##### AccessibleRelation key = %ls", relationSet->relations[i].key ); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleRelation key - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AccessibleRelation key is null."); + PrintDebugString("[WARN]: AccessibleRelation key is null."); relationSet->relations[i].key [0] = (wchar_t) 0; } @@ -2840,11 +2837,11 @@ AccessBridgeJavaEntryPoints::getAccessibleRelationSet(jobject accessibleContext, jobject globalRef = jniEnv->NewGlobalRef(target); EXCEPTION_CHECK("Getting AccessibleRelationSet - call to NewGlobalRef()", FALSE); relationSet->relations[i].targets[j] = (JOBJECT64)globalRef; - PrintDebugString(" relation set item: %p", globalRef); + PrintDebugString("[INFO]: relation set item: %p", globalRef); } } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet succeeded"); + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet succeeded"); return TRUE; } @@ -2862,7 +2859,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, const wchar_t *stringBytes; jsize length; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHypertext(%p, %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertext(%p, %p)", accessibleContext, hypertext); // get the AccessibleHypertext @@ -2873,10 +2870,10 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, jobject globalRef = jniEnv->NewGlobalRef(ht); EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to NewGlobalRef()", FALSE); hypertext->accessibleHypertext = (JOBJECT64)globalRef; - PrintDebugString(" ##### AccessibleHypertext = %p", globalRef); + PrintDebugString("[INFO]: ##### AccessibleHypertext = %p", globalRef); if (hypertext->accessibleHypertext == 0) { - PrintDebugString(" ##### null AccessibleHypertext; returning FALSE"); + PrintDebugString("[WARN]: ##### null AccessibleHypertext; returning FALSE"); return false; } @@ -2885,7 +2882,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, getAccessibleHyperlinkCountMethod,accessibleContext); EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink count = %d", hypertext->linkCount); + PrintDebugString("[INFO]: ##### hyperlink count = %d", hypertext->linkCount); // get the hypertext links @@ -2900,7 +2897,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, jobject globalRef = jniEnv->NewGlobalRef(hl); EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE); hypertext->links[i].accessibleHyperlink = (JOBJECT64)globalRef; - PrintDebugString(" ##### AccessibleHyperlink = %p", globalRef); + PrintDebugString("[INFO]: ##### AccessibleHyperlink = %p", globalRef); // get the hyperlink text jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject, @@ -2924,11 +2921,11 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, // jniEnv->CallVoidMethod(accessBridgeObject, // decrementReferenceMethod, js); //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE); - PrintDebugString("##### AccessibleHyperlink text = %ls", hypertext->links[i].text ); + PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[i].text ); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AccessibleHyperlink text is null."); + PrintDebugString("[WARN]: AccessibleHyperlink text is null."); hypertext->links[i].text[0] = (wchar_t) 0; } @@ -2937,7 +2934,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, hypertext->links[i].accessibleHyperlink, i); EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink start index = %d", hypertext->links[i].startIndex); + PrintDebugString("[INFO]: ##### hyperlink start index = %d", hypertext->links[i].startIndex); hypertext->links[i].endIndex = jniEnv->CallIntMethod(accessBridgeObject, @@ -2945,11 +2942,11 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext, hypertext->links[i].accessibleHyperlink, i); EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink end index = %d", hypertext->links[i].endIndex); + PrintDebugString("[INFO]: ##### hyperlink end index = %d", hypertext->links[i].endIndex); } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleHypertext succeeded"); + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertext succeeded"); return TRUE; } @@ -2963,7 +2960,7 @@ AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(jobject accessibleConte jthrowable exception; BOOL returnVal; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(%p, %p):", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(%p, %p):", accessibleContext, accessibleHyperlink); if (activateAccessibleHyperlinkMethod != (jmethodID) 0) { @@ -2972,7 +2969,7 @@ AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(jobject accessibleConte EXCEPTION_CHECK("activateAccessibleHyperlink - call to CallBooleanMethod()", FALSE); return returnVal; } else { - PrintDebugString("\r\n Error! either jniEnv == 0 or activateAccessibleHyperlinkMethod == 0"); + PrintDebugString("[ERROR]: either jniEnv == 0 or activateAccessibleHyperlinkMethod == 0"); return FALSE; } } @@ -2993,7 +2990,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC jthrowable exception; const wchar_t *stringBytes; jsize length; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(%p, %p, startIndex = %d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(%p, %p, startIndex = %d)", accessibleContext, hypertext, nStartIndex); // get the AccessibleHypertext @@ -3003,9 +3000,9 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC jobject globalRef = jniEnv->NewGlobalRef(ht); EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to NewGlobalRef()", FALSE); hypertext->accessibleHypertext = (JOBJECT64)globalRef; - PrintDebugString(" ##### AccessibleHypertext = %p", globalRef); + PrintDebugString("[INFO]: ##### AccessibleHypertext = %p", globalRef); if (hypertext->accessibleHypertext == 0) { - PrintDebugString(" ##### null AccessibleHypertext; returning FALSE"); + PrintDebugString("[WARN]: ##### null AccessibleHypertext; returning FALSE"); return FALSE; } @@ -3013,7 +3010,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC hypertext->linkCount = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink count = %d", hypertext->linkCount); + PrintDebugString("[INFO]: ##### hyperlink count = %d", hypertext->linkCount); if (nStartIndex >= hypertext->linkCount) { return FALSE; @@ -3025,7 +3022,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC // i < hypertext->linkCount int bufIndex = 0; for (int i = nStartIndex; (i < hypertext->linkCount) && (i < nStartIndex + MAX_HYPERLINKS); i++) { - PrintDebugString(" getting hyperlink %d ...", i); + PrintDebugString("[INFO]: getting hyperlink %d ...", i); // get the hyperlink jobject hl = jniEnv->CallObjectMethod(accessBridgeObject, @@ -3036,7 +3033,7 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC jobject globalRef = jniEnv->NewGlobalRef(hl); EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE); hypertext->links[bufIndex].accessibleHyperlink = (JOBJECT64)globalRef; - PrintDebugString(" ##### AccessibleHyperlink = %p", globalRef); + PrintDebugString("[INFO]: ##### AccessibleHyperlink = %p", globalRef); // get the hyperlink text jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject, @@ -3061,12 +3058,12 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC // jniEnv->CallVoidMethod(accessBridgeObject, // decrementReferenceMethod, js); //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE); - PrintDebugString("##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text ); + PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text ); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AccessibleHyperlink text is null."); + PrintDebugString("[WARN]: AccessibleHyperlink text is null."); hypertext->links[bufIndex].text[0] = (wchar_t) 0; } @@ -3075,19 +3072,19 @@ AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleC hypertext->links[bufIndex].accessibleHyperlink, i); EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink start index = %d", hypertext->links[bufIndex].startIndex); + PrintDebugString("[INFO]: ##### hyperlink start index = %d", hypertext->links[bufIndex].startIndex); hypertext->links[bufIndex].endIndex = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkEndIndexMethod, hypertext->links[bufIndex].accessibleHyperlink, i); EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink end index = %d", hypertext->links[bufIndex].endIndex); + PrintDebugString("[INFO]: ##### hyperlink end index = %d", hypertext->links[bufIndex].endIndex); bufIndex++; } - PrintDebugString(" ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt succeeded"); + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt succeeded"); return TRUE; } @@ -3095,7 +3092,7 @@ jint AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(const jobject acce jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(%X)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(%X)", accessibleContext); if (getAccessibleHyperlinkCountMethod == (jmethodID)0) { @@ -3106,7 +3103,7 @@ jint AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(const jobject acce jint linkCount = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", -1); - PrintDebugString(" ##### hyperlink count = %d", linkCount); + PrintDebugString("[INFO]: ##### hyperlink count = %d", linkCount); return linkCount; } @@ -3117,7 +3114,7 @@ jint AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(const jobject jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(%p, index = %d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(%p, index = %d)", hypertext, nIndex); if (getAccessibleHypertextLinkIndexMethod == (jmethodID)0) { @@ -3129,7 +3126,7 @@ jint AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(const jobject hypertext, nIndex); EXCEPTION_CHECK("##### Getting hyperlink index - call to CallIntMethod()", -1); - PrintDebugString(" ##### hyperlink index = %d", index); + PrintDebugString("[INFO]: ##### hyperlink index = %d", index); return index; } @@ -3142,7 +3139,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleHyperlink(jobject hypertext, const wchar_t *stringBytes; jsize length; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHyperlink(%p, index = %d)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHyperlink(%p, index = %d)", hypertext, index); @@ -3155,7 +3152,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleHyperlink(jobject hypertext, jobject globalRef = jniEnv->NewGlobalRef(hl); EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE); info->accessibleHyperlink = (JOBJECT64)globalRef; - PrintDebugString(" ##### AccessibleHyperlink = %p", globalRef); + PrintDebugString("[INFO]: ##### AccessibleHyperlink = %p", globalRef); // get the hyperlink text jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject, @@ -3180,12 +3177,12 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleHyperlink(jobject hypertext, // jniEnv->CallVoidMethod(accessBridgeObject, // decrementReferenceMethod, js); //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE); - PrintDebugString("##### AccessibleHyperlink text = %ls", info->text ); + PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", info->text ); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AccessibleHyperlink text is null."); + PrintDebugString("[WARN]: AccessibleHyperlink text is null."); info->text[0] = (wchar_t) 0; } @@ -3194,14 +3191,14 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleHyperlink(jobject hypertext, info->accessibleHyperlink, index); EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink start index = %d", info->startIndex); + PrintDebugString("[INFO]: ##### hyperlink start index = %d", info->startIndex); info->endIndex = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkEndIndexMethod, info->accessibleHyperlink, index); EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### hyperlink end index = %d", info->endIndex); + PrintDebugString("[INFO]: ##### hyperlink end index = %d", info->endIndex); return TRUE; } @@ -3215,7 +3212,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(jobject accessibleCon jthrowable exception; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(%p, %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(%p, %p)", accessibleContext, keyBindings); if (getAccessibleKeyBindingsCountMethod == (jmethodID) 0 || @@ -3230,7 +3227,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(jobject accessibleCon EXCEPTION_CHECK("##### Getting key bindings count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### key bindings count = %d", keyBindings->keyBindingsCount); + PrintDebugString("[INFO]: ##### key bindings count = %d", keyBindings->keyBindingsCount); // get the key bindings for (int i = 0; i < keyBindings->keyBindingsCount && i < MAX_KEY_BINDINGS; i++) { @@ -3241,8 +3238,9 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(jobject accessibleCon accessibleContext, i); EXCEPTION_CHECK("##### Getting key binding character - call to CallCharMethod()", FALSE); - PrintDebugString(" ##### key binding character = %c", keyBindings->keyBindingInfo[i].character); - PrintDebugString(" ##### key binding character in hex = %hx", keyBindings->keyBindingInfo[i].character); + PrintDebugString("[INFO]: ##### key binding character = %c"\ + " ##### key binding character in hex = %hx"\ + , keyBindings->keyBindingInfo[i].character, keyBindings->keyBindingInfo[i].character); // get the key binding modifiers keyBindings->keyBindingInfo[i].modifiers = jniEnv->CallIntMethod(accessBridgeObject, @@ -3250,7 +3248,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(jobject accessibleCon accessibleContext, i); EXCEPTION_CHECK("##### Getting key binding modifiers - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### key binding modifiers = %x", keyBindings->keyBindingInfo[i].modifiers); + PrintDebugString("[INFO]: ##### key binding modifiers = %x", keyBindings->keyBindingInfo[i].modifiers); } return FALSE; } @@ -3263,14 +3261,14 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext, const wchar_t *stringBytes; jsize length; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)", accessibleContext, icons); if (getAccessibleIconsCountMethod == (jmethodID) 0 || getAccessibleIconDescriptionMethod == (jmethodID) 0 || getAccessibleIconHeightMethod == (jmethodID) 0 || getAccessibleIconWidthMethod == (jmethodID) 0) { - PrintDebugString(" ##### missing method(s) !!!"); + PrintDebugString("[WARN]: ##### missing method(s) !!!"); return FALSE; } @@ -3280,7 +3278,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext, getAccessibleIconsCountMethod, accessibleContext); EXCEPTION_CHECK("##### Getting icons count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### icons count = %d", icons->iconsCount); + PrintDebugString("[INFO]: ##### icons count = %d", icons->iconsCount); // get the icons @@ -3308,11 +3306,11 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext, // jniEnv->CallVoidMethod(accessBridgeObject, // decrementReferenceMethod, js); //EXCEPTION_CHECK("Getting AccessibleIcon description - call to CallVoidMethod()", FALSE); - PrintDebugString("##### AccessibleIcon description = %ls", icons->iconInfo[i].description ); + PrintDebugString("[INFO]: ##### AccessibleIcon description = %ls", icons->iconInfo[i].description ); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleIcon description - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AccessibleIcon description is null."); + PrintDebugString("[WARN]: AccessibleIcon description is null."); icons->iconInfo[i].description[0] = (wchar_t) 0; } @@ -3323,7 +3321,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext, accessibleContext, i); EXCEPTION_CHECK("##### Getting icon height - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### icon height = %d", icons->iconInfo[i].height); + PrintDebugString("[INFO]: ##### icon height = %d", icons->iconInfo[i].height); // get the icon width icons->iconInfo[i].width = jniEnv->CallIntMethod(accessBridgeObject, @@ -3331,7 +3329,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext, accessibleContext, i); EXCEPTION_CHECK("##### Getting icon width - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### icon width = %d", icons->iconInfo[i].width); + PrintDebugString("[INFO]: ##### icon width = %d", icons->iconInfo[i].width); } return FALSE; } @@ -3344,12 +3342,12 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleActions(jobject accessibleContext const wchar_t *stringBytes; jsize length; - PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)", + PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)", accessibleContext, actions); if (getAccessibleActionsCountMethod == (jmethodID) 0 || getAccessibleActionNameMethod == (jmethodID) 0) { - PrintDebugString(" ##### missing method(s) !!!"); + PrintDebugString("[WARN]: ##### missing method(s) !!!"); return FALSE; } @@ -3359,7 +3357,7 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleActions(jobject accessibleContext getAccessibleActionsCountMethod,accessibleContext); EXCEPTION_CHECK("##### Getting actions count - call to CallIntMethod()", FALSE); - PrintDebugString(" ##### key actions count = %d", actions->actionsCount); + PrintDebugString("[INFO]: ##### key actions count = %d", actions->actionsCount); // get the actions @@ -3387,11 +3385,11 @@ BOOL AccessBridgeJavaEntryPoints::getAccessibleActions(jobject accessibleContext // jniEnv->CallVoidMethod(accessBridgeObject, // decrementReferenceMethod, js); //EXCEPTION_CHECK("Getting AccessibleAction name - call to CallVoidMethod()", FALSE); - PrintDebugString("##### AccessibleAction name = %ls", actions->actionInfo[i].name ); + PrintDebugString("[INFO]: ##### AccessibleAction name = %ls", actions->actionInfo[i].name ); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleAction name - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AccessibleAction name is null."); + PrintDebugString("[WARN]: AccessibleAction name is null."); actions->actionInfo[i].name [0] = (wchar_t) 0; } } @@ -3405,7 +3403,7 @@ BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext, jthrowable exception; BOOL returnVal; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::doAccessibleActions(%p, #actions %d %s):", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::doAccessibleActions(%p, #actions %d %s):", accessibleContext, actionsToDo->actionsCount, actionsToDo->actions[0].name); @@ -3415,15 +3413,15 @@ BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext, return FALSE; } - PrintDebugString("\r\n doing %d actions ...", actionsToDo->actionsCount); + PrintDebugString("[INFO]: doing %d actions ...", actionsToDo->actionsCount); for (int i = 0; i < actionsToDo->actionsCount && i < MAX_ACTIONS_TO_DO; i++) { - PrintDebugString("\r doing action %d: %s ...", i, actionsToDo->actions[i].name); + PrintDebugString("[INFO]: doing action %d: %s ...", i, actionsToDo->actions[i].name); // create a Java String for the action name wchar_t *actionName = (wchar_t *)actionsToDo->actions[i].name; jstring javaName = jniEnv->NewString(actionName, (jsize)wcslen(actionName)); if (javaName == 0) { - PrintDebugString("\r NewString failed"); + PrintDebugString("[ERROR]: NewString failed"); *failure = i; return FALSE; } @@ -3434,7 +3432,7 @@ BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext, EXCEPTION_CHECK("doAccessibleActions - call to CallBooleanMethod()", FALSE); if (returnVal != TRUE) { - PrintDebugString("\r Action %d failed", i); + PrintDebugString("[ERROR]: Action %d failed", i); *failure = i; return FALSE; } @@ -3458,7 +3456,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextInfo(jobject accessibleContext, return FALSE; } - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextInfo(%p, %d, %d):", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextInfo(%p, %d, %d):", accessibleContext, x, y); // Get the character count @@ -3467,9 +3465,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextInfo(jobject accessibleContext, getAccessibleCharCountFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleCharCount - call to CallIntMethod()", FALSE); - PrintDebugString(" Char count = %d", textInfo->charCount); + PrintDebugString("[INFO]: Char count = %d", textInfo->charCount); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleCharCountFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleCharCountFromContextMethod == 0"); return FALSE; } @@ -3479,9 +3477,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextInfo(jobject accessibleContext, getAccessibleCaretPositionFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleCaretPosition - call to CallIntMethod()", FALSE); - PrintDebugString(" Index at caret = %d", textInfo->caretIndex); + PrintDebugString("[INFO]: Index at caret = %d", textInfo->caretIndex); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleCaretPositionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleCaretPositionFromContextMethod == 0"); return FALSE; } @@ -3496,9 +3494,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextInfo(jobject accessibleContext, accessibleContext, x, y); EXCEPTION_CHECK("Getting AccessibleIndexAtPoint - call to CallIntMethod()", FALSE); } - PrintDebugString(" Index at point = %d", textInfo->indexAtPoint); + PrintDebugString("[INFO]: Index at point = %d", textInfo->indexAtPoint); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleIndexAtPointFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleIndexAtPointFromContextMethod == 0"); return FALSE; } return TRUE; @@ -3512,7 +3510,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextItems(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextItems(%p):", accessibleContext); // Verify the Java VM still exists and AccessibleContext is // an instance of AccessibleText @@ -3526,7 +3524,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, getAccessibleLetterAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to CallIntMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to GetStringChars()", FALSE); @@ -3536,15 +3534,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to CallVoidMethod()", FALSE); - PrintDebugString(" Accessible Text letter = %c", textItems->letter); + PrintDebugString("[INFO]: Accessible Text letter = %c", textItems->letter); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Text letter is null."); + PrintDebugString("[WARN]: Accessible Text letter is null."); textItems->letter = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleLetterAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleLetterAtIndexFromContextMethod == 0"); return FALSE; } @@ -3555,7 +3553,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, getAccessibleWordAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallIntMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringChars()", FALSE); @@ -3569,15 +3567,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Text word = %ls", textItems->word); + wPrintDebugString(L"[INFO]: Accessible Text word = %ls", textItems->word); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Text word is null."); + PrintDebugString("[WARN]: Accessible Text word is null."); textItems->word[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleWordAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleWordAtIndexFromContextMethod == 0"); return FALSE; } @@ -3587,7 +3585,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, getAccessibleSentenceAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringChars()", FALSE); @@ -3605,15 +3603,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext, jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Text sentence = %ls", textItems->sentence); + wPrintDebugString(L"[INFO]: Accessible Text sentence = %ls", textItems->sentence); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Text sentence is null."); + PrintDebugString("[WARN]: Accessible Text sentence is null."); textItems->sentence[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleSentenceAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleSentenceAtIndexFromContextMethod == 0"); return FALSE; } @@ -3628,7 +3626,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleCo jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(%p):", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(%p):", accessibleContext); // Verify the Java VM still exists and AccessibleContext is @@ -3643,9 +3641,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleCo getAccessibleTextSelectionStartFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleTextSelectionStart - call to CallIntMethod()", FALSE); - PrintDebugString(" Selection start = %d", selectionInfo->selectionStartIndex); + PrintDebugString("[INFO]: Selection start = %d", selectionInfo->selectionStartIndex); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextSelectionStartFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextSelectionStartFromContextMethod == 0"); return FALSE; } @@ -3655,9 +3653,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleCo getAccessibleTextSelectionEndFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleTextSelectionEnd - call to CallIntMethod()", FALSE); - PrintDebugString(" Selection end = %d", selectionInfo->selectionEndIndex); + PrintDebugString("[INFO]: Selection end = %d", selectionInfo->selectionEndIndex); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextSelectionEndFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextSelectionEndFromContextMethod == 0"); return FALSE; } @@ -3667,7 +3665,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleCo getAccessibleTextSelectedTextFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringChars()", FALSE); @@ -3681,15 +3679,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleCo jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallVoidMethod()", FALSE); - PrintDebugString(" Accessible's selected text = %s", selectionInfo->selectedText); + PrintDebugString("[INFO]: Accessible's selected text = %s", selectionInfo->selectedText); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible's selected text is null."); + PrintDebugString("[WARN]: Accessible's selected text is null."); selectionInfo->selectedText[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextSelectedTextFromContextMethod == 0"); + PrintDebugString("[WARN]: either env == 0 or getAccessibleTextSelectedTextFromContextMethod == 0"); return FALSE; } return TRUE; @@ -3703,7 +3701,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(%p):", accessibleContext); // Verify the Java VM still exists and AccessibleContext is // an instance of AccessibleText @@ -3712,7 +3710,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte } if (accessibleContext == (jobject) 0) { - PrintDebugString(" passed in AccessibleContext == null! (oops)"); + PrintDebugString("[WARN]: passed in AccessibleContext == null! (oops)"); attributes->bold = FALSE; attributes->italic = FALSE; @@ -3739,19 +3737,19 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the AttributeSet if (getAccessibleAttributeSetAtIndexFromContextMethod != (jmethodID) 0) { - PrintDebugString(" Getting AttributeSet at index..."); + PrintDebugString("[INFO]: Getting AttributeSet at index..."); AttributeSet = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleAttributeSetAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleAttributeSetAtIndex - call to CallObjectMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleAttributeSetAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributeSetAtIndexFromContextMethod == 0"); return FALSE; } // It is legal for the AttributeSet object to be null, in which case we return false! if (AttributeSet == (jobject) 0) { - PrintDebugString(" AttributeSet returned at index is null (this is legal! - see AWT in J2SE 1.3"); + PrintDebugString("[WARN]: AttributeSet returned at index is null (this is legal! - see AWT in J2SE 1.3"); attributes->bold = FALSE; attributes->italic = FALSE; @@ -3778,13 +3776,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the bold setting if (getBoldFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting bold from AttributeSet..."); + PrintDebugString("[INFO]: Getting bold from AttributeSet..."); attributes->bold = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, getBoldFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to CallBooleanMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getBoldFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getBoldFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3795,13 +3793,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the italic setting if (getItalicFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting italic from AttributeSet..."); + PrintDebugString("[INFO]: Getting italic from AttributeSet..."); attributes->italic = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, getItalicFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to CallBooleanMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getItalicdFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getItalicdFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3812,13 +3810,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the underline setting if (getUnderlineFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting underline from AttributeSet..."); + PrintDebugString("[INFO]: Getting underline from AttributeSet..."); attributes->underline = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, getUnderlineFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to CallBooleanMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getUnderlineFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getUnderlineFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3829,13 +3827,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the strikethrough setting if (getStrikethroughFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting strikethrough from AttributeSet..."); + PrintDebugString("[INFO]: Getting strikethrough from AttributeSet..."); attributes->strikethrough = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, getStrikethroughFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to CallBooleanMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getStrikethroughFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getStrikethroughFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3846,13 +3844,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the superscript setting if (getSuperscriptFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting superscript from AttributeSet..."); + PrintDebugString("[INFO]: Getting superscript from AttributeSet..."); attributes->superscript = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, getSuperscriptFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to CallBooleanMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getSuperscripteFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getSuperscripteFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3863,13 +3861,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the subscript setting if (getSubscriptFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting subscript from AttributeSet..."); + PrintDebugString("[INFO]: Getting subscript from AttributeSet..."); attributes->subscript = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, getSubscriptFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallBooleanMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getSubscriptFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getSubscriptFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3880,7 +3878,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the backgroundColor setting if (getBackgroundColorFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting backgroundColor from AttributeSet..."); + PrintDebugString("[INFO]: Getting backgroundColor from AttributeSet..."); js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject, getBackgroundColorFromAttributeSetMethod, AttributeSet); @@ -3898,15 +3896,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" AttributeSet's background color = %ls", attributes->backgroundColor); + wPrintDebugString(L"[INFO]: AttributeSet's background color = %ls", attributes->backgroundColor); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AttributeSet's background color is null."); + PrintDebugString("[WARN]: AttributeSet's background color is null."); attributes->backgroundColor[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getBackgroundColorFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getBackgroundColorFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3917,7 +3915,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the foregroundColor setting if (getForegroundColorFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting foregroundColor from AttributeSet..."); + PrintDebugString("[INFO]: Getting foregroundColor from AttributeSet..."); js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject, getForegroundColorFromAttributeSetMethod, AttributeSet); @@ -3935,15 +3933,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" AttributeSet's foreground color = %ls", attributes->foregroundColor); + wPrintDebugString(L"[INFO]: AttributeSet's foreground color = %ls", attributes->foregroundColor); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AttributeSet's foreground color is null."); + PrintDebugString("[WARN]: AttributeSet's foreground color is null."); attributes->foregroundColor[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getForegroundColorFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getForegroundColorFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3954,7 +3952,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the fontFamily setting if (getFontFamilyFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting fontFamily from AttributeSet..."); + PrintDebugString("[INFO]: Getting fontFamily from AttributeSet..."); js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject, getFontFamilyFromAttributeSetMethod, AttributeSet); @@ -3972,15 +3970,15 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" AttributeSet's fontFamily = %ls", attributes->fontFamily); + wPrintDebugString(L"[INFO]: AttributeSet's fontFamily = %ls", attributes->fontFamily); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" AttributeSet's fontFamily is null."); + PrintDebugString("[WARN]: AttributeSet's fontFamily is null."); attributes->backgroundColor[0] = (wchar_t) 0; } } else { - PrintDebugString(" Error! either env == 0 or getFontFamilyFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getFontFamilyFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -3991,14 +3989,14 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the font size if (getFontSizeFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting font size from AttributeSet..."); + PrintDebugString("[INFO]: Getting font size from AttributeSet..."); attributes->fontSize = jniEnv->CallIntMethod(accessBridgeObject, getFontSizeFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to CallIntMethod()", FALSE); - PrintDebugString(" AttributeSet's font size = %d", attributes->fontSize); + PrintDebugString("[INFO]: AttributeSet's font size = %d", attributes->fontSize); } else { - PrintDebugString(" Error! either env == 0 or getAlignmentFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAlignmentFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4016,7 +4014,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte AttributeSet); EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getAlignmentFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAlignmentFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4027,13 +4025,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the bidiLevel setting if (getBidiLevelFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting bidiLevel from AttributeSet..."); + PrintDebugString("[INFO]: Getting bidiLevel from AttributeSet..."); attributes->bidiLevel = jniEnv->CallIntMethod(accessBridgeObject, getBidiLevelFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getBidiLevelFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getBidiLevelFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4044,13 +4042,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the firstLineIndent setting if (getFirstLineIndentFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting firstLineIndent from AttributeSet..."); + PrintDebugString("[ERROR]: Getting firstLineIndent from AttributeSet..."); attributes->firstLineIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject, getFirstLineIndentFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getFirstLineIndentFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getFirstLineIndentFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4061,13 +4059,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the leftIndent setting if (getLeftIndentFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting leftIndent from AttributeSet..."); + PrintDebugString("[INFO]: Getting leftIndent from AttributeSet..."); attributes->leftIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject, getLeftIndentFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getLeftIndentFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getLeftIndentFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4078,13 +4076,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the rightIndent setting if (getRightIndentFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting rightIndent from AttributeSet..."); + PrintDebugString("[INFO]: Getting rightIndent from AttributeSet..."); attributes->rightIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject, getRightIndentFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getRightIndentFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getRightIndentFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4095,13 +4093,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the lineSpacing setting if (getLineSpacingFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting lineSpacing from AttributeSet..."); + PrintDebugString("[INFO]: Getting lineSpacing from AttributeSet..."); attributes->lineSpacing = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject, getLineSpacingFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getLineSpacingFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getLineSpacingFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4112,13 +4110,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the spaceAbove setting if (getSpaceAboveFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting spaceAbove from AttributeSet..."); + PrintDebugString("[INFO]: Getting spaceAbove from AttributeSet..."); attributes->spaceAbove = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject, getSpaceAboveFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getSpaceAboveFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getSpaceAboveFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4129,13 +4127,13 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the spaceBelow setting if (getSpaceBelowFromAttributeSetMethod != (jmethodID) 0) { - PrintDebugString(" Getting spaceBelow from AttributeSet..."); + PrintDebugString("[INFO]: Getting spaceBelow from AttributeSet..."); attributes->spaceBelow = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject, getSpaceBelowFromAttributeSetMethod, AttributeSet); EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to CallIntMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or getSpaceBelowFromAttributeSetMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getSpaceBelowFromAttributeSetMethod == 0"); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to CallVoidMethod()", FALSE); @@ -4146,12 +4144,12 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Release the AttributeSet object if (decrementReferenceMethod != (jmethodID) 0) { - PrintDebugString(" Decrementing reference to AttributeSet..."); + PrintDebugString("[INFO]: Decrementing reference to AttributeSet..."); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, AttributeSet); EXCEPTION_CHECK("Releasing AttributeSet object - call to CallVoidMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or accessBridgeObject == 0"); + PrintDebugString("[ERROR]: either env == 0 or accessBridgeObject == 0"); jniEnv->DeleteLocalRef(AttributeSet); EXCEPTION_CHECK("Releasing AttributeSet object - call to DeleteLocalRef()", FALSE); return FALSE; @@ -4159,12 +4157,12 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte // Get the full attributes string at index if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) { - PrintDebugString(" Getting full attributes string from Context..."); + PrintDebugString("[INFO]: Getting full attributes string from Context..."); js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleAttributesAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE); @@ -4178,18 +4176,18 @@ AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleConte jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Text attributes = %ls", attributes->fullAttributesString); + wPrintDebugString(L"[INFO]: Accessible Text attributes = %ls", attributes->fullAttributesString); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" Accessible Text attributes is null."); + PrintDebugString("[WARN]: Accessible Text attributes is null."); attributes->fullAttributesString[0] = (wchar_t) 0; jniEnv->DeleteLocalRef(AttributeSet); EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE); return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0"); jniEnv->DeleteLocalRef(AttributeSet); return FALSE; } @@ -4204,7 +4202,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, Ac jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextRect(%p), index = %d", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextRect(%p), index = %d", accessibleContext, index); // Verify the Java VM still exists and AccessibleContext is @@ -4219,9 +4217,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, Ac getAccessibleXcoordTextRectAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleXcoordTextRect - call to CallIntMethod()", FALSE); - PrintDebugString(" X coord = %d", rectInfo->x); + PrintDebugString("[INFO]: X coord = %d", rectInfo->x); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleXcoordTextRectAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleXcoordTextRectAtIndexFromContextMethod == 0"); return FALSE; } @@ -4231,9 +4229,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, Ac getAccessibleYcoordTextRectAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleYcoordTextRect - call to CallIntMethod()", FALSE); - PrintDebugString(" Y coord = %d", rectInfo->y); + PrintDebugString("[INFO]: Y coord = %d", rectInfo->y); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleYcoordTextRectAtIndexFromContextMethod == 0"); + PrintDebugString("[INFO]: either env == 0 or getAccessibleYcoordTextRectAtIndexFromContextMethod == 0"); return FALSE; } @@ -4243,9 +4241,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, Ac getAccessibleWidthTextRectAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleWidthTextRect - call to CallIntMethod()", FALSE); - PrintDebugString(" Width = %d", rectInfo->width); + PrintDebugString("[INFO]: Width = %d", rectInfo->width); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleWidthTextRectAtIndexFromContextMethod == 0"); + PrintDebugString("[INFO]: either env == 0 or getAccessibleWidthTextRectAtIndexFromContextMethod == 0"); return FALSE; } @@ -4255,9 +4253,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, Ac getAccessibleHeightTextRectAtIndexFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleHeightTextRect - call to CallIntMethod()", FALSE); - PrintDebugString(" Height = %d", rectInfo->height); + PrintDebugString("[INFO]: Height = %d", rectInfo->height); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleHeightTextRectAtIndexFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleHeightTextRectAtIndexFromContextMethod == 0"); return FALSE; } @@ -4274,7 +4272,7 @@ AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, Accessi jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getCaretLocation(%p), index = %d", + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getCaretLocation(%p), index = %d", accessibleContext, index); // Verify the Java VM still exists and AccessibleContext is @@ -4289,9 +4287,9 @@ AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, Accessi getCaretLocationXMethod, accessibleContext, index); EXCEPTION_CHECK("Getting caret X coordinate - call to CallIntMethod()", FALSE); - PrintDebugString(" X coord = %d", rectInfo->x); + PrintDebugString("[INFO]: X coord = %d", rectInfo->x); } else { - PrintDebugString(" Error! either env == 0 or getCaretLocationXMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getCaretLocationXMethod == 0"); return FALSE; } @@ -4301,9 +4299,9 @@ AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, Accessi getCaretLocationYMethod, accessibleContext, index); EXCEPTION_CHECK("Getting caret Y coordinate - call to CallIntMethod()", FALSE); - PrintDebugString(" Y coord = %d", rectInfo->y); + PrintDebugString("[INFO]: Y coord = %d", rectInfo->y); } else { - PrintDebugString(" Error! either env == 0 or getCaretLocationYMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getCaretLocationYMethod == 0"); return FALSE; } @@ -4313,9 +4311,9 @@ AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, Accessi getCaretLocationWidthMethod, accessibleContext, index); EXCEPTION_CHECK("Getting caret width - call to CallIntMethod()", FALSE); - PrintDebugString(" Width = %d", rectInfo->width); + PrintDebugString("[INFO]: Width = %d", rectInfo->width); } else { - PrintDebugString(" Error! either env == 0 or getCaretLocationWidthMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getCaretLocationWidthMethod == 0"); return FALSE; } @@ -4325,9 +4323,9 @@ AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, Accessi getCaretLocationHeightMethod, accessibleContext, index); EXCEPTION_CHECK("Getting caret height - call to CallIntMethod()", FALSE); - PrintDebugString(" Height = %d", rectInfo->height); + PrintDebugString("[INFO]: Height = %d", rectInfo->height); } else { - PrintDebugString(" Error! either env == 0 or getCaretLocationHeightMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getCaretLocationHeightMethod == 0"); return FALSE; } @@ -4341,7 +4339,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(jobject accessibleConte jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(%p):", accessibleContext); // Verify the Java VM still exists and AccessibleContext is // an instance of AccessibleText @@ -4355,9 +4353,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(jobject accessibleConte getAccessibleTextLineLeftBoundsFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleTextLineLeftBounds - call to CallIntMethod()", FALSE); - PrintDebugString(" startIndex = %d", *startIndex); + PrintDebugString("[INFO]: startIndex = %d", *startIndex); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextLineLeftBoundsFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextLineLeftBoundsFromContextMethod == 0"); return FALSE; } @@ -4367,9 +4365,9 @@ AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(jobject accessibleConte getAccessibleTextLineRightBoundsFromContextMethod, accessibleContext, index); EXCEPTION_CHECK("Getting AccessibleTextLineRightBounds - call to CallIntMethod()", FALSE); - PrintDebugString(" endIndex = %d", *endIndex); + PrintDebugString("[INFO]: endIndex = %d", *endIndex); } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextLineRightBoundsFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextLineRightBoundsFromContextMethod == 0"); return FALSE; } @@ -4384,7 +4382,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRange(jobject accessibleContext, jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextRange(%p, %d, %d, *text, %d):", accessibleContext, start, end, len); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextRange(%p, %d, %d, *text, %d):", accessibleContext, start, end, len); // Verify the Java VM still exists and AccessibleContext is // an instance of AccessibleText @@ -4394,7 +4392,7 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRange(jobject accessibleContext, // range is inclusive if (end < start) { - PrintDebugString(" Error! end < start!"); + PrintDebugString("[ERROR]: end < start!"); text[0] = (wchar_t) 0; return FALSE; } @@ -4405,32 +4403,32 @@ AccessBridgeJavaEntryPoints::getAccessibleTextRange(jobject accessibleContext, getAccessibleTextRangeFromContextMethod, accessibleContext, start, end); EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringChars()", FALSE); - wPrintDebugString(L" Accessible Text stringBytes returned from Java = %ls", stringBytes); + wPrintDebugString(L"[INFO]: Accessible Text stringBytes returned from Java = %ls", stringBytes); wcsncpy(text, stringBytes, len); length = jniEnv->GetStringLength(js); - PrintDebugString(" Accessible Text stringBytes length = %d", length); + PrintDebugString("[INFO]: Accessible Text stringBytes length = %d", length); text[length < len ? length : len - 2] = (wchar_t) 0; - wPrintDebugString(L" Accessible Text 'text' after null termination = %ls", text); + wPrintDebugString(L"[INFO]: Accessible Text 'text' after null termination = %ls", text); EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringLength()", FALSE); jniEnv->ReleaseStringChars(js, stringBytes); EXCEPTION_CHECK("Getting AccessibleTextRange - call to ReleaseStringChars()", FALSE); jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallVoidMethod()", FALSE); - wPrintDebugString(L" Accessible Text range = %ls", text); + wPrintDebugString(L"[INFO]: Accessible Text range = %ls", text); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting AccessibleTextRange - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" current Accessible Text range is null."); + PrintDebugString("[WARN]: current Accessible Text range is null."); text[0] = (wchar_t) 0; return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getAccessibleTextRangeFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextRangeFromContextMethod == 0"); return FALSE; } return TRUE; @@ -4445,7 +4443,7 @@ AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(jobject access jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(%p):", accessibleContext); // Get the current Accessible Value if (getCurrentAccessibleValueFromContextMethod != (jmethodID) 0) { @@ -4453,7 +4451,7 @@ AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(jobject access getCurrentAccessibleValueFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringChars()", FALSE); @@ -4466,16 +4464,16 @@ AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(jobject access jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallVoidMethod()", FALSE); - PrintDebugString(" current Accessible Value = %s", value); + PrintDebugString("[INFO]: current Accessible Value = %s", value); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" current Accessible Value is null."); + PrintDebugString("[WARN]: current Accessible Value is null."); value[0] = (wchar_t) 0; return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getCurrentAccessibleValueFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getCurrentAccessibleValueFromContextMethod == 0"); return FALSE; } return TRUE; @@ -4488,7 +4486,7 @@ AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject access jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(%p):", accessibleContext); // Get the maximum Accessible Value if (getMaximumAccessibleValueFromContextMethod != (jmethodID) 0) { @@ -4496,7 +4494,7 @@ AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject access getMaximumAccessibleValueFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringChars()", FALSE); @@ -4509,16 +4507,16 @@ AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject access jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallVoidMethod()", FALSE); - PrintDebugString(" maximum Accessible Value = %s", value); + PrintDebugString("[INFO]: maximum Accessible Value = %s", value); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" maximum Accessible Value is null."); + PrintDebugString("[WARN]: maximum Accessible Value is null."); value[0] = (wchar_t) 0; return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getMaximumAccessibleValueFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getMaximumAccessibleValueFromContextMethod == 0"); return FALSE; } return TRUE; @@ -4531,7 +4529,7 @@ AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject access jthrowable exception; jsize length; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(%p):", accessibleContext); // Get the mimimum Accessible Value if (getMinimumAccessibleValueFromContextMethod != (jmethodID) 0) { @@ -4539,7 +4537,7 @@ AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject access getMinimumAccessibleValueFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallObjectMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod(), js = %p", js); + PrintDebugString("[INFO]: returned from CallObjectMethod(), js = %p", js); if (js != (jstring) 0) { stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0); EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringChars()", FALSE); @@ -4552,16 +4550,16 @@ AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject access jniEnv->CallVoidMethod(accessBridgeObject, decrementReferenceMethod, js); EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallVoidMethod()", FALSE); - PrintDebugString(" mimimum Accessible Value = %s", value); + PrintDebugString("[INFO]: mimimum Accessible Value = %s", value); jniEnv->DeleteLocalRef(js); EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to DeleteLocalRef()", FALSE); } else { - PrintDebugString(" mimimum Accessible Value is null."); + PrintDebugString("[WARN]: mimimum Accessible Value is null."); value[0] = (wchar_t) 0; return FALSE; } } else { - PrintDebugString(" Error! either env == 0 or getMinimumAccessibleValueFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getMinimumAccessibleValueFromContextMethod == 0"); return FALSE; } return TRUE; @@ -4574,7 +4572,7 @@ void AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(jobject accessibleContext, int i) { jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(%p):", accessibleContext); // Add the child to the AccessibleSelection if (addAccessibleSelectionFromContextMethod != (jmethodID) 0) { @@ -4582,9 +4580,9 @@ AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(jobject accessibl addAccessibleSelectionFromContextMethod, accessibleContext, i); EXCEPTION_CHECK_VOID("Doing addAccessibleSelection - call to CallVoidMethod()"); - PrintDebugString(" returned from CallObjectMethod()"); + PrintDebugString("[INFO]: returned from CallObjectMethod()"); } else { - PrintDebugString(" Error! either env == 0 or addAccessibleSelectionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or addAccessibleSelectionFromContextMethod == 0"); } } @@ -4592,7 +4590,7 @@ void AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(jobject accessibleContext) { jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(%p):", accessibleContext); // Clearing the Selection of the AccessibleSelection if (clearAccessibleSelectionFromContextMethod != (jmethodID) 0) { @@ -4600,9 +4598,9 @@ AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(jobject accessi clearAccessibleSelectionFromContextMethod, accessibleContext); EXCEPTION_CHECK_VOID("Doing clearAccessibleSelection - call to CallVoidMethod()"); - PrintDebugString(" returned from CallObjectMethod()"); + PrintDebugString("[INFO]: returned from CallObjectMethod()"); } else { - PrintDebugString(" Error! either env == 0 or clearAccessibleSelectionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or clearAccessibleSelectionFromContextMethod == 0"); } } @@ -4612,7 +4610,7 @@ AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(jobject accessibl jobject globalRef; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(%p):", accessibleContext); if (getAccessibleSelectionContextFromContextMethod != (jmethodID) 0) { returnedAccessibleContext = jniEnv->CallObjectMethod( @@ -4624,11 +4622,11 @@ AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(jobject accessibl EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to NewGlobalRef()", (jobject) 0); jniEnv->DeleteLocalRef(returnedAccessibleContext); EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to DeleteLocalRef()", (jobject) 0); - PrintDebugString(" Returning - returnedAccessibleContext = %p; globalRef = %p", + PrintDebugString("[INFO]: Returning - returnedAccessibleContext = %p; globalRef = %p", returnedAccessibleContext, globalRef); return globalRef; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleSelectionContextFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleSelectionContextFromContextMethod == 0"); return (jobject) 0; } } @@ -4638,7 +4636,7 @@ AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(jobject acce int count; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(%p):", accessibleContext); // Get (& return) the # of items selected in the AccessibleSelection if (getAccessibleSelectionCountFromContextMethod != (jmethodID) 0) { @@ -4646,10 +4644,10 @@ AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(jobject acce getAccessibleSelectionCountFromContextMethod, accessibleContext); EXCEPTION_CHECK("Getting AccessibleSelectionCount - call to CallIntMethod()", -1); - PrintDebugString(" returned from CallObjectMethod()"); + PrintDebugString("[INFO]: returned from CallObjectMethod()"); return count; } else { - PrintDebugString(" Error! either env == 0 or getAccessibleSelectionCountFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or getAccessibleSelectionCountFromContextMethod == 0"); return -1; } } @@ -4659,7 +4657,7 @@ AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(jobject access jboolean result; jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(%p):", accessibleContext); // Get (& return) the # of items selected in the AccessibleSelection if (isAccessibleChildSelectedFromContextMethod != (jmethodID) 0) { @@ -4667,12 +4665,12 @@ AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(jobject access isAccessibleChildSelectedFromContextMethod, accessibleContext, i); EXCEPTION_CHECK("Doing isAccessibleChildSelected - call to CallBooleanMethod()", FALSE); - PrintDebugString(" returned from CallObjectMethod()"); + PrintDebugString("[INFO]: returned from CallObjectMethod()"); if (result != 0) { return TRUE; } } else { - PrintDebugString(" Error! either env == 0 or isAccessibleChildSelectedFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or isAccessibleChildSelectedFromContextMethod == 0"); } return FALSE; } @@ -4682,7 +4680,7 @@ void AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(jobject accessibleContext, int i) { jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(%p):", accessibleContext); // Remove the i-th child from the AccessibleSelection if (removeAccessibleSelectionFromContextMethod != (jmethodID) 0) { @@ -4690,9 +4688,9 @@ AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(jobject access removeAccessibleSelectionFromContextMethod, accessibleContext, i); EXCEPTION_CHECK_VOID("Doing removeAccessibleSelection - call to CallVoidMethod()"); - PrintDebugString(" returned from CallObjectMethod()"); + PrintDebugString("[INFO]: returned from CallObjectMethod()"); } else { - PrintDebugString(" Error! either env == 0 or removeAccessibleSelectionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or removeAccessibleSelectionFromContextMethod == 0"); } } @@ -4700,7 +4698,7 @@ void AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(jobject accessibleContext) { jthrowable exception; - PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(%p):", accessibleContext); + PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(%p):", accessibleContext); // Select all children (if possible) of the AccessibleSelection if (selectAllAccessibleSelectionFromContextMethod != (jmethodID) 0) { @@ -4708,9 +4706,9 @@ AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(jobject acc selectAllAccessibleSelectionFromContextMethod, accessibleContext); EXCEPTION_CHECK_VOID("Doing selectAllAccessibleSelection - call to CallVoidMethod()"); - PrintDebugString(" returned from CallObjectMethod()"); + PrintDebugString("[INFO]: returned from CallObjectMethod()"); } else { - PrintDebugString(" Error! either env == 0 or selectAllAccessibleSelectionFromContextMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or selectAllAccessibleSelectionFromContextMethod == 0"); } } @@ -4721,7 +4719,7 @@ BOOL AccessBridgeJavaEntryPoints::addJavaEventNotification(jlong type) { jthrowable exception; - PrintDebugString("\r\n in AccessBridgeJavaEntryPoints::addJavaEventNotification(%016I64X);", type); + PrintDebugString("[INFO]: in AccessBridgeJavaEntryPoints::addJavaEventNotification(%016I64X);", type); // Let AccessBridge know we want to add an event type if (addJavaEventNotificationMethod != (jmethodID) 0) { @@ -4729,7 +4727,7 @@ AccessBridgeJavaEntryPoints::addJavaEventNotification(jlong type) { addJavaEventNotificationMethod, type); EXCEPTION_CHECK("Doing addJavaEventNotification - call to CallVoidMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or addJavaEventNotificationMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or addJavaEventNotificationMethod == 0"); return FALSE; } return TRUE; @@ -4739,7 +4737,7 @@ BOOL AccessBridgeJavaEntryPoints::removeJavaEventNotification(jlong type) { jthrowable exception; - PrintDebugString("\r\n in AccessBridgeJavaEntryPoints::removeJavaEventNotification(%016I64X):", type); + PrintDebugString("[INFO]: in AccessBridgeJavaEntryPoints::removeJavaEventNotification(%016I64X):", type); // Let AccessBridge know we want to remove an event type if (removeJavaEventNotificationMethod != (jmethodID) 0) { @@ -4747,7 +4745,7 @@ AccessBridgeJavaEntryPoints::removeJavaEventNotification(jlong type) { removeJavaEventNotificationMethod, type); EXCEPTION_CHECK("Doing removeJavaEventNotification - call to CallVoidMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or removeJavaEventNotificationMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or removeJavaEventNotificationMethod == 0"); return FALSE; } return TRUE; @@ -4757,19 +4755,19 @@ BOOL AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(jlong type) { jthrowable exception; - PrintDebugString("\r\n in AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(%016I64X);", type); + PrintDebugString("[INFO]: in AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(%016I64X);", type); // Let AccessBridge know we want to add an event type if (addAccessibilityEventNotificationMethod != (jmethodID) 0) { - PrintDebugString("\r\n addAccessibilityEventNotification: calling void method: accessBridgeObject = %p", accessBridgeObject); + PrintDebugString("[INFO]: addAccessibilityEventNotification: calling void method: accessBridgeObject = %p", accessBridgeObject); jniEnv->CallVoidMethod(accessBridgeObject, addAccessibilityEventNotificationMethod, type); EXCEPTION_CHECK("Doing addAccessibilityEvent - call to CallVoidMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or addAccessibilityEventNotificationMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or addAccessibilityEventNotificationMethod == 0"); return FALSE; } - PrintDebugString("\r\n addAccessibilityEventNotification: just returning true"); + PrintDebugString("[INFO]: addAccessibilityEventNotification: just returning true"); return TRUE; } @@ -4777,7 +4775,7 @@ BOOL AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(jlong type) { jthrowable exception; - PrintDebugString("\r\n in AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(%016I64X):", type); + PrintDebugString("[INFO]: in AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(%016I64X):", type); // Let AccessBridge know we want to remove an event type if (removeAccessibilityEventNotificationMethod != (jmethodID) 0) { @@ -4785,7 +4783,7 @@ AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(jlong type) { removeAccessibilityEventNotificationMethod, type); EXCEPTION_CHECK("Doing removeAccessibilityEvent - call to CallVoidMethod()", FALSE); } else { - PrintDebugString(" Error! either env == 0 or removeAccessibilityEventNotificationMethod == 0"); + PrintDebugString("[ERROR]: either env == 0 or removeAccessibilityEventNotificationMethod == 0"); return FALSE; } return TRUE; diff --git a/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/JavaAccessBridge.cpp b/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/JavaAccessBridge.cpp index 7b9c602965f..6bb0f3600d9 100644 --- a/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/JavaAccessBridge.cpp +++ b/src/src/jdk.accessibility/windows/native/libjavaaccessbridge/JavaAccessBridge.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -85,7 +85,7 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_sun_java_accessibility_internal_AccessBridge_runDLL(JNIEnv *env, jobject obj) { - PrintDebugString("\r\nJavaAccessBridge.DLL runDLL() called"); + PrintDebugString("[INFO]: JavaAccessBridge.DLL runDLL() called"); theJavaAccessBridge->javaRun(env, obj); } @@ -100,20 +100,20 @@ extern "C" { switch (message) { case WM_INITDIALOG: - PrintDebugString("In AccessBridgeDialog - Initializing"); + PrintDebugString("[INFO]: In AccessBridgeDialog - Initializing"); break; case WM_COMMAND: command = LOWORD (wParam); - PrintDebugString("In AccessBridgeDialog - Got WM_COMMAND, command: %X", command); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got WM_COMMAND, command: %X", command); break; // call from Java with data for us to deliver case WM_COPYDATA: if (theDialogWindow == (HWND) wParam) { - PrintDebugString("In AccessBridgeDialog - Got WM_COPYDATA from ourselves"); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got WM_COPYDATA from ourselves"); } else { - PrintDebugString("In AccessBridgeDialog - Got WM_COPYDATA from HWND %p", wParam); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got WM_COPYDATA from HWND %p", wParam); sentToUs = (COPYDATASTRUCT *) lParam; package = (char *) sentToUs->lpData; theJavaAccessBridge->processPackage(package, sentToUs->cbData); @@ -125,16 +125,16 @@ extern "C" { // wParam == sourceHwnd // lParam == buffer size in shared memory if (theDialogWindow == (HWND) wParam) { - PrintDebugString("In AccessBridgeDialog - Got AB_MESSAGE_WAITING from ourselves"); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got AB_MESSAGE_WAITING from ourselves"); } else { - PrintDebugString("In AccessBridgeDialog - Got AB_MESSAGE_WAITING from HWND %p", wParam); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got AB_MESSAGE_WAITING from HWND %p", wParam); LRESULT returnVal = theJavaAccessBridge->receiveMemoryPackage((HWND) wParam, (long) lParam); } break; // a JavaAccessBridge DLL is going away case AB_DLL_GOING_AWAY: - PrintDebugString("In AccessBridgeDialog - Got AB_DLL_GOING_AWAY message"); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got AB_DLL_GOING_AWAY message"); theJavaAccessBridge->WindowsATDestroyed((HWND) wParam); break; @@ -145,7 +145,7 @@ extern "C" { // A new Windows AT just said "hi"; // say "hi" back so it can mate up with us // otherwise don't do anything (e.g. don't set up data structures yet) - PrintDebugString("In AccessBridgeDialog - Got theFromWindowsHelloMsgID message"); + PrintDebugString("[INFO]: In AccessBridgeDialog - Got theFromWindowsHelloMsgID message"); theJavaAccessBridge->postHelloToWindowsDLLMsg((HWND) wParam); } } @@ -165,6 +165,7 @@ extern "C" { JavaAccessBridge::JavaAccessBridge(HINSTANCE hInstance) { windowsInstance = hInstance; ATs = (AccessBridgeATInstance *) 0; + initializeFileLogger("java_access_bridge"); initBroadcastMessageIDs(); // get the unique to us broadcast msg. IDs } @@ -177,7 +178,7 @@ extern DWORD JavaBridgeThreadId; JavaAccessBridge::~JavaAccessBridge() { // inform all other AccessBridges that we're going away - PrintDebugString("\r\nin JavaAccessBridge::~JavaAccessBridge()"); + PrintDebugString("[INFO]: in JavaAccessBridge::~JavaAccessBridge()"); // Send a shutdown message for those applications like StarOffice that do // send a shutdown message themselves. @@ -185,13 +186,13 @@ JavaAccessBridge::~JavaAccessBridge() { AccessBridgeATInstance *current = ATs; while (current != (AccessBridgeATInstance *) 0) { - PrintDebugString(" telling %p we're going away", current->winAccessBridgeWindow); + PrintDebugString("[INFO]: telling %p we're going away", current->winAccessBridgeWindow); SendMessage(current->winAccessBridgeWindow, AB_DLL_GOING_AWAY, (WPARAM) dialogWindow, (LPARAM) 0); current = current->nextATInstance; } - PrintDebugString(" finished telling ATs about our demise"); + PrintDebugString("[INFO]: finished telling ATs about our demise"); if(JavaBridgeThreadId) { @@ -201,8 +202,9 @@ JavaAccessBridge::~JavaAccessBridge() { delete ATs; - PrintDebugString(" finished deleting ATs"); - PrintDebugString("GOODBYE CRUEL WORLD..."); + PrintDebugString("[INFO]: finished deleting ATs"); + PrintDebugString("[INFO]: GOODBYE CRUEL WORLD..."); + finalizeFileLogger(); } @@ -210,17 +212,17 @@ void JavaAccessBridge::javaRun(JNIEnv *env, jobject obj) { MSG msg; - PrintDebugString("JavaAccessBridge::javaRun(%p, %p) called", env, obj); + PrintDebugString("[INFO]: JavaAccessBridge::javaRun(%p, %p) called", env, obj); if (env->GetJavaVM(&javaVM) != 0) { return; // huh!?!?! } - PrintDebugString(" -> javaVM = %p", javaVM); + PrintDebugString("[INFO]: -> javaVM = %p", javaVM); if (javaVM->AttachCurrentThread((void **) &windowsThreadJNIEnv, NULL) != 0) { return; // huh!?!?! } - PrintDebugString(" -> windowsThreadJNIEnv = %p", windowsThreadJNIEnv); + PrintDebugString("[INFO]: -> windowsThreadJNIEnv = %p", windowsThreadJNIEnv); javaThreadABObject = env->NewGlobalRef(obj); windowsThreadABObject = windowsThreadJNIEnv->NewGlobalRef(obj); @@ -230,7 +232,7 @@ JavaAccessBridge::javaRun(JNIEnv *env, jobject obj) { if (javaThreadEntryPoints->BuildJavaEntryPoints() == FALSE) { return; // couldn't build our entry points; let's get out of here! } - PrintDebugString(" all Java thread entry points successfully found."); + PrintDebugString("[INFO]: all Java thread entry points successfully found."); // initialize the Windows thread AccessBridge entry points windowsThreadEntryPoints = new AccessBridgeJavaEntryPoints(windowsThreadJNIEnv, @@ -238,12 +240,12 @@ JavaAccessBridge::javaRun(JNIEnv *env, jobject obj) { if (windowsThreadEntryPoints->BuildJavaEntryPoints() == FALSE) { return; // couldn't build our entry points; let's get out of here! } - PrintDebugString(" all Windows thread entry points successfully found."); + PrintDebugString("[INFO]: all Windows thread entry points successfully found."); // open our window if (initWindow() == TRUE) { - PrintDebugString(" Window created. HWND = %p", dialogWindow); + PrintDebugString("[INFO]: Window created. HWND = %p", dialogWindow); // post a broadcast msg.; let other AccessBridge DLLs know we exist postHelloToWindowsDLLMsg(HWND_BROADCAST); @@ -254,7 +256,7 @@ JavaAccessBridge::javaRun(JNIEnv *env, jobject obj) { DispatchMessage(&msg); } } else { - PrintDebugString(" FAILED TO CREATE WINDOW!!!"); + PrintDebugString("[ERROR]: FAILED TO CREATE WINDOW!!!"); } javaVM->DetachCurrentThread(); @@ -301,8 +303,8 @@ JavaAccessBridge::initWindow() { */ void JavaAccessBridge::postHelloToWindowsDLLMsg(HWND destHwnd) { - PrintDebugString("\r\nIn JavaAccessBridge::postHelloToWindowsDLLMsg"); - PrintDebugString(" calling PostMessage(%p, %X, %p, %p)", + PrintDebugString("[INFO]: In JavaAccessBridge::postHelloToWindowsDLLMsg"); + PrintDebugString("[INFO]: calling PostMessage(%p, %X, %p, %p)", destHwnd, theFromJavaHelloMsgID, dialogWindow, dialogWindow); PostMessage(destHwnd, theFromJavaHelloMsgID, (WPARAM) dialogWindow, (LPARAM) dialogWindow); } @@ -333,10 +335,10 @@ JavaAccessBridge::sendPackage(char *buffer, int bufsize, HWND destHwnd) { void JavaAccessBridge::sendJavaEventPackage(char *buffer, int bufsize, long type) { - PrintDebugString("JavaAccessBridge::sendJavaEventPackage(), type = %X", type); + PrintDebugString("[INFO]: JavaAccessBridge::sendJavaEventPackage(), type = %X", type); if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); } AccessBridgeATInstance *ati = ATs; @@ -353,10 +355,10 @@ JavaAccessBridge::sendJavaEventPackage(char *buffer, int bufsize, long type) { void JavaAccessBridge::sendAccessibilityEventPackage(char *buffer, int bufsize, long type) { - PrintDebugString("JavaAccessBridge::sendAccessibilityEventPackage(), type = %X", type); + PrintDebugString("[INFO]: JavaAccessBridge::sendAccessibilityEventPackage(), type = %X", type); if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR] ATs == 0! (shouldn't happen here!)"); } AccessBridgeATInstance *ati = ATs; @@ -381,11 +383,11 @@ BOOL JavaAccessBridge::receiveMemoryPackage(HWND srcWindow, long bufsize) { char *IPCview; - PrintDebugString("\r\nJavaAccessBridge::receiveMemoryPackage(%p, %d)", srcWindow, bufsize); + PrintDebugString("[INFO]: JavaAccessBridge::receiveMemoryPackage(%p, %d)", srcWindow, bufsize); // look-up the appropriate IPCview based on the srcHWND of the Windows AccessBridge DLL if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR! - ATs == 0 (shouldn't happen in receiveMemoryPackage()!"); + PrintDebugString("[ERROR]: - ATs == 0 (shouldn't happen in receiveMemoryPackage()!"); return FALSE; } AccessBridgeATInstance *ati = ATs->findABATInstanceFromATHWND(srcWindow); @@ -408,7 +410,7 @@ JavaAccessBridge::receiveMemoryPackage(HWND srcWindow, long bufsize) { } else { //DEBUG_CODE(AppendToCallInfo("ERROR receiving memory package: couldn't find srcWindow")); - PrintDebugString("ERROR receiving memory package: couldn't find srcWindow"); + PrintDebugString("[ERROR]: receiving memory package: couldn't find srcWindow"); return FALSE; } } @@ -420,11 +422,11 @@ JavaAccessBridge::receiveMemoryPackage(HWND srcWindow, long bufsize) { */ LRESULT JavaAccessBridge::processPackage(char *buffer, int bufsize) { - PrintDebugString("\r\nProcessing package sent from Windows, bufsize = %d:", bufsize); + PrintDebugString("[INFO]: Processing package sent from Windows, bufsize = %d:", bufsize); PackageType *type = (PackageType *) buffer; LRESULT returnVal = 0; - PrintDebugString(" PackageType = %X:", *type); + PrintDebugString("[INFO]: PackageType = %X:", *type); jobject rAC; switch (*type) { @@ -433,13 +435,13 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { case cMemoryMappedFileCreatedPackage: // Windows is telling us it created a memory mapped file for us to use // in repsonding to various information querying packages (see below) - PrintDebugString(" type == cMemoryMappedFileCreatedPackage"); + PrintDebugString("[INFO]: type == cMemoryMappedFileCreatedPackage"); if (bufsize == (sizeof(PackageType) + sizeof(MemoryMappedFileCreatedPackage))) { MemoryMappedFileCreatedPackage *pkg = (MemoryMappedFileCreatedPackage *) (buffer + sizeof(PackageType)); returnVal = MemoryMappedFileCreated((HWND)ABLongToHandle(pkg->bridgeWindow), pkg->filename); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(MemoryMappedFileCreatedPackage)); } break; @@ -447,84 +449,84 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ information querying packages ------------------ case cReleaseJavaObjectPackage: - PrintDebugString(" type == cReleaseJavaObjectPackage"); + PrintDebugString("[INFO]: type == cReleaseJavaObjectPackage"); if (bufsize == (sizeof(PackageType) + sizeof(ReleaseJavaObjectPackage))) { ReleaseJavaObjectPackage *pkg = (ReleaseJavaObjectPackage *) (buffer + sizeof(PackageType)); releaseJavaObject((jobject)pkg->object); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(ReleaseJavaObjectPackage)); } break; case cGetAccessBridgeVersionPackage: - PrintDebugString(" type == cGetAccessBridgeVersionPackage"); + PrintDebugString("[INFO]: type == cGetAccessBridgeVersionPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessBridgeVersionPackage))) { GetAccessBridgeVersionPackage *pkg = (GetAccessBridgeVersionPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getVersionInfo(&(pkg->rVersionInfo)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessBridgeVersionPackage)); } break; case cIsJavaWindowPackage: - PrintDebugString(" type == cIsJavaWindowPackage"); + PrintDebugString("[INFO]: type == cIsJavaWindowPackage"); if (bufsize == (sizeof(PackageType) + sizeof(IsJavaWindowPackage))) { IsJavaWindowPackage *pkg = (IsJavaWindowPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->isJavaWindow(pkg->window); - PrintDebugString(" -> returning result = %d", pkg->rResult); + PrintDebugString("[INFO]: -> returning result = %d", pkg->rResult); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(IsJavaWindowPackage)); } break; case cIsSameObjectPackage: - PrintDebugString(" type == cIsSameObjectPackage"); + PrintDebugString("[INFO]: type == cIsSameObjectPackage"); if (bufsize == (sizeof(PackageType) + sizeof(IsSameObjectPackage))) { IsSameObjectPackage *pkg = (IsSameObjectPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->isSameObject((jobject)pkg->obj1, (jobject)pkg->obj2); - PrintDebugString(" -> returning result = %d", pkg->rResult); + PrintDebugString("[INFO]: -> returning result = %d", pkg->rResult); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(IsSameObjectPackage)); } break; case cGetAccessibleContextFromHWNDPackage: - PrintDebugString(" type == cGetAccessibleContextFromHWNDPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleContextFromHWNDPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage))) { GetAccessibleContextFromHWNDPackage *pkg = (GetAccessibleContextFromHWNDPackage *) (buffer + sizeof(PackageType)); rAC = windowsThreadEntryPoints->getAccessibleContextFromHWND(pkg->window); pkg->rAccessibleContext = (JOBJECT64)rAC; pkg->rVMID = HandleToLong(dialogWindow); - PrintDebugString(" -> returning AC = %p, vmID = %X", rAC, pkg->rVMID); + PrintDebugString("[INFO]: -> returning AC = %p, vmID = %X", rAC, pkg->rVMID); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage)); } break; case cGetHWNDFromAccessibleContextPackage: - PrintDebugString(" type == cGetHWNDFromAccessibleContextPackage"); + PrintDebugString("[INFO]: type == cGetHWNDFromAccessibleContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetHWNDFromAccessibleContextPackage))) { GetHWNDFromAccessibleContextPackage *pkg = (GetHWNDFromAccessibleContextPackage *) (buffer + sizeof(PackageType)); pkg->rHWND = ABHandleToLong( windowsThreadEntryPoints->getHWNDFromAccessibleContext((jobject)pkg->accessibleContext) ); - PrintDebugString(" -> returning HWND = %p", pkg->rHWND); + PrintDebugString("[INFO]: -> returning HWND = %p", pkg->rHWND); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetHWNDFromAccessibleContextPackage)); } break; @@ -533,15 +535,15 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { /* ===== utility methods ===== */ case cSetTextContentsPackage: - PrintDebugString(" type == cSetTextContentsPackage"); + PrintDebugString("[INFO]: type == cSetTextContentsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(SetTextContentsPackage))) { SetTextContentsPackage *pkg = (SetTextContentsPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->setTextContents((jobject)pkg->accessibleContext, pkg->text); - PrintDebugString(" -> returning result = %d", pkg->rResult); + PrintDebugString("[INFO]: -> returning result = %d", pkg->rResult); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(SetTextContentsPackage)); } break; @@ -552,75 +554,76 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { (GetParentWithRolePackage *) (buffer + sizeof(PackageType)); rAC = windowsThreadEntryPoints->getParentWithRole((jobject)pkg->accessibleContext, pkg->role); pkg->rAccessibleContext = (JOBJECT64)rAC; - PrintDebugString(" type == cGetParentWithRolePackage"); - PrintDebugString(" pkg->vmID: %X", pkg->vmID); - PrintDebugString(" pkg->accessibleContext: %p", (jobject)pkg->accessibleContext); - PrintDebugString(" pkg->role: %ls", pkg->role); - PrintDebugString(" -> returning rAccessibleContext = %p", rAC); - } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[INFO]: type == cGetParentWithRolePackage\n"\ + " pkg->vmID: %X"\ + " pkg->accessibleContext: %p"\ + " pkg->role: %ls"\ + " -> returning rAccessibleContext = %p"\ + , pkg->vmID, (jobject)pkg->accessibleContext, pkg->role, rAC); + } else { + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetParentWithRolePackage)); } break; case cGetTopLevelObjectPackage: - PrintDebugString(" type == cGetTopLevelObjectPackage"); + PrintDebugString("[INFO]: type == cGetTopLevelObjectPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetTopLevelObjectPackage))) { GetTopLevelObjectPackage *pkg = (GetTopLevelObjectPackage *) (buffer + sizeof(PackageType)); rAC = windowsThreadEntryPoints->getTopLevelObject((jobject)pkg->accessibleContext); pkg->rAccessibleContext = (JOBJECT64)rAC; - PrintDebugString(" -> returning rAccessibleContext = %p", rAC); + PrintDebugString("[INFO]: -> returning rAccessibleContext = %p", rAC); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetTopLevelObjectPackage)); } break; case cGetParentWithRoleElseRootPackage: - PrintDebugString(" type == cGetParentWithRoleElseRootPackage"); + PrintDebugString("[INFO]: type == cGetParentWithRoleElseRootPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetParentWithRoleElseRootPackage))) { GetParentWithRoleElseRootPackage *pkg = (GetParentWithRoleElseRootPackage *) (buffer + sizeof(PackageType)); rAC = windowsThreadEntryPoints->getParentWithRoleElseRoot((jobject)pkg->accessibleContext, pkg->role); pkg->rAccessibleContext = (JOBJECT64)rAC; - PrintDebugString(" -> returning rAccessibleContext = %p", rAC); + PrintDebugString("[INFO]: -> returning rAccessibleContext = %p", rAC); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetParentWithRoleElseRootPackage)); } break; case cGetObjectDepthPackage: - PrintDebugString(" type == cGetObjectDepthPackage"); + PrintDebugString("[INFO]: type == cGetObjectDepthPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetObjectDepthPackage))) { GetObjectDepthPackage *pkg = (GetObjectDepthPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->getObjectDepth((jobject)pkg->accessibleContext); - PrintDebugString(" -> returning rResult = %d", pkg->rResult); + PrintDebugString("[INFO]: -> returning rResult = %d", pkg->rResult); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetObjectDepthPackage)); } break; case cGetActiveDescendentPackage: - PrintDebugString(" type == cGetActiveDescendentPackage"); + PrintDebugString("[INFO]: type == cGetActiveDescendentPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetActiveDescendentPackage))) { GetActiveDescendentPackage *pkg = (GetActiveDescendentPackage *) (buffer + sizeof(PackageType)); rAC = windowsThreadEntryPoints->getActiveDescendent((jobject)pkg->accessibleContext); pkg->rAccessibleContext = (JOBJECT64)rAC; - PrintDebugString(" -> returning rAccessibleContext = %p", rAC); + PrintDebugString("[INFO]: -> returning rAccessibleContext = %p", rAC); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetActiveDescendentPackage)); } break; case cGetAccessibleContextAtPackage: - PrintDebugString(" type == cGetAccessibleContextAtPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleContextAtPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextAtPackage))) { GetAccessibleContextAtPackage *pkg = (GetAccessibleContextAtPackage *) (buffer + sizeof(PackageType)); @@ -628,13 +631,13 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { windowsThreadEntryPoints->getAccessibleContextAt(pkg->x, pkg->y, (jobject)pkg->AccessibleContext); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextAtPackage)); } break; case cGetAccessibleContextWithFocusPackage: - PrintDebugString(" type == cGetAccessibleContextWithFocusPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleContextWithFocusPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage))) { GetAccessibleContextWithFocusPackage *pkg = (GetAccessibleContextWithFocusPackage *) (buffer + sizeof(PackageType)); @@ -642,46 +645,46 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { windowsThreadEntryPoints->getAccessibleContextWithFocus(); pkg->rVMID = HandleToLong(dialogWindow); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage)); } break; case cGetAccessibleContextInfoPackage: - PrintDebugString(" type == cGetAccessibleContextInfoPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleContextInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleContextInfoPackage))) { GetAccessibleContextInfoPackage *pkg = (GetAccessibleContextInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleContextInfo( (jobject)pkg->AccessibleContext, &(pkg->rAccessibleContextInfo)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleContextInfoPackage)); } break; case cGetAccessibleChildFromContextPackage: - PrintDebugString(" type == cGetAccessibleChildFromContextPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleChildFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleChildFromContextPackage))) { GetAccessibleChildFromContextPackage *pkg = (GetAccessibleChildFromContextPackage *) (buffer + sizeof(PackageType)); pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleChildFromContext( (jobject)pkg->AccessibleContext, pkg->childIndex); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleChildFromContextPackage)); } break; case cGetAccessibleParentFromContextPackage: - PrintDebugString(" type == cGetAccessibleParentFromContextPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleParentFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleParentFromContextPackage))) { GetAccessibleParentFromContextPackage *pkg = (GetAccessibleParentFromContextPackage *) (buffer + sizeof(PackageType)); pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleParentFromContext( (jobject)pkg->AccessibleContext); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleParentFromContextPackage)); } break; @@ -689,106 +692,106 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ begin AccessibleTable packages ------------------ case cGetAccessibleTableInfoPackage: - PrintDebugString(" ##### type == cGetAccessibleTableInfoPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableInfoPackage))) { GetAccessibleTableInfoPackage *pkg = (GetAccessibleTableInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTableInfo((jobject)pkg->accessibleContext, &(pkg->rTableInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableInfoPackage)); } break; case cGetAccessibleTableCellInfoPackage: - PrintDebugString(" ##### type == cGetAccessibleTableCellInfoPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableCellInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableCellInfoPackage))) { GetAccessibleTableCellInfoPackage *pkg = (GetAccessibleTableCellInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTableCellInfo((jobject)pkg->accessibleTable, pkg->row, pkg->column, &(pkg->rTableCellInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableCellInfoPackage)); } break; case cGetAccessibleTableRowHeaderPackage: - PrintDebugString(" ##### type == cGetAccessibleTableRowHeaderPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableRowHeaderPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowHeaderPackage))) { GetAccessibleTableRowHeaderPackage *pkg = (GetAccessibleTableRowHeaderPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTableRowHeader((jobject)pkg->accessibleContext, &(pkg->rTableInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowHeaderPackage)); } break; case cGetAccessibleTableColumnHeaderPackage: - PrintDebugString(" ##### type == cGetAccessibleTableColumnHeaderPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableColumnHeaderPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnHeaderPackage))) { GetAccessibleTableColumnHeaderPackage *pkg = (GetAccessibleTableColumnHeaderPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTableColumnHeader((jobject)pkg->accessibleContext, &(pkg->rTableInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnHeaderPackage)); } break; case cGetAccessibleTableRowDescriptionPackage: - PrintDebugString(" ##### type == cGetAccessibleTableRowDescriptionPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableRowDescriptionPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowDescriptionPackage))) { GetAccessibleTableRowDescriptionPackage *pkg = (GetAccessibleTableRowDescriptionPackage *) (buffer + sizeof(PackageType)); pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleTableRowDescription( (jobject)pkg->accessibleContext, pkg->row); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowDescriptionPackage)); } break; case cGetAccessibleTableColumnDescriptionPackage: - PrintDebugString(" ##### type == cGetAccessibleTableColumnDescriptionPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableColumnDescriptionPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnDescriptionPackage))) { GetAccessibleTableColumnDescriptionPackage *pkg = (GetAccessibleTableColumnDescriptionPackage *) (buffer + sizeof(PackageType)); pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleTableColumnDescription( (jobject)pkg->accessibleContext, pkg->column); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnDescriptionPackage)); } break; case cGetAccessibleTableColumnSelectionCountPackage: - PrintDebugString(" ##### type == cGetAccessibleTableColumnSelectionCountPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableColumnSelectionCountPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionCountPackage))) { GetAccessibleTableColumnSelectionCountPackage *pkg = (GetAccessibleTableColumnSelectionCountPackage *) (buffer + sizeof(PackageType)); pkg->rCount = windowsThreadEntryPoints->getAccessibleTableColumnSelectionCount( (jobject)pkg->accessibleTable); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionCountPackage)); } break; case cGetAccessibleTableRowSelectionCountPackage: - PrintDebugString(" ##### type == cGetAccessibleTableRowSelectionCountPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableRowSelectionCountPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionCountPackage))) { GetAccessibleTableRowSelectionCountPackage *pkg = (GetAccessibleTableRowSelectionCountPackage *) (buffer + sizeof(PackageType)); @@ -796,114 +799,114 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { pkg->rCount = windowsThreadEntryPoints->getAccessibleTableRowSelectionCount( (jobject)pkg->accessibleTable); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionCountPackage)); } break; case cIsAccessibleTableRowSelectedPackage: - PrintDebugString(" ##### type == cIsAccessibleTableRowSelectedPackage"); + PrintDebugString("[INFO]: ##### type == cIsAccessibleTableRowSelectedPackage"); if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleTableRowSelectedPackage))) { IsAccessibleTableRowSelectedPackage *pkg = (IsAccessibleTableRowSelectedPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->isAccessibleTableRowSelected( (jobject)pkg->accessibleTable, pkg->row); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(IsAccessibleTableRowSelectedPackage)); } break; case cIsAccessibleTableColumnSelectedPackage: - PrintDebugString(" ##### type == cIsAccessibleTableColumnSelectedPackage"); + PrintDebugString("[INFO]: ##### type == cIsAccessibleTableColumnSelectedPackage"); if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleTableColumnSelectedPackage))) { IsAccessibleTableColumnSelectedPackage *pkg = (IsAccessibleTableColumnSelectedPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->isAccessibleTableColumnSelected( (jobject)pkg->accessibleTable, pkg->column); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(IsAccessibleTableColumnSelectedPackage)); } break; case cGetAccessibleTableColumnSelectionsPackage: - PrintDebugString(" ##### type == cGetAccessibleTableColumnSelectionsPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableColumnSelectionsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionsPackage))) { GetAccessibleTableColumnSelectionsPackage *pkg = (GetAccessibleTableColumnSelectionsPackage *) (buffer + sizeof(PackageType)); - PrintDebugString(" ##### cGetAccessibleTableColumnSelectionsPackage count=%d", pkg->count); + PrintDebugString("[INFO]: ##### cGetAccessibleTableColumnSelectionsPackage count=%d", pkg->count); windowsThreadEntryPoints->getAccessibleTableColumnSelections( (jobject)pkg->accessibleTable, pkg->count, pkg->rSelections); for (int i = 0; i < pkg->count; i++) { - PrintDebugString(" ##### cGetAccessibleTableColumnSelectionsPackage(%d)=%d", i, pkg->rSelections[i]); + PrintDebugString("[INFO]: ##### cGetAccessibleTableColumnSelectionsPackage(%d)=%d", i, pkg->rSelections[i]); } - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnSelectionsPackage)); } break; case cGetAccessibleTableRowSelectionsPackage: - PrintDebugString(" ##### type == cGetAccessibleTableRowSelectionsPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableRowSelectionsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionsPackage))) { GetAccessibleTableRowSelectionsPackage *pkg = (GetAccessibleTableRowSelectionsPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTableRowSelections( (jobject)pkg->accessibleTable, pkg->count, pkg->rSelections); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowSelectionsPackage)); } break; case cGetAccessibleTableRowPackage: - PrintDebugString(" ##### type == cGetAccessibleTableRowPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableRowPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableRowPackage))) { GetAccessibleTableRowPackage *pkg = (GetAccessibleTableRowPackage *) (buffer + sizeof(PackageType)); pkg->rRow = windowsThreadEntryPoints->getAccessibleTableRow( (jobject)pkg->accessibleTable, pkg->index); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableRowPackage)); } break; case cGetAccessibleTableColumnPackage: - PrintDebugString(" ##### type == cGetAccessibleTableColumnPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableColumnPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableColumnPackage))) { GetAccessibleTableColumnPackage *pkg = (GetAccessibleTableColumnPackage *) (buffer + sizeof(PackageType)); pkg->rColumn = windowsThreadEntryPoints->getAccessibleTableColumn( (jobject)pkg->accessibleTable, pkg->index); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableColumnPackage)); } break; case cGetAccessibleTableIndexPackage: - PrintDebugString(" ##### type == cGetAccessibleTableIndexPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleTableIndexPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTableIndexPackage))) { GetAccessibleTableIndexPackage *pkg = (GetAccessibleTableIndexPackage *) (buffer + sizeof(PackageType)); pkg->rIndex = windowsThreadEntryPoints->getAccessibleTableIndex( (jobject)pkg->accessibleTable, pkg->row, pkg->column); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTableIndexPackage)); } break; @@ -914,15 +917,15 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ begin AccessibleRelationSet packages ------------------ case cGetAccessibleRelationSetPackage: - PrintDebugString(" ##### type == cGetAccessibleRelationSetPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleRelationSetPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleRelationSetPackage))) { GetAccessibleRelationSetPackage *pkg = (GetAccessibleRelationSetPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleRelationSet( (jobject)pkg->accessibleContext, &(pkg->rAccessibleRelationSetInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleRelationSetPackage)); } break; @@ -932,85 +935,85 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ begin AccessibleHypertext packages ------------------ case cGetAccessibleHypertextPackage: - PrintDebugString(" ##### type == cGetAccessibleHypertextPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleHypertextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextPackage))) { GetAccessibleHypertextPackage *pkg = (GetAccessibleHypertextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleHypertext( (jobject)pkg->accessibleContext, &(pkg->rAccessibleHypertextInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextPackage)); } break; case cActivateAccessibleHyperlinkPackage: - PrintDebugString(" ##### type == cActivateAccessibleHyperlinkPackage"); + PrintDebugString("[INFO]: ##### type == cActivateAccessibleHyperlinkPackage"); if (bufsize == (sizeof(PackageType) + sizeof(ActivateAccessibleHyperlinkPackage))) { ActivateAccessibleHyperlinkPackage *pkg = (ActivateAccessibleHyperlinkPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->activateAccessibleHyperlink( (jobject)pkg->accessibleContext, (jobject)pkg->accessibleHyperlink); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(ActivateAccessibleHyperlinkPackage)); } break; case cGetAccessibleHyperlinkCountPackage: - PrintDebugString(" ##### type == cGetAccessibleHyperlinkCountPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleHyperlinkCountPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHyperlinkCountPackage))) { GetAccessibleHyperlinkCountPackage *pkg = (GetAccessibleHyperlinkCountPackage *) (buffer + sizeof(PackageType)); pkg->rLinkCount = windowsThreadEntryPoints->getAccessibleHyperlinkCount( (jobject)pkg->accessibleContext); - PrintDebugString(" ##### processing succeeded: pkg->rLinkCount = %d", pkg->rLinkCount); + PrintDebugString("[INFO]: ##### processing succeeded: pkg->rLinkCount = %d", pkg->rLinkCount); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleHyperlinkCountPackage)); } break; case cGetAccessibleHypertextExtPackage: - PrintDebugString(" ##### type == cGetAccessibleHypertextExtPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleHypertextExtPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextExtPackage))) { GetAccessibleHypertextExtPackage *pkg = (GetAccessibleHypertextExtPackage *) (buffer + sizeof(PackageType)); pkg->rSuccess = windowsThreadEntryPoints->getAccessibleHypertextExt( (jobject)pkg->accessibleContext, pkg->startIndex, &(pkg->rAccessibleHypertextInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextExtPackage)); } break; case cGetAccessibleHypertextLinkIndexPackage: - PrintDebugString(" ##### type == cGetAccessibleHypertextLinkIndexPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleHypertextLinkIndexPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHypertextLinkIndexPackage))) { GetAccessibleHypertextLinkIndexPackage *pkg = (GetAccessibleHypertextLinkIndexPackage *) (buffer + sizeof(PackageType)); pkg->rLinkIndex = windowsThreadEntryPoints->getAccessibleHypertextLinkIndex( (jobject)pkg->hypertext, pkg->charIndex); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleHypertextLinkIndexPackage)); } break; case cGetAccessibleHyperlinkPackage: - PrintDebugString(" ##### type == cGetAccessibleHyperlinkPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleHyperlinkPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleHyperlinkPackage))) { GetAccessibleHyperlinkPackage *pkg = (GetAccessibleHyperlinkPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleHyperlink((jobject)pkg->hypertext, pkg->linkIndex, &(pkg->rAccessibleHyperlinkInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleHyperlinkPackage)); } break; @@ -1020,59 +1023,59 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ begin Accessible KeyBindings, Icons and Actions case cGetAccessibleKeyBindingsPackage: - PrintDebugString(" ##### type == cGetAccessibleKeyBindingsPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleKeyBindingsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleKeyBindingsPackage))) { GetAccessibleKeyBindingsPackage *pkg = (GetAccessibleKeyBindingsPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleKeyBindings ( (jobject)pkg->accessibleContext, &(pkg->rAccessibleKeyBindings)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleKeyBindingsPackage)); } break; case cGetAccessibleIconsPackage: - PrintDebugString(" ##### type == cGetAccessibleIconsPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleIconsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleIconsPackage))) { GetAccessibleIconsPackage *pkg = (GetAccessibleIconsPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleIcons ( (jobject)pkg->accessibleContext, &(pkg->rAccessibleIcons)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleIconsPackage)); } break; case cGetAccessibleActionsPackage: - PrintDebugString(" ##### type == cGetAccessibleActionsPackage"); + PrintDebugString("[INFO]: ##### type == cGetAccessibleActionsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleActionsPackage))) { GetAccessibleActionsPackage *pkg = (GetAccessibleActionsPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleActions ( (jobject)pkg->accessibleContext, &(pkg->rAccessibleActions)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleActionsPackage)); } break; case cDoAccessibleActionsPackage: - PrintDebugString(" ##### type == cDoAccessibleActionsPackage"); + PrintDebugString("[INFO]: ##### type == cDoAccessibleActionsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(DoAccessibleActionsPackage))) { DoAccessibleActionsPackage *pkg = (DoAccessibleActionsPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->doAccessibleActions((jobject)pkg->accessibleContext, &(pkg->actionsToDo), &(pkg->failure)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(DoAccessibleActionsPackage)); } break; @@ -1080,50 +1083,50 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ begin addtional methods for Teton case cGetVirtualAccessibleNamePackage: - PrintDebugString(" ##### type == GetVirtualAccessibleNamePackage"); + PrintDebugString("[INFO]: ##### type == GetVirtualAccessibleNamePackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetVirtualAccessibleNamePackage))) { GetVirtualAccessibleNamePackage *pkg = (GetVirtualAccessibleNamePackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getVirtualAccessibleName ((const jobject)pkg->accessibleContext, pkg->rName, pkg->len); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetVirtualAccessibleNamePackage)); } break; case cRequestFocusPackage: - PrintDebugString(" ##### type == RequestFocusPackage"); + PrintDebugString("[INFO]: ##### type == RequestFocusPackage"); if (bufsize == (sizeof(PackageType) + sizeof(RequestFocusPackage))) { RequestFocusPackage *pkg = (RequestFocusPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->requestFocus ( (jobject)pkg->accessibleContext); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(RequestFocusPackage)); } break; case cSelectTextRangePackage: - PrintDebugString(" ##### type == SelectTextRangePackage"); + PrintDebugString("[INFO]: ##### type == SelectTextRangePackage"); if (bufsize == (sizeof(PackageType) + sizeof(SelectTextRangePackage))) { SelectTextRangePackage *pkg = (SelectTextRangePackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->selectTextRange ( (jobject)pkg->accessibleContext, pkg->startIndex, pkg->endIndex); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(SelectTextRangePackage)); } break; case cGetTextAttributesInRangePackage: - PrintDebugString(" ##### type == GetTextAttributesInRangePackage"); + PrintDebugString("[INFO]: ##### type == GetTextAttributesInRangePackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetTextAttributesInRangePackage))) { GetTextAttributesInRangePackage *pkg = (GetTextAttributesInRangePackage *) (buffer + sizeof(PackageType)); @@ -1131,30 +1134,30 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { (jobject)pkg->accessibleContext, pkg->startIndex, pkg->endIndex, (AccessibleTextAttributesInfo *)&(pkg->attributes), &(pkg->rLength)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetTextAttributesInRangePackage)); } break; case cGetVisibleChildrenCountPackage: - PrintDebugString(" ##### type == GetVisibleChildrenCountPackage"); + PrintDebugString("[INFO]: ##### type == GetVisibleChildrenCountPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetVisibleChildrenCountPackage))) { GetVisibleChildrenCountPackage *pkg = (GetVisibleChildrenCountPackage *) (buffer + sizeof(PackageType)); pkg->rChildrenCount = windowsThreadEntryPoints->getVisibleChildrenCount ((jobject)pkg->accessibleContext); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetVisibleChildrenCountPackage)); } break; case cGetVisibleChildrenPackage: - PrintDebugString(" ##### type == GetVisibleChildrenPackage"); + PrintDebugString("[INFO]: ##### type == GetVisibleChildrenPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetVisibleChildrenPackage))) { GetVisibleChildrenPackage *pkg = (GetVisibleChildrenPackage *) (buffer + sizeof(PackageType)); @@ -1162,23 +1165,23 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { pkg->startIndex, &(pkg->rVisibleChildrenInfo)); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetVisibleChildrenPackage)); } break; case cSetCaretPositionPackage: - PrintDebugString(" ##### type == SetCaretPositionPackage"); + PrintDebugString("[INFO]: ##### type == SetCaretPositionPackage"); if (bufsize == (sizeof(PackageType) + sizeof(SetCaretPositionPackage))) { SetCaretPositionPackage *pkg = (SetCaretPositionPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->setCaretPosition ( (jobject)pkg->accessibleContext, pkg->position); - PrintDebugString(" ##### processing succeeded"); + PrintDebugString("[INFO]: ##### processing succeeded"); } else { - PrintDebugString(" ##### processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: ##### processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(SetCaretPositionPackage)); } break; @@ -1190,105 +1193,105 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ Accessible Text packages ------------------ case cGetAccessibleTextInfoPackage: - PrintDebugString(" type == cGetAccessibleTextInfoPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage))) { GetAccessibleTextInfoPackage *pkg = (GetAccessibleTextInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextInfo((jobject)pkg->AccessibleContext, &(pkg->rTextInfo), pkg->x, pkg->y); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage)); } break; case cGetAccessibleTextItemsPackage: - PrintDebugString(" type == cGetAccessibleTextItemsPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextItemsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextItemsPackage))) { GetAccessibleTextItemsPackage *pkg = (GetAccessibleTextItemsPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextItems((jobject)pkg->AccessibleContext, &(pkg->rTextItemsInfo), pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextInfoPackage)); } break; case cGetAccessibleTextSelectionInfoPackage: - PrintDebugString(" type == cGetAccessibleTextSelectionInfoPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextSelectionInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextSelectionInfoPackage))) { GetAccessibleTextSelectionInfoPackage *pkg = (GetAccessibleTextSelectionInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextSelectionInfo( (jobject)pkg->AccessibleContext, &(pkg->rTextSelectionItemsInfo)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextSelectionInfoPackage)); } break; case cGetAccessibleTextAttributeInfoPackage: - PrintDebugString(" type == cGetAccessibleTextAttributeInfoPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextAttributeInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextAttributeInfoPackage))) { GetAccessibleTextAttributeInfoPackage *pkg = (GetAccessibleTextAttributeInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextAttributes( (jobject)pkg->AccessibleContext, pkg->index, (AccessibleTextAttributesInfo *) &(pkg->rAttributeInfo)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextAttributeInfoPackage)); } break; case cGetAccessibleTextRectInfoPackage: - PrintDebugString(" type == cGetAccessibleTextRectInfoPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextRectInfoPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextRectInfoPackage))) { GetAccessibleTextRectInfoPackage *pkg = (GetAccessibleTextRectInfoPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextRect((jobject)pkg->AccessibleContext, &(pkg->rTextRectInfo), pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextRectInfoPackage)); } break; case cGetCaretLocationPackage: - PrintDebugString(" type == cGetCaretLocationPackage"); + PrintDebugString("[INFO]: type == cGetCaretLocationPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetCaretLocationPackage))) { GetCaretLocationPackage *pkg = (GetCaretLocationPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getCaretLocation((jobject)pkg->AccessibleContext, &(pkg->rTextRectInfo), pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetCaretLocationPackage)); } break; case cGetAccessibleTextLineBoundsPackage: - PrintDebugString(" type == cGetAccessibleTextLineBoundsPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextLineBoundsPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextLineBoundsPackage))) { GetAccessibleTextLineBoundsPackage *pkg = (GetAccessibleTextLineBoundsPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextLineBounds((jobject)pkg->AccessibleContext, pkg->index, &(pkg->rLineStart), &(pkg->rLineEnd)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextLineBoundsPackage)); } break; case cGetAccessibleTextRangePackage: - PrintDebugString(" type == cGetAccessibleTextRangePackage"); + PrintDebugString("[INFO]: type == cGetAccessibleTextRangePackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleTextRangePackage))) { GetAccessibleTextRangePackage *pkg = (GetAccessibleTextRangePackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getAccessibleTextRange((jobject)pkg->AccessibleContext, pkg->start, pkg->end, (wchar_t *) &(pkg->rText), (sizeof(pkg->rText) / sizeof(wchar_t))); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleTextRangePackage)); } break; @@ -1297,40 +1300,40 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ Accessible Value packages ------------------ case cGetCurrentAccessibleValueFromContextPackage: - PrintDebugString(" type == cGetCurrentAccessibleValueFromContextPackage"); + PrintDebugString("[INFO]: type == cGetCurrentAccessibleValueFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetCurrentAccessibleValueFromContextPackage))) { GetCurrentAccessibleValueFromContextPackage *pkg = (GetCurrentAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getCurrentAccessibleValueFromContext((jobject)pkg->AccessibleContext, (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t))); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetCurrentAccessibleValueFromContextPackage)); } break; case cGetMaximumAccessibleValueFromContextPackage: - PrintDebugString(" type == cGetMaximumAccessibleValueFromContextPackage"); + PrintDebugString("[INFO]: type == cGetMaximumAccessibleValueFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetMaximumAccessibleValueFromContextPackage))) { GetMaximumAccessibleValueFromContextPackage *pkg = (GetMaximumAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getMaximumAccessibleValueFromContext((jobject)pkg->AccessibleContext, (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t))); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetMaximumAccessibleValueFromContextPackage)); } break; case cGetMinimumAccessibleValueFromContextPackage: - PrintDebugString(" type == cGetMinimumAccessibleValueFromContextPackage"); + PrintDebugString("[INFO]: type == cGetMinimumAccessibleValueFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetMinimumAccessibleValueFromContextPackage))) { GetMinimumAccessibleValueFromContextPackage *pkg = (GetMinimumAccessibleValueFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->getMinimumAccessibleValueFromContext((jobject)pkg->AccessibleContext, (wchar_t *) &(pkg->rValue), (sizeof(pkg->rValue) / sizeof(wchar_t))); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetMinimumAccessibleValueFromContextPackage)); } break; @@ -1338,90 +1341,90 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ Accessible Selection packages ------------------ case cAddAccessibleSelectionFromContextPackage: - PrintDebugString(" type == cAddAccessibleSelectionFromContextPackage"); + PrintDebugString("[INFO]: type == cAddAccessibleSelectionFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(AddAccessibleSelectionFromContextPackage))) { AddAccessibleSelectionFromContextPackage *pkg = (AddAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->addAccessibleSelectionFromContext((jobject)pkg->AccessibleContext, pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(AddAccessibleSelectionFromContextPackage)); } break; case cClearAccessibleSelectionFromContextPackage: - PrintDebugString(" type == cClearAccessibleSelectionFromContextPackage"); + PrintDebugString("[INFO]: type == cClearAccessibleSelectionFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(ClearAccessibleSelectionFromContextPackage))) { ClearAccessibleSelectionFromContextPackage *pkg = (ClearAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->clearAccessibleSelectionFromContext((jobject)pkg->AccessibleContext); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(ClearAccessibleSelectionFromContextPackage)); } break; case cGetAccessibleSelectionFromContextPackage: - PrintDebugString(" type == cGetAccessibleSelectionFromContextPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleSelectionFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleSelectionFromContextPackage))) { GetAccessibleSelectionFromContextPackage *pkg = (GetAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType)); pkg->rAccessibleContext = (JOBJECT64)windowsThreadEntryPoints->getAccessibleSelectionFromContext( (jobject)pkg->AccessibleContext, pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleSelectionFromContextPackage)); } break; case cGetAccessibleSelectionCountFromContextPackage: - PrintDebugString(" type == cGetAccessibleSelectionCountFromContextPackage"); + PrintDebugString("[INFO]: type == cGetAccessibleSelectionCountFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(GetAccessibleSelectionCountFromContextPackage))) { GetAccessibleSelectionCountFromContextPackage *pkg = (GetAccessibleSelectionCountFromContextPackage *) (buffer + sizeof(PackageType)); pkg->rCount = windowsThreadEntryPoints->getAccessibleSelectionCountFromContext( (jobject)pkg->AccessibleContext); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(GetAccessibleSelectionCountFromContextPackage)); } break; case cIsAccessibleChildSelectedFromContextPackage: - PrintDebugString(" type == cIsAccessibleChildSelectedFromContextPackage"); + PrintDebugString("[INFO]: type == cIsAccessibleChildSelectedFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(IsAccessibleChildSelectedFromContextPackage))) { IsAccessibleChildSelectedFromContextPackage *pkg = (IsAccessibleChildSelectedFromContextPackage *) (buffer + sizeof(PackageType)); pkg->rResult = windowsThreadEntryPoints->isAccessibleChildSelectedFromContext( (jobject)pkg->AccessibleContext, pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(IsAccessibleChildSelectedFromContextPackage)); } break; case cRemoveAccessibleSelectionFromContextPackage: - PrintDebugString(" type == cRemoveAccessibleSelectionFromContextPackage"); + PrintDebugString("[INFO]: type == cRemoveAccessibleSelectionFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(RemoveAccessibleSelectionFromContextPackage))) { RemoveAccessibleSelectionFromContextPackage *pkg = (RemoveAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->removeAccessibleSelectionFromContext((jobject)pkg->AccessibleContext, pkg->index); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(RemoveAccessibleSelectionFromContextPackage)); } break; case cSelectAllAccessibleSelectionFromContextPackage: - PrintDebugString(" type == cSelectAllAccessibleSelectionFromContextPackage"); + PrintDebugString("[INFO]: type == cSelectAllAccessibleSelectionFromContextPackage"); if (bufsize == (sizeof(PackageType) + sizeof(SelectAllAccessibleSelectionFromContextPackage))) { SelectAllAccessibleSelectionFromContextPackage *pkg = (SelectAllAccessibleSelectionFromContextPackage *) (buffer + sizeof(PackageType)); windowsThreadEntryPoints->selectAllAccessibleSelectionFromContext((jobject)pkg->AccessibleContext); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(SelectAllAccessibleSelectionFromContextPackage)); } break; @@ -1430,60 +1433,60 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { // ------------ event notification management packages ------------------ case cAddJavaEventNotificationPackage: - PrintDebugString(" type = cAddJavaEventNotificationPackage"); + PrintDebugString("[INFO]: type = cAddJavaEventNotificationPackage"); if (bufsize == (sizeof(PackageType) + sizeof(AddJavaEventNotificationPackage))) { AddJavaEventNotificationPackage *pkg = (AddJavaEventNotificationPackage *) (buffer + sizeof(PackageType)); addJavaEventNotification(pkg->type, (HWND)ABLongToHandle( pkg->DLLwindow ) ); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(AddJavaEventNotificationPackage)); } break; case cRemoveJavaEventNotificationPackage: - PrintDebugString(" type = cRemoveJavaEventNotificationPackage"); + PrintDebugString("[INFO]: type = cRemoveJavaEventNotificationPackage"); if (bufsize == (sizeof(PackageType) + sizeof(RemoveJavaEventNotificationPackage))) { RemoveJavaEventNotificationPackage *pkg = (RemoveJavaEventNotificationPackage *) (buffer + sizeof(PackageType)); removeJavaEventNotification(pkg->type, (HWND)ABLongToHandle( pkg->DLLwindow )); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(RemoveJavaEventNotificationPackage)); } break; case cAddAccessibilityEventNotificationPackage: - PrintDebugString(" type = cAddAccessibilityEventNotificationPackage"); + PrintDebugString("[INFO]: type = cAddAccessibilityEventNotificationPackage"); if (bufsize == (sizeof(PackageType) + sizeof(AddAccessibilityEventNotificationPackage))) { AddAccessibilityEventNotificationPackage *pkg = (AddAccessibilityEventNotificationPackage *) (buffer + sizeof(PackageType)); addAccessibilityEventNotification(pkg->type, (HWND)ABLongToHandle(pkg->DLLwindow)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(AddAccessibilityEventNotificationPackage)); } break; case cRemoveAccessibilityEventNotificationPackage: - PrintDebugString(" type = cRemoveAccessibilityEventNotificationPackage"); + PrintDebugString("[INFO]: type = cRemoveAccessibilityEventNotificationPackage"); if (bufsize == (sizeof(PackageType) + sizeof(RemoveAccessibilityEventNotificationPackage))) { RemoveAccessibilityEventNotificationPackage *pkg = (RemoveAccessibilityEventNotificationPackage *) (buffer + sizeof(PackageType)); removeAccessibilityEventNotification(pkg->type, (HWND)ABLongToHandle(pkg->DLLwindow)); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(RemoveAccessibilityEventNotificationPackage)); } break; default: - PrintDebugString(" processing FAILED!! -> don't know how to handle type = %X", *type); + PrintDebugString("[ERROR]: processing FAILED!! -> don't know how to handle type = %X", *type); returnVal = -1; break; } - PrintDebugString(" package processing completed"); + PrintDebugString("[INFO]: package processing completed"); return returnVal; } @@ -1502,17 +1505,17 @@ JavaAccessBridge::processPackage(char *buffer, int bufsize) { */ LRESULT JavaAccessBridge::MemoryMappedFileCreated(HWND ATBridgeDLLWindow, char *filename) { - PrintDebugString(" in MemoryMappedFileCreated(%p, %s)!", ATBridgeDLLWindow, filename); + PrintDebugString("[INFO]: in MemoryMappedFileCreated(%p, %s)!", ATBridgeDLLWindow, filename); AccessBridgeATInstance *newAT = new AccessBridgeATInstance(dialogWindow, ATBridgeDLLWindow, filename, ATs); - PrintDebugString(" just created a new ATInstance = %p, old = %p", newAT, ATs); + PrintDebugString("[INFO]: just created a new ATInstance = %p, old = %p", newAT, ATs); ATs = newAT; LRESULT returnVal = ATs->initiateIPC(); if (returnVal == 0) { - PrintDebugString(" Successfully initiated IPC with AT!!!"); + PrintDebugString("[INFO]: Successfully initiated IPC with AT!!!"); } else { - PrintDebugString(" ERROR: Failed to initiate IPC with AT!!!"); + PrintDebugString("[ERROR]: Failed to initiate IPC with AT!!!"); } return returnVal; @@ -1525,9 +1528,9 @@ JavaAccessBridge::MemoryMappedFileCreated(HWND ATBridgeDLLWindow, char *filename */ void JavaAccessBridge::WindowsATDestroyed(HWND ATBridgeDLLWindow) { - PrintDebugString("\r\nin JavaAccessBridge::WindowsATDestroyed(%p)", ATBridgeDLLWindow); + PrintDebugString("[INFO]: in JavaAccessBridge::WindowsATDestroyed(%p)", ATBridgeDLLWindow); if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! -> ATs == 0! (shouldn't happen here)"); + PrintDebugString("[ERROR]: -> ATs == 0! (shouldn't happen here)"); return; } @@ -1539,20 +1542,20 @@ JavaAccessBridge::WindowsATDestroyed(HWND ATBridgeDLLWindow) { removeJavaEventNotification(currentAT->javaEventMask, ATBridgeDLLWindow); removeAccessibilityEventNotification(currentAT->accessibilityEventMask, ATBridgeDLLWindow); delete currentAT; - PrintDebugString(" data structures successfully removed"); + PrintDebugString("[INFO]: data structures successfully removed"); } else { while (currentAT != (AccessBridgeATInstance *) NULL) { if (currentAT->winAccessBridgeWindow == ATBridgeDLLWindow) { previousAT->nextATInstance = currentAT->nextATInstance; delete currentAT; - PrintDebugString(" data structures successfully removed"); + PrintDebugString("[INFO]: data structures successfully removed"); return; } else { previousAT = currentAT; currentAT = currentAT->nextATInstance; } } - PrintDebugString(" ERROR!! couldn't find matching data structures!"); + PrintDebugString("[ERROR]: couldn't find matching data structures!"); } } @@ -1570,13 +1573,13 @@ JavaAccessBridge::WindowsATDestroyed(HWND ATBridgeDLLWindow) { */ void JavaAccessBridge::releaseJavaObject(jobject object) { - PrintDebugString("In JavaAccessBridge::releaseJavaObject"); - PrintDebugString(" object X: %p", object); + PrintDebugString("[INFO]: In JavaAccessBridge::releaseJavaObject"); + PrintDebugString("[INFO]: object X: %p", object); if (windowsThreadJNIEnv != (JNIEnv *) 0) { windowsThreadJNIEnv->DeleteGlobalRef(object); - PrintDebugString(" global reference deleted.", object); + PrintDebugString("[INFO]: global reference deleted.", object); } else { - PrintDebugString(" Error! windowsThreadJNIEnv == 0"); + PrintDebugString("[ERROR]: windowsThreadJNIEnv == 0"); } } @@ -1590,23 +1593,23 @@ void JavaAccessBridge::addJavaEventNotification(jlong type, HWND DLLwindow) { // walk through list of ATs, find this one and add this type // and, if we weren't listening for these before, ask Java for 'em - PrintDebugString(" adding Java event type %016I64X to HWND %p", type, DLLwindow); + PrintDebugString("[INFO]: adding Java event type %016I64X to HWND %p", type, DLLwindow); AccessBridgeATInstance *ati = ATs; long globalEventMask = 0; while (ati != (AccessBridgeATInstance *) 0) { if (ati->winAccessBridgeWindow == DLLwindow) { ati->javaEventMask |= type; - PrintDebugString(" found HWND, javaEventMask now is %X", ati->javaEventMask); + PrintDebugString("[INFO]: found HWND, javaEventMask now is %X", ati->javaEventMask); } else { globalEventMask |= ati->javaEventMask; } ati = ati->nextATInstance; } - PrintDebugString(" union of all Java AT event masks: %X", globalEventMask); + PrintDebugString("[INFO]: union of all Java AT event masks: %X", globalEventMask); if (!(globalEventMask & type)) { // no other ATs wanted this event; // start getting them from Java - PrintDebugString(" no other AT wanted this Java event (so not registered); adding to AccessBridge.java"); + PrintDebugString("[INFO]: no other AT wanted this Java event (so not registered); adding to AccessBridge.java"); windowsThreadEntryPoints->addJavaEventNotification(type); } } @@ -1619,23 +1622,23 @@ void JavaAccessBridge::removeJavaEventNotification(jlong type, HWND DLLwindow) { // walk through list of ATs, find this one and remove this type // and, if no other AT wants 'em either, tell Java we no longer want 'em - PrintDebugString(" removing Java event type %016I64X from HWND %p", type, DLLwindow); + PrintDebugString("[INFO]: removing Java event type %016I64X from HWND %p", type, DLLwindow); AccessBridgeATInstance *ati = ATs; long globalEventMask = 0; while (ati != (AccessBridgeATInstance *) 0) { if (ati->winAccessBridgeWindow == DLLwindow) { ati->javaEventMask &= (0xFFFFFFFF - type); - PrintDebugString(" found HWND, javaEventMask now is %X", ati->javaEventMask); + PrintDebugString("[INFO]: found HWND, javaEventMask now is %X", ati->javaEventMask); } else { globalEventMask |= ati->javaEventMask; } ati = ati->nextATInstance; } - PrintDebugString(" union of all Java AT event masks: %X", globalEventMask); + PrintDebugString("[INFO]: union of all Java AT event masks: %X", globalEventMask); if (!(globalEventMask & type)) { // no other ATs wanted this event; // stop getting them from Java - PrintDebugString(" no other AT wanted this Java event (so can remove); removing from AccessBridge.java"); + PrintDebugString("[INFO]: no other AT wanted this Java event (so can remove); removing from AccessBridge.java"); windowsThreadEntryPoints->removeJavaEventNotification(type); } } @@ -1649,23 +1652,23 @@ void JavaAccessBridge::addAccessibilityEventNotification(jlong type, HWND DLLwindow) { // walk through list of ATs, find this one and add this type // and, if we weren't listening for these before, ask Java for 'em - PrintDebugString(" adding Accesibility event type %016I64X to HWND %p", type, DLLwindow); + PrintDebugString("[INFO]: adding Accesibility event type %016I64X to HWND %p", type, DLLwindow); AccessBridgeATInstance *ati = ATs; long globalEventMask = 0; while (ati != (AccessBridgeATInstance *) 0) { if (ati->winAccessBridgeWindow == DLLwindow) { ati->accessibilityEventMask |= type; - PrintDebugString(" found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask); + PrintDebugString("[INFO]: found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask); } else { globalEventMask |= ati->accessibilityEventMask; } ati = ati->nextATInstance; } - PrintDebugString(" union of all Accessibility AT event masks: %X", globalEventMask); + PrintDebugString("[INFO]: union of all Accessibility AT event masks: %X", globalEventMask); if (!(globalEventMask & type)) { // no other ATs wanted this event; // start getting them from Java - PrintDebugString(" no other AT wanted this Accesibility event (so not registered); adding to AccessBridge.java"); + PrintDebugString("[INFO]: no other AT wanted this Accesibility event (so not registered); adding to AccessBridge.java"); windowsThreadEntryPoints->addAccessibilityEventNotification(type); } } @@ -1678,23 +1681,23 @@ void JavaAccessBridge::removeAccessibilityEventNotification(jlong type, HWND DLLwindow) { // walk through list of ATs, find this one and remove this type // and, if no other AT wants 'em either, tell Java we no longer want 'em - PrintDebugString(" removing Accesibility event type %016I64X from HWND %p", type, DLLwindow); + PrintDebugString("[INFO]: removing Accesibility event type %016I64X from HWND %p", type, DLLwindow); AccessBridgeATInstance *ati = ATs; long globalEventMask = 0; while (ati != (AccessBridgeATInstance *) 0) { if (ati->winAccessBridgeWindow == DLLwindow) { ati->accessibilityEventMask &= (0xFFFFFFFF - type); - PrintDebugString(" found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask); + PrintDebugString("[INFO]: found HWND, accessibilityEventMask now is %X", ati->accessibilityEventMask); } else { globalEventMask |= ati->accessibilityEventMask; } ati = ati->nextATInstance; } - PrintDebugString(" union of all Accessibility AT event masks: %X", globalEventMask); + PrintDebugString("[INFO]: union of all Accessibility AT event masks: %X", globalEventMask); if (!(globalEventMask & type)) { // no other ATs wanted this event; // stop getting them from Java - PrintDebugString(" no other AT wanted this Accessibility event (so can remove); removing from AccessBridge.java"); + PrintDebugString("[INFO]: no other AT wanted this Accessibility event (so can remove); removing from AccessBridge.java"); windowsThreadEntryPoints->removeAccessibilityEventNotification(type); } } @@ -1711,13 +1714,13 @@ JavaAccessBridge::firePropertyCaretChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jint oldValue, jint newValue) { - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyCaretChanged(%p, %p, %p, %p, %d, %d)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyCaretChanged(%p, %p, %p, %p, %d, %d)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -1733,17 +1736,17 @@ JavaAccessBridge::firePropertyCaretChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyCaretChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif pkg->oldPosition = oldValue; @@ -1753,7 +1756,7 @@ JavaAccessBridge::firePropertyCaretChange(JNIEnv *env, jobject callingObj, } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyCaretChange event"); + PrintDebugString("[INFO]: done with propertyCaretChange event"); } /** @@ -1765,13 +1768,13 @@ JavaAccessBridge::firePropertyDescriptionChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jstring oldValue, jstring newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyDescriptionChanged(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyDescriptionChanged(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -1788,17 +1791,17 @@ JavaAccessBridge::firePropertyDescriptionChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyCaretChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif if (oldValue != (jstring) 0) { @@ -1839,7 +1842,7 @@ JavaAccessBridge::firePropertyDescriptionChange(JNIEnv *env, jobject callingObj, } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyDescriptionChange event"); + PrintDebugString("[INFO]: done with propertyDescriptionChange event"); } /** @@ -1851,13 +1854,13 @@ JavaAccessBridge::firePropertyNameChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jstring oldValue, jstring newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyNameChanged(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyNameChanged(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -1874,17 +1877,17 @@ JavaAccessBridge::firePropertyNameChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyNameChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif if (oldValue != (jstring) 0) { @@ -1925,7 +1928,7 @@ JavaAccessBridge::firePropertyNameChange(JNIEnv *env, jobject callingObj, } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyNameChange event"); + PrintDebugString("[INFO]: done with propertyNameChange event"); } @@ -1937,12 +1940,12 @@ void JavaAccessBridge::firePropertySelectionChange(JNIEnv *env, jobject callingObj, jobject event, jobject source) { - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertySelectionChanged(%p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertySelectionChanged(%p, %p, %p, %p)", env, callingObj, event, source); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -1958,24 +1961,24 @@ JavaAccessBridge::firePropertySelectionChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertySelectionChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertySelectionChangeEvent); } ati = ati->nextATInstance; } - PrintDebugString(" done with propertySelectionChange event"); + PrintDebugString("[INFO]: done with propertySelectionChange event"); } @@ -1988,13 +1991,13 @@ JavaAccessBridge::firePropertyStateChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jstring oldValue, jstring newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyStateChanged(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyStateChanged(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2011,17 +2014,17 @@ JavaAccessBridge::firePropertyStateChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyStateChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif if (oldValue != (jstring) 0) { @@ -2062,7 +2065,7 @@ JavaAccessBridge::firePropertyStateChange(JNIEnv *env, jobject callingObj, } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyStateChange event"); + PrintDebugString("[INFO]: done with propertyStateChange event"); } @@ -2074,12 +2077,12 @@ void JavaAccessBridge::firePropertyTextChange(JNIEnv *env, jobject callingObj, jobject event, jobject source) { - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyTextChanged(%p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyTextChanged(%p, %p, %p, %p)", env, callingObj, event, source); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2095,24 +2098,24 @@ JavaAccessBridge::firePropertyTextChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyTextChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p",pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyTextChangeEvent); } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyTextChange event"); + PrintDebugString("[INFO]: done with propertyTextChange event"); } @@ -2125,13 +2128,13 @@ JavaAccessBridge::firePropertyValueChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jstring oldValue, jstring newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyValueChanged(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyValueChanged(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2148,17 +2151,17 @@ JavaAccessBridge::firePropertyValueChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyValueChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif if (oldValue != (jstring) 0) { @@ -2199,7 +2202,7 @@ JavaAccessBridge::firePropertyValueChange(JNIEnv *env, jobject callingObj, } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyValueChange event"); + PrintDebugString("[INFO]: done with propertyValueChange event"); } /** @@ -2210,12 +2213,12 @@ void JavaAccessBridge::firePropertyVisibleDataChange(JNIEnv *env, jobject callingObj, jobject event, jobject source) { - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyVisibleDataChanged(%p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyVisibleDataChanged(%p, %p, %p, %p)", env, callingObj, event, source); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2231,24 +2234,24 @@ JavaAccessBridge::firePropertyVisibleDataChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyVisibleDataChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyVisibleDataChangeEvent); } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyVisibleDataChange event"); + PrintDebugString("[INFO]: done with propertyVisibleDataChange event"); } @@ -2261,13 +2264,13 @@ JavaAccessBridge::firePropertyChildChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jobject oldValue, jobject newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyChildPropertyChanged(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyChildPropertyChanged(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2283,7 +2286,7 @@ JavaAccessBridge::firePropertyChildChange(JNIEnv *env, jobject callingObj, while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyChildChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); @@ -2291,22 +2294,24 @@ JavaAccessBridge::firePropertyChildChange(JNIEnv *env, jobject callingObj, pkg->oldChildAccessibleContext = (JOBJECT64)env->NewGlobalRef(oldValue); pkg->newChildAccessibleContext = (JOBJECT64)env->NewGlobalRef(newValue); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); - PrintDebugString(" GlobalRef'd OldChildAC: %p", pkg->oldChildAccessibleContext); - PrintDebugString(" GlobalRef'd NewChildAC: %p", pkg->newChildAccessibleContext); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p"\ + " GlobalRef'd OldChildAC: %p"\ + " GlobalRef'd NewChildAC: %p"\ + , pkg->Event, pkg->AccessibleContextSource, pkg->oldChildAccessibleContext, pkg->newChildAccessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); - PrintDebugString(" GlobalRef'd OldChildAC: %016I64X", pkg->oldChildAccessibleContext); - PrintDebugString(" GlobalRef'd NewChildAC: %016I64X", pkg->newChildAccessibleContext); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X"\ + " GlobalRef'd OldChildAC: %016I64X"\ + " GlobalRef'd NewChildAC: %016I64X"\ + , pkg->Event, pkg->AccessibleContextSource, pkg->oldChildAccessibleContext, pkg->newChildAccessibleContext); #endif ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyChildChangeEvent); } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyChildChange event"); + PrintDebugString("[INFO]: done with propertyChildChange event"); } @@ -2319,13 +2324,13 @@ JavaAccessBridge::firePropertyActiveDescendentChange(JNIEnv *env, jobject callin jobject event, jobject source, jobject oldValue, jobject newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyActiveDescendentPropertyChanged(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyActiveDescendentPropertyChanged(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2341,7 +2346,7 @@ JavaAccessBridge::firePropertyActiveDescendentChange(JNIEnv *env, jobject callin while (ati != (AccessBridgeATInstance *) 0) { if (ati->accessibilityEventMask & cPropertyActiveDescendentChangeEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); // make new GlobalRefs for this AT pkg->Event = (JOBJECT64)env->NewGlobalRef(event); @@ -2349,22 +2354,24 @@ JavaAccessBridge::firePropertyActiveDescendentChange(JNIEnv *env, jobject callin pkg->oldActiveDescendentAccessibleContext = (JOBJECT64)env->NewGlobalRef(oldValue); pkg->newActiveDescendentAccessibleContext = (JOBJECT64)env->NewGlobalRef(newValue); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); - PrintDebugString(" GlobalRef'd OldActiveDescendentAC: %p", pkg->oldActiveDescendentAccessibleContext); - PrintDebugString(" GlobalRef'd NewActiveDescendentAC: %p", pkg->newActiveDescendentAccessibleContext); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p"\ + " GlobalRef'd OldActiveDescendentAC: %p"\ + " GlobalRef'd NewActiveDescendentAC: %p"\ + , pkg->Event, pkg->AccessibleContextSource, pkg->oldActiveDescendentAccessibleContext, pkg->newActiveDescendentAccessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); - PrintDebugString(" GlobalRef'd OldActiveDescendentAC: %016I64X", pkg->oldActiveDescendentAccessibleContext); - PrintDebugString(" GlobalRef'd NewActiveDescendentAC: %016I64X", pkg->newActiveDescendentAccessibleContext); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X"\ + " GlobalRef'd OldActiveDescendentAC: %016I64X"\ + " GlobalRef'd NewActiveDescendentAC: %016I64X"\ + , pkg->Event, pkg->AccessibleContextSource, pkg->oldActiveDescendentAccessibleContext, pkg->newActiveDescendentAccessibleContext); #endif ati->sendAccessibilityEventPackage(buffer, sizeof(buffer), cPropertyActiveDescendentChangeEvent); } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyActiveChange event"); + PrintDebugString("[INFO]: done with propertyActiveChange event"); } /** @@ -2376,13 +2383,13 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj, jobject event, jobject source, jstring oldValue, jstring newValue){ - PrintDebugString("\r\nJava_com_sun_java_accessibility_internal_AccessBridge_propertyTableModelChange(%p, %p, %p, %p, %p, %p)", + PrintDebugString("[INFO]: Java_com_sun_java_accessibility_internal_AccessBridge_propertyTableModelChange(%p, %p, %p, %p, %p, %p)", env, callingObj, event, source, oldValue, newValue); // sanity check if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; // panic! } @@ -2405,11 +2412,11 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj, pkg->Event = (JOBJECT64)env->NewGlobalRef(event); pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif if (oldValue != (jstring) 0) { @@ -2450,31 +2457,31 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj, } ati = ati->nextATInstance; } - PrintDebugString(" done with propertyTableModelChange event"); + PrintDebugString("[INFO]: done with propertyTableModelChange event"); } #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) #define PRINT_GLOBALREFS() \ - PrintDebugString(" GlobalRef'd Event: %p", pkg->Event); \ - PrintDebugString(" GlobalRef'd Source: %p", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %p"\ + " GlobalRef'd Source: %p", pkg->Event, pkg->AccessibleContextSource); #else // JOBJECT64 is jlong (64 bit) #define PRINT_GLOBALREFS() \ - PrintDebugString(" GlobalRef'd Event: %016I64X", pkg->Event); \ - PrintDebugString(" GlobalRef'd Source: %016I64X", pkg->AccessibleContextSource); + PrintDebugString("[INFO]: GlobalRef'd Event: %016I64X"\ + " GlobalRef'd Source: %016I64X", pkg->Event, pkg->AccessibleContextSource); #endif #define FIRE_EVENT(function, packageStruct, packageConstant, eventConstant) \ void JavaAccessBridge::function(JNIEnv *env, jobject callingObj, \ jobject eventObj, jobject source) { \ \ - PrintDebugString("\r\nFiring event id = %d(%p, %p, %p, %p); vmID = %X", \ - eventConstant, env, callingObj, eventObj, source, dialogWindow); \ + PrintDebugString("[INFO]: Firing event id = %d(%p, %p, %p, %p); vmID = %X", \ + eventConstant, env, callingObj, eventObj, source, dialogWindow);\ \ /* sanity check */ \ if (ATs == (AccessBridgeATInstance *) 0) { \ - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); \ + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); \ return; /* panic! */ \ } \ \ @@ -2488,11 +2495,11 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj, /* make new Global Refs, send events only to those ATs that want 'em */ \ AccessBridgeATInstance *ati = ATs; \ while (ati != (AccessBridgeATInstance *) 0) { \ - PrintDebugString("\r\njavaEventMask = %X eventConstant=%d pkg->vmID=%X", \ + PrintDebugString("[INFO]: javaEventMask = %X eventConstant=%d pkg->vmID=%X",\ ati->javaEventMask, eventConstant, pkg->vmID ); \ if (ati->javaEventMask & eventConstant) { \ \ - PrintDebugString(" sending to AT"); \ + PrintDebugString("[INFO]: sending to AT"); \ /* make new GlobalRefs for this AT */ \ pkg->Event = (JOBJECT64)env->NewGlobalRef(eventObj); \ pkg->AccessibleContextSource = (JOBJECT64)env->NewGlobalRef(source); \ @@ -2502,17 +2509,17 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj, } \ ati = ati->nextATInstance; \ } \ - PrintDebugString(" done with firing AWT event"); \ + PrintDebugString("[INFO]: done with firing AWT event"); \ } void JavaAccessBridge::javaShutdown(JNIEnv *env, jobject callingObj) { - PrintDebugString("\r\nFiring event id = %d(%p, %p); vmID = %X", + PrintDebugString("[INFO]: Firing event id = %d(%p, %p); vmID = %X", cJavaShutdownEvent, env, callingObj, dialogWindow); /* sanity check */ if (ATs == (AccessBridgeATInstance *) 0) { - PrintDebugString(" ERROR!! ATs == 0! (shouldn't happen here!)"); + PrintDebugString("[ERROR]: ATs == 0! (shouldn't happen here!)"); return; /* panic! */ } @@ -2527,12 +2534,12 @@ JavaAccessBridge::firePropertyTableModelChange(JNIEnv *env, jobject callingObj, AccessBridgeATInstance *ati = ATs; while (ati != (AccessBridgeATInstance *) 0) { if (ati->javaEventMask & cJavaShutdownEvent) { - PrintDebugString(" sending to AT"); + PrintDebugString("[INFO]: sending to AT"); ati->sendJavaEventPackage(buffer, sizeof(buffer), cJavaShutdownEvent); } ati = ati->nextATInstance; } - PrintDebugString(" done with firing AWT event"); + PrintDebugString("[INFO]: done with firing AWT event"); } FIRE_EVENT(fireFocusGained, FocusGainedPackage, cFocusGainedPackage, cFocusGainedEvent) diff --git a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeEventHandler.cpp b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeEventHandler.cpp index a445d6b21e3..d5600ef5cc1 100644 --- a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeEventHandler.cpp +++ b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeEventHandler.cpp @@ -170,7 +170,7 @@ AccessBridgeEventHandler::firePropertyChange(long vmID, if (propertyChangeFP != (AccessBridge_PropertyChangeFP) 0) { propertyChangeFP(vmID, event, source, property, oldName, newName); } else { - DEBUG_CODE(AppendToCallInfo(" Error! propertyChangeFP == 0\r\n")); + DEBUG_CODE(AppendToCallInfo("[ERROR]: propertyChangeFP == 0")); } } @@ -186,9 +186,9 @@ AccessBridgeEventHandler::firePropertyChange(long vmID, * */ #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) -const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%p, %p); vmID = %X\r\n"; +const char fireEventDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s(%p, %p); vmID = %X\r\n"; #else // JOBJECT64 is jlong (64 bit) -const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%016I64X, %016I64X); vmID = %X\r\n"; +const char fireEventDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s(%016I64X, %016I64X); vmID = %X\r\n"; #endif #define FIRE_EVENT(method, FPprototype, eventFP) \ @@ -199,18 +199,18 @@ const char fireEventDebugString[] = "\r\nIn AccessBridgeEventHandler::%s(%016I64 if (eventFP != (FPprototype) 0) { \ eventFP(vmID, event, source); \ } else { \ - DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ + DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0")); \ } \ } void AccessBridgeEventHandler::fireJavaShutdown(long vmID) { DEBUG_CODE(char debugBuf[255]); - DEBUG_CODE(sprintf(debugBuf, "\r\nCalling fireJavaShutdown; vmID = %X\r\n", vmID)); + DEBUG_CODE(sprintf(debugBuf, "[INFO]: Calling fireJavaShutdown; vmID = %X\r\n", vmID)); DEBUG_CODE(AppendToCallInfo(debugBuf)); if (javaShutdownFP != (AccessBridge_JavaShutdownFP) 0) { javaShutdownFP(vmID); } else { - DEBUG_CODE(AppendToCallInfo(" Error! javaShutdownFP == 0\r\n")); + DEBUG_CODE(AppendToCallInfo("[ERROR]: javaShutdownFP == 0")); } } @@ -241,9 +241,9 @@ FIRE_EVENT(firePopupMenuWillBecomeVisible, AccessBridge_PopupMenuWillBecomeVisib * */ #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) -const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a no-param property change (%p, %p):\r\n"; +const char firePropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a no-param property change (%p, %p):\r\n"; #else // JOBJECT64 is jlong (64 bit) -const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a no-param property change (%016I64X, %016I64X):\r\n"; +const char firePropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a no-param property change (%016I64X, %016I64X):\r\n"; #endif #define FIRE_PROPERTY_CHANGE(method, FPprototype, eventFP) \ @@ -254,7 +254,7 @@ const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::% if (eventFP != (FPprototype) 0) { \ eventFP(vmID, event, source); \ } else { \ - DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ + DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0")); \ } \ } @@ -269,9 +269,9 @@ const char firePropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::% * */ #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) -const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a string property change (%p, %p, %ls, %ls):\r\n"; +const char fireStringPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a string property change (%p, %p, %ls, %ls):\r\n"; #else // JOBJECT64 is jlong (64 bit) -const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing a string property change (%016I64X, %016I64X, %ls, %ls):\r\n"; +const char fireStringPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing a string property change (%016I64X, %016I64X, %ls, %ls):\r\n"; #endif #define FIRE_STRING_PROPERTY_CHANGE(method, FPprototype, eventFP, oldValue, newValue) \ @@ -283,7 +283,7 @@ const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHand if (eventFP != (FPprototype) 0) { \ eventFP(vmID, event, source, oldValue, newValue); \ } else { \ - DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ + DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0\r\n")); \ } \ } @@ -298,9 +298,9 @@ const char fireStringPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHand * */ #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) -const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an int property change (%p, %p, %d, %d):\r\n"; +const char fireIntPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an int property change (%p, %p, %d, %d):\r\n"; #else // JOBJECT64 is jlong (64 bit) -const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an int property change (%016I64X, %016I64X, %d, %d):\r\n"; +const char fireIntPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an int property change (%016I64X, %016I64X, %d, %d):\r\n"; #endif #define FIRE_INT_PROPERTY_CHANGE(method, FPprototype, eventFP) \ @@ -312,7 +312,7 @@ const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler if (eventFP != (FPprototype) 0) { \ eventFP(vmID, event, source, oldValue, newValue); \ } else { \ - DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ + DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0\r\n")); \ } \ } @@ -327,9 +327,9 @@ const char fireIntPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler * */ #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) -const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an AC property change (%p, %p, %p, %p):\r\n"; +const char fireACPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an AC property change (%p, %p, %p, %p):\r\n"; #else // JOBJECT64 is jlong (64 bit) -const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler::%s, Firing an AC property change (%016I64X, %016I64X, %016I64X, %016I64X):\r\n"; +const char fireACPropertyChangeDebugString[] = "[INFO]: In AccessBridgeEventHandler::%s, Firing an AC property change (%016I64X, %016I64X, %016I64X, %016I64X):\r\n"; #endif #define FIRE_AC_PROPERTY_CHANGE(method, FPprototype, eventFP) \ @@ -341,7 +341,7 @@ const char fireACPropertyChangeDebugString[] = "\r\nIn AccessBridgeEventHandler: if (eventFP != (FPprototype) 0) { \ eventFP(vmID, event, source, oldValue, newValue); \ } else { \ - DEBUG_CODE(AppendToCallInfo(" Error! eventFP == 0\r\n")); \ + DEBUG_CODE(AppendToCallInfo("[ERROR]: eventFP == 0\r\n")); \ } \ } diff --git a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeJavaVMInstance.cpp b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeJavaVMInstance.cpp index 129cf144fb4..3d189600b42 100644 --- a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeJavaVMInstance.cpp +++ b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeJavaVMInstance.cpp @@ -198,8 +198,8 @@ AccessBridgeJavaVMInstance::sendPackage(char *buffer, long bufsize) { toCopy.cbData = bufsize; toCopy.lpData = buffer; - PrintDebugString("In AccessBridgeVMInstance::sendPackage"); - PrintDebugString(" javaAccessBridgeWindow: %p", javaAccessBridgeWindow); + PrintDebugString("[INFO]: In AccessBridgeVMInstance::sendPackage"); + PrintDebugString("[INFO]: javaAccessBridgeWindow: %p", javaAccessBridgeWindow); /* This was SendMessage. Normally that is a blocking call. However, if * SendMessage is sent to another process, e.g. another JVM and an incoming * SendMessage is pending, control will be passed to the DialogProc to handle @@ -280,7 +280,7 @@ AccessBridgeJavaVMInstance::sendMemoryPackage(char *buffer, long bufsize) { char *done = &memoryMappedView[bufsize]; *done = 0; - PrintDebugString(" javaAccessBridgeWindow: %p", javaAccessBridgeWindow); + PrintDebugString("[INFO]: javaAccessBridgeWindow: %p", javaAccessBridgeWindow); // See the comment above the call to SendMessageTimeout in SendPackage method above. UINT flags = SMTO_BLOCK | SMTO_NOTIMEOUTIFNOTHUNG; DWORD_PTR out; // not used @@ -309,7 +309,7 @@ AccessBridgeJavaVMInstance::sendMemoryPackage(char *buffer, long bufsize) { */ HWND AccessBridgeJavaVMInstance::findAccessBridgeWindow(long javaVMID) { - PrintDebugString("In findAccessBridgeWindow"); + PrintDebugString("[INFO]: In findAccessBridgeWindow"); // no need to recurse really if (vmID == javaVMID) { return javaAccessBridgeWindow; @@ -338,7 +338,7 @@ AccessBridgeJavaVMInstance::findAccessBridgeWindow(long javaVMID) { */ AccessBridgeJavaVMInstance * AccessBridgeJavaVMInstance::findABJavaVMInstanceFromJavaHWND(HWND window) { - PrintDebugString("In findABJavaInstanceFromJavaHWND"); + PrintDebugString("[INFO]: In findABJavaInstanceFromJavaHWND"); // no need to recurse really if (javaAccessBridgeWindow == window) { return this; diff --git a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeMessageQueue.cpp b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeMessageQueue.cpp index 5eb0e282c52..9d6887bed56 100644 --- a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeMessageQueue.cpp +++ b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/AccessBridgeMessageQueue.cpp @@ -88,17 +88,17 @@ AccessBridgeMessageQueue::getEventsWaiting() { */ QueueReturns AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) { - PrintDebugString(" in AccessBridgeMessageQueue::add()"); - PrintDebugString(" queue size = %d", size); + PrintDebugString("[INFO]: in AccessBridgeMessageQueue::add()"); + PrintDebugString("[INFO]: queue size = %d", size); QueueReturns returnVal = cElementPushedOK; if (queueLocked) { - PrintDebugString(" queue was locked; returning cQueueInUse!"); + PrintDebugString("[WARN]: queue was locked; returning cQueueInUse!"); return cQueueInUse; } queueLocked = TRUE; { - PrintDebugString(" adding element to queue!"); + PrintDebugString("[INFO]: adding element to queue!"); if (end == (AccessBridgeQueueElement *) 0) { if (start == (AccessBridgeQueueElement *) 0 && size == 0) { start = element; @@ -118,7 +118,7 @@ AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) { } } queueLocked = FALSE; - PrintDebugString(" returning from AccessBridgeMessageQueue::add()"); + PrintDebugString("[INFO]: returning from AccessBridgeMessageQueue::add()"); return returnVal; } @@ -129,17 +129,17 @@ AccessBridgeMessageQueue::add(AccessBridgeQueueElement *element) { */ QueueReturns AccessBridgeMessageQueue::remove(AccessBridgeQueueElement **element) { - PrintDebugString(" in AccessBridgeMessageQueue::remove()"); - PrintDebugString(" queue size = %d", size); + PrintDebugString("[INFO]: in AccessBridgeMessageQueue::remove()"); + PrintDebugString("[INFO]: queue size = %d", size); QueueReturns returnVal = cMoreMessages; if (queueLocked) { - PrintDebugString(" queue was locked; returning cQueueInUse!"); + PrintDebugString("[WARN]: queue was locked; returning cQueueInUse!"); return cQueueInUse; } queueLocked = TRUE; { - PrintDebugString(" removing element from queue!"); + PrintDebugString("[INFO]: removing element from queue!"); if (size > 0) { if (start != (AccessBridgeQueueElement *) 0) { *element = start; @@ -161,7 +161,7 @@ AccessBridgeMessageQueue::remove(AccessBridgeQueueElement **element) { } } queueLocked = FALSE; - PrintDebugString(" returning from AccessBridgeMessageQueue::remove()"); + PrintDebugString("[INFO]: returning from AccessBridgeMessageQueue::remove()"); return returnVal; } diff --git a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp index 34f61bc967c..d5c0b887ffe 100644 --- a/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp +++ b/src/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -76,7 +76,7 @@ BOOL CALLBACK newJVMFoundDialogProc(HWND hwndDlg, UINT message, WPARAM wParam, L // Remind user later that a new JVM was installed case cRemindThereIsNewJVM: - PrintDebugString(" newJVMDialogProc: cRemindThereIsNewJVM"); + PrintDebugString("[INFO]: newJVMDialogProc: cRemindThereIsNewJVM"); // do nothing EndDialog(hwndDlg, wParam); return TRUE; @@ -130,13 +130,14 @@ extern "C" { switch (fdwReason) { case DLL_PROCESS_ATTACH: // A Windows executable loaded us - PrintDebugString("DLL_PROCESS_ATTACH"); + initializeFileLogger("windows_access_bridge"); + PrintDebugString("[INFO]: DLL_PROCESS_ATTACH"); theWindowsAccessBridge = new WinAccessBridge(hinstDll); break; case DLL_PROCESS_DETACH: // A Windows executable unloaded us if (theWindowsAccessBridge != (WinAccessBridge *) 0) { - PrintDebugString("*** AccessBridgeDialogProc -> deleting theWindowsAccessBridge"); + PrintDebugString("[INFO]: *** AccessBridgeDialogProc -> deleting theWindowsAccessBridge"); delete theWindowsAccessBridge; } break; @@ -173,15 +174,15 @@ extern "C" { switch (message) { case WM_INITDIALOG: - PrintDebugString("AccessBridgeDialogProc -> Initializing"); + PrintDebugString("[INFO]: AccessBridgeDialogProc -> Initializing"); break; // call from Java with data for us to deliver case WM_COPYDATA: if (theDialogWindow == (HWND) wParam) { - PrintDebugString("AccessBridgeDialogProc -> Got WM_COPYDATA from Java Bridge DLL"); + PrintDebugString("[INFO]: AccessBridgeDialogProc -> Got WM_COPYDATA from Java Bridge DLL"); } else { - PrintDebugString("AccessBridgeDialogProc -> Got WM_COPYDATA from HWND %p", wParam); + PrintDebugString("[INFO]: AccessBridgeDialogProc -> Got WM_COPYDATA from HWND %p", wParam); sentToUs = (COPYDATASTRUCT *) lParam; package = (char *) sentToUs->lpData; theWindowsAccessBridge->preProcessPackage(package, sentToUs->cbData); @@ -190,7 +191,7 @@ extern "C" { // message to ourselves -> de-queue messages and send 'em case AB_MESSAGE_QUEUED: - PrintDebugString("AccessBridgeDialogProc -> Got AB_MESSAGE_QUEUED from ourselves"); + PrintDebugString("[INFO]: AccessBridgeDialogProc -> Got AB_MESSAGE_QUEUED from ourselves"); theWindowsAccessBridge->receiveAQueuedPackage(); break; @@ -214,12 +215,12 @@ extern "C" { // to the message queue. That would delay the destruction of the instance // until the chain is not being traversed. case AB_DLL_GOING_AWAY: - PrintDebugString("***** AccessBridgeDialogProc -> Got AB_DLL_GOING_AWAY message"); + PrintDebugString("[INFO]: ***** AccessBridgeDialogProc -> Got AB_DLL_GOING_AWAY message"); if (isVMInstanceChainInUse) { - PrintDebugString(" javaVMs chain in use, calling PostMessage"); + PrintDebugString("[INFO]: javaVMs chain in use, calling PostMessage"); PostMessage(hDlg, AB_DLL_GOING_AWAY, wParam, (LPARAM)0); } else { - PrintDebugString(" calling javaVMDestroyed"); + PrintDebugString("[INFO]: calling javaVMDestroyed"); theWindowsAccessBridge->JavaVMDestroyed((HWND) wParam); } break; @@ -228,7 +229,7 @@ extern "C" { // the JavaVM is saying "hi"! // wParam == sourceHwnd; lParam == JavaVMID if (message == theFromJavaHelloMsgID) { - PrintDebugString("AccessBridgeDialogProc -> Got theFromJavaHelloMsgID; wParam = %p, lParam = %p", wParam, lParam); + PrintDebugString("[INFO]: AccessBridgeDialogProc -> Got theFromJavaHelloMsgID; wParam = %p, lParam = %p", wParam, lParam); theWindowsAccessBridge->rendezvousWithNewJavaDLL((HWND) wParam, (long ) lParam); } break; @@ -250,7 +251,7 @@ extern "C" { */ WinAccessBridge::WinAccessBridge(HINSTANCE hInstance) { - PrintDebugString("WinAccessBridge ctor"); + PrintDebugString("[INFO]: WinAccessBridge ctor"); // IntializeCriticalSection should only be called once. InitializeCriticalSection(&sendMemoryIPCLock); @@ -276,25 +277,25 @@ WinAccessBridge::~WinAccessBridge() { // -> shut down all event listening // -> release all objects held in the JVM by us - PrintDebugString("*****in WinAccessBridge::~WinAccessBridge()"); + PrintDebugString("[INFO]: *****in WinAccessBridge::~WinAccessBridge()"); // send a broadcast msg.; let other AccessBridge DLLs know we're going away AccessBridgeJavaVMInstance *current = javaVMs; while (current != (AccessBridgeJavaVMInstance *) 0) { - PrintDebugString(" telling %p we're going away", current->javaAccessBridgeWindow); + PrintDebugString("[INFO]: telling %p we're going away", current->javaAccessBridgeWindow); SendMessage(current->javaAccessBridgeWindow, AB_DLL_GOING_AWAY, (WPARAM) dialogWindow, (LPARAM) 0); current = current->nextJVMInstance; } - PrintDebugString(" finished telling JVMs about our demise"); + PrintDebugString("[INFO]: finished telling JVMs about our demise"); delete eventHandler; delete messageQueue; delete javaVMs; - PrintDebugString(" finished deleting eventHandler, messageQueue, and javaVMs"); - PrintDebugString("GOODBYE CRUEL WORLD..."); + PrintDebugString("[INFO]: finished deleting eventHandler, messageQueue, and javaVMs"); + PrintDebugString("[INFO]: GOODBYE CRUEL WORLD..."); DestroyWindow(theDialogWindow); } @@ -338,7 +339,7 @@ LRESULT WinAccessBridge::rendezvousWithNewJavaDLL(HWND JavaBridgeDLLwindow, long vmID) { LRESULT returnVal; - PrintDebugString("in WinAccessBridge::rendezvousWithNewJavaDLL(%p, %X)", + PrintDebugString("[INFO]: in WinAccessBridge::rendezvousWithNewJavaDLL(%p, %X)", JavaBridgeDLLwindow, vmID); isVMInstanceChainInUse = true; @@ -354,23 +355,23 @@ WinAccessBridge::rendezvousWithNewJavaDLL(HWND JavaBridgeDLLwindow, long vmID) { long javaEventMask = eventHandler->getJavaEventMask(); long accessibilityEventMask = eventHandler->getAccessibilityEventMask(); - PrintDebugString(" Setting Java event mask to: %X", javaEventMask); + PrintDebugString("[INFO]: Setting Java event mask to: %X", javaEventMask); if (javaEventMask != 0) { addJavaEventNotification(javaEventMask); } - PrintDebugString(" Setting Accessibility event mask to: %X", accessibilityEventMask); + PrintDebugString("[INFO]: Setting Accessibility event mask to: %X", accessibilityEventMask); if (accessibilityEventMask != 0) { addAccessibilityEventNotification(accessibilityEventMask); } } else { - PrintDebugString(" ERROR: Failed to initiate IPC with newly created JavaVM!!!"); + PrintDebugString("[ERROR]: Failed to initiate IPC with newly created JavaVM!!!"); return FALSE; } - PrintDebugString(" Success!! We rendezvoused with the JavaDLL"); + PrintDebugString("[INFO]: Success!! We rendezvoused with the JavaDLL"); return returnVal; } @@ -421,7 +422,7 @@ WinAccessBridge::sendMemoryPackage(char *buffer, long bufsize, HWND destWindow) return FALSE; } } else { - PrintDebugString("ERROR sending memory package: couldn't find destWindow"); + PrintDebugString("[ERROR]: sending memory package: couldn't find destWindow"); return FALSE; } return TRUE; @@ -434,7 +435,7 @@ WinAccessBridge::sendMemoryPackage(char *buffer, long bufsize, HWND destWindow) */ BOOL WinAccessBridge::queuePackage(char *buffer, long bufsize) { - PrintDebugString(" in WinAccessBridge::queuePackage(%p, %d)", buffer, bufsize); + PrintDebugString("[INFO]: in WinAccessBridge::queuePackage(%p, %d)", buffer, bufsize); AccessBridgeQueueElement *element = new AccessBridgeQueueElement(buffer, bufsize); @@ -454,37 +455,37 @@ BOOL WinAccessBridge::receiveAQueuedPackage() { AccessBridgeQueueElement *element = NULL; - PrintDebugString("in WinAccessBridge::receiveAQueuedPackage()"); + PrintDebugString("[INFO]: in WinAccessBridge::receiveAQueuedPackage()"); // ensure against re-entrancy problems... if (messageQueue->getRemoveLockSetting() == FALSE) { messageQueue->setRemoveLock(TRUE); - PrintDebugString(" dequeueing message"); + PrintDebugString("[INFO]: dequeueing message"); QueueReturns result = messageQueue->remove(&element); switch (result) { case cQueueBroken: - PrintDebugString(" ERROR!!! Queue seems to be broken!"); + PrintDebugString("[ERROR]: Queue seems to be broken!"); messageQueue->setRemoveLock(FALSE); return FALSE; case cMoreMessages: case cQueueEmpty: if (element != (AccessBridgeQueueElement *) 0) { - PrintDebugString(" found one; sending it!"); + PrintDebugString("[INFO]: found one; sending it!"); processPackage(element->buffer, element->bufsize); delete element; } else { - PrintDebugString(" ODD... element == 0!"); + PrintDebugString("[WARN]: ODD... element == 0!"); return FALSE; } break; case cQueueInUse: - PrintDebugString(" Queue in use, will try again later..."); + PrintDebugString("[WARN]: Queue in use, will try again later..."); PostMessage(dialogWindow, AB_MESSAGE_QUEUED, (WPARAM) 0, (LPARAM) 0); break; @@ -493,7 +494,7 @@ WinAccessBridge::receiveAQueuedPackage() { return FALSE; // should never get something we don't recognize! } } else { - PrintDebugString(" unable to dequeue message; remove lock is set"); + PrintDebugString("[WARN]: unable to dequeue message; remove lock is set"); PostMessage(dialogWindow, AB_MESSAGE_QUEUED, (WPARAM) 0, (LPARAM) 0); // Fix for 6995891 } @@ -510,13 +511,13 @@ WinAccessBridge::receiveAQueuedPackage() { */ void WinAccessBridge::preProcessPackage(char *buffer, long bufsize) { - PrintDebugString("PreProcessing package sent from Java:"); + PrintDebugString("[INFO]: PreProcessing package sent from Java:"); PackageType *type = (PackageType *) buffer; switch (*type) { - PrintDebugString(" type == %X", *type); + PrintDebugString("[INFO]: type == %X", *type); // event packages all get queued for later handling //case cPropertyChangePackage: @@ -555,11 +556,11 @@ WinAccessBridge::preProcessPackage(char *buffer, long bufsize) { // perhaps there will be some other packages to process at some point... // default: - PrintDebugString(" processing FAILED!! -> don't know how to handle type = %X", *type); + PrintDebugString("[ERROR]: processing FAILED!! -> don't know how to handle type = %X", *type); break; } - PrintDebugString(" package preprocessing completed"); + PrintDebugString("[INFO]: package preprocessing completed"); } @@ -568,12 +569,12 @@ WinAccessBridge::preProcessPackage(char *buffer, long bufsize) { if (bufsize == sizeof(PackageType) + sizeof(eventPackage)) { \ eventPackage *pkg = \ (eventPackage *) (buffer + sizeof(PackageType)); \ - PrintDebugString(" begin callback to AT, type == %X", *type); \ + PrintDebugString("[INFO]: begin callback to AT, type == %X", *type); \ theWindowsAccessBridge->eventHandler->fireEventMethod( \ pkg->vmID, pkg->Event, pkg->AccessibleContextSource); \ - PrintDebugString(" event callback complete!"); \ + PrintDebugString("[INFO]: event callback complete!"); \ } else { \ - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", \ + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", \ bufsize, sizeof(PackageType) + sizeof(eventPackage)); \ } \ break; @@ -583,13 +584,13 @@ WinAccessBridge::preProcessPackage(char *buffer, long bufsize) { if (bufsize == sizeof(PackageType) + sizeof(eventPackage)) { \ eventPackage *pkg = \ (eventPackage *) (buffer + sizeof(PackageType)); \ - PrintDebugString(" begin callback to AT, type == %X", *type); \ + PrintDebugString("[INFO]: begin callback to AT, type == %X", *type); \ theWindowsAccessBridge->eventHandler->fireEventMethod( \ pkg->vmID, pkg->Event, pkg->AccessibleContextSource, \ pkg->oldValue, pkg->newValue); \ - PrintDebugString(" event callback complete!"); \ + PrintDebugString("[INFO]: event callback complete!"); \ } else { \ - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", \ + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", \ bufsize, sizeof(PackageType) + sizeof(eventPackage)); \ } \ break; @@ -599,13 +600,13 @@ WinAccessBridge::preProcessPackage(char *buffer, long bufsize) { if (bufsize == sizeof(PackageType) + sizeof(eventPackage)) { \ eventPackage *pkg = \ (eventPackage *) (buffer + sizeof(PackageType)); \ - PrintDebugString(" begin callback to AT, type == %X", *type); \ + PrintDebugString("[INFO]: begin callback to AT, type == %X", *type); \ theWindowsAccessBridge->eventHandler->fireEventMethod( \ pkg->vmID, pkg->Event, pkg->AccessibleContextSource, \ pkg->oldValue, pkg->newValue); \ - PrintDebugString(" event callback complete!"); \ + PrintDebugString("[INFO]: event callback complete!"); \ } else { \ - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", \ + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", \ bufsize, sizeof(PackageType) + sizeof(eventPackage)); \ } \ break; @@ -617,24 +618,24 @@ WinAccessBridge::preProcessPackage(char *buffer, long bufsize) { */ void WinAccessBridge::processPackage(char *buffer, long bufsize) { - PrintDebugString("WinAccessBridge::Processing package sent from Java:"); + PrintDebugString("[INFO]: WinAccessBridge::Processing package sent from Java:"); PackageType *type = (PackageType *) buffer; switch (*type) { - PrintDebugString(" type == %X", *type); + PrintDebugString("[INFO]: type == %X", *type); case cJavaShutdownPackage: - PrintDebugString(" type == cJavaShutdownPackage"); + PrintDebugString("[INFO]: type == cJavaShutdownPackage"); if (bufsize == sizeof(PackageType) + sizeof(JavaShutdownPackage)) { JavaShutdownPackage *pkg = (JavaShutdownPackage *) (buffer + sizeof(PackageType)); theWindowsAccessBridge->eventHandler->fireJavaShutdown(pkg->vmID); - PrintDebugString(" event callback complete!"); - PrintDebugString(" event fired!"); + PrintDebugString("[INFO]: event callback complete!"); + PrintDebugString("[INFO]: event fired!"); } else { - PrintDebugString(" processing FAILED!! -> bufsize = %d; expectation = %d", + PrintDebugString("[ERROR]: processing FAILED!! -> bufsize = %d; expectation = %d", bufsize, sizeof(PackageType) + sizeof(JavaShutdownPackage)); } break; @@ -698,11 +699,11 @@ WinAccessBridge::processPackage(char *buffer, long bufsize) { default: - PrintDebugString(" processing FAILED!! -> don't know how to handle type = %X", *type); + PrintDebugString("[ERROR]: processing FAILED!! -> don't know how to handle type = %X", *type); break; } - PrintDebugString(" package processing completed"); + PrintDebugString("[INFO]: package processing completed"); } @@ -710,7 +711,7 @@ WinAccessBridge::processPackage(char *buffer, long bufsize) { void WinAccessBridge::JavaVMDestroyed(HWND VMBridgeDLLWindow) { - PrintDebugString("***** WinAccessBridge::JavaVMDestroyed(%p)", VMBridgeDLLWindow); + PrintDebugString("[INFO]: ***** WinAccessBridge::JavaVMDestroyed(%p)", VMBridgeDLLWindow); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return; @@ -723,7 +724,7 @@ WinAccessBridge::JavaVMDestroyed(HWND VMBridgeDLLWindow) { javaVMs = javaVMs->nextJVMInstance; delete currentVM; - PrintDebugString(" data structures successfully removed"); + PrintDebugString("[INFO]: data structures successfully removed"); // [[[FIXME]]] inform Windows AT that a JVM went away, // and that any jobjects it's got lying around for that JVM @@ -735,7 +736,7 @@ WinAccessBridge::JavaVMDestroyed(HWND VMBridgeDLLWindow) { previousVM->nextJVMInstance = currentVM->nextJVMInstance; delete currentVM; - PrintDebugString(" data structures successfully removed"); + PrintDebugString("[INFO]: data structures successfully removed"); // [[[FIXME]]] inform Windows AT that a JVM went away, // and that any jobjects it's got lying around for that JVM @@ -747,7 +748,7 @@ WinAccessBridge::JavaVMDestroyed(HWND VMBridgeDLLWindow) { currentVM = currentVM->nextJVMInstance; } } - PrintDebugString(" ERROR!! couldn't find matching data structures!"); + PrintDebugString("[ERROR]: couldn't find matching data structures!"); } isVMInstanceChainInUse = false; } @@ -765,9 +766,9 @@ WinAccessBridge::JavaVMDestroyed(HWND VMBridgeDLLWindow) { void WinAccessBridge::releaseJavaObject(long vmID, JOBJECT64 object) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::releaseJavaObject(%X, %p)", vmID, object); + PrintDebugString("[INFO]: WinAccessBridge::releaseJavaObject(%X, %p)", vmID, object); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::releaseJavaObject(%X, %016I64X)", vmID, object); + PrintDebugString("[INFO]: WinAccessBridge::releaseJavaObject(%X, %016I64X)", vmID, object); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return; @@ -802,15 +803,16 @@ WinAccessBridge::getVersionInfo(long vmID, AccessBridgeVersionInfo *info) { *type = cGetAccessBridgeVersionPackage; pkg->vmID = vmID; - PrintDebugString("WinAccessBridge::getVersionInfo(%X, )", vmID); + PrintDebugString("[INFO]: WinAccessBridge::getVersionInfo(%X, )", vmID); HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(info, &(pkg->rVersionInfo), sizeof(AccessBridgeVersionInfo)); - PrintDebugString(" VMversion: %ls", info->VMversion); - PrintDebugString(" bridgeJavaClassVersion: %ls", info->bridgeJavaClassVersion); - PrintDebugString(" bridgeJavaDLLVersion: %ls", info->bridgeJavaDLLVersion); - PrintDebugString(" bridgeWinDLLVersion: %ls", info->bridgeWinDLLVersion); + PrintDebugString("[INFO]: VMversion: %ls\n"\ + " bridgeJavaClassVersion: %ls\n"\ + " bridgeJavaDLLVersion: %ls\n"\ + " bridgeWinDLLVersion: %ls\n"\ + , info->VMversion, info->bridgeJavaClassVersion, info->bridgeJavaDLLVersion, info->bridgeWinDLLVersion); return TRUE; } } @@ -843,7 +845,7 @@ WinAccessBridge::isJavaWindow(HWND window) { return FALSE; } - PrintDebugString("In WinAccessBridge::isJavaWindow"); + PrintDebugString("[INFO]: In WinAccessBridge::isJavaWindow"); @@ -853,7 +855,7 @@ WinAccessBridge::isJavaWindow(HWND window) { *type = cIsJavaWindowPackage; pkg->window = (jint) window; - PrintDebugString("WinAccessBridge::isJavaWindow(%p)", window); + PrintDebugString("[INFO]: WinAccessBridge::isJavaWindow(%p)", window); isVMInstanceChainInUse = true; AccessBridgeJavaVMInstance *current = javaVMs; @@ -908,9 +910,9 @@ BOOL WinAccessBridge::isSameObject(long vmID, JOBJECT64 obj1, JOBJECT64 obj2) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::isSameObject(%p %p)", obj1, obj2); + PrintDebugString("[INFO]: WinAccessBridge::isSameObject(%p %p)", obj1, obj2); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::isSameObject(%016I64X %016I64X)", obj1, obj2); + PrintDebugString("[INFO]: WinAccessBridge::isSameObject(%016I64X %016I64X)", obj1, obj2); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -928,14 +930,14 @@ WinAccessBridge::isSameObject(long vmID, JOBJECT64 obj1, JOBJECT64 obj2) { HWND destABWindow = javaVMs->findAccessBridgeWindow(pkg->vmID); if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { if (pkg->rResult != 0) { - PrintDebugString(" WinAccessBridge::isSameObject returning TRUE (same object)"); + PrintDebugString("[INFO]: WinAccessBridge::isSameObject returning TRUE (same object)"); return TRUE; } else { - PrintDebugString(" WinAccessBridge::isSameObject returning FALSE (different object)"); + PrintDebugString("[INFO]: WinAccessBridge::isSameObject returning FALSE (different object)"); return FALSE; } } - PrintDebugString(" WinAccessBridge::isSameObject returning FALSE (sendMemoryPackage failed)"); + PrintDebugString("[ERROR]: WinAccessBridge::isSameObject returning FALSE (sendMemoryPackage failed)"); return FALSE; } @@ -958,7 +960,7 @@ WinAccessBridge::getAccessibleContextFromHWND(HWND window, long *vmID, JOBJECT64 *type = cGetAccessibleContextFromHWNDPackage; pkg->window = (jint) window; - PrintDebugString("WinAccessBridge::getAccessibleContextFromHWND(%p, )", window); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleContextFromHWND(%p, )", window); DEBUG_CODE(pkg->rVMID = (long ) 0x01010101); DEBUG_CODE(pkg->rAccessibleContext = (JOBJECT64) 0x01010101); @@ -971,15 +973,14 @@ WinAccessBridge::getAccessibleContextFromHWND(HWND window, long *vmID, JOBJECT64 if (pkg->rAccessibleContext != 0) { *vmID = pkg->rVMID; *AccessibleContext = (JOBJECT64)pkg->rAccessibleContext; - PrintDebugString(" current->vmID = %X", current->vmID); - PrintDebugString(" pkg->rVMID = %X", pkg->rVMID); + PrintDebugString("[INFO]: current->vmID = %X, pkg->rVMID = %X", current->vmID, pkg->rVMID); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" pkg->rAccessibleContext = %p", pkg->rAccessibleContext); + PrintDebugString("[INFO]: pkg->rAccessibleContext = %p", pkg->rAccessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" pkg->rAccessibleContext = %016I64X", pkg->rAccessibleContext); + PrintDebugString("[INFO]: pkg->rAccessibleContext = %016I64X", pkg->rAccessibleContext); #endif if (pkg->rVMID != current->vmID) { - PrintDebugString(" ERROR! getAccessibleContextFromHWND vmIDs don't match!"); + PrintDebugString("[ERROR]: getAccessibleContextFromHWND vmIDs don't match!"); isVMInstanceChainInUse = false; return FALSE; } @@ -994,7 +995,7 @@ WinAccessBridge::getAccessibleContextFromHWND(HWND window, long *vmID, JOBJECT64 // This isn't really an error; it just means that the HWND was for a non-Java // window. It's also possible the HWND was for a Java window but the JVM has // since been shut down and sendMemoryPackage returned FALSE. - PrintDebugString(" ERROR! getAccessibleContextFromHWND no matching HWND found!"); + PrintDebugString("[ERROR]: getAccessibleContextFromHWND no matching HWND found!"); return FALSE; } @@ -1003,7 +1004,7 @@ WinAccessBridge::getAccessibleContextFromHWND(HWND window, long *vmID, JOBJECT64 */ HWND WinAccessBridge::getHWNDFromAccessibleContext(long vmID, JOBJECT64 accessibleContext) { - PrintDebugString(" in WinAccessBridge::getHWNDFromAccessibleContext"); + PrintDebugString("[INFO]: in WinAccessBridge::getHWNDFromAccessibleContext"); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return (HWND)0; } @@ -1015,9 +1016,9 @@ WinAccessBridge::getHWNDFromAccessibleContext(long vmID, JOBJECT64 accessibleCon pkg->accessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getHWNDFromAccessibleContext(%p)", accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getHWNDFromAccessibleContext(%p)", accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getHWNDFromAccessibleContext(%016I64X)", accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getHWNDFromAccessibleContext(%016I64X)", accessibleContext); #endif HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -1081,7 +1082,7 @@ WinAccessBridge::getAccessibleContextAt(long vmID, JOBJECT64 AccessibleContextPa pkg->x = x; pkg->y = y; - PrintDebugString("WinAccessBridge::getAccessibleContextAt(%X, %p, %d, %c)", vmID, AccessibleContextParent, x, y); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleContextAt(%X, %p, %d, %c)", vmID, AccessibleContextParent, x, y); HWND destABWindow = javaVMs->findAccessBridgeWindow(pkg->vmID); if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { *AccessibleContext = pkg->rAccessibleContext; @@ -1114,7 +1115,7 @@ WinAccessBridge::getAccessibleContextWithFocus(HWND window, long *vmID, JOBJECT6 GetAccessibleContextWithFocusPackage *pkg = (GetAccessibleContextWithFocusPackage *) (buffer + sizeof(PackageType)); *type = cGetAccessibleContextWithFocusPackage; - PrintDebugString("WinAccessBridge::getAccessibleContextWithFocus(%p, %X, )", window, vmID); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleContextWithFocus(%p, %X, )", window, vmID); // find vmID, etc. from HWND; ask that VM for the AC w/Focus HWND pkgVMID; if (getAccessibleContextFromHWND(window, (long *)&(pkgVMID), &(pkg->rAccessibleContext)) == TRUE) { @@ -1151,21 +1152,22 @@ WinAccessBridge::getAccessibleContextInfo(long vmID, pkg->AccessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleContextInfo(%X, %p, )", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleContextInfo(%X, %p, )", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleContextInfo(%X, %016I64X, )", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleContextInfo(%X, %016I64X, )", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(info, &(pkg->rAccessibleContextInfo), sizeof(AccessibleContextInfo)); - PrintDebugString(" name: %ls", info->name); - PrintDebugString(" description: %ls", info->description); - PrintDebugString(" role: %ls", info->role); - PrintDebugString(" role_en_US: %ls", info->role_en_US); - PrintDebugString(" states: %ls", info->states); - PrintDebugString(" states_en_US: %ls", info->states_en_US); + PrintDebugString("[INFO]: name: %ls\n"\ + " description: %ls\n"\ + " role: %ls\n"\ + " role_en_US: %ls\n"\ + " states: %ls\n"\ + " states_en_US: %ls\n"\ + , info->name, info->description, info->role, info->role_en_US, info->states, info->states_en_US); return TRUE; } } @@ -1200,9 +1202,9 @@ WinAccessBridge::getAccessibleChildFromContext(long vmID, pkg->childIndex = childIndex; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleChildFromContext(%X, %p, %d)", vmID, AccessibleContext, childIndex); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleChildFromContext(%X, %p, %d)", vmID, AccessibleContext, childIndex); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleChildFromContext(%X, %016I64X, %d)", vmID, AccessibleContext, childIndex); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleChildFromContext(%X, %016I64X, %d)", vmID, AccessibleContext, childIndex); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -1235,7 +1237,7 @@ WinAccessBridge::getAccessibleParentFromContext(long vmID, pkg->vmID = vmID; pkg->AccessibleContext = AccessibleContext; - PrintDebugString("WinAccessBridge::getAccessibleParentFromContext(%X, %p)", vmID, AccessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleParentFromContext(%X, %p)", vmID, AccessibleContext); // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { @@ -1255,10 +1257,10 @@ WinAccessBridge::getAccessibleTableInfo(long vmID, AccessibleTableInfo *tableInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableInfo(%X, %p, %p)", vmID, accessibleContext, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableInfo(%X, %p, %p)", vmID, accessibleContext, tableInfo); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableInfo(%X, %016I64X, %p)", vmID, accessibleContext, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableInfo(%X, %016I64X, %p)", vmID, accessibleContext, tableInfo); #endif @@ -1278,12 +1280,12 @@ WinAccessBridge::getAccessibleTableInfo(long vmID, if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(tableInfo, &(pkg->rTableInfo), sizeof(AccessibleTableInfo)); if (pkg->rTableInfo.rowCount != -1) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableInfo succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableInfo succeeded"); return TRUE; } } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableInfo failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableInfo failed"); return FALSE; } @@ -1292,7 +1294,7 @@ WinAccessBridge::getAccessibleTableCellInfo(long vmID, JOBJECT64 accessibleTable jint row, jint column, AccessibleTableCellInfo *tableCellInfo) { - PrintDebugString("##### WinAccessBridge::getAccessibleTableCellInfo(%X, %p, %d, %d, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableCellInfo(%X, %p, %d, %d, %p)", vmID, accessibleTable, row, column, tableCellInfo); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1311,13 +1313,13 @@ WinAccessBridge::getAccessibleTableCellInfo(long vmID, JOBJECT64 accessibleTable if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" XXXX pkg->rTableCellInfo.accessibleContext = %p", pkg->rTableCellInfo.accessibleContext); + PrintDebugString("[INFO]: XXXX pkg->rTableCellInfo.accessibleContext = %p", pkg->rTableCellInfo.accessibleContext); memcpy(tableCellInfo, &(pkg->rTableCellInfo), sizeof(AccessibleTableCellInfo)); - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableCellInfo succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableCellInfo succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableCellInfo failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableCellInfo failed"); return FALSE; } @@ -1326,9 +1328,9 @@ BOOL WinAccessBridge::getAccessibleTableRowHeader(long vmID, JOBJECT64 accessibleContext, AccessibleTableInfo *tableInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowHeader(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowHeader(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowHeader(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowHeader(%X, %016I64X)", vmID, accessibleContext); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1345,12 +1347,12 @@ WinAccessBridge::getAccessibleTableRowHeader(long vmID, JOBJECT64 accessibleCont HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowHeader succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowHeader succeeded"); memcpy(tableInfo, &(pkg->rTableInfo), sizeof(AccessibleTableInfo)); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowHeader failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableRowHeader failed"); return FALSE; } @@ -1358,9 +1360,9 @@ BOOL WinAccessBridge::getAccessibleTableColumnHeader(long vmID, JOBJECT64 accessibleContext, AccessibleTableInfo *tableInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnHeader(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnHeader(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnHeader(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnHeader(%X, %016I64X)", vmID, accessibleContext); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1377,12 +1379,12 @@ WinAccessBridge::getAccessibleTableColumnHeader(long vmID, JOBJECT64 accessibleC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnHeader succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnHeader succeeded"); memcpy(tableInfo, &(pkg->rTableInfo), sizeof(AccessibleTableInfo)); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnHeader failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableColumnHeader failed"); return FALSE; } @@ -1392,10 +1394,10 @@ WinAccessBridge::getAccessibleTableRowDescription(long vmID, jint row) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowDescription(%X, %p, %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowDescription(%X, %p, %d)", vmID, accessibleContext, row); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowDescription(%X, %016I64X, %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowDescription(%X, %016I64X, %d)", vmID, accessibleContext, row); #endif @@ -1414,11 +1416,11 @@ WinAccessBridge::getAccessibleTableRowDescription(long vmID, HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowDescription succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowDescription succeeded"); return pkg->rAccessibleContext; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowDescription failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableRowDescription failed"); return (JOBJECT64)0; } @@ -1428,10 +1430,10 @@ WinAccessBridge::getAccessibleTableColumnDescription(long vmID, jint column) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnDescription(%X, %p, %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnDescription(%X, %p, %d)", vmID, accessibleContext, column); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnDescription(%X, %016I64X, %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnDescription(%X, %016I64X, %d)", vmID, accessibleContext, column); #endif @@ -1451,11 +1453,11 @@ WinAccessBridge::getAccessibleTableColumnDescription(long vmID, HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnDescription succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnDescription succeeded"); return pkg->rAccessibleContext; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnDescription failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableColumnDescription failed"); return (JOBJECT64)0; } @@ -1463,9 +1465,9 @@ jint WinAccessBridge::getAccessibleTableRowSelectionCount(long vmID, JOBJECT64 accessibleTable) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowSelectionCount(%X, %p)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowSelectionCount(%X, %p)", vmID, accessibleTable); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowSelectionCount(%X, %016I64X)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowSelectionCount(%X, %016I64X)", vmID, accessibleTable); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1483,11 +1485,11 @@ WinAccessBridge::getAccessibleTableRowSelectionCount(long vmID, JOBJECT64 access HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowSelectionCount succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowSelectionCount succeeded"); return pkg->rCount; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowSelectionCount failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableRowSelectionCount failed"); return 0; } @@ -1495,9 +1497,9 @@ BOOL WinAccessBridge::isAccessibleTableRowSelected(long vmID, JOBJECT64 accessibleTable, jint row) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::isAccessibleTableRowSelected(%X, %p)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::isAccessibleTableRowSelected(%X, %p)", vmID, accessibleTable); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::isAccessibleTableRowSelected(%X, %016I64X)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::isAccessibleTableRowSelected(%X, %016I64X)", vmID, accessibleTable); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1515,11 +1517,11 @@ WinAccessBridge::isAccessibleTableRowSelected(long vmID, JOBJECT64 accessibleTab HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::isAccessibleTableRowSelected succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::isAccessibleTableRowSelected succeeded"); return pkg->rResult; } } - PrintDebugString(" ##### WinAccessBridge::isAccessibleTableRowSelected failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::isAccessibleTableRowSelected failed"); return FALSE; } @@ -1527,9 +1529,9 @@ BOOL WinAccessBridge::getAccessibleTableRowSelections(long vmID, JOBJECT64 accessibleTable, jint count, jint *selections) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowSelections(%X, %p)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowSelections(%X, %p)", vmID, accessibleTable); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRowSelections(%X, %016I64X)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowSelections(%X, %016I64X)", vmID, accessibleTable); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1548,12 +1550,12 @@ WinAccessBridge::getAccessibleTableRowSelections(long vmID, JOBJECT64 accessible HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowSelections succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRowSelections succeeded"); memcpy(selections, pkg->rSelections, count * sizeof(jint)); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRowSelections failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableRowSelections failed"); return FALSE; } @@ -1562,10 +1564,10 @@ jint WinAccessBridge::getAccessibleTableColumnSelectionCount(long vmID, JOBJECT64 accessibleTable) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnSelectionCount(%X, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnSelectionCount(%X, %p)", vmID, accessibleTable); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnSelectionCount(%X, %016I64X)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnSelectionCount(%X, %016I64X)", vmID, accessibleTable); #endif @@ -1584,20 +1586,20 @@ WinAccessBridge::getAccessibleTableColumnSelectionCount(long vmID, JOBJECT64 acc HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnSelectionCount succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnSelectionCount succeeded"); return pkg->rCount; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnSelectionCount failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableColumnSelectionCount failed"); return 0; } BOOL WinAccessBridge::isAccessibleTableColumnSelected(long vmID, JOBJECT64 accessibleTable, jint column) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::isAccessibleTableColumnSelected(%X, %p)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::isAccessibleTableColumnSelected(%X, %p)", vmID, accessibleTable); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::isAccessibleTableColumnSelected(%X, %016I64X)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::isAccessibleTableColumnSelected(%X, %016I64X)", vmID, accessibleTable); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1615,11 +1617,11 @@ WinAccessBridge::isAccessibleTableColumnSelected(long vmID, JOBJECT64 accessible HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::isAccessibleTableColumnSelected succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::isAccessibleTableColumnSelected succeeded"); return pkg->rResult; } } - PrintDebugString(" ##### WinAccessBridge::isAccessibleTableColumnSelected failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::isAccessibleTableColumnSelected failed"); return FALSE; } @@ -1628,9 +1630,9 @@ WinAccessBridge::getAccessibleTableColumnSelections(long vmID, JOBJECT64 accessi jint *selections) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnSelections(%X, %p)", vmID, accessibleTable); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnSelections(%X, %p)", vmID, accessibleTable); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumnSelections(%X, %016I64X)", vmID, accessibleTable); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableColumnSelections(%X, %016I64X)", vmID, accessibleTable); #endif if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { @@ -1649,12 +1651,12 @@ WinAccessBridge::getAccessibleTableColumnSelections(long vmID, JOBJECT64 accessi HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnSelections succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumnSelections succeeded"); memcpy(selections, pkg->rSelections, count * sizeof(jint)); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumnSelections failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableColumnSelections failed"); return FALSE; } @@ -1662,10 +1664,10 @@ jint WinAccessBridge::getAccessibleTableRow(long vmID, JOBJECT64 accessibleTable, jint index) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRow(%X, %p, index=%d)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRow(%X, %p, index=%d)", vmID, accessibleTable, index); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableRow(%X, %016I64X, index=%d)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRow(%X, %016I64X, index=%d)", vmID, accessibleTable, index); #endif @@ -1685,11 +1687,11 @@ WinAccessBridge::getAccessibleTableRow(long vmID, JOBJECT64 accessibleTable, jin HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRow succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableRow succeeded"); return pkg->rRow; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableRow failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableRow failed"); return 0; } @@ -1697,10 +1699,10 @@ jint WinAccessBridge::getAccessibleTableColumn(long vmID, JOBJECT64 accessibleTable, jint index) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumn(%X, %p, index=%d)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumn(%X, %p, index=%d)", vmID, accessibleTable, index); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableColumn(%X, %016I64X, index=%d)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumn(%X, %016I64X, index=%d)", vmID, accessibleTable, index); #endif @@ -1720,11 +1722,11 @@ WinAccessBridge::getAccessibleTableColumn(long vmID, JOBJECT64 accessibleTable, HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumn succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableColumn succeeded"); return pkg->rColumn; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableColumn failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableColumn failed"); return 0; } @@ -1732,10 +1734,10 @@ jint WinAccessBridge::getAccessibleTableIndex(long vmID, JOBJECT64 accessibleTable, jint row, jint column) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleTableIndex(%X, %p, row=%d, col=%d)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableIndex(%X, %p, row=%d, col=%d)", vmID, accessibleTable, row, column); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleTableIndex(%X, %016I64X, row=%d, col=%d)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableIndex(%X, %016I64X, row=%d, col=%d)", vmID, accessibleTable, row, column); #endif @@ -1756,11 +1758,11 @@ WinAccessBridge::getAccessibleTableIndex(long vmID, JOBJECT64 accessibleTable, j HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableIndex succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleTableIndex succeeded"); return pkg->rIndex; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleTableIndex failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleTableIndex failed"); return 0; } @@ -1771,10 +1773,10 @@ WinAccessBridge::getAccessibleRelationSet(long vmID, JOBJECT64 accessibleContext AccessibleRelationSetInfo *relationSetInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleRelationSet(%X, %p, %X)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleRelationSet(%X, %p, %X)", vmID, accessibleContext, relationSetInfo); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleRelationSet(%X, %016I64X, %X)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleRelationSet(%X, %016I64X, %X)", vmID, accessibleContext, relationSetInfo); #endif @@ -1792,14 +1794,14 @@ WinAccessBridge::getAccessibleRelationSet(long vmID, JOBJECT64 accessibleContext HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### pkg->rAccessibleRelationSetInfo.relationCount = %X", + PrintDebugString("[INFO]: ##### pkg->rAccessibleRelationSetInfo.relationCount = %X", pkg->rAccessibleRelationSetInfo.relationCount); memcpy(relationSetInfo, &(pkg->rAccessibleRelationSetInfo), sizeof(AccessibleRelationSetInfo)); - PrintDebugString(" ##### WinAccessBridge::getAccessibleRelationSet succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleRelationSet succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleRelationSet failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleRelationSet failed"); return FALSE; } @@ -1811,10 +1813,10 @@ WinAccessBridge::getAccessibleHypertext(long vmID, JOBJECT64 accessibleContext, AccessibleHypertextInfo *hypertextInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleHypertext(%X, %p, %X)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertext(%X, %p, %X)", vmID, accessibleContext, hypertextInfo); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleHypertext(%X, %016I64X, %X)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertext(%X, %016I64X, %X)", vmID, accessibleContext, hypertextInfo); #endif @@ -1834,13 +1836,13 @@ WinAccessBridge::getAccessibleHypertext(long vmID, JOBJECT64 accessibleContext, if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(hypertextInfo, &(pkg->rAccessibleHypertextInfo), sizeof(AccessibleHypertextInfo)); - PrintDebugString(" ##### hypertextInfo.linkCount = %d", hypertextInfo->linkCount); - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertext succeeded"); + PrintDebugString("[INFO]: ##### hypertextInfo.linkCount = %d", hypertextInfo->linkCount); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertext succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertext failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleHypertext failed"); return FALSE; } @@ -1850,10 +1852,10 @@ WinAccessBridge::activateAccessibleHyperlink(long vmID, JOBJECT64 accessibleCont JOBJECT64 accessibleHyperlink) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::activateAccessibleHyperlink(%p %p)", accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::activateAccessibleHyperlink(%p %p)", accessibleContext, accessibleHyperlink); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::activateAccessibleHyperlink(%016I64X %016I64X)", accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::activateAccessibleHyperlink(%016I64X %016I64X)", accessibleContext, accessibleHyperlink); #endif @@ -1873,7 +1875,7 @@ WinAccessBridge::activateAccessibleHyperlink(long vmID, JOBJECT64 accessibleCont if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { return pkg->rResult; } - PrintDebugString(" WinAccessBridge::activateAccessibleHyperlink returning FALSE (sendMemoryPackage failed)"); + PrintDebugString("[ERROR]: WinAccessBridge::activateAccessibleHyperlink returning FALSE (sendMemoryPackage failed)"); return FALSE; } @@ -1887,10 +1889,10 @@ WinAccessBridge::getAccessibleHyperlinkCount(const long vmID, const AccessibleContext accessibleContext) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleHyperlinkCount(%X, %p)", + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHyperlinkCount(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleHyperlinkCount(%X, %016I64X)", + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHyperlinkCount(%X, %016I64X)", vmID, accessibleContext); #endif @@ -1908,12 +1910,12 @@ WinAccessBridge::getAccessibleHyperlinkCount(const long vmID, HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### hypetext link count = %d", pkg->rLinkCount); - PrintDebugString(" ##### WinAccessBridge::getAccessibleHyperlinkCount succeeded"); + PrintDebugString("[INFO]: ##### hypetext link count = %d", pkg->rLinkCount); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHyperlinkCount succeeded"); return pkg->rLinkCount; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleHyperlinkCount failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleHyperlinkCount failed"); return -1; } @@ -1931,10 +1933,10 @@ WinAccessBridge::getAccessibleHypertextExt(const long vmID, /* OUT */ AccessibleHypertextInfo *hypertextInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleHypertextExt(%X, %p %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertextExt(%X, %p %p)", vmID, accessibleContext, hypertextInfo); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleHypertextExt(%X, %016I64X %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertextExt(%X, %016I64X %p)", vmID, accessibleContext, hypertextInfo); #endif @@ -1953,19 +1955,18 @@ WinAccessBridge::getAccessibleHypertextExt(const long vmID, HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### pkg->rSuccess = %d", pkg->rSuccess); + PrintDebugString("[INFO]: ##### pkg->rSuccess = %d", pkg->rSuccess); memcpy(hypertextInfo, &(pkg->rAccessibleHypertextInfo), sizeof(AccessibleHypertextInfo)); if (pkg->rSuccess == TRUE) { - PrintDebugString(" ##### hypertextInfo.linkCount = %d", hypertextInfo->linkCount); - PrintDebugString(" ##### hypertextInfo.linkCount = %d", hypertextInfo->linkCount); + PrintDebugString("[INFO]: ##### hypertextInfo.linkCount = %d", hypertextInfo->linkCount); } else { - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertextExt failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleHypertextExt failed"); } - return pkg->rSuccess;; + return pkg->rSuccess; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertextExt failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleHypertextExt failed"); return FALSE; } @@ -1982,10 +1983,10 @@ WinAccessBridge::getAccessibleHypertextLinkIndex(const long vmID, const jint charIndex) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleHypertextLinkIndex(%X, %p)", + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertextLinkIndex(%X, %p)", vmID, hypertext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleHypertextLinkIndex(%X, %016I64X)", + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertextLinkIndex(%X, %016I64X)", vmID, hypertext); #endif @@ -2004,12 +2005,12 @@ WinAccessBridge::getAccessibleHypertextLinkIndex(const long vmID, HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" ##### hypetext link index = %d", pkg->rLinkIndex); - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertextLinkIndex succeeded"); + PrintDebugString("[INFO]: ##### hypetext link index = %d", pkg->rLinkIndex); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertextLinkIndex succeeded"); return pkg->rLinkIndex; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertextLinkIndex failed"); + PrintDebugString("[ERROR] ##### WinAccessBridge::getAccessibleHypertextLinkIndex failed"); return -1; } @@ -2025,10 +2026,10 @@ WinAccessBridge::getAccessibleHyperlink(const long vmID, /* OUT */ AccessibleHyperlinkInfo *hyperlinkInfo) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleHyperlink(%X, %p, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHyperlink(%X, %p, %p)", vmID, hypertext, hyperlinkInfo); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleHyperlink(%X, %016I64X, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHyperlink(%X, %016I64X, %p)", vmID, hypertext, hyperlinkInfo); #endif @@ -2049,11 +2050,11 @@ WinAccessBridge::getAccessibleHyperlink(const long vmID, if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(hyperlinkInfo, &(pkg->rAccessibleHyperlinkInfo), sizeof(AccessibleHyperlinkInfo)); - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertext succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleHypertext succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleHypertext failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleHypertext failed"); return FALSE; } @@ -2065,10 +2066,10 @@ WinAccessBridge::getAccessibleKeyBindings(long vmID, JOBJECT64 accessibleContext AccessibleKeyBindings *keyBindings) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleKeyBindings(%X, %p, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleKeyBindings(%X, %p, %p)", vmID, accessibleContext, keyBindings); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleKeyBindings(%X, %016I64X, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleKeyBindings(%X, %016I64X, %p)", vmID, accessibleContext, keyBindings); #endif @@ -2088,19 +2089,20 @@ WinAccessBridge::getAccessibleKeyBindings(long vmID, JOBJECT64 accessibleContext if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(keyBindings, &(pkg->rAccessibleKeyBindings), sizeof(AccessibleKeyBindings)); - PrintDebugString(" ##### keyBindings.keyBindingsCount = %d", keyBindings->keyBindingsCount); + PrintDebugString("[INFO]: ##### keyBindings.keyBindingsCount = %d", keyBindings->keyBindingsCount); for (int i = 0; i < keyBindings->keyBindingsCount; ++i) { - PrintDebugString(" Key Binding # %d", i+1); - PrintDebugString(" Modifiers: 0x%x", keyBindings->keyBindingInfo[i].modifiers); - PrintDebugString(" Character (hex): 0x%x", keyBindings->keyBindingInfo[i].character); - PrintDebugString(" Character (wide char): %lc", keyBindings->keyBindingInfo[i].character); + PrintDebugString("[INFO]: Key Binding # %d"\ + " Modifiers: 0x%x"\ + " Character (hex): 0x%x"\ + " Character (wide char): %lc"\ + , i+1, keyBindings->keyBindingInfo[i].modifiers, keyBindings->keyBindingInfo[i].character, keyBindings->keyBindingInfo[i].character); } - PrintDebugString(" ##### WinAccessBridge::getAccessibleKeyBindings succeeded"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleKeyBindings succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleKeyBindings failed"); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleKeyBindings failed"); return FALSE; } @@ -2108,10 +2110,10 @@ BOOL WinAccessBridge::getAccessibleIcons(long vmID, JOBJECT64 accessibleContext, AccessibleIcons *icons) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleIcons(%X, %p, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleIcons(%X, %p, %p)", vmID, accessibleContext, icons); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleIcons(%X, %016I64X, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleIcons(%X, %016I64X, %p)", vmID, accessibleContext, icons); #endif @@ -2131,13 +2133,13 @@ WinAccessBridge::getAccessibleIcons(long vmID, JOBJECT64 accessibleContext, Acce if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(icons, &(pkg->rAccessibleIcons), sizeof(AccessibleIcons)); - PrintDebugString(" ##### icons.iconsCount = %d", icons->iconsCount); - PrintDebugString(" ##### WinAccessBridge::getAccessibleIcons succeeded"); + PrintDebugString("[INFO]: ##### icons.iconsCount = %d", icons->iconsCount); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleIcons succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleIcons failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleIcons failed"); return FALSE; } @@ -2145,10 +2147,10 @@ BOOL WinAccessBridge::getAccessibleActions(long vmID, JOBJECT64 accessibleContext, AccessibleActions *actions) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("##### WinAccessBridge::getAccessibleActions(%X, %p, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleActions(%X, %p, %p)", vmID, accessibleContext, actions); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("##### WinAccessBridge::getAccessibleActions(%X, %016I64X, %p)", vmID, + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleActions(%X, %016I64X, %p)", vmID, accessibleContext, actions); #endif @@ -2168,13 +2170,13 @@ WinAccessBridge::getAccessibleActions(long vmID, JOBJECT64 accessibleContext, Ac if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(actions, &(pkg->rAccessibleActions), sizeof(AccessibleActions)); - PrintDebugString(" ##### actions.actionsCount = %d", actions->actionsCount); - PrintDebugString(" ##### WinAccessBridge::getAccessibleActions succeeded"); + PrintDebugString("[INFO]: ##### actions.actionsCount = %d", actions->actionsCount); + PrintDebugString("[INFO]: ##### WinAccessBridge::getAccessibleActions succeeded"); return TRUE; } } - PrintDebugString(" ##### WinAccessBridge::getAccessibleActions failed"); + PrintDebugString("[ERROR]: ##### WinAccessBridge::getAccessibleActions failed"); return FALSE; } @@ -2183,11 +2185,11 @@ WinAccessBridge::doAccessibleActions(long vmID, JOBJECT64 accessibleContext, AccessibleActionsToDo *actionsToDo, jint *failure) { #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::doAccessibleActions(%p #actions %d %ls)", accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::doAccessibleActions(%p #actions %d %ls)", accessibleContext, actionsToDo->actionsCount, actionsToDo->actions[0].name); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::doAccessibleActions(%016I64X #actions %d %ls)", accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::doAccessibleActions(%016I64X #actions %d %ls)", accessibleContext, actionsToDo->actionsCount, actionsToDo->actions[0].name); #endif @@ -2209,7 +2211,7 @@ WinAccessBridge::doAccessibleActions(long vmID, JOBJECT64 accessibleContext, *failure = pkg->failure; return pkg->rResult; } - PrintDebugString(" WinAccessBridge::doAccessibleActions returning FALSE (sendMemoryPackage failed)"); + PrintDebugString("[ERROR]: WinAccessBridge::doAccessibleActions returning FALSE (sendMemoryPackage failed)"); return FALSE; } @@ -2234,9 +2236,9 @@ WinAccessBridge::setTextContents (const long vmID, const AccessibleContext acces wcsncpy(pkg->text, text, sizeof(pkg->text)/sizeof(wchar_t)); // wide character copy #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::setTextContents(%X, %016I64X %ls)", vmID, accessibleContext, text); + PrintDebugString("[INFO]: WinAccessBridge::setTextContents(%X, %016I64X %ls)", vmID, accessibleContext, text); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::setTextContents(%X, %p %ls)", vmID, accessibleContext, text); + PrintDebugString("[INFO]: WinAccessBridge::setTextContents(%X, %p %ls)", vmID, accessibleContext, text); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2271,18 +2273,19 @@ WinAccessBridge::getParentWithRole (const long vmID, const AccessibleContext acc memcpy((void *)(&(pkg->role)), (void *)role, sizeof(pkg->role)); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getParentWithRole(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getParentWithRole(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getParentWithRole(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getParentWithRole(%X, %016I64X)", vmID, accessibleContext); #endif - PrintDebugString(" pkg->vmID: %X", pkg->vmID); - PrintDebugString(" pkg->accessibleContext: %p", pkg->accessibleContext); - PrintDebugString(" pkg->role: %ls", pkg->role); + PrintDebugString("[INFO]: pkg->vmID: %X"\ + " pkg->accessibleContext: %p"\ + " pkg->role: %ls"\ + , pkg->vmID, pkg->accessibleContext, pkg->role); // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { - PrintDebugString(" pkg->rAccessibleContext: %p", pkg->rAccessibleContext); + PrintDebugString("[INFO]: pkg->rAccessibleContext: %p", pkg->rAccessibleContext); return pkg->rAccessibleContext; } } @@ -2310,9 +2313,9 @@ WinAccessBridge::getTopLevelObject (const long vmID, const AccessibleContext acc pkg->accessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getTopLevelObject(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getTopLevelObject(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getTopLevelObject(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getTopLevelObject(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2345,9 +2348,9 @@ WinAccessBridge::getParentWithRoleElseRoot (const long vmID, const AccessibleCon memcpy((void *)(&(pkg->role)), (void *)role, sizeof(pkg->role)); #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getParentWithRoleElseRoot(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getParentWithRoleElseRoot(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getParentWithRoleElseRoot(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getParentWithRoleElseRoot(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2378,9 +2381,9 @@ WinAccessBridge::getObjectDepth (const long vmID, const AccessibleContext access pkg->accessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getObjectDepth(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getObjectDepth(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getObjectDepth(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getObjectDepth(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2410,9 +2413,9 @@ WinAccessBridge::getActiveDescendent (const long vmID, const AccessibleContext a pkg->accessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getActiveDescendent(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getActiveDescendent(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getActiveDescendent(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getActiveDescendent(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2451,16 +2454,16 @@ WinAccessBridge::getVirtualAccessibleName(long vmID, AccessibleContext accessibl pkg->len = (int)max; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getVirtualAccessibleName(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getVirtualAccessibleName(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getVirtualAccessibleName(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getVirtualAccessibleName(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); if (destABWindow != (HWND) 0) { if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { wcsncpy(name, pkg->rName, max); - PrintDebugString(" WinAccessBridge::getVirtualAccessibleName: Virtual name = %ls", name); + PrintDebugString("[INFO]: WinAccessBridge::getVirtualAccessibleName: Virtual name = %ls", name); return TRUE; } } @@ -2486,9 +2489,9 @@ WinAccessBridge::requestFocus(long vmID, AccessibleContext accessibleContext) { pkg->accessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::requestFocus(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::requestFocus(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::requestFocus(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::requestFocus(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2521,10 +2524,10 @@ WinAccessBridge::selectTextRange(long vmID, AccessibleContext accessibleContext, pkg->endIndex = endIndex; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" WinAccessBridge::selectTextRange(%X, %p %d %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::selectTextRange(%X, %p %d %d)", vmID, accessibleContext, startIndex, endIndex); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" WinAccessBridge::selectTextRange(%X, %016I64X %d %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::selectTextRange(%X, %016I64X %d %d)", vmID, accessibleContext, startIndex, endIndex); #endif // need to call only the HWND/VM that contains this AC @@ -2563,10 +2566,10 @@ WinAccessBridge::getTextAttributesInRange(long vmID, AccessibleContext accessibl #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString(" WinAccessBridge::getTextAttributesInRange(%X, %p %d %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::getTextAttributesInRange(%X, %p %d %d)", vmID, accessibleContext, startIndex, endIndex); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString(" WinAccessBridge::getTextAttributesInRange(%X, %016I64X %d %d)", vmID, accessibleContext, + PrintDebugString("[INFO]: WinAccessBridge::getTextAttributesInRange(%X, %016I64X %d %d)", vmID, accessibleContext, startIndex, endIndex); #endif // need to call only the HWND/VM that contains this AC @@ -2600,9 +2603,9 @@ WinAccessBridge::getVisibleChildrenCount(long vmID, AccessibleContext accessible pkg->accessibleContext = accessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getVisibleChildrenCount(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getVisibleChildrenCount(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getVisibleChildrenCount(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getVisibleChildrenCount(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2635,9 +2638,9 @@ WinAccessBridge::getVisibleChildren(long vmID, AccessibleContext accessibleConte pkg->startIndex = startIndex; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getVisibleChildren(%X, %p)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getVisibleChildren(%X, %p)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getVisibleChildren(%X, %016I64X)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::getVisibleChildren(%X, %016I64X)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2670,9 +2673,9 @@ WinAccessBridge::setCaretPosition(long vmID, AccessibleContext accessibleContext pkg->position = position; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::setCaretPosition(%X, %p %ls)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::setCaretPosition(%X, %p %ls)", vmID, accessibleContext); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::setCaretPosition(%X, %016I64X %ls)", vmID, accessibleContext); + PrintDebugString("[INFO]: WinAccessBridge::setCaretPosition(%X, %016I64X %ls)", vmID, accessibleContext); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2712,9 +2715,9 @@ WinAccessBridge::getAccessibleTextInfo(long vmID, pkg->y = y; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextInfo(%X, %p, %p, %d, %d)", vmID, AccessibleContext, textInfo, x, y); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextInfo(%X, %p, %p, %d, %d)", vmID, AccessibleContext, textInfo, x, y); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextInfo(%X, %016I64X, %p, %d, %d)", vmID, AccessibleContext, textInfo, x, y); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextInfo(%X, %016I64X, %p, %d, %d)", vmID, AccessibleContext, textInfo, x, y); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2722,9 +2725,10 @@ WinAccessBridge::getAccessibleTextInfo(long vmID, if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) { memcpy(textInfo, &(pkg->rTextInfo), sizeof(AccessibleTextInfo)); if (pkg->rTextInfo.charCount != -1) { - PrintDebugString(" charCount: %d", textInfo->charCount); - PrintDebugString(" caretIndex: %d", textInfo->caretIndex); - PrintDebugString(" indexAtPoint: %d", textInfo->indexAtPoint); + PrintDebugString("[INFO]: charCount: %d"\ + " caretIndex: %d"\ + " indexAtPoint: %d"\ + , textInfo->charCount, textInfo->caretIndex, textInfo->indexAtPoint); return TRUE; } } @@ -2760,9 +2764,9 @@ WinAccessBridge::getAccessibleTextItems(long vmID, pkg->rTextItemsInfo.sentence[0] = '\0'; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextItems(%X, %p, %p, %d)", vmID, AccessibleContext, textItems, index); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextItems(%X, %p, %p, %d)", vmID, AccessibleContext, textItems, index); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextItems(%X, %016I64X, %p, %d)", vmID, AccessibleContext, textItems, index); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextItems(%X, %016I64X, %p, %d)", vmID, AccessibleContext, textItems, index); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2799,9 +2803,9 @@ WinAccessBridge::getAccessibleTextSelectionInfo(long vmID, pkg->AccessibleContext = AccessibleContext; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextSelectionInfo(%X, %p, %p)", vmID, AccessibleContext, selectionInfo); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextSelectionInfo(%X, %p, %p)", vmID, AccessibleContext, selectionInfo); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextSelectionInfo(%X, %016I64X, %p)", vmID, AccessibleContext, selectionInfo); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextSelectionInfo(%X, %016I64X, %p)", vmID, AccessibleContext, selectionInfo); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2839,9 +2843,9 @@ WinAccessBridge::getAccessibleTextAttributes(long vmID, pkg->index = index; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextAttributes(%X, %p, %d, %p)", vmID, AccessibleContext, index, attributes); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextAttributes(%X, %p, %d, %p)", vmID, AccessibleContext, index, attributes); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextAttributes(%X, %016I64X, %d, %p)", vmID, AccessibleContext, index, attributes); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextAttributes(%X, %016I64X, %d, %p)", vmID, AccessibleContext, index, attributes); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2877,9 +2881,9 @@ WinAccessBridge::getAccessibleTextRect(long vmID, pkg->index = index; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextRect(%X, %p, %p, %d)", vmID, AccessibleContext, rectInfo, index); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextRect(%X, %p, %p, %d)", vmID, AccessibleContext, rectInfo, index); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextRect(%X, %016I64X, %p, %d)", vmID, AccessibleContext, rectInfo, index); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextRect(%X, %016I64X, %p, %d)", vmID, AccessibleContext, rectInfo, index); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2917,9 +2921,9 @@ WinAccessBridge::getCaretLocation(long vmID, pkg->index = index; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getCaretLocation(%X, %p, %p, %d)", vmID, AccessibleContext, rectInfo, index); + PrintDebugString("[INFO]: WinAccessBridge::getCaretLocation(%X, %p, %p, %d)", vmID, AccessibleContext, rectInfo, index); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getCaretLocation(%X, %016I64X, %p, %d)", vmID, AccessibleContext, rectInfo, index); + PrintDebugString("[INFO]: WinAccessBridge::getCaretLocation(%X, %016I64X, %p, %d)", vmID, AccessibleContext, rectInfo, index); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -2969,9 +2973,9 @@ WinAccessBridge::getAccessibleTextLineBounds(long vmID, pkg->index = index; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextLineBounds(%X, %p, %d, )", vmID, AccessibleContext, index); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextLineBounds(%X, %p, %d, )", vmID, AccessibleContext, index); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextLineBounds(%X, %016I64X, %d, )", vmID, AccessibleContext, index); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextLineBounds(%X, %016I64X, %d, )", vmID, AccessibleContext, index); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -3011,9 +3015,9 @@ WinAccessBridge::getAccessibleTextRange(long vmID, pkg->end = end; #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - PrintDebugString("WinAccessBridge::getAccessibleTextRange(%X, %p, %d, %d, )", vmID, AccessibleContext, start, end); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextRange(%X, %p, %d, %d, )", vmID, AccessibleContext, start, end); #else // JOBJECT64 is jlong (64 bit) - PrintDebugString("WinAccessBridge::getAccessibleTextRange(%X, %016I64X, %d, %d, )", vmID, AccessibleContext, start, end); + PrintDebugString("[INFO]: WinAccessBridge::getAccessibleTextRange(%X, %016I64X, %d, %d, )", vmID, AccessibleContext, start, end); #endif // need to call only the HWND/VM that contains this AC HWND destABWindow = javaVMs->findAccessBridgeWindow(vmID); @@ -3290,7 +3294,7 @@ WinAccessBridge::selectAllAccessibleSelectionFromContext(long vmID, */ void WinAccessBridge::addJavaEventNotification(jlong type) { - PrintDebugString("WinAccessBridge::addJavaEventNotification(%016I64X)", type); + PrintDebugString("[INFO]: WinAccessBridge::addJavaEventNotification(%016I64X)", type); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return; } @@ -3302,7 +3306,7 @@ WinAccessBridge::addJavaEventNotification(jlong type) { pkg->type = type; pkg->DLLwindow = ABHandleToLong(dialogWindow); - PrintDebugString(" ->pkgType = %X, eventType = %016I64X, DLLwindow = %p", + PrintDebugString("[INFO]: ->pkgType = %X, eventType = %016I64X, DLLwindow = %p", *pkgType, pkg->type, pkg->DLLwindow); // send addEventNotification message to all JVMs @@ -3327,7 +3331,7 @@ WinAccessBridge::addJavaEventNotification(jlong type) { */ void WinAccessBridge::removeJavaEventNotification(jlong type) { - PrintDebugString("in WinAccessBridge::removeJavaEventNotification(%016I64X)", type); + PrintDebugString("[INFO]: in WinAccessBridge::removeJavaEventNotification(%016I64X)", type); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return; } @@ -3338,7 +3342,7 @@ WinAccessBridge::removeJavaEventNotification(jlong type) { pkg->type = type; pkg->DLLwindow = ABHandleToLong(dialogWindow); - PrintDebugString(" ->pkgType = %X, eventType = %016I64X, DLLwindow = %p", + PrintDebugString("[INFO]: ->pkgType = %X, eventType = %016I64X, DLLwindow = %p", *pkgType, pkg->type, pkg->DLLwindow); // send removeEventNotification message to all JVMs @@ -3365,7 +3369,7 @@ WinAccessBridge::removeJavaEventNotification(jlong type) { */ void WinAccessBridge::addAccessibilityEventNotification(jlong type) { - PrintDebugString("in WinAccessBridge::addAccessibilityEventNotification(%016I64X)", type); + PrintDebugString("[INFO]: in WinAccessBridge::addAccessibilityEventNotification(%016I64X)", type); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return; } @@ -3376,7 +3380,7 @@ WinAccessBridge::addAccessibilityEventNotification(jlong type) { pkg->type = type; pkg->DLLwindow = ABHandleToLong(dialogWindow); - PrintDebugString(" ->pkgType = %X, eventType = %016I64X, DLLwindow = %X", + PrintDebugString("[INFO]: ->pkgType = %X, eventType = %016I64X, DLLwindow = %X", *pkgType, pkg->type, pkg->DLLwindow); // send addEventNotification message to all JVMs @@ -3401,7 +3405,7 @@ WinAccessBridge::addAccessibilityEventNotification(jlong type) { */ void WinAccessBridge::removeAccessibilityEventNotification(jlong type) { - PrintDebugString("in WinAccessBridge::removeAccessibilityEventNotification(%016I64X)", type); + PrintDebugString("[INFO]: in WinAccessBridge::removeAccessibilityEventNotification(%016I64X)", type); if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) { return; } @@ -3412,7 +3416,7 @@ WinAccessBridge::removeAccessibilityEventNotification(jlong type) { pkg->type = type; pkg->DLLwindow = ABHandleToLong(dialogWindow); - PrintDebugString(" ->pkgType = %X, eventType = %016I64X, DLLwindow = %X", + PrintDebugString("[INFO]: ->pkgType = %X, eventType = %016I64X, DLLwindow = %X", *pkgType, pkg->type, pkg->DLLwindow); // send removeEventNotification message to all JVMs diff --git a/src/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java b/src/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java index d66262ae1b4..c9c2362bcc1 100644 --- a/src/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java +++ b/src/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -772,6 +772,8 @@ public synchronized void engineLoad(InputStream stream, char[] password) } if (debug != null) { dumpTokenMap(); + debug.println("P11KeyStore load. Entry count: " + + aliasMap.size()); } } catch (KeyStoreException | PKCS11Exception e) { throw new IOException("load failed", e); diff --git a/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDHKeyAgreement.java b/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDHKeyAgreement.java index c05106826ae..943ce2f685a 100644 --- a/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDHKeyAgreement.java +++ b/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDHKeyAgreement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, 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 @@ -176,7 +176,7 @@ protected byte[] engineGenerateSecret() throws IllegalStateException { @Override protected int engineGenerateSecret(byte[] sharedSecret, int offset) throws IllegalStateException, ShortBufferException { - if (offset + secretLen > sharedSecret.length) { + if (secretLen > sharedSecret.length - offset) { throw new ShortBufferException("Need " + secretLen + " bytes, only " + (sharedSecret.length - offset) + " available"); diff --git a/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java b/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java index 6070d22c1db..29ef2cee3fa 100644 --- a/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java +++ b/src/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, 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 @@ -165,7 +165,7 @@ protected void engineUpdate(ByteBuffer byteBuffer) { if (len <= 0) { return; } - if (offset + len >= precomputedDigest.length) { + if (len >= precomputedDigest.length - offset) { offset = RAW_ECDSA_MAX + 1; return; } @@ -412,10 +412,10 @@ private byte[] signDigestNative(ECPrivateKey privateKey, byte[] digest, // DER OID byte[] encodedParams = ECUtil.encodeECParameterSpec(null, params); - int keySize = params.getCurve().getField().getFieldSize(); + int orderLength = params.getOrder().bitLength(); - // seed is twice the key size (in bytes) plus 1 - byte[] seed = new byte[(((keySize + 7) >> 3) + 1) * 2]; + // seed is twice the order length (in bytes) plus 1 + byte[] seed = new byte[(((orderLength + 7) >> 3) + 1) * 2]; random.nextBytes(seed); diff --git a/src/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c b/src/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c index c439eb702bd..299135d9914 100644 --- a/src/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c +++ b/src/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * * This library is free software; you can redistribute it and/or @@ -660,6 +660,7 @@ ECDSA_SignDigestWithSeed(ECPrivateKey *key, SECItem *signature, SECItem kGpoint = { siBuffer, NULL, 0}; int flen = 0; /* length in bytes of the field size */ unsigned olen; /* length in bytes of the base point order */ + unsigned int orderBitSize; #if EC_DEBUG char mpstr[256]; @@ -762,10 +763,11 @@ ECDSA_SignDigestWithSeed(ECPrivateKey *key, SECItem *signature, SECITEM_TO_MPINT(*digest, &s); /* s = HASH(M) */ /* In the definition of EC signing, digests are truncated - * to the length of n in bits. + * to the order length * (see SEC 1 "Elliptic Curve Digit Signature Algorithm" section 4.1.*/ - if (digest->len*8 > (unsigned int)ecParams->fieldID.size) { - mpl_rsh(&s,&s,digest->len*8 - ecParams->fieldID.size); + orderBitSize = mpl_significant_bits(&n); + if (digest->len*8 > orderBitSize) { + mpl_rsh(&s,&s,digest->len*8 - orderBitSize); } #if EC_DEBUG @@ -898,6 +900,7 @@ ECDSA_VerifyDigest(ECPublicKey *key, const SECItem *signature, int slen; /* length in bytes of a half signature (r or s) */ int flen; /* length in bytes of the field size */ unsigned olen; /* length in bytes of the base point order */ + unsigned int orderBitSize; #if EC_DEBUG char mpstr[256]; @@ -977,11 +980,12 @@ ECDSA_VerifyDigest(ECPublicKey *key, const SECItem *signature, SECITEM_TO_MPINT(*digest, &u1); /* u1 = HASH(M) */ /* In the definition of EC signing, digests are truncated - * to the length of n in bits. + * to the order length, in bits. * (see SEC 1 "Elliptic Curve Digit Signature Algorithm" section 4.1.*/ /* u1 = HASH(M') */ - if (digest->len*8 > (unsigned int)ecParams->fieldID.size) { - mpl_rsh(&u1,&u1,digest->len*8- ecParams->fieldID.size); + orderBitSize = mpl_significant_bits(&n); + if (digest->len*8 > orderBitSize) { + mpl_rsh(&u1,&u1,digest->len*8- orderBitSize); } #if EC_DEBUG diff --git a/src/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java b/src/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java index 67536dbd57a..7f9736fe165 100644 --- a/src/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java +++ b/src/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -44,6 +44,8 @@ import java.security.interfaces.RSAPrivateCrtKey; import java.util.*; +import sun.security.util.Debug; + /** * Implementation of key store for Windows using the Microsoft Crypto API. * @@ -185,6 +187,7 @@ void setCertificateChain(X509Certificate[] chain) private static final String KEYSTORE_COMPATIBILITY_MODE_PROP = "sun.security.mscapi.keyStoreCompatibilityMode"; private final boolean keyStoreCompatibilityMode; + private static final Debug debug = Debug.getInstance("keystore"); /* * The keystore entries. @@ -728,6 +731,11 @@ public void engineLoad(InputStream stream, char[] password) } catch (KeyStoreException e) { throw new IOException(e); } + + if (debug != null) { + debug.println("MSCAPI keystore load: entry count: " + + entries.size()); + } } /** diff --git a/src/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp b/src/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp index 2d94288e9ce..7172e0a31fd 100644 --- a/src/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp +++ b/src/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp @@ -799,8 +799,8 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_00024PSS_sign SS_CHECK(::NCryptTranslateHandle( NULL, &hk, - hCryptProv, - hCryptKey, + (HCRYPTPROV)hCryptProv, + (HCRYPTKEY)hCryptKey, NULL, 0)); @@ -996,8 +996,8 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_00024PSS_verify SS_CHECK(::NCryptTranslateHandle( NULL, &hk, - hCryptProv, - hKey, + (HCRYPTPROV)hCryptProv, + (HCRYPTKEY)hKey, NULL, 0)); diff --git a/src/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c b/src/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c index 887f101ba95..5f5c601982a 100644 --- a/src/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c +++ b/src/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c @@ -897,8 +897,51 @@ static bool read_exec_segments(struct ps_prochandle* ph, ELF_EHDR* exec_ehdr) { #define LD_BASE_OFFSET offsetof(struct r_debug, r_ldbase) #define LINK_MAP_ADDR_OFFSET offsetof(struct link_map, l_addr) #define LINK_MAP_NAME_OFFSET offsetof(struct link_map, l_name) +#define LINK_MAP_LD_OFFSET offsetof(struct link_map, l_ld) #define LINK_MAP_NEXT_OFFSET offsetof(struct link_map, l_next) +// Calculate the load address of shared library +// on prelink-enabled environment. +// +// In case of GDB, it would be calculated by offset of link_map.l_ld +// and the address of .dynamic section. +// See GDB implementation: lm_addr_check @ solib-svr4.c +static uintptr_t calc_prelinked_load_address(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* elf_ehdr, uintptr_t link_map_addr) { + ELF_PHDR *phbuf; + uintptr_t lib_ld; + uintptr_t lib_dyn_addr = 0L; + uintptr_t load_addr; + int i; + + phbuf = read_program_header_table(lib_fd, elf_ehdr); + if (phbuf == NULL) { + print_debug("can't read program header of shared object\n"); + return 0L; + } + + // Get the address of .dynamic section from shared library. + for (i = 0; i < elf_ehdr->e_phnum; i++) { + if (phbuf[i].p_type == PT_DYNAMIC) { + lib_dyn_addr = phbuf[i].p_vaddr; + break; + } + } + + free(phbuf); + + if (ps_pdread(ph, (psaddr_t)link_map_addr + LINK_MAP_LD_OFFSET, + &lib_ld, sizeof(uintptr_t)) != PS_OK) { + print_debug("can't read address of dynamic section in shared object\n"); + return 0L; + } + + // Return the load address which is calculated by the address of .dynamic + // and link_map.l_ld . + load_addr = lib_ld - lib_dyn_addr; + print_debug("lib_ld = 0x%lx, lib_dyn_addr = 0x%lx -> lib_base_diff = 0x%lx\n", lib_ld, lib_dyn_addr, load_addr); + return load_addr; +} + // read shared library info from runtime linker's data structures. // This work is done by librtlb_db in Solaris static bool read_shared_lib_info(struct ps_prochandle* ph) { @@ -1000,6 +1043,14 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { // continue with other libraries... } else { if (read_elf_header(lib_fd, &elf_ehdr)) { + if (lib_base_diff == 0x0L) { + lib_base_diff = calc_prelinked_load_address(ph, lib_fd, &elf_ehdr, link_map_addr); + if (lib_base_diff == 0x0L) { + close(lib_fd); + return false; + } + } + lib_base = lib_base_diff + find_base_address(lib_fd, &elf_ehdr); print_debug("reading library %s @ 0x%lx [ 0x%lx ]\n", lib_name, lib_base, lib_base_diff); diff --git a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java index 9fffe4bb010..ef0b2a0aa13 100644 --- a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java +++ b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java @@ -45,30 +45,38 @@ private static boolean launcherHelp() { return false; } - private static boolean commonHelp() { + private static boolean commonHelp(String mode) { // --pid <pid> // --exe <exe> // --core <core> - System.out.println(" --exe\t<executable image name>"); - System.out.println(" --core\t<path to coredump>"); - System.out.println(" --pid\t<pid of process to attach>"); + System.out.println(" --pid <pid> \tTo attach to and operate on the given live process."); + System.out.println(" --core <corefile>\tTo operate on the given core file."); + System.out.println(" --exe <executable for corefile>"); + System.out.println(); + System.out.println(" The --core and --exe options must be set together to give the core"); + System.out.println(" file, and associated executable, to operate on. Otherwise the --pid"); + System.out.println(" option can be set to operate on a live process."); + System.out.println(" The arguments for --exe and --core can use absolute or relative paths."); + System.out.println(); + System.out.println(" Examples: jhsdb " + mode + " --pid 1234"); + System.out.println(" or jhsdb " + mode + " --core ./core.1234 --exe ./myexe"); return false; } private static boolean debugdHelp() { // [options] <pid> [server-id] // [options] <executable> <core> [server-id] - System.out.println(" --serverid\t<unique id for this debug server>"); - return commonHelp(); + System.out.println(" --serverid <id> \tA unique identifier for this debug server."); + return commonHelp("debugd"); } private static boolean jinfoHelp() { // --flags -> -flags // --sysprops -> -sysprops - System.out.println(" --flags\tto print VM flags"); - System.out.println(" --sysprops\tto print Java System properties"); - System.out.println(" <no option>\tto print both of the above"); - return commonHelp(); + System.out.println(" --flags \tTo print VM flags."); + System.out.println(" --sysprops \tTo print Java System properties."); + System.out.println(" <no option> \tTo print both of the above."); + return commonHelp("jinfo"); } private static boolean jmapHelp() { @@ -78,27 +86,27 @@ private static boolean jmapHelp() { // --clstats -> -clstats // --finalizerinfo -> -finalizerinfo - System.out.println(" <no option>\tto print same info as Solaris pmap"); - System.out.println(" --heap\tto print java heap summary"); - System.out.println(" --binaryheap\tto dump java heap in hprof binary format"); - System.out.println(" --dumpfile\tname of the dump file"); - System.out.println(" --histo\tto print histogram of java object heap"); - System.out.println(" --clstats\tto print class loader statistics"); - System.out.println(" --finalizerinfo\tto print information on objects awaiting finalization"); - return commonHelp(); + System.out.println(" <no option> \tTo print same info as Solaris pmap."); + System.out.println(" --heap \tTo print java heap summary."); + System.out.println(" --binaryheap \tTo dump java heap in hprof binary format."); + System.out.println(" --dumpfile <name>\tThe name of the dump file."); + System.out.println(" --histo \tTo print histogram of java object heap."); + System.out.println(" --clstats \tTo print class loader statistics."); + System.out.println(" --finalizerinfo \tTo print information on objects awaiting finalization."); + return commonHelp("jmap"); } private static boolean jstackHelp() { // --locks -> -l // --mixed -> -m - System.out.println(" --locks\tto print java.util.concurrent locks"); - System.out.println(" --mixed\tto print both java and native frames (mixed mode)"); - return commonHelp(); + System.out.println(" --locks \tTo print java.util.concurrent locks."); + System.out.println(" --mixed \tTo print both Java and native frames (mixed mode)."); + return commonHelp("jstack"); } private static boolean jsnapHelp() { - System.out.println(" --all\tto print all performance counters"); - return commonHelp(); + System.out.println(" --all \tTo print all performance counters."); + return commonHelp("jsnap"); } private static boolean toolHelp(String toolName) { @@ -117,8 +125,11 @@ private static boolean toolHelp(String toolName) { if (toolName.equals("debugd")) { return debugdHelp(); } - if (toolName.equals("hsdb") || toolName.equals("clhsdb")) { - return commonHelp(); + if (toolName.equals("hsdb")) { + return commonHelp("hsdb"); + } + if (toolName.equals("clhsdb")) { + return commonHelp("clhsdb"); } return launcherHelp(); } diff --git a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java index cc71287e3fc..9963b196354 100644 --- a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java +++ b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64CurrentFrameGuess.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, Red Hat Inc. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -223,7 +223,13 @@ public boolean run(long regionInBytesToSearch) { } } - setValues(sp, fp, null); + // We found a PC in the frame anchor. Check that it's plausible, and + // if it is, use it. + if (vm.isJavaPCDbg(pc)) { + setValues(sp, fp, pc); + } else { + setValues(sp, fp, null); + } return true; } diff --git a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java index 80b6c79e608..a3c25f5b634 100644 --- a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java +++ b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, Red Hat Inc. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -136,7 +136,15 @@ public AARCH64Frame(Address raw_sp, Address raw_fp) { this.raw_sp = raw_sp; this.raw_unextendedSP = raw_sp; this.raw_fp = raw_fp; - this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize()); + + // We cannot assume SP[-1] always contains a valid return PC (e.g. if + // the callee is a C/C++ compiled frame). If the PC is not known to + // Java then this.pc is null. + Address savedPC = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize()); + if (VM.getVM().isJavaPCDbg(savedPC)) { + this.pc = savedPC; + } + adjustUnextendedSP(); // Frame must be fully constructed before this call diff --git a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java index 49849f9240c..b2d1119508b 100644 --- a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java +++ b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java @@ -51,14 +51,12 @@ public class PPC64Frame extends Frame { private static final int INTERPRETER_FRAME_MDX_OFFSET = INTERPRETER_FRAME_LAST_SP_OFFSET -1; private static final int INTERPRETER_FRAME_ESP_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1; private static final int INTERPRETER_FRAME_BCX_OFFSET = INTERPRETER_FRAME_ESP_OFFSET - 1; - private static final int INTERPRETER_FRAME_CACHE_OFFSET =INTERPRETER_FRAME_BCX_OFFSET - 1; + private static final int INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_BCX_OFFSET - 1; private static final int INTERPRETER_FRAME_MONITORS_OFFSET = INTERPRETER_FRAME_CACHE_OFFSET - 1; private static final int INTERPRETER_FRAME_LOCALS_OFFSET = INTERPRETER_FRAME_MONITORS_OFFSET - 1; private static final int INTERPRETER_FRAME_MIRROR_OFFSET = INTERPRETER_FRAME_LOCALS_OFFSET - 1; private static final int INTERPRETER_FRAME_METHOD_OFFSET = INTERPRETER_FRAME_MIRROR_OFFSET - 1; - private static final int INTERPRETER_FRAME_INITIAL_SP_OFFSET = INTERPRETER_FRAME_BCX_OFFSET - 1; // FIXME: probably wrong, but unused anyway - private static final int INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET; - private static final int INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET; + private static final int INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1; // Entry frames private static int ENTRY_FRAME_CALL_WRAPPER_OFFSET; @@ -444,7 +442,7 @@ public BasicObjectLock interpreterFrameMonitorBegin() { } public BasicObjectLock interpreterFrameMonitorEnd() { - Address result = addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET).getAddressAt(0); + Address result = addressOfStackSlot(INTERPRETER_FRAME_MONITORS_OFFSET).getAddressAt(0); if (Assert.ASSERTS_ENABLED) { // make sure the pointer points inside the frame Assert.that(AddressOps.gt(getFP(), result), "result must < than frame pointer"); diff --git a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java index d329fa441c3..adef5e43901 100644 --- a/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java +++ b/src/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java @@ -1066,10 +1066,15 @@ public void visit(Symbol sym) { } private void writeSymbol(Symbol sym) throws IOException { - byte[] buf = sym.asString().getBytes("UTF-8"); - writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE); - writeSymbolID(sym); - out.write(buf); + if(sym != null) { + byte[] buf = sym.asString().getBytes("UTF-8"); + writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE); + writeSymbolID(sym); + out.write(buf); + } else { + writeHeader(HPROF_UTF8, 0 + OBJ_ID_SIZE); + writeSymbolID(null); + } } private void writeClasses() throws IOException { @@ -1118,7 +1123,8 @@ private void writeObjectID(Oop oop) throws IOException { } private void writeSymbolID(Symbol sym) throws IOException { - writeObjectID(getAddressValue(sym.getAddress())); + long address = (sym != null) ? getAddressValue(sym.getAddress()) : getAddressValue(null); + writeObjectID(address); } private void writeObjectID(long address) throws IOException { diff --git a/src/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavaScriptScanner.java b/src/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavaScriptScanner.java index 9de049515bf..4afd46b74c1 100644 --- a/src/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavaScriptScanner.java +++ b/src/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavaScriptScanner.java @@ -69,12 +69,10 @@ static class ParseException extends Exception { private boolean newline = true; Map<String, TagParser> tagParsers; - Set<String> eventAttrs; Set<String> uriAttrs; public JavaScriptScanner() { initTagParsers(); - initEventAttrs(); initURIAttrs(); } @@ -101,7 +99,10 @@ private void checkHtmlTag(String tag) { private void checkHtmlAttr(String name, String value) { String n = name.toLowerCase(Locale.ENGLISH); - if (eventAttrs.contains(n) + // See https://www.w3.org/TR/html52/webappapis.html#events-event-handlers + // An event handler has a name, which always starts with "on" and is followed by + // the name of the event for which it is intended. + if (n.startsWith("on") || uriAttrs.contains(n) && value != null && value.toLowerCase(Locale.ENGLISH).trim().startsWith("javascript:")) { reporter.report(); @@ -1061,34 +1062,6 @@ public void parse(int pos) { } - private void initEventAttrs() { - eventAttrs = new HashSet<>(Arrays.asList( - // See https://www.w3.org/TR/html-markup/global-attributes.html#common.attrs.event-handler - "onabort", "onblur", "oncanplay", "oncanplaythrough", - "onchange", "onclick", "oncontextmenu", "ondblclick", - "ondrag", "ondragend", "ondragenter", "ondragleave", - "ondragover", "ondragstart", "ondrop", "ondurationchange", - "onemptied", "onended", "onerror", "onfocus", "oninput", - "oninvalid", "onkeydown", "onkeypress", "onkeyup", - "onload", "onloadeddata", "onloadedmetadata", "onloadstart", - "onmousedown", "onmousemove", "onmouseout", "onmouseover", - "onmouseup", "onmousewheel", "onpause", "onplay", - "onplaying", "onprogress", "onratechange", "onreadystatechange", - "onreset", "onscroll", "onseeked", "onseeking", - "onselect", "onshow", "onstalled", "onsubmit", "onsuspend", - "ontimeupdate", "onvolumechange", "onwaiting", - - // See https://www.w3.org/TR/html4/sgml/dtd.html - // Most of the attributes that take a %Script are also defined as event handlers - // in HTML 5. The one exception is onunload. - // "onchange", "onclick", "ondblclick", "onfocus", - // "onkeydown", "onkeypress", "onkeyup", "onload", - // "onmousedown", "onmousemove", "onmouseout", "onmouseover", - // "onmouseup", "onreset", "onselect", "onsubmit", - "onunload" - )); - } - private void initURIAttrs() { uriAttrs = new HashSet<>(Arrays.asList( // See https://www.w3.org/TR/html4/sgml/dtd.html diff --git a/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java b/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java index 8699bed356b..9504488aaf0 100644 --- a/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java +++ b/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/JavaScriptScanner.java @@ -61,34 +61,8 @@ public Void visitStartElement(StartElementTree tree, Consumer<DocTreePath> f) { public Void visitAttribute(AttributeTree tree, Consumer<DocTreePath> f) { String name = tree.getName().toString().toLowerCase(Locale.ENGLISH); switch (name) { - // See https://www.w3.org/TR/html-markup/global-attributes.html#common.attrs.event-handler - case "onabort": case "onblur": case "oncanplay": case "oncanplaythrough": - case "onchange": case "onclick": case "oncontextmenu": case "ondblclick": - case "ondrag": case "ondragend": case "ondragenter": case "ondragleave": - case "ondragover": case "ondragstart": case "ondrop": case "ondurationchange": - case "onemptied": case "onended": case "onerror": case "onfocus": case "oninput": - case "oninvalid": case "onkeydown": case "onkeypress": case "onkeyup": - case "onload": case "onloadeddata": case "onloadedmetadata": case "onloadstart": - case "onmousedown": case "onmousemove": case "onmouseout": case "onmouseover": - case "onmouseup": case "onmousewheel": case "onpause": case "onplay": - case "onplaying": case "onprogress": case "onratechange": case "onreadystatechange": - case "onreset": case "onscroll": case "onseeked": case "onseeking": - case "onselect": case "onshow": case "onstalled": case "onsubmit": case "onsuspend": - case "ontimeupdate": case "onvolumechange": case "onwaiting": - - // See https://www.w3.org/TR/html4/sgml/dtd.html - // Most of the attributes that take a %Script are also defined as event handlers - // in HTML 5. The one exception is onunload. - // case "onchange": case "onclick": case "ondblclick": case "onfocus": - // case "onkeydown": case "onkeypress": case "onkeyup": case "onload": - // case "onmousedown": case "onmousemove": case "onmouseout": case "onmouseover": - // case "onmouseup": case "onreset": case "onselect": case "onsubmit": - case "onunload": - f.accept(getCurrentPath()); - break; - // See https://www.w3.org/TR/html4/sgml/dtd.html - // https://www.w3.org/TR/html5/ + // https://www.w3.org/TR/html52/fullindex.html#attributes-table // These are all the attributes that take a %URI or a valid URL potentially surrounded // by spaces case "action": case "cite": case "classid": case "codebase": case "data": @@ -102,6 +76,14 @@ public Void visitAttribute(AttributeTree tree, Consumer<DocTreePath> f) { } } break; + // See https://www.w3.org/TR/html52/webappapis.html#events-event-handlers + // An event handler has a name, which always starts with "on" and is followed by + // the name of the event for which it is intended. + default: + if (name.startsWith("on")) { + f.accept(getCurrentPath()); + } + break; } return super.visitAttribute(tree, f); } diff --git a/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index 02fa9aefe01..f2418d46a07 100644 --- a/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/src/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -54,6 +54,7 @@ import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.jvm.Target; import com.sun.tools.javac.main.Arguments; import com.sun.tools.javac.main.CommandLine; import com.sun.tools.javac.main.OptionHelper; @@ -549,6 +550,11 @@ private Result parseAndExecute(List<String> argList, Iterable<? extends JavaFile ((BaseFileManager) fileManager).handleOptions(fileManagerOpts); } + if (fileManager.isSupportedOption(MULTIRELEASE.primaryName) == 1) { + Target target = Target.instance(context); + List<String> list = List.of(target.multiReleaseValue()); + fileManager.handleOption(MULTIRELEASE.primaryName, list.iterator()); + } compOpts.notifyListeners(); List<String> modules = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.MODULE, s -> Collections.EMPTY_LIST); diff --git a/src/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java b/src/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java new file mode 100644 index 00000000000..4e9abb45678 --- /dev/null +++ b/src/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.tools; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.stream.Stream; + +/** + * A helper class that retrieves the main class name for + * a running Java process using the proc filesystem (procfs) + */ +public class ProcessHelper implements sun.tools.common.ProcessHelper { + + + private static final String CMD_PREFIX = "cmd:"; + private static final ProcessHelper INSTANCE = new ProcessHelper(); + + public static ProcessHelper getInstance() { + return INSTANCE; + } + + /** + * Gets the main class name for the given Java process by parsing the + * process command line. If the application was started with the <em>-jar</em> + * option this method returns the name of the jar file. If the application + * was started with <em>-m</em> or <em>--module</em> option, the method returns + * the module name and the main class name. + * @param pid - process ID (pid) + * @return the main class name or null if the process no longer exists or + * was started with a native launcher (e.g. jcmd etc) + */ + + public String getMainClass(String pid) { + String cmdLine = getCommandLine(pid); + if (cmdLine == null) { + return null; + } + if (cmdLine.startsWith(CMD_PREFIX)) { + cmdLine = cmdLine.substring(CMD_PREFIX.length()); + } + String[] parts = cmdLine.split("\0"); + String mainClass = null; + + if(parts.length == 0) { + return null; + } + + // Check the executable + String[] executablePath = parts[0].split("/"); + if (executablePath.length > 0) { + String binaryName = executablePath[executablePath.length - 1]; + if (!"java".equals(binaryName)) { + // Skip the process if it is not started with java launcher + return null; + } + } + + // To be consistent with the behavior on other platforms, if -jar, -m, or --module + // options are used then just return the value (the path to the jar file or module + // name with a main class). Otherwise, the main class name is the first part that + // is not a Java option (doesn't start with '-' and is not a classpath or a module + // whitespace option). + + for (int i = 1; i < parts.length && mainClass == null; i++) { + if (i < parts.length - 1) { + if (parts[i].equals("-m") || parts[i].equals("--module") || parts[i].equals("-jar")) { + return parts[i + 1]; + } + } + + if (parts[i].startsWith("--module=")) { + return parts[i].substring("--module=".length()); + } + + // If this is a classpath or a module whitespace option then skip the next part + // (the classpath or the option value itself) + if (parts[i].equals("-cp") || parts[i].equals("-classpath") || parts[i].equals("--class-path") || + isModuleWhiteSpaceOption(parts[i])) { + i++; + continue; + } + // Skip all other Java options + if (parts[i].startsWith("-")) { + continue; + } + + // If it is a source-file mode then return null + if (parts[i].endsWith(".java")) { + return null; + } + + mainClass = parts[i]; + } + return mainClass; + + } + + private static String getCommandLine(String pid) { + try (Stream<String> lines = + Files.lines(Paths.get("/proc/" + pid + "/cmdline"))) { + return lines.findFirst().orElse(null); + } catch (IOException | UncheckedIOException e) { + return null; + } + } + + private static boolean isModuleWhiteSpaceOption(String option) { + return option.equals("-p") || + option.equals("--module-path") || + option.equals("--upgrade-module-path") || + option.equals("--add-modules") || + option.equals("--limit-modules") || + option.equals("--add-exports") || + option.equals("--add-opens") || + option.equals("--add-reads") || + option.equals("--patch-module"); + } + +} + + diff --git a/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java b/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java index d8e44d385ab..496bcf7033b 100644 --- a/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java +++ b/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessArgumentMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -78,25 +78,37 @@ private static String getExcludeStringFrom(Class<?> excludeClass) { } private static boolean check(VirtualMachineDescriptor vmd, String excludeClass, String partialMatch) { + String mainClass = null; - try { - VmIdentifier vmId = new VmIdentifier(vmd.id()); - MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId); - MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1); - mainClass = MonitoredVmUtil.mainClass(monitoredVm, true); - monitoredHost.detach(monitoredVm); - } catch (NullPointerException npe) { - // There is a potential race, where a running java app is being - // queried, unfortunately the java app has shutdown after this - // method is started but before getMonitoredVM is called. - // If this is the case, then the /tmp/hsperfdata_xxx/pid file - // will have disappeared and we will get a NullPointerException. - // Handle this gracefully.... - return false; - } catch (MonitorException | URISyntaxException e) { - return false; + + // Get the main class name using platform specific helper + ProcessHelper helper = ProcessHelper.platformProcessHelper(); + if (helper != null) { + mainClass = helper.getMainClass(vmd.id()); } + // If the main class name is still unset then retrieve it with the attach mechanism + if (mainClass == null) { + try { + VmIdentifier vmId = new VmIdentifier(vmd.id()); + MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId); + MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1); + mainClass = MonitoredVmUtil.mainClass(monitoredVm, true); + monitoredHost.detach(monitoredVm); + } catch (NullPointerException npe) { + // There is a potential race, where a running java app is being + // queried, unfortunately the java app has shutdown after this + // method is started but before getMonitoredVM is called. + // If this is the case, then the /tmp/hsperfdata_xxx/pid file + // will have disappeared and we will get a NullPointerException. + // Handle this gracefully.... + return false; + } catch (MonitorException | URISyntaxException e) { + return false; + } + } + + if (excludeClass != null && mainClass.equals(excludeClass)) { return false; } diff --git a/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java b/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java new file mode 100644 index 00000000000..d0f2d69bc16 --- /dev/null +++ b/src/src/jdk.jcmd/share/classes/sun/tools/common/ProcessHelper.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.tools.common; + +import java.lang.reflect.Method; + +/** + * A helper class to retrieve the main class name for a running + * Java process. + */ + +public interface ProcessHelper { + + /** + * Returns an instance of the ProcessHelper class. + * + * @return ProcessHelper object or null if not supported on this platform. + */ + public static ProcessHelper platformProcessHelper() { + try { + Class<?> c = Class.forName("sun.tools.ProcessHelper"); + @SuppressWarnings("unchecked") + Method m = c.getMethod("getInstance"); + return (ProcessHelper) m.invoke(null); + } catch (ClassNotFoundException e) { + return null; + } catch (ReflectiveOperationException e) { + throw new InternalError(e); + } + } + + + /** + * Returns the main class name for the given Java process + * + * @param pid - process ID (pid) + * @return main class name or null if the main class could not be retrieved + */ + + String getMainClass(String pid); +} diff --git a/src/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java b/src/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java index 4a625a7d720..8ae45029e49 100644 --- a/src/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java +++ b/src/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2019, 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 @@ -30,6 +30,7 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.Set; import com.sun.tools.classfile.AccessFlags; import com.sun.tools.classfile.Attribute; @@ -471,6 +472,9 @@ protected void writeMethods() { setPendingNewline(false); } + private static final int DEFAULT_ALLOWED_MAJOR_VERSION = 52; + private static final int DEFAULT_ALLOWED_MINOR_VERSION = 0; + protected void writeMethod(Method m) { if (!options.checkAccess(m.access_flags)) return; @@ -504,11 +508,24 @@ protected void writeMethod(Method m) { } } - writeModifiers(flags.getMethodModifiers()); + Set<String> modifiers = flags.getMethodModifiers(); + + String name = getName(m); + if (classFile.isInterface() && + (!flags.is(AccessFlags.ACC_ABSTRACT)) && !name.equals("<clinit>")) { + if (classFile.major_version > DEFAULT_ALLOWED_MAJOR_VERSION || + (classFile.major_version == DEFAULT_ALLOWED_MAJOR_VERSION && classFile.minor_version >= DEFAULT_ALLOWED_MINOR_VERSION)) { + if (!flags.is(AccessFlags.ACC_STATIC | AccessFlags.ACC_PRIVATE)) { + modifiers.add("default"); + } + } + } + + writeModifiers(modifiers); if (methodType != null) { print(new JavaTypePrinter(false).printTypeArgs(methodType.typeParamTypes)); } - switch (getName(m)) { + switch (name) { case "<init>": print(getJavaName(classFile)); print(getJavaParameterTypes(d, flags)); @@ -519,7 +536,7 @@ protected void writeMethod(Method m) { default: print(getJavaReturnType(d)); print(" "); - print(getName(m)); + print(name); print(getJavaParameterTypes(d, flags)); break; } diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/Event.java b/src/src/jdk.jfr/share/classes/jdk/jfr/Event.java index d3f8c8bdb26..9a6ddaa02f4 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/Event.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/Event.java @@ -88,7 +88,7 @@ @Enabled(true) @StackTrace(true) @Registered(true) -abstract public class Event { +abstract public class Event extends jdk.internal.event.Event { /** * Sole constructor, for invocation by subclass constructors, typically * implicit. diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/events/CertificateId.java b/src/src/jdk.jfr/share/classes/jdk/jfr/events/CertificateId.java new file mode 100644 index 00000000000..eb95cd4348a --- /dev/null +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/events/CertificateId.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.events; + +import jdk.jfr.Label; +import jdk.jfr.Relational; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Label("X509 Certificate Id") +@Relational +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface CertificateId { +} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java b/src/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java new file mode 100644 index 00000000000..e56310210de --- /dev/null +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.events; + +import jdk.jfr.*; +import jdk.jfr.internal.MirrorEvent; + +@Category({"Java Development Kit", "Security"}) +@Label("Security Property Modification") +@Name("jdk.SecurityPropertyModification") +@Description("Modification of Security property") +@MirrorEvent(className = "jdk.internal.event.SecurityPropertyModificationEvent") +public final class SecurityPropertyModificationEvent extends AbstractJDKEvent { + @Label("Key") + public String key; + + @Label("Value") + public String value; +} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java b/src/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java new file mode 100644 index 00000000000..e45d491ce77 --- /dev/null +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.events; + +import jdk.jfr.Category; +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.internal.MirrorEvent; + +@Category({"Java Development Kit", "Security"}) +@Label("TLS Handshake") +@Name("jdk.TLSHandshake") +@Description("Parameters used in TLS Handshake") +@MirrorEvent(className = "jdk.internal.event.TLSHandshakeEvent") +public final class TLSHandshakeEvent extends AbstractJDKEvent { + @Label("Peer Host") + public String peerHost; + + @Label("Peer Port") + public int peerPort; + + @Label("Protocol Version") + public String protocolVersion; + + @Label("Cipher Suite") + public String cipherSuite; + + @Label("Certificate Id") + @Description("Peer Certificate Id") + @CertificateId + public long certificateId; +} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/events/X509CertificateEvent.java b/src/src/jdk.jfr/share/classes/jdk/jfr/events/X509CertificateEvent.java new file mode 100644 index 00000000000..7efb5d6d804 --- /dev/null +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/events/X509CertificateEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.events; + +import jdk.jfr.*; +import jdk.jfr.internal.MirrorEvent; + +@Category({"Java Development Kit", "Security"}) +@Label("X509 Certificate") +@Name("jdk.X509Certificate") +@Description("Details of X.509 Certificate parsed by JDK") +@MirrorEvent(className = "jdk.internal.event.X509CertificateEvent") +public final class X509CertificateEvent extends AbstractJDKEvent { + @Label("Signature Algorithm") + public String algorithm; + + @Label("Serial Number") + public String serialNumber; + + @Label("Subject") + public String subject; + + @Label("Issuer") + public String issuer; + + @Label("Key Type") + public String keyType; + + @Label("Key Length") + public int keyLength; + + @Label("Certificate Id") + @CertificateId + public long certificateId; + + @Label("Valid From") + @Timestamp(Timestamp.MILLISECONDS_SINCE_EPOCH) + public long validFrom; + + @Label("Valid Until") + @Timestamp(Timestamp.MILLISECONDS_SINCE_EPOCH) + public long validUntil; +} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/events/X509ValidationEvent.java b/src/src/jdk.jfr/share/classes/jdk/jfr/events/X509ValidationEvent.java new file mode 100644 index 00000000000..dd93510b30c --- /dev/null +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/events/X509ValidationEvent.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.events; + +import jdk.jfr.*; +import jdk.jfr.internal.MirrorEvent; + +@Category({"Java Development Kit", "Security"}) +@Label("X509 Validation") +@Name("jdk.X509Validation") +@Description("Serial numbers from X.509 Certificates forming chain of trust") +@MirrorEvent(className = "jdk.internal.event.X509ValidationEvent") +public final class X509ValidationEvent extends AbstractJDKEvent { + @CertificateId + @Label("Certificate Id") + public long certificateId; + + @Label("Certificate Position") + @Description("Certificate position in chain of trust, 1 = trust anchor") + public int certificatePosition; + + @Label("Validation Counter") + public long validationCounter; +} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java index 7a2098ab046..2ead6c8c565 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java @@ -41,7 +41,6 @@ import jdk.internal.module.Modules; import jdk.jfr.AnnotationElement; import jdk.jfr.Enabled; -import jdk.jfr.Event; import jdk.jfr.Name; import jdk.jfr.Period; import jdk.jfr.SettingControl; @@ -109,7 +108,7 @@ static void remove(PlatformEventType type, List<AnnotationElement> aes, Class<? } } - EventControl(PlatformEventType es, Class<? extends Event> eventClass) { + EventControl(PlatformEventType es, Class<? extends jdk.internal.event.Event> eventClass) { this(es); defineSettings(eventClass); } diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventHandlerCreator.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventHandlerCreator.java index 0d5fe27ddbc..dcbc8bd24c5 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventHandlerCreator.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventHandlerCreator.java @@ -93,11 +93,11 @@ public static String makeEventHandlerName(long id) { return EventHandler.class.getName() + id + SUFFIX; } - public EventHandlerCreator(long id, List<SettingInfo> settingInfos, EventType type, Class<? extends Event> eventClass) { + public EventHandlerCreator(long id, List<SettingInfo> settingInfos, EventType type, Class<? extends jdk.internal.event.Event> eventClass) { this(id, settingInfos, createFieldInfos(eventClass, type)); } - private static List<FieldInfo> createFieldInfos(Class<? extends Event> eventClass, EventType type) throws Error { + private static List<FieldInfo> createFieldInfos(Class<? extends jdk.internal.event.Event> eventClass, EventType type) throws Error { List<FieldInfo> fieldInfos = new ArrayList<>(); for (ValueDescriptor v : type.getFields()) { // Only value descriptors that are not fields on the event class. diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java index 8b365458716..c2945f3ae9d 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java @@ -102,6 +102,7 @@ public boolean isString() { private static final Type ANNOTATION_TYPE_ENABLED = Type.getType(Enabled.class); private static final Type TYPE_EVENT_HANDLER = Type.getType(EventHandler.class); private static final Type TYPE_SETTING_CONTROL = Type.getType(SettingControl.class); + private static final Type TYPE_OBJECT = Type.getType(Object.class); private static final Method METHOD_COMMIT = new Method("commit", Type.VOID_TYPE, new Type[0]); private static final Method METHOD_BEGIN = new Method("begin", Type.VOID_TYPE, new Type[0]); private static final Method METHOD_END = new Method("end", Type.VOID_TYPE, new Type[0]); @@ -117,6 +118,7 @@ public boolean isString() { private final Method writeMethod; private final String eventHandlerXInternalName; private final String eventName; + private final boolean untypedEventHandler; private boolean guardHandlerReference; private Class<?> superClass; @@ -125,11 +127,20 @@ public boolean isString() { this.classNode = createClassNode(bytes); this.settingInfos = buildSettingInfos(superClass, classNode); this.fieldInfos = buildFieldInfos(superClass, classNode); + this.untypedEventHandler = hasUntypedHandler(); this.writeMethod = makeWriteMethod(fieldInfos); this.eventHandlerXInternalName = ASMToolkit.getInternalName(EventHandlerCreator.makeEventHandlerName(id)); String n = annotationValue(classNode, ANNOTATION_TYPE_NAME.getDescriptor(), String.class); this.eventName = n == null ? classNode.name.replace("/", ".") : n; + } + private boolean hasUntypedHandler() { + for (FieldNode field : classNode.fields) { + if (FIELD_EVENT_HANDLER.equals(field.name)) { + return field.desc.equals(TYPE_OBJECT.getDescriptor()); + } + } + throw new InternalError("Class missing handler field"); } public String getClassName() { @@ -225,7 +236,7 @@ private static List<SettingInfo> buildSettingInfos(Class<?> superClass, ClassNod } } } - for (Class<?> c = superClass; c != Event.class; c = c.getSuperclass()) { + for (Class<?> c = superClass; c != jdk.internal.event.Event.class; c = c.getSuperclass()) { for (java.lang.reflect.Method method : c.getDeclaredMethods()) { if (!methodSet.contains(method.getName())) { // skip private method in base classes @@ -249,7 +260,6 @@ private static List<SettingInfo> buildSettingInfos(Class<?> superClass, ClassNod } } return settingInfos; - } private static List<FieldInfo> buildFieldInfos(Class<?> superClass, ClassNode classNode) { @@ -264,14 +274,13 @@ private static List<FieldInfo> buildFieldInfos(Class<?> superClass, ClassNode cl fieldInfos.add(new FieldInfo("startTime", Type.LONG_TYPE.getDescriptor(), classNode.name)); fieldInfos.add(new FieldInfo("duration", Type.LONG_TYPE.getDescriptor(), classNode.name)); for (FieldNode field : classNode.fields) { - String className = Type.getType(field.desc).getClassName(); - if (!fieldSet.contains(field.name) && isValidField(field.access, className)) { + if (!fieldSet.contains(field.name) && isValidField(field.access, Type.getType(field.desc).getClassName())) { FieldInfo fi = new FieldInfo(field.name, field.desc, classNode.name); fieldInfos.add(fi); fieldSet.add(field.name); } } - for (Class<?> c = superClass; c != Event.class; c = c.getSuperclass()) { + for (Class<?> c = superClass; c != jdk.internal.event.Event.class; c = c.getSuperclass()) { for (Field field : c.getDeclaredFields()) { // skip private field in base classes if (!Modifier.isPrivate(field.getModifiers())) { @@ -321,10 +330,10 @@ private void makeInstrumented() { updateMethod(METHOD_IS_ENABLED, methodVisitor -> { Label nullLabel = new Label(); if (guardHandlerReference) { - methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, TYPE_EVENT_HANDLER.getDescriptor()); + getEventHandler(methodVisitor); methodVisitor.visitJumpInsn(Opcodes.IFNULL, nullLabel); } - methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, TYPE_EVENT_HANDLER.getDescriptor()); + getEventHandler(methodVisitor); ASMToolkit.invokeVirtual(methodVisitor, TYPE_EVENT_HANDLER.getInternalName(), METHOD_IS_ENABLED); methodVisitor.visitInsn(Opcodes.IRETURN); if (guardHandlerReference) { @@ -408,7 +417,7 @@ private void makeInstrumented() { // eventHandler.write(...); // } methodVisitor.visitJumpInsn(Opcodes.IFEQ, end); - methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, Type.getDescriptor(EventHandler.class)); + getEventHandler(methodVisitor); methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName); for (FieldInfo fi : fieldInfos) { @@ -426,8 +435,12 @@ private void makeInstrumented() { // MyEvent#shouldCommit() updateMethod(METHOD_EVENT_SHOULD_COMMIT, methodVisitor -> { Label fail = new Label(); - // if (!eventHandler.shoouldCommit(duration) goto fail; - methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, Type.getDescriptor(EventHandler.class)); + if (guardHandlerReference) { + getEventHandler(methodVisitor); + methodVisitor.visitJumpInsn(Opcodes.IFNULL, fail); + } + // if (!eventHandler.shouldCommit(duration) goto fail; + getEventHandler(methodVisitor); methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_DURATION, "J"); ASMToolkit.invokeVirtual(methodVisitor, TYPE_EVENT_HANDLER.getInternalName(), METHOD_EVENT_HANDLER_SHOULD_COMMIT); @@ -435,7 +448,11 @@ private void makeInstrumented() { for (SettingInfo si : settingInfos) { // if (!settingsMethod(eventHandler.settingX)) goto fail; methodVisitor.visitIntInsn(Opcodes.ALOAD, 0); - methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, Type.getDescriptor(EventHandler.class)); + if (untypedEventHandler) { + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, TYPE_OBJECT.getDescriptor()); + } else { + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, Type.getDescriptor(EventHandler.class)); + } methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName); methodVisitor.visitFieldInsn(Opcodes.GETFIELD, eventHandlerXInternalName, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor()); methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, si.internalSettingName); @@ -452,6 +469,15 @@ private void makeInstrumented() { }); } + private void getEventHandler(MethodVisitor methodVisitor) { + if (untypedEventHandler) { + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, TYPE_OBJECT.getDescriptor()); + methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, TYPE_EVENT_HANDLER.getInternalName()); + } else { + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, Type.getDescriptor(EventHandler.class)); + } + } + private void makeUninstrumented() { updateExistingWithReturnFalse(METHOD_EVENT_SHOULD_COMMIT); updateExistingWithReturnFalse(METHOD_IS_ENABLED); diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java index 885b274da22..e9f6d2a9a60 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java @@ -106,11 +106,11 @@ private JVM() { public native void endRecording(); /** - * Return a list of all classes deriving from {@link Event} + * Return a list of all classes deriving from {@link jdk.internal.event.Event} * * @return list of event classes. */ - public native List<Class<? extends Event>> getAllEventClasses(); + public native List<Class<? extends jdk.internal.event.Event>> getAllEventClasses(); /** * Return a count of the number of unloaded classes deriving from {@link Event} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java index 37071aafbd3..9e8ce2e4de6 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java @@ -26,7 +26,6 @@ import java.lang.reflect.Modifier; -import jdk.jfr.Event; import jdk.jfr.internal.handlers.EventHandler; import jdk.jfr.internal.instrument.JDKEvents; @@ -53,8 +52,8 @@ final class JVMUpcalls { */ static byte[] onRetransform(long traceId, boolean dummy, Class<?> clazz, byte[] oldBytes) throws Throwable { try { - if (Event.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) { - EventHandler handler = Utils.getHandler(clazz.asSubclass(Event.class)); + if (jdk.internal.event.Event.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) { + EventHandler handler = Utils.getHandler(clazz.asSubclass(jdk.internal.event.Event.class)); if (handler == null) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "No event handler found for " + clazz.getName() + ". Ignoring instrumentation request."); // Probably triggered by some other agent diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java index b0b0db71ddb..d27b2cd655c 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -56,6 +57,7 @@ public final class MetadataRepository { private final List<EventControl> nativeControls = new ArrayList<EventControl>(100); private final TypeLibrary typeLibrary = TypeLibrary.getInstance(); private final SettingsManager settingsManager = new SettingsManager(); + private final Map<String, Class<? extends Event>> mirrors = new HashMap<>(); private boolean staleMetadata = true; private boolean unregistered; private long lastUnloaded = -1; @@ -105,7 +107,7 @@ public synchronized List<EventType> getRegisteredEventTypes() { return eventTypes; } - public synchronized EventType getEventType(Class<? extends Event> eventClass) { + public synchronized EventType getEventType(Class<? extends jdk.internal.event.Event> eventClass) { EventHandler h = getHandler(eventClass); if (h != null && h.isRegistered()) { return h.getEventType(); @@ -121,15 +123,20 @@ public synchronized void unregister(Class<? extends Event> eventClass) { } // never registered, ignore call } - public synchronized EventType register(Class<? extends Event> eventClass) { + public synchronized EventType register(Class<? extends jdk.internal.event.Event> eventClass) { return register(eventClass, Collections.emptyList(), Collections.emptyList()); } - public synchronized EventType register(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) { + public synchronized EventType register(Class<? extends jdk.internal.event.Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) { Utils.checkRegisterPermission(); EventHandler handler = getHandler(eventClass); if (handler == null) { - handler = makeHandler(eventClass, dynamicAnnotations, dynamicFields); + if (eventClass.getAnnotation(MirrorEvent.class) != null) { + // don't register mirrors + return null; + } + PlatformEventType pe = findMirrorType(eventClass); + handler = makeHandler(eventClass, pe, dynamicAnnotations, dynamicFields); } handler.setRegistered(true); typeLibrary.addType(handler.getPlatformEventType()); @@ -143,16 +150,32 @@ public synchronized EventType register(Class<? extends Event> eventClass, List<A return handler.getEventType(); } - private EventHandler getHandler(Class<? extends Event> eventClass) { + private PlatformEventType findMirrorType(Class<? extends jdk.internal.event.Event> eventClass) throws InternalError { + String fullName = eventClass.getModule().getName() + ":" + eventClass.getName(); + Class<? extends Event> mirrorClass = mirrors.get(fullName); + if (mirrorClass == null) { + return null; // not a mirror + } + Utils.verifyMirror(mirrorClass, eventClass); + PlatformEventType et = (PlatformEventType) TypeLibrary.createType(mirrorClass); + typeLibrary.removeType(et.getId()); + long id = Type.getTypeId(eventClass); + et.setId(id); + return et; + } + + private EventHandler getHandler(Class<? extends jdk.internal.event.Event> eventClass) { Utils.ensureValidEventSubclass(eventClass); SecuritySupport.makeVisibleToJFR(eventClass); Utils.ensureInitialized(eventClass); return Utils.getHandler(eventClass); } - private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError { + private EventHandler makeHandler(Class<? extends jdk.internal.event.Event> eventClass, PlatformEventType pEventType, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError { SecuritySupport.addHandlerExport(eventClass); - PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields); + if (pEventType == null) { + pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields); + } EventType eventType = PrivateAccess.getInstance().newEventType(pEventType); EventControl ec = new EventControl(pEventType, eventClass); Class<? extends EventHandler> handlerClass = null; @@ -198,9 +221,9 @@ private void storeDescriptorInJVM() throws InternalError { } private static List<EventHandler> getEventHandlers() { - List<Class<? extends Event>> allEventClasses = jvm.getAllEventClasses(); + List<Class<? extends jdk.internal.event.Event>> allEventClasses = jvm.getAllEventClasses(); List<EventHandler> eventHandlers = new ArrayList<>(allEventClasses.size()); - for (Class<? extends Event> clazz : allEventClasses) { + for (Class<? extends jdk.internal.event.Event> clazz : allEventClasses) { EventHandler eh = Utils.getHandler(clazz); if (eh != null) { eventHandlers.add(eh); @@ -252,9 +275,9 @@ private void unregisterUnloaded() { long unloaded = jvm.getUnloadedEventClassCount(); if (this.lastUnloaded != unloaded) { this.lastUnloaded = unloaded; - List<Class<? extends Event>> eventClasses = jvm.getAllEventClasses(); + List<Class<? extends jdk.internal.event.Event>> eventClasses = jvm.getAllEventClasses(); HashSet<Long> knownIds = new HashSet<>(eventClasses.size()); - for (Class<? extends Event> ec: eventClasses) { + for (Class<? extends jdk.internal.event.Event> ec: eventClasses) { knownIds.add(Type.getTypeId(ec)); } for (Type type : typeLibrary.getTypes()) { @@ -270,8 +293,18 @@ private void unregisterUnloaded() { } } - synchronized public void setUnregistered() { + synchronized void setUnregistered() { unregistered = true; } + public synchronized void registerMirror(Class<? extends Event> eventClass) { + MirrorEvent me = eventClass.getAnnotation(MirrorEvent.class); + if (me != null) { + String fullName = me.module() + ":" + me.className(); + mirrors.put(fullName, eventClass); + return; + } + throw new InternalError("Mirror class must have annotation " + MirrorEvent.class.getName()); + } + } diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MirrorEvent.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MirrorEvent.java new file mode 100644 index 00000000000..79451c6d759 --- /dev/null +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/MirrorEvent.java @@ -0,0 +1,25 @@ +package jdk.jfr.internal; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.ElementType; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface MirrorEvent { + /** + * Fully qualified name of the class to mirror metadata for (for example, + * {@code "jdk.internal.event.Example"}) + * + * @return the fully qualified class name of the event + */ + String className(); + + /** + * The module where the event is located, by default {@code "java.base"}. + * + * @return the module name + */ + String module() default "java.base"; +} diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index cbea2e45aac..7c48fc26624 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -81,9 +81,7 @@ public PlatformRecorder() throws Exception { Logger.log(JFR_SYSTEM, INFO, "Registered JDK events"); JDKEvents.addInstrumentation(); startDiskMonitor(); - SecuritySupport.registerEvent(ActiveRecordingEvent.class); activeRecordingEvent = EventType.getEventType(ActiveRecordingEvent.class); - SecuritySupport.registerEvent(ActiveSettingEvent.class); activeSettingEvent = EventType.getEventType(ActiveSettingEvent.class); shutdownHook = SecuritySupport.createThreadWitNoPermissions("JFR: Shutdown Hook", new ShutdownHook(this)); SecuritySupport.setUncaughtExceptionHandler(shutdownHook, new ShutdownHook.ExceptionHandler()); @@ -91,6 +89,7 @@ public PlatformRecorder() throws Exception { timer = createTimer(); } + private static Timer createTimer() { try { List<Timer> result = new CopyOnWriteArrayList<>(); diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java index 74707121d37..e460430b459 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java @@ -318,7 +318,6 @@ public PlatformRecording newSnapshotClone(String reason, Boolean pathToGcRoots) PlatformRecording clone = recorder.newTemporaryRecording(); clone.setShouldWriteActiveRecordingEvent(false); clone.setName(getName()); - clone.setDestination(this.destination); clone.setToDisk(true); // We purposely don't clone settings here, since // a union a == a diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java index f8a57f6c9f0..23ff7c74a69 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java @@ -77,6 +77,14 @@ public final class SecuritySupport { static final SafePath USER_HOME = getPathInProperty("user.home", null); static final SafePath JAVA_IO_TMPDIR = getPathInProperty("java.io.tmpdir", null); + static { + // ensure module java.base can read module jdk.jfr as early as possible + addReadEdge(Object.class); + addHandlerExport(Object.class); + addEventsExport(Object.class); + addInstrumentExport(Object.class); + } + final static class SecureRecorderListener implements FlightRecorderListener { private final AccessControlContext context; @@ -260,8 +268,24 @@ static void addHandlerExport(Class<?> clazz) { Modules.addExports(JFR_MODULE, Utils.HANDLERS_PACKAGE_NAME, clazz.getModule()); } - public static void registerEvent(Class<? extends Event> eventClass) { - doPrivileged(() -> FlightRecorder.register(eventClass), new FlightRecorderPermission(Utils.REGISTER_EVENT)); + static void addEventsExport(Class<?> clazz) { + Modules.addExports(JFR_MODULE, Utils.EVENTS_PACKAGE_NAME, clazz.getModule()); + } + + static void addInstrumentExport(Class<?> clazz) { + Modules.addExports(JFR_MODULE, Utils.INSTRUMENT_PACKAGE_NAME, clazz.getModule()); + } + + static void addReadEdge(Class<?> clazz) { + Modules.addReads(clazz.getModule(), JFR_MODULE); + } + + public static void registerEvent(Class<? extends jdk.internal.event.Event> eventClass) { + doPrivileged(() -> MetadataRepository.getInstance().register(eventClass), new FlightRecorderPermission(Utils.REGISTER_EVENT)); + } + + public static void registerMirror(Class<? extends Event> eventClass) { + doPrivileged(() -> MetadataRepository.getInstance().registerMirror(eventClass), new FlightRecorderPermission(Utils.REGISTER_EVENT)); } static boolean getBooleanProperty(String propertyName) { diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SettingsManager.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SettingsManager.java index 592f216c186..29602bc9259 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SettingsManager.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/SettingsManager.java @@ -37,7 +37,6 @@ import java.util.Set; import java.util.StringJoiner; -import jdk.jfr.Event; import jdk.jfr.internal.handlers.EventHandler; final class SettingsManager { @@ -152,9 +151,9 @@ void setSettings(List<Map<String, String>> activeSettings) { } } - public void updateRetransform(List<Class<? extends Event>> eventClasses) { + public void updateRetransform(List<Class<? extends jdk.internal.event.Event>> eventClasses) { List<Class<?>> classes = new ArrayList<>(); - for(Class<? extends Event> eventClass: eventClasses) { + for(Class<? extends jdk.internal.event.Event> eventClass: eventClasses) { EventHandler eh = Utils.getHandler(eventClass); if (eh != null ) { PlatformEventType eventType = eh.getPlatformEventType(); diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java index 7bb57a18b1f..967e7e28274 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java @@ -71,10 +71,11 @@ public class Type implements Comparable<Type> { private final String name; private final String superType; private final boolean constantPool; - private final long id; private final ArrayList<ValueDescriptor> fields = new ArrayList<>(); private Boolean simpleType; // calculated lazy private boolean remove = true; + private long id; + /** * Creates a type * @@ -318,4 +319,8 @@ public void setRemove(boolean remove) { public boolean getRemove() { return remove; } + + public void setId(long id) { + this.id = id; + } } diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java index 40544e944b4..a511bd03198 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java @@ -49,7 +49,6 @@ import jdk.jfr.AnnotationElement; import jdk.jfr.Description; -import jdk.jfr.Event; import jdk.jfr.Label; import jdk.jfr.MetadataDefinition; import jdk.jfr.Name; @@ -240,7 +239,7 @@ public static Type createType(Class<?> clazz, List<AnnotationElement> dynamicAnn // STRUCT String superType = null; boolean eventType = false; - if (Event.class.isAssignableFrom(clazz)) { + if (jdk.internal.event.Event.class.isAssignableFrom(clazz)) { superType = Type.SUPER_TYPE_EVENT; eventType= true; } @@ -489,4 +488,8 @@ private static void visitAnnotations(Queue<Type> typeQ, List<AnnotationElement> aQ.addAll(ae.getAnnotationElements()); } } + + public void removeType(long id) { + types.remove(id); + } } diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java index 9c2a858fbb4..997b4bdb2a4 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java @@ -313,7 +313,7 @@ static long nanosToTicks(long nanos) { return (long) (nanos * JVM.getJVM().getTimeConversionFactor()); } - static synchronized EventHandler getHandler(Class<? extends Event> eventClass) { + static synchronized EventHandler getHandler(Class<? extends jdk.internal.event.Event> eventClass) { Utils.ensureValidEventSubclass(eventClass); try { Field f = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER); @@ -324,7 +324,7 @@ static synchronized EventHandler getHandler(Class<? extends Event> eventClass) { } } - static synchronized void setHandler(Class<? extends Event> eventClass, EventHandler handler) { + static synchronized void setHandler(Class<? extends jdk.internal.event.Event> eventClass, EventHandler handler) { Utils.ensureValidEventSubclass(eventClass); try { Field field = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER); @@ -368,7 +368,7 @@ public static <T> List<T> sanitizeNullFreeList(List<T> elements, Class<T> clazz) static List<Field> getVisibleEventFields(Class<?> clazz) { Utils.ensureValidEventSubclass(clazz); List<Field> fields = new ArrayList<>(); - for (Class<?> c = clazz; c != Event.class; c = c.getSuperclass()) { + for (Class<?> c = clazz; c != jdk.internal.event.Event.class; c = c.getSuperclass()) { for (Field field : c.getDeclaredFields()) { // skip private field in base classes if (c == clazz || !Modifier.isPrivate(field.getModifiers())) { @@ -380,10 +380,10 @@ static List<Field> getVisibleEventFields(Class<?> clazz) { } public static void ensureValidEventSubclass(Class<?> eventClass) { - if (Event.class.isAssignableFrom(eventClass) && Modifier.isAbstract(eventClass.getModifiers())) { + if (jdk.internal.event.Event.class.isAssignableFrom(eventClass) && Modifier.isAbstract(eventClass.getModifiers())) { throw new IllegalArgumentException("Abstract event classes are not allowed"); } - if (eventClass == Event.class || !Event.class.isAssignableFrom(eventClass)) { + if (eventClass == Event.class || eventClass == jdk.internal.event.Event.class || !jdk.internal.event.Event.class.isAssignableFrom(eventClass)) { throw new IllegalArgumentException("Must be a subclass to " + Event.class.getName()); } } @@ -412,7 +412,7 @@ public static void writeGeneratedASM(String className, byte[] bytes) { } } - public static void ensureInitialized(Class<? extends Event> eventClass) { + public static void ensureInitialized(Class<? extends jdk.internal.event.Event> eventClass) { SecuritySupport.ensureClassIsInitialized(eventClass); } @@ -545,6 +545,50 @@ public static String upgradeLegacyJDKEvent(String eventName) { return eventName; } + public static void verifyMirror(Class<?> mirror, Class<?> real) { + Class<?> cMirror = Objects.requireNonNull(mirror); + Class<?> cReal = Objects.requireNonNull(real); + + while (cReal != null) { + Map<String, Field> mirrorFields = new HashMap<>(); + if (cMirror != null) { + for (Field f : cMirror.getDeclaredFields()) { + if (isSupportedType(f.getType())) { + mirrorFields.put(f.getName(), f); + } + } + } + for (Field realField : cReal.getDeclaredFields()) { + if (isSupportedType(realField.getType())) { + String fieldName = realField.getName(); + Field mirrorField = mirrorFields.get(fieldName); + if (mirrorField == null) { + throw new InternalError("Missing mirror field for " + cReal.getName() + "#" + fieldName); + } + if (realField.getModifiers() != mirrorField.getModifiers()) { + throw new InternalError("Incorrect modifier for mirror field "+ cMirror.getName() + "#" + fieldName); + } + mirrorFields.remove(fieldName); + } + } + if (!mirrorFields.isEmpty()) { + throw new InternalError( + "Found additional fields in mirror class " + cMirror.getName() + " " + mirrorFields.keySet()); + } + if (cMirror != null) { + cMirror = cMirror.getSuperclass(); + } + cReal = cReal.getSuperclass(); + } + } + + private static boolean isSupportedType(Class<?> type) { + if (Modifier.isTransient(type.getModifiers()) || Modifier.isStatic(type.getModifiers())) { + return false; + } + return Type.isValidJavaFieldType(type.getName()); + } + public static String makeFilename(Recording recording) { String pid = JVM.getJVM().getPid(); String date = Repository.REPO_DATE_FORMAT.format(LocalDateTime.now()); diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java index 0fad0c5b8c1..d3e83ca39db 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java @@ -26,6 +26,8 @@ import java.io.IOException; import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.time.Duration; import java.time.Instant; import java.time.LocalDate; @@ -126,26 +128,37 @@ public String execute(String name, String filename, Long maxAge, Long maxSize, S recording = findRecording(name); } PlatformRecorder recorder = PrivateAccess.getInstance().getPlatformRecorder(); - synchronized (recorder) { - dump(recorder, recording, name, filename, maxSize, pathToGcRoots, beginTime, endTime); + + try { + synchronized (recorder) { + dump(recorder, recording, name, filename, maxSize, pathToGcRoots, beginTime, endTime); + } + } catch (IOException | InvalidPathException e) { + throw new DCmdException("Dump failed. Could not copy recording data. %s", e.getMessage()); } return getResult(); } - public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException { + public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException, IOException { try (PlatformRecording r = newSnapShot(recorder, recording, pathToGcRoots)) { r.filter(beginTime, endTime, maxSize); if (r.getChunks().isEmpty()) { throw new DCmdException("Dump failed. No data found in the specified interval."); } - SafePath dumpFile = resolvePath(recording, filename); - - // Needed for JVM - Utils.touch(dumpFile.toPath()); - r.dumpStopped(new WriteableUserPath(dumpFile.toPath())); - reportOperationComplete("Dumped", name, dumpFile); - } catch (IOException | InvalidPathException e) { - throw new DCmdException("Dump failed. Could not copy recording data. %s", e.getMessage()); + // If a filename exist, use it + // if a filename doesn't exist, use destination set earlier + // if destination doesn't exist, generate a filename + WriteableUserPath wup = null; + if (recording != null) { + PlatformRecording pRecording = PrivateAccess.getInstance().getPlatformRecording(recording); + wup = pRecording.getDestination(); + } + if (filename != null || (filename == null && wup == null) ) { + SafePath safe = resolvePath(recording, filename); + wup = new WriteableUserPath(safe.toPath()); + } + r.dumpStopped(wup); + reportOperationComplete("Dumped", name, new SafePath(wup.getText())); } } diff --git a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/JDKEvents.java b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/JDKEvents.java index f24869bd976..a8cdfa6cbd2 100644 --- a/src/src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/JDKEvents.java +++ b/src/src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/JDKEvents.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.List; -import jdk.internal.module.Modules; import jdk.jfr.Event; import jdk.jfr.events.ActiveRecordingEvent; import jdk.jfr.events.ActiveSettingEvent; @@ -38,8 +37,12 @@ import jdk.jfr.events.FileForceEvent; import jdk.jfr.events.FileReadEvent; import jdk.jfr.events.FileWriteEvent; +import jdk.jfr.events.SecurityPropertyModificationEvent; import jdk.jfr.events.SocketReadEvent; import jdk.jfr.events.SocketWriteEvent; +import jdk.jfr.events.TLSHandshakeEvent; +import jdk.jfr.events.X509CertificateEvent; +import jdk.jfr.events.X509ValidationEvent; import jdk.jfr.internal.JVM; import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; @@ -50,6 +53,13 @@ public final class JDKEvents { + private static final Class<?>[] mirrorEventClasses = { + SecurityPropertyModificationEvent.class, + TLSHandshakeEvent.class, + X509CertificateEvent.class, + X509ValidationEvent.class + }; + private static final Class<?>[] eventClasses = { FileForceEvent.class, FileReadEvent.class, @@ -60,7 +70,11 @@ public final class JDKEvents { ExceptionStatisticsEvent.class, ErrorThrownEvent.class, ActiveSettingEvent.class, - ActiveRecordingEvent.class + ActiveRecordingEvent.class, + jdk.internal.event.SecurityPropertyModificationEvent.class, + jdk.internal.event.TLSHandshakeEvent.class, + jdk.internal.event.X509CertificateEvent.class, + jdk.internal.event.X509ValidationEvent.class }; // This is a list of the classes with instrumentation code that should be applied. @@ -83,12 +97,9 @@ public final class JDKEvents { public synchronized static void initialize() { try { if (initializationTriggered == false) { - Module jdkJfrModule = Event.class.getModule(); - Module javaBaseModule = Object.class.getModule(); - Modules.addReads(javaBaseModule, jdkJfrModule); - Modules.addExports(jdkJfrModule, Utils.EVENTS_PACKAGE_NAME, javaBaseModule); - Modules.addExports(jdkJfrModule, Utils.INSTRUMENT_PACKAGE_NAME, javaBaseModule); - Modules.addExports(jdkJfrModule, Utils.HANDLERS_PACKAGE_NAME, javaBaseModule); + for (Class<?> mirrorEventClass : mirrorEventClasses) { + SecuritySupport.registerMirror(((Class<? extends Event>)mirrorEventClass)); + } for (Class<?> eventClass : eventClasses) { SecuritySupport.registerEvent((Class<? extends Event>) eventClass); } diff --git a/src/src/jdk.jfr/share/conf/jfr/default.jfc b/src/src/jdk.jfr/share/conf/jfr/default.jfc index 6164a4e1bc0..04e02e93134 100644 --- a/src/src/jdk.jfr/share/conf/jfr/default.jfc +++ b/src/src/jdk.jfr/share/conf/jfr/default.jfc @@ -588,6 +588,26 @@ <setting name="threshold" control="socket-io-threshold">20 ms</setting> </event> + <event name="jdk.SecurityPropertyModification"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + + <event name="jdk.TLSHandshake"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + + <event name="jdk.X509Validation"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + + <event name="jdk.X509Certificate"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + <event name="jdk.JavaExceptionThrow"> <setting name="enabled" control="enable-exceptions">false</setting> <setting name="stackTrace">true</setting> diff --git a/src/src/jdk.jfr/share/conf/jfr/profile.jfc b/src/src/jdk.jfr/share/conf/jfr/profile.jfc index 267064ad0ee..fec835f1493 100644 --- a/src/src/jdk.jfr/share/conf/jfr/profile.jfc +++ b/src/src/jdk.jfr/share/conf/jfr/profile.jfc @@ -588,6 +588,26 @@ <setting name="threshold" control="socket-io-threshold">10 ms</setting> </event> + <event name="jdk.SecurityPropertyModification"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + + <event name="jdk.TLSHandshake"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + + <event name="jdk.X509Validation"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + + <event name="jdk.X509Certificate"> + <setting name="enabled">false</setting> + <setting name="stackTrace">true</setting> + </event> + <event name="jdk.JavaExceptionThrow"> <setting name="enabled" control="enable-exceptions">false</setting> <setting name="stackTrace">true</setting> diff --git a/src/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_es_PE.java b/src/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_es_PE.java index 5d483d6f75d..7f49bac3993 100644 --- a/src/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_es_PE.java +++ b/src/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_es_PE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -63,6 +63,21 @@ protected final Object[][] getContents() { "hh:mm a", // short time pattern } }, + { "NumberElements", + new String[] { + ".", // decimal separator + ",", // group (thousands) separator + ";", // list separator + "%", // percent sign + "0", // native 0 digit + "#", // pattern digit + "-", // minus sign + "E", // exponential + "\u2030", // per mille + "\u221e", // infinity + "\ufffd" // NaN + } + }, { "DatePatterns", new String[] { "EEEE d' de 'MMMM' de 'yyyy", // full date pattern diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java index ea3b39c357d..651ebfb9364 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_de.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java index 222a6c472e4..cae59965b92 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_es.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java index 81f328e5e99..a7c1858e173 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_fr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java index af93a43ae50..61201ebe464 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_it.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java index 65928b247d4..4e896da5cf3 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ja.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java index 0d75d57fcd0..72903e7129b 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_ko.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java index b6401a59725..b30213573b5 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_pt_BR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java index cc9ce084eac..13289f6aa3d 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_sv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java index 33f58ab420e..e04c8e8067f 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_CN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java index 8c93c553675..fcafa0cf30b 100644 --- a/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java +++ b/src/src/jdk.localedata/share/classes/sun/util/resources/ext/TimeZoneNames_zh_TW.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -371,7 +371,7 @@ protected final Object[][] getContents() { {"Africa/Nouakchott", GMT}, {"Africa/Ouagadougou", GMT}, {"Africa/Porto-Novo", WAT}, - {"Africa/Sao_Tome", WAT}, + {"Africa/Sao_Tome", GMT}, {"Africa/Timbuktu", GMT}, {"Africa/Tripoli", EET}, {"Africa/Tunis", CET}, diff --git a/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java b/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java index 525a2a51852..e88471633c2 100644 --- a/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java +++ b/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JdkRegExp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -82,6 +82,8 @@ public JdkRegExp(final String source, final String flags) throws ParserException } } catch (final PatternSyntaxException e2) { throwParserException("syntax", e2.getMessage()); + } catch (StackOverflowError e3) { + throw new RuntimeException(e3); } } diff --git a/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java b/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java index a602338939d..ccddc876fc1 100644 --- a/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java +++ b/src/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/JoniRegExp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -82,6 +82,8 @@ public JoniRegExp(final String pattern, final String flags) throws ParserExcepti } } catch (final PatternSyntaxException | JOniException e2) { throwParserException("syntax", e2.getMessage()); + } catch (StackOverflowError e3) { + throw new RuntimeException(e3); } } diff --git a/src/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java b/src/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java index 62138dee284..caf55b04e53 100644 --- a/src/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java +++ b/src/src/jdk.security.auth/share/classes/com/sun/security/auth/module/Krb5LoginModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -644,6 +644,7 @@ private void attemptAuthentication(boolean getPasswdFromSharedState) // renew if ticket is old. Credentials newCred = renewCredentials(cred); if (newCred != null) { + newCred.setProxy(cred.getProxy()); cred = newCred; } } @@ -1070,6 +1071,10 @@ public boolean commit() throws LoginException { // create Kerberos Ticket if (isInitiator) { kerbTicket = Krb5Util.credsToTicket(cred); + if (cred.getProxy() != null) { + KerberosSecrets.getJavaxSecurityAuthKerberosAccess() + .kerberosTicketSetProxy(kerbTicket,Krb5Util.credsToTicket(cred.getProxy())); + } } if (storeKey && encKeys != null) { diff --git a/src/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/src/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index d49273e7a2e..4c1074ef211 100644 --- a/src/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/src/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -1202,7 +1202,7 @@ private long writeEntry(Entry e, OutputStream os) return 0; long written = 0; - if (e.csize > 0 && (e.crc != 0 || e.size == 0)) { + if (e.method != METHOD_STORED && e.csize > 0 && (e.crc != 0 || e.size == 0)) { // pre-compressed entry, write directly to output stream writeTo(e, os); } else { diff --git a/src/test/fmw/gtest/CONTRIBUTORS b/src/test/fmw/gtest/CONTRIBUTORS new file mode 100644 index 00000000000..feae2fc0441 --- /dev/null +++ b/src/test/fmw/gtest/CONTRIBUTORS @@ -0,0 +1,37 @@ +# This file contains a list of people who've made non-trivial +# contribution to the Google C++ Testing Framework project. People +# who commit code to the project are encouraged to add their names +# here. Please keep the list sorted by first names. + +Ajay Joshi <jaj@google.com> +Balázs Dán <balazs.dan@gmail.com> +Bharat Mediratta <bharat@menalto.com> +Chandler Carruth <chandlerc@google.com> +Chris Prince <cprince@google.com> +Chris Taylor <taylorc@google.com> +Dan Egnor <egnor@google.com> +Eric Roman <eroman@chromium.org> +Hady Zalek <hady.zalek@gmail.com> +Jeffrey Yasskin <jyasskin@google.com> +Jói Sigurðsson <joi@google.com> +Keir Mierle <mierle@gmail.com> +Keith Ray <keith.ray@gmail.com> +Kenton Varda <kenton@google.com> +Manuel Klimek <klimek@google.com> +Markus Heule <markus.heule@gmail.com> +Mika Raento <mikie@iki.fi> +Miklós Fazekas <mfazekas@szemafor.com> +Pasi Valminen <pasi.valminen@gmail.com> +Patrick Hanna <phanna@google.com> +Patrick Riley <pfr@google.com> +Peter Kaminski <piotrk@google.com> +Preston Jackson <preston.a.jackson@gmail.com> +Rainer Klaffenboeck <rainer.klaffenboeck@dynatrace.com> +Russ Cox <rsc@google.com> +Russ Rufer <russ@pentad.com> +Sean Mcafee <eefacm@gmail.com> +Sigurður Ásgeirsson <siggi@google.com> +Tracy Bialik <tracy@pentad.com> +Vadim Berman <vadimb@google.com> +Vlad Losev <vladl@google.com> +Zhanyong Wan <wan@google.com> diff --git a/src/test/fmw/gtest/README b/src/test/fmw/gtest/README deleted file mode 100644 index 26f35a84794..00000000000 --- a/src/test/fmw/gtest/README +++ /dev/null @@ -1,435 +0,0 @@ -Google C++ Testing Framework -============================ - -http://code.google.com/p/googletest/ - -Overview --------- - -Google's framework for writing C++ tests on a variety of platforms -(Linux, Mac OS X, Windows, Windows CE, Symbian, etc). Based on the -xUnit architecture. Supports automatic test discovery, a rich set of -assertions, user-defined assertions, death tests, fatal and non-fatal -failures, various options for running the tests, and XML test report -generation. - -Please see the project page above for more information as well as the -mailing list for questions, discussions, and development. There is -also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please -join us! - -Requirements for End Users --------------------------- - -Google Test is designed to have fairly minimal requirements to build -and use with your projects, but there are some. Currently, we support -Linux, Windows, Mac OS X, and Cygwin. We will also make our best -effort to support other platforms (e.g. Solaris, AIX, and z/OS). -However, since core members of the Google Test project have no access -to these platforms, Google Test may have outstanding issues there. If -you notice any problems on your platform, please notify -googletestframework@googlegroups.com. Patches for fixing them are -even more welcome! - -### Linux Requirements ### - -These are the base requirements to build and use Google Test from a source -package (as described below): - * GNU-compatible Make or gmake - * POSIX-standard shell - * POSIX(-2) Regular Expressions (regex.h) - * A C++98-standard-compliant compiler - -### Windows Requirements ### - - * Microsoft Visual C++ 7.1 or newer - -### Cygwin Requirements ### - - * Cygwin 1.5.25-14 or newer - -### Mac OS X Requirements ### - - * Mac OS X 10.4 Tiger or newer - * Developer Tools Installed - -Also, you'll need CMake 2.6.4 or higher if you want to build the -samples using the provided CMake script, regardless of the platform. - -Requirements for Contributors ------------------------------ - -We welcome patches. If you plan to contribute a patch, you need to -build Google Test and its own tests from an SVN checkout (described -below), which has further requirements: - - * Python version 2.3 or newer (for running some of the tests and - re-generating certain source files from templates) - * CMake 2.6.4 or newer - -Getting the Source ------------------- - -There are two primary ways of getting Google Test's source code: you -can download a stable source release in your preferred archive format, -or directly check out the source from our Subversion (SVN) repositary. -The SVN checkout requires a few extra steps and some extra software -packages on your system, but lets you track the latest development and -make patches much more easily, so we highly encourage it. - -### Source Package ### - -Google Test is released in versioned source packages which can be -downloaded from the download page [1]. Several different archive -formats are provided, but the only difference is the tools used to -manipulate them, and the size of the resulting file. Download -whichever you are most comfortable with. - - [1] http://code.google.com/p/googletest/downloads/list - -Once the package is downloaded, expand it using whichever tools you -prefer for that type. This will result in a new directory with the -name "gtest-X.Y.Z" which contains all of the source code. Here are -some examples on Linux: - - tar -xvzf gtest-X.Y.Z.tar.gz - tar -xvjf gtest-X.Y.Z.tar.bz2 - unzip gtest-X.Y.Z.zip - -### SVN Checkout ### - -To check out the main branch (also known as the "trunk") of Google -Test, run the following Subversion command: - - svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn - -Setting up the Build --------------------- - -To build Google Test and your tests that use it, you need to tell your -build system where to find its headers and source files. The exact -way to do it depends on which build system you use, and is usually -straightforward. - -### Generic Build Instructions ### - -Suppose you put Google Test in directory ${GTEST_DIR}. To build it, -create a library build target (or a project as called by Visual Studio -and Xcode) to compile - - ${GTEST_DIR}/src/gtest-all.cc - -with ${GTEST_DIR}/include in the system header search path and ${GTEST_DIR} -in the normal header search path. Assuming a Linux-like system and gcc, -something like the following will do: - - g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \ - -pthread -c ${GTEST_DIR}/src/gtest-all.cc - ar -rv libgtest.a gtest-all.o - -(We need -pthread as Google Test uses threads.) - -Next, you should compile your test source file with -${GTEST_DIR}/include in the system header search path, and link it -with gtest and any other necessary libraries: - - g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \ - -o your_test - -As an example, the make/ directory contains a Makefile that you can -use to build Google Test on systems where GNU make is available -(e.g. Linux, Mac OS X, and Cygwin). It doesn't try to build Google -Test's own tests. Instead, it just builds the Google Test library and -a sample test. You can use it as a starting point for your own build -script. - -If the default settings are correct for your environment, the -following commands should succeed: - - cd ${GTEST_DIR}/make - make - ./sample1_unittest - -If you see errors, try to tweak the contents of make/Makefile to make -them go away. There are instructions in make/Makefile on how to do -it. - -### Using CMake ### - -Google Test comes with a CMake build script (CMakeLists.txt) that can -be used on a wide range of platforms ("C" stands for cross-platofrm.). -If you don't have CMake installed already, you can download it for -free from http://www.cmake.org/. - -CMake works by generating native makefiles or build projects that can -be used in the compiler environment of your choice. The typical -workflow starts with: - - mkdir mybuild # Create a directory to hold the build output. - cd mybuild - cmake ${GTEST_DIR} # Generate native build scripts. - -If you want to build Google Test's samples, you should replace the -last command with - - cmake -Dgtest_build_samples=ON ${GTEST_DIR} - -If you are on a *nix system, you should now see a Makefile in the -current directory. Just type 'make' to build gtest. - -If you use Windows and have Vistual Studio installed, a gtest.sln file -and several .vcproj files will be created. You can then build them -using Visual Studio. - -On Mac OS X with Xcode installed, a .xcodeproj file will be generated. - -### Legacy Build Scripts ### - -Before settling on CMake, we have been providing hand-maintained build -projects/scripts for Visual Studio, Xcode, and Autotools. While we -continue to provide them for convenience, they are not actively -maintained any more. We highly recommend that you follow the -instructions in the previous two sections to integrate Google Test -with your existing build system. - -If you still need to use the legacy build scripts, here's how: - -The msvc\ folder contains two solutions with Visual C++ projects. -Open the gtest.sln or gtest-md.sln file using Visual Studio, and you -are ready to build Google Test the same way you build any Visual -Studio project. Files that have names ending with -md use DLL -versions of Microsoft runtime libraries (the /MD or the /MDd compiler -option). Files without that suffix use static versions of the runtime -libraries (the /MT or the /MTd option). Please note that one must use -the same option to compile both gtest and the test code. If you use -Visual Studio 2005 or above, we recommend the -md version as /MD is -the default for new projects in these versions of Visual Studio. - -On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using -Xcode. Build the "gtest" target. The universal binary framework will -end up in your selected build directory (selected in the Xcode -"Preferences..." -> "Building" pane and defaults to xcode/build). -Alternatively, at the command line, enter: - - xcodebuild - -This will build the "Release" configuration of gtest.framework in your -default build location. See the "xcodebuild" man page for more -information about building different configurations and building in -different locations. - -If you wish to use the Google Test Xcode project with Xcode 4.x and -above, you need to either: - * update the SDK configuration options in xcode/Config/General.xconfig. - Comment options SDKROOT, MACOS_DEPLOYMENT_TARGET, and GCC_VERSION. If - you choose this route you lose the ability to target earlier versions - of MacOS X. - * Install an SDK for an earlier version. This doesn't appear to be - supported by Apple, but has been reported to work - (http://stackoverflow.com/questions/5378518). - -Tweaking Google Test --------------------- - -Google Test can be used in diverse environments. The default -configuration may not work (or may not work well) out of the box in -some environments. However, you can easily tweak Google Test by -defining control macros on the compiler command line. Generally, -these macros are named like GTEST_XYZ and you define them to either 1 -or 0 to enable or disable a certain feature. - -We list the most frequently used macros below. For a complete list, -see file include/gtest/internal/gtest-port.h. - -### Choosing a TR1 Tuple Library ### - -Some Google Test features require the C++ Technical Report 1 (TR1) -tuple library, which is not yet available with all compilers. The -good news is that Google Test implements a subset of TR1 tuple that's -enough for its own need, and will automatically use this when the -compiler doesn't provide TR1 tuple. - -Usually you don't need to care about which tuple library Google Test -uses. However, if your project already uses TR1 tuple, you need to -tell Google Test to use the same TR1 tuple library the rest of your -project uses, or the two tuple implementations will clash. To do -that, add - - -DGTEST_USE_OWN_TR1_TUPLE=0 - -to the compiler flags while compiling Google Test and your tests. If -you want to force Google Test to use its own tuple library, just add - - -DGTEST_USE_OWN_TR1_TUPLE=1 - -to the compiler flags instead. - -If you don't want Google Test to use tuple at all, add - - -DGTEST_HAS_TR1_TUPLE=0 - -and all features using tuple will be disabled. - -### Multi-threaded Tests ### - -Google Test is thread-safe where the pthread library is available. -After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE -macro to see whether this is the case (yes if the macro is #defined to -1, no if it's undefined.). - -If Google Test doesn't correctly detect whether pthread is available -in your environment, you can force it with - - -DGTEST_HAS_PTHREAD=1 - -or - - -DGTEST_HAS_PTHREAD=0 - -When Google Test uses pthread, you may need to add flags to your -compiler and/or linker to select the pthread library, or you'll get -link errors. If you use the CMake script or the deprecated Autotools -script, this is taken care of for you. If you use your own build -script, you'll need to read your compiler and linker's manual to -figure out what flags to add. - -### As a Shared Library (DLL) ### - -Google Test is compact, so most users can build and link it as a -static library for the simplicity. You can choose to use Google Test -as a shared library (known as a DLL on Windows) if you prefer. - -To compile *gtest* as a shared library, add - - -DGTEST_CREATE_SHARED_LIBRARY=1 - -to the compiler flags. You'll also need to tell the linker to produce -a shared library instead - consult your linker's manual for how to do -it. - -To compile your *tests* that use the gtest shared library, add - - -DGTEST_LINKED_AS_SHARED_LIBRARY=1 - -to the compiler flags. - -Note: while the above steps aren't technically necessary today when -using some compilers (e.g. GCC), they may become necessary in the -future, if we decide to improve the speed of loading the library (see -http://gcc.gnu.org/wiki/Visibility for details). Therefore you are -recommended to always add the above flags when using Google Test as a -shared library. Otherwise a future release of Google Test may break -your build script. - -### Avoiding Macro Name Clashes ### - -In C++, macros don't obey namespaces. Therefore two libraries that -both define a macro of the same name will clash if you #include both -definitions. In case a Google Test macro clashes with another -library, you can force Google Test to rename its macro to avoid the -conflict. - -Specifically, if both Google Test and some other code define macro -FOO, you can add - - -DGTEST_DONT_DEFINE_FOO=1 - -to the compiler flags to tell Google Test to change the macro's name -from FOO to GTEST_FOO. Currently FOO can be FAIL, SUCCEED, or TEST. -For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write - - GTEST_TEST(SomeTest, DoesThis) { ... } - -instead of - - TEST(SomeTest, DoesThis) { ... } - -in order to define a test. - -Upgrating from an Earlier Version ---------------------------------- - -We strive to keep Google Test releases backward compatible. -Sometimes, though, we have to make some breaking changes for the -users' long-term benefits. This section describes what you'll need to -do if you are upgrading from an earlier version of Google Test. - -### Upgrading from 1.3.0 or Earlier ### - -You may need to explicitly enable or disable Google Test's own TR1 -tuple library. See the instructions in section "Choosing a TR1 Tuple -Library". - -### Upgrading from 1.4.0 or Earlier ### - -The Autotools build script (configure + make) is no longer officially -supportted. You are encouraged to migrate to your own build system or -use CMake. If you still need to use Autotools, you can find -instructions in the README file from Google Test 1.4.0. - -On platforms where the pthread library is available, Google Test uses -it in order to be thread-safe. See the "Multi-threaded Tests" section -for what this means to your build script. - -If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google -Test will no longer compile. This should affect very few people, as a -large portion of STL (including <string>) doesn't compile in this mode -anyway. We decided to stop supporting it in order to greatly simplify -Google Test's implementation. - -Developing Google Test ----------------------- - -This section discusses how to make your own changes to Google Test. - -### Testing Google Test Itself ### - -To make sure your changes work as intended and don't break existing -functionality, you'll want to compile and run Google Test's own tests. -For that you can use CMake: - - mkdir mybuild - cd mybuild - cmake -Dgtest_build_tests=ON ${GTEST_DIR} - -Make sure you have Python installed, as some of Google Test's tests -are written in Python. If the cmake command complains about not being -able to find Python ("Could NOT find PythonInterp (missing: -PYTHON_EXECUTABLE)"), try telling it explicitly where your Python -executable can be found: - - cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR} - -Next, you can build Google Test and all of its own tests. On *nix, -this is usually done by 'make'. To run the tests, do - - make test - -All tests should pass. - -### Regenerating Source Files ### - -Some of Google Test's source files are generated from templates (not -in the C++ sense) using a script. A template file is named FOO.pump, -where FOO is the name of the file it will generate. For example, the -file include/gtest/internal/gtest-type-util.h.pump is used to generate -gtest-type-util.h in the same directory. - -Normally you don't need to worry about regenerating the source files, -unless you need to modify them. In that case, you should modify the -corresponding .pump files instead and run the pump.py Python script to -regenerate them. You can find pump.py in the scripts/ directory. -Read the Pump manual [2] for how to use it. - - [2] http://code.google.com/p/googletest/wiki/PumpManual - -### Contributing a Patch ### - -We welcome patches. Please read the Google Test developer's guide [3] -for how you can contribute. In particular, make sure you have signed -the Contributor License Agreement, or we won't be able to accept the -patch. - - [3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide - -Happy testing! diff --git a/src/test/fmw/gtest/README.md b/src/test/fmw/gtest/README.md new file mode 100644 index 00000000000..46de3dd47fa --- /dev/null +++ b/src/test/fmw/gtest/README.md @@ -0,0 +1,345 @@ +### Generic Build Instructions + +#### Setup + +To build Google Test and your tests that use it, you need to tell your build +system where to find its headers and source files. The exact way to do it +depends on which build system you use, and is usually straightforward. + +#### Build + +Suppose you put Google Test in directory `${GTEST_DIR}`. To build it, create a +library build target (or a project as called by Visual Studio and Xcode) to +compile + + ${GTEST_DIR}/src/gtest-all.cc + +with `${GTEST_DIR}/include` in the system header search path and `${GTEST_DIR}` +in the normal header search path. Assuming a Linux-like system and gcc, +something like the following will do: + + g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \ + -pthread -c ${GTEST_DIR}/src/gtest-all.cc + ar -rv libgtest.a gtest-all.o + +(We need `-pthread` as Google Test uses threads.) + +Next, you should compile your test source file with `${GTEST_DIR}/include` in +the system header search path, and link it with gtest and any other necessary +libraries: + + g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \ + -o your_test + +As an example, the make/ directory contains a Makefile that you can use to build +Google Test on systems where GNU make is available (e.g. Linux, Mac OS X, and +Cygwin). It doesn't try to build Google Test's own tests. Instead, it just +builds the Google Test library and a sample test. You can use it as a starting +point for your own build script. + +If the default settings are correct for your environment, the following commands +should succeed: + + cd ${GTEST_DIR}/make + make + ./sample1_unittest + +If you see errors, try to tweak the contents of `make/Makefile` to make them go +away. There are instructions in `make/Makefile` on how to do it. + +### Using CMake + +Google Test comes with a CMake build script ( +[CMakeLists.txt](https://github.com/google/googletest/blob/master/CMakeLists.txt)) +that can be used on a wide range of platforms ("C" stands for cross-platform.). +If you don't have CMake installed already, you can download it for free from +<http://www.cmake.org/>. + +CMake works by generating native makefiles or build projects that can be used in +the compiler environment of your choice. You can either build Google Test as a +standalone project or it can be incorporated into an existing CMake build for +another project. + +#### Standalone CMake Project + +When building Google Test as a standalone project, the typical workflow starts +with: + + mkdir mybuild # Create a directory to hold the build output. + cd mybuild + cmake ${GTEST_DIR} # Generate native build scripts. + +If you want to build Google Test's samples, you should replace the last command +with + + cmake -Dgtest_build_samples=ON ${GTEST_DIR} + +If you are on a \*nix system, you should now see a Makefile in the current +directory. Just type 'make' to build gtest. + +If you use Windows and have Visual Studio installed, a `gtest.sln` file and +several `.vcproj` files will be created. You can then build them using Visual +Studio. + +On Mac OS X with Xcode installed, a `.xcodeproj` file will be generated. + +#### Incorporating Into An Existing CMake Project + +If you want to use gtest in a project which already uses CMake, then a more +robust and flexible approach is to build gtest as part of that project directly. +This is done by making the GoogleTest source code available to the main build +and adding it using CMake's `add_subdirectory()` command. This has the +significant advantage that the same compiler and linker settings are used +between gtest and the rest of your project, so issues associated with using +incompatible libraries (eg debug/release), etc. are avoided. This is +particularly useful on Windows. Making GoogleTest's source code available to the +main build can be done a few different ways: + +* Download the GoogleTest source code manually and place it at a known + location. This is the least flexible approach and can make it more difficult + to use with continuous integration systems, etc. +* Embed the GoogleTest source code as a direct copy in the main project's + source tree. This is often the simplest approach, but is also the hardest to + keep up to date. Some organizations may not permit this method. +* Add GoogleTest as a git submodule or equivalent. This may not always be + possible or appropriate. Git submodules, for example, have their own set of + advantages and drawbacks. +* Use CMake to download GoogleTest as part of the build's configure step. This + is just a little more complex, but doesn't have the limitations of the other + methods. + +The last of the above methods is implemented with a small piece of CMake code in +a separate file (e.g. `CMakeLists.txt.in`) which is copied to the build area and +then invoked as a sub-build _during the CMake stage_. That directory is then +pulled into the main build with `add_subdirectory()`. For example: + +New file `CMakeLists.txt.in`: + +``` cmake +cmake_minimum_required(VERSION 2.8.2) + +project(googletest-download NONE) + +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG master + SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) +``` + +Existing build's `CMakeLists.txt`: + +``` cmake +# Download and unpack googletest at configure time +configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src + ${CMAKE_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL) + +# The gtest/gtest_main targets carry header search path +# dependencies automatically when using CMake 2.8.11 or +# later. Otherwise we have to add them here ourselves. +if (CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include") +endif() + +# Now simply link against gtest or gtest_main as needed. Eg +add_executable(example example.cpp) +target_link_libraries(example gtest_main) +add_test(NAME example_test COMMAND example) +``` + +Note that this approach requires CMake 2.8.2 or later due to its use of the +`ExternalProject_Add()` command. The above technique is discussed in more detail +in [this separate article](http://crascit.com/2015/07/25/cmake-gtest/) which +also contains a link to a fully generalized implementation of the technique. + +##### Visual Studio Dynamic vs Static Runtimes + +By default, new Visual Studio projects link the C runtimes dynamically but +Google Test links them statically. This will generate an error that looks +something like the following: gtest.lib(gtest-all.obj) : error LNK2038: mismatch +detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value +'MDd_DynamicDebug' in main.obj + +Google Test already has a CMake option for this: `gtest_force_shared_crt` + +Enabling this option will make gtest link the runtimes dynamically too, and +match the project in which it is included. + +### Legacy Build Scripts + +Before settling on CMake, we have been providing hand-maintained build +projects/scripts for Visual Studio, Xcode, and Autotools. While we continue to +provide them for convenience, they are not actively maintained any more. We +highly recommend that you follow the instructions in the above sections to +integrate Google Test with your existing build system. + +If you still need to use the legacy build scripts, here's how: + +The msvc\ folder contains two solutions with Visual C++ projects. Open the +`gtest.sln` or `gtest-md.sln` file using Visual Studio, and you are ready to +build Google Test the same way you build any Visual Studio project. Files that +have names ending with -md use DLL versions of Microsoft runtime libraries (the +/MD or the /MDd compiler option). Files without that suffix use static versions +of the runtime libraries (the /MT or the /MTd option). Please note that one must +use the same option to compile both gtest and the test code. If you use Visual +Studio 2005 or above, we recommend the -md version as /MD is the default for new +projects in these versions of Visual Studio. + +On Mac OS X, open the `gtest.xcodeproj` in the `xcode/` folder using Xcode. +Build the "gtest" target. The universal binary framework will end up in your +selected build directory (selected in the Xcode "Preferences..." -> "Building" +pane and defaults to xcode/build). Alternatively, at the command line, enter: + + xcodebuild + +This will build the "Release" configuration of gtest.framework in your default +build location. See the "xcodebuild" man page for more information about +building different configurations and building in different locations. + +If you wish to use the Google Test Xcode project with Xcode 4.x and above, you +need to either: + +* update the SDK configuration options in xcode/Config/General.xconfig. + Comment options `SDKROOT`, `MACOS_DEPLOYMENT_TARGET`, and `GCC_VERSION`. If + you choose this route you lose the ability to target earlier versions of + MacOS X. +* Install an SDK for an earlier version. This doesn't appear to be supported + by Apple, but has been reported to work + (http://stackoverflow.com/questions/5378518). + +### Tweaking Google Test + +Google Test can be used in diverse environments. The default configuration may +not work (or may not work well) out of the box in some environments. However, +you can easily tweak Google Test by defining control macros on the compiler +command line. Generally, these macros are named like `GTEST_XYZ` and you define +them to either 1 or 0 to enable or disable a certain feature. + +We list the most frequently used macros below. For a complete list, see file +[include/gtest/internal/gtest-port.h](https://github.com/google/googletest/blob/master/include/gtest/internal/gtest-port.h). + +### Choosing a TR1 Tuple Library + +Some Google Test features require the C++ Technical Report 1 (TR1) tuple +library, which is not yet available with all compilers. The good news is that +Google Test implements a subset of TR1 tuple that's enough for its own need, and +will automatically use this when the compiler doesn't provide TR1 tuple. + +Usually you don't need to care about which tuple library Google Test uses. +However, if your project already uses TR1 tuple, you need to tell Google Test to +use the same TR1 tuple library the rest of your project uses, or the two tuple +implementations will clash. To do that, add + + -DGTEST_USE_OWN_TR1_TUPLE=0 + +to the compiler flags while compiling Google Test and your tests. If you want to +force Google Test to use its own tuple library, just add + + -DGTEST_USE_OWN_TR1_TUPLE=1 + +to the compiler flags instead. + +If you don't want Google Test to use tuple at all, add + + -DGTEST_HAS_TR1_TUPLE=0 + +and all features using tuple will be disabled. + +### Multi-threaded Tests + +Google Test is thread-safe where the pthread library is available. After +`#include "gtest/gtest.h"`, you can check the `GTEST_IS_THREADSAFE` macro to see +whether this is the case (yes if the macro is `#defined` to 1, no if it's +undefined.). + +If Google Test doesn't correctly detect whether pthread is available in your +environment, you can force it with + + -DGTEST_HAS_PTHREAD=1 + +or + + -DGTEST_HAS_PTHREAD=0 + +When Google Test uses pthread, you may need to add flags to your compiler and/or +linker to select the pthread library, or you'll get link errors. If you use the +CMake script or the deprecated Autotools script, this is taken care of for you. +If you use your own build script, you'll need to read your compiler and linker's +manual to figure out what flags to add. + +### As a Shared Library (DLL) + +Google Test is compact, so most users can build and link it as a static library +for the simplicity. You can choose to use Google Test as a shared library (known +as a DLL on Windows) if you prefer. + +To compile *gtest* as a shared library, add + + -DGTEST_CREATE_SHARED_LIBRARY=1 + +to the compiler flags. You'll also need to tell the linker to produce a shared +library instead - consult your linker's manual for how to do it. + +To compile your *tests* that use the gtest shared library, add + + -DGTEST_LINKED_AS_SHARED_LIBRARY=1 + +to the compiler flags. + +Note: while the above steps aren't technically necessary today when using some +compilers (e.g. GCC), they may become necessary in the future, if we decide to +improve the speed of loading the library (see +<http://gcc.gnu.org/wiki/Visibility> for details). Therefore you are recommended +to always add the above flags when using Google Test as a shared library. +Otherwise a future release of Google Test may break your build script. + +### Avoiding Macro Name Clashes + +In C++, macros don't obey namespaces. Therefore two libraries that both define a +macro of the same name will clash if you `#include` both definitions. In case a +Google Test macro clashes with another library, you can force Google Test to +rename its macro to avoid the conflict. + +Specifically, if both Google Test and some other code define macro FOO, you can +add + + -DGTEST_DONT_DEFINE_FOO=1 + +to the compiler flags to tell Google Test to change the macro's name from `FOO` +to `GTEST_FOO`. Currently `FOO` can be `FAIL`, `SUCCEED`, or `TEST`. For +example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write + + GTEST_TEST(SomeTest, DoesThis) { ... } + +instead of + + TEST(SomeTest, DoesThis) { ... } + +in order to define a test. diff --git a/src/test/fmw/gtest/include/gtest/gtest-death-test.h b/src/test/fmw/gtest/include/gtest/gtest-death-test.h index 957a69c6a9e..20c54d86951 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-death-test.h +++ b/src/test/fmw/gtest/include/gtest/gtest-death-test.h @@ -26,14 +26,14 @@ // 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. + // -// Author: wan@google.com (Zhanyong Wan) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) // // This header file defines the public API for death tests. It is // #included by gtest.h so a user doesn't need to include this // directly. +// GOOGLETEST_CM0001 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ @@ -99,10 +99,11 @@ GTEST_API_ bool InDeathTestChild(); // // On the regular expressions used in death tests: // +// GOOGLETEST_CM0005 DO NOT DELETE // On POSIX-compliant systems (*nix), we use the <regex.h> library, // which uses the POSIX extended regex syntax. // -// On other platforms (e.g. Windows), we only support a simple regex +// On other platforms (e.g. Windows or Mac), we only support a simple regex // syntax implemented as part of Google Test. This limited // implementation should be enough most of the time when writing // death tests; though it lacks many features you can find in PCRE @@ -160,7 +161,7 @@ GTEST_API_ bool InDeathTestChild(); // is rarely a problem as people usually don't put the test binary // directory in PATH. // -// TODO(wan@google.com): make thread-safe death tests search the PATH. +// FIXME: make thread-safe death tests search the PATH. // Asserts that a given statement causes the program to exit, with an // integer exit status that satisfies predicate, and emitting error output @@ -198,9 +199,10 @@ class GTEST_API_ ExitedWithCode { const int exit_code_; }; -# if !GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Tests that an exit code describes an exit due to termination by a // given signal. +// GOOGLETEST_CM0006 DO NOT DELETE class GTEST_API_ KilledBySignal { public: explicit KilledBySignal(int signum); @@ -272,6 +274,54 @@ class GTEST_API_ KilledBySignal { # endif // NDEBUG for EXPECT_DEBUG_DEATH #endif // GTEST_HAS_DEATH_TEST +// This macro is used for implementing macros such as +// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where +// death tests are not supported. Those macros must compile on such systems +// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on +// systems that support death tests. This allows one to write such a macro +// on a system that does not support death tests and be sure that it will +// compile on a death-test supporting system. It is exposed publicly so that +// systems that have death-tests with stricter requirements than +// GTEST_HAS_DEATH_TEST can write their own equivalent of +// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED. +// +// Parameters: +// statement - A statement that a macro such as EXPECT_DEATH would test +// for program termination. This macro has to make sure this +// statement is compiled but not executed, to ensure that +// EXPECT_DEATH_IF_SUPPORTED compiles with a certain +// parameter iff EXPECT_DEATH compiles with it. +// regex - A regex that a macro such as EXPECT_DEATH would use to test +// the output of statement. This parameter has to be +// compiled but not evaluated by this macro, to ensure that +// this macro only accepts expressions that a macro such as +// EXPECT_DEATH would accept. +// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED +// and a return statement for ASSERT_DEATH_IF_SUPPORTED. +// This ensures that ASSERT_DEATH_IF_SUPPORTED will not +// compile inside functions where ASSERT_DEATH doesn't +// compile. +// +// The branch that has an always false condition is used to ensure that +// statement and regex are compiled (and thus syntactically correct) but +// never executed. The unreachable code macro protects the terminator +// statement from generating an 'unreachable code' warning in case +// statement unconditionally returns or throws. The Message constructor at +// the end allows the syntax of streaming additional messages into the +// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. +# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_LOG_(WARNING) \ + << "Death tests are not supported on this platform.\n" \ + << "Statement '" #statement "' cannot be verified."; \ + } else if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::RE::PartialMatch(".*", (regex)); \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + terminator; \ + } else \ + ::testing::Message() + // EXPECT_DEATH_IF_SUPPORTED(statement, regex) and // ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if // death tests are supported; otherwise they just issue a warning. This is @@ -284,9 +334,9 @@ class GTEST_API_ KilledBySignal { ASSERT_DEATH(statement, regex) #else # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ - GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, ) + GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, ) # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ - GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return) + GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return) #endif } // namespace testing diff --git a/src/test/fmw/gtest/include/gtest/gtest-message.h b/src/test/fmw/gtest/include/gtest/gtest-message.h index fe879bca792..5ca041614cb 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-message.h +++ b/src/test/fmw/gtest/include/gtest/gtest-message.h @@ -26,10 +26,9 @@ // 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. + // -// Author: wan@google.com (Zhanyong Wan) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) // // This header file defines the Message class. // @@ -43,6 +42,8 @@ // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user // program! +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ @@ -50,6 +51,9 @@ #include "gtest/internal/gtest-port.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + // Ensures that there is at least one operator<< in the global namespace. // See Message& operator<<(...) below for why. void operator<<(const testing::internal::Secret&, int); @@ -196,7 +200,6 @@ class GTEST_API_ Message { std::string GetString() const; private: - #if GTEST_OS_SYMBIAN // These are needed as the Nokia Symbian Compiler cannot decide between // const T& and const T* in a function template. The Nokia compiler _can_ @@ -247,4 +250,6 @@ std::string StreamableToString(const T& streamable) { } // namespace internal } // namespace testing +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + #endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest-param-test.h b/src/test/fmw/gtest/include/gtest/gtest-param-test.h index d6702c8f162..3e95e4390e0 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-param-test.h +++ b/src/test/fmw/gtest/include/gtest/gtest-param-test.h @@ -31,13 +31,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: vladl@google.com (Vlad Losev) -// // Macros and functions for implementing parameterized tests -// in Google C++ Testing Framework (Google Test) +// in Google C++ Testing and Mocking Framework (Google Test) // // This file is generated by a SCRIPT. DO NOT EDIT BY HAND! // +// GOOGLETEST_CM0001 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ @@ -79,7 +78,7 @@ TEST_P(FooTest, HasBlahBlah) { // Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test // case with any set of parameters you want. Google Test defines a number // of functions for generating test parameters. They return what we call -// (surprise!) parameter generators. Here is a summary of them, which +// (surprise!) parameter generators. Here is a summary of them, which // are all in the testing namespace: // // @@ -185,15 +184,10 @@ TEST_P(DerivedTest, DoesBlah) { # include <utility> #endif -// scripts/fuse_gtest.py depends on gtest's own header being #included -// *unconditionally*. Therefore these #includes cannot be moved -// inside #if GTEST_HAS_PARAM_TEST. #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-param-util.h" #include "gtest/internal/gtest-param-util-generated.h" -#if GTEST_HAS_PARAM_TEST - namespace testing { // Functions producing parameter generators. @@ -273,7 +267,7 @@ internal::ParamGenerator<T> Range(T start, T end) { // each with C-string values of "foo", "bar", and "baz": // // const char* strings[] = {"foo", "bar", "baz"}; -// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings)); +// INSTANTIATE_TEST_CASE_P(StringSequence, StringTest, ValuesIn(strings)); // // This instantiates tests from test case StlStringTest // each with STL strings with values "a" and "b": @@ -1375,8 +1369,6 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3, } # endif // GTEST_HAS_COMBINE - - # define TEST_P(test_case_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ : public test_case_name { \ @@ -1387,14 +1379,17 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3, static int AddToRegistry() { \ ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ GetTestCasePatternHolder<test_case_name>(\ - #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ - #test_case_name, \ - #test_name, \ - new ::testing::internal::TestMetaFactory< \ - GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ + #test_case_name, \ + ::testing::internal::CodeLocation(\ + __FILE__, __LINE__))->AddTestPattern(\ + GTEST_STRINGIFY_(test_case_name), \ + GTEST_STRINGIFY_(test_name), \ + new ::testing::internal::TestMetaFactory< \ + GTEST_TEST_CLASS_NAME_(\ + test_case_name, test_name)>()); \ return 0; \ } \ - static int gtest_registering_dummy_; \ + static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ GTEST_DISALLOW_COPY_AND_ASSIGN_(\ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ }; \ @@ -1403,19 +1398,37 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3, GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() -# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ - ::testing::internal::ParamGenerator<test_case_name::ParamType> \ +// The optional last argument to INSTANTIATE_TEST_CASE_P allows the user +// to specify a function or functor that generates custom test name suffixes +// based on the test parameters. The function should accept one argument of +// type testing::TestParamInfo<class ParamType>, and return std::string. +// +// testing::PrintToStringParamName is a builtin test suffix generator that +// returns the value of testing::PrintToString(GetParam()). +// +// Note: test names must be non-empty, unique, and may only contain ASCII +// alphanumeric characters or underscore. Because PrintToString adds quotes +// to std::string and C strings, it won't work for these types. + +# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \ + static ::testing::internal::ParamGenerator<test_case_name::ParamType> \ gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ - int gtest_##prefix##test_case_name##_dummy_ = \ + static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \ + const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \ + return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \ + (__VA_ARGS__)(info); \ + } \ + static int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \ ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ GetTestCasePatternHolder<test_case_name>(\ - #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\ - #prefix, \ - >est_##prefix##test_case_name##_EvalGenerator_, \ - __FILE__, __LINE__) + #test_case_name, \ + ::testing::internal::CodeLocation(\ + __FILE__, __LINE__))->AddTestCaseInstantiation(\ + #prefix, \ + >est_##prefix##test_case_name##_EvalGenerator_, \ + >est_##prefix##test_case_name##_EvalGenerateName_, \ + __FILE__, __LINE__) } // namespace testing -#endif // GTEST_HAS_PARAM_TEST - #endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest-param-test.h.pump b/src/test/fmw/gtest/include/gtest/gtest-param-test.h.pump index 2dc9303b5e3..274f2b3b569 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-param-test.h.pump +++ b/src/test/fmw/gtest/include/gtest/gtest-param-test.h.pump @@ -30,13 +30,12 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: vladl@google.com (Vlad Losev) -// // Macros and functions for implementing parameterized tests -// in Google C++ Testing Framework (Google Test) +// in Google C++ Testing and Mocking Framework (Google Test) // // This file is generated by a SCRIPT. DO NOT EDIT BY HAND! // +// GOOGLETEST_CM0001 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ @@ -78,7 +77,7 @@ TEST_P(FooTest, HasBlahBlah) { // Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test // case with any set of parameters you want. Google Test defines a number // of functions for generating test parameters. They return what we call -// (surprise!) parameter generators. Here is a summary of them, which +// (surprise!) parameter generators. Here is a summary of them, which // are all in the testing namespace: // // @@ -184,15 +183,10 @@ TEST_P(DerivedTest, DoesBlah) { # include <utility> #endif -// scripts/fuse_gtest.py depends on gtest's own header being #included -// *unconditionally*. Therefore these #includes cannot be moved -// inside #if GTEST_HAS_PARAM_TEST. #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-param-util.h" #include "gtest/internal/gtest-param-util-generated.h" -#if GTEST_HAS_PARAM_TEST - namespace testing { // Functions producing parameter generators. @@ -272,7 +266,7 @@ internal::ParamGenerator<T> Range(T start, T end) { // each with C-string values of "foo", "bar", and "baz": // // const char* strings[] = {"foo", "bar", "baz"}; -// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings)); +// INSTANTIATE_TEST_CASE_P(StringSequence, StringTest, ValuesIn(strings)); // // This instantiates tests from test case StlStringTest // each with STL strings with values "a" and "b": @@ -441,8 +435,6 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( ]] # endif // GTEST_HAS_COMBINE - - # define TEST_P(test_case_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ : public test_case_name { \ @@ -453,14 +445,17 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( static int AddToRegistry() { \ ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ GetTestCasePatternHolder<test_case_name>(\ - #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ - #test_case_name, \ - #test_name, \ - new ::testing::internal::TestMetaFactory< \ - GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ + #test_case_name, \ + ::testing::internal::CodeLocation(\ + __FILE__, __LINE__))->AddTestPattern(\ + GTEST_STRINGIFY_(test_case_name), \ + GTEST_STRINGIFY_(test_name), \ + new ::testing::internal::TestMetaFactory< \ + GTEST_TEST_CLASS_NAME_(\ + test_case_name, test_name)>()); \ return 0; \ } \ - static int gtest_registering_dummy_; \ + static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ GTEST_DISALLOW_COPY_AND_ASSIGN_(\ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ }; \ @@ -469,19 +464,37 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() -# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ - ::testing::internal::ParamGenerator<test_case_name::ParamType> \ +// The optional last argument to INSTANTIATE_TEST_CASE_P allows the user +// to specify a function or functor that generates custom test name suffixes +// based on the test parameters. The function should accept one argument of +// type testing::TestParamInfo<class ParamType>, and return std::string. +// +// testing::PrintToStringParamName is a builtin test suffix generator that +// returns the value of testing::PrintToString(GetParam()). +// +// Note: test names must be non-empty, unique, and may only contain ASCII +// alphanumeric characters or underscore. Because PrintToString adds quotes +// to std::string and C strings, it won't work for these types. + +# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \ + static ::testing::internal::ParamGenerator<test_case_name::ParamType> \ gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ - int gtest_##prefix##test_case_name##_dummy_ = \ + static ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \ + const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \ + return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \ + (__VA_ARGS__)(info); \ + } \ + static int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \ ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ GetTestCasePatternHolder<test_case_name>(\ - #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\ - #prefix, \ - >est_##prefix##test_case_name##_EvalGenerator_, \ - __FILE__, __LINE__) + #test_case_name, \ + ::testing::internal::CodeLocation(\ + __FILE__, __LINE__))->AddTestCaseInstantiation(\ + #prefix, \ + >est_##prefix##test_case_name##_EvalGenerator_, \ + >est_##prefix##test_case_name##_EvalGenerateName_, \ + __FILE__, __LINE__) } // namespace testing -#endif // GTEST_HAS_PARAM_TEST - #endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest-printers.h b/src/test/fmw/gtest/include/gtest/gtest-printers.h index 0639d9f5869..71f2aaec949 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-printers.h +++ b/src/test/fmw/gtest/include/gtest/gtest-printers.h @@ -26,10 +26,9 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) -// Google Test - The Google C++ Testing Framework + +// Google Test - The Google C++ Testing and Mocking Framework // // This file implements a universal value printer that can print a // value of any type T: @@ -46,6 +45,10 @@ // 2. operator<<(ostream&, const T&) defined in either foo or the // global namespace. // +// However if T is an STL-style container then it is printed element-wise +// unless foo::PrintTo(const T&, ostream*) is defined. Note that +// operator<<() is ignored for container types. +// // If none of the above is defined, it will print the debug string of // the value if it is a protocol buffer, or print the raw bytes in the // value otherwise. @@ -92,6 +95,8 @@ // being defined as many user-defined container types don't have // value_type. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ @@ -103,6 +108,16 @@ #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-internal.h" +#if GTEST_HAS_STD_TUPLE_ +# include <tuple> +#endif + +#if GTEST_HAS_ABSL +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "absl/types/variant.h" +#endif // GTEST_HAS_ABSL + namespace testing { // Definitions in the 'internal' and 'internal2' name spaces are @@ -121,7 +136,11 @@ enum TypeKind { kProtobuf, // a protobuf type kConvertibleToInteger, // a type implicitly convertible to BiggestInt // (e.g. a named or unnamed enum type) - kOtherType // anything else +#if GTEST_HAS_ABSL + kConvertibleToStringView, // a type implicitly convertible to + // absl::string_view +#endif + kOtherType // anything else }; // TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called @@ -133,7 +152,8 @@ class TypeWithoutFormatter { public: // This default version is called when kTypeKind is kOtherType. static void PrintValue(const T& value, ::std::ostream* os) { - PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value), + PrintBytesInObjectTo(static_cast<const unsigned char*>( + reinterpret_cast<const void*>(&value)), sizeof(value), os); } }; @@ -147,10 +167,10 @@ template <typename T> class TypeWithoutFormatter<T, kProtobuf> { public: static void PrintValue(const T& value, ::std::ostream* os) { - const ::testing::internal::string short_str = value.ShortDebugString(); - const ::testing::internal::string pretty_str = - short_str.length() <= kProtobufOneLinerMaxLength ? - short_str : ("\n" + value.DebugString()); + std::string pretty_str = value.ShortDebugString(); + if (pretty_str.length() > kProtobufOneLinerMaxLength) { + pretty_str = "\n" + value.DebugString(); + } *os << ("<" + pretty_str + ">"); } }; @@ -171,6 +191,19 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> { } }; +#if GTEST_HAS_ABSL +template <typename T> +class TypeWithoutFormatter<T, kConvertibleToStringView> { + public: + // Since T has neither operator<< nor PrintTo() but can be implicitly + // converted to absl::string_view, we print it as a absl::string_view. + // + // Note: the implementation is further below, as it depends on + // internal::PrintTo symbol which is defined later in the file. + static void PrintValue(const T& value, ::std::ostream* os); +}; +#endif + // Prints the given value to the given ostream. If the value is a // protocol message, its debug string is printed; if it's an enum or // of a type implicitly convertible to BiggestInt, it's printed as an @@ -198,10 +231,19 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> { template <typename Char, typename CharTraits, typename T> ::std::basic_ostream<Char, CharTraits>& operator<<( ::std::basic_ostream<Char, CharTraits>& os, const T& x) { - TypeWithoutFormatter<T, - (internal::IsAProtocolMessage<T>::value ? kProtobuf : - internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ? - kConvertibleToInteger : kOtherType)>::PrintValue(x, &os); + TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value + ? kProtobuf + : internal::ImplicitlyConvertible< + const T&, internal::BiggestInt>::value + ? kConvertibleToInteger + : +#if GTEST_HAS_ABSL + internal::ImplicitlyConvertible< + const T&, absl::string_view>::value + ? kConvertibleToStringView + : +#endif + kOtherType)>::PrintValue(x, &os); return os; } @@ -250,6 +292,103 @@ void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) { namespace testing { namespace internal { +// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a +// value of type ToPrint that is an operand of a comparison assertion +// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in +// the comparison, and is used to help determine the best way to +// format the value. In particular, when the value is a C string +// (char pointer) and the other operand is an STL string object, we +// want to format the C string as a string, since we know it is +// compared by value with the string object. If the value is a char +// pointer but the other operand is not an STL string object, we don't +// know whether the pointer is supposed to point to a NUL-terminated +// string, and thus want to print it as a pointer to be safe. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + +// The default case. +template <typename ToPrint, typename OtherOperand> +class FormatForComparison { + public: + static ::std::string Format(const ToPrint& value) { + return ::testing::PrintToString(value); + } +}; + +// Array. +template <typename ToPrint, size_t N, typename OtherOperand> +class FormatForComparison<ToPrint[N], OtherOperand> { + public: + static ::std::string Format(const ToPrint* value) { + return FormatForComparison<const ToPrint*, OtherOperand>::Format(value); + } +}; + +// By default, print C string as pointers to be safe, as we don't know +// whether they actually point to a NUL-terminated string. + +#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \ + template <typename OtherOperand> \ + class FormatForComparison<CharType*, OtherOperand> { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(static_cast<const void*>(value)); \ + } \ + } + +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t); + +#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_ + +// If a C string is compared with an STL string object, we know it's meant +// to point to a NUL-terminated string, and thus can print it as a string. + +#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ + template <> \ + class FormatForComparison<CharType*, OtherStringType> { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(value); \ + } \ + } + +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string); + +#if GTEST_HAS_GLOBAL_STRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string); +#endif + +#if GTEST_HAS_GLOBAL_WSTRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring); +#endif + +#if GTEST_HAS_STD_WSTRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring); +#endif + +#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_ + +// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc) +// operand to be used in a failure message. The type (but not value) +// of the other operand may affect the format. This allows us to +// print a char* as a raw pointer when it is compared against another +// char* or void*, and print it as a C string when it is compared +// against an std::string object, for example. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +template <typename T1, typename T2> +std::string FormatForComparisonFailureMessage( + const T1& value, const T2& /* other_operand */) { + return FormatForComparison<T1, T2>::Format(value); +} + // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given // value to the given ostream. The caller must ensure that // 'ostream_ptr' is not NULL, or the behavior is undefined. @@ -263,11 +402,18 @@ class UniversalPrinter; template <typename T> void UniversalPrint(const T& value, ::std::ostream* os); +enum DefaultPrinterType { + kPrintContainer, + kPrintPointer, + kPrintFunctionPointer, + kPrintOther, +}; +template <DefaultPrinterType type> struct WrapPrinterType {}; + // Used to print an STL-style container when the user doesn't define // a PrintTo() for it. template <typename C> -void DefaultPrintTo(IsContainer /* dummy */, - false_type /* is not a pointer */, +void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */, const C& container, ::std::ostream* os) { const size_t kMaxCount = 32; // The maximum number of elements to print. *os << '{'; @@ -300,40 +446,34 @@ void DefaultPrintTo(IsContainer /* dummy */, // implementation-defined. Therefore they will be printed as raw // bytes.) template <typename T> -void DefaultPrintTo(IsNotContainer /* dummy */, - true_type /* is a pointer */, +void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */, T* p, ::std::ostream* os) { if (p == NULL) { *os << "NULL"; } else { - // C++ doesn't allow casting from a function pointer to any object - // pointer. - // - // IsTrue() silences warnings: "Condition is always true", - // "unreachable code". - if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) { - // T is not a function type. We just call << to print p, - // relying on ADL to pick up user-defined << for their pointer - // types, if any. - *os << p; - } else { - // T is a function type, so '*os << p' doesn't do what we want - // (it just prints p as bool). We want to print p as a const - // void*. However, we cannot cast it to const void* directly, - // even using reinterpret_cast, as earlier versions of gcc - // (e.g. 3.4.5) cannot compile the cast when p is a function - // pointer. Casting to UInt64 first solves the problem. - *os << reinterpret_cast<const void*>( - reinterpret_cast<internal::UInt64>(p)); - } + // T is not a function type. We just call << to print p, + // relying on ADL to pick up user-defined << for their pointer + // types, if any. + *os << p; + } +} +template <typename T> +void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */, + T* p, ::std::ostream* os) { + if (p == NULL) { + *os << "NULL"; + } else { + // T is a function type, so '*os << p' doesn't do what we want + // (it just prints p as bool). We want to print p as a const + // void*. + *os << reinterpret_cast<const void*>(p); } } // Used to print a non-container, non-pointer value when the user // doesn't define PrintTo() for it. template <typename T> -void DefaultPrintTo(IsNotContainer /* dummy */, - false_type /* is not a pointer */, +void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */, const T& value, ::std::ostream* os) { ::testing_internal::DefaultPrintNonContainerTo(value, os); } @@ -351,11 +491,8 @@ void DefaultPrintTo(IsNotContainer /* dummy */, // wants). template <typename T> void PrintTo(const T& value, ::std::ostream* os) { - // DefaultPrintTo() is overloaded. The type of its first two - // arguments determine which version will be picked. If T is an - // STL-style container, the version for container will be called; if - // T is a pointer, the pointer version will be called; otherwise the - // generic version will be called. + // DefaultPrintTo() is overloaded. The type of its first argument + // determines which version will be picked. // // Note that we check for container types here, prior to we check // for protocol message types in our operator<<. The rationale is: @@ -367,13 +504,27 @@ void PrintTo(const T& value, ::std::ostream* os) { // elements; therefore we check for container types here to ensure // that our format is used. // - // The second argument of DefaultPrintTo() is needed to bypass a bug - // in Symbian's C++ compiler that prevents it from picking the right - // overload between: - // - // PrintTo(const T& x, ...); - // PrintTo(T* x, ...); - DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os); + // Note that MSVC and clang-cl do allow an implicit conversion from + // pointer-to-function to pointer-to-object, but clang-cl warns on it. + // So don't use ImplicitlyConvertible if it can be helped since it will + // cause this warning, and use a separate overload of DefaultPrintTo for + // function pointers so that the `*os << p` in the object pointer overload + // doesn't cause that warning either. + DefaultPrintTo( + WrapPrinterType < + (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) && + !IsRecursiveContainer<T>::value + ? kPrintContainer + : !is_pointer<T>::value + ? kPrintOther +#if GTEST_LANG_CXX11 + : std::is_function<typename std::remove_pointer<T>::type>::value +#else + : !internal::ImplicitlyConvertible<T, const void*>::value +#endif + ? kPrintFunctionPointer + : kPrintPointer > (), + value, os); } // The following list of PrintTo() overloads tells @@ -480,14 +631,27 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { } #endif // GTEST_HAS_STD_WSTRING -#if GTEST_HAS_TR1_TUPLE -// Overload for ::std::tr1::tuple. Needed for printing function arguments, -// which are packed as tuples. +#if GTEST_HAS_ABSL +// Overload for absl::string_view. +inline void PrintTo(absl::string_view sp, ::std::ostream* os) { + PrintTo(::std::string(sp), os); +} +#endif // GTEST_HAS_ABSL + +#if GTEST_LANG_CXX11 +inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } +#endif // GTEST_LANG_CXX11 +#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ // Helper function for printing a tuple. T must be instantiated with // a tuple type. template <typename T> void PrintTupleTo(const T& t, ::std::ostream* os); +#endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ + +#if GTEST_HAS_TR1_TUPLE +// Overload for ::std::tr1::tuple. Needed for printing function arguments, +// which are packed as tuples. // Overloaded PrintTo() for tuples of various arities. We support // tuples of up-to 10 fields. The following implementation works @@ -561,6 +725,13 @@ void PrintTo( } #endif // GTEST_HAS_TR1_TUPLE +#if GTEST_HAS_STD_TUPLE_ +template <typename... Types> +void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) { + PrintTupleTo(t, os); +} +#endif // GTEST_HAS_STD_TUPLE_ + // Overload for std::pair. template <typename T1, typename T2> void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) { @@ -580,10 +751,7 @@ class UniversalPrinter { public: // MSVC warns about adding const to a function type, so we want to // disable the warning. -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4180) // Temporarily disables warning 4180. -#endif // _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180) // Note: we deliberately don't call this PrintTo(), as that name // conflicts with ::testing::internal::PrintTo in the body of the @@ -600,11 +768,51 @@ class UniversalPrinter { PrintTo(value, os); } -#ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. -#endif // _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_POP_() }; +#if GTEST_HAS_ABSL + +// Printer for absl::optional + +template <typename T> +class UniversalPrinter<::absl::optional<T>> { + public: + static void Print(const ::absl::optional<T>& value, ::std::ostream* os) { + *os << '('; + if (!value) { + *os << "nullopt"; + } else { + UniversalPrint(*value, os); + } + *os << ')'; + } +}; + +// Printer for absl::variant + +template <typename... T> +class UniversalPrinter<::absl::variant<T...>> { + public: + static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) { + *os << '('; + absl::visit(Visitor{os}, value); + *os << ')'; + } + + private: + struct Visitor { + template <typename U> + void operator()(const U& u) const { + *os << "'" << GetTypeName<U>() << "' with value "; + UniversalPrint(u, os); + } + ::std::ostream* os; + }; +}; + +#endif // GTEST_HAS_ABSL + // UniversalPrintArray(begin, len, os) prints an array of 'len' // elements, starting at address 'begin'. template <typename T> @@ -618,7 +826,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) { // If the array has more than kThreshold elements, we'll have to // omit some details by printing only the first and the last // kChunkSize elements. - // TODO(wan@google.com): let the user control the threshold using a flag. + // FIXME: let the user control the threshold using a flag. if (len <= kThreshold) { PrintRawArrayTo(begin, len, os); } else { @@ -654,10 +862,7 @@ class UniversalPrinter<T&> { public: // MSVC warns about adding const to a function type, so we want to // disable the warning. -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4180) // Temporarily disables warning 4180. -#endif // _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180) static void Print(const T& value, ::std::ostream* os) { // Prints the address of the value. We use reinterpret_cast here @@ -668,9 +873,7 @@ class UniversalPrinter<T&> { UniversalPrint(value, os); } -#ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. -#endif // _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_POP_() }; // Prints a value tersely: for a reference type, the referenced value @@ -705,7 +908,7 @@ class UniversalTersePrinter<const char*> { if (str == NULL) { *os << "NULL"; } else { - UniversalPrint(string(str), os); + UniversalPrint(std::string(str), os); } } }; @@ -756,16 +959,70 @@ void UniversalPrint(const T& value, ::std::ostream* os) { UniversalPrinter<T1>::Print(value, os); } +typedef ::std::vector< ::std::string> Strings; + +// TuplePolicy<TupleT> must provide: +// - tuple_size +// size of tuple TupleT. +// - get<size_t I>(const TupleT& t) +// static function extracting element I of tuple TupleT. +// - tuple_element<size_t I>::type +// type of element I of tuple TupleT. +template <typename TupleT> +struct TuplePolicy; + #if GTEST_HAS_TR1_TUPLE -typedef ::std::vector<string> Strings; +template <typename TupleT> +struct TuplePolicy { + typedef TupleT Tuple; + static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value; + + template <size_t I> + struct tuple_element : ::std::tr1::tuple_element<static_cast<int>(I), Tuple> { + }; + + template <size_t I> + static typename AddReference<const typename ::std::tr1::tuple_element< +#if defined(_MSC_VER) && _MSC_VER < 1900 + I, Tuple>::type>::type +#else + static_cast<int>(I), Tuple>::type>::type +#endif + get(const Tuple& tuple) { + return ::std::tr1::get<I>(tuple); + } +}; +template <typename TupleT> +const size_t TuplePolicy<TupleT>::tuple_size; +#endif // GTEST_HAS_TR1_TUPLE +#if GTEST_HAS_STD_TUPLE_ +template <typename... Types> +struct TuplePolicy< ::std::tuple<Types...> > { + typedef ::std::tuple<Types...> Tuple; + static const size_t tuple_size = ::std::tuple_size<Tuple>::value; + + template <size_t I> + struct tuple_element : ::std::tuple_element<I, Tuple> {}; + + template <size_t I> + static const typename ::std::tuple_element<I, Tuple>::type& get( + const Tuple& tuple) { + return ::std::get<I>(tuple); + } +}; +template <typename... Types> +const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size; +#endif // GTEST_HAS_STD_TUPLE_ + +#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ // This helper template allows PrintTo() for tuples and // UniversalTersePrintTupleFieldsToStrings() to be defined by // induction on the number of tuple fields. The idea is that // TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N // fields in tuple t, and can be defined in terms of // TuplePrefixPrinter<N - 1>. - +// // The inductive case. template <size_t N> struct TuplePrefixPrinter { @@ -773,9 +1030,14 @@ struct TuplePrefixPrinter { template <typename Tuple> static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os); - *os << ", "; - UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type> - ::Print(::std::tr1::get<N - 1>(t), os); + GTEST_INTENTIONAL_CONST_COND_PUSH_() + if (N > 1) { + GTEST_INTENTIONAL_CONST_COND_POP_() + *os << ", "; + } + UniversalPrinter< + typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type> + ::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os); } // Tersely prints the first N fields of a tuple to a string vector, @@ -784,12 +1046,12 @@ struct TuplePrefixPrinter { static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings); ::std::stringstream ss; - UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss); + UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss); strings->push_back(ss.str()); } }; -// Base cases. +// Base case. template <> struct TuplePrefixPrinter<0> { template <typename Tuple> @@ -798,34 +1060,13 @@ struct TuplePrefixPrinter<0> { template <typename Tuple> static void TersePrintPrefixToStrings(const Tuple&, Strings*) {} }; -// We have to specialize the entire TuplePrefixPrinter<> class -// template here, even though the definition of -// TersePrintPrefixToStrings() is the same as the generic version, as -// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't -// support specializing a method template of a class template. -template <> -struct TuplePrefixPrinter<1> { - template <typename Tuple> - static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { - UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>:: - Print(::std::tr1::get<0>(t), os); - } - - template <typename Tuple> - static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { - ::std::stringstream ss; - UniversalTersePrint(::std::tr1::get<0>(t), &ss); - strings->push_back(ss.str()); - } -}; -// Helper function for printing a tuple. T must be instantiated with -// a tuple type. -template <typename T> -void PrintTupleTo(const T& t, ::std::ostream* os) { +// Helper function for printing a tuple. +// Tuple must be either std::tr1::tuple or std::tuple type. +template <typename Tuple> +void PrintTupleTo(const Tuple& t, ::std::ostream* os) { *os << "("; - TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>:: - PrintPrefixTo(t, os); + TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os); *os << ")"; } @@ -835,14 +1076,24 @@ void PrintTupleTo(const T& t, ::std::ostream* os) { template <typename Tuple> Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) { Strings result; - TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>:: + TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>:: TersePrintPrefixToStrings(value, &result); return result; } -#endif // GTEST_HAS_TR1_TUPLE +#endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ } // namespace internal +#if GTEST_HAS_ABSL +namespace internal2 { +template <typename T> +void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue( + const T& value, ::std::ostream* os) { + internal::PrintTo(absl::string_view(value), os); +} +} // namespace internal2 +#endif + template <typename T> ::std::string PrintToString(const T& value) { ::std::stringstream ss; @@ -852,4 +1103,9 @@ ::std::string PrintToString(const T& value) { } // namespace testing +// Include any custom printer added by the local installation. +// We must include this header at the end to make sure it can use the +// declarations from this file. +#include "gtest/internal/custom/gtest-printers.h" + #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest-spi.h b/src/test/fmw/gtest/include/gtest/gtest-spi.h index f63fa9a1b2a..1e8983938ea 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-spi.h +++ b/src/test/fmw/gtest/include/gtest/gtest-spi.h @@ -26,17 +26,21 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) + // // Utilities for testing Google Test itself and code that uses Google Test // (e.g. frameworks built on top of Google Test). +// GOOGLETEST_CM0004 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_ #define GTEST_INCLUDE_GTEST_GTEST_SPI_H_ #include "gtest/gtest.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + namespace testing { // This helper class can be used to mock out Google Test failure reporting @@ -97,13 +101,12 @@ class GTEST_API_ SingleFailureChecker { public: // The constructor remembers the arguments. SingleFailureChecker(const TestPartResultArray* results, - TestPartResult::Type type, - const string& substr); + TestPartResult::Type type, const std::string& substr); ~SingleFailureChecker(); private: const TestPartResultArray* const results_; const TestPartResult::Type type_; - const string substr_; + const std::string substr_; GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); }; @@ -112,6 +115,8 @@ class GTEST_API_ SingleFailureChecker { } // namespace testing +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + // A set of macros for testing Google Test assertions or code that's expected // to generate Google Test fatal failures. It verifies that the given // statement will cause exactly one fatal Google Test failure with 'substr' diff --git a/src/test/fmw/gtest/include/gtest/gtest-test-part.h b/src/test/fmw/gtest/include/gtest/gtest-test-part.h index 77eb844839d..1c7b89e0879 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-test-part.h +++ b/src/test/fmw/gtest/include/gtest/gtest-test-part.h @@ -27,8 +27,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Author: mheule@google.com (Markus Heule) -// +// GOOGLETEST_CM0001 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ #define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ @@ -38,6 +37,9 @@ #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-string.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + namespace testing { // A copyable object representing the result of a test part (i.e. an @@ -143,7 +145,7 @@ class GTEST_API_ TestPartResultArray { }; // This interface knows how to report a test part result. -class TestPartResultReporterInterface { +class GTEST_API_ TestPartResultReporterInterface { public: virtual ~TestPartResultReporterInterface() {} @@ -176,4 +178,6 @@ class GTEST_API_ HasNewFatalFailureHelper } // namespace testing +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + #endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest-typed-test.h b/src/test/fmw/gtest/include/gtest/gtest-typed-test.h index fe1e83b274b..74bce46bdc5 100644 --- a/src/test/fmw/gtest/include/gtest/gtest-typed-test.h +++ b/src/test/fmw/gtest/include/gtest/gtest-typed-test.h @@ -26,8 +26,9 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) + + +// GOOGLETEST_CM0001 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ @@ -82,6 +83,24 @@ TYPED_TEST(FooTest, DoesBlah) { TYPED_TEST(FooTest, HasPropertyA) { ... } +// TYPED_TEST_CASE takes an optional third argument which allows to specify a +// class that generates custom test name suffixes based on the type. This should +// be a class which has a static template function GetName(int index) returning +// a string for each type. The provided integer index equals the index of the +// type in the provided type list. In many cases the index can be ignored. +// +// For example: +// class MyTypeNames { +// public: +// template <typename T> +// static std::string GetName(int) { +// if (std::is_same<T, char>()) return "char"; +// if (std::is_same<T, int>()) return "int"; +// if (std::is_same<T, unsigned int>()) return "unsignedInt"; +// } +// }; +// TYPED_TEST_CASE(FooTest, MyTypes, MyTypeNames); + #endif // 0 // Type-parameterized tests are abstract test patterns parameterized @@ -143,6 +162,11 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes); // If the type list contains only one type, you can write that type // directly without Types<...>: // INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int); +// +// Similar to the optional argument of TYPED_TEST_CASE above, +// INSTANTIATE_TEST_CASE_P takes an optional fourth argument which allows to +// generate custom names. +// INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes, MyTypeNames); #endif // 0 @@ -159,31 +183,46 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes); // given test case. # define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_ +// Expands to the name of the typedef for the NameGenerator, responsible for +// creating the suffixes of the name. +#define GTEST_NAME_GENERATOR_(TestCaseName) \ + gtest_type_params_##TestCaseName##_NameGenerator + // The 'Types' template argument below must have spaces around it // since some compilers may choke on '>>' when passing a template // instance (e.g. Types<int>) -# define TYPED_TEST_CASE(CaseName, Types) \ - typedef ::testing::internal::TypeList< Types >::type \ - GTEST_TYPE_PARAMS_(CaseName) - -# define TYPED_TEST(CaseName, TestName) \ - template <typename gtest_TypeParam_> \ - class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ - : public CaseName<gtest_TypeParam_> { \ - private: \ - typedef CaseName<gtest_TypeParam_> TestFixture; \ - typedef gtest_TypeParam_ TypeParam; \ - virtual void TestBody(); \ - }; \ - bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \ - ::testing::internal::TypeParameterizedTest< \ - CaseName, \ - ::testing::internal::TemplateSel< \ - GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \ - GTEST_TYPE_PARAMS_(CaseName)>::Register(\ - "", #CaseName, #TestName, 0); \ - template <typename gtest_TypeParam_> \ - void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody() +# define TYPED_TEST_CASE(CaseName, Types, ...) \ + typedef ::testing::internal::TypeList< Types >::type GTEST_TYPE_PARAMS_( \ + CaseName); \ + typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \ + GTEST_NAME_GENERATOR_(CaseName) + +# define TYPED_TEST(CaseName, TestName) \ + template <typename gtest_TypeParam_> \ + class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ + : public CaseName<gtest_TypeParam_> { \ + private: \ + typedef CaseName<gtest_TypeParam_> TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + virtual void TestBody(); \ + }; \ + static bool gtest_##CaseName##_##TestName##_registered_ \ + GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTest< \ + CaseName, \ + ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \ + TestName)>, \ + GTEST_TYPE_PARAMS_( \ + CaseName)>::Register("", \ + ::testing::internal::CodeLocation( \ + __FILE__, __LINE__), \ + #CaseName, #TestName, 0, \ + ::testing::internal::GenerateNames< \ + GTEST_NAME_GENERATOR_(CaseName), \ + GTEST_TYPE_PARAMS_(CaseName)>()); \ + template <typename gtest_TypeParam_> \ + void GTEST_TEST_CLASS_NAME_(CaseName, \ + TestName)<gtest_TypeParam_>::TestBody() #endif // GTEST_HAS_TYPED_TEST @@ -240,19 +279,27 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes); namespace GTEST_CASE_NAMESPACE_(CaseName) { \ typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \ } \ - static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \ - GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\ - __FILE__, __LINE__, #__VA_ARGS__) + static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) \ + GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames( \ + __FILE__, __LINE__, #__VA_ARGS__) // The 'Types' template argument below must have spaces around it // since some compilers may choke on '>>' when passing a template // instance (e.g. Types<int>) -# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \ - bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \ - ::testing::internal::TypeParameterizedTestCase<CaseName, \ - GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \ - ::testing::internal::TypeList< Types >::type>::Register(\ - #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName)) +# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types, ...) \ + static bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTestCase< \ + CaseName, GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \ + ::testing::internal::TypeList< Types >::type>:: \ + Register(#Prefix, \ + ::testing::internal::CodeLocation(__FILE__, __LINE__), \ + >EST_TYPED_TEST_CASE_P_STATE_(CaseName), #CaseName, \ + GTEST_REGISTERED_TEST_NAMES_(CaseName), \ + ::testing::internal::GenerateNames< \ + ::testing::internal::NameGeneratorSelector< \ + __VA_ARGS__>::type, \ + ::testing::internal::TypeList< Types >::type>()) #endif // GTEST_HAS_TYPED_TEST_P diff --git a/src/test/fmw/gtest/include/gtest/gtest.h b/src/test/fmw/gtest/include/gtest/gtest.h index 6fa0a3925e7..325bbe05970 100644 --- a/src/test/fmw/gtest/include/gtest/gtest.h +++ b/src/test/fmw/gtest/include/gtest/gtest.h @@ -26,10 +26,9 @@ // 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. + // -// Author: wan@google.com (Zhanyong Wan) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) // // This header file defines the public API for Google Test. It should be // included by any test program that uses Google Test. @@ -48,6 +47,8 @@ // registration from Barthelemy Dagenais' (barthelemy@prologique.com) // easyUnit framework. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_GTEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_H_ @@ -65,23 +66,35 @@ #include "gtest/gtest-test-part.h" #include "gtest/gtest-typed-test.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + // Depending on the platform, different string classes are available. // On Linux, in addition to ::std::string, Google also makes use of // class ::string, which has the same interface as ::std::string, but // has a different implementation. // -// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that +// You can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that // ::string is available AND is a distinct type to ::std::string, or // define it to 0 to indicate otherwise. // -// If the user's ::std::string and ::string are the same class due to -// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0. +// If ::std::string and ::string are the same class on your platform +// due to aliasing, you should define GTEST_HAS_GLOBAL_STRING to 0. // -// If the user doesn't define GTEST_HAS_GLOBAL_STRING, it is defined +// If you do not define GTEST_HAS_GLOBAL_STRING, it is defined // heuristically. namespace testing { +// Silence C4100 (unreferenced formal parameter) and 4805 +// unsafe mix of type 'const int' and type 'const bool' +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4805) +# pragma warning(disable:4100) +#endif + + // Declares the flags. // This flag temporary enables the disabled tests. @@ -103,6 +116,10 @@ GTEST_DECLARE_string_(color); // the tests to run. If the filter is not given all tests are executed. GTEST_DECLARE_string_(filter); +// This flag controls whether Google Test installs a signal handler that dumps +// debugging information when fatal signals are raised. +GTEST_DECLARE_bool_(install_failure_signal_handler); + // This flag causes the Google Test to list tests. None of the tests listed // are actually run if the flag is provided. GTEST_DECLARE_bool_(list_tests); @@ -115,6 +132,9 @@ GTEST_DECLARE_string_(output); // test. GTEST_DECLARE_bool_(print_time); +// This flags control whether Google Test prints UTF8 characters as text. +GTEST_DECLARE_bool_(print_utf8); + // This flag specifies the random number seed. GTEST_DECLARE_int32_(random_seed); @@ -135,7 +155,7 @@ GTEST_DECLARE_int32_(stack_trace_depth); // When this flag is specified, a failed assertion will throw an // exception if exceptions are enabled, or exit the program with a -// non-zero code otherwise. +// non-zero code otherwise. For use with an external test framework. GTEST_DECLARE_bool_(throw_on_failure); // When this flag is set with a "host:port" string, on supported @@ -143,6 +163,10 @@ GTEST_DECLARE_bool_(throw_on_failure); // the specified host machine. GTEST_DECLARE_string_(stream_result_to); +#if GTEST_USE_OWN_FLAGFILE_FLAG_ +GTEST_DECLARE_string_(flagfile); +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ + // The upper limit for valid stack trace depths. const int kMaxStackTraceDepth = 100; @@ -160,6 +184,7 @@ class TestEventListenersAccessor; class TestEventRepeater; class UnitTestRecordPropertyTestHelper; class WindowsDeathTest; +class FuchsiaDeathTest; class UnitTestImpl* GetUnitTestImpl(); void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); @@ -258,8 +283,35 @@ class GTEST_API_ AssertionResult { // Copy constructor. // Used in EXPECT_TRUE/FALSE(assertion_result). AssertionResult(const AssertionResult& other); + +#if defined(_MSC_VER) && _MSC_VER < 1910 + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */) +#endif + // Used in the EXPECT_TRUE/FALSE(bool_expression). - explicit AssertionResult(bool success) : success_(success) {} + // + // T must be contextually convertible to bool. + // + // The second parameter prevents this overload from being considered if + // the argument is implicitly convertible to AssertionResult. In that case + // we want AssertionResult's copy constructor to be used. + template <typename T> + explicit AssertionResult( + const T& success, + typename internal::EnableIf< + !internal::ImplicitlyConvertible<T, AssertionResult>::value>::type* + /*enabler*/ = NULL) + : success_(success) {} + +#if defined(_MSC_VER) && _MSC_VER < 1910 + GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif + + // Assignment operator. + AssertionResult& operator=(AssertionResult other) { + swap(other); + return *this; + } // Returns true iff the assertion succeeded. operator bool() const { return success_; } // NOLINT @@ -274,7 +326,7 @@ class GTEST_API_ AssertionResult { const char* message() const { return message_.get() != NULL ? message_->c_str() : ""; } - // TODO(vladl@google.com): Remove this after making sure no clients use it. + // FIXME: Remove this after making sure no clients use it. // Deprecated; please use message() instead. const char* failure_message() const { return message(); } @@ -300,6 +352,9 @@ class GTEST_API_ AssertionResult { message_->append(a_message.GetString().c_str()); } + // Swap the contents of this AssertionResult with other. + void swap(AssertionResult& other); + // Stores result of the assertion predicate. bool success_; // Stores the message describing the condition in case the expectation @@ -307,8 +362,6 @@ class GTEST_API_ AssertionResult { // Referenced via a pointer to avoid taking too much stack frame space // with test assertions. internal::scoped_ptr< ::std::string> message_; - - GTEST_DISALLOW_ASSIGN_(AssertionResult); }; // Makes a successful assertion result. @@ -321,6 +374,15 @@ GTEST_API_ AssertionResult AssertionFailure(); // Deprecated; use AssertionFailure() << msg. GTEST_API_ AssertionResult AssertionFailure(const Message& msg); +} // namespace testing + +// Includes the auto-generated header that implements a family of generic +// predicate assertion macros. This include comes late because it relies on +// APIs declared above. +#include "gtest/gtest_pred_impl.h" + +namespace testing { + // The abstract class that all tests inherit from. // // In Google Test, a unit test program contains one or many TestCases, and @@ -331,12 +393,12 @@ GTEST_API_ AssertionResult AssertionFailure(const Message& msg); // this for you. // // The only time you derive from Test is when defining a test fixture -// to be used a TEST_F. For example: +// to be used in a TEST_F. For example: // // class FooTest : public testing::Test { // protected: -// virtual void SetUp() { ... } -// virtual void TearDown() { ... } +// void SetUp() override { ... } +// void TearDown() override { ... } // ... // }; // @@ -428,20 +490,19 @@ class GTEST_API_ Test { // internal method to avoid clashing with names used in user TESTs. void DeleteSelf_() { delete this; } - // Uses a GTestFlagSaver to save and restore all Google Test flags. - const internal::GTestFlagSaver* const gtest_flag_saver_; + const internal::scoped_ptr< GTEST_FLAG_SAVER_ > gtest_flag_saver_; - // Often a user mis-spells SetUp() as Setup() and spends a long time + // Often a user misspells SetUp() as Setup() and spends a long time // wondering why it is never called by Google Test. The declaration of // the following method is solely for catching such an error at // compile time: // // - The return type is deliberately chosen to be not void, so it - // will be a conflict if a user declares void Setup() in his test - // fixture. + // will be a conflict if void Setup() is declared in the user's + // test fixture. // // - This method is private, so it will be another compiler error - // if a user calls it from his test fixture. + // if the method is called from the user's test fixture. // // DO NOT OVERRIDE THIS FUNCTION. // @@ -527,9 +588,8 @@ class GTEST_API_ TestResult { // Returns the elapsed time, in milliseconds. TimeInMillis elapsed_time() const { return elapsed_time_; } - // Returns the i-th test part result among all the results. i can range - // from 0 to test_property_count() - 1. If i is not in that range, aborts - // the program. + // Returns the i-th test part result among all the results. i can range from 0 + // to total_part_count() - 1. If i is not in that range, aborts the program. const TestPartResult& GetTestPartResult(int i) const; // Returns the i-th test property. i can range from 0 to @@ -546,6 +606,7 @@ class GTEST_API_ TestResult { friend class internal::TestResultAccessor; friend class internal::UnitTestImpl; friend class internal::WindowsDeathTest; + friend class internal::FuchsiaDeathTest; // Gets the vector of TestPartResults. const std::vector<TestPartResult>& test_part_results() const { @@ -571,7 +632,7 @@ class GTEST_API_ TestResult { // Adds a failure if the key is a reserved attribute of Google Test // testcase tags. Returns true if the property is valid. - // TODO(russr): Validate attribute names are legal and human readable. + // FIXME: Validate attribute names are legal and human readable. static bool ValidateTestProperty(const std::string& xml_element, const TestProperty& test_property); @@ -646,6 +707,15 @@ class GTEST_API_ TestInfo { return NULL; } + // Returns the file name where this test is defined. + const char* file() const { return location_.file; } + + // Returns the line where this test is defined. + int line() const { return location_.line; } + + // Return true if this test should not be run because it's in another shard. + bool is_in_another_shard() const { return is_in_another_shard_; } + // Returns true if this test should run, that is if the test is not // disabled (or it is disabled but the also_run_disabled_tests flag has // been specified) and its full name matches the user-specified filter. @@ -666,10 +736,9 @@ class GTEST_API_ TestInfo { // Returns true iff this test will appear in the XML report. bool is_reportable() const { - // For now, the XML report includes all tests matching the filter. - // In the future, we may trim tests that are excluded because of - // sharding. - return matches_filter_; + // The XML report includes tests matching the filter, excluding those + // run in other shards. + return matches_filter_ && !is_in_another_shard_; } // Returns the result of the test. @@ -688,6 +757,7 @@ class GTEST_API_ TestInfo { const char* name, const char* type_param, const char* value_param, + internal::CodeLocation code_location, internal::TypeId fixture_class_id, Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc, @@ -699,6 +769,7 @@ class GTEST_API_ TestInfo { const std::string& name, const char* a_type_param, // NULL if not a type-parameterized test const char* a_value_param, // NULL if not a value-parameterized test + internal::CodeLocation a_code_location, internal::TypeId fixture_class_id, internal::TestFactoryBase* factory); @@ -725,11 +796,13 @@ class GTEST_API_ TestInfo { // Text representation of the value parameter, or NULL if this is not a // value-parameterized test. const internal::scoped_ptr<const ::std::string> value_param_; + internal::CodeLocation location_; const internal::TypeId fixture_class_id_; // ID of the test fixture class bool should_run_; // True iff this test should run bool is_disabled_; // True iff this test is disabled bool matches_filter_; // True if this test matches the // user-specified filter. + bool is_in_another_shard_; // Will be run in another shard. internal::TestFactoryBase* const factory_; // The factory that creates // the test object @@ -924,7 +997,7 @@ class GTEST_API_ TestCase { }; // An Environment object is capable of setting up and tearing down an -// environment. The user should subclass this to define his own +// environment. You should subclass this to define your own // environment(s). // // An Environment object does the set-up and tear-down in virtual @@ -954,6 +1027,18 @@ class Environment { virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; } }; +#if GTEST_HAS_EXCEPTIONS + +// Exception which can be thrown from TestEventListener::OnTestPartResult. +class GTEST_API_ AssertionException + : public internal::GoogleTestFailureException { + public: + explicit AssertionException(const TestPartResult& result) + : GoogleTestFailureException(result) {} +}; + +#endif // GTEST_HAS_EXCEPTIONS + // The interface for tracing execution of tests. The methods are organized in // the order the corresponding events are fired. class TestEventListener { @@ -982,6 +1067,8 @@ class TestEventListener { virtual void OnTestStart(const TestInfo& test_info) = 0; // Fired after a failed assertion or a SUCCEED() invocation. + // If you want to throw an exception from this function to skip to the next + // TEST, it must be AssertionException defined above, or inherited from it. virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0; // Fired after the test ends. @@ -1148,14 +1235,12 @@ class GTEST_API_ UnitTest { // Returns the random seed used at the start of the current test run. int random_seed() const; -#if GTEST_HAS_PARAM_TEST // Returns the ParameterizedTestCaseRegistry object used to keep track of // value-parameterized tests and instantiate and register them. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. internal::ParameterizedTestCaseRegistry& parameterized_test_registry() GTEST_LOCK_EXCLUDED_(mutex_); -#endif // GTEST_HAS_PARAM_TEST // Gets the number of successful test cases. int successful_test_case_count() const; @@ -1255,11 +1340,11 @@ class GTEST_API_ UnitTest { internal::UnitTestImpl* impl() { return impl_; } const internal::UnitTestImpl* impl() const { return impl_; } - // These classes and funcions are friends as they need to access private + // These classes and functions are friends as they need to access private // members of UnitTest. + friend class ScopedTrace; friend class Test; friend class internal::AssertHelper; - friend class internal::ScopedTrace; friend class internal::StreamingListenerTest; friend class internal::UnitTestRecordPropertyTestHelper; friend Environment* AddGlobalTestEnvironment(Environment* env); @@ -1336,137 +1421,40 @@ GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv); namespace internal { -// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a -// value of type ToPrint that is an operand of a comparison assertion -// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in -// the comparison, and is used to help determine the best way to -// format the value. In particular, when the value is a C string -// (char pointer) and the other operand is an STL string object, we -// want to format the C string as a string, since we know it is -// compared by value with the string object. If the value is a char -// pointer but the other operand is not an STL string object, we don't -// know whether the pointer is supposed to point to a NUL-terminated -// string, and thus want to print it as a pointer to be safe. -// -// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. - -// The default case. -template <typename ToPrint, typename OtherOperand> -class FormatForComparison { - public: - static ::std::string Format(const ToPrint& value) { - return ::testing::PrintToString(value); - } -}; - -// Array. -template <typename ToPrint, size_t N, typename OtherOperand> -class FormatForComparison<ToPrint[N], OtherOperand> { - public: - static ::std::string Format(const ToPrint* value) { - return FormatForComparison<const ToPrint*, OtherOperand>::Format(value); - } -}; - -// By default, print C string as pointers to be safe, as we don't know -// whether they actually point to a NUL-terminated string. - -#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \ - template <typename OtherOperand> \ - class FormatForComparison<CharType*, OtherOperand> { \ - public: \ - static ::std::string Format(CharType* value) { \ - return ::testing::PrintToString(static_cast<const void*>(value)); \ - } \ - } - -GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char); -GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char); -GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t); -GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t); - -#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_ - -// If a C string is compared with an STL string object, we know it's meant -// to point to a NUL-terminated string, and thus can print it as a string. - -#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ - template <> \ - class FormatForComparison<CharType*, OtherStringType> { \ - public: \ - static ::std::string Format(CharType* value) { \ - return ::testing::PrintToString(value); \ - } \ - } - -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string); -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string); - -#if GTEST_HAS_GLOBAL_STRING -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string); -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string); -#endif - -#if GTEST_HAS_GLOBAL_WSTRING -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring); -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring); -#endif - -#if GTEST_HAS_STD_WSTRING -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring); -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring); -#endif - -#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_ - -// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc) -// operand to be used in a failure message. The type (but not value) -// of the other operand may affect the format. This allows us to -// print a char* as a raw pointer when it is compared against another -// char* or void*, and print it as a C string when it is compared -// against an std::string object, for example. -// -// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +// Separate the error generating code from the code path to reduce the stack +// frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers +// when calling EXPECT_* in a tight loop. template <typename T1, typename T2> -std::string FormatForComparisonFailureMessage( - const T1& value, const T2& /* other_operand */) { - return FormatForComparison<T1, T2>::Format(value); +AssertionResult CmpHelperEQFailure(const char* lhs_expression, + const char* rhs_expression, + const T1& lhs, const T2& rhs) { + return EqFailure(lhs_expression, + rhs_expression, + FormatForComparisonFailureMessage(lhs, rhs), + FormatForComparisonFailureMessage(rhs, lhs), + false); } // The helper function for {ASSERT|EXPECT}_EQ. template <typename T1, typename T2> -AssertionResult CmpHelperEQ(const char* expected_expression, - const char* actual_expression, - const T1& expected, - const T2& actual) { -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4389) // Temporarily disables warning on - // signed/unsigned mismatch. -#endif - - if (expected == actual) { +AssertionResult CmpHelperEQ(const char* lhs_expression, + const char* rhs_expression, + const T1& lhs, + const T2& rhs) { + if (lhs == rhs) { return AssertionSuccess(); } -#ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. -#endif - - return EqFailure(expected_expression, - actual_expression, - FormatForComparisonFailureMessage(expected, actual), - FormatForComparisonFailureMessage(actual, expected), - false); + return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs); } // With this overloaded version, we allow anonymous enums to be used // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums // can be implicitly cast to BiggestInt. -GTEST_API_ AssertionResult CmpHelperEQ(const char* expected_expression, - const char* actual_expression, - BiggestInt expected, - BiggestInt actual); +GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression, + const char* rhs_expression, + BiggestInt lhs, + BiggestInt rhs); // The helper class for {ASSERT|EXPECT}_EQ. The template argument // lhs_is_null_literal is true iff the first argument to ASSERT_EQ() @@ -1477,12 +1465,11 @@ class EqHelper { public: // This templatized version is for the general case. template <typename T1, typename T2> - static AssertionResult Compare(const char* expected_expression, - const char* actual_expression, - const T1& expected, - const T2& actual) { - return CmpHelperEQ(expected_expression, actual_expression, expected, - actual); + static AssertionResult Compare(const char* lhs_expression, + const char* rhs_expression, + const T1& lhs, + const T2& rhs) { + return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); } // With this overloaded version, we allow anonymous enums to be used @@ -1491,12 +1478,11 @@ class EqHelper { // // Even though its body looks the same as the above version, we // cannot merge the two, as it will make anonymous enums unhappy. - static AssertionResult Compare(const char* expected_expression, - const char* actual_expression, - BiggestInt expected, - BiggestInt actual) { - return CmpHelperEQ(expected_expression, actual_expression, expected, - actual); + static AssertionResult Compare(const char* lhs_expression, + const char* rhs_expression, + BiggestInt lhs, + BiggestInt rhs) { + return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); } }; @@ -1511,40 +1497,52 @@ class EqHelper<true> { // EXPECT_EQ(false, a_bool). template <typename T1, typename T2> static AssertionResult Compare( - const char* expected_expression, - const char* actual_expression, - const T1& expected, - const T2& actual, + const char* lhs_expression, + const char* rhs_expression, + const T1& lhs, + const T2& rhs, // The following line prevents this overload from being considered if T2 // is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr) // expands to Compare("", "", NULL, my_ptr), which requires a conversion // to match the Secret* in the other overload, which would otherwise make // this template match better. typename EnableIf<!is_pointer<T2>::value>::type* = 0) { - return CmpHelperEQ(expected_expression, actual_expression, expected, - actual); + return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); } // This version will be picked when the second argument to ASSERT_EQ() is a // pointer, e.g. ASSERT_EQ(NULL, a_pointer). template <typename T> static AssertionResult Compare( - const char* expected_expression, - const char* actual_expression, + const char* lhs_expression, + const char* rhs_expression, // We used to have a second template parameter instead of Secret*. That // template parameter would deduce to 'long', making this a better match // than the first overload even without the first overload's EnableIf. // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to // non-pointer argument" (even a deduced integral argument), so the old // implementation caused warnings in user code. - Secret* /* expected (NULL) */, - T* actual) { - // We already know that 'expected' is a null pointer. - return CmpHelperEQ(expected_expression, actual_expression, - static_cast<T*>(NULL), actual); + Secret* /* lhs (NULL) */, + T* rhs) { + // We already know that 'lhs' is a null pointer. + return CmpHelperEQ(lhs_expression, rhs_expression, + static_cast<T*>(NULL), rhs); } }; +// Separate the error generating code from the code path to reduce the stack +// frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers +// when calling EXPECT_OP in a tight loop. +template <typename T1, typename T2> +AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, + const T1& val1, const T2& val2, + const char* op) { + return AssertionFailure() + << "Expected: (" << expr1 << ") " << op << " (" << expr2 + << "), actual: " << FormatForComparisonFailureMessage(val1, val2) + << " vs " << FormatForComparisonFailureMessage(val2, val1); +} + // A macro for implementing the helper functions needed to implement // ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste // of similar code. @@ -1555,6 +1553,7 @@ class EqHelper<true> { // with gcc 4. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + #define GTEST_IMPL_CMP_HELPER_(op_name, op)\ template <typename T1, typename T2>\ AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ @@ -1562,10 +1561,7 @@ AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ if (val1 op val2) {\ return AssertionSuccess();\ } else {\ - return AssertionFailure() \ - << "Expected: (" << expr1 << ") " #op " (" << expr2\ - << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ - << " vs " << FormatForComparisonFailureMessage(val2, val1);\ + return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\ }\ }\ GTEST_API_ AssertionResult CmpHelper##op_name(\ @@ -1589,18 +1585,18 @@ GTEST_IMPL_CMP_HELPER_(GT, >); // The helper function for {ASSERT|EXPECT}_STREQ. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. -GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression, - const char* actual_expression, - const char* expected, - const char* actual); +GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); // The helper function for {ASSERT|EXPECT}_STRCASEEQ. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. -GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression, - const char* actual_expression, - const char* expected, - const char* actual); +GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); // The helper function for {ASSERT|EXPECT}_STRNE. // @@ -1622,10 +1618,10 @@ GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression, // Helper function for *_STREQ on wide strings. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. -GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression, - const char* actual_expression, - const wchar_t* expected, - const wchar_t* actual); +GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, + const char* s2_expression, + const wchar_t* s1, + const wchar_t* s2); // Helper function for *_STRNE on wide strings. // @@ -1683,28 +1679,28 @@ namespace internal { // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. template <typename RawType> -AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression, - const char* actual_expression, - RawType expected, - RawType actual) { - const FloatingPoint<RawType> lhs(expected), rhs(actual); +AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression, + const char* rhs_expression, + RawType lhs_value, + RawType rhs_value) { + const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value); if (lhs.AlmostEquals(rhs)) { return AssertionSuccess(); } - ::std::stringstream expected_ss; - expected_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) - << expected; + ::std::stringstream lhs_ss; + lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) + << lhs_value; - ::std::stringstream actual_ss; - actual_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) - << actual; + ::std::stringstream rhs_ss; + rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) + << rhs_value; - return EqFailure(expected_expression, - actual_expression, - StringStreamToString(&expected_ss), - StringStreamToString(&actual_ss), + return EqFailure(lhs_expression, + rhs_expression, + StringStreamToString(&lhs_ss), + StringStreamToString(&rhs_ss), false); } @@ -1761,7 +1757,6 @@ class GTEST_API_ AssertHelper { } // namespace internal -#if GTEST_HAS_PARAM_TEST // The pure interface class that all value-parameterized tests inherit from. // A value-parameterized class must inherit from both ::testing::Test and // ::testing::WithParamInterface. In most cases that just means inheriting @@ -1838,8 +1833,6 @@ template <typename T> class TestWithParam : public Test, public WithParamInterface<T> { }; -#endif // GTEST_HAS_PARAM_TEST - // Macros for indicating success/failure in test code. // ADD_FAILURE unconditionally adds a failure to the current test. @@ -1924,18 +1917,14 @@ class TestWithParam : public Test, public WithParamInterface<T> { GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_FATAL_FAILURE_) -// Includes the auto-generated header that implements a family of -// generic predicate assertion macros. -#include "gtest/gtest_pred_impl.h" - // Macros for testing equalities and inequalities. // -// * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual -// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2 -// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2 -// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2 -// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2 -// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2 +// * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2 +// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2 +// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2 +// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2 +// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2 +// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2 // // When they are not, Google Test prints both the tested expressions and // their actual values. The values must be compatible built-in types, @@ -1957,8 +1946,8 @@ class TestWithParam : public Test, public WithParamInterface<T> { // are related, not how their content is related. To compare two C // strings by content, use {ASSERT|EXPECT}_STR*(). // -// 3. {ASSERT|EXPECT}_EQ(expected, actual) is preferred to -// {ASSERT|EXPECT}_TRUE(expected == actual), as the former tells you +// 3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to +// {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you // what the actual value is when it fails, and similarly for the // other comparisons. // @@ -1969,17 +1958,17 @@ class TestWithParam : public Test, public WithParamInterface<T> { // // Examples: // -// EXPECT_NE(5, Foo()); -// EXPECT_EQ(NULL, a_pointer); +// EXPECT_NE(Foo(), 5); +// EXPECT_EQ(a_pointer, NULL); // ASSERT_LT(i, array_size); // ASSERT_GT(records.size(), 0) << "There is no record left."; -#define EXPECT_EQ(expected, actual) \ +#define EXPECT_EQ(val1, val2) \ EXPECT_PRED_FORMAT2(::testing::internal:: \ - EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \ - expected, actual) -#define EXPECT_NE(expected, actual) \ - EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, expected, actual) + EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \ + val1, val2) +#define EXPECT_NE(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) #define EXPECT_LE(val1, val2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) #define EXPECT_LT(val1, val2) \ @@ -1989,10 +1978,10 @@ class TestWithParam : public Test, public WithParamInterface<T> { #define EXPECT_GT(val1, val2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) -#define GTEST_ASSERT_EQ(expected, actual) \ +#define GTEST_ASSERT_EQ(val1, val2) \ ASSERT_PRED_FORMAT2(::testing::internal:: \ - EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \ - expected, actual) + EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \ + val1, val2) #define GTEST_ASSERT_NE(val1, val2) \ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) #define GTEST_ASSERT_LE(val1, val2) \ @@ -2047,29 +2036,29 @@ class TestWithParam : public Test, public WithParamInterface<T> { // // These macros evaluate their arguments exactly once. -#define EXPECT_STREQ(expected, actual) \ - EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual) +#define EXPECT_STREQ(s1, s2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2) #define EXPECT_STRNE(s1, s2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) -#define EXPECT_STRCASEEQ(expected, actual) \ - EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual) +#define EXPECT_STRCASEEQ(s1, s2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) #define EXPECT_STRCASENE(s1, s2)\ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) -#define ASSERT_STREQ(expected, actual) \ - ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual) +#define ASSERT_STREQ(s1, s2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2) #define ASSERT_STRNE(s1, s2) \ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) -#define ASSERT_STRCASEEQ(expected, actual) \ - ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual) +#define ASSERT_STRCASEEQ(s1, s2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) #define ASSERT_STRCASENE(s1, s2)\ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) // Macros for comparing floating-point numbers. // -// * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual): +// * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2): // Tests that two float values are almost equal. -// * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual): +// * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2): // Tests that two double values are almost equal. // * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error): // Tests that v1 and v2 are within the given distance to each other. @@ -2079,21 +2068,21 @@ class TestWithParam : public Test, public WithParamInterface<T> { // FloatingPoint template class in gtest-internal.h if you are // interested in the implementation details. -#define EXPECT_FLOAT_EQ(expected, actual)\ +#define EXPECT_FLOAT_EQ(val1, val2)\ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \ - expected, actual) + val1, val2) -#define EXPECT_DOUBLE_EQ(expected, actual)\ +#define EXPECT_DOUBLE_EQ(val1, val2)\ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \ - expected, actual) + val1, val2) -#define ASSERT_FLOAT_EQ(expected, actual)\ +#define ASSERT_FLOAT_EQ(val1, val2)\ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \ - expected, actual) + val1, val2) -#define ASSERT_DOUBLE_EQ(expected, actual)\ +#define ASSERT_DOUBLE_EQ(val1, val2)\ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \ - expected, actual) + val1, val2) #define EXPECT_NEAR(val1, val2, abs_error)\ EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ @@ -2156,6 +2145,57 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, #define EXPECT_NO_FATAL_FAILURE(statement) \ GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) +// Causes a trace (including the given source file path and line number, +// and the given message) to be included in every test failure message generated +// by code in the scope of the lifetime of an instance of this class. The effect +// is undone with the destruction of the instance. +// +// The message argument can be anything streamable to std::ostream. +// +// Example: +// testing::ScopedTrace trace("file.cc", 123, "message"); +// +class GTEST_API_ ScopedTrace { + public: + // The c'tor pushes the given source file location and message onto + // a trace stack maintained by Google Test. + + // Template version. Uses Message() to convert the values into strings. + // Slow, but flexible. + template <typename T> + ScopedTrace(const char* file, int line, const T& message) { + PushTrace(file, line, (Message() << message).GetString()); + } + + // Optimize for some known types. + ScopedTrace(const char* file, int line, const char* message) { + PushTrace(file, line, message ? message : "(null)"); + } + +#if GTEST_HAS_GLOBAL_STRING + ScopedTrace(const char* file, int line, const ::string& message) { + PushTrace(file, line, message); + } +#endif + + ScopedTrace(const char* file, int line, const std::string& message) { + PushTrace(file, line, message); + } + + // The d'tor pops the info pushed by the c'tor. + // + // Note that the d'tor is not virtual in order to be efficient. + // Don't inherit from ScopedTrace! + ~ScopedTrace(); + + private: + void PushTrace(const char* file, int line, std::string message); + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); +} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its + // c'tor and d'tor. Therefore it doesn't + // need to be used otherwise. + // Causes a trace (including the source file path, the current line // number, and the given message) to be included in every test failure // message generated by code in the current scope. The effect is @@ -2167,9 +2207,14 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, // of the dummy variable name, thus allowing multiple SCOPED_TRACE()s // to appear in the same block - as long as they are on different // lines. +// +// Assuming that each thread maintains its own stack of traces. +// Therefore, a SCOPED_TRACE() would (correctly) only affect the +// assertions in its own thread. #define SCOPED_TRACE(message) \ - ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ - __FILE__, __LINE__, ::testing::Message() << (message)) + ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ + __FILE__, __LINE__, (message)) + // Compile-time assertion for type equality. // StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are @@ -2215,8 +2260,8 @@ bool StaticAssertTypeEq() { // The convention is to end the test case name with "Test". For // example, a test case for the Foo class can be named FooTest. // -// The user should put his test code between braces after using this -// macro. Example: +// Test code should appear between braces after an invocation of +// this macro. Example: // // TEST(FooTest, InitializesCorrectly) { // Foo foo; @@ -2249,7 +2294,7 @@ bool StaticAssertTypeEq() { // name of the test within the test case. // // A test fixture class must be declared earlier. The user should put -// his test code between braces after using this macro. Example: +// the test code between braces after using this macro. Example: // // class FooTest : public testing::Test { // protected: @@ -2264,14 +2309,22 @@ bool StaticAssertTypeEq() { // } // // TEST_F(FooTest, ReturnsElementCountCorrectly) { -// EXPECT_EQ(0, a_.size()); -// EXPECT_EQ(1, b_.size()); +// EXPECT_EQ(a_.size(), 0); +// EXPECT_EQ(b_.size(), 1); // } #define TEST_F(test_fixture, test_name)\ GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId<test_fixture>()) +// Returns a path to temporary directory. +// Tries to determine an appropriate directory for the platform. +GTEST_API_ std::string TempDir(); + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + } // namespace testing // Use this function in main() to run all tests. It returns 0 if all @@ -2288,4 +2341,6 @@ inline int RUN_ALL_TESTS() { return ::testing::UnitTest::GetInstance()->Run(); } +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + #endif // GTEST_INCLUDE_GTEST_GTEST_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest_pred_impl.h b/src/test/fmw/gtest/include/gtest/gtest_pred_impl.h index 30ae712f50e..0c1105cb8eb 100644 --- a/src/test/fmw/gtest/include/gtest/gtest_pred_impl.h +++ b/src/test/fmw/gtest/include/gtest/gtest_pred_impl.h @@ -27,18 +27,19 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command +// This file is AUTOMATICALLY GENERATED on 01/02/2018 by command // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND! // // Implements a family of generic predicate assertion macros. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ -// Makes sure this header is not included before gtest.h. -#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ -# error Do not include gtest_pred_impl.h directly. Include gtest.h instead. -#endif // GTEST_INCLUDE_GTEST_GTEST_H_ +#include "gtest/gtest.h" + +namespace testing { // This header implements a family of generic predicate assertion // macros: @@ -66,8 +67,6 @@ // We also define the EXPECT_* variations. // // For now we only support predicates whose arity is at most 5. -// Please email googletestframework@googlegroups.com if you need -// support for higher arities. // GTEST_ASSERT_ is the basic statement to which all of the assertions // in this file reduce. Don't use this in your code. @@ -355,4 +354,6 @@ AssertionResult AssertPred5Helper(const char* pred_text, +} // namespace testing + #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ diff --git a/src/test/fmw/gtest/include/gtest/gtest_prod.h b/src/test/fmw/gtest/include/gtest/gtest_prod.h index da80ddc6c70..e651671ebde 100644 --- a/src/test/fmw/gtest/include/gtest/gtest_prod.h +++ b/src/test/fmw/gtest/include/gtest/gtest_prod.h @@ -26,10 +26,10 @@ // 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. + // -// Author: wan@google.com (Zhanyong Wan) -// -// Google C++ Testing Framework definitions useful in production code. +// Google C++ Testing and Mocking Framework definitions useful in production code. +// GOOGLETEST_CM0003 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ @@ -40,17 +40,20 @@ // // class MyClass { // private: -// void MyMethod(); -// FRIEND_TEST(MyClassTest, MyMethod); +// void PrivateMethod(); +// FRIEND_TEST(MyClassTest, PrivateMethodWorks); // }; // // class MyClassTest : public testing::Test { // // ... // }; // -// TEST_F(MyClassTest, MyMethod) { -// // Can call MyClass::MyMethod() here. +// TEST_F(MyClassTest, PrivateMethodWorks) { +// // Can call MyClass::PrivateMethod() here. // } +// +// Note: The test class must be in the same namespace as the class being tested. +// For example, putting MyClassTest in an anonymous namespace will not work. #define FRIEND_TEST(test_case_name, test_name)\ friend class test_case_name##_##test_name##_Test diff --git a/src/test/fmw/gtest/include/gtest/internal/custom/README.md b/src/test/fmw/gtest/include/gtest/internal/custom/README.md new file mode 100644 index 00000000000..ff391fb4e2b --- /dev/null +++ b/src/test/fmw/gtest/include/gtest/internal/custom/README.md @@ -0,0 +1,56 @@ +# Customization Points + +The custom directory is an injection point for custom user configurations. + +## Header `gtest.h` + +### The following macros can be defined: + +* `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of + `OsStackTraceGetterInterface`. +* `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See + `testing::TempDir` for semantics and signature. + +## Header `gtest-port.h` + +The following macros can be defined: + +### Flag related macros: + +* `GTEST_FLAG(flag_name)` +* `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its + own flagfile flag parsing. +* `GTEST_DECLARE_bool_(name)` +* `GTEST_DECLARE_int32_(name)` +* `GTEST_DECLARE_string_(name)` +* `GTEST_DEFINE_bool_(name, default_val, doc)` +* `GTEST_DEFINE_int32_(name, default_val, doc)` +* `GTEST_DEFINE_string_(name, default_val, doc)` + +### Logging: + +* `GTEST_LOG_(severity)` +* `GTEST_CHECK_(condition)` +* Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. + +### Threading: + +* `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. +* `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` + are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` + and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` +* `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` +* `GTEST_LOCK_EXCLUDED_(locks)` + +### Underlying library support features + +* `GTEST_HAS_CXXABI_H_` + +### Exporting API symbols: + +* `GTEST_API_` - Specifier for exported symbols. + +## Header `gtest-printers.h` + +* See documentation at `gtest/gtest-printers.h` for details on how to define a + custom printer. diff --git a/src/test/fmw/gtest/include/gtest/internal/custom/gtest-port.h b/src/test/fmw/gtest/include/gtest/internal/custom/gtest-port.h new file mode 100644 index 00000000000..cd85d956d2d --- /dev/null +++ b/src/test/fmw/gtest/include/gtest/internal/custom/gtest-port.h @@ -0,0 +1,37 @@ +// Copyright 2015, Google Inc. +// 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 Google Inc. 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. +// +// Injection point for custom user configurations. See README for details +// +// ** Custom implementation starts here ** + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/custom/gtest-printers.h b/src/test/fmw/gtest/include/gtest/internal/custom/gtest-printers.h new file mode 100644 index 00000000000..eb4467abcab --- /dev/null +++ b/src/test/fmw/gtest/include/gtest/internal/custom/gtest-printers.h @@ -0,0 +1,42 @@ +// Copyright 2015, Google Inc. +// 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 Google Inc. 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. +// +// This file provides an injection point for custom printers in a local +// installation of gTest. +// It will be included from gtest-printers.h and the overrides in this file +// will be visible to everyone. +// +// Injection point for custom user configurations. See README for details +// +// ** Custom implementation starts here ** + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/custom/gtest.h b/src/test/fmw/gtest/include/gtest/internal/custom/gtest.h new file mode 100644 index 00000000000..4c8e07be23f --- /dev/null +++ b/src/test/fmw/gtest/include/gtest/internal/custom/gtest.h @@ -0,0 +1,37 @@ +// Copyright 2015, Google Inc. +// 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 Google Inc. 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. +// +// Injection point for custom user configurations. See README for details +// +// ** Custom implementation starts here ** + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h b/src/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h index 2b3a78f5bf8..0a9b42c8a57 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h @@ -27,12 +27,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) // // This header file defines internal utilities needed for implementing // death tests. They are subject to change without notice. +// GOOGLETEST_CM0001 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ @@ -53,6 +52,9 @@ const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; #if GTEST_HAS_DEATH_TEST +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + // DeathTest is a class that hides much of the complexity of the // GTEST_DEATH_TEST_ macro. It is abstract; its static Create method // returns a concrete class that depends on the prevailing death test @@ -136,6 +138,8 @@ class GTEST_API_ DeathTest { GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest); }; +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + // Factory interface for death tests. May be mocked out for testing. class DeathTestFactory { public: @@ -218,14 +222,18 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status); // can be streamed. // This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in -// NDEBUG mode. In this case we need the statements to be executed, the regex is -// ignored, and the macro must accept a streamed message even though the message -// is never printed. -# define GTEST_EXECUTE_STATEMENT_(statement, regex) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } else \ +// NDEBUG mode. In this case we need the statements to be executed and the macro +// must accept a streamed message even though the message is never printed. +// The regex object is not evaluated, but it is used to prevent "unused" +// warnings and to avoid an expression that doesn't compile in debug mode. +#define GTEST_EXECUTE_STATEMENT_(statement, regex) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } else if (!::testing::internal::AlwaysTrue()) { \ + const ::testing::internal::RE& gtest_regex = (regex); \ + static_cast<void>(gtest_regex); \ + } else \ ::testing::Message() // A class representing the parsed contents of the @@ -264,53 +272,6 @@ class InternalRunDeathTestFlag { // the flag is specified; otherwise returns NULL. InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag(); -#else // GTEST_HAS_DEATH_TEST - -// This macro is used for implementing macros such as -// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where -// death tests are not supported. Those macros must compile on such systems -// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on -// systems that support death tests. This allows one to write such a macro -// on a system that does not support death tests and be sure that it will -// compile on a death-test supporting system. -// -// Parameters: -// statement - A statement that a macro such as EXPECT_DEATH would test -// for program termination. This macro has to make sure this -// statement is compiled but not executed, to ensure that -// EXPECT_DEATH_IF_SUPPORTED compiles with a certain -// parameter iff EXPECT_DEATH compiles with it. -// regex - A regex that a macro such as EXPECT_DEATH would use to test -// the output of statement. This parameter has to be -// compiled but not evaluated by this macro, to ensure that -// this macro only accepts expressions that a macro such as -// EXPECT_DEATH would accept. -// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED -// and a return statement for ASSERT_DEATH_IF_SUPPORTED. -// This ensures that ASSERT_DEATH_IF_SUPPORTED will not -// compile inside functions where ASSERT_DEATH doesn't -// compile. -// -// The branch that has an always false condition is used to ensure that -// statement and regex are compiled (and thus syntactically correct) but -// never executed. The unreachable code macro protects the terminator -// statement from generating an 'unreachable code' warning in case -// statement unconditionally returns or throws. The Message constructor at -// the end allows the syntax of streaming additional messages into the -// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. -# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ - GTEST_LOG_(WARNING) \ - << "Death tests are not supported on this platform.\n" \ - << "Statement '" #statement "' cannot be verified."; \ - } else if (::testing::internal::AlwaysFalse()) { \ - ::testing::internal::RE::PartialMatch(".*", (regex)); \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - terminator; \ - } else \ - ::testing::Message() - #endif // GTEST_HAS_DEATH_TEST } // namespace internal diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-filepath.h b/src/test/fmw/gtest/include/gtest/internal/gtest-filepath.h index 7a13b4b0de6..ae38d95bf84 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-filepath.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-filepath.h @@ -27,21 +27,24 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Author: keith.ray@gmail.com (Keith Ray) -// // Google Test filepath utilities // // This header file declares classes and functions used internally by // Google Test. They are subject to change without notice. // -// This file is #included in <gtest/internal/gtest-internal.h>. +// This file is #included in gtest/internal/gtest-internal.h. // Do not include this header file separately! +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #include "gtest/internal/gtest-string.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + namespace testing { namespace internal { @@ -203,4 +206,6 @@ class GTEST_API_ FilePath { } // namespace internal } // namespace testing +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-internal.h b/src/test/fmw/gtest/include/gtest/internal/gtest-internal.h index 0dcc3a3194f..38ea0fe6d9c 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-internal.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-internal.h @@ -27,13 +27,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) // // This header file declares functions and macros used internally by // Google Test. They are subject to change without notice. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ @@ -55,11 +55,14 @@ #include <string.h> #include <iomanip> #include <limits> +#include <map> #include <set> +#include <string> +#include <vector> #include "gtest/gtest-message.h" -#include "gtest/internal/gtest-string.h" #include "gtest/internal/gtest-filepath.h" +#include "gtest/internal/gtest-string.h" #include "gtest/internal/gtest-type-util.h" // Due to C++ preprocessor weirdness, we need double indirection to @@ -73,6 +76,9 @@ #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar) #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar +// Stringifies its argument. +#define GTEST_STRINGIFY_(name) #name + class ProtocolMessage; namespace proto2 { class Message; } @@ -93,13 +99,9 @@ ::std::string PrintToString(const T& value); namespace internal { struct TraceInfo; // Information about a trace point. -class ScopedTrace; // Implements scoped trace. class TestInfoImpl; // Opaque implementation of TestInfo class UnitTestImpl; // Opaque implementation of UnitTest -// How many times InitGoogleTest() has been called. -GTEST_API_ extern int g_init_gtest_count; - // The text used in failure messages to indicate the start of the // stack trace. GTEST_API_ extern const char kStackTraceMarker[]; @@ -139,6 +141,9 @@ GTEST_API_ std::string AppendUserMessage( #if GTEST_HAS_EXCEPTIONS +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \ +/* an exported class was derived from a class that was not exported */) + // This exception is thrown by (and only by) a failed Google Test // assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions // are enabled). We derive it from std::runtime_error, which is for @@ -150,26 +155,39 @@ class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { explicit GoogleTestFailureException(const TestPartResult& failure); }; -#endif // GTEST_HAS_EXCEPTIONS +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4275 -// A helper class for creating scoped traces in user programs. -class GTEST_API_ ScopedTrace { - public: - // The c'tor pushes the given source file location and message onto - // a trace stack maintained by Google Test. - ScopedTrace(const char* file, int line, const Message& message); - - // The d'tor pops the info pushed by the c'tor. - // - // Note that the d'tor is not virtual in order to be efficient. - // Don't inherit from ScopedTrace! - ~ScopedTrace(); +#endif // GTEST_HAS_EXCEPTIONS - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); -} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its - // c'tor and d'tor. Therefore it doesn't - // need to be used otherwise. +namespace edit_distance { +// Returns the optimal edits to go from 'left' to 'right'. +// All edits cost the same, with replace having lower priority than +// add/remove. +// Simple implementation of the Wagner-Fischer algorithm. +// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm +enum EditType { kMatch, kAdd, kRemove, kReplace }; +GTEST_API_ std::vector<EditType> CalculateOptimalEdits( + const std::vector<size_t>& left, const std::vector<size_t>& right); + +// Same as above, but the input is represented as strings. +GTEST_API_ std::vector<EditType> CalculateOptimalEdits( + const std::vector<std::string>& left, + const std::vector<std::string>& right); + +// Create a diff of the input strings in Unified diff format. +GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left, + const std::vector<std::string>& right, + size_t context = 2); + +} // namespace edit_distance + +// Calculate the diff between 'left' and 'right' and return it in unified diff +// format. +// If not null, stores in 'total_line_count' the total number of lines found +// in left + right. +GTEST_API_ std::string DiffStrings(const std::string& left, + const std::string& right, + size_t* total_line_count); // Constructs and returns the message for an equality assertion // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. @@ -471,6 +489,14 @@ GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr, typedef void (*SetUpTestCaseFunc)(); typedef void (*TearDownTestCaseFunc)(); +struct CodeLocation { + CodeLocation(const char* a_file, int a_line) + : file(a_file), line(a_line) {} + + const char* const file; + int line; +}; + // Creates a new TestInfo object and registers it with Google Test; // returns the created object. // @@ -482,6 +508,7 @@ typedef void (*TearDownTestCaseFunc)(); // this is not a typed or a type-parameterized test. // value_param text representation of the test's value parameter, // or NULL if this is not a type-parameterized test. +// code_location: code location where the test is defined // fixture_class_id: ID of the test fixture class // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case @@ -493,6 +520,7 @@ GTEST_API_ TestInfo* MakeAndRegisterTestInfo( const char* name, const char* type_param, const char* value_param, + CodeLocation code_location, TypeId fixture_class_id, SetUpTestCaseFunc set_up_tc, TearDownTestCaseFunc tear_down_tc, @@ -505,6 +533,9 @@ GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr); #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + // State of the definition of a type-parameterized test case. class GTEST_API_ TypedTestCasePState { public: @@ -522,10 +553,21 @@ class GTEST_API_ TypedTestCasePState { fflush(stderr); posix::Abort(); } - defined_test_names_.insert(test_name); + registered_tests_.insert( + ::std::make_pair(test_name, CodeLocation(file, line))); return true; } + bool TestExists(const std::string& test_name) const { + return registered_tests_.count(test_name) > 0; + } + + const CodeLocation& GetCodeLocation(const std::string& test_name) const { + RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name); + GTEST_CHECK_(it != registered_tests_.end()); + return it->second; + } + // Verifies that registered_tests match the test names in // defined_test_names_; returns registered_tests if successful, or // aborts the program otherwise. @@ -533,10 +575,14 @@ class GTEST_API_ TypedTestCasePState { const char* file, int line, const char* registered_tests); private: + typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap; + bool registered_; - ::std::set<const char*> defined_test_names_; + RegisteredTestsMap registered_tests_; }; +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + // Skips to the first non-space char after the first comma in 'str'; // returns NULL if no comma is found in 'str'. inline const char* SkipComma(const char* str) { @@ -555,6 +601,42 @@ inline std::string GetPrefixUntilComma(const char* str) { return comma == NULL ? str : std::string(str, comma); } +// Splits a given string on a given delimiter, populating a given +// vector with the fields. +void SplitString(const ::std::string& str, char delimiter, + ::std::vector< ::std::string>* dest); + +// The default argument to the template below for the case when the user does +// not provide a name generator. +struct DefaultNameGenerator { + template <typename T> + static std::string GetName(int i) { + return StreamableToString(i); + } +}; + +template <typename Provided = DefaultNameGenerator> +struct NameGeneratorSelector { + typedef Provided type; +}; + +template <typename NameGenerator> +void GenerateNamesRecursively(Types0, std::vector<std::string>*, int) {} + +template <typename NameGenerator, typename Types> +void GenerateNamesRecursively(Types, std::vector<std::string>* result, int i) { + result->push_back(NameGenerator::template GetName<typename Types::Head>(i)); + GenerateNamesRecursively<NameGenerator>(typename Types::Tail(), result, + i + 1); +} + +template <typename NameGenerator, typename Types> +std::vector<std::string> GenerateNames() { + std::vector<std::string> result; + GenerateNamesRecursively<NameGenerator>(Types(), &result, 0); + return result; +} + // TypeParameterizedTest<Fixture, TestSel, Types>::Register() // registers a list of type-parameterized tests with Google Test. The // return value is insignificant - we just need to return something @@ -569,8 +651,10 @@ class TypeParameterizedTest { // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase, // Types). Valid values for 'index' are [0, N - 1] where N is the // length of Types. - static bool Register(const char* prefix, const char* case_name, - const char* test_names, int index) { + static bool Register(const char* prefix, const CodeLocation& code_location, + const char* case_name, const char* test_names, int index, + const std::vector<std::string>& type_names = + GenerateNames<DefaultNameGenerator, Types>()) { typedef typename Types::Head Type; typedef Fixture<Type> FixtureClass; typedef typename GTEST_BIND_(TestSel, Type) TestClass; @@ -578,19 +662,23 @@ class TypeParameterizedTest { // First, registers the first type-parameterized test in the type // list. MakeAndRegisterTestInfo( - (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + "/" - + StreamableToString(index)).c_str(), - GetPrefixUntilComma(test_names).c_str(), + (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + + "/" + type_names[index]) + .c_str(), + StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(), GetTypeName<Type>().c_str(), NULL, // No value parameter. - GetTypeId<FixtureClass>(), - TestClass::SetUpTestCase, - TestClass::TearDownTestCase, - new TestFactoryImpl<TestClass>); + code_location, GetTypeId<FixtureClass>(), TestClass::SetUpTestCase, + TestClass::TearDownTestCase, new TestFactoryImpl<TestClass>); // Next, recurses (at compile time) with the tail of the type list. - return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail> - ::Register(prefix, case_name, test_names, index + 1); + return TypeParameterizedTest<Fixture, TestSel, + typename Types::Tail>::Register(prefix, + code_location, + case_name, + test_names, + index + 1, + type_names); } }; @@ -598,8 +686,11 @@ class TypeParameterizedTest { template <GTEST_TEMPLATE_ Fixture, class TestSel> class TypeParameterizedTest<Fixture, TestSel, Types0> { public: - static bool Register(const char* /*prefix*/, const char* /*case_name*/, - const char* /*test_names*/, int /*index*/) { + static bool Register(const char* /*prefix*/, const CodeLocation&, + const char* /*case_name*/, const char* /*test_names*/, + int /*index*/, + const std::vector<std::string>& = + std::vector<std::string>() /*type_names*/) { return true; } }; @@ -611,17 +702,35 @@ class TypeParameterizedTest<Fixture, TestSel, Types0> { template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types> class TypeParameterizedTestCase { public: - static bool Register(const char* prefix, const char* case_name, - const char* test_names) { + static bool Register(const char* prefix, CodeLocation code_location, + const TypedTestCasePState* state, const char* case_name, + const char* test_names, + const std::vector<std::string>& type_names = + GenerateNames<DefaultNameGenerator, Types>()) { + std::string test_name = StripTrailingSpaces( + GetPrefixUntilComma(test_names)); + if (!state->TestExists(test_name)) { + fprintf(stderr, "Failed to get code location for test %s.%s at %s.", + case_name, test_name.c_str(), + FormatFileLocation(code_location.file, + code_location.line).c_str()); + fflush(stderr); + posix::Abort(); + } + const CodeLocation& test_location = state->GetCodeLocation(test_name); + typedef typename Tests::Head Head; // First, register the first test in 'Test' for each type in 'Types'. TypeParameterizedTest<Fixture, Head, Types>::Register( - prefix, case_name, test_names, 0); + prefix, test_location, case_name, test_names, 0, type_names); // Next, recurses (at compile time) with the tail of the test list. - return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types> - ::Register(prefix, case_name, SkipComma(test_names)); + return TypeParameterizedTestCase<Fixture, typename Tests::Tail, + Types>::Register(prefix, code_location, + state, case_name, + SkipComma(test_names), + type_names); } }; @@ -629,8 +738,11 @@ class TypeParameterizedTestCase { template <GTEST_TEMPLATE_ Fixture, typename Types> class TypeParameterizedTestCase<Fixture, Templates0, Types> { public: - static bool Register(const char* /*prefix*/, const char* /*case_name*/, - const char* /*test_names*/) { + static bool Register(const char* /*prefix*/, const CodeLocation&, + const TypedTestCasePState* /*state*/, + const char* /*case_name*/, const char* /*test_names*/, + const std::vector<std::string>& = + std::vector<std::string>() /*type_names*/) { return true; } }; @@ -747,31 +859,6 @@ struct RemoveConst<T[N]> { #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \ GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T)) -// Adds reference to a type if it is not a reference type, -// otherwise leaves it unchanged. This is the same as -// tr1::add_reference, which is not widely available yet. -template <typename T> -struct AddReference { typedef T& type; }; // NOLINT -template <typename T> -struct AddReference<T&> { typedef T& type; }; // NOLINT - -// A handy wrapper around AddReference that works when the argument T -// depends on template parameters. -#define GTEST_ADD_REFERENCE_(T) \ - typename ::testing::internal::AddReference<T>::type - -// Adds a reference to const on top of T as necessary. For example, -// it transforms -// -// char ==> const char& -// const char ==> const char& -// char& ==> const char& -// const char& ==> const char& -// -// The argument T must depend on some template parameters. -#define GTEST_REFERENCE_TO_CONST_(T) \ - GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T)) - // ImplicitlyConvertible<From, To>::value is a compile-time bool // constant that's true iff type From can be implicitly converted to // type To. @@ -784,7 +871,7 @@ class ImplicitlyConvertible { // MakeFrom() is an expression whose type is From. We cannot simply // use From(), as the type From may not have a public default // constructor. - static From MakeFrom(); + static typename AddReference<From>::type MakeFrom(); // These two functions are overloaded. Given an expression // Helper(x), the compiler will pick the first version if x can be @@ -802,25 +889,20 @@ class ImplicitlyConvertible { // We have to put the 'public' section after the 'private' section, // or MSVC refuses to compile the code. public: - // MSVC warns about implicitly converting from double to int for - // possible loss of data, so we need to temporarily disable the - // warning. -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4244) // Temporarily disables warning 4244. - - static const bool value = - sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; -# pragma warning(pop) // Restores the warning state. -#elif defined(__BORLANDC__) +#if defined(__BORLANDC__) // C++Builder cannot use member overload resolution during template // instantiation. The simplest workaround is to use its C++0x type traits // functions (C++Builder 2009 and above only). static const bool value = __is_convertible(From, To); #else + // MSVC warns about implicitly converting from double to int for + // possible loss of data, so we need to temporarily disable the + // warning. + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244) static const bool value = sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; -#endif // _MSV_VER + GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif // __BORLANDC__ }; template <typename From, typename To> const bool ImplicitlyConvertible<From, To>::value; @@ -846,8 +928,11 @@ struct IsAProtocolMessage // a container class by checking the type of IsContainerTest<C>(0). // The value of the expression is insignificant. // -// Note that we look for both C::iterator and C::const_iterator. The -// reason is that C++ injects the name of a class as a member of the +// In C++11 mode we check the existence of a const_iterator and that an +// iterator is properly implemented for the container. +// +// For pre-C++11 that we look for both C::iterator and C::const_iterator. +// The reason is that C++ injects the name of a class as a member of the // class itself (e.g. you can refer to class iterator as either // 'iterator' or 'iterator::iterator'). If we look for C::iterator // only, for example, we would mistakenly think that a class named @@ -857,17 +942,96 @@ struct IsAProtocolMessage // IsContainerTest(typename C::const_iterator*) and // IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++. typedef int IsContainer; +#if GTEST_LANG_CXX11 +template <class C, + class Iterator = decltype(::std::declval<const C&>().begin()), + class = decltype(::std::declval<const C&>().end()), + class = decltype(++::std::declval<Iterator&>()), + class = decltype(*::std::declval<Iterator>()), + class = typename C::const_iterator> +IsContainer IsContainerTest(int /* dummy */) { + return 0; +} +#else template <class C> IsContainer IsContainerTest(int /* dummy */, typename C::iterator* /* it */ = NULL, typename C::const_iterator* /* const_it */ = NULL) { return 0; } +#endif // GTEST_LANG_CXX11 typedef char IsNotContainer; template <class C> IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; } +// Trait to detect whether a type T is a hash table. +// The heuristic used is that the type contains an inner type `hasher` and does +// not contain an inner type `reverse_iterator`. +// If the container is iterable in reverse, then order might actually matter. +template <typename T> +struct IsHashTable { + private: + template <typename U> + static char test(typename U::hasher*, typename U::reverse_iterator*); + template <typename U> + static int test(typename U::hasher*, ...); + template <typename U> + static char test(...); + + public: + static const bool value = sizeof(test<T>(0, 0)) == sizeof(int); +}; + +template <typename T> +const bool IsHashTable<T>::value; + +template<typename T> +struct VoidT { + typedef void value_type; +}; + +template <typename T, typename = void> +struct HasValueType : false_type {}; +template <typename T> +struct HasValueType<T, VoidT<typename T::value_type> > : true_type { +}; + +template <typename C, + bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer), + bool = HasValueType<C>::value> +struct IsRecursiveContainerImpl; + +template <typename C, bool HV> +struct IsRecursiveContainerImpl<C, false, HV> : public false_type {}; + +// Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to +// obey the same inconsistencies as the IsContainerTest, namely check if +// something is a container is relying on only const_iterator in C++11 and +// is relying on both const_iterator and iterator otherwise +template <typename C> +struct IsRecursiveContainerImpl<C, true, false> : public false_type {}; + +template <typename C> +struct IsRecursiveContainerImpl<C, true, true> { + #if GTEST_LANG_CXX11 + typedef typename IteratorTraits<typename C::const_iterator>::value_type + value_type; +#else + typedef typename IteratorTraits<typename C::iterator>::value_type value_type; +#endif + typedef is_same<value_type, C> type; +}; + +// IsRecursiveContainer<Type> is a unary compile-time predicate that +// evaluates whether C is a recursive container type. A recursive container +// type is a container type whose value_type is equal to the container type +// itself. An example for a recursive container type is +// boost::filesystem::path, whose iterator has a value_type that is equal to +// boost::filesystem::path. +template <typename C> +struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {}; + // EnableIf<condition>::type is void when 'Cond' is true, and // undefined when 'Cond' is false. To use SFINAE to make a function // overload only apply when a particular expression is true, add @@ -946,11 +1110,10 @@ void CopyArray(const T* from, size_t size, U* to) { // The relation between an NativeArray object (see below) and the // native array it represents. -enum RelationToSource { - kReference, // The NativeArray references the native array. - kCopy // The NativeArray makes a copy of the native array and - // owns the copy. -}; +// We use 2 different structs to allow non-copyable types to be used, as long +// as RelationToSourceReference() is passed. +struct RelationToSourceReference {}; +struct RelationToSourceCopy {}; // Adapts a native array to a read-only STL-style container. Instead // of the complete STL container concept, this adaptor only implements @@ -968,22 +1131,23 @@ class NativeArray { typedef Element* iterator; typedef const Element* const_iterator; - // Constructs from a native array. - NativeArray(const Element* array, size_t count, RelationToSource relation) { - Init(array, count, relation); + // Constructs from a native array. References the source. + NativeArray(const Element* array, size_t count, RelationToSourceReference) { + InitRef(array, count); + } + + // Constructs from a native array. Copies the source. + NativeArray(const Element* array, size_t count, RelationToSourceCopy) { + InitCopy(array, count); } // Copy constructor. NativeArray(const NativeArray& rhs) { - Init(rhs.array_, rhs.size_, rhs.relation_to_source_); + (this->*rhs.clone_)(rhs.array_, rhs.size_); } ~NativeArray() { - // Ensures that the user doesn't instantiate NativeArray with a - // const or reference type. - static_cast<void>(StaticAssertTypeEqHelper<Element, - GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>()); - if (relation_to_source_ == kCopy) + if (clone_ != &NativeArray::InitRef) delete[] array_; } @@ -997,23 +1161,30 @@ class NativeArray { } private: - // Initializes this object; makes a copy of the input array if - // 'relation' is kCopy. - void Init(const Element* array, size_t a_size, RelationToSource relation) { - if (relation == kReference) { - array_ = array; - } else { - Element* const copy = new Element[a_size]; - CopyArray(array, a_size, copy); - array_ = copy; - } + enum { + kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper< + Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value + }; + + // Initializes this object with a copy of the input. + void InitCopy(const Element* array, size_t a_size) { + Element* const copy = new Element[a_size]; + CopyArray(array, a_size, copy); + array_ = copy; + size_ = a_size; + clone_ = &NativeArray::InitCopy; + } + + // Initializes this object with a reference of the input. + void InitRef(const Element* array, size_t a_size) { + array_ = array; size_ = a_size; - relation_to_source_ = relation; + clone_ = &NativeArray::InitRef; } const Element* array_; size_t size_; - RelationToSource relation_to_source_; + void (NativeArray::*clone_)(const Element*, size_t); GTEST_DISALLOW_ASSIGN_(NativeArray); }; @@ -1037,7 +1208,7 @@ class NativeArray { #define GTEST_SUCCESS_(message) \ GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess) -// Suppresses MSVC warnings 4072 (unreachable code) for the code following +// Suppress MSVC warning 4702 (unreachable code) for the code following // statement if it returns or throws (or doesn't return or throw in some // situations). #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \ @@ -1148,6 +1319,7 @@ ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ ::test_info_ =\ ::testing::internal::MakeAndRegisterTestInfo(\ #test_case_name, #test_name, NULL, NULL, \ + ::testing::internal::CodeLocation(__FILE__, __LINE__), \ (parent_id), \ parent_class::SetUpTestCase, \ parent_class::TearDownTestCase, \ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h b/src/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h index b1362cd002c..082b87289ae 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h @@ -27,8 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: Dan Egnor (egnor@google.com) -// // A "smart" pointer type with reference tracking. Every pointer to a // particular object is kept on a circular linked list. When the last pointer // to an object is destroyed or reassigned, the object is deleted. @@ -62,9 +60,11 @@ // raw pointer (e.g. via get()) concurrently, and // - it's safe to write to two linked_ptrs that point to the same // shared object concurrently. -// TODO(wan@google.com): rename this to safe_linked_ptr to avoid +// FIXME: rename this to safe_linked_ptr to avoid // confusion with normal linked_ptr. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_ @@ -110,7 +110,12 @@ class linked_ptr_internal { MutexLock lock(&g_linked_ptr_mutex); linked_ptr_internal const* p = ptr; - while (p->next_ != ptr) p = p->next_; + while (p->next_ != ptr) { + assert(p->next_ != this && + "Trying to join() a linked ring we are already in. " + "Is GMock thread safety enabled?"); + p = p->next_; + } p->next_ = this; next_ = ptr; } @@ -123,7 +128,12 @@ class linked_ptr_internal { if (next_ == this) return true; linked_ptr_internal const* p = next_; - while (p->next_ != this) p = p->next_; + while (p->next_ != this) { + assert(p->next_ != next_ && + "Trying to depart() a linked ring we are not in. " + "Is GMock thread safety enabled?"); + p = p->next_; + } p->next_ = next_; return false; } diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h b/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h index e80548592c7..4fac8c02703 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h @@ -30,8 +30,7 @@ // 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. -// -// Author: vladl@google.com (Vlad Losev) + // Type and function utilities for implementing parameterized tests. // This file is generated by a SCRIPT. DO NOT EDIT BY HAND! @@ -40,20 +39,17 @@ // and at most 10 arguments in Combine. Please contact // googletestframework@googlegroups.com if you need more. // Please note that the number of arguments to Combine is limited -// by the maximum arity of the implementation of tr1::tuple which is +// by the maximum arity of the implementation of tuple which is // currently set at 10. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ -// scripts/fuse_gtest.py depends on gtest's own header being #included -// *unconditionally*. Therefore these #includes cannot be moved -// inside #if GTEST_HAS_PARAM_TEST. #include "gtest/internal/gtest-param-util.h" #include "gtest/internal/gtest-port.h" -#if GTEST_HAS_PARAM_TEST - namespace testing { // Forward declarations of ValuesIn(), which is implemented in @@ -79,7 +75,12 @@ class ValueArray1 { explicit ValueArray1(T1 v1) : v1_(v1) {} template <typename T> - operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); } + operator ParamGenerator<T>() const { + const T array[] = {static_cast<T>(v1_)}; + return ValuesIn(array); + } + + ValueArray1(const ValueArray1& other) : v1_(other.v1_) {} private: // No implementation - assignment is unsupported. @@ -99,6 +100,8 @@ class ValueArray2 { return ValuesIn(array); } + ValueArray2(const ValueArray2& other) : v1_(other.v1_), v2_(other.v2_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray2& other); @@ -119,6 +122,9 @@ class ValueArray3 { return ValuesIn(array); } + ValueArray3(const ValueArray3& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray3& other); @@ -141,6 +147,9 @@ class ValueArray4 { return ValuesIn(array); } + ValueArray4(const ValueArray4& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray4& other); @@ -164,6 +173,9 @@ class ValueArray5 { return ValuesIn(array); } + ValueArray5(const ValueArray5& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray5& other); @@ -190,6 +202,9 @@ class ValueArray6 { return ValuesIn(array); } + ValueArray6(const ValueArray6& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray6& other); @@ -217,6 +232,10 @@ class ValueArray7 { return ValuesIn(array); } + ValueArray7(const ValueArray7& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray7& other); @@ -246,6 +265,10 @@ class ValueArray8 { return ValuesIn(array); } + ValueArray8(const ValueArray8& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray8& other); @@ -277,6 +300,10 @@ class ValueArray9 { return ValuesIn(array); } + ValueArray9(const ValueArray9& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray9& other); @@ -309,6 +336,10 @@ class ValueArray10 { return ValuesIn(array); } + ValueArray10(const ValueArray10& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray10& other); @@ -343,6 +374,11 @@ class ValueArray11 { return ValuesIn(array); } + ValueArray11(const ValueArray11& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray11& other); @@ -379,6 +415,11 @@ class ValueArray12 { return ValuesIn(array); } + ValueArray12(const ValueArray12& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray12& other); @@ -417,6 +458,11 @@ class ValueArray13 { return ValuesIn(array); } + ValueArray13(const ValueArray13& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray13& other); @@ -456,6 +502,11 @@ class ValueArray14 { return ValuesIn(array); } + ValueArray14(const ValueArray14& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray14& other); @@ -497,6 +548,12 @@ class ValueArray15 { return ValuesIn(array); } + ValueArray15(const ValueArray15& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray15& other); @@ -541,6 +598,12 @@ class ValueArray16 { return ValuesIn(array); } + ValueArray16(const ValueArray16& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray16& other); @@ -586,6 +649,12 @@ class ValueArray17 { return ValuesIn(array); } + ValueArray17(const ValueArray17& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray17& other); @@ -633,6 +702,12 @@ class ValueArray18 { return ValuesIn(array); } + ValueArray18(const ValueArray18& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray18& other); @@ -681,6 +756,13 @@ class ValueArray19 { return ValuesIn(array); } + ValueArray19(const ValueArray19& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray19& other); @@ -731,6 +813,13 @@ class ValueArray20 { return ValuesIn(array); } + ValueArray20(const ValueArray20& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray20& other); @@ -784,6 +873,13 @@ class ValueArray21 { return ValuesIn(array); } + ValueArray21(const ValueArray21& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray21& other); @@ -838,6 +934,13 @@ class ValueArray22 { return ValuesIn(array); } + ValueArray22(const ValueArray22& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray22& other); @@ -894,6 +997,14 @@ class ValueArray23 { return ValuesIn(array); } + ValueArray23(const ValueArray23& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray23& other); @@ -952,6 +1063,14 @@ class ValueArray24 { return ValuesIn(array); } + ValueArray24(const ValueArray24& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray24& other); @@ -1011,6 +1130,14 @@ class ValueArray25 { return ValuesIn(array); } + ValueArray25(const ValueArray25& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray25& other); @@ -1072,6 +1199,14 @@ class ValueArray26 { return ValuesIn(array); } + ValueArray26(const ValueArray26& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray26& other); @@ -1136,6 +1271,15 @@ class ValueArray27 { return ValuesIn(array); } + ValueArray27(const ValueArray27& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray27& other); @@ -1201,6 +1345,15 @@ class ValueArray28 { return ValuesIn(array); } + ValueArray28(const ValueArray28& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray28& other); @@ -1267,6 +1420,15 @@ class ValueArray29 { return ValuesIn(array); } + ValueArray29(const ValueArray29& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray29& other); @@ -1336,6 +1498,15 @@ class ValueArray30 { return ValuesIn(array); } + ValueArray30(const ValueArray30& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray30& other); @@ -1407,6 +1578,16 @@ class ValueArray31 { return ValuesIn(array); } + ValueArray31(const ValueArray31& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray31& other); @@ -1479,6 +1660,16 @@ class ValueArray32 { return ValuesIn(array); } + ValueArray32(const ValueArray32& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray32& other); @@ -1554,6 +1745,16 @@ class ValueArray33 { return ValuesIn(array); } + ValueArray33(const ValueArray33& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray33& other); @@ -1630,6 +1831,16 @@ class ValueArray34 { return ValuesIn(array); } + ValueArray34(const ValueArray34& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray34& other); @@ -1707,6 +1918,17 @@ class ValueArray35 { return ValuesIn(array); } + ValueArray35(const ValueArray35& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray35& other); @@ -1787,6 +2009,17 @@ class ValueArray36 { return ValuesIn(array); } + ValueArray36(const ValueArray36& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray36& other); @@ -1869,6 +2102,17 @@ class ValueArray37 { return ValuesIn(array); } + ValueArray37(const ValueArray37& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray37& other); @@ -1952,6 +2196,17 @@ class ValueArray38 { return ValuesIn(array); } + ValueArray38(const ValueArray38& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray38& other); @@ -2037,6 +2292,18 @@ class ValueArray39 { return ValuesIn(array); } + ValueArray39(const ValueArray39& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray39& other); @@ -2124,6 +2391,18 @@ class ValueArray40 { return ValuesIn(array); } + ValueArray40(const ValueArray40& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray40& other); @@ -2213,6 +2492,18 @@ class ValueArray41 { return ValuesIn(array); } + ValueArray41(const ValueArray41& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray41& other); @@ -2304,6 +2595,18 @@ class ValueArray42 { return ValuesIn(array); } + ValueArray42(const ValueArray42& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray42& other); @@ -2396,6 +2699,19 @@ class ValueArray43 { return ValuesIn(array); } + ValueArray43(const ValueArray43& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray43& other); @@ -2490,6 +2806,19 @@ class ValueArray44 { return ValuesIn(array); } + ValueArray44(const ValueArray44& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray44& other); @@ -2586,6 +2915,19 @@ class ValueArray45 { return ValuesIn(array); } + ValueArray45(const ValueArray45& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_), v45_(other.v45_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray45& other); @@ -2684,6 +3026,19 @@ class ValueArray46 { return ValuesIn(array); } + ValueArray46(const ValueArray46& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_), v45_(other.v45_), v46_(other.v46_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray46& other); @@ -2784,6 +3139,20 @@ class ValueArray47 { return ValuesIn(array); } + ValueArray47(const ValueArray47& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_), v45_(other.v45_), v46_(other.v46_), + v47_(other.v47_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray47& other); @@ -2886,6 +3255,20 @@ class ValueArray48 { return ValuesIn(array); } + ValueArray48(const ValueArray48& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_), v45_(other.v45_), v46_(other.v46_), + v47_(other.v47_), v48_(other.v48_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray48& other); @@ -2989,6 +3372,20 @@ class ValueArray49 { return ValuesIn(array); } + ValueArray49(const ValueArray49& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_), v45_(other.v45_), v46_(other.v46_), + v47_(other.v47_), v48_(other.v48_), v49_(other.v49_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray49& other); @@ -3093,6 +3490,20 @@ class ValueArray50 { return ValuesIn(array); } + ValueArray50(const ValueArray50& other) : v1_(other.v1_), v2_(other.v2_), + v3_(other.v3_), v4_(other.v4_), v5_(other.v5_), v6_(other.v6_), + v7_(other.v7_), v8_(other.v8_), v9_(other.v9_), v10_(other.v10_), + v11_(other.v11_), v12_(other.v12_), v13_(other.v13_), v14_(other.v14_), + v15_(other.v15_), v16_(other.v16_), v17_(other.v17_), v18_(other.v18_), + v19_(other.v19_), v20_(other.v20_), v21_(other.v21_), v22_(other.v22_), + v23_(other.v23_), v24_(other.v24_), v25_(other.v25_), v26_(other.v26_), + v27_(other.v27_), v28_(other.v28_), v29_(other.v29_), v30_(other.v30_), + v31_(other.v31_), v32_(other.v32_), v33_(other.v33_), v34_(other.v34_), + v35_(other.v35_), v36_(other.v36_), v37_(other.v37_), v38_(other.v38_), + v39_(other.v39_), v40_(other.v40_), v41_(other.v41_), v42_(other.v42_), + v43_(other.v43_), v44_(other.v44_), v45_(other.v45_), v46_(other.v46_), + v47_(other.v47_), v48_(other.v48_), v49_(other.v49_), v50_(other.v50_) {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray50& other); @@ -3157,9 +3568,9 @@ class ValueArray50 { // template <typename T1, typename T2> class CartesianProductGenerator2 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > { + : public ParamGeneratorInterface< ::testing::tuple<T1, T2> > { public: - typedef ::std::tr1::tuple<T1, T2> ParamType; + typedef ::testing::tuple<T1, T2> ParamType; CartesianProductGenerator2(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2) @@ -3205,7 +3616,7 @@ class CartesianProductGenerator2 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -3237,7 +3648,7 @@ class CartesianProductGenerator2 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_); + current_value_.reset(new ParamType(*current1_, *current2_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -3259,7 +3670,7 @@ class CartesianProductGenerator2 const typename ParamGenerator<T2>::iterator begin2_; const typename ParamGenerator<T2>::iterator end2_; typename ParamGenerator<T2>::iterator current2_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator2::Iterator // No implementation - assignment is unsupported. @@ -3272,9 +3683,9 @@ class CartesianProductGenerator2 template <typename T1, typename T2, typename T3> class CartesianProductGenerator3 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > { + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3> > { public: - typedef ::std::tr1::tuple<T1, T2, T3> ParamType; + typedef ::testing::tuple<T1, T2, T3> ParamType; CartesianProductGenerator3(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3) @@ -3328,7 +3739,7 @@ class CartesianProductGenerator3 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -3364,7 +3775,7 @@ class CartesianProductGenerator3 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_); + current_value_.reset(new ParamType(*current1_, *current2_, *current3_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -3390,7 +3801,7 @@ class CartesianProductGenerator3 const typename ParamGenerator<T3>::iterator begin3_; const typename ParamGenerator<T3>::iterator end3_; typename ParamGenerator<T3>::iterator current3_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator3::Iterator // No implementation - assignment is unsupported. @@ -3404,9 +3815,9 @@ class CartesianProductGenerator3 template <typename T1, typename T2, typename T3, typename T4> class CartesianProductGenerator4 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > { + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4> ParamType; CartesianProductGenerator4(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3469,7 +3880,7 @@ class CartesianProductGenerator4 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -3509,8 +3920,8 @@ class CartesianProductGenerator4 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, - *current4_); + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, + *current4_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -3540,7 +3951,7 @@ class CartesianProductGenerator4 const typename ParamGenerator<T4>::iterator begin4_; const typename ParamGenerator<T4>::iterator end4_; typename ParamGenerator<T4>::iterator current4_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator4::Iterator // No implementation - assignment is unsupported. @@ -3555,9 +3966,9 @@ class CartesianProductGenerator4 template <typename T1, typename T2, typename T3, typename T4, typename T5> class CartesianProductGenerator5 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > { + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4, T5> ParamType; CartesianProductGenerator5(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3627,7 +4038,7 @@ class CartesianProductGenerator5 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -3671,8 +4082,8 @@ class CartesianProductGenerator5 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, - *current4_, *current5_); + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -3706,7 +4117,7 @@ class CartesianProductGenerator5 const typename ParamGenerator<T5>::iterator begin5_; const typename ParamGenerator<T5>::iterator end5_; typename ParamGenerator<T5>::iterator current5_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator5::Iterator // No implementation - assignment is unsupported. @@ -3723,10 +4134,10 @@ class CartesianProductGenerator5 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> class CartesianProductGenerator6 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4, T5, T6> ParamType; CartesianProductGenerator6(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3804,7 +4215,7 @@ class CartesianProductGenerator6 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -3852,8 +4263,8 @@ class CartesianProductGenerator6 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, - *current4_, *current5_, *current6_); + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -3891,7 +4302,7 @@ class CartesianProductGenerator6 const typename ParamGenerator<T6>::iterator begin6_; const typename ParamGenerator<T6>::iterator end6_; typename ParamGenerator<T6>::iterator current6_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator6::Iterator // No implementation - assignment is unsupported. @@ -3909,10 +4320,10 @@ class CartesianProductGenerator6 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> class CartesianProductGenerator7 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType; CartesianProductGenerator7(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3998,7 +4409,7 @@ class CartesianProductGenerator7 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -4050,8 +4461,8 @@ class CartesianProductGenerator7 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, - *current4_, *current5_, *current6_, *current7_); + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_, *current7_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -4093,7 +4504,7 @@ class CartesianProductGenerator7 const typename ParamGenerator<T7>::iterator begin7_; const typename ParamGenerator<T7>::iterator end7_; typename ParamGenerator<T7>::iterator current7_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator7::Iterator // No implementation - assignment is unsupported. @@ -4112,10 +4523,10 @@ class CartesianProductGenerator7 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> class CartesianProductGenerator8 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType; CartesianProductGenerator8(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4211,7 +4622,7 @@ class CartesianProductGenerator8 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -4267,8 +4678,8 @@ class CartesianProductGenerator8 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, - *current4_, *current5_, *current6_, *current7_, *current8_); + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_, *current7_, *current8_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -4314,7 +4725,7 @@ class CartesianProductGenerator8 const typename ParamGenerator<T8>::iterator begin8_; const typename ParamGenerator<T8>::iterator end8_; typename ParamGenerator<T8>::iterator current8_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator8::Iterator // No implementation - assignment is unsupported. @@ -4334,10 +4745,10 @@ class CartesianProductGenerator8 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> class CartesianProductGenerator9 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType; CartesianProductGenerator9(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4440,7 +4851,7 @@ class CartesianProductGenerator9 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -4500,9 +4911,9 @@ class CartesianProductGenerator9 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, *current4_, *current5_, *current6_, *current7_, *current8_, - *current9_); + *current9_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -4552,7 +4963,7 @@ class CartesianProductGenerator9 const typename ParamGenerator<T9>::iterator begin9_; const typename ParamGenerator<T9>::iterator end9_; typename ParamGenerator<T9>::iterator current9_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator9::Iterator // No implementation - assignment is unsupported. @@ -4573,10 +4984,10 @@ class CartesianProductGenerator9 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> class CartesianProductGenerator10 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType; + typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType; CartesianProductGenerator10(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4687,7 +5098,7 @@ class CartesianProductGenerator10 virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -4751,9 +5162,9 @@ class CartesianProductGenerator10 void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType(*current1_, *current2_, *current3_, + current_value_.reset(new ParamType(*current1_, *current2_, *current3_, *current4_, *current5_, *current6_, *current7_, *current8_, - *current9_, *current10_); + *current9_, *current10_)); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -4807,7 +5218,7 @@ class CartesianProductGenerator10 const typename ParamGenerator<T10>::iterator begin10_; const typename ParamGenerator<T10>::iterator end10_; typename ParamGenerator<T10>::iterator current10_; - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator10::Iterator // No implementation - assignment is unsupported. @@ -4838,8 +5249,8 @@ class CartesianProductHolder2 { CartesianProductHolder2(const Generator1& g1, const Generator2& g2) : g1_(g1), g2_(g2) {} template <typename T1, typename T2> - operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2> >( + operator ParamGenerator< ::testing::tuple<T1, T2> >() const { + return ParamGenerator< ::testing::tuple<T1, T2> >( new CartesianProductGenerator2<T1, T2>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_))); @@ -4860,8 +5271,8 @@ CartesianProductHolder3(const Generator1& g1, const Generator2& g2, const Generator3& g3) : g1_(g1), g2_(g2), g3_(g3) {} template <typename T1, typename T2, typename T3> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >( + operator ParamGenerator< ::testing::tuple<T1, T2, T3> >() const { + return ParamGenerator< ::testing::tuple<T1, T2, T3> >( new CartesianProductGenerator3<T1, T2, T3>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4885,8 +5296,8 @@ CartesianProductHolder4(const Generator1& g1, const Generator2& g2, const Generator3& g3, const Generator4& g4) : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {} template <typename T1, typename T2, typename T3, typename T4> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >( + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >() const { + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >( new CartesianProductGenerator4<T1, T2, T3, T4>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4912,8 +5323,8 @@ CartesianProductHolder5(const Generator1& g1, const Generator2& g2, const Generator3& g3, const Generator4& g4, const Generator5& g5) : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {} template <typename T1, typename T2, typename T3, typename T4, typename T5> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >( + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >() const { + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >( new CartesianProductGenerator5<T1, T2, T3, T4, T5>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4943,8 +5354,8 @@ CartesianProductHolder6(const Generator1& g1, const Generator2& g2, : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >( + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >() const { + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >( new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4976,9 +5387,9 @@ CartesianProductHolder7(const Generator1& g1, const Generator2& g2, : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> >( + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> >( new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -5014,9 +5425,9 @@ CartesianProductHolder8(const Generator1& g1, const Generator2& g2, g8_(g8) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >( + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >( new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -5055,9 +5466,9 @@ CartesianProductHolder9(const Generator1& g1, const Generator2& g2, g9_(g9) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> >( new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>( static_cast<ParamGenerator<T1> >(g1_), @@ -5099,10 +5510,10 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2, g9_(g9), g10_(g10) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, - T9, T10> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, - T9, T10> >( + operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, + T10> >() const { + return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, + T10> >( new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>( static_cast<ParamGenerator<T1> >(g1_), @@ -5138,6 +5549,4 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2, } // namespace internal } // namespace testing -#endif // GTEST_HAS_PARAM_TEST - #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump b/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump index 009206fd319..30dffe43c3c 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump @@ -29,8 +29,7 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. // 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. -// -// Author: vladl@google.com (Vlad Losev) + // Type and function utilities for implementing parameterized tests. // This file is generated by a SCRIPT. DO NOT EDIT BY HAND! @@ -39,20 +38,17 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. // and at most $maxtuple arguments in Combine. Please contact // googletestframework@googlegroups.com if you need more. // Please note that the number of arguments to Combine is limited -// by the maximum arity of the implementation of tr1::tuple which is +// by the maximum arity of the implementation of tuple which is // currently set at $maxtuple. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ -// scripts/fuse_gtest.py depends on gtest's own header being #included -// *unconditionally*. Therefore these #includes cannot be moved -// inside #if GTEST_HAS_PARAM_TEST. #include "gtest/internal/gtest-param-util.h" #include "gtest/internal/gtest-port.h" -#if GTEST_HAS_PARAM_TEST - namespace testing { // Forward declarations of ValuesIn(), which is implemented in @@ -72,29 +68,14 @@ internal::ParamGenerator<typename Container::value_type> ValuesIn( namespace internal { // Used in the Values() function to provide polymorphic capabilities. -template <typename T1> -class ValueArray1 { - public: - explicit ValueArray1(T1 v1) : v1_(v1) {} - - template <typename T> - operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); } - - private: - // No implementation - assignment is unsupported. - void operator=(const ValueArray1& other); - - const T1 v1_; -}; - -$range i 2..n +$range i 1..n $for i [[ $range j 1..i template <$for j, [[typename T$j]]> class ValueArray$i { public: - ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {} + $if i==1 [[explicit ]]ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {} template <typename T> operator ParamGenerator<T>() const { @@ -102,6 +83,8 @@ class ValueArray$i { return ValuesIn(array); } + ValueArray$i(const ValueArray$i& other) : $for j, [[v$(j)_(other.v$(j)_)]] {} + private: // No implementation - assignment is unsupported. void operator=(const ValueArray$i& other); @@ -128,9 +111,9 @@ $range k 2..i template <$for j, [[typename T$j]]> class CartesianProductGenerator$i - : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > { + : public ParamGeneratorInterface< ::testing::tuple<$for j, [[T$j]]> > { public: - typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType; + typedef ::testing::tuple<$for j, [[T$j]]> ParamType; CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]]) : $for j, [[g$(j)_(g$j)]] {} @@ -180,7 +163,7 @@ $for k [[ virtual ParamIteratorInterface<ParamType>* Clone() const { return new Iterator(*this); } - virtual const ParamType* Current() const { return ¤t_value_; } + virtual const ParamType* Current() const { return current_value_.get(); } virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const { // Having the same base generator guarantees that the other // iterator is of the same type and we can downcast. @@ -212,7 +195,7 @@ $for k [[ void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = ParamType($for j, [[*current$(j)_]]); + current_value_.reset(new ParamType($for j, [[*current$(j)_]])); } bool AtEnd() const { // We must report iterator past the end of the range when either of the @@ -237,7 +220,7 @@ $for j [[ typename ParamGenerator<T$j>::iterator current$(j)_; ]] - ParamType current_value_; + linked_ptr<ParamType> current_value_; }; // class CartesianProductGenerator$i::Iterator // No implementation - assignment is unsupported. @@ -269,8 +252,8 @@ class CartesianProductHolder$i { CartesianProductHolder$i($for j, [[const Generator$j& g$j]]) : $for j, [[g$(j)_(g$j)]] {} template <$for j, [[typename T$j]]> - operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const { - return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >( + operator ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >() const { + return ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >( new CartesianProductGenerator$i<$for j, [[T$j]]>( $for j,[[ @@ -296,6 +279,4 @@ $for j [[ } // namespace internal } // namespace testing -#endif // GTEST_HAS_PARAM_TEST - #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-param-util.h b/src/test/fmw/gtest/include/gtest/internal/gtest-param-util.h index d5e1028b0c1..d64f620c4c6 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-param-util.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-param-util.h @@ -26,29 +26,49 @@ // 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. -// -// Author: vladl@google.com (Vlad Losev) + // Type and function utilities for implementing parameterized tests. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ +#include <ctype.h> + #include <iterator> +#include <set> #include <utility> #include <vector> -// scripts/fuse_gtest.py depends on gtest's own header being #included -// *unconditionally*. Therefore these #includes cannot be moved -// inside #if GTEST_HAS_PARAM_TEST. #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-linked_ptr.h" #include "gtest/internal/gtest-port.h" #include "gtest/gtest-printers.h" -#if GTEST_HAS_PARAM_TEST - namespace testing { + +// Input to a parameterized test name generator, describing a test parameter. +// Consists of the parameter value and the integer parameter index. +template <class ParamType> +struct TestParamInfo { + TestParamInfo(const ParamType& a_param, size_t an_index) : + param(a_param), + index(an_index) {} + ParamType param; + size_t index; +}; + +// A builtin parameterized test name generator which returns the result of +// testing::PrintToString. +struct PrintToStringParamName { + template <class ParamType> + std::string operator()(const TestParamInfo<ParamType>& info) const { + return PrintToString(info.param); + } +}; + namespace internal { // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. @@ -58,7 +78,7 @@ namespace internal { // TEST_P macro is used to define two tests with the same name // but in different namespaces. GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name, - const char* file, int line); + CodeLocation code_location); template <typename> class ParamGeneratorInterface; template <typename> class ParamGenerator; @@ -206,7 +226,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> { return base_; } virtual void Advance() { - value_ = value_ + step_; + value_ = static_cast<T>(value_ + step_); index_++; } virtual ParamIteratorInterface<T>* Clone() const { @@ -243,7 +263,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> { const T& end, const IncrementT& step) { int end_index = 0; - for (T i = begin; i < end; i = i + step) + for (T i = begin; i < end; i = static_cast<T>(i + step)) end_index++; return end_index; } @@ -345,6 +365,37 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> { const ContainerType container_; }; // class ValuesInIteratorRangeGenerator +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Default parameterized test name generator, returns a string containing the +// integer test parameter index. +template <class ParamType> +std::string DefaultParamName(const TestParamInfo<ParamType>& info) { + Message name_stream; + name_stream << info.index; + return name_stream.GetString(); +} + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Parameterized test name overload helpers, which help the +// INSTANTIATE_TEST_CASE_P macro choose between the default parameterized +// test name generator and user param name generator. +template <class ParamType, class ParamNameGenFunctor> +ParamNameGenFunctor GetParamNameGen(ParamNameGenFunctor func) { + return func; +} + +template <class ParamType> +struct ParamNameGenFunc { + typedef std::string Type(const TestParamInfo<ParamType>&); +}; + +template <class ParamType> +typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() { + return DefaultParamName; +} + // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // // Stores a parameter value and later creates tests parameterized with that @@ -417,7 +468,7 @@ class ParameterizedTestCaseInfoBase { virtual ~ParameterizedTestCaseInfoBase() {} // Base part of test case name for display purposes. - virtual const string& GetTestCaseName() const = 0; + virtual const std::string& GetTestCaseName() const = 0; // Test case id to verify identity. virtual TypeId GetTestCaseTypeId() const = 0; // UnitTest class invokes this method to register tests in this @@ -449,12 +500,14 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { typedef typename TestCase::ParamType ParamType; // A function that returns an instance of appropriate generator type. typedef ParamGenerator<ParamType>(GeneratorCreationFunc)(); + typedef typename ParamNameGenFunc<ParamType>::Type ParamNameGeneratorFunc; - explicit ParameterizedTestCaseInfo(const char* name) - : test_case_name_(name) {} + explicit ParameterizedTestCaseInfo( + const char* name, CodeLocation code_location) + : test_case_name_(name), code_location_(code_location) {} // Test case base name for display purposes. - virtual const string& GetTestCaseName() const { return test_case_name_; } + virtual const std::string& GetTestCaseName() const { return test_case_name_; } // Test case id to verify identity. virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); } // TEST_P macro uses AddTestPattern() to record information @@ -472,11 +525,12 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { } // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information // about a generator. - int AddTestCaseInstantiation(const string& instantiation_name, + int AddTestCaseInstantiation(const std::string& instantiation_name, GeneratorCreationFunc* func, - const char* /* file */, - int /* line */) { - instantiations_.push_back(::std::make_pair(instantiation_name, func)); + ParamNameGeneratorFunc* name_func, + const char* file, int line) { + instantiations_.push_back( + InstantiationInfo(instantiation_name, func, name_func, file, line)); return 0; // Return value used only to run this method in namespace scope. } // UnitTest class invokes this method to register tests in this test case @@ -491,25 +545,45 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { for (typename InstantiationContainer::iterator gen_it = instantiations_.begin(); gen_it != instantiations_.end(); ++gen_it) { - const string& instantiation_name = gen_it->first; - ParamGenerator<ParamType> generator((*gen_it->second)()); + const std::string& instantiation_name = gen_it->name; + ParamGenerator<ParamType> generator((*gen_it->generator)()); + ParamNameGeneratorFunc* name_func = gen_it->name_func; + const char* file = gen_it->file; + int line = gen_it->line; - string test_case_name; + std::string test_case_name; if ( !instantiation_name.empty() ) test_case_name = instantiation_name + "/"; test_case_name += test_info->test_case_base_name; - int i = 0; + size_t i = 0; + std::set<std::string> test_param_names; for (typename ParamGenerator<ParamType>::iterator param_it = generator.begin(); param_it != generator.end(); ++param_it, ++i) { Message test_name_stream; - test_name_stream << test_info->test_base_name << "/" << i; + + std::string param_name = name_func( + TestParamInfo<ParamType>(*param_it, i)); + + GTEST_CHECK_(IsValidParamName(param_name)) + << "Parameterized test name '" << param_name + << "' is invalid, in " << file + << " line " << line << std::endl; + + GTEST_CHECK_(test_param_names.count(param_name) == 0) + << "Duplicate parameterized test name '" << param_name + << "', in " << file << " line " << line << std::endl; + + test_param_names.insert(param_name); + + test_name_stream << test_info->test_base_name << "/" << param_name; MakeAndRegisterTestInfo( test_case_name.c_str(), test_name_stream.GetString().c_str(), NULL, // No type parameter. PrintToString(*param_it).c_str(), + code_location_, GetTestCaseTypeId(), TestCase::SetUpTestCase, TestCase::TearDownTestCase, @@ -530,17 +604,50 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { test_base_name(a_test_base_name), test_meta_factory(a_test_meta_factory) {} - const string test_case_base_name; - const string test_base_name; + const std::string test_case_base_name; + const std::string test_base_name; const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory; }; typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer; - // Keeps pairs of <Instantiation name, Sequence generator creation function> - // received from INSTANTIATE_TEST_CASE_P macros. - typedef ::std::vector<std::pair<string, GeneratorCreationFunc*> > - InstantiationContainer; + // Records data received from INSTANTIATE_TEST_CASE_P macros: + // <Instantiation name, Sequence generator creation function, + // Name generator function, Source file, Source line> + struct InstantiationInfo { + InstantiationInfo(const std::string &name_in, + GeneratorCreationFunc* generator_in, + ParamNameGeneratorFunc* name_func_in, + const char* file_in, + int line_in) + : name(name_in), + generator(generator_in), + name_func(name_func_in), + file(file_in), + line(line_in) {} + + std::string name; + GeneratorCreationFunc* generator; + ParamNameGeneratorFunc* name_func; + const char* file; + int line; + }; + typedef ::std::vector<InstantiationInfo> InstantiationContainer; - const string test_case_name_; + static bool IsValidParamName(const std::string& name) { + // Check for empty string + if (name.empty()) + return false; + + // Check for invalid characters + for (std::string::size_type index = 0; index < name.size(); ++index) { + if (!isalnum(name[index]) && name[index] != '_') + return false; + } + + return true; + } + + const std::string test_case_name_; + CodeLocation code_location_; TestInfoContainer tests_; InstantiationContainer instantiations_; @@ -568,8 +675,7 @@ class ParameterizedTestCaseRegistry { template <class TestCase> ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder( const char* test_case_name, - const char* file, - int line) { + CodeLocation code_location) { ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL; for (TestCaseInfoContainer::iterator it = test_case_infos_.begin(); it != test_case_infos_.end(); ++it) { @@ -578,7 +684,7 @@ class ParameterizedTestCaseRegistry { // Complain about incorrect usage of Google Test facilities // and terminate the program since we cannot guaranty correct // test case setup and tear-down in this case. - ReportInvalidTestCaseType(test_case_name, file, line); + ReportInvalidTestCaseType(test_case_name, code_location); posix::Abort(); } else { // At this point we are sure that the object we found is of the same @@ -591,7 +697,8 @@ class ParameterizedTestCaseRegistry { } } if (typed_test_info == NULL) { - typed_test_info = new ParameterizedTestCaseInfo<TestCase>(test_case_name); + typed_test_info = new ParameterizedTestCaseInfo<TestCase>( + test_case_name, code_location); test_case_infos_.push_back(typed_test_info); } return typed_test_info; @@ -614,6 +721,4 @@ class ParameterizedTestCaseRegistry { } // namespace internal } // namespace testing -#endif // GTEST_HAS_PARAM_TEST - #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-port-arch.h b/src/test/fmw/gtest/include/gtest/internal/gtest-port-arch.h new file mode 100644 index 00000000000..f83700e06d9 --- /dev/null +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-port-arch.h @@ -0,0 +1,100 @@ +// Copyright 2015, Google Inc. +// 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 Google Inc. 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. +// +// The Google C++ Testing and Mocking Framework (Google Test) +// +// This header file defines the GTEST_OS_* macro. +// It is separate from gtest-port.h so that custom/gtest-port.h can include it. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ + +// Determines the platform on which Google Test is compiled. +#ifdef __CYGWIN__ +# define GTEST_OS_CYGWIN 1 +#elif defined __SYMBIAN32__ +# define GTEST_OS_SYMBIAN 1 +#elif defined _WIN32 +# define GTEST_OS_WINDOWS 1 +# ifdef _WIN32_WCE +# define GTEST_OS_WINDOWS_MOBILE 1 +# elif defined(__MINGW__) || defined(__MINGW32__) +# define GTEST_OS_WINDOWS_MINGW 1 +# elif defined(WINAPI_FAMILY) +# include <winapifamily.h> +# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# define GTEST_OS_WINDOWS_DESKTOP 1 +# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +# define GTEST_OS_WINDOWS_PHONE 1 +# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +# define GTEST_OS_WINDOWS_RT 1 +# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE) +# define GTEST_OS_WINDOWS_PHONE 1 +# define GTEST_OS_WINDOWS_TV_TITLE 1 +# else + // WINAPI_FAMILY defined but no known partition matched. + // Default to desktop. +# define GTEST_OS_WINDOWS_DESKTOP 1 +# endif +# else +# define GTEST_OS_WINDOWS_DESKTOP 1 +# endif // _WIN32_WCE +#elif defined __APPLE__ +# define GTEST_OS_MAC 1 +# if TARGET_OS_IPHONE +# define GTEST_OS_IOS 1 +# endif +#elif defined __FreeBSD__ +# define GTEST_OS_FREEBSD 1 +#elif defined __Fuchsia__ +# define GTEST_OS_FUCHSIA 1 +#elif defined __linux__ +# define GTEST_OS_LINUX 1 +# if defined __ANDROID__ +# define GTEST_OS_LINUX_ANDROID 1 +# endif +#elif defined __MVS__ +# define GTEST_OS_ZOS 1 +#elif defined(__sun) && defined(__SVR4) +# define GTEST_OS_SOLARIS 1 +#elif defined(_AIX) +# define GTEST_OS_AIX 1 +#elif defined(__hpux) +# define GTEST_OS_HPUX 1 +#elif defined __native_client__ +# define GTEST_OS_NACL 1 +#elif defined __NetBSD__ +# define GTEST_OS_NETBSD 1 +#elif defined __OpenBSD__ +# define GTEST_OS_OPENBSD 1 +#elif defined __QNX__ +# define GTEST_OS_QNX 1 +#endif // __CYGWIN__ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-port.h b/src/test/fmw/gtest/include/gtest/internal/gtest-port.h index b772f4bed77..49d3f7580d7 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-port.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-port.h @@ -27,33 +27,55 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: wan@google.com (Zhanyong Wan) -// // Low-level types and utilities for porting Google Test to various -// platforms. They are subject to change without notice. DO NOT USE -// THEM IN USER CODE. +// platforms. All macros ending with _ and symbols defined in an +// internal namespace are subject to change without notice. Code +// outside Google Test MUST NOT USE THEM DIRECTLY. Macros that don't +// end with _ are part of Google Test's public API and can be used by +// code outside Google Test. // // This file is fundamental to Google Test. All other Google Test source // files are expected to #include this. Therefore, it cannot #include // any other Google Test header. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ -// The user can define the following macros in the build script to -// control Google Test's behavior. If the user doesn't define a macro -// in this list, Google Test will define it. +// Environment-describing macros +// ----------------------------- +// +// Google Test can be used in many different environments. Macros in +// this section tell Google Test what kind of environment it is being +// used in, such that Google Test can provide environment-specific +// features and implementations. +// +// Google Test tries to automatically detect the properties of its +// environment, so users usually don't need to worry about these +// macros. However, the automatic detection is not perfect. +// Sometimes it's necessary for a user to define some of the following +// macros in the build script to override Google Test's decisions. +// +// If the user doesn't define a macro in the list, Google Test will +// provide a default definition. After this header is #included, all +// macros in this list will be defined to either 1 or 0. +// +// Notes to maintainers: +// - Each macro here is a user-tweakable knob; do not grow the list +// lightly. +// - Use #if to key off these macros. Don't use #ifdef or "#if +// defined(...)", which will not work as these macros are ALWAYS +// defined. // // GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2) // is/isn't available. // GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions // are enabled. // GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string -// is/isn't available (some systems define -// ::string, which is different to std::string). -// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string -// is/isn't available (some systems define -// ::wstring, which is different to std::wstring). +// is/isn't available +// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::wstring +// is/isn't available // GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular // expressions are/aren't available. // GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h> @@ -85,20 +107,33 @@ // GTEST_CREATE_SHARED_LIBRARY // - Define to 1 when compiling Google Test itself // as a shared library. - -// This header defines the following utilities: +// GTEST_DEFAULT_DEATH_TEST_STYLE +// - The default value of --gtest_death_test_style. +// The legacy default has been "fast" in the open +// source version since 2008. The recommended value +// is "threadsafe", and can be set in +// custom/gtest-port.h. + +// Platform-indicating macros +// -------------------------- +// +// Macros indicating the platform on which Google Test is being used +// (a macro is defined to 1 if compiled on the given platform; +// otherwise UNDEFINED -- it's never defined to 0.). Google Test +// defines these macros automatically. Code outside Google Test MUST +// NOT define them. // -// Macros indicating the current platform (defined to 1 if compiled on -// the given platform; otherwise undefined): // GTEST_OS_AIX - IBM AIX // GTEST_OS_CYGWIN - Cygwin +// GTEST_OS_FREEBSD - FreeBSD +// GTEST_OS_FUCHSIA - Fuchsia // GTEST_OS_HPUX - HP-UX // GTEST_OS_LINUX - Linux // GTEST_OS_LINUX_ANDROID - Google Android // GTEST_OS_MAC - Mac OS X // GTEST_OS_IOS - iOS -// GTEST_OS_IOS_SIMULATOR - iOS simulator // GTEST_OS_NACL - Google Native Client (NaCl) +// GTEST_OS_NETBSD - NetBSD // GTEST_OS_OPENBSD - OpenBSD // GTEST_OS_QNX - QNX // GTEST_OS_SOLARIS - Sun Solaris @@ -107,6 +142,8 @@ // GTEST_OS_WINDOWS_DESKTOP - Windows Desktop // GTEST_OS_WINDOWS_MINGW - MinGW // GTEST_OS_WINDOWS_MOBILE - Windows Mobile +// GTEST_OS_WINDOWS_PHONE - Windows Phone +// GTEST_OS_WINDOWS_RT - Windows Store App/WinRT // GTEST_OS_ZOS - z/OS // // Among the platforms, Cygwin, Linux, Max OS X, and Windows have the @@ -116,22 +153,50 @@ // googletestframework@googlegroups.com (patches for fixing them are // even more welcome!). // -// Note that it is possible that none of the GTEST_OS_* macros are defined. +// It is possible that none of the GTEST_OS_* macros are defined. + +// Feature-indicating macros +// ------------------------- +// +// Macros indicating which Google Test features are available (a macro +// is defined to 1 if the corresponding feature is supported; +// otherwise UNDEFINED -- it's never defined to 0.). Google Test +// defines these macros automatically. Code outside Google Test MUST +// NOT define them. +// +// These macros are public so that portable tests can be written. +// Such tests typically surround code using a feature with an #if +// which controls that code. For example: +// +// #if GTEST_HAS_DEATH_TEST +// EXPECT_DEATH(DoSomethingDeadly()); +// #endif // -// Macros indicating available Google Test features (defined to 1 if -// the corresponding feature is supported; otherwise undefined): // GTEST_HAS_COMBINE - the Combine() function (for value-parameterized // tests) // GTEST_HAS_DEATH_TEST - death tests -// GTEST_HAS_PARAM_TEST - value-parameterized tests // GTEST_HAS_TYPED_TEST - typed tests // GTEST_HAS_TYPED_TEST_P - type-parameterized tests +// GTEST_IS_THREADSAFE - Google Test is thread-safe. +// GOOGLETEST_CM0007 DO NOT DELETE // GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with // GTEST_HAS_POSIX_RE (see above) which users can // define themselves. // GTEST_USES_SIMPLE_RE - our own simple regex is used; -// the above two are mutually exclusive. +// the above RE\b(s) are mutually exclusive. // GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ(). + +// Misc public macros +// ------------------ +// +// GTEST_FLAG(flag_name) - references the variable corresponding to +// the given Google Test flag. + +// Internal utilities +// ------------------ +// +// The following macros and utilities are for Google Test's INTERNAL +// use only. Code outside Google Test MUST NOT USE THEM DIRECTLY. // // Macros for basic C++ coding: // GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning. @@ -140,13 +205,19 @@ // GTEST_DISALLOW_ASSIGN_ - disables operator=. // GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=. // GTEST_MUST_USE_RESULT_ - declares that a function's result must be used. +// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is +// suppressed (constant conditional). +// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127 +// is suppressed. +// +// C++11 feature wrappers: +// +// testing::internal::forward - portability wrapper for std::forward. +// testing::internal::move - portability wrapper for std::move. // // Synchronization: // Mutex, MutexLock, ThreadLocal, GetThreadCount() -// - synchronization primitives. -// GTEST_IS_THREADSAFE - defined to 1 to indicate that the above -// synchronization primitives have real implementations -// and Google Test is thread-safe; or 0 otherwise. +// - synchronization primitives. // // Template meta programming: // is_pointer - as in TR1; needed on Symbian and IBM XL C/C++ only. @@ -158,10 +229,10 @@ // // Regular expressions: // RE - a simple regular expression class using the POSIX -// Extended Regular Expression syntax on UNIX-like -// platforms, or a reduced regular exception syntax on -// other platforms, including Windows. -// +// Extended Regular Expression syntax on UNIX-like platforms +// GOOGLETEST_CM0008 DO NOT DELETE +// or a reduced regular exception syntax on other +// platforms, including Windows. // Logging: // GTEST_LOG_() - logs messages at the specified severity level. // LogToStderr() - directs all log messages to stderr. @@ -182,7 +253,6 @@ // BiggestInt - the biggest signed integer type. // // Command-line utilities: -// GTEST_FLAG() - references a flag. // GTEST_DECLARE_*() - declares a flag. // GTEST_DEFINE_*() - defines a flag. // GetInjectableArgvs() - returns the command line as a vector of strings. @@ -201,23 +271,44 @@ #ifndef _WIN32_WCE # include <sys/types.h> # include <sys/stat.h> -#endif // !_WIN32_WCE +#elif _WIN32_WCE >= 0x800 // Windows Embedded Compact 2013 +// Forward declare instead of including <windows.h> / <windef.h> / <winnt.h> +typedef wchar_t WCHAR; +typedef WCHAR *PWCHAR, *LPWCH, *PWCH; +typedef const WCHAR *LPCWCH, *PCWCH; +typedef __readableTo(sentinel(0)) const WCHAR *LPCWSTR, *PCWSTR; +typedef const WCHAR *LPCWCHAR, *PCWCHAR; +#endif #if defined __APPLE__ # include <AvailabilityMacros.h> # include <TargetConditionals.h> #endif +// Brings in the definition of HAS_GLOBAL_STRING. This must be done +// BEFORE we test HAS_GLOBAL_STRING. +#include <string> // NOLINT +#include <algorithm> // NOLINT #include <iostream> // NOLINT #include <sstream> // NOLINT -#include <string> // NOLINT +#include <utility> +#include <vector> // NOLINT + +#include "gtest/internal/gtest-port-arch.h" +#include "gtest/internal/custom/gtest-port.h" -#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" -#define GTEST_FLAG_PREFIX_ "gtest_" -#define GTEST_FLAG_PREFIX_DASH_ "gtest-" -#define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" -#define GTEST_NAME_ "Google Test" -#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/" +#if !defined(GTEST_DEV_EMAIL_) +# define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" +# define GTEST_FLAG_PREFIX_ "gtest_" +# define GTEST_FLAG_PREFIX_DASH_ "gtest-" +# define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" +# define GTEST_NAME_ "Google Test" +# define GTEST_PROJECT_URL_ "https://github.com/google/googletest/" +#endif // !defined(GTEST_DEV_EMAIL_) + +#if !defined(GTEST_INIT_GOOGLE_TEST_NAME_) +# define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest" +#endif // !defined(GTEST_INIT_GOOGLE_TEST_NAME_) // Determines the version of gcc that is used to compile this. #ifdef __GNUC__ @@ -226,55 +317,45 @@ (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) #endif // __GNUC__ -// Determines the platform on which Google Test is compiled. -#ifdef __CYGWIN__ -# define GTEST_OS_CYGWIN 1 -#elif defined __SYMBIAN32__ -# define GTEST_OS_SYMBIAN 1 -#elif defined _WIN32 -# define GTEST_OS_WINDOWS 1 -# ifdef _WIN32_WCE -# define GTEST_OS_WINDOWS_MOBILE 1 -# elif defined(__MINGW__) || defined(__MINGW32__) -# define GTEST_OS_WINDOWS_MINGW 1 -# else -# define GTEST_OS_WINDOWS_DESKTOP 1 -# endif // _WIN32_WCE -#elif defined __APPLE__ -# define GTEST_OS_MAC 1 -# if TARGET_OS_IPHONE -# define GTEST_OS_IOS 1 -# if TARGET_IPHONE_SIMULATOR -# define GTEST_OS_IOS_SIMULATOR 1 -# endif -# endif -#elif defined __linux__ -# define GTEST_OS_LINUX 1 -# if defined __ANDROID__ -# define GTEST_OS_LINUX_ANDROID 1 -# endif -#elif defined __MVS__ -# define GTEST_OS_ZOS 1 -#elif defined(__sun) && defined(__SVR4) -# define GTEST_OS_SOLARIS 1 -#elif defined(_AIX) -# define GTEST_OS_AIX 1 -#elif defined(__hpux) -# define GTEST_OS_HPUX 1 -#elif defined __native_client__ -# define GTEST_OS_NACL 1 -#elif defined __OpenBSD__ -# define GTEST_OS_OPENBSD 1 -#elif defined __QNX__ -# define GTEST_OS_QNX 1 -#endif // __CYGWIN__ +// Macros for disabling Microsoft Visual C++ warnings. +// +// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385) +// /* code that triggers warnings C4800 and C4385 */ +// GTEST_DISABLE_MSC_WARNINGS_POP_() +#if _MSC_VER >= 1400 +# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \ + __pragma(warning(push)) \ + __pragma(warning(disable: warnings)) +# define GTEST_DISABLE_MSC_WARNINGS_POP_() \ + __pragma(warning(pop)) +#else +// Older versions of MSVC don't have __pragma. +# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) +# define GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif + +// Clang on Windows does not understand MSVC's pragma warning. +// We need clang-specific way to disable function deprecation warning. +#ifdef __clang__ +# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") +#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ + _Pragma("clang diagnostic pop") +#else +# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) +# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ + GTEST_DISABLE_MSC_WARNINGS_POP_() +#endif #ifndef GTEST_LANG_CXX11 // gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when // -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a // value for __cplusplus, and recent versions of clang, gcc, and // probably other compilers set that too in C++11 mode. -# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L +# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L || _MSC_VER >= 1900 // Compiling in at least C++11 mode. # define GTEST_LANG_CXX11 1 # else @@ -282,19 +363,95 @@ # endif #endif +// Distinct from C++11 language support, some environments don't provide +// proper C++11 library support. Notably, it's possible to build in +// C++11 mode when targeting Mac OS X 10.6, which has an old libstdc++ +// with no C++11 support. +// +// libstdc++ has sufficient C++11 support as of GCC 4.6.0, __GLIBCXX__ +// 20110325, but maintenance releases in the 4.4 and 4.5 series followed +// this date, so check for those versions by their date stamps. +// https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning +#if GTEST_LANG_CXX11 && \ + (!defined(__GLIBCXX__) || ( \ + __GLIBCXX__ >= 20110325ul && /* GCC >= 4.6.0 */ \ + /* Blacklist of patch releases of older branches: */ \ + __GLIBCXX__ != 20110416ul && /* GCC 4.4.6 */ \ + __GLIBCXX__ != 20120313ul && /* GCC 4.4.7 */ \ + __GLIBCXX__ != 20110428ul && /* GCC 4.5.3 */ \ + __GLIBCXX__ != 20120702ul)) /* GCC 4.5.4 */ +# define GTEST_STDLIB_CXX11 1 +#endif + +// Only use C++11 library features if the library provides them. +#if GTEST_STDLIB_CXX11 +# define GTEST_HAS_STD_BEGIN_AND_END_ 1 +# define GTEST_HAS_STD_FORWARD_LIST_ 1 +# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) +// works only with VS2015U2 and better +# define GTEST_HAS_STD_FUNCTION_ 1 +# endif +# define GTEST_HAS_STD_INITIALIZER_LIST_ 1 +# define GTEST_HAS_STD_MOVE_ 1 +# define GTEST_HAS_STD_UNIQUE_PTR_ 1 +# define GTEST_HAS_STD_SHARED_PTR_ 1 +# define GTEST_HAS_UNORDERED_MAP_ 1 +# define GTEST_HAS_UNORDERED_SET_ 1 +#endif + +// C++11 specifies that <tuple> provides std::tuple. +// Some platforms still might not have it, however. +#if GTEST_LANG_CXX11 +# define GTEST_HAS_STD_TUPLE_ 1 +# if defined(__clang__) +// Inspired by +// https://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros +# if defined(__has_include) && !__has_include(<tuple>) +# undef GTEST_HAS_STD_TUPLE_ +# endif +# elif defined(_MSC_VER) +// Inspired by boost/config/stdlib/dinkumware.hpp +# if defined(_CPPLIB_VER) && _CPPLIB_VER < 520 +# undef GTEST_HAS_STD_TUPLE_ +# endif +# elif defined(__GLIBCXX__) +// Inspired by boost/config/stdlib/libstdcpp3.hpp, +// http://gcc.gnu.org/gcc-4.2/changes.html and +// https://web.archive.org/web/20140227044429/gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) +# undef GTEST_HAS_STD_TUPLE_ +# endif +# endif +#endif + // Brings in definitions for functions used in the testing::internal::posix // namespace (read, write, close, chdir, isatty, stat). We do not currently // use them on Windows Mobile. -#if !GTEST_OS_WINDOWS +#if GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS_MOBILE +# include <direct.h> +# include <io.h> +# endif +// In order to avoid having to include <windows.h>, use forward declaration +#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR) +// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two +// separate (equivalent) structs, instead of using typedef +typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION; +#elif _WIN32_WCE >= 0x800 +typedef struct CRITICAL_SECTION GTEST_CRITICAL_SECTION; +#else +// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION. +// This assumption is verified by +// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION. +typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; +#endif +#else // This assumes that non-Windows OSes provide unistd.h. For OSes where this // is not the case, we need to include headers that provide the functions // mentioned above. # include <unistd.h> # include <strings.h> -#elif !GTEST_OS_WINDOWS_MOBILE -# include <direct.h> -# include <io.h> -#endif +#endif // GTEST_OS_WINDOWS #if GTEST_OS_LINUX_ANDROID // Used to define __ANDROID_API__ matching the target NDK API level. @@ -311,7 +468,10 @@ # endif #endif -#if GTEST_HAS_POSIX_RE +#if GTEST_USES_PCRE +// The appropriate headers have already been included. + +#elif GTEST_HAS_POSIX_RE // On some platforms, <regex.h> needs someone to define size_t, and // won't compile otherwise. We can #include it here as we already @@ -333,19 +493,31 @@ // simple regex implementation instead. # define GTEST_USES_SIMPLE_RE 1 -#endif // GTEST_HAS_POSIX_RE +#endif // GTEST_USES_PCRE #ifndef GTEST_HAS_EXCEPTIONS // The user didn't tell us whether exceptions are enabled, so we need // to figure it out. -# if defined(_MSC_VER) || defined(__BORLANDC__) -// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS +# if defined(_MSC_VER) && defined(_CPPUNWIND) +// MSVC defines _CPPUNWIND to 1 iff exceptions are enabled. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__BORLANDC__) +// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS // macro to enable exceptions, so we'll do the same. // Assumes that exceptions are enabled by default. # ifndef _HAS_EXCEPTIONS # define _HAS_EXCEPTIONS 1 # endif // _HAS_EXCEPTIONS # define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS +# elif defined(__clang__) +// clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714, +// but iff cleanups are enabled after that. In Obj-C++ files, there can be +// cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions +// are disabled. clang has __has_feature(cxx_exceptions) which checks for C++ +// exceptions starting at clang r206352, but which checked for cleanups prior to +// that. To reliably check for C++ exception availability with clang, check for +// __EXCEPTIONS && __has_feature(cxx_exceptions). +# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions)) # elif defined(__GNUC__) && __EXCEPTIONS // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. # define GTEST_HAS_EXCEPTIONS 1 @@ -374,21 +546,17 @@ # define GTEST_HAS_STD_STRING 1 #elif !GTEST_HAS_STD_STRING // The user told us that ::std::string isn't available. -# error "Google Test cannot be used where ::std::string isn't available." +# error "::std::string isn't available." #endif // !defined(GTEST_HAS_STD_STRING) #ifndef GTEST_HAS_GLOBAL_STRING -// The user didn't tell us whether ::string is available, so we need -// to figure it out. - # define GTEST_HAS_GLOBAL_STRING 0 - #endif // GTEST_HAS_GLOBAL_STRING #ifndef GTEST_HAS_STD_WSTRING // The user didn't tell us whether ::std::wstring is available, so we need // to figure it out. -// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring +// FIXME: uses autoconf to detect whether ::std::wstring // is available. // Cygwin 1.7 and below doesn't support ::std::wstring. @@ -471,13 +639,14 @@ // Determines whether Google Test can use the pthreads library. #ifndef GTEST_HAS_PTHREAD -// The user didn't tell us explicitly, so we assume pthreads support is -// available on Linux and Mac. +// The user didn't tell us explicitly, so we make reasonable assumptions about +// which platforms have pthreads support. // // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0 // to your compiler flags. -# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \ - || GTEST_OS_QNX) +#define GTEST_HAS_PTHREAD \ + (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \ + GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA) #endif // GTEST_HAS_PTHREAD #if GTEST_HAS_PTHREAD @@ -489,6 +658,15 @@ # include <time.h> // NOLINT #endif +// Determines if hash_map/hash_set are available. +// Only used for testing against those containers. +#if !defined(GTEST_HAS_HASH_MAP_) +# if defined(_MSC_VER) && (_MSC_VER < 1900) +# define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available. +# define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available. +# endif // _MSC_VER +#endif // !defined(GTEST_HAS_HASH_MAP_) + // Determines whether Google Test can use tr1/tuple. You can define // this macro to 0 to prevent Google Test from using tuple (any // feature depending on tuple with be disabled in this mode). @@ -496,6 +674,14 @@ # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) // STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>. # define GTEST_HAS_TR1_TUPLE 0 +# elif defined(_MSC_VER) && (_MSC_VER >= 1910) +// Prevent `warning C4996: 'std::tr1': warning STL4002: +// The non-Standard std::tr1 namespace and TR1-only machinery +// are deprecated and will be REMOVED.` +# define GTEST_HAS_TR1_TUPLE 0 +# elif GTEST_LANG_CXX11 && defined(_LIBCPP_VERSION) +// libc++ doesn't support TR1. +# define GTEST_HAS_TR1_TUPLE 0 # else // The user didn't tell us not to do it, so we assume it's OK. # define GTEST_HAS_TR1_TUPLE 1 @@ -505,6 +691,10 @@ // Determines whether Google Test's own tr1 tuple implementation // should be used. #ifndef GTEST_USE_OWN_TR1_TUPLE +// We use our own tuple implementation on Symbian. +# if GTEST_OS_SYMBIAN +# define GTEST_USE_OWN_TR1_TUPLE 1 +# else // The user didn't tell us, so we need to figure it out. // We use our own TR1 tuple if we aren't sure the user has an @@ -518,7 +708,8 @@ // support TR1 tuple. libc++ only provides std::tuple, in C++11 mode, // and it can be used with some compilers that define __GNUC__. # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \ - && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600 + && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) \ + || (_MSC_VER >= 1600 && _MSC_VER < 1900) # define GTEST_ENV_HAS_TR1_TUPLE_ 1 # endif @@ -534,32 +725,25 @@ # else # define GTEST_USE_OWN_TR1_TUPLE 1 # endif - +# endif // GTEST_OS_SYMBIAN #endif // GTEST_USE_OWN_TR1_TUPLE -// To avoid conditional compilation everywhere, we make it -// gtest-port.h's responsibility to #include the header implementing -// tr1/tuple. +// To avoid conditional compilation we make it gtest-port.h's responsibility +// to #include the header implementing tuple. +#if GTEST_HAS_STD_TUPLE_ +# include <tuple> // IWYU pragma: export +# define GTEST_TUPLE_NAMESPACE_ ::std +#endif // GTEST_HAS_STD_TUPLE_ + +// We include tr1::tuple even if std::tuple is available to define printers for +// them. #if GTEST_HAS_TR1_TUPLE +# ifndef GTEST_TUPLE_NAMESPACE_ +# define GTEST_TUPLE_NAMESPACE_ ::std::tr1 +# endif // GTEST_TUPLE_NAMESPACE_ # if GTEST_USE_OWN_TR1_TUPLE -# include "gtest/internal/gtest-tuple.h" -# elif GTEST_ENV_HAS_STD_TUPLE_ -# include <tuple> -// C++11 puts its tuple into the ::std namespace rather than -// ::std::tr1. gtest expects tuple to live in ::std::tr1, so put it there. -// This causes undefined behavior, but supported compilers react in -// the way we intend. -namespace std { -namespace tr1 { -using ::std::get; -using ::std::make_tuple; -using ::std::tuple; -using ::std::tuple_element; -using ::std::tuple_size; -} -} - +# include "gtest/internal/gtest-tuple.h" // IWYU pragma: export // NOLINT # elif GTEST_OS_SYMBIAN // On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to @@ -574,7 +758,7 @@ using ::std::tuple_size; // This prevents <boost/tr1/detail/config.hpp>, which defines // BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>. # define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED -# include <tuple> +# include <tuple> // IWYU pragma: export // NOLINT # elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000) // GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header. This does @@ -584,20 +768,22 @@ using ::std::tuple_size; // Until version 4.3.2, gcc has a bug that causes <tr1/functional>, // which is #included by <tr1/tuple>, to not compile when RTTI is // disabled. _TR1_FUNCTIONAL is the header guard for -// <tr1/functional>. Hence the following #define is a hack to prevent +// <tr1/functional>. Hence the following #define is used to prevent // <tr1/functional> from being included. # define _TR1_FUNCTIONAL 1 # include <tr1/tuple> # undef _TR1_FUNCTIONAL // Allows the user to #include - // <tr1/functional> if he chooses to. + // <tr1/functional> if they choose to. # else # include <tr1/tuple> // NOLINT # endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302 -# else -// If the compiler is not GCC 4.0+, we assume the user is using a -// spec-conforming TR1 implementation. -# include <tuple> // NOLINT +// VS 2010 now has tr1 support. +# elif _MSC_VER >= 1600 +# include <tuple> // IWYU pragma: export // NOLINT + +# else // GTEST_USE_OWN_TR1_TUPLE +# include <tr1/tuple> // IWYU pragma: export // NOLINT # endif // GTEST_USE_OWN_TR1_TUPLE #endif // GTEST_HAS_TR1_TUPLE @@ -611,8 +797,12 @@ using ::std::tuple_size; # if GTEST_OS_LINUX && !defined(__ia64__) # if GTEST_OS_LINUX_ANDROID -// On Android, clone() is only available on ARM starting with Gingerbread. -# if defined(__arm__) && __ANDROID_API__ >= 9 +// On Android, clone() became available at different API levels for each 32-bit +// architecture. +# if defined(__LP64__) || \ + (defined(__arm__) && __ANDROID_API__ >= 9) || \ + (defined(__mips__) && __ANDROID_API__ >= 12) || \ + (defined(__i386__) && __ANDROID_API__ >= 17) # define GTEST_HAS_CLONE 1 # else # define GTEST_HAS_CLONE 0 @@ -631,7 +821,8 @@ using ::std::tuple_size; #ifndef GTEST_HAS_STREAM_REDIRECTION // By default, we assume that stream redirection is supported on all // platforms except known mobile ones. -# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN +# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || \ + GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT # define GTEST_HAS_STREAM_REDIRECTION 0 # else # define GTEST_HAS_STREAM_REDIRECTION 1 @@ -642,20 +833,15 @@ using ::std::tuple_size; // Google Test does not support death tests for VC 7.1 and earlier as // abort() in a VC 7.1 application compiled as GUI in debug config // pops up a dialog window that cannot be suppressed programmatically. -#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ - (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \ - (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \ +#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ + (GTEST_OS_MAC && !GTEST_OS_IOS) || \ + (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \ GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \ - GTEST_OS_OPENBSD || GTEST_OS_QNX) + GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \ + GTEST_OS_NETBSD || GTEST_OS_FUCHSIA) # define GTEST_HAS_DEATH_TEST 1 -# include <vector> // NOLINT #endif -// We don't support MSVC 7.1 with exceptions disabled now. Therefore -// all the compilers we care about are adequate for supporting -// value-parameterized tests. -#define GTEST_HAS_PARAM_TEST 1 - // Determines whether to support type-driven tests. // Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0, @@ -670,7 +856,7 @@ using ::std::tuple_size; // value-parameterized tests are enabled. The implementation doesn't // work on Sun Studio since it doesn't understand templated conversion // operators. -#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC) +#if (GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_) && !defined(__SUNPRO_CC) # define GTEST_HAS_COMBINE 1 #endif @@ -712,19 +898,48 @@ using ::std::tuple_size; // compiler the variable/parameter does not have to be used. #if defined(__GNUC__) && !defined(COMPILER_ICC) # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) -#else +#elif defined(__clang__) +# if __has_attribute(unused) +# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +# endif +#endif +#ifndef GTEST_ATTRIBUTE_UNUSED_ # define GTEST_ATTRIBUTE_UNUSED_ #endif +#if GTEST_LANG_CXX11 +# define GTEST_CXX11_EQUALS_DELETE_ = delete +#else // GTEST_LANG_CXX11 +# define GTEST_CXX11_EQUALS_DELETE_ +#endif // GTEST_LANG_CXX11 + +// Use this annotation before a function that takes a printf format string. +#if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC) +# if defined(__MINGW_PRINTF_FORMAT) +// MinGW has two different printf implementations. Ensure the format macro +// matches the selected implementation. See +// https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. +# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \ + first_to_check))) +# else +# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__((__format__(__printf__, string_index, first_to_check))) +# endif +#else +# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) +#endif + + // A macro to disallow operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_ASSIGN_(type)\ - void operator=(type const &) +#define GTEST_DISALLOW_ASSIGN_(type) \ + void operator=(type const &) GTEST_CXX11_EQUALS_DELETE_ // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ - type(type const &);\ +#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ + type(type const &) GTEST_CXX11_EQUALS_DELETE_; \ GTEST_DISALLOW_ASSIGN_(type) // Tell the compiler to warn about unused return values for functions declared @@ -738,6 +953,19 @@ using ::std::tuple_size; # define GTEST_MUST_USE_RESULT_ #endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC +// MS C++ compiler emits warning when a conditional expression is compile time +// constant. In some contexts this warning is false positive and needs to be +// suppressed. Use the following two macros in such cases: +// +// GTEST_INTENTIONAL_CONST_COND_PUSH_() +// while (true) { +// GTEST_INTENTIONAL_CONST_COND_POP_() +// } +# define GTEST_INTENTIONAL_CONST_COND_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127) +# define GTEST_INTENTIONAL_CONST_COND_POP_() \ + GTEST_DISABLE_MSC_WARNINGS_POP_() + // Determine whether the compiler supports Microsoft's Structured Exception // Handling. This is supported by several Windows compilers but generally // does not exist on any other system. @@ -752,21 +980,37 @@ using ::std::tuple_size; # define GTEST_HAS_SEH 0 # endif +#define GTEST_IS_THREADSAFE \ + (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \ + || (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \ + || GTEST_HAS_PTHREAD) + #endif // GTEST_HAS_SEH -#ifdef _MSC_VER +// GTEST_API_ qualifies all symbols that must be exported. The definitions below +// are guarded by #ifndef to give embedders a chance to define GTEST_API_ in +// gtest/internal/custom/gtest-port.h +#ifndef GTEST_API_ +#ifdef _MSC_VER # if GTEST_LINKED_AS_SHARED_LIBRARY # define GTEST_API_ __declspec(dllimport) # elif GTEST_CREATE_SHARED_LIBRARY # define GTEST_API_ __declspec(dllexport) # endif - +#elif __GNUC__ >= 4 || defined(__clang__) +# define GTEST_API_ __attribute__((visibility ("default"))) #endif // _MSC_VER +#endif // GTEST_API_ + #ifndef GTEST_API_ # define GTEST_API_ -#endif +#endif // GTEST_API_ + +#ifndef GTEST_DEFAULT_DEATH_TEST_STYLE +# define GTEST_DEFAULT_DEATH_TEST_STYLE "fast" +#endif // GTEST_DEFAULT_DEATH_TEST_STYLE #ifdef __GNUC__ // Ask the compiler to never inline a given function. @@ -776,16 +1020,66 @@ using ::std::tuple_size; #endif // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project. -#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) -# define GTEST_HAS_CXXABI_H_ 1 -#else -# define GTEST_HAS_CXXABI_H_ 0 +#if !defined(GTEST_HAS_CXXABI_H_) +# if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) +# define GTEST_HAS_CXXABI_H_ 1 +# else +# define GTEST_HAS_CXXABI_H_ 0 +# endif #endif +// A function level attribute to disable checking for use of uninitialized +// memory when built with MemorySanitizer. +#if defined(__clang__) +# if __has_feature(memory_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \ + __attribute__((no_sanitize_memory)) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +# endif // __has_feature(memory_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +#endif // __clang__ + +// A function level attribute to disable AddressSanitizer instrumentation. +#if defined(__clang__) +# if __has_feature(address_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \ + __attribute__((no_sanitize_address)) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +# endif // __has_feature(address_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +#endif // __clang__ + +// A function level attribute to disable ThreadSanitizer instrumentation. +#if defined(__clang__) +# if __has_feature(thread_sanitizer) +# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \ + __attribute__((no_sanitize_thread)) +# else +# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +# endif // __has_feature(thread_sanitizer) +#else +# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +#endif // __clang__ + namespace testing { class Message; +#if defined(GTEST_TUPLE_NAMESPACE_) +// Import tuple and friends into the ::testing namespace. +// It is part of our interface, having them in ::testing allows us to change +// their types as needed. +using GTEST_TUPLE_NAMESPACE_::get; +using GTEST_TUPLE_NAMESPACE_::make_tuple; +using GTEST_TUPLE_NAMESPACE_::tuple; +using GTEST_TUPLE_NAMESPACE_::tuple_size; +using GTEST_TUPLE_NAMESPACE_::tuple_element; +#endif // defined(GTEST_TUPLE_NAMESPACE_) + namespace internal { // A secret type that Google Test users don't know about. It has no @@ -797,8 +1091,8 @@ class Secret; // expression is true. For example, you could use it to verify the // size of a static array: // -// GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES, -// content_type_names_incorrect_size); +// GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES, +// names_incorrect_size); // // or to make sure a struct is smaller than a certain size: // @@ -808,16 +1102,22 @@ class Secret; // the expression is false, most compilers will issue a warning/error // containing the name of the variable. +#if GTEST_LANG_CXX11 +# define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg) +#else // !GTEST_LANG_CXX11 template <bool> -struct CompileAssert { + struct CompileAssert { }; -#define GTEST_COMPILE_ASSERT_(expr, msg) \ +# define GTEST_COMPILE_ASSERT_(expr, msg) \ typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \ msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_ +#endif // !GTEST_LANG_CXX11 // Implementation details of GTEST_COMPILE_ASSERT_: // +// (In C++11, we simply use static_assert instead of the following) +// // - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1 // elements (and thus is invalid) when the expression is false. // @@ -864,7 +1164,22 @@ template <typename T1, typename T2> struct StaticAssertTypeEqHelper; template <typename T> -struct StaticAssertTypeEqHelper<T, T> {}; +struct StaticAssertTypeEqHelper<T, T> { + enum { value = true }; +}; + +// Same as std::is_same<>. +template <typename T, typename U> +struct IsSame { + enum { value = false }; +}; +template <typename T> +struct IsSame<T, T> { + enum { value = true }; +}; + +// Evaluates to the number of elements in 'array'. +#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0])) #if GTEST_HAS_GLOBAL_STRING typedef ::string string; @@ -913,6 +1228,11 @@ class scoped_ptr { } } + friend void swap(scoped_ptr& a, scoped_ptr& b) { + using std::swap; + swap(a.ptr_, b.ptr_); + } + private: T* ptr_; @@ -921,6 +1241,10 @@ class scoped_ptr { // Defines RE. +#if GTEST_USES_PCRE +// if used, PCRE is injected by custom/gtest-port.h +#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE + // A simple C++ wrapper for <regex.h>. It uses the POSIX Extended // Regular Expression syntax. class GTEST_API_ RE { @@ -932,11 +1256,11 @@ class GTEST_API_ RE { // Constructs an RE from a string. RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT -#if GTEST_HAS_GLOBAL_STRING +# if GTEST_HAS_GLOBAL_STRING RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING +# endif // GTEST_HAS_GLOBAL_STRING RE(const char* regex) { Init(regex); } // NOLINT ~RE(); @@ -949,7 +1273,7 @@ class GTEST_API_ RE { // PartialMatch(str, re) returns true iff regular expression re // matches a substring of str (including str itself). // - // TODO(wan@google.com): make FullMatch() and PartialMatch() work + // FIXME: make FullMatch() and PartialMatch() work // when str contains NUL characters. static bool FullMatch(const ::std::string& str, const RE& re) { return FullMatch(str.c_str(), re); @@ -958,7 +1282,7 @@ class GTEST_API_ RE { return PartialMatch(str.c_str(), re); } -#if GTEST_HAS_GLOBAL_STRING +# if GTEST_HAS_GLOBAL_STRING static bool FullMatch(const ::string& str, const RE& re) { return FullMatch(str.c_str(), re); @@ -967,7 +1291,7 @@ class GTEST_API_ RE { return PartialMatch(str.c_str(), re); } -#endif // GTEST_HAS_GLOBAL_STRING +# endif // GTEST_HAS_GLOBAL_STRING static bool FullMatch(const char* str, const RE& re); static bool PartialMatch(const char* str, const RE& re); @@ -976,25 +1300,27 @@ class GTEST_API_ RE { void Init(const char* regex); // We use a const char* instead of an std::string, as Google Test used to be - // used where std::string is not available. TODO(wan@google.com): change to + // used where std::string is not available. FIXME: change to // std::string. const char* pattern_; bool is_valid_; -#if GTEST_USES_POSIX_RE +# if GTEST_USES_POSIX_RE regex_t full_regex_; // For FullMatch(). regex_t partial_regex_; // For PartialMatch(). -#else // GTEST_USES_SIMPLE_RE +# else // GTEST_USES_SIMPLE_RE const char* full_pattern_; // For FullMatch(); -#endif +# endif GTEST_DISALLOW_ASSIGN_(RE); }; +#endif // GTEST_USES_PCRE + // Formats a source file path and a line number as they would appear // in an error message from the compiler used to compile this code. GTEST_API_ ::std::string FormatFileLocation(const char* file, int line); @@ -1036,13 +1362,18 @@ class GTEST_API_ GTestLog { GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog); }; -#define GTEST_LOG_(severity) \ +#if !defined(GTEST_LOG_) + +# define GTEST_LOG_(severity) \ ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \ __FILE__, __LINE__).GetStream() inline void LogToStderr() {} inline void FlushInfoLog() { fflush(NULL); } +#endif // !defined(GTEST_LOG_) + +#if !defined(GTEST_CHECK_) // INTERNAL IMPLEMENTATION - DO NOT USE. // // GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition @@ -1057,12 +1388,13 @@ inline void FlushInfoLog() { fflush(NULL); } // condition itself, plus additional message streamed into it, if any, // and then it aborts the program. It aborts the program irrespective of // whether it is built in the debug mode or not. -#define GTEST_CHECK_(condition) \ +# define GTEST_CHECK_(condition) \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ if (::testing::internal::IsTrue(condition)) \ ; \ else \ GTEST_LOG_(FATAL) << "Condition " #condition " failed. " +#endif // !defined(GTEST_CHECK_) // An all-mode assert to verify that the given POSIX-style function // call returns 0 (indicating success). Known limitation: this @@ -1074,6 +1406,61 @@ inline void FlushInfoLog() { fflush(NULL); } GTEST_LOG_(FATAL) << #posix_call << "failed with error " \ << gtest_error +// Adds reference to a type if it is not a reference type, +// otherwise leaves it unchanged. This is the same as +// tr1::add_reference, which is not widely available yet. +template <typename T> +struct AddReference { typedef T& type; }; // NOLINT +template <typename T> +struct AddReference<T&> { typedef T& type; }; // NOLINT + +// A handy wrapper around AddReference that works when the argument T +// depends on template parameters. +#define GTEST_ADD_REFERENCE_(T) \ + typename ::testing::internal::AddReference<T>::type + +// Transforms "T" into "const T&" according to standard reference collapsing +// rules (this is only needed as a backport for C++98 compilers that do not +// support reference collapsing). Specifically, it transforms: +// +// char ==> const char& +// const char ==> const char& +// char& ==> char& +// const char& ==> const char& +// +// Note that the non-const reference will not have "const" added. This is +// standard, and necessary so that "T" can always bind to "const T&". +template <typename T> +struct ConstRef { typedef const T& type; }; +template <typename T> +struct ConstRef<T&> { typedef T& type; }; + +// The argument T must depend on some template parameters. +#define GTEST_REFERENCE_TO_CONST_(T) \ + typename ::testing::internal::ConstRef<T>::type + +#if GTEST_HAS_STD_MOVE_ +using std::forward; +using std::move; + +template <typename T> +struct RvalueRef { + typedef T&& type; +}; +#else // GTEST_HAS_STD_MOVE_ +template <typename T> +const T& move(const T& t) { + return t; +} +template <typename T> +GTEST_ADD_REFERENCE_(T) forward(GTEST_ADD_REFERENCE_(T) t) { return t; } + +template <typename T> +struct RvalueRef { + typedef const T& type; +}; +#endif // GTEST_HAS_STD_MOVE_ + // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // // Use ImplicitCast_ as a safe version of static_cast for upcasting in @@ -1124,7 +1511,9 @@ inline To DownCast_(From* f) { // so we only accept pointers // for compile-time type checking, and has no overhead in an // optimized build at run-time, as it will be optimized away // completely. + GTEST_INTENTIONAL_CONST_COND_PUSH_() if (false) { + GTEST_INTENTIONAL_CONST_COND_POP_() const To to = NULL; ::testing::internal::ImplicitCast_<From*>(to); } @@ -1145,6 +1534,11 @@ template <class Derived, class Base> Derived* CheckedDowncastToActualType(Base* base) { #if GTEST_HAS_RTTI GTEST_CHECK_(typeid(*base) == typeid(Derived)); +#endif + +#if GTEST_HAS_DOWNCAST_ + return ::down_cast<Derived*>(base); +#elif GTEST_HAS_RTTI return dynamic_cast<Derived*>(base); // NOLINT #else return static_cast<Derived*>(base); // Poor man's downcast. @@ -1165,26 +1559,34 @@ GTEST_API_ void CaptureStderr(); GTEST_API_ std::string GetCapturedStderr(); #endif // GTEST_HAS_STREAM_REDIRECTION +// Returns the size (in bytes) of a file. +GTEST_API_ size_t GetFileSize(FILE* file); +// Reads the entire content of a file as a string. +GTEST_API_ std::string ReadEntireFile(FILE* file); -#if GTEST_HAS_DEATH_TEST +// All command line arguments. +GTEST_API_ std::vector<std::string> GetArgvs(); -const ::std::vector<testing::internal::string>& GetInjectableArgvs(); -void SetInjectableArgvs(const ::std::vector<testing::internal::string>* - new_argvs); +#if GTEST_HAS_DEATH_TEST -// A copy of all command line arguments. Set by InitGoogleTest(). -extern ::std::vector<testing::internal::string> g_argvs; +std::vector<std::string> GetInjectableArgvs(); +// Deprecated: pass the args vector by value instead. +void SetInjectableArgvs(const std::vector<std::string>* new_argvs); +void SetInjectableArgvs(const std::vector<std::string>& new_argvs); +#if GTEST_HAS_GLOBAL_STRING +void SetInjectableArgvs(const std::vector< ::string>& new_argvs); +#endif // GTEST_HAS_GLOBAL_STRING +void ClearInjectableArgvs(); #endif // GTEST_HAS_DEATH_TEST // Defines synchronization primitives. - -#if GTEST_HAS_PTHREAD - -// Sleeps for (roughly) n milli-seconds. This function is only for -// testing Google Test's own constructs. Don't use it in user tests, -// either directly or indirectly. +#if GTEST_IS_THREADSAFE +# if GTEST_HAS_PTHREAD +// Sleeps for (roughly) n milliseconds. This function is only for testing +// Google Test's own constructs. Don't use it in user tests, either +// directly or indirectly. inline void SleepMilliseconds(int n) { const timespec time = { 0, // 0 seconds. @@ -1192,7 +1594,13 @@ inline void SleepMilliseconds(int n) { }; nanosleep(&time, NULL); } +# endif // GTEST_HAS_PTHREAD + +# if GTEST_HAS_NOTIFICATION_ +// Notification has already been imported into the namespace. +// Nothing to do here. +# elif GTEST_HAS_PTHREAD // Allows a controller thread to pause execution of newly created // threads until notified. Instances of this class must be created // and destroyed in the controller thread. @@ -1236,6 +1644,62 @@ class Notification { GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); }; +# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT + +GTEST_API_ void SleepMilliseconds(int n); + +// Provides leak-safe Windows kernel handle ownership. +// Used in death tests and in threading support. +class GTEST_API_ AutoHandle { + public: + // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to + // avoid including <windows.h> in this header file. Including <windows.h> is + // undesirable because it defines a lot of symbols and macros that tend to + // conflict with client code. This assumption is verified by + // WindowsTypesTest.HANDLEIsVoidStar. + typedef void* Handle; + AutoHandle(); + explicit AutoHandle(Handle handle); + + ~AutoHandle(); + + Handle Get() const; + void Reset(); + void Reset(Handle handle); + + private: + // Returns true iff the handle is a valid handle object that can be closed. + bool IsCloseable() const; + + Handle handle_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); +}; + +// Allows a controller thread to pause execution of newly created +// threads until notified. Instances of this class must be created +// and destroyed in the controller thread. +// +// This class is only for testing Google Test's own constructs. Do not +// use it in user tests, either directly or indirectly. +class GTEST_API_ Notification { + public: + Notification(); + void Notify(); + void WaitForNotification(); + + private: + AutoHandle event_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); +}; +# endif // GTEST_HAS_NOTIFICATION_ + +// On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD +// defined, but we don't want to use MinGW's pthreads implementation, which +// has conformance problems with some versions of the POSIX standard. +# if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW + // As a C-function, ThreadFuncWithCLinkage cannot be templated itself. // Consequently, it cannot select a correct instantiation of ThreadWithParam // in order to call its Run(). Introducing ThreadWithParamBase as a @@ -1273,10 +1737,9 @@ extern "C" inline void* ThreadFuncWithCLinkage(void* thread) { template <typename T> class ThreadWithParam : public ThreadWithParamBase { public: - typedef void (*UserThreadFunc)(T); + typedef void UserThreadFunc(T); - ThreadWithParam( - UserThreadFunc func, T param, Notification* thread_can_start) + ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) : func_(func), param_(param), thread_can_start_(thread_can_start), @@ -1303,7 +1766,7 @@ class ThreadWithParam : public ThreadWithParamBase { } private: - const UserThreadFunc func_; // User-supplied thread function. + UserThreadFunc* const func_; // User-supplied thread function. const T param_; // User-supplied parameter to the thread function. // When non-NULL, used to block execution until the controller thread // notifies. @@ -1313,26 +1776,293 @@ class ThreadWithParam : public ThreadWithParamBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); }; +# endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD || + // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ -// MutexBase and Mutex implement mutex on pthreads-based platforms. They -// are used in conjunction with class MutexLock: +# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +// Mutex and ThreadLocal have already been imported into the namespace. +// Nothing to do here. + +# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT + +// Mutex implements mutex on Windows platforms. It is used in conjunction +// with class MutexLock: // // Mutex mutex; // ... -// MutexLock lock(&mutex); // Acquires the mutex and releases it at the end -// // of the current scope. -// -// MutexBase implements behavior for both statically and dynamically -// allocated mutexes. Do not use MutexBase directly. Instead, write -// the following to define a static mutex: +// MutexLock lock(&mutex); // Acquires the mutex and releases it at the +// // end of the current scope. // +// A static Mutex *must* be defined or declared using one of the following +// macros: // GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex); +// GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex); // -// You can forward declare a static mutex like this: +// (A non-static Mutex is defined/declared in the usual way). +class GTEST_API_ Mutex { + public: + enum MutexType { kStatic = 0, kDynamic = 1 }; + // We rely on kStaticMutex being 0 as it is to what the linker initializes + // type_ in static mutexes. critical_section_ will be initialized lazily + // in ThreadSafeLazyInit(). + enum StaticConstructorSelector { kStaticMutex = 0 }; + + // This constructor intentionally does nothing. It relies on type_ being + // statically initialized to 0 (effectively setting it to kStatic) and on + // ThreadSafeLazyInit() to lazily initialize the rest of the members. + explicit Mutex(StaticConstructorSelector /*dummy*/) {} + + Mutex(); + ~Mutex(); + + void Lock(); + + void Unlock(); + + // Does nothing if the current thread holds the mutex. Otherwise, crashes + // with high probability. + void AssertHeld(); + + private: + // Initializes owner_thread_id_ and critical_section_ in static mutexes. + void ThreadSafeLazyInit(); + + // Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503, + // we assume that 0 is an invalid value for thread IDs. + unsigned int owner_thread_id_; + + // For static mutexes, we rely on these members being initialized to zeros + // by the linker. + MutexType type_; + long critical_section_init_phase_; // NOLINT + GTEST_CRITICAL_SECTION* critical_section_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); +}; + +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::Mutex mutex + +# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ + ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex) + +// We cannot name this class MutexLock because the ctor declaration would +// conflict with a macro named MutexLock, which is defined on some +// platforms. That macro is used as a defensive measure to prevent against +// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than +// "MutexLock l(&mu)". Hence the typedef trick below. +class GTestMutexLock { + public: + explicit GTestMutexLock(Mutex* mutex) + : mutex_(mutex) { mutex_->Lock(); } + + ~GTestMutexLock() { mutex_->Unlock(); } + + private: + Mutex* const mutex_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock); +}; + +typedef GTestMutexLock MutexLock; + +// Base class for ValueHolder<T>. Allows a caller to hold and delete a value +// without knowing its type. +class ThreadLocalValueHolderBase { + public: + virtual ~ThreadLocalValueHolderBase() {} +}; + +// Provides a way for a thread to send notifications to a ThreadLocal +// regardless of its parameter type. +class ThreadLocalBase { + public: + // Creates a new ValueHolder<T> object holding a default value passed to + // this ThreadLocal<T>'s constructor and returns it. It is the caller's + // responsibility not to call this when the ThreadLocal<T> instance already + // has a value on the current thread. + virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0; + + protected: + ThreadLocalBase() {} + virtual ~ThreadLocalBase() {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase); +}; + +// Maps a thread to a set of ThreadLocals that have values instantiated on that +// thread and notifies them when the thread exits. A ThreadLocal instance is +// expected to persist until all threads it has values on have terminated. +class GTEST_API_ ThreadLocalRegistry { + public: + // Registers thread_local_instance as having value on the current thread. + // Returns a value that can be used to identify the thread from other threads. + static ThreadLocalValueHolderBase* GetValueOnCurrentThread( + const ThreadLocalBase* thread_local_instance); + + // Invoked when a ThreadLocal instance is destroyed. + static void OnThreadLocalDestroyed( + const ThreadLocalBase* thread_local_instance); +}; + +class GTEST_API_ ThreadWithParamBase { + public: + void Join(); + + protected: + class Runnable { + public: + virtual ~Runnable() {} + virtual void Run() = 0; + }; + + ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start); + virtual ~ThreadWithParamBase(); + + private: + AutoHandle thread_; +}; + +// Helper class for testing Google Test's multi-threading constructs. +template <typename T> +class ThreadWithParam : public ThreadWithParamBase { + public: + typedef void UserThreadFunc(T); + + ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) + : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) { + } + virtual ~ThreadWithParam() {} + + private: + class RunnableImpl : public Runnable { + public: + RunnableImpl(UserThreadFunc* func, T param) + : func_(func), + param_(param) { + } + virtual ~RunnableImpl() {} + virtual void Run() { + func_(param_); + } + + private: + UserThreadFunc* const func_; + const T param_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl); + }; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); +}; + +// Implements thread-local storage on Windows systems. // -// GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex); +// // Thread 1 +// ThreadLocal<int> tl(100); // 100 is the default value for each thread. +// +// // Thread 2 +// tl.set(150); // Changes the value for thread 2 only. +// EXPECT_EQ(150, tl.get()); +// +// // Thread 1 +// EXPECT_EQ(100, tl.get()); // In thread 1, tl has the original value. +// tl.set(200); +// EXPECT_EQ(200, tl.get()); +// +// The template type argument T must have a public copy constructor. +// In addition, the default ThreadLocal constructor requires T to have +// a public default constructor. // -// To create a dynamic mutex, just define an object of type Mutex. +// The users of a TheadLocal instance have to make sure that all but one +// threads (including the main one) using that instance have exited before +// destroying it. Otherwise, the per-thread objects managed for them by the +// ThreadLocal instance are not guaranteed to be destroyed on all platforms. +// +// Google Test only uses global ThreadLocal objects. That means they +// will die after main() has returned. Therefore, no per-thread +// object managed by Google Test will be leaked as long as all threads +// using Google Test have exited when main() returns. +template <typename T> +class ThreadLocal : public ThreadLocalBase { + public: + ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {} + explicit ThreadLocal(const T& value) + : default_factory_(new InstanceValueHolderFactory(value)) {} + + ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); } + + T* pointer() { return GetOrCreateValue(); } + const T* pointer() const { return GetOrCreateValue(); } + const T& get() const { return *pointer(); } + void set(const T& value) { *pointer() = value; } + + private: + // Holds a value of T. Can be deleted via its base class without the caller + // knowing the type of T. + class ValueHolder : public ThreadLocalValueHolderBase { + public: + ValueHolder() : value_() {} + explicit ValueHolder(const T& value) : value_(value) {} + + T* pointer() { return &value_; } + + private: + T value_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); + }; + + + T* GetOrCreateValue() const { + return static_cast<ValueHolder*>( + ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer(); + } + + virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const { + return default_factory_->MakeNewHolder(); + } + + class ValueHolderFactory { + public: + ValueHolderFactory() {} + virtual ~ValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const = 0; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory); + }; + + class DefaultValueHolderFactory : public ValueHolderFactory { + public: + DefaultValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory); + }; + + class InstanceValueHolderFactory : public ValueHolderFactory { + public: + explicit InstanceValueHolderFactory(const T& value) : value_(value) {} + virtual ValueHolder* MakeNewHolder() const { + return new ValueHolder(value_); + } + + private: + const T value_; // The value for each thread. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory); + }; + + scoped_ptr<ValueHolderFactory> default_factory_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); +}; + +# elif GTEST_HAS_PTHREAD + +// MutexBase and Mutex implement mutex on pthreads-based platforms. class MutexBase { public: // Acquires this mutex. @@ -1377,8 +2107,8 @@ class MutexBase { }; // Forward-declares a static mutex. -# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ - extern ::testing::internal::MutexBase mutex +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::MutexBase mutex // Defines and statically (i.e. at link time) initializes a static mutex. // The initialization list here does not explicitly initialize each field, @@ -1386,8 +2116,8 @@ class MutexBase { // particular, the owner_ field (a pthread_t) is not explicitly initialized. // This allows initialization to work whether pthread_t is a scalar or struct. // The flag -Wmissing-field-initializers must not be specified for this to work. -# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ - ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false } +#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ + ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0} // The Mutex class can only be used for mutexes created at runtime. It // shares its API with MutexBase otherwise. @@ -1405,9 +2135,11 @@ class Mutex : public MutexBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); }; -// We cannot name this class MutexLock as the ctor declaration would +// We cannot name this class MutexLock because the ctor declaration would // conflict with a macro named MutexLock, which is defined on some -// platforms. Hence the typedef trick below. +// platforms. That macro is used as a defensive measure to prevent against +// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than +// "MutexLock l(&mu)". Hence the typedef trick below. class GTestMutexLock { public: explicit GTestMutexLock(MutexBase* mutex) @@ -1441,41 +2173,14 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) { } // Implements thread-local storage on pthreads-based systems. -// -// // Thread 1 -// ThreadLocal<int> tl(100); // 100 is the default value for each thread. -// -// // Thread 2 -// tl.set(150); // Changes the value for thread 2 only. -// EXPECT_EQ(150, tl.get()); -// -// // Thread 1 -// EXPECT_EQ(100, tl.get()); // In thread 1, tl has the original value. -// tl.set(200); -// EXPECT_EQ(200, tl.get()); -// -// The template type argument T must have a public copy constructor. -// In addition, the default ThreadLocal constructor requires T to have -// a public default constructor. -// -// An object managed for a thread by a ThreadLocal instance is deleted -// when the thread exits. Or, if the ThreadLocal instance dies in -// that thread, when the ThreadLocal dies. It's the user's -// responsibility to ensure that all other threads using a ThreadLocal -// have exited when it dies, or the per-thread objects for those -// threads will not be deleted. -// -// Google Test only uses global ThreadLocal objects. That means they -// will die after main() has returned. Therefore, no per-thread -// object managed by Google Test will be leaked as long as all threads -// using Google Test have exited when main() returns. template <typename T> -class ThreadLocal { +class GTEST_API_ ThreadLocal { public: - ThreadLocal() : key_(CreateKey()), - default_() {} - explicit ThreadLocal(const T& value) : key_(CreateKey()), - default_(value) {} + ThreadLocal() + : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {} + explicit ThreadLocal(const T& value) + : key_(CreateKey()), + default_factory_(new InstanceValueHolderFactory(value)) {} ~ThreadLocal() { // Destroys the managed object for the current thread, if any. @@ -1495,6 +2200,7 @@ class ThreadLocal { // Holds a value of type T. class ValueHolder : public ThreadLocalValueHolderBase { public: + ValueHolder() : value_() {} explicit ValueHolder(const T& value) : value_(value) {} T* pointer() { return &value_; } @@ -1520,22 +2226,54 @@ class ThreadLocal { return CheckedDowncastToActualType<ValueHolder>(holder)->pointer(); } - ValueHolder* const new_holder = new ValueHolder(default_); + ValueHolder* const new_holder = default_factory_->MakeNewHolder(); ThreadLocalValueHolderBase* const holder_base = new_holder; GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base)); return new_holder->pointer(); } + class ValueHolderFactory { + public: + ValueHolderFactory() {} + virtual ~ValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const = 0; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory); + }; + + class DefaultValueHolderFactory : public ValueHolderFactory { + public: + DefaultValueHolderFactory() {} + virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory); + }; + + class InstanceValueHolderFactory : public ValueHolderFactory { + public: + explicit InstanceValueHolderFactory(const T& value) : value_(value) {} + virtual ValueHolder* MakeNewHolder() const { + return new ValueHolder(value_); + } + + private: + const T value_; // The value for each thread. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory); + }; + // A key pthreads uses for looking up per-thread values. const pthread_key_t key_; - const T default_; // The default value for each thread. + scoped_ptr<ValueHolderFactory> default_factory_; GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); }; -# define GTEST_IS_THREADSAFE 1 +# endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ -#else // GTEST_HAS_PTHREAD +#else // GTEST_IS_THREADSAFE // A dummy implementation of synchronization primitives (mutex, lock, // and thread-local variable). Necessary for compiling Google Test where @@ -1555,6 +2293,11 @@ class Mutex { # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex +// We cannot name this class MutexLock because the ctor declaration would +// conflict with a macro named MutexLock, which is defined on some +// platforms. That macro is used as a defensive measure to prevent against +// inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than +// "MutexLock l(&mu)". Hence the typedef trick below. class GTestMutexLock { public: explicit GTestMutexLock(Mutex*) {} // NOLINT @@ -1563,7 +2306,7 @@ class GTestMutexLock { typedef GTestMutexLock MutexLock; template <typename T> -class ThreadLocal { +class GTEST_API_ ThreadLocal { public: ThreadLocal() : value_() {} explicit ThreadLocal(const T& value) : value_(value) {} @@ -1575,11 +2318,7 @@ class ThreadLocal { T value_; }; -// The above synchronization primitives have dummy implementations. -// Therefore Google Test is not thread-safe. -# define GTEST_IS_THREADSAFE 0 - -#endif // GTEST_HAS_PTHREAD +#endif // GTEST_IS_THREADSAFE // Returns the number of threads running in the process, or 0 to indicate that // we cannot detect it. @@ -1618,6 +2357,13 @@ template <bool bool_value> const bool bool_constant<bool_value>::value; typedef bool_constant<false> false_type; typedef bool_constant<true> true_type; +template <typename T, typename U> +struct is_same : public false_type {}; + +template <typename T> +struct is_same<T, T> : public true_type {}; + + template <typename T> struct is_pointer : public false_type {}; @@ -1629,6 +2375,7 @@ struct IteratorTraits { typedef typename Iterator::value_type value_type; }; + template <typename T> struct IteratorTraits<T*> { typedef T value_type; @@ -1690,6 +2437,13 @@ inline char ToUpper(char ch) { return static_cast<char>(toupper(static_cast<unsigned char>(ch))); } +inline std::string StripTrailingSpaces(std::string str) { + std::string::iterator it = str.end(); + while (it != str.begin() && IsSpace(*--it)) + it = str.erase(it); + return str; +} + // The testing::internal::posix namespace holds wrappers for common // POSIX functions. These wrappers hide the differences between // Windows/MSVC and POSIX systems. Since some compilers define these @@ -1723,7 +2477,7 @@ inline char* StrDup(const char* src) { return _strdup(src); } # endif // __BORLANDC__ # if GTEST_OS_WINDOWS_MOBILE -inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); } +inline int FileNo(FILE* file) { return static_cast<int>(_fileno(file)); } // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this // time and thus not defined there. # else @@ -1753,11 +2507,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } // Functions deprecated by MSVC 8.0. -#ifdef _MSC_VER -// Temporarily disable warning 4996 (deprecated function). -# pragma warning(push) -# pragma warning(disable:4996) -#endif +GTEST_DISABLE_MSC_DEPRECATED_PUSH_() inline const char* StrNCpy(char* dest, const char* src, size_t n) { return strncpy(dest, src, n); @@ -1767,7 +2517,7 @@ inline const char* StrNCpy(char* dest, const char* src, size_t n) { // StrError() aren't needed on Windows CE at this time and thus not // defined there. -#if !GTEST_OS_WINDOWS_MOBILE +#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT inline int ChDir(const char* dir) { return chdir(dir); } #endif inline FILE* FOpen(const char* path, const char* mode) { @@ -1791,8 +2541,9 @@ inline int Close(int fd) { return close(fd); } inline const char* StrError(int errnum) { return strerror(errnum); } #endif inline const char* GetEnv(const char* name) { -#if GTEST_OS_WINDOWS_MOBILE +#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT // We are on Windows CE, which has no environment variables. + static_cast<void>(name); // To prevent 'unused argument' warning. return NULL; #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9) // Environment variables which we programmatically clear will be set to the @@ -1804,9 +2555,7 @@ inline const char* GetEnv(const char* name) { #endif } -#ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. -#endif +GTEST_DISABLE_MSC_DEPRECATED_POP_() #if GTEST_OS_WINDOWS_MOBILE // Windows CE has no C library. The abort() function is used in @@ -1907,31 +2656,44 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds. // Utilities for command line flags and environment variables. // Macro for referencing flags. -#define GTEST_FLAG(name) FLAGS_gtest_##name +#if !defined(GTEST_FLAG) +# define GTEST_FLAG(name) FLAGS_gtest_##name +#endif // !defined(GTEST_FLAG) + +#if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_) +# define GTEST_USE_OWN_FLAGFILE_FLAG_ 1 +#endif // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_) + +#if !defined(GTEST_DECLARE_bool_) +# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver // Macros for declaring flags. -#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) -#define GTEST_DECLARE_int32_(name) \ +# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) +# define GTEST_DECLARE_int32_(name) \ GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name) -#define GTEST_DECLARE_string_(name) \ +# define GTEST_DECLARE_string_(name) \ GTEST_API_ extern ::std::string GTEST_FLAG(name) // Macros for defining flags. -#define GTEST_DEFINE_bool_(name, default_val, doc) \ +# define GTEST_DEFINE_bool_(name, default_val, doc) \ GTEST_API_ bool GTEST_FLAG(name) = (default_val) -#define GTEST_DEFINE_int32_(name, default_val, doc) \ +# define GTEST_DEFINE_int32_(name, default_val, doc) \ GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val) -#define GTEST_DEFINE_string_(name, default_val, doc) \ +# define GTEST_DEFINE_string_(name, default_val, doc) \ GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val) +#endif // !defined(GTEST_DECLARE_bool_) + // Thread annotations -#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) -#define GTEST_LOCK_EXCLUDED_(locks) +#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) +# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) +# define GTEST_LOCK_EXCLUDED_(locks) +#endif // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) // Parses 'str' for a 32-bit signed integer. If successful, writes the result // to *value and returns true; otherwise leaves *value unchanged and returns // false. -// TODO(chandlerc): Find a better way to refactor flag and environment parsing +// FIXME: Find a better way to refactor flag and environment parsing // out of both gtest-port.cc and gtest.cc to avoid exporting this utility // function. bool ParseInt32(const Message& src_text, const char* str, Int32* value); @@ -1940,6 +2702,7 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value); // corresponding to the given Google Test flag. bool BoolFromGTestEnv(const char* flag, bool default_val); GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val); +std::string OutputFlagAlsoCheckEnvVar(); const char* StringFromGTestEnv(const char* flag, const char* default_val); } // namespace internal diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-string.h b/src/test/fmw/gtest/include/gtest/internal/gtest-string.h index 97f1a7fdd2c..4c9b6262c3c 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-string.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-string.h @@ -27,17 +27,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) // // This header file declares the String class and functions used internally by // Google Test. They are subject to change without notice. They should not used // by code external to Google Test. // -// This header file is #included by <gtest/internal/gtest-internal.h>. +// This header file is #included by gtest-internal.h. // It should not be #included by other files. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h b/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h index 7b3dfc312dc..78a3a6a01fa 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h @@ -30,11 +30,12 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) + // Implements a subset of TR1 tuple needed by Google Test and Google Mock. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ @@ -42,7 +43,7 @@ // The compiler used in Symbian has a bug that prevents us from declaring the // tuple template as a friend (it complains that tuple is redefined). This -// hack bypasses the bug by declaring the members that should otherwise be +// bypasses the bug by declaring the members that should otherwise be // private as public. // Sun Studio versions < 12 also have the above bug. #if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590) @@ -53,6 +54,14 @@ private: #endif +// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict +// with our own definitions. Therefore using our own tuple does not work on +// those compilers. +#if defined(_MSC_VER) && _MSC_VER >= 1600 /* 1600 is Visual Studio 2010 */ +# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \ +GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers." +#endif + // GTEST_n_TUPLE_(T) is the type of an n-tuple. #define GTEST_0_TUPLE_(T) tuple<> #define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \ diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump b/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump index c7d9e039b1f..bb626e049f0 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump @@ -29,11 +29,12 @@ $$ This meta comment fixes auto-indentation in Emacs. }} // 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. -// -// Author: wan@google.com (Zhanyong Wan) + // Implements a subset of TR1 tuple needed by Google Test and Google Mock. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ @@ -41,7 +42,7 @@ $$ This meta comment fixes auto-indentation in Emacs. }} // The compiler used in Symbian has a bug that prevents us from declaring the // tuple template as a friend (it complains that tuple is redefined). This -// hack bypasses the bug by declaring the members that should otherwise be +// bypasses the bug by declaring the members that should otherwise be // private as public. // Sun Studio versions < 12 also have the above bug. #if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590) @@ -52,6 +53,14 @@ $$ This meta comment fixes auto-indentation in Emacs. }} private: #endif +// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict +// with our own definitions. Therefore using our own tuple does not work on +// those compilers. +#if defined(_MSC_VER) && _MSC_VER >= 1600 /* 1600 is Visual Studio 2010 */ +# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \ +GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers." +#endif + $range i 0..n-1 $range j 0..n diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h b/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h index e46f7cfcb48..28e41124536 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h @@ -30,8 +30,7 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) + // Type utilities needed for implementing typed and type-parameterized // tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! @@ -41,6 +40,8 @@ // Please contact googletestframework@googlegroups.com if you need // more. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ @@ -57,6 +58,22 @@ namespace testing { namespace internal { +// Canonicalizes a given name with respect to the Standard C++ Library. +// This handles removing the inline namespace within `std` that is +// used by various standard libraries (e.g., `std::__1`). Names outside +// of namespace std are returned unmodified. +inline std::string CanonicalizeForStdLibVersioning(std::string s) { + static const char prefix[] = "std::__"; + if (s.compare(0, strlen(prefix), prefix) == 0) { + std::string::size_type end = s.find("::", strlen(prefix)); + if (end != s.npos) { + // Erase everything between the initial `std` and the second `::`. + s.erase(strlen("std"), end - strlen("std")); + } + } + return s; +} + // GetTypeName<T>() returns a human-readable name of type T. // NB: This function is also used in Google Mock, so don't move it inside of // the typed-test-only section below. @@ -75,7 +92,7 @@ std::string GetTypeName() { char* const readable_name = __cxa_demangle(name, 0, 0, &status); const std::string name_str(status == 0 ? readable_name : name); free(readable_name); - return name_str; + return CanonicalizeForStdLibVersioning(name_str); # else return name; # endif // GTEST_HAS_CXXABI_H_ || __HP_aCC diff --git a/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump b/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump index 251fdf025b2..0001a5d39df 100644 --- a/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump +++ b/src/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump @@ -28,8 +28,7 @@ $var n = 50 $$ Maximum length of type lists we want to support. // 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. -// -// Author: wan@google.com (Zhanyong Wan) + // Type utilities needed for implementing typed and type-parameterized // tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! @@ -39,6 +38,8 @@ $var n = 50 $$ Maximum length of type lists we want to support. // Please contact googletestframework@googlegroups.com if you need // more. +// GOOGLETEST_CM0001 DO NOT DELETE + #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ @@ -55,6 +56,22 @@ $var n = 50 $$ Maximum length of type lists we want to support. namespace testing { namespace internal { +// Canonicalizes a given name with respect to the Standard C++ Library. +// This handles removing the inline namespace within `std` that is +// used by various standard libraries (e.g., `std::__1`). Names outside +// of namespace std are returned unmodified. +inline std::string CanonicalizeForStdLibVersioning(std::string s) { + static const char prefix[] = "std::__"; + if (s.compare(0, strlen(prefix), prefix) == 0) { + std::string::size_type end = s.find("::", strlen(prefix)); + if (end != s.npos) { + // Erase everything between the initial `std` and the second `::`. + s.erase(strlen("std"), end - strlen("std")); + } + } + return s; +} + // GetTypeName<T>() returns a human-readable name of type T. // NB: This function is also used in Google Mock, so don't move it inside of // the typed-test-only section below. @@ -73,7 +90,7 @@ std::string GetTypeName() { char* const readable_name = __cxa_demangle(name, 0, 0, &status); const std::string name_str(status == 0 ? readable_name : name); free(readable_name); - return name_str; + return CanonicalizeForStdLibVersioning(name_str); # else return name; # endif // GTEST_HAS_CXXABI_H_ || __HP_aCC diff --git a/src/test/fmw/gtest/src/gtest-all.cc b/src/test/fmw/gtest/src/gtest-all.cc index 0a9cee52233..b217a18006b 100644 --- a/src/test/fmw/gtest/src/gtest-all.cc +++ b/src/test/fmw/gtest/src/gtest-all.cc @@ -26,10 +26,9 @@ // 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. + // -// Author: mheule@google.com (Markus Heule) -// -// Google C++ Testing Framework (Google Test) +// Google C++ Testing and Mocking Framework (Google Test) // // Sometimes it's desirable to build Google Test by compiling a single file. // This file serves this purpose. diff --git a/src/test/fmw/gtest/src/gtest-death-test.cc b/src/test/fmw/gtest/src/gtest-death-test.cc index a6023fce4fa..09083551612 100644 --- a/src/test/fmw/gtest/src/gtest-death-test.cc +++ b/src/test/fmw/gtest/src/gtest-death-test.cc @@ -26,13 +26,13 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) + // // This file implements death tests. #include "gtest/gtest-death-test.h" #include "gtest/internal/gtest-port.h" +#include "gtest/internal/custom/gtest.h" #if GTEST_HAS_DEATH_TEST @@ -61,26 +61,30 @@ # include <spawn.h> # endif // GTEST_OS_QNX +# if GTEST_OS_FUCHSIA +# include <lib/fdio/io.h> +# include <lib/fdio/spawn.h> +# include <zircon/processargs.h> +# include <zircon/syscalls.h> +# include <zircon/syscalls/port.h> +# endif // GTEST_OS_FUCHSIA + #endif // GTEST_HAS_DEATH_TEST #include "gtest/gtest-message.h" #include "gtest/internal/gtest-string.h" - -// Indicates that this translation unit is part of Google Test's -// implementation. It must come before gtest-internal-inl.h is -// included, or there will be a compiler error. This trick is to -// prevent a user from accidentally including gtest-internal-inl.h in -// his code. -#define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" -#undef GTEST_IMPLEMENTATION_ namespace testing { // Constants. // The default death test style. -static const char kDefaultDeathTestStyle[] = "fast"; +// +// This is defined in internal/gtest-port.h as "fast", but can be overridden by +// a definition in internal/custom/gtest-port.h. The recommended value, which is +// used internally at Google, is "threadsafe". +static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE; GTEST_DEFINE_string_( death_test_style, @@ -120,7 +124,9 @@ namespace internal { // Valid only for fast death tests. Indicates the code is running in the // child process of a fast style death test. +# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA static bool g_in_fast_death_test_child = false; +# endif // Returns a Boolean value indicating whether the caller is currently // executing in the context of the death test child process. Tools such as @@ -128,10 +134,10 @@ static bool g_in_fast_death_test_child = false; // tests. IMPORTANT: This is an internal utility. Using it may break the // implementation of death tests. User code MUST NOT use it. bool InDeathTestChild() { -# if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA - // On Windows, death tests are thread-safe regardless of the value of the - // death_test_style flag. + // On Windows and Fuchsia, death tests are thread-safe regardless of the value + // of the death_test_style flag. return !GTEST_FLAG(internal_run_death_test).empty(); # else @@ -151,7 +157,7 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) { // ExitedWithCode function-call operator. bool ExitedWithCode::operator()(int exit_status) const { -# if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA return exit_status == exit_code_; @@ -159,19 +165,27 @@ bool ExitedWithCode::operator()(int exit_status) const { return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; -# endif // GTEST_OS_WINDOWS +# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA } -# if !GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // KilledBySignal constructor. KilledBySignal::KilledBySignal(int signum) : signum_(signum) { } // KilledBySignal function-call operator. bool KilledBySignal::operator()(int exit_status) const { +# if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) + { + bool result; + if (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) { + return result; + } + } +# endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_; } -# endif // !GTEST_OS_WINDOWS +# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA namespace internal { @@ -182,7 +196,7 @@ namespace internal { static std::string ExitSummary(int exit_code) { Message m; -# if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA m << "Exited with exit status " << exit_code; @@ -198,7 +212,7 @@ static std::string ExitSummary(int exit_code) { m << " (core dumped)"; } # endif -# endif // GTEST_OS_WINDOWS +# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA return m.GetString(); } @@ -209,7 +223,7 @@ bool ExitedUnsuccessfully(int exit_status) { return !ExitedWithCode(0)(exit_status); } -# if !GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Generates a textual failure message when a death test finds more than // one thread running, or cannot determine the number of threads, prior // to executing the given statement. It is the responsibility of the @@ -218,13 +232,19 @@ static std::string DeathTestThreadWarning(size_t thread_count) { Message msg; msg << "Death tests use fork(), which is unsafe particularly" << " in a threaded context. For this test, " << GTEST_NAME_ << " "; - if (thread_count == 0) + if (thread_count == 0) { msg << "couldn't detect the number of threads."; - else + } else { msg << "detected " << thread_count << " threads."; + } + msg << " See " + "https://github.com/google/googletest/blob/master/googletest/docs/" + "advanced.md#death-tests-and-threads" + << " for more explanation and suggested solutions, especially if" + << " this is the last message you see before your test times out."; return msg.GetString(); } -# endif // !GTEST_OS_WINDOWS +# endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Flag characters for reporting a death test that did not die. static const char kDeathTestLived = 'L'; @@ -232,6 +252,13 @@ static const char kDeathTestReturned = 'R'; static const char kDeathTestThrew = 'T'; static const char kDeathTestInternalError = 'I'; +#if GTEST_OS_FUCHSIA + +// File descriptor used for the pipe in the child process. +static const int kFuchsiaReadPipeFd = 3; + +#endif + // An enumeration describing all of the possible ways that a death test can // conclude. DIED means that the process died while executing the test // code; LIVED means that process lived beyond the end of the test code; @@ -239,7 +266,7 @@ static const char kDeathTestInternalError = 'I'; // statement, which is not allowed; THREW means that the test statement // returned control by throwing an exception. IN_PROGRESS means the test // has not yet concluded. -// TODO(vladl@google.com): Unify names and possibly values for +// FIXME: Unify names and possibly values for // AbortReason, DeathTestOutcome, and flag characters above. enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; @@ -248,7 +275,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; // message is propagated back to the parent process. Otherwise, the // message is simply printed to stderr. In either case, the program // then exits with status 1. -void DeathTestAbort(const std::string& message) { +static void DeathTestAbort(const std::string& message) { // On a POSIX system, this function may be called from a threadsafe-style // death test child process, which operates on a very small stack. Use // the heap for any additional non-minuscule memory requirements. @@ -552,7 +579,12 @@ bool DeathTestImpl::Passed(bool status_ok) { break; case DIED: if (status_ok) { +# if GTEST_USES_PCRE + // PCRE regexes support embedded NULs. + const bool matched = RE::PartialMatch(error_message, *regex()); +# else const bool matched = RE::PartialMatch(error_message.c_str(), *regex()); +# endif // GTEST_USES_PCRE if (matched) { success = true; } else { @@ -768,7 +800,200 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() { set_spawned(true); return OVERSEE_TEST; } -# else // We are not on Windows. + +# elif GTEST_OS_FUCHSIA + +class FuchsiaDeathTest : public DeathTestImpl { + public: + FuchsiaDeathTest(const char* a_statement, + const RE* a_regex, + const char* file, + int line) + : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {} + virtual ~FuchsiaDeathTest() { + zx_status_t status = zx_handle_close(child_process_); + GTEST_DEATH_TEST_CHECK_(status == ZX_OK); + status = zx_handle_close(port_); + GTEST_DEATH_TEST_CHECK_(status == ZX_OK); + } + + // All of these virtual functions are inherited from DeathTest. + virtual int Wait(); + virtual TestRole AssumeRole(); + + private: + // The name of the file in which the death test is located. + const char* const file_; + // The line number on which the death test is located. + const int line_; + + zx_handle_t child_process_ = ZX_HANDLE_INVALID; + zx_handle_t port_ = ZX_HANDLE_INVALID; +}; + +// Utility class for accumulating command-line arguments. +class Arguments { + public: + Arguments() { + args_.push_back(NULL); + } + + ~Arguments() { + for (std::vector<char*>::iterator i = args_.begin(); i != args_.end(); + ++i) { + free(*i); + } + } + void AddArgument(const char* argument) { + args_.insert(args_.end() - 1, posix::StrDup(argument)); + } + + template <typename Str> + void AddArguments(const ::std::vector<Str>& arguments) { + for (typename ::std::vector<Str>::const_iterator i = arguments.begin(); + i != arguments.end(); + ++i) { + args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); + } + } + char* const* Argv() { + return &args_[0]; + } + + int size() { + return args_.size() - 1; + } + + private: + std::vector<char*> args_; +}; + +// Waits for the child in a death test to exit, returning its exit +// status, or 0 if no child process exists. As a side effect, sets the +// outcome data member. +int FuchsiaDeathTest::Wait() { + if (!spawned()) + return 0; + + // Register to wait for the child process to terminate. + zx_status_t status_zx; + status_zx = zx_object_wait_async(child_process_, + port_, + 0 /* key */, + ZX_PROCESS_TERMINATED, + ZX_WAIT_ASYNC_ONCE); + GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); + + // Wait for it to terminate, or an exception to be received. + zx_port_packet_t packet; + status_zx = zx_port_wait(port_, ZX_TIME_INFINITE, &packet); + GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); + + if (ZX_PKT_IS_EXCEPTION(packet.type)) { + // Process encountered an exception. Kill it directly rather than letting + // other handlers process the event. + status_zx = zx_task_kill(child_process_); + GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); + + // Now wait for |child_process_| to terminate. + zx_signals_t signals = 0; + status_zx = zx_object_wait_one( + child_process_, ZX_PROCESS_TERMINATED, ZX_TIME_INFINITE, &signals); + GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); + GTEST_DEATH_TEST_CHECK_(signals & ZX_PROCESS_TERMINATED); + } else { + // Process terminated. + GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type)); + GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_PROCESS_TERMINATED); + } + + ReadAndInterpretStatusByte(); + + zx_info_process_t buffer; + status_zx = zx_object_get_info( + child_process_, + ZX_INFO_PROCESS, + &buffer, + sizeof(buffer), + nullptr, + nullptr); + GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); + + GTEST_DEATH_TEST_CHECK_(buffer.exited); + set_status(buffer.return_code); + return status(); +} + +// The AssumeRole process for a Fuchsia death test. It creates a child +// process with the same executable as the current process to run the +// death test. The child process is given the --gtest_filter and +// --gtest_internal_run_death_test flags such that it knows to run the +// current death test only. +DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { + const UnitTestImpl* const impl = GetUnitTestImpl(); + const InternalRunDeathTestFlag* const flag = + impl->internal_run_death_test_flag(); + const TestInfo* const info = impl->current_test_info(); + const int death_test_index = info->result()->death_test_count(); + + if (flag != NULL) { + // ParseInternalRunDeathTestFlag() has performed all the necessary + // processing. + set_write_fd(kFuchsiaReadPipeFd); + return EXECUTE_TEST; + } + + CaptureStderr(); + // Flush the log buffers since the log streams are shared with the child. + FlushInfoLog(); + + // Build the child process command line. + const std::string filter_flag = + std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + + info->test_case_name() + "." + info->name(); + const std::string internal_flag = + std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + + file_ + "|" + + StreamableToString(line_) + "|" + + StreamableToString(death_test_index); + Arguments args; + args.AddArguments(GetInjectableArgvs()); + args.AddArgument(filter_flag.c_str()); + args.AddArgument(internal_flag.c_str()); + + // Build the pipe for communication with the child. + zx_status_t status; + zx_handle_t child_pipe_handle; + uint32_t type; + status = fdio_pipe_half(&child_pipe_handle, &type); + GTEST_DEATH_TEST_CHECK_(status >= 0); + set_read_fd(status); + + // Set the pipe handle for the child. + fdio_spawn_action_t add_handle_action = {}; + add_handle_action.action = FDIO_SPAWN_ACTION_ADD_HANDLE; + add_handle_action.h.id = PA_HND(type, kFuchsiaReadPipeFd); + add_handle_action.h.handle = child_pipe_handle; + + // Spawn the child process. + status = fdio_spawn_etc(ZX_HANDLE_INVALID, FDIO_SPAWN_CLONE_ALL, + args.Argv()[0], args.Argv(), nullptr, 1, + &add_handle_action, &child_process_, nullptr); + GTEST_DEATH_TEST_CHECK_(status == ZX_OK); + + // Create an exception port and attach it to the |child_process_|, to allow + // us to suppress the system default exception handler from firing. + status = zx_port_create(0, &port_); + GTEST_DEATH_TEST_CHECK_(status == ZX_OK); + status = zx_task_bind_exception_port( + child_process_, port_, 0 /* key */, 0 /*options */); + GTEST_DEATH_TEST_CHECK_(status == ZX_OK); + + set_spawned(true); + return OVERSEE_TEST; +} + +#else // We are neither on Windows, nor on Fuchsia. // ForkingDeathTest provides implementations for most of the abstract // methods of the DeathTest interface. Only the AssumeRole method is @@ -872,9 +1097,13 @@ class ExecDeathTest : public ForkingDeathTest { ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { } virtual TestRole AssumeRole(); private: - static ::std::vector<testing::internal::string> - GetArgvsForDeathTestChildProcess() { - ::std::vector<testing::internal::string> args = GetInjectableArgvs(); + static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() { + ::std::vector<std::string> args = GetInjectableArgvs(); +# if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) + ::std::vector<std::string> extra_args = + GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_(); + args.insert(args.end(), extra_args.begin(), extra_args.end()); +# endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) return args; } // The name of the file in which the death test is located. @@ -970,6 +1199,7 @@ static int ExecDeathTestChildMain(void* child_arg) { } # endif // !GTEST_OS_QNX +# if GTEST_HAS_CLONE // Two utility routines that together determine the direction the stack // grows. // This could be accomplished more elegantly by a single recursive @@ -979,18 +1209,22 @@ static int ExecDeathTestChildMain(void* child_arg) { // GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining // StackLowerThanAddress into StackGrowsDown, which then doesn't give // correct answer. -void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; -void StackLowerThanAddress(const void* ptr, bool* result) { +static void StackLowerThanAddress(const void* ptr, + bool* result) GTEST_NO_INLINE_; +static void StackLowerThanAddress(const void* ptr, bool* result) { int dummy; *result = (&dummy < ptr); } -bool StackGrowsDown() { +// Make sure AddressSanitizer does not tamper with the stack here. +GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +static bool StackGrowsDown() { int dummy; bool result; StackLowerThanAddress(&dummy, &result); return result; } +# endif // GTEST_HAS_CLONE // Spawns a child process with the same executable as the current process in // a thread-safe manner and instructs it to run the death test. The @@ -1182,6 +1416,13 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, *test = new WindowsDeathTest(statement, regex, file, line); } +# elif GTEST_OS_FUCHSIA + + if (GTEST_FLAG(death_test_style) == "threadsafe" || + GTEST_FLAG(death_test_style) == "fast") { + *test = new FuchsiaDeathTest(statement, regex, file, line); + } + # else if (GTEST_FLAG(death_test_style) == "threadsafe") { @@ -1202,31 +1443,11 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, return true; } -// Splits a given string on a given delimiter, populating a given -// vector with the fields. GTEST_HAS_DEATH_TEST implies that we have -// ::std::string, so we can use it here. -static void SplitString(const ::std::string& str, char delimiter, - ::std::vector< ::std::string>* dest) { - ::std::vector< ::std::string> parsed; - ::std::string::size_type pos = 0; - while (::testing::internal::AlwaysTrue()) { - const ::std::string::size_type colon = str.find(delimiter, pos); - if (colon == ::std::string::npos) { - parsed.push_back(str.substr(pos)); - break; - } else { - parsed.push_back(str.substr(pos, colon - pos)); - pos = colon + 1; - } - } - dest->swap(parsed); -} - # if GTEST_OS_WINDOWS // Recreates the pipe and event handles from the provided parameters, // signals the event, and returns a file descriptor wrapped around the pipe // handle. This function is called in the child process only. -int GetStatusFileDescriptor(unsigned int parent_process_id, +static int GetStatusFileDescriptor(unsigned int parent_process_id, size_t write_handle_as_size_t, size_t event_handle_as_size_t) { AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, @@ -1237,7 +1458,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id, StreamableToString(parent_process_id)); } - // TODO(vladl@google.com): Replace the following check with a + // FIXME: Replace the following check with a // compile-time assertion when available. GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t)); @@ -1245,7 +1466,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id, reinterpret_cast<HANDLE>(write_handle_as_size_t); HANDLE dup_write_handle; - // The newly initialized handle is accessible only in in the parent + // The newly initialized handle is accessible only in the parent // process. To obtain one accessible within the child, we need to use // DuplicateHandle. if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, @@ -1322,6 +1543,16 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { write_fd = GetStatusFileDescriptor(parent_process_id, write_handle_as_size_t, event_handle_as_size_t); + +# elif GTEST_OS_FUCHSIA + + if (fields.size() != 3 + || !ParseNaturalNumber(fields[1], &line) + || !ParseNaturalNumber(fields[2], &index)) { + DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + + GTEST_FLAG(internal_run_death_test)); + } + # else if (fields.size() != 4 diff --git a/src/test/fmw/gtest/src/gtest-filepath.cc b/src/test/fmw/gtest/src/gtest-filepath.cc index 6be58b6fca2..a7e65c082a7 100644 --- a/src/test/fmw/gtest/src/gtest-filepath.cc +++ b/src/test/fmw/gtest/src/gtest-filepath.cc @@ -26,14 +26,12 @@ // 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. -// -// Authors: keith.ray@gmail.com (Keith Ray) -#include "gtest/gtest-message.h" #include "gtest/internal/gtest-filepath.h" -#include "gtest/internal/gtest-port.h" #include <stdlib.h> +#include "gtest/internal/gtest-port.h" +#include "gtest/gtest-message.h" #if GTEST_OS_WINDOWS_MOBILE # include <windows.h> @@ -48,6 +46,8 @@ # include <climits> // Some Linux distributions define PATH_MAX here. #endif // GTEST_OS_WINDOWS_MOBILE +#include "gtest/internal/gtest-string.h" + #if GTEST_OS_WINDOWS # define GTEST_PATH_MAX_ _MAX_PATH #elif defined(PATH_MAX) @@ -58,8 +58,6 @@ # define GTEST_PATH_MAX_ _POSIX_PATH_MAX #endif // GTEST_OS_WINDOWS -#include "gtest/internal/gtest-string.h" - namespace testing { namespace internal { @@ -70,7 +68,6 @@ namespace internal { // of them. const char kPathSeparator = '\\'; const char kAlternatePathSeparator = '/'; -const char kPathSeparatorString[] = "\\"; const char kAlternatePathSeparatorString[] = "/"; # if GTEST_OS_WINDOWS_MOBILE // Windows CE doesn't have a current directory. You should not use @@ -84,7 +81,6 @@ const char kCurrentDirectoryString[] = ".\\"; # endif // GTEST_OS_WINDOWS_MOBILE #else const char kPathSeparator = '/'; -const char kPathSeparatorString[] = "/"; const char kCurrentDirectoryString[] = "./"; #endif // GTEST_OS_WINDOWS @@ -99,7 +95,7 @@ static bool IsPathSeparator(char c) { // Returns the current working directory, or "" if unsuccessful. FilePath FilePath::GetCurrentDir() { -#if GTEST_OS_WINDOWS_MOBILE +#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT // Windows CE doesn't have a current directory, so we just return // something reasonable. return FilePath(kCurrentDirectoryString); @@ -108,7 +104,14 @@ FilePath FilePath::GetCurrentDir() { return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); #else char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; - return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); + char* result = getcwd(cwd, sizeof(cwd)); +# if GTEST_OS_NACL + // getcwd will likely fail in NaCl due to the sandbox, so return something + // reasonable. The user may have provided a shim implementation for getcwd, + // however, so fallback only when failure is detected. + return FilePath(result == NULL ? kCurrentDirectoryString : cwd); +# endif // GTEST_OS_NACL + return FilePath(result == NULL ? "" : cwd); #endif // GTEST_OS_WINDOWS_MOBILE } @@ -125,7 +128,7 @@ FilePath FilePath::RemoveExtension(const char* extension) const { return *this; } -// Returns a pointer to the last occurence of a valid path separator in +// Returns a pointer to the last occurrence of a valid path separator in // the FilePath. On Windows, for example, both '/' and '\' are valid path // separators. Returns NULL if no path separator was found. const char* FilePath::FindLastPathSeparator() const { @@ -247,7 +250,7 @@ bool FilePath::DirectoryExists() const { // root directory per disk drive.) bool FilePath::IsRootDirectory() const { #if GTEST_OS_WINDOWS - // TODO(wan@google.com): on Windows a network share like + // FIXME: on Windows a network share like // \\server\share can be a root directory, although it cannot be the // current directory. Handle this properly. return pathname_.length() == 3 && IsAbsolutePath(); @@ -347,7 +350,7 @@ FilePath FilePath::RemoveTrailingPathSeparator() const { // Removes any redundant separators that might be in the pathname. // For example, "bar///foo" becomes "bar/foo". Does not eliminate other // redundancies that might be in a pathname involving "." or "..". -// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share). +// FIXME: handle Windows network shares (e.g. \\server\share). void FilePath::Normalize() { if (pathname_.c_str() == NULL) { pathname_ = ""; diff --git a/src/test/fmw/gtest/src/gtest-internal-inl.h b/src/test/fmw/gtest/src/gtest-internal-inl.h index 35df303cca6..479004149b4 100644 --- a/src/test/fmw/gtest/src/gtest-internal-inl.h +++ b/src/test/fmw/gtest/src/gtest-internal-inl.h @@ -27,24 +27,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Utility functions and classes used by the Google C++ testing framework. -// -// Author: wan@google.com (Zhanyong Wan) -// +// Utility functions and classes used by the Google C++ testing framework.// // This file contains purely Google Test's internal implementation. Please // DO NOT #INCLUDE IT IN A USER PROGRAM. #ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_ #define GTEST_SRC_GTEST_INTERNAL_INL_H_ -// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is -// part of Google Test's implementation; otherwise it's undefined. -#if !GTEST_IMPLEMENTATION_ -// A user is trying to include this from his code - just say no. -# error "gtest-internal-inl.h is part of Google Test's internal implementation." -# error "It must not be included except by Google Test itself." -#endif // GTEST_IMPLEMENTATION_ - #ifndef _WIN32_WCE # include <errno.h> #endif // !_WIN32_WCE @@ -67,9 +56,12 @@ # include <windows.h> // NOLINT #endif // GTEST_OS_WINDOWS -#include "gtest/gtest.h" // NOLINT +#include "gtest/gtest.h" #include "gtest/gtest-spi.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) + namespace testing { // Declares the flags. @@ -94,12 +86,14 @@ const char kFilterFlag[] = "filter"; const char kListTestsFlag[] = "list_tests"; const char kOutputFlag[] = "output"; const char kPrintTimeFlag[] = "print_time"; +const char kPrintUTF8Flag[] = "print_utf8"; const char kRandomSeedFlag[] = "random_seed"; const char kRepeatFlag[] = "repeat"; const char kShuffleFlag[] = "shuffle"; const char kStackTraceDepthFlag[] = "stack_trace_depth"; const char kStreamResultToFlag[] = "stream_result_to"; const char kThrowOnFailureFlag[] = "throw_on_failure"; +const char kFlagfileFlag[] = "flagfile"; // A valid random seed must be in [1, kMaxRandomSeed]. const int kMaxRandomSeed = 99999; @@ -173,6 +167,7 @@ class GTestFlagSaver { list_tests_ = GTEST_FLAG(list_tests); output_ = GTEST_FLAG(output); print_time_ = GTEST_FLAG(print_time); + print_utf8_ = GTEST_FLAG(print_utf8); random_seed_ = GTEST_FLAG(random_seed); repeat_ = GTEST_FLAG(repeat); shuffle_ = GTEST_FLAG(shuffle); @@ -194,6 +189,7 @@ class GTestFlagSaver { GTEST_FLAG(list_tests) = list_tests_; GTEST_FLAG(output) = output_; GTEST_FLAG(print_time) = print_time_; + GTEST_FLAG(print_utf8) = print_utf8_; GTEST_FLAG(random_seed) = random_seed_; GTEST_FLAG(repeat) = repeat_; GTEST_FLAG(shuffle) = shuffle_; @@ -215,6 +211,7 @@ class GTestFlagSaver { bool list_tests_; std::string output_; bool print_time_; + bool print_utf8_; internal::Int32 random_seed_; internal::Int32 repeat_; bool shuffle_; @@ -425,13 +422,17 @@ class OsStackTraceGetterInterface { // in the trace. // skip_count - the number of top frames to be skipped; doesn't count // against max_depth. - virtual string CurrentStackTrace(int max_depth, int skip_count) = 0; + virtual std::string CurrentStackTrace(int max_depth, int skip_count) = 0; // UponLeavingGTest() should be called immediately before Google Test calls // user code. It saves some information about the current stack that // CurrentStackTrace() will use to find and hide Google Test stack frames. virtual void UponLeavingGTest() = 0; + // This string is inserted in place of stack frames that are part of + // Google Test's implementation. + static const char* const kElidedFramesMarker; + private: GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface); }; @@ -439,25 +440,21 @@ class OsStackTraceGetterInterface { // A working implementation of the OsStackTraceGetterInterface interface. class OsStackTraceGetter : public OsStackTraceGetterInterface { public: - OsStackTraceGetter() : caller_frame_(NULL) {} - - virtual string CurrentStackTrace(int max_depth, int skip_count) - GTEST_LOCK_EXCLUDED_(mutex_); + OsStackTraceGetter() {} - virtual void UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_); - - // This string is inserted in place of stack frames that are part of - // Google Test's implementation. - static const char* const kElidedFramesMarker; + virtual std::string CurrentStackTrace(int max_depth, int skip_count); + virtual void UponLeavingGTest(); private: - Mutex mutex_; // protects all internal state +#if GTEST_HAS_ABSL + Mutex mutex_; // Protects all internal state. // We save the stack frame below the frame that calls user code. // We do this because the address of the frame immediately below // the user code changes between the call to UponLeavingGTest() - // and any calls to CurrentStackTrace() from within the user code. - void* caller_frame_; + // and any calls to the stack trace code from within the user code. + void* caller_frame_ = nullptr; +#endif // GTEST_HAS_ABSL GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); }; @@ -673,13 +670,11 @@ class GTEST_API_ UnitTestImpl { tear_down_tc)->AddTestInfo(test_info); } -#if GTEST_HAS_PARAM_TEST // Returns ParameterizedTestCaseRegistry object used to keep track of // value-parameterized tests and instantiate and register them. internal::ParameterizedTestCaseRegistry& parameterized_test_registry() { return parameterized_test_registry_; } -#endif // GTEST_HAS_PARAM_TEST // Sets the TestCase object for the test that's currently running. void set_current_test_case(TestCase* a_current_test_case) { @@ -854,14 +849,12 @@ class GTEST_API_ UnitTestImpl { // shuffled order. std::vector<int> test_case_indices_; -#if GTEST_HAS_PARAM_TEST // ParameterizedTestRegistry object used to register value-parameterized // tests. internal::ParameterizedTestCaseRegistry parameterized_test_registry_; // Indicates whether RegisterParameterizedTests() has been called already. bool parameterized_tests_registered_; -#endif // GTEST_HAS_PARAM_TEST // Index of the last death test case registered. Initially -1. int last_death_test_case_; @@ -968,32 +961,6 @@ GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); // platform. GTEST_API_ std::string GetLastErrnoDescription(); -# if GTEST_OS_WINDOWS -// Provides leak-safe Windows kernel handle ownership. -class AutoHandle { - public: - AutoHandle() : handle_(INVALID_HANDLE_VALUE) {} - explicit AutoHandle(HANDLE handle) : handle_(handle) {} - - ~AutoHandle() { Reset(); } - - HANDLE Get() const { return handle_; } - void Reset() { Reset(INVALID_HANDLE_VALUE); } - void Reset(HANDLE handle) { - if (handle != handle_) { - if (handle_ != INVALID_HANDLE_VALUE) - ::CloseHandle(handle_); - handle_ = handle; - } - } - - private: - HANDLE handle_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); -}; -# endif // GTEST_OS_WINDOWS - // Attempts to parse a string into a positive integer pointed to by the // number parameter. Returns true if that is possible. // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use @@ -1027,7 +994,7 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) { const bool parse_success = *end == '\0' && errno == 0; - // TODO(vladl@google.com): Convert this to compile time assertion when it is + // FIXME: Convert this to compile time assertion when it is // available. GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed)); @@ -1075,21 +1042,19 @@ class StreamingListener : public EmptyTestEventListener { virtual ~AbstractSocketWriter() {} // Sends a string to the socket. - virtual void Send(const string& message) = 0; + virtual void Send(const std::string& message) = 0; // Closes the socket. virtual void CloseConnection() {} // Sends a string and a newline to the socket. - void SendLn(const string& message) { - Send(message + "\n"); - } + void SendLn(const std::string& message) { Send(message + "\n"); } }; // Concrete class for actually writing strings to a socket. class SocketWriter : public AbstractSocketWriter { public: - SocketWriter(const string& host, const string& port) + SocketWriter(const std::string& host, const std::string& port) : sockfd_(-1), host_name_(host), port_num_(port) { MakeConnection(); } @@ -1100,7 +1065,7 @@ class StreamingListener : public EmptyTestEventListener { } // Sends a string to the socket. - virtual void Send(const string& message) { + virtual void Send(const std::string& message) { GTEST_CHECK_(sockfd_ != -1) << "Send() can be called only when there is a connection."; @@ -1126,17 +1091,19 @@ class StreamingListener : public EmptyTestEventListener { } int sockfd_; // socket file descriptor - const string host_name_; - const string port_num_; + const std::string host_name_; + const std::string port_num_; GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter); }; // class SocketWriter // Escapes '=', '&', '%', and '\n' characters in str as "%xx". - static string UrlEncode(const char* str); + static std::string UrlEncode(const char* str); - StreamingListener(const string& host, const string& port) - : socket_writer_(new SocketWriter(host, port)) { Start(); } + StreamingListener(const std::string& host, const std::string& port) + : socket_writer_(new SocketWriter(host, port)) { + Start(); + } explicit StreamingListener(AbstractSocketWriter* socket_writer) : socket_writer_(socket_writer) { Start(); } @@ -1197,13 +1164,13 @@ class StreamingListener : public EmptyTestEventListener { private: // Sends the given message and a newline to the socket. - void SendLn(const string& message) { socket_writer_->SendLn(message); } + void SendLn(const std::string& message) { socket_writer_->SendLn(message); } // Called at the start of streaming to notify the receiver what // protocol we are using. void Start() { SendLn("gtest_streaming_protocol_version=1.0"); } - string FormatBool(bool value) { return value ? "1" : "0"; } + std::string FormatBool(bool value) { return value ? "1" : "0"; } const scoped_ptr<AbstractSocketWriter> socket_writer_; @@ -1215,4 +1182,6 @@ class StreamingListener : public EmptyTestEventListener { } // namespace internal } // namespace testing +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 + #endif // GTEST_SRC_GTEST_INTERNAL_INL_H_ diff --git a/src/test/fmw/gtest/src/gtest-port.cc b/src/test/fmw/gtest/src/gtest-port.cc index 0c4df5f29a7..fecb5d11c21 100644 --- a/src/test/fmw/gtest/src/gtest-port.cc +++ b/src/test/fmw/gtest/src/gtest-port.cc @@ -26,8 +26,7 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) + #include "gtest/internal/gtest-port.h" @@ -35,15 +34,16 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <fstream> -#if GTEST_OS_WINDOWS_MOBILE -# include <windows.h> // For TerminateProcess() -#elif GTEST_OS_WINDOWS +#if GTEST_OS_WINDOWS +# include <windows.h> # include <io.h> # include <sys/stat.h> +# include <map> // Used in ThreadLocal. #else # include <unistd.h> -#endif // GTEST_OS_WINDOWS_MOBILE +#endif // GTEST_OS_WINDOWS #if GTEST_OS_MAC # include <mach/mach_init.h> @@ -53,22 +53,25 @@ #if GTEST_OS_QNX # include <devctl.h> +# include <fcntl.h> # include <sys/procfs.h> #endif // GTEST_OS_QNX +#if GTEST_OS_AIX +# include <procinfo.h> +# include <sys/types.h> +#endif // GTEST_OS_AIX + +#if GTEST_OS_FUCHSIA +# include <zircon/process.h> +# include <zircon/syscalls.h> +#endif // GTEST_OS_FUCHSIA + #include "gtest/gtest-spi.h" #include "gtest/gtest-message.h" #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-string.h" - -// Indicates that this translation unit is part of Google Test's -// implementation. It must come before gtest-internal-inl.h is -// included, or there will be a compiler error. This trick is to -// prevent a user from accidentally including gtest-internal-inl.h in -// his code. -#define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" -#undef GTEST_IMPLEMENTATION_ namespace testing { namespace internal { @@ -82,10 +85,31 @@ const int kStdOutFileno = STDOUT_FILENO; const int kStdErrFileno = STDERR_FILENO; #endif // _MSC_VER -#if GTEST_OS_MAC +#if GTEST_OS_LINUX + +namespace { +template <typename T> +T ReadProcFileField(const std::string& filename, int field) { + std::string dummy; + std::ifstream file(filename.c_str()); + while (field-- > 0) { + file >> dummy; + } + T output = 0; + file >> output; + return output; +} +} // namespace + +// Returns the number of active threads, or 0 when there is an error. +size_t GetThreadCount() { + const std::string filename = + (Message() << "/proc/" << getpid() << "/stat").GetString(); + return ReadProcFileField<int>(filename, 19); +} + +#elif GTEST_OS_MAC -// Returns the number of threads running in the process, or 0 to indicate that -// we cannot detect it. size_t GetThreadCount() { const task_t task = mach_task_self(); mach_msg_type_number_t thread_count; @@ -123,6 +147,38 @@ size_t GetThreadCount() { } } +#elif GTEST_OS_AIX + +size_t GetThreadCount() { + struct procentry64 entry; + pid_t pid = getpid(); + int status = getprocs64(&entry, sizeof(entry), NULL, 0, &pid, 1); + if (status == 1) { + return entry.pi_thcount; + } else { + return 0; + } +} + +#elif GTEST_OS_FUCHSIA + +size_t GetThreadCount() { + int dummy_buffer; + size_t avail; + zx_status_t status = zx_object_get_info( + zx_process_self(), + ZX_INFO_PROCESS_THREADS, + &dummy_buffer, + 0, + nullptr, + &avail); + if (status == ZX_OK) { + return avail; + } else { + return 0; + } +} + #else size_t GetThreadCount() { @@ -131,7 +187,432 @@ size_t GetThreadCount() { return 0; } -#endif // GTEST_OS_MAC +#endif // GTEST_OS_LINUX + +#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS + +void SleepMilliseconds(int n) { + ::Sleep(n); +} + +AutoHandle::AutoHandle() + : handle_(INVALID_HANDLE_VALUE) {} + +AutoHandle::AutoHandle(Handle handle) + : handle_(handle) {} + +AutoHandle::~AutoHandle() { + Reset(); +} + +AutoHandle::Handle AutoHandle::Get() const { + return handle_; +} + +void AutoHandle::Reset() { + Reset(INVALID_HANDLE_VALUE); +} + +void AutoHandle::Reset(HANDLE handle) { + // Resetting with the same handle we already own is invalid. + if (handle_ != handle) { + if (IsCloseable()) { + ::CloseHandle(handle_); + } + handle_ = handle; + } else { + GTEST_CHECK_(!IsCloseable()) + << "Resetting a valid handle to itself is likely a programmer error " + "and thus not allowed."; + } +} + +bool AutoHandle::IsCloseable() const { + // Different Windows APIs may use either of these values to represent an + // invalid handle. + return handle_ != NULL && handle_ != INVALID_HANDLE_VALUE; +} + +Notification::Notification() + : event_(::CreateEvent(NULL, // Default security attributes. + TRUE, // Do not reset automatically. + FALSE, // Initially unset. + NULL)) { // Anonymous event. + GTEST_CHECK_(event_.Get() != NULL); +} + +void Notification::Notify() { + GTEST_CHECK_(::SetEvent(event_.Get()) != FALSE); +} + +void Notification::WaitForNotification() { + GTEST_CHECK_( + ::WaitForSingleObject(event_.Get(), INFINITE) == WAIT_OBJECT_0); +} + +Mutex::Mutex() + : owner_thread_id_(0), + type_(kDynamic), + critical_section_init_phase_(0), + critical_section_(new CRITICAL_SECTION) { + ::InitializeCriticalSection(critical_section_); +} + +Mutex::~Mutex() { + // Static mutexes are leaked intentionally. It is not thread-safe to try + // to clean them up. + // FIXME: Switch to Slim Reader/Writer (SRW) Locks, which requires + // nothing to clean it up but is available only on Vista and later. + // https://docs.microsoft.com/en-us/windows/desktop/Sync/slim-reader-writer--srw--locks + if (type_ == kDynamic) { + ::DeleteCriticalSection(critical_section_); + delete critical_section_; + critical_section_ = NULL; + } +} + +void Mutex::Lock() { + ThreadSafeLazyInit(); + ::EnterCriticalSection(critical_section_); + owner_thread_id_ = ::GetCurrentThreadId(); +} + +void Mutex::Unlock() { + ThreadSafeLazyInit(); + // We don't protect writing to owner_thread_id_ here, as it's the + // caller's responsibility to ensure that the current thread holds the + // mutex when this is called. + owner_thread_id_ = 0; + ::LeaveCriticalSection(critical_section_); +} + +// Does nothing if the current thread holds the mutex. Otherwise, crashes +// with high probability. +void Mutex::AssertHeld() { + ThreadSafeLazyInit(); + GTEST_CHECK_(owner_thread_id_ == ::GetCurrentThreadId()) + << "The current thread is not holding the mutex @" << this; +} + +namespace { + +// Use the RAII idiom to flag mem allocs that are intentionally never +// deallocated. The motivation is to silence the false positive mem leaks +// that are reported by the debug version of MS's CRT which can only detect +// if an alloc is missing a matching deallocation. +// Example: +// MemoryIsNotDeallocated memory_is_not_deallocated; +// critical_section_ = new CRITICAL_SECTION; +// +class MemoryIsNotDeallocated +{ + public: + MemoryIsNotDeallocated() : old_crtdbg_flag_(0) { +#ifdef _MSC_VER + old_crtdbg_flag_ = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + // Set heap allocation block type to _IGNORE_BLOCK so that MS debug CRT + // doesn't report mem leak if there's no matching deallocation. + _CrtSetDbgFlag(old_crtdbg_flag_ & ~_CRTDBG_ALLOC_MEM_DF); +#endif // _MSC_VER + } + + ~MemoryIsNotDeallocated() { +#ifdef _MSC_VER + // Restore the original _CRTDBG_ALLOC_MEM_DF flag + _CrtSetDbgFlag(old_crtdbg_flag_); +#endif // _MSC_VER + } + + private: + int old_crtdbg_flag_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(MemoryIsNotDeallocated); +}; + +} // namespace + +// Initializes owner_thread_id_ and critical_section_ in static mutexes. +void Mutex::ThreadSafeLazyInit() { + // Dynamic mutexes are initialized in the constructor. + if (type_ == kStatic) { + switch ( + ::InterlockedCompareExchange(&critical_section_init_phase_, 1L, 0L)) { + case 0: + // If critical_section_init_phase_ was 0 before the exchange, we + // are the first to test it and need to perform the initialization. + owner_thread_id_ = 0; + { + // Use RAII to flag that following mem alloc is never deallocated. + MemoryIsNotDeallocated memory_is_not_deallocated; + critical_section_ = new CRITICAL_SECTION; + } + ::InitializeCriticalSection(critical_section_); + // Updates the critical_section_init_phase_ to 2 to signal + // initialization complete. + GTEST_CHECK_(::InterlockedCompareExchange( + &critical_section_init_phase_, 2L, 1L) == + 1L); + break; + case 1: + // Somebody else is already initializing the mutex; spin until they + // are done. + while (::InterlockedCompareExchange(&critical_section_init_phase_, + 2L, + 2L) != 2L) { + // Possibly yields the rest of the thread's time slice to other + // threads. + ::Sleep(0); + } + break; + + case 2: + break; // The mutex is already initialized and ready for use. + + default: + GTEST_CHECK_(false) + << "Unexpected value of critical_section_init_phase_ " + << "while initializing a static mutex."; + } + } +} + +namespace { + +class ThreadWithParamSupport : public ThreadWithParamBase { + public: + static HANDLE CreateThread(Runnable* runnable, + Notification* thread_can_start) { + ThreadMainParam* param = new ThreadMainParam(runnable, thread_can_start); + DWORD thread_id; + // FIXME: Consider to use _beginthreadex instead. + HANDLE thread_handle = ::CreateThread( + NULL, // Default security. + 0, // Default stack size. + &ThreadWithParamSupport::ThreadMain, + param, // Parameter to ThreadMainStatic + 0x0, // Default creation flags. + &thread_id); // Need a valid pointer for the call to work under Win98. + GTEST_CHECK_(thread_handle != NULL) << "CreateThread failed with error " + << ::GetLastError() << "."; + if (thread_handle == NULL) { + delete param; + } + return thread_handle; + } + + private: + struct ThreadMainParam { + ThreadMainParam(Runnable* runnable, Notification* thread_can_start) + : runnable_(runnable), + thread_can_start_(thread_can_start) { + } + scoped_ptr<Runnable> runnable_; + // Does not own. + Notification* thread_can_start_; + }; + + static DWORD WINAPI ThreadMain(void* ptr) { + // Transfers ownership. + scoped_ptr<ThreadMainParam> param(static_cast<ThreadMainParam*>(ptr)); + if (param->thread_can_start_ != NULL) + param->thread_can_start_->WaitForNotification(); + param->runnable_->Run(); + return 0; + } + + // Prohibit instantiation. + ThreadWithParamSupport(); + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParamSupport); +}; + +} // namespace + +ThreadWithParamBase::ThreadWithParamBase(Runnable *runnable, + Notification* thread_can_start) + : thread_(ThreadWithParamSupport::CreateThread(runnable, + thread_can_start)) { +} + +ThreadWithParamBase::~ThreadWithParamBase() { + Join(); +} + +void ThreadWithParamBase::Join() { + GTEST_CHECK_(::WaitForSingleObject(thread_.Get(), INFINITE) == WAIT_OBJECT_0) + << "Failed to join the thread with error " << ::GetLastError() << "."; +} + +// Maps a thread to a set of ThreadIdToThreadLocals that have values +// instantiated on that thread and notifies them when the thread exits. A +// ThreadLocal instance is expected to persist until all threads it has +// values on have terminated. +class ThreadLocalRegistryImpl { + public: + // Registers thread_local_instance as having value on the current thread. + // Returns a value that can be used to identify the thread from other threads. + static ThreadLocalValueHolderBase* GetValueOnCurrentThread( + const ThreadLocalBase* thread_local_instance) { + DWORD current_thread = ::GetCurrentThreadId(); + MutexLock lock(&mutex_); + ThreadIdToThreadLocals* const thread_to_thread_locals = + GetThreadLocalsMapLocked(); + ThreadIdToThreadLocals::iterator thread_local_pos = + thread_to_thread_locals->find(current_thread); + if (thread_local_pos == thread_to_thread_locals->end()) { + thread_local_pos = thread_to_thread_locals->insert( + std::make_pair(current_thread, ThreadLocalValues())).first; + StartWatcherThreadFor(current_thread); + } + ThreadLocalValues& thread_local_values = thread_local_pos->second; + ThreadLocalValues::iterator value_pos = + thread_local_values.find(thread_local_instance); + if (value_pos == thread_local_values.end()) { + value_pos = + thread_local_values + .insert(std::make_pair( + thread_local_instance, + linked_ptr<ThreadLocalValueHolderBase>( + thread_local_instance->NewValueForCurrentThread()))) + .first; + } + return value_pos->second.get(); + } + + static void OnThreadLocalDestroyed( + const ThreadLocalBase* thread_local_instance) { + std::vector<linked_ptr<ThreadLocalValueHolderBase> > value_holders; + // Clean up the ThreadLocalValues data structure while holding the lock, but + // defer the destruction of the ThreadLocalValueHolderBases. + { + MutexLock lock(&mutex_); + ThreadIdToThreadLocals* const thread_to_thread_locals = + GetThreadLocalsMapLocked(); + for (ThreadIdToThreadLocals::iterator it = + thread_to_thread_locals->begin(); + it != thread_to_thread_locals->end(); + ++it) { + ThreadLocalValues& thread_local_values = it->second; + ThreadLocalValues::iterator value_pos = + thread_local_values.find(thread_local_instance); + if (value_pos != thread_local_values.end()) { + value_holders.push_back(value_pos->second); + thread_local_values.erase(value_pos); + // This 'if' can only be successful at most once, so theoretically we + // could break out of the loop here, but we don't bother doing so. + } + } + } + // Outside the lock, let the destructor for 'value_holders' deallocate the + // ThreadLocalValueHolderBases. + } + + static void OnThreadExit(DWORD thread_id) { + GTEST_CHECK_(thread_id != 0) << ::GetLastError(); + std::vector<linked_ptr<ThreadLocalValueHolderBase> > value_holders; + // Clean up the ThreadIdToThreadLocals data structure while holding the + // lock, but defer the destruction of the ThreadLocalValueHolderBases. + { + MutexLock lock(&mutex_); + ThreadIdToThreadLocals* const thread_to_thread_locals = + GetThreadLocalsMapLocked(); + ThreadIdToThreadLocals::iterator thread_local_pos = + thread_to_thread_locals->find(thread_id); + if (thread_local_pos != thread_to_thread_locals->end()) { + ThreadLocalValues& thread_local_values = thread_local_pos->second; + for (ThreadLocalValues::iterator value_pos = + thread_local_values.begin(); + value_pos != thread_local_values.end(); + ++value_pos) { + value_holders.push_back(value_pos->second); + } + thread_to_thread_locals->erase(thread_local_pos); + } + } + // Outside the lock, let the destructor for 'value_holders' deallocate the + // ThreadLocalValueHolderBases. + } + + private: + // In a particular thread, maps a ThreadLocal object to its value. + typedef std::map<const ThreadLocalBase*, + linked_ptr<ThreadLocalValueHolderBase> > ThreadLocalValues; + // Stores all ThreadIdToThreadLocals having values in a thread, indexed by + // thread's ID. + typedef std::map<DWORD, ThreadLocalValues> ThreadIdToThreadLocals; + + // Holds the thread id and thread handle that we pass from + // StartWatcherThreadFor to WatcherThreadFunc. + typedef std::pair<DWORD, HANDLE> ThreadIdAndHandle; + + static void StartWatcherThreadFor(DWORD thread_id) { + // The returned handle will be kept in thread_map and closed by + // watcher_thread in WatcherThreadFunc. + HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION, + FALSE, + thread_id); + GTEST_CHECK_(thread != NULL); + // We need to pass a valid thread ID pointer into CreateThread for it + // to work correctly under Win98. + DWORD watcher_thread_id; + HANDLE watcher_thread = ::CreateThread( + NULL, // Default security. + 0, // Default stack size + &ThreadLocalRegistryImpl::WatcherThreadFunc, + reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)), + CREATE_SUSPENDED, + &watcher_thread_id); + GTEST_CHECK_(watcher_thread != NULL); + // Give the watcher thread the same priority as ours to avoid being + // blocked by it. + ::SetThreadPriority(watcher_thread, + ::GetThreadPriority(::GetCurrentThread())); + ::ResumeThread(watcher_thread); + ::CloseHandle(watcher_thread); + } + + // Monitors exit from a given thread and notifies those + // ThreadIdToThreadLocals about thread termination. + static DWORD WINAPI WatcherThreadFunc(LPVOID param) { + const ThreadIdAndHandle* tah = + reinterpret_cast<const ThreadIdAndHandle*>(param); + GTEST_CHECK_( + ::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0); + OnThreadExit(tah->first); + ::CloseHandle(tah->second); + delete tah; + return 0; + } + + // Returns map of thread local instances. + static ThreadIdToThreadLocals* GetThreadLocalsMapLocked() { + mutex_.AssertHeld(); + MemoryIsNotDeallocated memory_is_not_deallocated; + static ThreadIdToThreadLocals* map = new ThreadIdToThreadLocals(); + return map; + } + + // Protects access to GetThreadLocalsMapLocked() and its return value. + static Mutex mutex_; + // Protects access to GetThreadMapLocked() and its return value. + static Mutex thread_map_mutex_; +}; + +Mutex ThreadLocalRegistryImpl::mutex_(Mutex::kStaticMutex); +Mutex ThreadLocalRegistryImpl::thread_map_mutex_(Mutex::kStaticMutex); + +ThreadLocalValueHolderBase* ThreadLocalRegistry::GetValueOnCurrentThread( + const ThreadLocalBase* thread_local_instance) { + return ThreadLocalRegistryImpl::GetValueOnCurrentThread( + thread_local_instance); +} + +void ThreadLocalRegistry::OnThreadLocalDestroyed( + const ThreadLocalBase* thread_local_instance) { + ThreadLocalRegistryImpl::OnThreadLocalDestroyed(thread_local_instance); +} + +#endif // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS #if GTEST_USES_POSIX_RE @@ -247,7 +728,7 @@ bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { } // Helper function used by ValidateRegex() to format error messages. -std::string FormatRegexSyntaxError(const char* regex, int index) { +static std::string FormatRegexSyntaxError(const char* regex, int index) { return (Message() << "Syntax error at index " << index << " in simple regular expression \"" << regex << "\": ").GetString(); } @@ -256,7 +737,7 @@ std::string FormatRegexSyntaxError(const char* regex, int index) { // otherwise returns true. bool ValidateRegex(const char* regex) { if (regex == NULL) { - // TODO(wan@google.com): fix the source file location in the + // FIXME: fix the source file location in the // assertion failures to match where the regex is used in user // code. ADD_FAILURE() << "NULL is not a valid simple regular expression."; @@ -481,7 +962,6 @@ GTEST_API_ ::std::string FormatCompilerIndependentFileLocation( return file_name + ":" + StreamableToString(line); } - GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line) : severity_(severity) { const char* const marker = @@ -500,12 +980,10 @@ GTestLog::~GTestLog() { posix::Abort(); } } + // Disable Microsoft deprecation warnings for POSIX functions called from // this class (creat, dup, dup2, and close) -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4996) -#endif // _MSC_VER +GTEST_DISABLE_MSC_DEPRECATED_PUSH_() #if GTEST_HAS_STREAM_REDIRECTION @@ -581,12 +1059,6 @@ class CapturedStream { } private: - // Reads the entire content of a file as an std::string. - static std::string ReadEntireFile(FILE* file); - - // Returns the size (in bytes) of a file. - static size_t GetFileSize(FILE* file); - const int fd_; // A stream to capture. int uncaptured_fd_; // Name of the temporary file holding the stderr output. @@ -595,44 +1067,14 @@ class CapturedStream { GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream); }; -// Returns the size (in bytes) of a file. -size_t CapturedStream::GetFileSize(FILE* file) { - fseek(file, 0, SEEK_END); - return static_cast<size_t>(ftell(file)); -} - -// Reads the entire content of a file as a string. -std::string CapturedStream::ReadEntireFile(FILE* file) { - const size_t file_size = GetFileSize(file); - char* const buffer = new char[file_size]; - - size_t bytes_last_read = 0; // # of bytes read in the last fread() - size_t bytes_read = 0; // # of bytes read so far - - fseek(file, 0, SEEK_SET); - - // Keeps reading the file until we cannot read further or the - // pre-determined file size is reached. - do { - bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file); - bytes_read += bytes_last_read; - } while (bytes_last_read > 0 && bytes_read < file_size); - - const std::string content(buffer, bytes_read); - delete[] buffer; - - return content; -} - -# ifdef _MSC_VER -# pragma warning(pop) -# endif // _MSC_VER +GTEST_DISABLE_MSC_DEPRECATED_POP_() static CapturedStream* g_captured_stderr = NULL; static CapturedStream* g_captured_stdout = NULL; // Starts capturing an output stream (stdout/stderr). -void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { +static void CaptureStream(int fd, const char* stream_name, + CapturedStream** stream) { if (*stream != NULL) { GTEST_LOG_(FATAL) << "Only one " << stream_name << " capturer can exist at a time."; @@ -641,7 +1083,7 @@ void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { } // Stops capturing the output stream and returns the captured string. -std::string GetCapturedStream(CapturedStream** captured_stream) { +static std::string GetCapturedStream(CapturedStream** captured_stream) { const std::string content = (*captured_stream)->GetCapturedString(); delete *captured_stream; @@ -672,25 +1114,67 @@ std::string GetCapturedStderr() { #endif // GTEST_HAS_STREAM_REDIRECTION -#if GTEST_HAS_DEATH_TEST -// A copy of all command line arguments. Set by InitGoogleTest(). -::std::vector<testing::internal::string> g_argvs; -static const ::std::vector<testing::internal::string>* g_injected_test_argvs = - NULL; // Owned. -void SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) { - if (g_injected_test_argvs != argvs) - delete g_injected_test_argvs; - g_injected_test_argvs = argvs; + +size_t GetFileSize(FILE* file) { + fseek(file, 0, SEEK_END); + return static_cast<size_t>(ftell(file)); } -const ::std::vector<testing::internal::string>& GetInjectableArgvs() { +std::string ReadEntireFile(FILE* file) { + const size_t file_size = GetFileSize(file); + char* const buffer = new char[file_size]; + + size_t bytes_last_read = 0; // # of bytes read in the last fread() + size_t bytes_read = 0; // # of bytes read so far + + fseek(file, 0, SEEK_SET); + + // Keeps reading the file until we cannot read further or the + // pre-determined file size is reached. + do { + bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file); + bytes_read += bytes_last_read; + } while (bytes_last_read > 0 && bytes_read < file_size); + + const std::string content(buffer, bytes_read); + delete[] buffer; + + return content; +} + +#if GTEST_HAS_DEATH_TEST +static const std::vector<std::string>* g_injected_test_argvs = NULL; // Owned. + +std::vector<std::string> GetInjectableArgvs() { if (g_injected_test_argvs != NULL) { return *g_injected_test_argvs; } - return g_argvs; + return GetArgvs(); +} + +void SetInjectableArgvs(const std::vector<std::string>* new_argvs) { + if (g_injected_test_argvs != new_argvs) delete g_injected_test_argvs; + g_injected_test_argvs = new_argvs; +} + +void SetInjectableArgvs(const std::vector<std::string>& new_argvs) { + SetInjectableArgvs( + new std::vector<std::string>(new_argvs.begin(), new_argvs.end())); +} + +#if GTEST_HAS_GLOBAL_STRING +void SetInjectableArgvs(const std::vector< ::string>& new_argvs) { + SetInjectableArgvs( + new std::vector<std::string>(new_argvs.begin(), new_argvs.end())); +} +#endif // GTEST_HAS_GLOBAL_STRING + +void ClearInjectableArgvs() { + delete g_injected_test_argvs; + g_injected_test_argvs = NULL; } #endif // GTEST_HAS_DEATH_TEST @@ -764,16 +1248,23 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value) { // // The value is considered true iff it's not "0". bool BoolFromGTestEnv(const char* flag, bool default_value) { +#if defined(GTEST_GET_BOOL_FROM_ENV_) + return GTEST_GET_BOOL_FROM_ENV_(flag, default_value); +#else const std::string env_var = FlagToEnvVar(flag); const char* const string_value = posix::GetEnv(env_var.c_str()); return string_value == NULL ? default_value : strcmp(string_value, "0") != 0; +#endif // defined(GTEST_GET_BOOL_FROM_ENV_) } // Reads and returns a 32-bit integer stored in the environment // variable corresponding to the given flag; if it isn't set or // doesn't represent a valid 32-bit integer, returns default_value. Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { +#if defined(GTEST_GET_INT32_FROM_ENV_) + return GTEST_GET_INT32_FROM_ENV_(flag, default_value); +#else const std::string env_var = FlagToEnvVar(flag); const char* const string_value = posix::GetEnv(env_var.c_str()); if (string_value == NULL) { @@ -791,14 +1282,36 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { } return result; +#endif // defined(GTEST_GET_INT32_FROM_ENV_) +} + +// As a special case for the 'output' flag, if GTEST_OUTPUT is not +// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build +// system. The value of XML_OUTPUT_FILE is a filename without the +// "xml:" prefix of GTEST_OUTPUT. +// Note that this is meant to be called at the call site so it does +// not check that the flag is 'output' +// In essence this checks an env variable called XML_OUTPUT_FILE +// and if it is set we prepend "xml:" to its value, if it not set we return "" +std::string OutputFlagAlsoCheckEnvVar(){ + std::string default_value_for_output_flag = ""; + const char* xml_output_file_env = posix::GetEnv("XML_OUTPUT_FILE"); + if (NULL != xml_output_file_env) { + default_value_for_output_flag = std::string("xml:") + xml_output_file_env; + } + return default_value_for_output_flag; } // Reads and returns the string environment variable corresponding to // the given flag; if it's not set, returns default_value. const char* StringFromGTestEnv(const char* flag, const char* default_value) { +#if defined(GTEST_GET_STRING_FROM_ENV_) + return GTEST_GET_STRING_FROM_ENV_(flag, default_value); +#else const std::string env_var = FlagToEnvVar(flag); const char* const value = posix::GetEnv(env_var.c_str()); return value == NULL ? default_value : value; +#endif // defined(GTEST_GET_STRING_FROM_ENV_) } } // namespace internal diff --git a/src/test/fmw/gtest/src/gtest-printers.cc b/src/test/fmw/gtest/src/gtest-printers.cc index 75fa4081009..de4d245e9fc 100644 --- a/src/test/fmw/gtest/src/gtest-printers.cc +++ b/src/test/fmw/gtest/src/gtest-printers.cc @@ -26,10 +26,9 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) -// Google Test - The Google C++ Testing Framework + +// Google Test - The Google C++ Testing and Mocking Framework // // This file implements a universal value printer that can print a // value of any type T: @@ -43,11 +42,13 @@ // defines Foo. #include "gtest/gtest-printers.h" -#include <ctype.h> #include <stdio.h> +#include <cctype> +#include <cwchar> #include <ostream> // NOLINT #include <string> #include "gtest/internal/gtest-port.h" +#include "src/gtest-internal-inl.h" namespace testing { @@ -56,6 +57,9 @@ namespace { using ::std::ostream; // Prints a segment of bytes in the given object. +GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start, size_t count, ostream* os) { char text[5] = ""; @@ -85,7 +89,7 @@ void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count, // If the object size is bigger than kThreshold, we'll have to omit // some details by printing only the first and the last kChunkSize // bytes. - // TODO(wan): let the user control the threshold using a flag. + // FIXME: let the user control the threshold using a flag. if (count < kThreshold) { PrintByteSegmentInObjectTo(obj_bytes, 0, count, os); } else { @@ -119,7 +123,7 @@ namespace internal { // Depending on the value of a char (or wchar_t), we print it in one // of three formats: // - as is if it's a printable ASCII (e.g. 'a', '2', ' '), -// - as a hexidecimal escape sequence (e.g. '\x7F'), or +// - as a hexadecimal escape sequence (e.g. '\x7F'), or // - as a special escape sequence (e.g. '\r', '\n'). enum CharFormat { kAsIs, @@ -176,7 +180,10 @@ static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) { *os << static_cast<char>(c); return kAsIs; } else { - *os << "\\x" + String::FormatHexInt(static_cast<UnsignedChar>(c)); + ostream::fmtflags flags = os->flags(); + *os << "\\x" << std::hex << std::uppercase + << static_cast<int>(static_cast<UnsignedChar>(c)); + os->flags(flags); return kHexEscape; } } @@ -223,7 +230,7 @@ void PrintCharAndCodeTo(Char c, ostream* os) { return; *os << " (" << static_cast<int>(c); - // For more convenience, we print c's code again in hexidecimal, + // For more convenience, we print c's code again in hexadecimal, // unless c was already printed in the form '\x##' or the code is in // [1, 9]. if (format == kHexEscape || (1 <= c && c <= 9)) { @@ -252,11 +259,15 @@ void PrintTo(wchar_t wc, ostream* os) { // The array starts at begin, the length is len, it may include '\0' characters // and may not be NUL-terminated. template <typename CharType> -static void PrintCharsAsStringTo( +GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +static CharFormat PrintCharsAsStringTo( const CharType* begin, size_t len, ostream* os) { const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; *os << kQuoteBegin; bool is_previous_hex = false; + CharFormat print_format = kAsIs; for (size_t index = 0; index < len; ++index) { const CharType cur = begin[index]; if (is_previous_hex && IsXDigit(cur)) { @@ -266,13 +277,21 @@ static void PrintCharsAsStringTo( *os << "\" " << kQuoteBegin; } is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; + // Remember if any characters required hex escaping. + if (is_previous_hex) { + print_format = kHexEscape; + } } *os << "\""; + return print_format; } // Prints a (const) char/wchar_t array of 'len' elements, starting at address // 'begin'. CharType must be either char or wchar_t. template <typename CharType> +GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ static void UniversalPrintCharArray( const CharType* begin, size_t len, ostream* os) { // The code @@ -329,20 +348,95 @@ void PrintTo(const wchar_t* s, ostream* os) { *os << "NULL"; } else { *os << ImplicitCast_<const void*>(s) << " pointing to "; - PrintCharsAsStringTo(s, wcslen(s), os); + PrintCharsAsStringTo(s, std::wcslen(s), os); } } #endif // wchar_t is native +namespace { + +bool ContainsUnprintableControlCodes(const char* str, size_t length) { + const unsigned char *s = reinterpret_cast<const unsigned char *>(str); + + for (size_t i = 0; i < length; i++) { + unsigned char ch = *s++; + if (std::iscntrl(ch)) { + switch (ch) { + case '\t': + case '\n': + case '\r': + break; + default: + return true; + } + } + } + return false; +} + +bool IsUTF8TrailByte(unsigned char t) { return 0x80 <= t && t<= 0xbf; } + +bool IsValidUTF8(const char* str, size_t length) { + const unsigned char *s = reinterpret_cast<const unsigned char *>(str); + + for (size_t i = 0; i < length;) { + unsigned char lead = s[i++]; + + if (lead <= 0x7f) { + continue; // single-byte character (ASCII) 0..7F + } + if (lead < 0xc2) { + return false; // trail byte or non-shortest form + } else if (lead <= 0xdf && (i + 1) <= length && IsUTF8TrailByte(s[i])) { + ++i; // 2-byte character + } else if (0xe0 <= lead && lead <= 0xef && (i + 2) <= length && + IsUTF8TrailByte(s[i]) && + IsUTF8TrailByte(s[i + 1]) && + // check for non-shortest form and surrogate + (lead != 0xe0 || s[i] >= 0xa0) && + (lead != 0xed || s[i] < 0xa0)) { + i += 2; // 3-byte character + } else if (0xf0 <= lead && lead <= 0xf4 && (i + 3) <= length && + IsUTF8TrailByte(s[i]) && + IsUTF8TrailByte(s[i + 1]) && + IsUTF8TrailByte(s[i + 2]) && + // check for non-shortest form + (lead != 0xf0 || s[i] >= 0x90) && + (lead != 0xf4 || s[i] < 0x90)) { + i += 3; // 4-byte character + } else { + return false; + } + } + return true; +} + +void ConditionalPrintAsText(const char* str, size_t length, ostream* os) { + if (!ContainsUnprintableControlCodes(str, length) && + IsValidUTF8(str, length)) { + *os << "\n As Text: \"" << str << "\""; + } +} + +} // anonymous namespace + // Prints a ::string object. #if GTEST_HAS_GLOBAL_STRING void PrintStringTo(const ::string& s, ostream* os) { - PrintCharsAsStringTo(s.data(), s.size(), os); + if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { + if (GTEST_FLAG(print_utf8)) { + ConditionalPrintAsText(s.data(), s.size(), os); + } + } } #endif // GTEST_HAS_GLOBAL_STRING void PrintStringTo(const ::std::string& s, ostream* os) { - PrintCharsAsStringTo(s.data(), s.size(), os); + if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { + if (GTEST_FLAG(print_utf8)) { + ConditionalPrintAsText(s.data(), s.size(), os); + } + } } // Prints a ::wstring object. diff --git a/src/test/fmw/gtest/src/gtest-test-part.cc b/src/test/fmw/gtest/src/gtest-test-part.cc index c60eef3ab35..c88860d9238 100644 --- a/src/test/fmw/gtest/src/gtest-test-part.cc +++ b/src/test/fmw/gtest/src/gtest-test-part.cc @@ -26,21 +26,12 @@ // 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. + // -// Author: mheule@google.com (Markus Heule) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) #include "gtest/gtest-test-part.h" - -// Indicates that this translation unit is part of Google Test's -// implementation. It must come before gtest-internal-inl.h is -// included, or there will be a compiler error. This trick is to -// prevent a user from accidentally including gtest-internal-inl.h in -// his code. -#define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" -#undef GTEST_IMPLEMENTATION_ namespace testing { diff --git a/src/test/fmw/gtest/src/gtest-typed-test.cc b/src/test/fmw/gtest/src/gtest-typed-test.cc index f0079f407c5..1dc2ad38bab 100644 --- a/src/test/fmw/gtest/src/gtest-typed-test.cc +++ b/src/test/fmw/gtest/src/gtest-typed-test.cc @@ -26,10 +26,10 @@ // 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. -// -// Author: wan@google.com (Zhanyong Wan) + #include "gtest/gtest-typed-test.h" + #include "gtest/gtest.h" namespace testing { @@ -45,33 +45,41 @@ static const char* SkipSpaces(const char* str) { return str; } +static std::vector<std::string> SplitIntoTestNames(const char* src) { + std::vector<std::string> name_vec; + src = SkipSpaces(src); + for (; src != NULL; src = SkipComma(src)) { + name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src))); + } + return name_vec; +} + // Verifies that registered_tests match the test names in -// defined_test_names_; returns registered_tests if successful, or +// registered_tests_; returns registered_tests if successful, or // aborts the program otherwise. const char* TypedTestCasePState::VerifyRegisteredTestNames( const char* file, int line, const char* registered_tests) { - typedef ::std::set<const char*>::const_iterator DefinedTestIter; + typedef RegisteredTestsMap::const_iterator RegisteredTestIter; registered_ = true; - // Skip initial whitespace in registered_tests since some - // preprocessors prefix stringizied literals with whitespace. - registered_tests = SkipSpaces(registered_tests); + std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests); Message errors; - ::std::set<std::string> tests; - for (const char* names = registered_tests; names != NULL; - names = SkipComma(names)) { - const std::string name = GetPrefixUntilComma(names); + + std::set<std::string> tests; + for (std::vector<std::string>::const_iterator name_it = name_vec.begin(); + name_it != name_vec.end(); ++name_it) { + const std::string& name = *name_it; if (tests.count(name) != 0) { errors << "Test " << name << " is listed more than once.\n"; continue; } bool found = false; - for (DefinedTestIter it = defined_test_names_.begin(); - it != defined_test_names_.end(); + for (RegisteredTestIter it = registered_tests_.begin(); + it != registered_tests_.end(); ++it) { - if (name == *it) { + if (name == it->first) { found = true; break; } @@ -85,11 +93,11 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames( } } - for (DefinedTestIter it = defined_test_names_.begin(); - it != defined_test_names_.end(); + for (RegisteredTestIter it = registered_tests_.begin(); + it != registered_tests_.end(); ++it) { - if (tests.count(*it) == 0) { - errors << "You forgot to list test " << *it << ".\n"; + if (tests.count(it->first) == 0) { + errors << "You forgot to list test " << it->first << ".\n"; } } diff --git a/src/test/fmw/gtest/src/gtest.cc b/src/test/fmw/gtest/src/gtest.cc index 4c4ee86fe39..2270e08c2ca 100644 --- a/src/test/fmw/gtest/src/gtest.cc +++ b/src/test/fmw/gtest/src/gtest.cc @@ -26,12 +26,12 @@ // 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. + // -// Author: wan@google.com (Zhanyong Wan) -// -// The Google C++ Testing Framework (Google Test) +// The Google C++ Testing and Mocking Framework (Google Test) #include "gtest/gtest.h" +#include "gtest/internal/custom/gtest.h" #include "gtest/gtest-spi.h" #include <ctype.h> @@ -46,6 +46,8 @@ #include <algorithm> #include <iomanip> #include <limits> +#include <list> +#include <map> #include <ostream> // NOLINT #include <sstream> #include <vector> @@ -55,7 +57,7 @@ #if GTEST_OS_LINUX -// TODO(kenton@google.com): Use autoconf to detect availability of +// FIXME: Use autoconf to detect availability of // gettimeofday(). # define GTEST_HAS_GETTIMEOFDAY_ 1 @@ -83,6 +85,7 @@ #elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE. # include <windows.h> // NOLINT +# undef min #elif GTEST_OS_WINDOWS // We are on Windows proper. @@ -93,9 +96,9 @@ # if GTEST_OS_WINDOWS_MINGW // MinGW has gettimeofday() but not _ftime64(). -// TODO(kenton@google.com): Use autoconf to detect availability of +// FIXME: Use autoconf to detect availability of // gettimeofday(). -// TODO(kenton@google.com): There are other ways to get the time on +// FIXME: There are other ways to get the time on // Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW // supports these. consider using them instead. # define GTEST_HAS_GETTIMEOFDAY_ 1 @@ -105,11 +108,12 @@ // cpplint thinks that the header is already included, so we want to // silence it. # include <windows.h> // NOLINT +# undef min #else // Assume other platforms have gettimeofday(). -// TODO(kenton@google.com): Use autoconf to detect availability of +// FIXME: Use autoconf to detect availability of // gettimeofday(). # define GTEST_HAS_GETTIMEOFDAY_ 1 @@ -127,21 +131,29 @@ #if GTEST_CAN_STREAM_RESULTS_ # include <arpa/inet.h> // NOLINT # include <netdb.h> // NOLINT +# include <sys/socket.h> // NOLINT +# include <sys/types.h> // NOLINT #endif -// Indicates that this translation unit is part of Google Test's -// implementation. It must come before gtest-internal-inl.h is -// included, or there will be a compiler error. This trick is to -// prevent a user from accidentally including gtest-internal-inl.h in -// his code. -#define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" -#undef GTEST_IMPLEMENTATION_ #if GTEST_OS_WINDOWS # define vsnprintf _vsnprintf #endif // GTEST_OS_WINDOWS +#if GTEST_OS_MAC +#ifndef GTEST_OS_IOS +#include <crt_externs.h> +#endif +#endif + +#if GTEST_HAS_ABSL +#include "absl/debugging/failure_signal_handler.h" +#include "absl/debugging/stacktrace.h" +#include "absl/debugging/symbolize.h" +#include "absl/strings/str_cat.h" +#endif // GTEST_HAS_ABSL + namespace testing { using internal::CountIf; @@ -163,8 +175,10 @@ static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*"; // A test filter that matches everything. static const char kUniversalFilter[] = "*"; -// The default output file for XML output. -static const char kDefaultOutputFile[] = "test_detail.xml"; +// The default output format. +static const char kDefaultOutputFormat[] = "xml"; +// The default output file. +static const char kDefaultOutputFile[] = "test_detail"; // The environment variable name for the test shard index. static const char kTestShardIndex[] = "GTEST_SHARD_INDEX"; @@ -183,9 +197,31 @@ const char kStackTraceMarker[] = "\nStack trace:\n"; // specified on the command line. bool g_help_flag = false; +// Utilty function to Open File for Writing +static FILE* OpenFileForWriting(const std::string& output_file) { + FILE* fileout = NULL; + FilePath output_file_path(output_file); + FilePath output_dir(output_file_path.RemoveFileName()); + + if (output_dir.CreateDirectoriesRecursively()) { + fileout = posix::FOpen(output_file.c_str(), "w"); + } + if (fileout == NULL) { + GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file << "\""; + } + return fileout; +} + } // namespace internal +// Bazel passes in the argument to '--test_filter' via the TESTBRIDGE_TEST_ONLY +// environment variable. static const char* GetDefaultFilter() { + const char* const testbridge_test_only = + internal::posix::GetEnv("TESTBRIDGE_TEST_ONLY"); + if (testbridge_test_only != NULL) { + return testbridge_test_only; + } return kUniversalFilter; } @@ -222,15 +258,28 @@ GTEST_DEFINE_string_( "exclude). A test is run if it matches one of the positive " "patterns and does not match any of the negative patterns."); +GTEST_DEFINE_bool_( + install_failure_signal_handler, + internal::BoolFromGTestEnv("install_failure_signal_handler", false), + "If true and supported on the current platform, " GTEST_NAME_ " should " + "install a signal handler that dumps debugging information when fatal " + "signals are raised."); + GTEST_DEFINE_bool_(list_tests, false, "List all tests without running them."); +// The net priority order after flag processing is thus: +// --gtest_output command line flag +// GTEST_OUTPUT environment variable +// XML_OUTPUT_FILE environment variable +// '' GTEST_DEFINE_string_( output, - internal::StringFromGTestEnv("output", ""), - "A format (currently must be \"xml\"), optionally followed " - "by a colon and an output file name or directory. A directory " - "is indicated by a trailing pathname separator. " + internal::StringFromGTestEnv("output", + internal::OutputFlagAlsoCheckEnvVar().c_str()), + "A format (defaults to \"xml\" but can be specified to be \"json\"), " + "optionally followed by a colon and an output file name or directory. " + "A directory is indicated by a trailing pathname separator. " "Examples: \"xml:filename.xml\", \"xml::directoryname/\". " "If a directory is specified, output files will be created " "within that directory, with file-names based on the test " @@ -243,6 +292,12 @@ GTEST_DEFINE_bool_( "True iff " GTEST_NAME_ " should display elapsed time in text output."); +GTEST_DEFINE_bool_( + print_utf8, + internal::BoolFromGTestEnv("print_utf8", true), + "True iff " GTEST_NAME_ + " prints UTF8 characters as text."); + GTEST_DEFINE_int32_( random_seed, internal::Int32FromGTestEnv("random_seed", 0), @@ -284,7 +339,14 @@ GTEST_DEFINE_bool_( internal::BoolFromGTestEnv("throw_on_failure", false), "When this flag is specified, a failed assertion will throw an exception " "if exceptions are enabled or exit the program with a non-zero code " - "otherwise."); + "otherwise. For use with an external test framework."); + +#if GTEST_USE_OWN_FLAGFILE_FLAG_ +GTEST_DEFINE_string_( + flagfile, + internal::StringFromGTestEnv("flagfile", ""), + "This flag specifies the flagfile to read command-line flags from."); +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ namespace internal { @@ -293,7 +355,8 @@ namespace internal { // than kMaxRange. UInt32 Random::Generate(UInt32 range) { // These constants are the same as are used in glibc's rand(3). - state_ = (1103515245U*state_ + 12345U) % kMaxRange; + // Use wider types than necessary to prevent unsigned overflow diagnostics. + state_ = static_cast<UInt32>(1103515245ULL*state_ + 12345U) % kMaxRange; GTEST_CHECK_(range > 0) << "Cannot generate a number in the range [0, 0)."; @@ -310,13 +373,7 @@ UInt32 Random::Generate(UInt32 range) { // GTestIsInitialized() returns true iff the user has initialized // Google Test. Useful for catching the user mistake of not initializing // Google Test before calling RUN_ALL_TESTS(). -// -// A user must call testing::InitGoogleTest() to initialize Google -// Test. g_init_gtest_count is set to the number of times -// InitGoogleTest() has been called. We don't protect this variable -// under a mutex as it is only accessed in the main thread. -GTEST_API_ int g_init_gtest_count = 0; -static bool GTestIsInitialized() { return g_init_gtest_count != 0; } +static bool GTestIsInitialized() { return GetArgvs().size() > 0; } // Iterates over a vector of TestCases, keeping a running sum of the // results of calling a given int-returning method on each. @@ -372,8 +429,19 @@ void AssertHelper::operator=(const Message& message) const { // Mutex for linked pointers. GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex); -// Application pathname gotten in InitGoogleTest. -std::string g_executable_path; +// A copy of all command line arguments. Set by InitGoogleTest(). +static ::std::vector<std::string> g_argvs; + +::std::vector<std::string> GetArgvs() { +#if defined(GTEST_CUSTOM_GET_ARGVS_) + // GTEST_CUSTOM_GET_ARGVS_() may return a container of std::string or + // ::string. This code converts it to the appropriate type. + const auto& custom = GTEST_CUSTOM_GET_ARGVS_(); + return ::std::vector<std::string>(custom.begin(), custom.end()); +#else // defined(GTEST_CUSTOM_GET_ARGVS_) + return g_argvs; +#endif // defined(GTEST_CUSTOM_GET_ARGVS_) +} // Returns the current application's name, removing directory path if that // is present. @@ -381,9 +449,9 @@ FilePath GetCurrentExecutableName() { FilePath result; #if GTEST_OS_WINDOWS - result.Set(FilePath(g_executable_path).RemoveExtension("exe")); + result.Set(FilePath(GetArgvs()[0]).RemoveExtension("exe")); #else - result.Set(FilePath(g_executable_path)); + result.Set(FilePath(GetArgvs()[0])); #endif // GTEST_OS_WINDOWS return result.RemoveDirectoryName(); @@ -394,8 +462,6 @@ FilePath GetCurrentExecutableName() { // Returns the output format, or "" for normal printed output. std::string UnitTestOptions::GetOutputFormat() { const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); - if (gtest_output_flag == NULL) return std::string(""); - const char* const colon = strchr(gtest_output_flag, ':'); return (colon == NULL) ? std::string(gtest_output_flag) : @@ -406,19 +472,22 @@ std::string UnitTestOptions::GetOutputFormat() { // was explicitly specified. std::string UnitTestOptions::GetAbsolutePathToOutputFile() { const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); - if (gtest_output_flag == NULL) - return ""; + + std::string format = GetOutputFormat(); + if (format.empty()) + format = std::string(kDefaultOutputFormat); const char* const colon = strchr(gtest_output_flag, ':'); if (colon == NULL) - return internal::FilePath::ConcatPaths( + return internal::FilePath::MakeFileName( internal::FilePath( UnitTest::GetInstance()->original_working_dir()), - internal::FilePath(kDefaultOutputFile)).string(); + internal::FilePath(kDefaultOutputFile), 0, + format.c_str()).string(); internal::FilePath output_name(colon + 1); if (!output_name.IsAbsolutePath()) - // TODO(wan@google.com): on Windows \some\path is not an absolute + // FIXME: on Windows \some\path is not an absolute // path (as its meaning depends on the current drive), yet the // following logic for turning it into an absolute path is wrong. // Fix it. @@ -609,12 +678,12 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); // This predicate-formatter checks that 'results' contains a test part // failure of the given type and that the failure message contains the // given substring. -AssertionResult HasOneFailure(const char* /* results_expr */, - const char* /* type_expr */, - const char* /* substr_expr */, - const TestPartResultArray& results, - TestPartResult::Type type, - const string& substr) { +static AssertionResult HasOneFailure(const char* /* results_expr */, + const char* /* type_expr */, + const char* /* substr_expr */, + const TestPartResultArray& results, + TestPartResult::Type type, + const std::string& substr) { const std::string expected(type == TestPartResult::kFatalFailure ? "1 fatal failure" : "1 non-fatal failure"); @@ -648,13 +717,10 @@ AssertionResult HasOneFailure(const char* /* results_expr */, // The constructor of SingleFailureChecker remembers where to look up // test part results, what type of failure we expect, and what // substring the failure message should contain. -SingleFailureChecker:: SingleFailureChecker( - const TestPartResultArray* results, - TestPartResult::Type type, - const string& substr) - : results_(results), - type_(type), - substr_(substr) {} +SingleFailureChecker::SingleFailureChecker(const TestPartResultArray* results, + TestPartResult::Type type, + const std::string& substr) + : results_(results), type_(type), substr_(substr) {} // The destructor of SingleFailureChecker verifies that the given // TestPartResultArray contains exactly one failure that has the given @@ -775,8 +841,12 @@ int UnitTestImpl::test_to_run_count() const { // CurrentOsStackTraceExceptTop(1), Foo() will be included in the // trace but Bar() and CurrentOsStackTraceExceptTop() won't. std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) { - (void)skip_count; - return ""; + return os_stack_trace_getter()->CurrentStackTrace( + static_cast<int>(GTEST_FLAG(stack_trace_depth)), + skip_count + 1 + // Skips the user-specified number of frames plus this function + // itself. + ); // NOLINT } // Returns the current time in milliseconds. @@ -791,7 +861,7 @@ TimeInMillis GetTimeInMillis() { SYSTEMTIME now_systime; FILETIME now_filetime; ULARGE_INTEGER now_int64; - // TODO(kenton@google.com): Shouldn't this just use + // FIXME: Shouldn't this just use // GetSystemTimeAsFileTime()? GetSystemTime(&now_systime); if (SystemTimeToFileTime(&now_systime, &now_filetime)) { @@ -805,21 +875,13 @@ TimeInMillis GetTimeInMillis() { #elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_ __timeb64 now; -# ifdef _MSC_VER - // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996 // (deprecated function) there. - // TODO(kenton@google.com): Use GetTickCount()? Or use + // FIXME: Use GetTickCount()? Or use // SystemTimeToFileTime() -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4996) // Temporarily disables warning 4996. + GTEST_DISABLE_MSC_DEPRECATED_PUSH_() _ftime64(&now); -# pragma warning(pop) // Restores the warning state. -# else - - _ftime64(&now); - -# endif // _MSC_VER + GTEST_DISABLE_MSC_DEPRECATED_POP_() return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm; #elif GTEST_HAS_GETTIMEOFDAY_ @@ -904,6 +966,23 @@ static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length, #endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING +void SplitString(const ::std::string& str, char delimiter, + ::std::vector< ::std::string>* dest) { + ::std::vector< ::std::string> parsed; + ::std::string::size_type pos = 0; + while (::testing::internal::AlwaysTrue()) { + const ::std::string::size_type colon = str.find(delimiter, pos); + if (colon == ::std::string::npos) { + parsed.push_back(str.substr(pos)); + break; + } else { + parsed.push_back(str.substr(pos, colon - pos)); + pos = colon + 1; + } + } + dest->swap(parsed); +} + } // namespace internal // Constructs an empty Message. @@ -959,6 +1038,13 @@ AssertionResult::AssertionResult(const AssertionResult& other) static_cast< ::std::string*>(NULL)) { } +// Swaps two AssertionResults. +void AssertionResult::swap(AssertionResult& other) { + using std::swap; + swap(success_, other.success_); + swap(message_, other.message_); +} + // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. AssertionResult AssertionResult::operator!() const { AssertionResult negation(!success_); @@ -985,6 +1071,276 @@ AssertionResult AssertionFailure(const Message& message) { namespace internal { +namespace edit_distance { +std::vector<EditType> CalculateOptimalEdits(const std::vector<size_t>& left, + const std::vector<size_t>& right) { + std::vector<std::vector<double> > costs( + left.size() + 1, std::vector<double>(right.size() + 1)); + std::vector<std::vector<EditType> > best_move( + left.size() + 1, std::vector<EditType>(right.size() + 1)); + + // Populate for empty right. + for (size_t l_i = 0; l_i < costs.size(); ++l_i) { + costs[l_i][0] = static_cast<double>(l_i); + best_move[l_i][0] = kRemove; + } + // Populate for empty left. + for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) { + costs[0][r_i] = static_cast<double>(r_i); + best_move[0][r_i] = kAdd; + } + + for (size_t l_i = 0; l_i < left.size(); ++l_i) { + for (size_t r_i = 0; r_i < right.size(); ++r_i) { + if (left[l_i] == right[r_i]) { + // Found a match. Consume it. + costs[l_i + 1][r_i + 1] = costs[l_i][r_i]; + best_move[l_i + 1][r_i + 1] = kMatch; + continue; + } + + const double add = costs[l_i + 1][r_i]; + const double remove = costs[l_i][r_i + 1]; + const double replace = costs[l_i][r_i]; + if (add < remove && add < replace) { + costs[l_i + 1][r_i + 1] = add + 1; + best_move[l_i + 1][r_i + 1] = kAdd; + } else if (remove < add && remove < replace) { + costs[l_i + 1][r_i + 1] = remove + 1; + best_move[l_i + 1][r_i + 1] = kRemove; + } else { + // We make replace a little more expensive than add/remove to lower + // their priority. + costs[l_i + 1][r_i + 1] = replace + 1.00001; + best_move[l_i + 1][r_i + 1] = kReplace; + } + } + } + + // Reconstruct the best path. We do it in reverse order. + std::vector<EditType> best_path; + for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) { + EditType move = best_move[l_i][r_i]; + best_path.push_back(move); + l_i -= move != kAdd; + r_i -= move != kRemove; + } + std::reverse(best_path.begin(), best_path.end()); + return best_path; +} + +namespace { + +// Helper class to convert string into ids with deduplication. +class InternalStrings { + public: + size_t GetId(const std::string& str) { + IdMap::iterator it = ids_.find(str); + if (it != ids_.end()) return it->second; + size_t id = ids_.size(); + return ids_[str] = id; + } + + private: + typedef std::map<std::string, size_t> IdMap; + IdMap ids_; +}; + +} // namespace + +std::vector<EditType> CalculateOptimalEdits( + const std::vector<std::string>& left, + const std::vector<std::string>& right) { + std::vector<size_t> left_ids, right_ids; + { + InternalStrings intern_table; + for (size_t i = 0; i < left.size(); ++i) { + left_ids.push_back(intern_table.GetId(left[i])); + } + for (size_t i = 0; i < right.size(); ++i) { + right_ids.push_back(intern_table.GetId(right[i])); + } + } + return CalculateOptimalEdits(left_ids, right_ids); +} + +namespace { + +// Helper class that holds the state for one hunk and prints it out to the +// stream. +// It reorders adds/removes when possible to group all removes before all +// adds. It also adds the hunk header before printint into the stream. +class Hunk { + public: + Hunk(size_t left_start, size_t right_start) + : left_start_(left_start), + right_start_(right_start), + adds_(), + removes_(), + common_() {} + + void PushLine(char edit, const char* line) { + switch (edit) { + case ' ': + ++common_; + FlushEdits(); + hunk_.push_back(std::make_pair(' ', line)); + break; + case '-': + ++removes_; + hunk_removes_.push_back(std::make_pair('-', line)); + break; + case '+': + ++adds_; + hunk_adds_.push_back(std::make_pair('+', line)); + break; + } + } + + void PrintTo(std::ostream* os) { + PrintHeader(os); + FlushEdits(); + for (std::list<std::pair<char, const char*> >::const_iterator it = + hunk_.begin(); + it != hunk_.end(); ++it) { + *os << it->first << it->second << "\n"; + } + } + + bool has_edits() const { return adds_ || removes_; } + + private: + void FlushEdits() { + hunk_.splice(hunk_.end(), hunk_removes_); + hunk_.splice(hunk_.end(), hunk_adds_); + } + + // Print a unified diff header for one hunk. + // The format is + // "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@" + // where the left/right parts are omitted if unnecessary. + void PrintHeader(std::ostream* ss) const { + *ss << "@@ "; + if (removes_) { + *ss << "-" << left_start_ << "," << (removes_ + common_); + } + if (removes_ && adds_) { + *ss << " "; + } + if (adds_) { + *ss << "+" << right_start_ << "," << (adds_ + common_); + } + *ss << " @@\n"; + } + + size_t left_start_, right_start_; + size_t adds_, removes_, common_; + std::list<std::pair<char, const char*> > hunk_, hunk_adds_, hunk_removes_; +}; + +} // namespace + +// Create a list of diff hunks in Unified diff format. +// Each hunk has a header generated by PrintHeader above plus a body with +// lines prefixed with ' ' for no change, '-' for deletion and '+' for +// addition. +// 'context' represents the desired unchanged prefix/suffix around the diff. +// If two hunks are close enough that their contexts overlap, then they are +// joined into one hunk. +std::string CreateUnifiedDiff(const std::vector<std::string>& left, + const std::vector<std::string>& right, + size_t context) { + const std::vector<EditType> edits = CalculateOptimalEdits(left, right); + + size_t l_i = 0, r_i = 0, edit_i = 0; + std::stringstream ss; + while (edit_i < edits.size()) { + // Find first edit. + while (edit_i < edits.size() && edits[edit_i] == kMatch) { + ++l_i; + ++r_i; + ++edit_i; + } + + // Find the first line to include in the hunk. + const size_t prefix_context = std::min(l_i, context); + Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1); + for (size_t i = prefix_context; i > 0; --i) { + hunk.PushLine(' ', left[l_i - i].c_str()); + } + + // Iterate the edits until we found enough suffix for the hunk or the input + // is over. + size_t n_suffix = 0; + for (; edit_i < edits.size(); ++edit_i) { + if (n_suffix >= context) { + // Continue only if the next hunk is very close. + std::vector<EditType>::const_iterator it = edits.begin() + edit_i; + while (it != edits.end() && *it == kMatch) ++it; + if (it == edits.end() || (it - edits.begin()) - edit_i >= context) { + // There is no next edit or it is too far away. + break; + } + } + + EditType edit = edits[edit_i]; + // Reset count when a non match is found. + n_suffix = edit == kMatch ? n_suffix + 1 : 0; + + if (edit == kMatch || edit == kRemove || edit == kReplace) { + hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str()); + } + if (edit == kAdd || edit == kReplace) { + hunk.PushLine('+', right[r_i].c_str()); + } + + // Advance indices, depending on edit type. + l_i += edit != kAdd; + r_i += edit != kRemove; + } + + if (!hunk.has_edits()) { + // We are done. We don't want this hunk. + break; + } + + hunk.PrintTo(&ss); + } + return ss.str(); +} + +} // namespace edit_distance + +namespace { + +// The string representation of the values received in EqFailure() are already +// escaped. Split them on escaped '\n' boundaries. Leave all other escaped +// characters the same. +std::vector<std::string> SplitEscapedString(const std::string& str) { + std::vector<std::string> lines; + size_t start = 0, end = str.size(); + if (end > 2 && str[0] == '"' && str[end - 1] == '"') { + ++start; + --end; + } + bool escaped = false; + for (size_t i = start; i + 1 < end; ++i) { + if (escaped) { + escaped = false; + if (str[i] == 'n') { + lines.push_back(str.substr(start, i - start - 1)); + start = i + 1; + } + } else { + escaped = str[i] == '\\'; + } + } + lines.push_back(str.substr(start, end - start)); + return lines; +} + +} // namespace + // Constructs and returns the message for an equality assertion // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. // @@ -992,31 +1348,43 @@ namespace internal { // and their values, as strings. For example, for ASSERT_EQ(foo, bar) // where foo is 5 and bar is 6, we have: // -// expected_expression: "foo" -// actual_expression: "bar" -// expected_value: "5" -// actual_value: "6" +// lhs_expression: "foo" +// rhs_expression: "bar" +// lhs_value: "5" +// rhs_value: "6" // // The ignoring_case parameter is true iff the assertion is a -// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will +// *_STRCASEEQ*. When it's true, the string "Ignoring case" will // be inserted into the message. -AssertionResult EqFailure(const char* expected_expression, - const char* actual_expression, - const std::string& expected_value, - const std::string& actual_value, +AssertionResult EqFailure(const char* lhs_expression, + const char* rhs_expression, + const std::string& lhs_value, + const std::string& rhs_value, bool ignoring_case) { Message msg; - msg << "Value of: " << actual_expression; - if (actual_value != actual_expression) { - msg << "\n Actual: " << actual_value; + msg << "Expected equality of these values:"; + msg << "\n " << lhs_expression; + if (lhs_value != lhs_expression) { + msg << "\n Which is: " << lhs_value; + } + msg << "\n " << rhs_expression; + if (rhs_value != rhs_expression) { + msg << "\n Which is: " << rhs_value; } - msg << "\nExpected: " << expected_expression; if (ignoring_case) { - msg << " (ignoring case)"; + msg << "\nIgnoring case"; } - if (expected_value != expected_expression) { - msg << "\nWhich is: " << expected_value; + + if (!lhs_value.empty() && !rhs_value.empty()) { + const std::vector<std::string> lhs_lines = + SplitEscapedString(lhs_value); + const std::vector<std::string> rhs_lines = + SplitEscapedString(rhs_value); + if (lhs_lines.size() > 1 || rhs_lines.size() > 1) { + msg << "\nWith diff:\n" + << edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines); + } } return AssertionFailure() << msg; @@ -1048,7 +1416,7 @@ AssertionResult DoubleNearPredFormat(const char* expr1, const double diff = fabs(val1 - val2); if (diff <= abs_error) return AssertionSuccess(); - // TODO(wan): do not print the value of an expression if it's + // FIXME: do not print the value of an expression if it's // already a literal. return AssertionFailure() << "The difference between " << expr1 << " and " << expr2 @@ -1114,18 +1482,18 @@ namespace internal { // The helper function for {ASSERT|EXPECT}_EQ with int or enum // arguments. -AssertionResult CmpHelperEQ(const char* expected_expression, - const char* actual_expression, - BiggestInt expected, - BiggestInt actual) { - if (expected == actual) { +AssertionResult CmpHelperEQ(const char* lhs_expression, + const char* rhs_expression, + BiggestInt lhs, + BiggestInt rhs) { + if (lhs == rhs) { return AssertionSuccess(); } - return EqFailure(expected_expression, - actual_expression, - FormatForComparisonFailureMessage(expected, actual), - FormatForComparisonFailureMessage(actual, expected), + return EqFailure(lhs_expression, + rhs_expression, + FormatForComparisonFailureMessage(lhs, rhs), + FormatForComparisonFailureMessage(rhs, lhs), false); } @@ -1164,34 +1532,34 @@ GTEST_IMPL_CMP_HELPER_(GT, > ) #undef GTEST_IMPL_CMP_HELPER_ // The helper function for {ASSERT|EXPECT}_STREQ. -AssertionResult CmpHelperSTREQ(const char* expected_expression, - const char* actual_expression, - const char* expected, - const char* actual) { - if (String::CStringEquals(expected, actual)) { +AssertionResult CmpHelperSTREQ(const char* lhs_expression, + const char* rhs_expression, + const char* lhs, + const char* rhs) { + if (String::CStringEquals(lhs, rhs)) { return AssertionSuccess(); } - return EqFailure(expected_expression, - actual_expression, - PrintToString(expected), - PrintToString(actual), + return EqFailure(lhs_expression, + rhs_expression, + PrintToString(lhs), + PrintToString(rhs), false); } // The helper function for {ASSERT|EXPECT}_STRCASEEQ. -AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression, - const char* actual_expression, - const char* expected, - const char* actual) { - if (String::CaseInsensitiveCStringEquals(expected, actual)) { +AssertionResult CmpHelperSTRCASEEQ(const char* lhs_expression, + const char* rhs_expression, + const char* lhs, + const char* rhs) { + if (String::CaseInsensitiveCStringEquals(lhs, rhs)) { return AssertionSuccess(); } - return EqFailure(expected_expression, - actual_expression, - PrintToString(expected), - PrintToString(actual), + return EqFailure(lhs_expression, + rhs_expression, + PrintToString(lhs), + PrintToString(rhs), true); } @@ -1343,7 +1711,7 @@ namespace { AssertionResult HRESULTFailureHelper(const char* expr, const char* expected, long hr) { // NOLINT -# if GTEST_OS_WINDOWS_MOBILE +# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE // Windows CE doesn't support FormatMessage. const char error_text[] = ""; @@ -1400,7 +1768,7 @@ AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT // Utility functions for encoding Unicode text (wide strings) in // UTF-8. -// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8 +// A Unicode code-point can have up to 21 bits, and is encoded in UTF-8 // like this: // // Code-point length Encoding @@ -1464,7 +1832,7 @@ std::string CodePointToUtf8(UInt32 code_point) { return str; } -// The following two functions only make sense if the the system +// The following two functions only make sense if the system // uses UTF-16 for wide string encoding. All supported systems // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16. @@ -1546,18 +1914,18 @@ bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) { } // Helper function for *_STREQ on wide strings. -AssertionResult CmpHelperSTREQ(const char* expected_expression, - const char* actual_expression, - const wchar_t* expected, - const wchar_t* actual) { - if (String::WideCStringEquals(expected, actual)) { +AssertionResult CmpHelperSTREQ(const char* lhs_expression, + const char* rhs_expression, + const wchar_t* lhs, + const wchar_t* rhs) { + if (String::WideCStringEquals(lhs, rhs)) { return AssertionSuccess(); } - return EqFailure(expected_expression, - actual_expression, - PrintToString(expected), - PrintToString(actual), + return EqFailure(lhs_expression, + rhs_expression, + PrintToString(lhs), + PrintToString(rhs), false); } @@ -1776,13 +2144,8 @@ static const char* const kReservedTestSuiteAttributes[] = { // The list of reserved attributes used in the <testcase> element of XML output. static const char* const kReservedTestCaseAttributes[] = { - "classname", - "name", - "status", - "time", - "type_param", - "value_param" -}; + "classname", "name", "status", "time", + "type_param", "value_param", "file", "line"}; template <int kSize> std::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) { @@ -1818,8 +2181,9 @@ static std::string FormatWordList(const std::vector<std::string>& words) { return word_list.GetString(); } -bool ValidateTestPropertyName(const std::string& property_name, - const std::vector<std::string>& reserved_names) { +static bool ValidateTestPropertyName( + const std::string& property_name, + const std::vector<std::string>& reserved_names) { if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != reserved_names.end()) { ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name @@ -1890,14 +2254,15 @@ int TestResult::test_property_count() const { // Creates a Test object. -// The c'tor saves the values of all Google Test flags. +// The c'tor saves the states of all flags. Test::Test() - : gtest_flag_saver_(new internal::GTestFlagSaver) { + : gtest_flag_saver_(new GTEST_FLAG_SAVER_) { } -// The d'tor restores the values of all Google Test flags. +// The d'tor restores the states of all flags. The actual work is +// done by the d'tor of the gtest_flag_saver_ field, and thus not +// visible here. Test::~Test() { - delete gtest_flag_saver_; } // Sets up the test fixture. @@ -1966,8 +2331,8 @@ bool Test::HasSameFixtureClass() { const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId(); if (first_is_TEST || this_is_TEST) { - // The user mixed TEST and TEST_F in this test case - we'll tell - // him/her how to fix it. + // Both TEST and TEST_F appear in same test case, which is incorrect. + // Tell the user how to fix this. // Gets the name of the TEST and the name of the TEST_F. Note // that first_is_TEST and this_is_TEST cannot both be true, as @@ -1987,8 +2352,8 @@ bool Test::HasSameFixtureClass() { << "want to change the TEST to TEST_F or move it to another test\n" << "case."; } else { - // The user defined two fixture classes with the same name in - // two namespaces - we'll tell him/her how to fix it. + // Two fixture classes with the same name appear in two different + // namespaces, which is not allowed. Tell the user how to fix this. ADD_FAILURE() << "All tests in the same test case must use the same test fixture\n" << "class. However, in test case " @@ -2115,6 +2480,8 @@ Result HandleExceptionsInMethodIfSupported( #if GTEST_HAS_EXCEPTIONS try { return HandleSehExceptionsInMethodIfSupported(object, method, location); + } catch (const AssertionException&) { // NOLINT + // This failure was reported already. } catch (const internal::GoogleTestFailureException&) { // NOLINT // This exception type can only be thrown by a failed Google // Test assertion with the intention of letting another testing @@ -2181,12 +2548,14 @@ TestInfo::TestInfo(const std::string& a_test_case_name, const std::string& a_name, const char* a_type_param, const char* a_value_param, + internal::CodeLocation a_code_location, internal::TypeId fixture_class_id, internal::TestFactoryBase* factory) : test_case_name_(a_test_case_name), name_(a_name), type_param_(a_type_param ? new std::string(a_type_param) : NULL), value_param_(a_value_param ? new std::string(a_value_param) : NULL), + location_(a_code_location), fixture_class_id_(fixture_class_id), should_run_(false), is_disabled_(false), @@ -2210,6 +2579,7 @@ namespace internal { // this is not a typed or a type-parameterized test. // value_param: text representation of the test's value parameter, // or NULL if this is not a value-parameterized test. +// code_location: code location where the test is defined // fixture_class_id: ID of the test fixture class // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case @@ -2221,20 +2591,20 @@ TestInfo* MakeAndRegisterTestInfo( const char* name, const char* type_param, const char* value_param, + CodeLocation code_location, TypeId fixture_class_id, SetUpTestCaseFunc set_up_tc, TearDownTestCaseFunc tear_down_tc, TestFactoryBase* factory) { TestInfo* const test_info = new TestInfo(test_case_name, name, type_param, value_param, - fixture_class_id, factory); + code_location, fixture_class_id, factory); GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info); return test_info; } -#if GTEST_HAS_PARAM_TEST void ReportInvalidTestCaseType(const char* test_case_name, - const char* file, int line) { + CodeLocation code_location) { Message errors; errors << "Attempted redefinition of test case " << test_case_name << ".\n" @@ -2246,11 +2616,10 @@ void ReportInvalidTestCaseType(const char* test_case_name, << "probably rename one of the classes to put the tests into different\n" << "test cases."; - fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), - errors.GetString().c_str()); + GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file, + code_location.line) + << " " << errors.GetString(); } -#endif // GTEST_HAS_PARAM_TEST - } // namespace internal namespace { @@ -2288,12 +2657,10 @@ namespace internal { // and INSTANTIATE_TEST_CASE_P into regular tests and registers those. // This will be done just once during the program runtime. void UnitTestImpl::RegisterParameterizedTests() { -#if GTEST_HAS_PARAM_TEST if (!parameterized_tests_registered_) { parameterized_test_registry_.RegisterTests(); parameterized_tests_registered_ = true; } -#endif } } // namespace internal @@ -2321,18 +2688,18 @@ void TestInfo::Run() { factory_, &internal::TestFactoryBase::CreateTest, "the test fixture's constructor"); - // Runs the test only if the test object was created and its - // constructor didn't generate a fatal failure. - if ((test != NULL) && !Test::HasFatalFailure()) { + // Runs the test if the constructor didn't generate a fatal failure. + // Note that the object will not be null + if (!Test::HasFatalFailure()) { // This doesn't throw as all user code that can throw are wrapped into // exception handling code. test->Run(); } - // Deletes the test object. - impl->os_stack_trace_getter()->UponLeavingGTest(); - internal::HandleExceptionsInMethodIfSupported( - test, &Test::DeleteSelf_, "the test fixture's destructor"); + // Deletes the test object. + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported( + test, &Test::DeleteSelf_, "the test fixture's destructor"); result_.set_elapsed_time(internal::GetTimeInMillis() - start); @@ -2557,10 +2924,11 @@ enum GTestColor { COLOR_YELLOW }; -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ + !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW // Returns the character attribute for the given color. -WORD GetColorAttribute(GTestColor color) { +static WORD GetColorAttribute(GTestColor color) { switch (color) { case COLOR_RED: return FOREGROUND_RED; case COLOR_GREEN: return FOREGROUND_GREEN; @@ -2569,11 +2937,42 @@ WORD GetColorAttribute(GTestColor color) { } } +static int GetBitOffset(WORD color_mask) { + if (color_mask == 0) return 0; + + int bitOffset = 0; + while ((color_mask & 1) == 0) { + color_mask >>= 1; + ++bitOffset; + } + return bitOffset; +} + +static WORD GetNewColor(GTestColor color, WORD old_color_attrs) { + // Let's reuse the BG + static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | + BACKGROUND_RED | BACKGROUND_INTENSITY; + static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | + FOREGROUND_RED | FOREGROUND_INTENSITY; + const WORD existing_bg = old_color_attrs & background_mask; + + WORD new_color = + GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY; + static const int bg_bitOffset = GetBitOffset(background_mask); + static const int fg_bitOffset = GetBitOffset(foreground_mask); + + if (((new_color & background_mask) >> bg_bitOffset) == + ((new_color & foreground_mask) >> fg_bitOffset)) { + new_color ^= FOREGROUND_INTENSITY; // invert intensity + } + return new_color; +} + #else // Returns the ANSI color code for the given color. COLOR_DEFAULT is // an invalid input. -const char* GetAnsiColorCode(GTestColor color) { +static const char* GetAnsiColorCode(GTestColor color) { switch (color) { case COLOR_RED: return "1"; case COLOR_GREEN: return "2"; @@ -2589,7 +2988,7 @@ bool ShouldUseColor(bool stdout_is_tty) { const char* const gtest_color = GTEST_FLAG(color).c_str(); if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { -#if GTEST_OS_WINDOWS +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW // On Windows the TERM variable is usually not set, but the // console there does support colors. return stdout_is_tty; @@ -2602,6 +3001,10 @@ bool ShouldUseColor(bool stdout_is_tty) { String::CStringEquals(term, "xterm-256color") || String::CStringEquals(term, "screen") || String::CStringEquals(term, "screen-256color") || + String::CStringEquals(term, "tmux") || + String::CStringEquals(term, "tmux-256color") || + String::CStringEquals(term, "rxvt-unicode") || + String::CStringEquals(term, "rxvt-unicode-256color") || String::CStringEquals(term, "linux") || String::CStringEquals(term, "cygwin"); return stdout_is_tty && term_supports_color; @@ -2621,12 +3024,13 @@ bool ShouldUseColor(bool stdout_is_tty) { // cannot simply emit special characters and have the terminal change colors. // This routine must actually emit the characters rather than return a string // that would be colored when printed, as can be done on Linux. -void ColoredPrintf(GTestColor color, const char* fmt, ...) { +static void ColoredPrintf(GTestColor color, const char* fmt, ...) { va_list args; va_start(args, fmt); -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS - const bool use_color = false; +#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || \ + GTEST_OS_IOS || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT + const bool use_color = AlwaysFalse(); #else static const bool in_color_mode = ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0); @@ -2640,20 +3044,22 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { return; } -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ + !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); // Gets the current text color. CONSOLE_SCREEN_BUFFER_INFO buffer_info; GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); const WORD old_color_attrs = buffer_info.wAttributes; + const WORD new_color = GetNewColor(color, old_color_attrs); // We need to flush the stream buffers into the console before each // SetConsoleTextAttribute call lest it affect the text that is already // printed but has not yet reached the console. fflush(stdout); - SetConsoleTextAttribute(stdout_handle, - GetColorAttribute(color) | FOREGROUND_INTENSITY); + SetConsoleTextAttribute(stdout_handle, new_color); + vprintf(fmt, args); fflush(stdout); @@ -2667,12 +3073,12 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { va_end(args); } -// Text printed in Google Test's text output and --gunit_list_tests +// Text printed in Google Test's text output and --gtest_list_tests // output to label the type parameter and value parameter for a test. static const char kTypeParamLabel[] = "TypeParam"; static const char kValueParamLabel[] = "GetParam()"; -void PrintFullTestCommentIfPresent(const TestInfo& test_info) { +static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { const char* const type_param = test_info.type_param(); const char* const value_param = test_info.value_param(); @@ -2943,7 +3349,7 @@ void TestEventRepeater::Append(TestEventListener *listener) { listeners_.push_back(listener); } -// TODO(vladl@google.com): Factor the search functionality into Vector::Find. +// FIXME: Factor the search functionality into Vector::Find. TestEventListener* TestEventRepeater::Release(TestEventListener *listener) { for (size_t i = 0; i < listeners_.size(); ++i) { if (listeners_[i] == listener) { @@ -3017,6 +3423,11 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { explicit XmlUnitTestResultPrinter(const char* output_file); virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); + void ListTestsMatchingFilter(const std::vector<TestCase*>& test_cases); + + // Prints an XML summary of all unit tests. + static void PrintXmlTestsList(std::ostream* stream, + const std::vector<TestCase*>& test_cases); private: // Is c a whitespace character that is normalized to a space character @@ -3078,6 +3489,11 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { // to delimit this attribute from prior attributes. static std::string TestPropertiesAsXmlAttributes(const TestResult& result); + // Streams an XML representation of the test properties of a TestResult + // object. + static void OutputXmlTestProperties(std::ostream* stream, + const TestResult& result); + // The output file. const std::string output_file_; @@ -3087,46 +3503,30 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { // Creates a new XmlUnitTestResultPrinter. XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) : output_file_(output_file) { - if (output_file_.c_str() == NULL || output_file_.empty()) { - fprintf(stderr, "XML output file may not be null\n"); - fflush(stderr); - exit(EXIT_FAILURE); + if (output_file_.empty()) { + GTEST_LOG_(FATAL) << "XML output file may not be null"; } } // Called after the unit test ends. void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, int /*iteration*/) { - FILE* xmlout = NULL; - FilePath output_file(output_file_); - FilePath output_dir(output_file.RemoveFileName()); - - if (output_dir.CreateDirectoriesRecursively()) { - xmlout = posix::FOpen(output_file_.c_str(), "w"); - } - if (xmlout == NULL) { - // TODO(wan): report the reason of the failure. - // - // We don't do it for now as: - // - // 1. There is no urgent need for it. - // 2. It's a bit involved to make the errno variable thread-safe on - // all three operating systems (Linux, Windows, and Mac OS). - // 3. To interpret the meaning of errno in a thread-safe way, - // we need the strerror_r() function, which is not available on - // Windows. - fprintf(stderr, - "Unable to open file \"%s\"\n", - output_file_.c_str()); - fflush(stderr); - exit(EXIT_FAILURE); - } + FILE* xmlout = OpenFileForWriting(output_file_); std::stringstream stream; PrintXmlUnitTest(&stream, unit_test); fprintf(xmlout, "%s", StringStreamToString(&stream).c_str()); fclose(xmlout); } +void XmlUnitTestResultPrinter::ListTestsMatchingFilter( + const std::vector<TestCase*>& test_cases) { + FILE* xmlout = OpenFileForWriting(output_file_); + std::stringstream stream; + PrintXmlTestsList(&stream, test_cases); + fprintf(xmlout, "%s", StringStreamToString(&stream).c_str()); + fclose(xmlout); +} + // Returns an XML-escaped copy of the input string str. If is_attribute // is true, the text is meant to appear as an attribute value, and // normalizable whitespace is preserved by replacing it with character @@ -3137,7 +3537,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, // module will consist of ordinary English text. // If this module is ever modified to produce version 1.1 XML output, // most invalid characters can be retained using character references. -// TODO(wan): It might be nice to have a minimally invasive, human-readable +// FIXME: It might be nice to have a minimally invasive, human-readable // escaping scheme for invalid characters, rather than dropping them. std::string XmlUnitTestResultPrinter::EscapeXml( const std::string& str, bool is_attribute) { @@ -3198,6 +3598,7 @@ std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( // The following routines generate an XML representation of a UnitTest // object. +// GOOGLETEST_CM0009 DO NOT DELETE // // This is how Google Test concepts map to the DTD: // @@ -3215,34 +3616,39 @@ std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( // Formats the given time in milliseconds as seconds. std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) { ::std::stringstream ss; - ss << ms/1000.0; + ss << (static_cast<double>(ms) * 1e-3); return ss.str(); } -// Converts the given epoch time in milliseconds to a date string in the ISO -// 8601 format, without the timezone information. -std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) { - // Using non-reentrant version as localtime_r is not portable. - time_t seconds = static_cast<time_t>(ms / 1000); -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4996) // Temporarily disables warning 4996 - // (function or variable may be unsafe). - const struct tm* const time_struct = localtime(&seconds); // NOLINT -# pragma warning(pop) // Restores the warning state again. +static bool PortableLocaltime(time_t seconds, struct tm* out) { +#if defined(_MSC_VER) + return localtime_s(out, &seconds) == 0; +#elif defined(__MINGW32__) || defined(__MINGW64__) + // MINGW <time.h> provides neither localtime_r nor localtime_s, but uses + // Windows' localtime(), which has a thread-local tm buffer. + struct tm* tm_ptr = localtime(&seconds); // NOLINT + if (tm_ptr == NULL) + return false; + *out = *tm_ptr; + return true; #else - const struct tm* const time_struct = localtime(&seconds); // NOLINT + return localtime_r(&seconds, out) != NULL; #endif - if (time_struct == NULL) - return ""; // Invalid ms value +} +// Converts the given epoch time in milliseconds to a date string in the ISO +// 8601 format, without the timezone information. +std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) { + struct tm time_struct; + if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct)) + return ""; // YYYY-MM-DDThh:mm:ss - return StreamableToString(time_struct->tm_year + 1900) + "-" + - String::FormatIntWidth2(time_struct->tm_mon + 1) + "-" + - String::FormatIntWidth2(time_struct->tm_mday) + "T" + - String::FormatIntWidth2(time_struct->tm_hour) + ":" + - String::FormatIntWidth2(time_struct->tm_min) + ":" + - String::FormatIntWidth2(time_struct->tm_sec); + return StreamableToString(time_struct.tm_year + 1900) + "-" + + String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" + + String::FormatIntWidth2(time_struct.tm_mday) + "T" + + String::FormatIntWidth2(time_struct.tm_hour) + ":" + + String::FormatIntWidth2(time_struct.tm_min) + ":" + + String::FormatIntWidth2(time_struct.tm_sec); } // Streams an XML CDATA section, escaping invalid CDATA sequences as needed. @@ -3282,13 +3688,17 @@ void XmlUnitTestResultPrinter::OutputXmlAttribute( } // Prints an XML representation of a TestInfo object. -// TODO(wan): There is also value in printing properties with the plain printer. +// FIXME: There is also value in printing properties with the plain printer. void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, const char* test_case_name, const TestInfo& test_info) { const TestResult& result = *test_info.result(); const std::string kTestcase = "testcase"; + if (test_info.is_in_another_shard()) { + return; + } + *stream << " <testcase"; OutputXmlAttribute(stream, kTestcase, "name", test_info.name()); @@ -3299,13 +3709,19 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, if (test_info.type_param() != NULL) { OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param()); } + if (GTEST_FLAG(list_tests)) { + OutputXmlAttribute(stream, kTestcase, "file", test_info.file()); + OutputXmlAttribute(stream, kTestcase, "line", + StreamableToString(test_info.line())); + *stream << " />\n"; + return; + } OutputXmlAttribute(stream, kTestcase, "status", test_info.should_run() ? "run" : "notrun"); OutputXmlAttribute(stream, kTestcase, "time", FormatTimeInMillisAsSeconds(result.elapsed_time())); OutputXmlAttribute(stream, kTestcase, "classname", test_case_name); - *stream << TestPropertiesAsXmlAttributes(result); int failures = 0; for (int i = 0; i < result.total_part_count(); ++i) { @@ -3314,22 +3730,28 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, if (++failures == 1) { *stream << ">\n"; } - const string location = internal::FormatCompilerIndependentFileLocation( - part.file_name(), part.line_number()); - const string summary = location + "\n" + part.summary(); + const std::string location = + internal::FormatCompilerIndependentFileLocation(part.file_name(), + part.line_number()); + const std::string summary = location + "\n" + part.summary(); *stream << " <failure message=\"" << EscapeXmlAttribute(summary.c_str()) << "\" type=\"\">"; - const string detail = location + "\n" + part.message(); + const std::string detail = location + "\n" + part.message(); OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str()); *stream << "</failure>\n"; } } - if (failures == 0) + if (failures == 0 && result.test_property_count() == 0) { *stream << " />\n"; - else + } else { + if (failures == 0) { + *stream << ">\n"; + } + OutputXmlTestProperties(stream, result); *stream << " </testcase>\n"; + } } // Prints an XML representation of a TestCase object @@ -3340,17 +3762,18 @@ void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream, OutputXmlAttribute(stream, kTestsuite, "name", test_case.name()); OutputXmlAttribute(stream, kTestsuite, "tests", StreamableToString(test_case.reportable_test_count())); - OutputXmlAttribute(stream, kTestsuite, "failures", - StreamableToString(test_case.failed_test_count())); - OutputXmlAttribute( - stream, kTestsuite, "disabled", - StreamableToString(test_case.reportable_disabled_test_count())); - OutputXmlAttribute(stream, kTestsuite, "errors", "0"); - OutputXmlAttribute(stream, kTestsuite, "time", - FormatTimeInMillisAsSeconds(test_case.elapsed_time())); - *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result()) - << ">\n"; - + if (!GTEST_FLAG(list_tests)) { + OutputXmlAttribute(stream, kTestsuite, "failures", + StreamableToString(test_case.failed_test_count())); + OutputXmlAttribute( + stream, kTestsuite, "disabled", + StreamableToString(test_case.reportable_disabled_test_count())); + OutputXmlAttribute(stream, kTestsuite, "errors", "0"); + OutputXmlAttribute(stream, kTestsuite, "time", + FormatTimeInMillisAsSeconds(test_case.elapsed_time())); + *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result()); + } + *stream << ">\n"; for (int i = 0; i < test_case.total_test_count(); ++i) { if (test_case.GetTestInfo(i)->is_reportable()) OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i)); @@ -3384,7 +3807,6 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, OutputXmlAttribute(stream, kTestsuites, "random_seed", StreamableToString(unit_test.random_seed())); } - *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); @@ -3397,6 +3819,28 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, *stream << "</" << kTestsuites << ">\n"; } +void XmlUnitTestResultPrinter::PrintXmlTestsList( + std::ostream* stream, const std::vector<TestCase*>& test_cases) { + const std::string kTestsuites = "testsuites"; + + *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + *stream << "<" << kTestsuites; + + int total_tests = 0; + for (size_t i = 0; i < test_cases.size(); ++i) { + total_tests += test_cases[i]->total_test_count(); + } + OutputXmlAttribute(stream, kTestsuites, "tests", + StreamableToString(total_tests)); + OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); + *stream << ">\n"; + + for (size_t i = 0; i < test_cases.size(); ++i) { + PrintXmlTestCase(stream, *test_cases[i]); + } + *stream << "</" << kTestsuites << ">\n"; +} + // Produces a string representing the test properties in a result as space // delimited XML attributes based on the property key="value" pairs. std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( @@ -3410,8 +3854,390 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( return attributes.GetString(); } +void XmlUnitTestResultPrinter::OutputXmlTestProperties( + std::ostream* stream, const TestResult& result) { + const std::string kProperties = "properties"; + const std::string kProperty = "property"; + + if (result.test_property_count() <= 0) { + return; + } + + *stream << "<" << kProperties << ">\n"; + for (int i = 0; i < result.test_property_count(); ++i) { + const TestProperty& property = result.GetTestProperty(i); + *stream << "<" << kProperty; + *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\""; + *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\""; + *stream << "/>\n"; + } + *stream << "</" << kProperties << ">\n"; +} + // End XmlUnitTestResultPrinter +// This class generates an JSON output file. +class JsonUnitTestResultPrinter : public EmptyTestEventListener { + public: + explicit JsonUnitTestResultPrinter(const char* output_file); + + virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); + + // Prints an JSON summary of all unit tests. + static void PrintJsonTestList(::std::ostream* stream, + const std::vector<TestCase*>& test_cases); + + private: + // Returns an JSON-escaped copy of the input string str. + static std::string EscapeJson(const std::string& str); + + //// Verifies that the given attribute belongs to the given element and + //// streams the attribute as JSON. + static void OutputJsonKey(std::ostream* stream, + const std::string& element_name, + const std::string& name, + const std::string& value, + const std::string& indent, + bool comma = true); + static void OutputJsonKey(std::ostream* stream, + const std::string& element_name, + const std::string& name, + int value, + const std::string& indent, + bool comma = true); + + // Streams a JSON representation of a TestInfo object. + static void OutputJsonTestInfo(::std::ostream* stream, + const char* test_case_name, + const TestInfo& test_info); + + // Prints a JSON representation of a TestCase object + static void PrintJsonTestCase(::std::ostream* stream, + const TestCase& test_case); + + // Prints a JSON summary of unit_test to output stream out. + static void PrintJsonUnitTest(::std::ostream* stream, + const UnitTest& unit_test); + + // Produces a string representing the test properties in a result as + // a JSON dictionary. + static std::string TestPropertiesAsJson(const TestResult& result, + const std::string& indent); + + // The output file. + const std::string output_file_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter); +}; + +// Creates a new JsonUnitTestResultPrinter. +JsonUnitTestResultPrinter::JsonUnitTestResultPrinter(const char* output_file) + : output_file_(output_file) { + if (output_file_.empty()) { + GTEST_LOG_(FATAL) << "JSON output file may not be null"; + } +} + +void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, + int /*iteration*/) { + FILE* jsonout = OpenFileForWriting(output_file_); + std::stringstream stream; + PrintJsonUnitTest(&stream, unit_test); + fprintf(jsonout, "%s", StringStreamToString(&stream).c_str()); + fclose(jsonout); +} + +// Returns an JSON-escaped copy of the input string str. +std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) { + Message m; + + for (size_t i = 0; i < str.size(); ++i) { + const char ch = str[i]; + switch (ch) { + case '\\': + case '"': + case '/': + m << '\\' << ch; + break; + case '\b': + m << "\\b"; + break; + case '\t': + m << "\\t"; + break; + case '\n': + m << "\\n"; + break; + case '\f': + m << "\\f"; + break; + case '\r': + m << "\\r"; + break; + default: + if (ch < ' ') { + m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch)); + } else { + m << ch; + } + break; + } + } + + return m.GetString(); +} + +// The following routines generate an JSON representation of a UnitTest +// object. + +// Formats the given time in milliseconds as seconds. +static std::string FormatTimeInMillisAsDuration(TimeInMillis ms) { + ::std::stringstream ss; + ss << (static_cast<double>(ms) * 1e-3) << "s"; + return ss.str(); +} + +// Converts the given epoch time in milliseconds to a date string in the +// RFC3339 format, without the timezone information. +static std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms) { + struct tm time_struct; + if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct)) + return ""; + // YYYY-MM-DDThh:mm:ss + return StreamableToString(time_struct.tm_year + 1900) + "-" + + String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" + + String::FormatIntWidth2(time_struct.tm_mday) + "T" + + String::FormatIntWidth2(time_struct.tm_hour) + ":" + + String::FormatIntWidth2(time_struct.tm_min) + ":" + + String::FormatIntWidth2(time_struct.tm_sec) + "Z"; +} + +static inline std::string Indent(int width) { + return std::string(width, ' '); +} + +void JsonUnitTestResultPrinter::OutputJsonKey( + std::ostream* stream, + const std::string& element_name, + const std::string& name, + const std::string& value, + const std::string& indent, + bool comma) { + const std::vector<std::string>& allowed_names = + GetReservedAttributesForElement(element_name); + + GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != + allowed_names.end()) + << "Key \"" << name << "\" is not allowed for value \"" << element_name + << "\"."; + + *stream << indent << "\"" << name << "\": \"" << EscapeJson(value) << "\""; + if (comma) + *stream << ",\n"; +} + +void JsonUnitTestResultPrinter::OutputJsonKey( + std::ostream* stream, + const std::string& element_name, + const std::string& name, + int value, + const std::string& indent, + bool comma) { + const std::vector<std::string>& allowed_names = + GetReservedAttributesForElement(element_name); + + GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != + allowed_names.end()) + << "Key \"" << name << "\" is not allowed for value \"" << element_name + << "\"."; + + *stream << indent << "\"" << name << "\": " << StreamableToString(value); + if (comma) + *stream << ",\n"; +} + +// Prints a JSON representation of a TestInfo object. +void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream, + const char* test_case_name, + const TestInfo& test_info) { + const TestResult& result = *test_info.result(); + const std::string kTestcase = "testcase"; + const std::string kIndent = Indent(10); + + *stream << Indent(8) << "{\n"; + OutputJsonKey(stream, kTestcase, "name", test_info.name(), kIndent); + + if (test_info.value_param() != NULL) { + OutputJsonKey(stream, kTestcase, "value_param", + test_info.value_param(), kIndent); + } + if (test_info.type_param() != NULL) { + OutputJsonKey(stream, kTestcase, "type_param", test_info.type_param(), + kIndent); + } + if (GTEST_FLAG(list_tests)) { + OutputJsonKey(stream, kTestcase, "file", test_info.file(), kIndent); + OutputJsonKey(stream, kTestcase, "line", test_info.line(), kIndent, false); + *stream << "\n" << Indent(8) << "}"; + return; + } + + OutputJsonKey(stream, kTestcase, "status", + test_info.should_run() ? "RUN" : "NOTRUN", kIndent); + OutputJsonKey(stream, kTestcase, "time", + FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent); + OutputJsonKey(stream, kTestcase, "classname", test_case_name, kIndent, false); + *stream << TestPropertiesAsJson(result, kIndent); + + int failures = 0; + for (int i = 0; i < result.total_part_count(); ++i) { + const TestPartResult& part = result.GetTestPartResult(i); + if (part.failed()) { + *stream << ",\n"; + if (++failures == 1) { + *stream << kIndent << "\"" << "failures" << "\": [\n"; + } + const std::string location = + internal::FormatCompilerIndependentFileLocation(part.file_name(), + part.line_number()); + const std::string message = EscapeJson(location + "\n" + part.message()); + *stream << kIndent << " {\n" + << kIndent << " \"failure\": \"" << message << "\",\n" + << kIndent << " \"type\": \"\"\n" + << kIndent << " }"; + } + } + + if (failures > 0) + *stream << "\n" << kIndent << "]"; + *stream << "\n" << Indent(8) << "}"; +} + +// Prints an JSON representation of a TestCase object +void JsonUnitTestResultPrinter::PrintJsonTestCase(std::ostream* stream, + const TestCase& test_case) { + const std::string kTestsuite = "testsuite"; + const std::string kIndent = Indent(6); + + *stream << Indent(4) << "{\n"; + OutputJsonKey(stream, kTestsuite, "name", test_case.name(), kIndent); + OutputJsonKey(stream, kTestsuite, "tests", test_case.reportable_test_count(), + kIndent); + if (!GTEST_FLAG(list_tests)) { + OutputJsonKey(stream, kTestsuite, "failures", test_case.failed_test_count(), + kIndent); + OutputJsonKey(stream, kTestsuite, "disabled", + test_case.reportable_disabled_test_count(), kIndent); + OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent); + OutputJsonKey(stream, kTestsuite, "time", + FormatTimeInMillisAsDuration(test_case.elapsed_time()), + kIndent, false); + *stream << TestPropertiesAsJson(test_case.ad_hoc_test_result(), kIndent) + << ",\n"; + } + + *stream << kIndent << "\"" << kTestsuite << "\": [\n"; + + bool comma = false; + for (int i = 0; i < test_case.total_test_count(); ++i) { + if (test_case.GetTestInfo(i)->is_reportable()) { + if (comma) { + *stream << ",\n"; + } else { + comma = true; + } + OutputJsonTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i)); + } + } + *stream << "\n" << kIndent << "]\n" << Indent(4) << "}"; +} + +// Prints a JSON summary of unit_test to output stream out. +void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream, + const UnitTest& unit_test) { + const std::string kTestsuites = "testsuites"; + const std::string kIndent = Indent(2); + *stream << "{\n"; + + OutputJsonKey(stream, kTestsuites, "tests", unit_test.reportable_test_count(), + kIndent); + OutputJsonKey(stream, kTestsuites, "failures", unit_test.failed_test_count(), + kIndent); + OutputJsonKey(stream, kTestsuites, "disabled", + unit_test.reportable_disabled_test_count(), kIndent); + OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent); + if (GTEST_FLAG(shuffle)) { + OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(), + kIndent); + } + OutputJsonKey(stream, kTestsuites, "timestamp", + FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()), + kIndent); + OutputJsonKey(stream, kTestsuites, "time", + FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent, + false); + + *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent) + << ",\n"; + + OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent); + *stream << kIndent << "\"" << kTestsuites << "\": [\n"; + + bool comma = false; + for (int i = 0; i < unit_test.total_test_case_count(); ++i) { + if (unit_test.GetTestCase(i)->reportable_test_count() > 0) { + if (comma) { + *stream << ",\n"; + } else { + comma = true; + } + PrintJsonTestCase(stream, *unit_test.GetTestCase(i)); + } + } + + *stream << "\n" << kIndent << "]\n" << "}\n"; +} + +void JsonUnitTestResultPrinter::PrintJsonTestList( + std::ostream* stream, const std::vector<TestCase*>& test_cases) { + const std::string kTestsuites = "testsuites"; + const std::string kIndent = Indent(2); + *stream << "{\n"; + int total_tests = 0; + for (size_t i = 0; i < test_cases.size(); ++i) { + total_tests += test_cases[i]->total_test_count(); + } + OutputJsonKey(stream, kTestsuites, "tests", total_tests, kIndent); + + OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent); + *stream << kIndent << "\"" << kTestsuites << "\": [\n"; + + for (size_t i = 0; i < test_cases.size(); ++i) { + if (i != 0) { + *stream << ",\n"; + } + PrintJsonTestCase(stream, *test_cases[i]); + } + + *stream << "\n" + << kIndent << "]\n" + << "}\n"; +} +// Produces a string representing the test properties in a result as +// a JSON dictionary. +std::string JsonUnitTestResultPrinter::TestPropertiesAsJson( + const TestResult& result, const std::string& indent) { + Message attributes; + for (int i = 0; i < result.test_property_count(); ++i) { + const TestProperty& property = result.GetTestProperty(i); + attributes << ",\n" << indent << "\"" << property.key() << "\": " + << "\"" << EscapeJson(property.value()) << "\""; + } + return attributes.GetString(); +} + +// End JsonUnitTestResultPrinter + #if GTEST_CAN_STREAM_RESULTS_ // Checks if str contains '=', '&', '%' or '\n' characters. If yes, @@ -3419,8 +4245,8 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( // example, replaces "=" with "%3D". This algorithm is O(strlen(str)) // in both time and space -- important as the input str may contain an // arbitrarily long test failure message and stack trace. -string StreamingListener::UrlEncode(const char* str) { - string result; +std::string StreamingListener::UrlEncode(const char* str) { + std::string result; result.reserve(strlen(str) + 1); for (char ch = *str; ch != '\0'; ch = *++str) { switch (ch) { @@ -3482,58 +4308,82 @@ void StreamingListener::SocketWriter::MakeConnection() { // End of class Streaming Listener #endif // GTEST_CAN_STREAM_RESULTS__ -// Class ScopedTrace +// class OsStackTraceGetter -// Pushes the given source file location and message onto a per-thread -// trace stack maintained by Google Test. -ScopedTrace::ScopedTrace(const char* file, int line, const Message& message) - GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { - TraceInfo trace; - trace.file = file; - trace.line = line; - trace.message = message.GetString(); +const char* const OsStackTraceGetterInterface::kElidedFramesMarker = + "... " GTEST_NAME_ " internal frames ..."; - UnitTest::GetInstance()->PushGTestTrace(trace); -} +std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) + GTEST_LOCK_EXCLUDED_(mutex_) { +#if GTEST_HAS_ABSL + std::string result; -// Pops the info pushed by the c'tor. -ScopedTrace::~ScopedTrace() - GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { - UnitTest::GetInstance()->PopGTestTrace(); -} + if (max_depth <= 0) { + return result; + } + max_depth = std::min(max_depth, kMaxStackTraceDepth); -// class OsStackTraceGetter + std::vector<void*> raw_stack(max_depth); + // Skips the frames requested by the caller, plus this function. + const int raw_stack_size = + absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1); -// Returns the current OS stack trace as an std::string. Parameters: -// -// max_depth - the maximum number of stack frames to be included -// in the trace. -// skip_count - the number of top frames to be skipped; doesn't count -// against max_depth. -// -string OsStackTraceGetter::CurrentStackTrace(int /* max_depth */, - int /* skip_count */) - GTEST_LOCK_EXCLUDED_(mutex_) { + void* caller_frame = nullptr; + { + MutexLock lock(&mutex_); + caller_frame = caller_frame_; + } + + for (int i = 0; i < raw_stack_size; ++i) { + if (raw_stack[i] == caller_frame && + !GTEST_FLAG(show_internal_stack_frames)) { + // Add a marker to the trace and stop adding frames. + absl::StrAppend(&result, kElidedFramesMarker, "\n"); + break; + } + + char tmp[1024]; + const char* symbol = "(unknown)"; + if (absl::Symbolize(raw_stack[i], tmp, sizeof(tmp))) { + symbol = tmp; + } + + char line[1024]; + snprintf(line, sizeof(line), " %p: %s\n", raw_stack[i], symbol); + result += line; + } + + return result; + +#else // !GTEST_HAS_ABSL + static_cast<void>(max_depth); + static_cast<void>(skip_count); return ""; +#endif // GTEST_HAS_ABSL } -void OsStackTraceGetter::UponLeavingGTest() - GTEST_LOCK_EXCLUDED_(mutex_) { -} +void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { +#if GTEST_HAS_ABSL + void* caller_frame = nullptr; + if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) { + caller_frame = nullptr; + } -const char* const -OsStackTraceGetter::kElidedFramesMarker = - "... " GTEST_NAME_ " internal frames ..."; + MutexLock lock(&mutex_); + caller_frame_ = caller_frame; +#endif // GTEST_HAS_ABSL +} // A helper class that creates the premature-exit file in its // constructor and deletes the file in its destructor. class ScopedPrematureExitFile { public: explicit ScopedPrematureExitFile(const char* premature_exit_filepath) - : premature_exit_filepath_(premature_exit_filepath) { + : premature_exit_filepath_(premature_exit_filepath ? + premature_exit_filepath : "") { // If a path to the premature-exit file is specified... - if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') { + if (!premature_exit_filepath_.empty()) { // create the file with a single "0" character in it. I/O // errors are ignored as there's nothing better we can do and we // don't want to fail the test because of this. @@ -3544,13 +4394,18 @@ class ScopedPrematureExitFile { } ~ScopedPrematureExitFile() { - if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') { - remove(premature_exit_filepath_); + if (!premature_exit_filepath_.empty()) { + int retval = remove(premature_exit_filepath_.c_str()); + if (retval) { + GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \"" + << premature_exit_filepath_ << "\" with error " + << retval; + } } } private: - const char* const premature_exit_filepath_; + const std::string premature_exit_filepath_; GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile); }; @@ -3815,11 +4670,16 @@ void UnitTest::AddTestPartResult( // with another testing framework) and specify the former on the // command line for debugging. if (GTEST_FLAG(break_on_failure)) { -#if GTEST_OS_WINDOWS +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT // Using DebugBreak on Windows allows gtest to still break into a debugger // when a failure happens and both the --gtest_break_on_failure and // the --gtest_catch_exceptions flags are specified. DebugBreak(); +#elif (!defined(__native_client__)) && \ + ((defined(__clang__) || defined(__GNUC__)) && \ + (defined(__x86_64__) || defined(__i386__))) + // with clang/gcc we can achieve the same effect on x86 by invoking int3 + asm("int3"); #else // Dereference NULL through a volatile pointer to prevent the compiler // from removing. We use this rather than abort() or __builtin_trap() for @@ -3887,13 +4747,13 @@ int UnitTest::Run() { // used for the duration of the program. impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions)); -#if GTEST_HAS_SEH +#if GTEST_OS_WINDOWS // Either the user wants Google Test to catch exceptions thrown by the // tests or this is executing in the context of death test child // process. In either case the user does not want to see pop-up dialogs // about crashes - they are expected. if (impl()->catch_exceptions() || in_death_test_child_process) { -# if !GTEST_OS_WINDOWS_MOBILE +# if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT // SetErrorMode doesn't exist on CE. SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); @@ -3916,7 +4776,7 @@ int UnitTest::Run() { // VC++ doesn't define _set_abort_behavior() prior to the version 8.0. // Users of prior VC versions shall suffer the agony and pain of // clicking through the countless debug dialogs. - // TODO(vladl@google.com): find a way to suppress the abort dialog() in the + // FIXME: find a way to suppress the abort dialog() in the // debug mode when compiled with VC 7.1 or lower. if (!GTEST_FLAG(break_on_failure)) _set_abort_behavior( @@ -3924,7 +4784,7 @@ int UnitTest::Run() { _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. # endif } -#endif // GTEST_HAS_SEH +#endif // GTEST_OS_WINDOWS return internal::HandleExceptionsInMethodIfSupported( impl(), @@ -3957,7 +4817,6 @@ const TestInfo* UnitTest::current_test_info() const // Returns the random seed used at the start of the current test run. int UnitTest::random_seed() const { return impl_->random_seed(); } -#if GTEST_HAS_PARAM_TEST // Returns ParameterizedTestCaseRegistry object used to keep track of // value-parameterized tests and instantiate and register them. internal::ParameterizedTestCaseRegistry& @@ -3965,7 +4824,6 @@ internal::ParameterizedTestCaseRegistry& GTEST_LOCK_EXCLUDED_(mutex_) { return impl_->parameterized_test_registry(); } -#endif // GTEST_HAS_PARAM_TEST // Creates an empty UnitTest. UnitTest::UnitTest() { @@ -3996,25 +4854,16 @@ namespace internal { UnitTestImpl::UnitTestImpl(UnitTest* parent) : parent_(parent), -#ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4355) // Temporarily disables warning 4355 - // (using this in initializer). - default_global_test_part_result_reporter_(this), - default_per_thread_test_part_result_reporter_(this), -# pragma warning(pop) // Restores the warning state again. -#else + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */) default_global_test_part_result_reporter_(this), default_per_thread_test_part_result_reporter_(this), -#endif // _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_POP_() global_test_part_result_repoter_( &default_global_test_part_result_reporter_), per_thread_test_part_result_reporter_( &default_per_thread_test_part_result_reporter_), -#if GTEST_HAS_PARAM_TEST parameterized_test_registry_(), parameterized_tests_registered_(false), -#endif // GTEST_HAS_PARAM_TEST last_death_test_case_(-1), current_test_case_(NULL), current_test_info_(NULL), @@ -4081,10 +4930,12 @@ void UnitTestImpl::ConfigureXmlOutput() { if (output_format == "xml") { listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); + } else if (output_format == "json") { + listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter( + UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); } else if (output_format != "") { - printf("WARNING: unrecognized output format \"%s\" ignored.\n", - output_format.c_str()); - fflush(stdout); + GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \"" + << output_format << "\" ignored."; } } @@ -4099,9 +4950,8 @@ void UnitTestImpl::ConfigureStreamingOutput() { listeners()->Append(new StreamingListener(target.substr(0, pos), target.substr(pos+1))); } else { - printf("WARNING: unrecognized streaming target \"%s\" ignored.\n", - target.c_str()); - fflush(stdout); + GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target + << "\" ignored."; } } } @@ -4117,6 +4967,11 @@ void UnitTestImpl::PostFlagParsingInit() { if (!post_flag_parse_init_performed_) { post_flag_parse_init_performed_ = true; +#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_) + // Register to send notifications about key process state changes. + listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_()); +#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_) + #if GTEST_HAS_DEATH_TEST InitDeathTestSubprocessControlInfo(); SuppressTestEventsIfInSubprocess(); @@ -4135,6 +4990,13 @@ void UnitTestImpl::PostFlagParsingInit() { // Configures listeners for streaming test results to the specified server. ConfigureStreamingOutput(); #endif // GTEST_CAN_STREAM_RESULTS_ + +#if GTEST_HAS_ABSL + if (GTEST_FLAG(install_failure_signal_handler)) { + absl::FailureSignalHandlerOptions options; + absl::InstallFailureSignalHandler(options); + } +#endif // GTEST_HAS_ABSL } } @@ -4178,11 +5040,11 @@ TestCase* UnitTestImpl::GetTestCase(const char* test_case_name, Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc) { // Can we find a TestCase with the given name? - const std::vector<TestCase*>::const_iterator test_case = - std::find_if(test_cases_.begin(), test_cases_.end(), + const std::vector<TestCase*>::reverse_iterator test_case = + std::find_if(test_cases_.rbegin(), test_cases_.rend(), TestCaseNameIs(test_case_name)); - if (test_case != test_cases_.end()) + if (test_case != test_cases_.rend()) return *test_case; // No. Let's create one. @@ -4223,13 +5085,8 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); } // All other functions called from RunAllTests() may safely assume that // parameterized tests are ready to be counted and run. bool UnitTestImpl::RunAllTests() { - // Makes sure InitGoogleTest() was called. - if (!GTestIsInitialized()) { - printf("%s", - "\nThis test program did NOT call ::testing::InitGoogleTest " - "before calling RUN_ALL_TESTS(). Please fix it.\n"); - return false; - } + // True iff Google Test is initialized before RUN_ALL_TESTS() is called. + const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized(); // Do not run any test if the --help flag was specified. if (g_help_flag) @@ -4250,6 +5107,11 @@ bool UnitTestImpl::RunAllTests() { #if GTEST_HAS_DEATH_TEST in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL); +# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) + if (in_subprocess_for_death_test) { + GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_(); + } +# endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) #endif // GTEST_HAS_DEATH_TEST const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex, @@ -4352,6 +5214,20 @@ bool UnitTestImpl::RunAllTests() { repeater->OnTestProgramEnd(*parent_); + if (!gtest_is_initialized_before_run_all_tests) { + ColoredPrintf( + COLOR_RED, + "\nIMPORTANT NOTICE - DO NOT IGNORE:\n" + "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_ + "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_ + " will start to enforce the valid usage. " + "Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT +#if GTEST_FOR_GOOGLE_ + ColoredPrintf(COLOR_RED, + "For more details, see http://wiki/Main/ValidGUnitMain.\n"); +#endif // GTEST_FOR_GOOGLE_ + } + return !failed; } @@ -4453,8 +5329,8 @@ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { // each TestCase and TestInfo object. // If shard_tests == true, further filters tests based on sharding // variables in the environment - see -// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide. -// Returns the number of tests that should run. +// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md +// . Returns the number of tests that should run. int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ? Int32FromEnvOrDie(kTestTotalShards, -1) : -1; @@ -4493,10 +5369,11 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) && matches_filter; - const bool is_selected = is_runnable && - (shard_tests == IGNORE_SHARDING_PROTOCOL || - ShouldRunTestOnShard(total_shards, shard_index, - num_runnable_tests)); + const bool is_in_another_shard = + shard_tests != IGNORE_SHARDING_PROTOCOL && + !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests); + test_info->is_in_another_shard_ = is_in_another_shard; + const bool is_selected = is_runnable && !is_in_another_shard; num_runnable_tests += is_runnable; num_selected_tests += is_selected; @@ -4566,6 +5443,23 @@ void UnitTestImpl::ListTestsMatchingFilter() { } } fflush(stdout); + const std::string& output_format = UnitTestOptions::GetOutputFormat(); + if (output_format == "xml" || output_format == "json") { + FILE* fileout = OpenFileForWriting( + UnitTestOptions::GetAbsolutePathToOutputFile().c_str()); + std::stringstream stream; + if (output_format == "xml") { + XmlUnitTestResultPrinter( + UnitTestOptions::GetAbsolutePathToOutputFile().c_str()) + .PrintXmlTestsList(&stream, test_cases_); + } else if (output_format == "json") { + JsonUnitTestResultPrinter( + UnitTestOptions::GetAbsolutePathToOutputFile().c_str()) + .PrintJsonTestList(&stream, test_cases_); + } + fprintf(fileout, "%s", StringStreamToString(&stream).c_str()); + fclose(fileout); + } } // Sets the OS stack trace getter. @@ -4586,17 +5480,25 @@ void UnitTestImpl::set_os_stack_trace_getter( // getter, and returns it. OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() { if (os_stack_trace_getter_ == NULL) { +#ifdef GTEST_OS_STACK_TRACE_GETTER_ + os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_; +#else os_stack_trace_getter_ = new OsStackTraceGetter; +#endif // GTEST_OS_STACK_TRACE_GETTER_ } return os_stack_trace_getter_; } -// Returns the TestResult for the test that's currently running, or -// the TestResult for the ad hoc test if no test is running. +// Returns the most specific TestResult currently running. TestResult* UnitTestImpl::current_test_result() { - return current_test_info_ ? - &(current_test_info_->result_) : &ad_hoc_test_result_; + if (current_test_info_ != NULL) { + return ¤t_test_info_->result_; + } + if (current_test_case_ != NULL) { + return ¤t_test_case_->ad_hoc_test_result_; + } + return &ad_hoc_test_result_; } // Shuffles all test cases, and the tests within each test case, @@ -4677,9 +5579,8 @@ bool SkipPrefix(const char* prefix, const char** pstr) { // part can be omitted. // // Returns the value of the flag, or NULL if the parsing failed. -const char* ParseFlagValue(const char* str, - const char* flag, - bool def_optional) { +static const char* ParseFlagValue(const char* str, const char* flag, + bool def_optional) { // str and flag must not be NULL. if (str == NULL || flag == NULL) return NULL; @@ -4715,7 +5616,7 @@ const char* ParseFlagValue(const char* str, // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. -bool ParseBoolFlag(const char* str, const char* flag, bool* value) { +static bool ParseBoolFlag(const char* str, const char* flag, bool* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, true); @@ -4749,7 +5650,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. -bool ParseStringFlag(const char* str, const char* flag, std::string* value) { +template <typename String> +/* static was removed to workaround SStudio bug 27279066 */ +bool ParseStringFlag(const char* str, const char* flag, String* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, false); @@ -4785,7 +5688,7 @@ static bool HasGoogleTestFlagPrefix(const char* str) { // @Y changes the color to yellow. // @D changes to the default terminal text color. // -// TODO(wan@google.com): Write tests for this once we add stdout +// FIXME: Write tests for this once we add stdout // capturing to Google Test. static void PrintColorEncoded(const char* str) { GTestColor color = COLOR_DEFAULT; // The current color. @@ -4851,24 +5754,25 @@ static const char kColorEncodedHelpMessage[] = " Enable/disable colored output. The default is @Gauto@D.\n" " -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n" " Don't print the elapsed time of each test.\n" -" @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G" +" @G--" GTEST_FLAG_PREFIX_ "output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G" GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n" -" Generate an XML report in the given directory or with the given file\n" -" name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" -#if GTEST_CAN_STREAM_RESULTS_ +" Generate a JSON or XML report in the given directory or with the given\n" +" file name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" +# if GTEST_CAN_STREAM_RESULTS_ " @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n" " Stream test results to the given server.\n" -#endif // GTEST_CAN_STREAM_RESULTS_ +# endif // GTEST_CAN_STREAM_RESULTS_ "\n" "Assertion Behavior:\n" -#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS +# if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS " @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n" " Set the default death test style.\n" -#endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS +# endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS " @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n" " Turn assertion failures into debugger break-points.\n" " @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n" -" Turn assertion failures into C++ exceptions.\n" +" Turn assertion failures into C++ exceptions for use by an external\n" +" test framework.\n" " @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n" " Do not report exceptions as test failures. Instead, allow them\n" " to crash the program or throw a pop-up (on Windows).\n" @@ -4885,6 +5789,56 @@ static const char kColorEncodedHelpMessage[] = "(not one in your own code or tests), please report it to\n" "@G<" GTEST_DEV_EMAIL_ ">@D.\n"; +static bool ParseGoogleTestFlag(const char* const arg) { + return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, + >EST_FLAG(also_run_disabled_tests)) || + ParseBoolFlag(arg, kBreakOnFailureFlag, + >EST_FLAG(break_on_failure)) || + ParseBoolFlag(arg, kCatchExceptionsFlag, + >EST_FLAG(catch_exceptions)) || + ParseStringFlag(arg, kColorFlag, >EST_FLAG(color)) || + ParseStringFlag(arg, kDeathTestStyleFlag, + >EST_FLAG(death_test_style)) || + ParseBoolFlag(arg, kDeathTestUseFork, + >EST_FLAG(death_test_use_fork)) || + ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) || + ParseStringFlag(arg, kInternalRunDeathTestFlag, + >EST_FLAG(internal_run_death_test)) || + ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) || + ParseStringFlag(arg, kOutputFlag, >EST_FLAG(output)) || + ParseBoolFlag(arg, kPrintTimeFlag, >EST_FLAG(print_time)) || + ParseBoolFlag(arg, kPrintUTF8Flag, >EST_FLAG(print_utf8)) || + ParseInt32Flag(arg, kRandomSeedFlag, >EST_FLAG(random_seed)) || + ParseInt32Flag(arg, kRepeatFlag, >EST_FLAG(repeat)) || + ParseBoolFlag(arg, kShuffleFlag, >EST_FLAG(shuffle)) || + ParseInt32Flag(arg, kStackTraceDepthFlag, + >EST_FLAG(stack_trace_depth)) || + ParseStringFlag(arg, kStreamResultToFlag, + >EST_FLAG(stream_result_to)) || + ParseBoolFlag(arg, kThrowOnFailureFlag, + >EST_FLAG(throw_on_failure)); +} + +#if GTEST_USE_OWN_FLAGFILE_FLAG_ +static void LoadFlagsFromFile(const std::string& path) { + FILE* flagfile = posix::FOpen(path.c_str(), "r"); + if (!flagfile) { + GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile) + << "\""; + } + std::string contents(ReadEntireFile(flagfile)); + posix::FClose(flagfile); + std::vector<std::string> lines; + SplitString(contents, '\n', &lines); + for (size_t i = 0; i < lines.size(); ++i) { + if (lines[i].empty()) + continue; + if (!ParseGoogleTestFlag(lines[i].c_str())) + g_help_flag = true; + } +} +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ + // Parses the command line for Google Test flags, without initializing // other parts of Google Test. The type parameter CharType can be // instantiated to either char or wchar_t. @@ -4898,35 +5852,24 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { using internal::ParseInt32Flag; using internal::ParseStringFlag; - // Do we see a Google Test flag? - if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, - >EST_FLAG(also_run_disabled_tests)) || - ParseBoolFlag(arg, kBreakOnFailureFlag, - >EST_FLAG(break_on_failure)) || - ParseBoolFlag(arg, kCatchExceptionsFlag, - >EST_FLAG(catch_exceptions)) || - ParseStringFlag(arg, kColorFlag, >EST_FLAG(color)) || - ParseStringFlag(arg, kDeathTestStyleFlag, - >EST_FLAG(death_test_style)) || - ParseBoolFlag(arg, kDeathTestUseFork, - >EST_FLAG(death_test_use_fork)) || - ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) || - ParseStringFlag(arg, kInternalRunDeathTestFlag, - >EST_FLAG(internal_run_death_test)) || - ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) || - ParseStringFlag(arg, kOutputFlag, >EST_FLAG(output)) || - ParseBoolFlag(arg, kPrintTimeFlag, >EST_FLAG(print_time)) || - ParseInt32Flag(arg, kRandomSeedFlag, >EST_FLAG(random_seed)) || - ParseInt32Flag(arg, kRepeatFlag, >EST_FLAG(repeat)) || - ParseBoolFlag(arg, kShuffleFlag, >EST_FLAG(shuffle)) || - ParseInt32Flag(arg, kStackTraceDepthFlag, - >EST_FLAG(stack_trace_depth)) || - ParseStringFlag(arg, kStreamResultToFlag, - >EST_FLAG(stream_result_to)) || - ParseBoolFlag(arg, kThrowOnFailureFlag, - >EST_FLAG(throw_on_failure)) - ) { - // Yes. Shift the remainder of the argv list left by one. Note + bool remove_flag = false; + if (ParseGoogleTestFlag(arg)) { + remove_flag = true; +#if GTEST_USE_OWN_FLAGFILE_FLAG_ + } else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) { + LoadFlagsFromFile(GTEST_FLAG(flagfile)); + remove_flag = true; +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ + } else if (arg_string == "--help" || arg_string == "-h" || + arg_string == "-?" || arg_string == "/?" || + HasGoogleTestFlagPrefix(arg)) { + // Both help flag and unrecognized Google Test flags (excluding + // internal ones) trigger help display. + g_help_flag = true; + } + + if (remove_flag) { + // Shift the remainder of the argv list left by one. Note // that argv has (*argc + 1) elements, the last one always being // NULL. The following loop moves the trailing NULL element as // well. @@ -4940,12 +5883,6 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { // We also need to decrement the iterator as we just removed // an element. i--; - } else if (arg_string == "--help" || arg_string == "-h" || - arg_string == "-?" || arg_string == "/?" || - HasGoogleTestFlagPrefix(arg)) { - // Both help flag and unrecognized Google Test flags (excluding - // internal ones) trigger help display. - g_help_flag = true; } } @@ -4961,6 +5898,17 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { // other parts of Google Test. void ParseGoogleTestFlagsOnly(int* argc, char** argv) { ParseGoogleTestFlagsOnlyImpl(argc, argv); + + // Fix the value of *_NSGetArgc() on macOS, but iff + // *_NSGetArgv() == argv + // Only applicable to char** version of argv +#if GTEST_OS_MAC +#ifndef GTEST_OS_IOS + if (*_NSGetArgv() == argv) { + *_NSGetArgc() = *argc; + } +#endif +#endif } void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) { ParseGoogleTestFlagsOnlyImpl(argc, argv); @@ -4972,23 +5920,19 @@ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) { // wchar_t. template <typename CharType> void InitGoogleTestImpl(int* argc, CharType** argv) { - g_init_gtest_count++; - // We don't want to run the initialization code twice. - if (g_init_gtest_count != 1) return; + if (GTestIsInitialized()) return; if (*argc <= 0) return; - internal::g_executable_path = internal::StreamableToString(argv[0]); - -#if GTEST_HAS_DEATH_TEST - g_argvs.clear(); for (int i = 0; i != *argc; i++) { g_argvs.push_back(StreamableToString(argv[i])); } -#endif // GTEST_HAS_DEATH_TEST +#if GTEST_HAS_ABSL + absl::InitializeSymbolizer(g_argvs[0].c_str()); +#endif // GTEST_HAS_ABSL ParseGoogleTestFlagsOnly(argc, argv); GetUnitTestImpl()->PostFlagParsingInit(); @@ -5006,13 +5950,62 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { // // Calling the function for the second time has no user-visible effect. void InitGoogleTest(int* argc, char** argv) { +#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) + GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv); +#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) internal::InitGoogleTestImpl(argc, argv); +#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) } // This overloaded version can be used in Windows programs compiled in // UNICODE mode. void InitGoogleTest(int* argc, wchar_t** argv) { +#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) + GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv); +#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) internal::InitGoogleTestImpl(argc, argv); +#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) +} + +std::string TempDir() { +#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) + return GTEST_CUSTOM_TEMPDIR_FUNCTION_(); +#endif + +#if GTEST_OS_WINDOWS_MOBILE + return "\\temp\\"; +#elif GTEST_OS_WINDOWS + const char* temp_dir = internal::posix::GetEnv("TEMP"); + if (temp_dir == NULL || temp_dir[0] == '\0') + return "\\temp\\"; + else if (temp_dir[strlen(temp_dir) - 1] == '\\') + return temp_dir; + else + return std::string(temp_dir) + "\\"; +#elif GTEST_OS_LINUX_ANDROID + return "/sdcard/"; +#else + return "/tmp/"; +#endif // GTEST_OS_WINDOWS_MOBILE +} + +// Class ScopedTrace + +// Pushes the given source file location and message onto a per-thread +// trace stack maintained by Google Test. +void ScopedTrace::PushTrace(const char* file, int line, std::string message) { + internal::TraceInfo trace; + trace.file = file; + trace.line = line; + trace.message.swap(message); + + UnitTest::GetInstance()->PushGTestTrace(trace); +} + +// Pops the info pushed by the c'tor. +ScopedTrace::~ScopedTrace() + GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { + UnitTest::GetInstance()->PopGTestTrace(); } } // namespace testing diff --git a/src/test/fmw/gtest/src/gtest_main.cc b/src/test/fmw/gtest/src/gtest_main.cc index f3028225523..2113f621e65 100644 --- a/src/test/fmw/gtest/src/gtest_main.cc +++ b/src/test/fmw/gtest/src/gtest_main.cc @@ -28,11 +28,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdio.h> - #include "gtest/gtest.h" GTEST_API_ int main(int argc, char **argv) { - printf("Running main() from gtest_main.cc\n"); + printf("Running main() from %s\n", __FILE__); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/src/test/hotspot/jtreg/ProblemList.txt b/src/test/hotspot/jtreg/ProblemList.txt index 096d155583f..f9197349194 100644 --- a/src/test/hotspot/jtreg/ProblemList.txt +++ b/src/test/hotspot/jtreg/ProblemList.txt @@ -88,34 +88,33 @@ runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64 serviceability/sa/ClhsdbAttach.java 8193639 solaris-all serviceability/sa/ClhsdbCDSCore.java 8207832 linux-x64 -serviceability/sa/ClhsdbCDSJstackPrintAll.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbCDSJstackPrintAll.java 8193639 solaris-all serviceability/sa/CDSJMapClstats.java 8193639 solaris-all serviceability/sa/ClhsdbField.java 8193639 solaris-all -serviceability/sa/ClhsdbFindPC.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbFindPC.java 8193639 solaris-all serviceability/sa/ClhsdbFlags.java 8193639 solaris-all -serviceability/sa/ClhsdbInspect.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/ClhsdbJdis.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbInspect.java 8193639 solaris-all +serviceability/sa/ClhsdbJdis.java 8193639 solaris-all serviceability/sa/ClhsdbJhisto.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/ClhsdbJstack.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbJstack.java 8193639 solaris-all serviceability/sa/ClhsdbLongConstant.java 8193639 solaris-all serviceability/sa/ClhsdbPmap.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/ClhsdbPrintAll.java 8193639 solaris-all -serviceability/sa/ClhsdbPrintAs.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbPrintAs.java 8193639 solaris-all serviceability/sa/ClhsdbPrintStatics.java 8193639 solaris-all serviceability/sa/ClhsdbPstack.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java 8193639 solaris-all serviceability/sa/ClhsdbScanOops.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/ClhsdbSource.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbSource.java 8193639 solaris-all serviceability/sa/ClhsdbSymbol.java 8193639 solaris-all serviceability/sa/ClhsdbSymbolTable.java 8193639 solaris-all serviceability/sa/ClhsdbThread.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/ClhsdbVmStructsDump.java 8193639 solaris-all -serviceability/sa/ClhsdbWhere.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/ClhsdbWhere.java 8193639 solaris-all serviceability/sa/DeadlockDetectionTest.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/JhsdbThreadInfoTest.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/JhsdbThreadInfoTest.java 8193639 solaris-all serviceability/sa/sadebugd/SADebugDTest.java 8163805 generic-all serviceability/sa/TestClassDump.java 8193639 solaris-all -serviceability/sa/TestClhsdbJstackLock.java 8211767 linux-ppc64le,linux-ppc64 serviceability/sa/TestCpoolForInvokeDynamic.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 serviceability/sa/TestDefaultMethods.java 8193639 solaris-all serviceability/sa/TestG1HeapRegion.java 8193639 solaris-all @@ -123,7 +122,7 @@ serviceability/sa/TestHeapDumpForInvokeDynamic.java 8193639 solaris-all serviceability/sa/TestHeapDumpForLargeArray.java 8193639 solaris-all serviceability/sa/TestInstanceKlassSizeForInterface.java 8193639 solaris-all serviceability/sa/TestIntConstant.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 -serviceability/sa/TestJhsdbJstackLock.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 +serviceability/sa/TestJhsdbJstackLock.java 8193639 solaris-all serviceability/sa/TestRevPtrsForInvokeDynamic.java 8191270 generic-all serviceability/sa/TestType.java 8193639 solaris-all serviceability/sa/TestUniverse.java#id0 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64 diff --git a/src/test/hotspot/jtreg/TEST.ROOT b/src/test/hotspot/jtreg/TEST.ROOT index 377be06cee2..3b5e1b9b1f3 100644 --- a/src/test/hotspot/jtreg/TEST.ROOT +++ b/src/test/hotspot/jtreg/TEST.ROOT @@ -67,7 +67,7 @@ requires.properties= \ docker.support # Minimum jtreg version -requiredVersion=4.2 b12 +requiredVersion=4.2 b13 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../../ notation to reach them diff --git a/src/test/hotspot/jtreg/TEST.groups b/src/test/hotspot/jtreg/TEST.groups index f91cca7c175..72953ed2928 100644 --- a/src/test/hotspot/jtreg/TEST.groups +++ b/src/test/hotspot/jtreg/TEST.groups @@ -42,6 +42,7 @@ hotspot_compiler_all_gcs = \ hotspot_gc = \ gc +# By design this group should include ALL tests under runtime sub-directory hotspot_runtime = \ runtime @@ -63,6 +64,9 @@ hotspot_misc = \ hotspot_native_sanity = \ native_sanity +hotspot_containers = \ + containers + tier1_common = \ sanity/BasicVMTest.java \ gtest/GTestWrapper.java @@ -243,7 +247,6 @@ tier1_runtime = \ -runtime/Thread/CancellableThreadTest.java \ -runtime/Thread/TestThreadDumpMonitorContention.java \ -runtime/Unsafe/RangeCheck.java \ - -runtime/containers/ \ sanity/ \ testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java \ -:tier1_runtime_appcds_exclude \ @@ -290,7 +293,6 @@ hotspot_tier2_runtime = \ serviceability/ \ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \ -runtime/Thread/TestThreadDumpMonitorContention.java \ - -runtime/containers/ \ -:tier1_runtime \ -:tier1_serviceability \ -:hotspot_tier2_runtime_platform_agnostic \ @@ -304,7 +306,6 @@ hotspot_tier2_runtime_platform_agnostic = \ hotspot_tier3_runtime = \ runtime/ \ serviceability/ \ - -runtime/containers/ \ -:tier1_runtime \ -:tier1_serviceability \ -:hotspot_tier2_runtime_platform_agnostic \ diff --git a/src/test/hotspot/jtreg/compiler/c1/CCEMessageTest.java b/src/test/hotspot/jtreg/compiler/c1/CCEMessageTest.java new file mode 100644 index 00000000000..5922e028cfe --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c1/CCEMessageTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8225644 + * @summary C1 dumps incorrect class name in CCE message + * @run main/othervm compiler.c1.CCEMessageTest + * @run main/othervm -Xcomp -XX:TieredStopAtLevel=1 compiler.c1.CCEMessageTest + */ + +package compiler.c1; + +public class CCEMessageTest { + public static void main(String... args) { + String[] s = null; + try { + s = (String[])new Object[1]; + } catch (ClassCastException cce) { + if (!cce.getMessage().contains("[Ljava.lang.String;")) + throw new AssertionError("Incorrect CCE message", cce); + } + if (s != null) + throw new AssertionError("Unexpected error"); + } +} diff --git a/src/test/hotspot/jtreg/compiler/c1/TestGotoIf.jasm b/src/test/hotspot/jtreg/compiler/c1/TestGotoIf.jasm new file mode 100644 index 00000000000..b5dc03af232 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c1/TestGotoIf.jasm @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +public class compiler/c1/TestGotoIf version 52:0 { + public Field f1:"I"; + public Field f2:"I"; + public static Field i:"I"; + + Method "<init>":"()V" stack 1 locals 1 { + aload_0; + invokespecial Method java/lang/Object."<init>":"()V"; + return; + } + + public Method test1:"()I" stack 3 locals 1 { + aload_0; + getfield Field f1:"I"; + aload_0; + getfield Field f2:"I"; + iconst_1; + isub; + // Without the fix, if got eliminated by CEE + if_icmpgt Null; + iconst_1; + Return: stack_frame_type stack1; + stack_map int; + ireturn; + Null: stack_frame_type same; + iconst_0; + goto Return; // Backbranch (t_goto) with safepoint + } + + public Method test2:"()I" stack 3 locals 1 { + aload_0; + getfield Field f1:"I"; + aload_0; + getfield Field f2:"I"; + iconst_1; + isub; + goto Skip; + Return: stack_frame_type full; + stack_map int; + ireturn; + Skip: stack_frame_type full; + stack_map int, int; + // Without the fix, if got eliminated by CEE + if_icmpgt Null; + iconst_1; + goto Return; // Backbranch (f_goto) with safepoint + Null: stack_frame_type full; + stack_map; + iconst_0; + goto Return; // Backbranch (t_goto) with safepoint + } + + public Method test3:"()I" stack 3 locals 1 { + aload_0; + getfield Field f1:"I"; + aload_0; + getfield Field f2:"I"; + iconst_1; + isub; + goto Skip; + Return: stack_frame_type full; + stack_map int; + ireturn; + Null: stack_frame_type full; + stack_map; + iconst_0; + goto Return; // Backbranch (t_goto) with safepoint + Skip: stack_frame_type full; + stack_map int, int; + // If will be eliminated by CEE + if_icmpgt Null; // Backbranch (if) with safepoint + iconst_1; + goto Return; // Backbranch (f_goto) with safepoint + } + + public Method test4:"()I" stack 3 locals 1 { + aload_0; + getfield Field f1:"I"; + aload_0; + getfield Field f2:"I"; + iconst_1; + isub; + goto Skip; + Null: stack_frame_type full; + stack_map; + iconst_0; + Return: stack_frame_type full; + stack_map int; + ireturn; + Skip: stack_frame_type full; + stack_map int, int; + // If will be eliminated by CEE + if_icmpgt Null; // Backbranch (if) with safepoint + iconst_1; + goto Return; // Backbranch (f_goto) with safepoint + } + + public Method test5:"()I" stack 3 locals 2 { + aload_0; + getfield Field f1:"I"; + aload_0; + getfield Field f2:"I"; + iconst_1; + isub; + goto Skip; + Null: stack_frame_type full; + stack_map; + iconst_0; + goto Return; + Skip: stack_frame_type full; + stack_map int, int; + // If will be eliminated by CEE + if_icmpgt Null; // Backbranch (if) with safepoint + iconst_1; + Return: stack_frame_type full; + stack_map int; + ireturn; + } + + public Method test6:"()I" stack 4 locals 1 { + getstatic Field i:"I"; + Loop: stack_frame_type full; + stack_map int; + // Decrement i and exit loop if < 0 + iconst_0; + getstatic Field i:"I"; + iconst_1; + isub; + dup; + putstatic Field i:"I"; + if_icmpgt Exit; + + iconst_1; + // Without the fix, if got eliminated by CEE + if_icmpgt Null; + iconst_1; + goto Loop; // Backbranch (f_goto) with safepoint + Null: stack_frame_type same; + iconst_0; + goto Loop; // Backbranch (t_goto) with safepoint + + Exit: stack_frame_type full; + stack_map int; + iconst_0; + ireturn; + } +} diff --git a/src/test/hotspot/jtreg/compiler/c1/TestGotoIfMain.java b/src/test/hotspot/jtreg/compiler/c1/TestGotoIfMain.java new file mode 100644 index 00000000000..ac8b1b8bedc --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c1/TestGotoIfMain.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8218721 + * @compile TestGotoIf.jasm + * @run main/othervm -XX:TieredStopAtLevel=1 -Xcomp + * -XX:CompileCommand=compileonly,compiler.c1.TestGotoIf::test* + * compiler.c1.TestGotoIfMain + */ + +package compiler.c1; + +public class TestGotoIfMain { + public static void main(String[] args) { + TestGotoIf test = new TestGotoIf(); + test.i = 5; + test.test1(); + test.test2(); + test.test3(); + test.test4(); + test.test5(); + test.test6(); + } +} diff --git a/src/test/hotspot/jtreg/compiler/c2/Test8217359.java b/src/test/hotspot/jtreg/compiler/c2/Test8217359.java new file mode 100644 index 00000000000..ca0d2cc7544 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c2/Test8217359.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, Huawei Technologies Co. Ltd. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8217359 + * @summary C2 compiler triggers SIGSEGV after transformation in ConvI2LNode::Ideal + * + * @run main/othervm -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,compiler.c2.Test8217359::test + * compiler.c2.Test8217359 + */ + +package compiler.c2; + +public class Test8217359 { + + public static int ival = 0; + public static long lsum = 0; + public static long lval = 0; + + public static void test() { + short s = -25632; + float f = 0.512F, f1 = 2.556F; + int i6 = 32547, i7 = 9, i8 = -9, i9 = 36, i10 = -223; + + for (i6 = 4; i6 < 182; i6++) { + i8 = 1; + while (++i8 < 17) { + f1 = 1; + do { + i7 += (182 + (f1 * f1)); + } while (++f1 < 1); + + Test8217359.ival += (i8 | Test8217359.ival); + } + } + + for (i9 = 9; i9 < 100; ++i9) { + i10 -= i6; + i10 >>= s; + i7 += (((i9 * i10) + i6) - Test8217359.lval); + } + + lsum += i6 + i7 + i8; + } + + public static void main(String[] args) { + for (int i = 0; i < 16000; i++) { + test(); + } + } + +} diff --git a/src/test/hotspot/jtreg/compiler/c2/TestIfWithDeadRegion.java b/src/test/hotspot/jtreg/compiler/c2/TestIfWithDeadRegion.java new file mode 100644 index 00000000000..1117908e1e4 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c2/TestIfWithDeadRegion.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8219807 + * @summary Test IfNode::up_one_dom() with dead regions. + * @compile -XDstringConcat=inline TestIfWithDeadRegion.java + * @run main/othervm -XX:CompileCommand=compileonly,compiler.c2.TestIfWithDeadRegion::test + * compiler.c2.TestIfWithDeadRegion + */ + +package compiler.c2; + +import java.util.function.Supplier; + +public class TestIfWithDeadRegion { + + static String msg; + + static String getString(String s, int i) { + String current = s + String.valueOf(i); + System.nanoTime(); + return current; + } + + static void test(Supplier<String> supplier) { + msg = supplier.get(); + } + + public static void main(String[] args) { + for (int i = 0; i < 20_000; ++i) { + test(() -> getString("Test1", 42)); + test(() -> getString("Test2", 42)); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/c2/TestMatcherLargeOffset.java b/src/test/hotspot/jtreg/compiler/c2/TestMatcherLargeOffset.java new file mode 100644 index 00000000000..ebfa3ce34b8 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c2/TestMatcherLargeOffset.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8202952 + * @summary C2: Unexpected dead nodes after matching + * + * @run main/othervm -XX:-TieredCompilation -Xcomp -XX:CompileOnly=::test + * compiler.c2.TestMatcherLargeOffset + */ +package compiler.c2; + +public class TestMatcherLargeOffset { + public static final int N = 400; + public static int iArrFld[] = new int[N]; + + public static void m(int i4) { + i4 |= -104; + iArrFld[(i4 >>> 1) % N] >>= i4; + } + + public static void test() { + int i2 = 1, i24 = 65; + for (int i1 = 7; i1 < 384; ++i1) { + for (long l = 2; l < 67; l++) { + m(i2); + for (i24 = 1; 2 > i24; ++i24) { + iArrFld = iArrFld; + } + } + i2 = (-229 / i24); + } + } + public static void main(String[] strArr) { + for (int i = 0; i < 5; i++ ) { + test(); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java b/src/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java new file mode 100644 index 00000000000..e959f91c5fa --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/c2/TestUseOptoBiasInliningWithoutEliminateLocks.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8217990 + * @summary With -XX:+UseOptoBiasInlining loading the markword is replaced by 0L if EliminateLocks is disabled. assert(dmw->is_neutral()) failed: invariant fails. + * @author Richard Reingruber richard DOT reingruber AT sap DOT com + * + * @library /test/lib /test/hotspot/jtreg + * + * @build sun.hotspot.WhiteBox + * @build ClassFileInstaller + * + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions + * -XX:CompileCommand=compileonly,*.TestUseOptoBiasInliningWithoutEliminateLocks::dontinline_testMethod + * -XX:CompileCommand=dontinline,*::dontinline_* + * -XX:-EliminateLocks + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -Xbatch + * -XX:-TieredCompilation + * compiler.c2.TestUseOptoBiasInliningWithoutEliminateLocks + */ + +package compiler.c2; + +import sun.hotspot.WhiteBox; + +public class TestUseOptoBiasInliningWithoutEliminateLocks { + + public static final WhiteBox WB = WhiteBox.getWhiteBox(); + + public static void main(String[] args) { + new TestUseOptoBiasInliningWithoutEliminateLocks().run(); + } + + public boolean warmupDone; + + public void run() { + for(int i = 0; i < 30000; i++) { + dontinline_testMethod(); + } + warmupDone = true; + dontinline_testMethod(); + } + + public void dontinline_testMethod() { + PointXY l1 = new PointXY(4.0f, 2.0f); + synchronized (l1) { + dontinline_deopt(); + } + } + + public void dontinline_deopt() { + if (warmupDone) { + WB.deoptimizeFrames(false); + } + } + + static class PointXY { + + public float fritz; + public float felix; + + public PointXY(float fritz_param, float felix_param) { + this.fritz = fritz_param; +// this.felix = felix_param; + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestByteVect.java b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestByteVect.java index 42b3ebf9a38..97310e0a31d 100644 --- a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestByteVect.java +++ b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestByteVect.java @@ -27,6 +27,9 @@ * @summary Implement vectorization optimizations in hotspot-server * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestByteVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestByteVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestByteVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestByteVect */ package compiler.c2.cr6340864; diff --git a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestDoubleVect.java b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestDoubleVect.java index 56fce03cc83..63f4d449f13 100644 --- a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestDoubleVect.java +++ b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestDoubleVect.java @@ -27,6 +27,9 @@ * @summary Implement vectorization optimizations in hotspot-server * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestDoubleVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestDoubleVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestDoubleVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestDoubleVect */ package compiler.c2.cr6340864; diff --git a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestFloatVect.java b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestFloatVect.java index c64c28ba0ec..5676a77a3cb 100644 --- a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestFloatVect.java +++ b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestFloatVect.java @@ -27,6 +27,9 @@ * @summary Implement vectorization optimizations in hotspot-server * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestFloatVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestFloatVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestFloatVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestFloatVect */ package compiler.c2.cr6340864; diff --git a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestIntVect.java b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestIntVect.java index 87c8557adb9..40180f74310 100644 --- a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestIntVect.java +++ b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestIntVect.java @@ -27,6 +27,9 @@ * @summary Implement vectorization optimizations in hotspot-server * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestIntVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestIntVect */ package compiler.c2.cr6340864; diff --git a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestLongVect.java b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestLongVect.java index 1bd0bf5c91b..da454146d17 100644 --- a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestLongVect.java +++ b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestLongVect.java @@ -27,6 +27,9 @@ * @summary Implement vectorization optimizations in hotspot-server * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestLongVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestLongVect */ package compiler.c2.cr6340864; diff --git a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestShortVect.java b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestShortVect.java index e2bf2a90308..1aa3bd86f20 100644 --- a/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestShortVect.java +++ b/src/test/hotspot/jtreg/compiler/c2/cr6340864/TestShortVect.java @@ -27,6 +27,9 @@ * @summary Implement vectorization optimizations in hotspot-server * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestShortVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestShortVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestShortVect + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestShortVect */ package compiler.c2.cr6340864; diff --git a/src/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java b/src/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java new file mode 100644 index 00000000000..c2ba005520a --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test TestOverloadCompileQueues + * @bug 8163511 + * @summary Test overloading the C1 and C2 compile queues with tasks. + * @run main/othervm -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1 + * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues + * @run main/othervm -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2 + * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues + */ + +package compiler.classUnloading.methodUnloading; + +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +public class TestOverloadCompileQueues { + public static final int ITERS = 500; // Increase for longer stress testing + + // Some methods to fill up the compile queue + public static void test0() { } + public static void test1() { } + public static void test2() { } + public static void test3() { } + public static void test4() { } + public static void test5() { } + public static void test6() { } + public static void test7() { } + public static void test8() { } + public static void test9() { } + public static void test10() { } + public static void test11() { } + public static void test12() { } + public static void test13() { } + public static void test14() { } + public static void test15() { } + public static void test16() { } + public static void test17() { } + public static void test18() { } + public static void test19() { } + + public static void main(String[] args) throws Throwable { + Class<?> thisClass = TestOverloadCompileQueues.class; + ClassLoader defaultLoader = thisClass.getClassLoader(); + URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation(); + + for (int i = 0; i < ITERS; ++i) { + // Load test class with own class loader + URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent()); + Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader); + + // Execute all test methods to trigger compilation and fill up compile queue + for (int j = 1; j < 20; ++j) { + Method method = testClass.getDeclaredMethod("test" + j); + method.invoke(null); + method.invoke(null); + } + + // Unload dead classes from ealier iterations + System.gc(); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java b/src/test/hotspot/jtreg/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java index d4dbf663a19..99ceb2e98b8 100644 --- a/src/test/hotspot/jtreg/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java +++ b/src/test/hotspot/jtreg/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -44,6 +44,7 @@ import jdk.test.lib.JDKToolFinder; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Utils; +import jtreg.SkippedException; import java.io.IOException; import java.lang.reflect.Executable; @@ -119,12 +120,11 @@ private static TestCombination generateUniqueCombination( } public static void main(String args[]) { - int iterations - = Integer.getInteger("jdk.test.lib.iterations", 1); if (!DtraceRunner.dtraceAvailable()) { - System.out.println("INFO: There is no dtrace avaiable. Skipping."); - return; + throw new SkippedException("There is no dtrace avaiable."); } + int iterations + = Integer.getInteger("jdk.test.lib.iterations", 1); int[] availableLevels = CompilerUtils.getAvailableCompilationLevels(); // adding one more entry(zero) for interpeter availableLevels diff --git a/src/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java b/src/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java index 6c349239ad7..881bb9052b9 100644 --- a/src/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java +++ b/src/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java @@ -27,6 +27,9 @@ * @summary incorrect results of char vectors right shift operaiton * * @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.codegen.TestCharVect2 + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.codegen.TestCharVect2 + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.codegen.TestCharVect2 + * @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.codegen.TestCharVect2 */ package compiler.codegen; diff --git a/src/test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java b/src/test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java index 63c44ca66c1..c6d43bea6d2 100644 --- a/src/test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java +++ b/src/test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java @@ -127,24 +127,22 @@ import compiler.whitebox.CompilerWhiteBoxTest; import sun.hotspot.code.Compiler; +import jtreg.SkippedException; public class TestAESMain { public static void main(String[] args) { String mode = System.getProperty("mode", "CBC"); if ((mode.equals("CBC") || mode.equals("ECB")) && !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.AESCrypt", "implEncryptBlock", byte[].class, int.class, byte[].class, int.class)) { - System.out.println("AES intrinsic is not available"); - return; + throw new SkippedException("AES intrinsic is not available"); } if (mode.equals("GCM") && !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.GHASH", "processBlocks", byte[].class, int.class, int.class, long[].class, long[].class)) { - System.out.println("GHASH intrinsic is not available"); - return; + throw new SkippedException("GHASH intrinsic is not available"); } if (mode.equals("CTR") && !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CounterMode", "implCrypt", byte[].class, int.class, int.class, byte[].class, int.class)) { - System.out.println("AES-CTR intrinsic is not available"); - return; + throw new SkippedException("AES-CTR intrinsic is not available"); } int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); diff --git a/src/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java b/src/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java index 649135eea59..7eb2533ff7d 100644 --- a/src/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java +++ b/src/test/hotspot/jtreg/compiler/codegen/aes/TestCipherBlockChainingEncrypt.java @@ -25,7 +25,12 @@ * @test * @bug 8209951 * @summary SIGBUS in com.sun.crypto.provider.CipherBlockChaining - * @run main/othervm/timeout=300 -Xbatch + * @library /test/lib / + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xbatch + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestCipherBlockChainingEncrypt */ @@ -40,6 +45,10 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; +import compiler.whitebox.CompilerWhiteBoxTest; +import sun.hotspot.code.Compiler; +import jtreg.SkippedException; + public class TestCipherBlockChainingEncrypt { private static String algorithm = "PBEWithHmacSHA1AndAES_256"; private static final String PBEPASS = "Hush, it's supposed to be a secret!"; @@ -53,8 +62,11 @@ public class TestCipherBlockChainingEncrypt { private static Cipher ci; public static void main(String[] args) throws Exception { - for(int i=0; i<5_000; i++) { - if (!(new TestCipherBlockChainingEncrypt().test(args))) { + if (!Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CipherBlockChaining", "implEncrypt", byte[].class, int.class, int.class, byte[].class, int.class)) { + throw new SkippedException("Base64 intrinsic is not available"); + } + for(int i=0; i<2_000; i++) { + if (!(new TestCipherBlockChainingEncrypt().test(args))) { throw new RuntimeException("TestCipherBlockChainingEncrypt test failed"); } } diff --git a/src/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java b/src/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java index feeb477ed2a..60b2d033219 100644 --- a/src/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java +++ b/src/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ * * @build sun.hotspot.WhiteBox * @requires !(vm.cpu.features ~= ".*aes.*") + * @requires vm.compiler1.enabled | !vm.graal.enabled * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions diff --git a/src/test/hotspot/jtreg/compiler/escapeAnalysis/TestGetClass.java b/src/test/hotspot/jtreg/compiler/escapeAnalysis/TestGetClass.java new file mode 100644 index 00000000000..7b2b587b2cf --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/escapeAnalysis/TestGetClass.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8218201 + * @summary BCEscapeAnalyzer assigns wrong escape state to getClass return value. + * @run main/othervm -XX:-TieredCompilation -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_getClass + * -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,compiler.escapeAnalysis.TestGetClass::test + * -XX:+PrintCompilation compiler.escapeAnalysis.TestGetClass + */ + +package compiler.escapeAnalysis; + +public class TestGetClass { + static Object obj = new Object(); + + public static boolean test() { + if (obj.getClass() == Object.class) { + synchronized (obj) { + return true; + } + } + return false; + } + + public static void main(String[] args) { + if (!test()) { + throw new RuntimeException("Test failed"); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/intrinsics/Test8215792.java b/src/test/hotspot/jtreg/compiler/intrinsics/Test8215792.java new file mode 100644 index 00000000000..b2de6e1aee2 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/intrinsics/Test8215792.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, Arm Limited. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8215792 + * @summary Fix a bug in AArch64 string intrinsics + * + * @run main/othervm compiler.intrinsics.Test8215792 + * @run main/othervm -XX:-CompactStrings compiler.intrinsics.Test8215792 + */ + +package compiler.intrinsics; + +public class Test8215792 { + + private static final int ITERATIONS = 10000; + private static final String pattern = "01234567890123456789"; + + public static void main(String[] args) { + + // Repeat many times to trigger compilation + for (int iter = 0; iter < ITERATIONS; iter++) { + StringBuilder str1 = new StringBuilder("ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456789"); + StringBuilder str2 = new StringBuilder("\u4f60\u598dCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456789"); + + for (int i = 0; i < 20; i++) { + // Remove one character from the tail + str1.setLength(str1.length() - 1); + str2.setLength(str2.length() - 1); + // Pattern string should not be found after characters removed from the tail + if (str1.indexOf(pattern) != -1 || str2.indexOf(pattern) != -1) { + System.out.println("FAILED"); + System.exit(1); + } + } + } + System.out.println("PASSED"); + } +} + diff --git a/src/test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java b/src/test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java index ab8b27126b2..debb12d5212 100644 --- a/src/test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java +++ b/src/test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java @@ -51,14 +51,14 @@ import compiler.whitebox.CompilerWhiteBoxTest; import sun.hotspot.code.Compiler; +import jtreg.SkippedException; public class TestBase64 { static boolean checkOutput = Boolean.getBoolean("checkOutput"); public static void main(String[] args) throws Exception { if (!Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "java.util.Base64$Encoder", "encodeBlock", byte[].class, int.class, int.class, byte[].class, int.class, boolean.class)) { - System.out.println("Base64 intrinsic is not available"); - return; + throw new SkippedException("Base64 intrinsic is not available"); } int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); System.out.println(iters + " iterations"); diff --git a/src/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java b/src/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java new file mode 100644 index 00000000000..780b46a7164 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, BELLSOFT. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @requires os.arch=="aarch64" + * @summary String::compareTo implementation uses different algorithms for + * different string length. This test creates string with specified + * size and longer string, which is same at beginning. + * Expecting length delta to be returned. Test class takes 2 + * parameters: <string length>, <maximum string length delta> + * Input parameters for this test are set according to Aarch64 + * String::compareTo intrinsic implementation specifics. Aarch64 + * implementation has 1, 4, 8 -characters loops for length < 72 and + * 16, 32, 64 -characters loops for length >= 72. Code is also affected + * by SoftwarePrefetchHintDistance vm flag value. + * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 25 71 72 73 88 90 192 193 208 209 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 25 71 72 73 88 90 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 25 71 72 73 88 90 + */ + +package compiler.intrinsics.string; + +public class TestStringCompareToDifferentLength { + private final int size; + + public static void main(String args[]) { + if (args.length > 1) { + int maxLengthDelta = Integer.parseInt(args[0]); + for (int i = 1; i < args.length; i++) { + int size = Integer.parseInt(args[i]); + TestStringCompareToDifferentLength test + = new TestStringCompareToDifferentLength(size); + for (int delta = 1; delta <= maxLengthDelta; delta++) { + test.testCompareTo(delta); + } + } + } else { + System.out.println("Usage: $testClass $maxLengthDelta $testLength [$testLength2 [$testLength3 [...]]]"); + } + } + + private TestStringCompareToDifferentLength(int size) { + this.size = size; + } + + private void testCompareTo(int delta) { + char strsrc[] = new char[size + delta]; + // generate ASCII string + for (int i = 0; i < size + delta; i++) { + strsrc[i] = (char) ('a' + (i % 26)); + } + + String longLatin1 = new String(strsrc); + String shortLatin1 = longLatin1.substring(0, size); + + String longUTF16LastChar = longLatin1.substring(0, longLatin1.length() - 1) + '\uBEEF'; + String longUTF16FirstChar = '\uBEEF' + longLatin1.substring(1, longLatin1.length()); + String shortUTF16FirstChar = longUTF16FirstChar.substring(0, size); + + for (int i = 0; i < 10000; i++) { + checkCase(longLatin1, shortLatin1, delta, "LL"); // Latin1-Latin1. + checkCase(longUTF16LastChar, shortLatin1, delta, "UL"); // Latin1-UTF-16 case. + checkCase(longUTF16FirstChar, shortUTF16FirstChar, delta, "UU"); // UTF-16-UTF-16 case + } + } + + private void checkCase(String str2, String str1, int expected, String caseName) { + int result = str2.compareTo(str1); + int reversedResult = str1.compareTo(str2); + if (expected != result || result != -reversedResult) { + throw new AssertionError(String.format("%s CASE FAILED: size = %d, " + + "expected = %d, but got result = %d, " + + "reversedResult = %d for string1 = '%s', string2 = '%s'", + caseName, size, expected, result, + reversedResult, str1, str2)); + } + } +} + diff --git a/src/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToSameLength.java b/src/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToSameLength.java new file mode 100644 index 00000000000..49634d6d705 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToSameLength.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, BELLSOFT. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @requires os.arch=="aarch64" + * @summary String::compareTo implementation uses different algorithms for + * different string length. This test creates various strings of + * specified size, which are different at all possible index values and + * compares them. Expecting separately calculated result to be returned. + * String size is specified via commandline. Various size values can + * be specified during intrinsic development in order to test cases + * specific for new or modified intrinsic implementation. Aarch64 + * implementation has 1, 4, 8 -characters loops for length < 72 and + * 16, 32, 64 -characters loops for string length >= 72. Code is also + * affected by SoftwarePrefetchHintDistance flag value. + * Test class can also accept "-fullmode" parameter + * with maxLength paramter after it. Then it will iterate through all + * string length values up to maxLength parameter (inclusive). It takes + * a lot of time but is useful for development. + * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 71 72 73 88 90 192 193 208 209 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 71 72 73 88 90 + * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToSameLength 2 5 10 13 17 20 25 71 72 73 88 90 + */ + +package compiler.intrinsics.string; + +public class TestStringCompareToSameLength { + private final int size; + + public static void main(String args[]) { + if (args.length == 0) { + throw new IllegalArgumentException("Usage: $testClass $testLength1" + + " [$testLength2 [...]] | -fullmode $maxLength"); + } + if (args.length == 2 && "-fullmode".equals(args[0])) { + int maxLength = Integer.parseInt(args[1]); + for (int length = 1; length <= maxLength; length++) { + TestStringCompareToSameLength test = new TestStringCompareToSameLength(length); + for (int mismatchIdx = 0; mismatchIdx <= length; mismatchIdx++) { + test.testCompareTo(mismatchIdx); + } + } + } else { + for (String arg : args) { + int size = Integer.parseInt(arg); + TestStringCompareToSameLength test = new TestStringCompareToSameLength(size); + for (int mismatchIdx = 0; mismatchIdx <= size; mismatchIdx++) { + test.testCompareTo(mismatchIdx); + } + } + } + } + + private TestStringCompareToSameLength(int size) { + this.size = size; + } + + private void testCompareTo(int mismatchIdx) { + // Create Latin1 strings: latin1, latin2, which are different at index. + // Case of index == size is a case of equal strings + char latinSrc[] = new char[size]; + // generate ASCII string + for (int i = 0; i < size; i++) { + latinSrc[i] = (char) ('a' + (i % 26)); + } + String latinStr1 = new String(latinSrc); + if (mismatchIdx != size) latinSrc[mismatchIdx] = (char) ('a' - 1); + String latinStr2 = new String(latinSrc); + + // Create 3 utf strings: utfStr1, utfStr2: same as latinStr1, but has UTF-16 character + // utfStr1 and utfStr2 are different at requested index and character value is greater + // than same index character in latinStr1. + // utfStr3 is different at requested index and character value is less than same + // index character in latinStr1. Will be a Latin1-encoded string in case difference + // is requested at last character. This case not applicable and is skipped below. + char cArray[] = latinStr1.toCharArray(); + cArray[cArray.length - 1] = '\uBEEF'; // at least last character is UTF-16 + if (mismatchIdx != size) cArray[mismatchIdx] = '\u1234'; + String utfStr1 = new String(cArray); + if (mismatchIdx != size) cArray[mismatchIdx] = '\u5678'; + String utfStr2 = new String(cArray); + if (mismatchIdx != size) cArray[mismatchIdx] = (char) ('a' - 2); // less than Latin1 index position + // utfStr3 will be Latin1 if last character differ. Will skip this case + String utfStr3 = new String(cArray); + + for (int i = 0; i < 10000; i++) { + checkCase(mismatchIdx, latinStr1, latinStr2, "LL"); // compare Latin1 with Latin1 + + checkCase(mismatchIdx, utfStr1, utfStr2, "UU"); // compare UTF-16 vs UTF-16 + + if (size != mismatchIdx) { // UTF-16 and Latin1 strings can't be equal. Then skip this case + // compare UTF16 string, which is expected to be > than Latin1 + checkCase(mismatchIdx, latinStr1, utfStr1, "U(large)L"); + if (mismatchIdx != size - 1) { + // compare UTF16 string, which is expected to be < than Latin1 + checkCase(mismatchIdx, latinStr1, utfStr3, "U(small)L"); + } + } + } + } + + private void checkCase(int mismatchIdx, String str1, String str2, String caseName) { + int expected; + if (mismatchIdx != size) { + expected = str1.charAt(mismatchIdx) - str2.charAt(mismatchIdx); + } else { + expected = str1.length() - str2.length(); + } + int result = str1.compareTo(str2); + int reversedResult = str2.compareTo(str1); + if (expected != result || result != -reversedResult) { + throw new AssertionError(String.format("%s CASE FAILED: size = %d, " + + "mismatchIdx = %d, expected = %d, but got result = %d, " + + "reversedResult = %d for string1 = '%s', string2 = '%s'", + caseName, size, mismatchIdx, expected, result, + reversedResult, str1, str2)); + } + } +} + diff --git a/src/test/hotspot/jtreg/compiler/jsr292/NonInlinedCall/InvokeTest.java b/src/test/hotspot/jtreg/compiler/jsr292/NonInlinedCall/InvokeTest.java index e1f3a3a9828..bc1f3d0c31b 100644 --- a/src/test/hotspot/jtreg/compiler/jsr292/NonInlinedCall/InvokeTest.java +++ b/src/test/hotspot/jtreg/compiler/jsr292/NonInlinedCall/InvokeTest.java @@ -60,6 +60,8 @@ public class InvokeTest { static final MethodHandle privateMH; // invokespecial I.f4 T static final MethodHandle basicMH; + static final MethodHandle intrinsicMH; // invokevirtual Object.hashCode + static final WhiteBox WB = WhiteBox.getWhiteBox(); static volatile boolean doDeopt = false; @@ -75,6 +77,7 @@ public class InvokeTest { specialMH = LOOKUP.findSpecial(T.class, "f4", mtype, T.class); privateMH = LOOKUP.findSpecial(I.class, "f4", mtype, I.class); basicMH = NonInlinedReinvoker.make(staticMH); + intrinsicMH = LOOKUP.findVirtual(Object.class, "hashCode", MethodType.methodType(int.class)); } catch (Exception e) { throw new Error(e); } @@ -117,6 +120,10 @@ static class Q1 extends T implements J1 {} static class Q2 extends T implements J2 {} static class Q3 extends T implements J3 {} + static class H { + public int hashCode() { return 0; } + } + @DontInline static void linkToVirtual(T recv, Class<?> expected) { try { @@ -137,6 +144,16 @@ static void linkToVirtualDefault(T recv, Class<?> expected) { } } + @DontInline + static void linkToVirtualIntrinsic(Object recv, int expected) { + try { + int v = (int)intrinsicMH.invokeExact(recv); + assertEquals(v, expected); + } catch (Throwable e) { + throw new Error(e); + } + } + @DontInline static void linkToInterface(I recv, Class<?> expected) { try { @@ -177,7 +194,6 @@ static void linkToSpecialIntf(I recv, Class<?> expected) { } } - @DontInline static void invokeBasic() { try { @@ -215,6 +231,8 @@ static void testVirtual() { run(() -> linkToVirtual(new T(), T.class)); run(() -> linkToVirtualDefault(new T(), I.class)); + run(() -> linkToVirtualIntrinsic(new H(), 0)); + // Megamorphic case (optimized virtual call) run(() -> { linkToVirtual(new T() {}, T.class); diff --git a/src/test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java b/src/test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java index e792ad170c9..a0979704f5f 100644 --- a/src/test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java +++ b/src/test/hotspot/jtreg/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -115,16 +115,15 @@ static void redefineFoo() throws Exception { mainAttrs.putValue("Can-Redefine-Classes", "true"); mainAttrs.putValue("Can-Retransform-Classes", "true"); - Path jar = Files.createTempFile("myagent", ".jar"); - try { - JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jar.toFile()), manifest); - add(jarStream, FooAgent.class); - add(jarStream, FooTransformer.class); - jarStream.close(); - runAgent(jar); - } finally { - Files.deleteIfExists(jar); - } + // The jar file will be added to the system classloader search path. It is not safe + // to delete it while the JVM is running, so make sure to create it in the test + // directory so it will be cleaned up by the test harness. + Path jar = Files.createTempFile(Path.of(""), "myagent", ".jar"); + JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jar.toFile()), manifest); + add(jarStream, FooAgent.class); + add(jarStream, FooTransformer.class); + jarStream.close(); + runAgent(jar); } public static void runAgent(Path agent) throws Exception { diff --git a/src/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/src/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index 58fa89c357f..2cb6e2eebcb 100644 --- a/src/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/src/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -96,6 +96,7 @@ import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotStackFrameReference; import jdk.vm.ci.meta.ResolvedJavaMethod; +import jtreg.SkippedException; import sun.hotspot.WhiteBox; import java.lang.reflect.Method; @@ -143,11 +144,10 @@ public static void main(String[] args) { int levels[] = CompilerUtils.getAvailableCompilationLevels(); // we need compilation level 4 to use EscapeAnalysis if (levels.length < 1 || levels[levels.length - 1] != 4) { - System.out.println("INFO: Test needs compilation level 4 to" - + " be available. Skipping."); - } else { - new MaterializeVirtualObjectTest().test(); + throw new SkippedException("Test needs compilation level 4"); } + + new MaterializeVirtualObjectTest().test(); } private static String getName() { diff --git a/src/test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java b/src/test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java new file mode 100644 index 00000000000..c6350c06751 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8215044 + * @summary C2 crash in loopTransform.cpp with assert(cl->trip_count() > 0) failed: peeling a fully unrolled loop + * + * @run main/othervm -XX:CompileOnly=PeelingZeroTripCount.test PeelingZeroTripCount + * + */ + +public class PeelingZeroTripCount { + + public static void main(String[] args) { + PeelingZeroTripCount issue = new PeelingZeroTripCount(); + for (int i = 0; i < 10000; i++) { + issue.test(new int[999]); + } + } + + public void test(int[] iaarg) { + int[] iarr = new int[777]; + for (int i = 4; i > 0; i--) { + for (int j = 0; j <= i - 1; j++) { + int istep = 2 * j - i + 1; + int iadj = 0; + if (istep < 0) { + iadj = iarr[0-istep] + iaarg[i-1]; + } else { + iadj = iarr[istep] + iaarg[i-1]; + } + } + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/loopstripmining/StripMinedLoopReorgOffsets.java b/src/test/hotspot/jtreg/compiler/loopstripmining/StripMinedLoopReorgOffsets.java new file mode 100644 index 00000000000..9dd6b586f4d --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/loopstripmining/StripMinedLoopReorgOffsets.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8210390 + * @summary C2 still crashes with "assert(mode == ControlAroundStripMined && use == sfpt) failed: missed a node" + * + * @run main/othervm -Xcomp StripMinedLoopReorgOffsets + * + */ + +public class StripMinedLoopReorgOffsets { + + public static final int N = 400; + + public static long instanceCount=-4622920139809038929L; + + public void mainTest(String[] strArr1) { + + int i1=-211, i20=54720, i21=205, i22=2184, i23=58, i24=-50110, iArr3[]=new int[N]; + + for (i20 = 16; 331 > i20; ++i20) { + i1 = i20; + i21 += i1; + iArr3[i20] <<= (int)StripMinedLoopReorgOffsets.instanceCount; + for (i22 = 4; i22 < 80; i22++) { + i21 = i23; + i24 = 1; + while (++i24 < 2) { + try { + iArr3[i22] = (i23 / i1); + } catch (ArithmeticException a_e) {} + } + } + } + + System.out.println("i1 i20 = " + i1 + "," + i20); + System.out.println("i21 i22 i23 = " + i21 + "," + i22 + "," + i23); + System.out.println("i24 = " + i24); + } + public static void main(String[] strArr) { + StripMinedLoopReorgOffsets _instance = new StripMinedLoopReorgOffsets(); + for (int i = 0; i < 10; i++ ) { + _instance.mainTest(strArr); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java b/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java index 903bc5fe1c8..39031a6f55a 100644 --- a/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java +++ b/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright 2016 Azul Systems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -40,29 +40,14 @@ public class TestOnSpinWait { public static void main(String[] args) throws Exception { - - // Test C1 compiler - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", - "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch", - "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", - "-XX:+PrintInlining", Launcher.class.getName()); - - OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); - - analyzer.shouldHaveExitValue(0); - - // The test is applicable only to C1 (present in Server VM). - analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) intrinsic"); - // Test C2 compiler - pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:-TieredCompilation", "-Xbatch", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", Launcher.class.getName()); - analyzer = new OutputAnalyzer(pb.start()); + OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); analyzer.shouldHaveExitValue(0); diff --git a/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java b/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java new file mode 100644 index 00000000000..0df26e528a7 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Azul Systems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test TestOnSpinWaitC1 + * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified + * @bug 8147844 + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64" + * @requires vm.compiler1.enabled + * @run driver compiler.onSpinWait.TestOnSpinWait + */ + +package compiler.onSpinWait; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class TestOnSpinWaitC1 { + + public static void main(String[] args) throws Exception { + + // Test C1 compiler + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", + "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch", + "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", + "-XX:+PrintInlining", Launcher.class.getName()); + + OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); + + analyzer.shouldHaveExitValue(0); + analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) intrinsic"); + } + + static class Launcher { + + public static void main(final String[] args) throws Exception { + int end = 20_000; + + for (int i=0; i < end; i++) { + test(); + } + } + static void test() { + java.lang.Thread.onSpinWait(); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java b/src/test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java new file mode 100644 index 00000000000..50b268a252e --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8215265 + * @summary C2: range check elimination may allow illegal out of bound access + * + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:-UseLoopPredicate RangeCheckEliminationScaleNotOne + * + */ + +import java.util.Arrays; + +public class RangeCheckEliminationScaleNotOne { + public static void main(String[] args) { + { + int[] array = new int[199]; + boolean[] flags = new boolean[100]; + Arrays.fill(flags, true); + flags[0] = false; + flags[1] = false; + for (int i = 0; i < 20_000; i++) { + test1(100, array, 0, flags); + } + boolean ex = false; + try { + test1(100, array, -5, flags); + } catch (ArrayIndexOutOfBoundsException aie) { + ex = true; + } + if (!ex) { + throw new RuntimeException("no AIOOB exception"); + } + } + + { + int[] array = new int[199]; + boolean[] flags = new boolean[100]; + Arrays.fill(flags, true); + flags[0] = false; + flags[1] = false; + for (int i = 0; i < 20_000; i++) { + test2(100, array, 198, flags); + } + boolean ex = false; + try { + test2(100, array, 203, flags); + } catch (ArrayIndexOutOfBoundsException aie) { + ex = true; + } + if (!ex) { + throw new RuntimeException("no AIOOB exception"); + } + } + } + + private static int test1(int stop, int[] array, int offset, boolean[] flags) { + if (array == null) {} + int res = 0; + for (int i = 0; i < stop; i++) { + if (flags[i]) { + res += array[2 * i + offset]; + } + } + return res; + } + + + private static int test2(int stop, int[] array, int offset, boolean[] flags) { + if (array == null) {} + int res = 0; + for (int i = 0; i < stop; i++) { + if (flags[i]) { + res += array[-2 * i + offset]; + } + } + return res; + } +} diff --git a/src/test/hotspot/jtreg/compiler/regalloc/VolatileLoadMemBarsOnlyUses.java b/src/test/hotspot/jtreg/compiler/regalloc/VolatileLoadMemBarsOnlyUses.java new file mode 100644 index 00000000000..e09fb048b99 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/regalloc/VolatileLoadMemBarsOnlyUses.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8210389 + * @summary C2: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc + * + * @run main/othervm -Xcomp -XX:CompileOnly=VolatileLoadMemBarsOnlyUses VolatileLoadMemBarsOnlyUses + * + */ + +public class VolatileLoadMemBarsOnlyUses { + + public static final int N = 400; + public static long instanceCount=-94L; + public static volatile byte byFld=-108; + + public int mainTest(String[] strArr1) { + + int i17=9, i19=1, i20=63, i21=-32916, i22=0, iArr[]=new int[N]; + boolean b1=false; + double d3=76.18241; + + for (int i : iArr) { + for (i17 = 2; i17 < 63; i17++) { + if (b1) break; + byFld += (byte)(0.131F + (i17 * i17)); + } + for (i19 = 1; 63 > i19; ++i19) { + for (i21 = 1; i21 < 2; i21++) { + d3 = i22; + if (b1) continue; + i20 = i21; + } + d3 -= byFld; + instanceCount = 46725L; + } + switch ((((i22 >>> 1) % 4) * 5) + 91) { + case 98: + break; + case 110: + break; + case 105: + break; + case 103: + break; + default: + } + } + + return i20; + } + public static void main(String[] strArr) { + VolatileLoadMemBarsOnlyUses _instance = new VolatileLoadMemBarsOnlyUses(); + for (int i = 0; i < 10; i++ ) { + _instance.mainTest(strArr); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortRatio.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortRatio.java index fe510beb150..3613d5c4cf8 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortRatio.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortRatio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,18 +33,18 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMAbortRatio + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMAbortRatio */ package compiler.rtm.locking; import compiler.testlibrary.rtm.AbortProvoker; +import compiler.testlibrary.rtm.XAbortProvoker; import compiler.testlibrary.rtm.CompilableTest; import compiler.testlibrary.rtm.RTMLockingStatistics; import compiler.testlibrary.rtm.RTMTestBase; -import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.cli.CommandLineOptionTest; @@ -117,7 +117,7 @@ private void verifyAbortRatio(int abortRatio, boolean useStackLock) public static class Test implements CompilableTest { private static final int TOTAL_ITERATIONS = 10000; private static final int WARMUP_ITERATIONS = 1000; - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private final XAbortProvoker xabort = new XAbortProvoker(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") @@ -130,13 +130,13 @@ public String getMethodWithLockName() { @Override public String[] getMethodsToCompileNames() { - return new String[] { getMethodWithLockName(), "*.pageSize" }; + return new String[] { getMethodWithLockName(), "*.doAbort" }; } public void lock(boolean abort) { synchronized(monitor) { if (abort) { - Test.UNSAFE.pageSize(); + xabort.doAbort(); } } } diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortThreshold.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortThreshold.java index 6288d7e9e99..98bc11256b5 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortThreshold.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAbortThreshold.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,9 +33,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMAbortThreshold + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMAbortThreshold */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java index f8a0c7b994c..ba0a1ef6d44 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -35,18 +35,18 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMAfterNonRTMDeopt + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMAfterNonRTMDeopt */ package compiler.rtm.locking; import compiler.testlibrary.rtm.AbortProvoker; +import compiler.testlibrary.rtm.XAbortProvoker; import compiler.testlibrary.rtm.CompilableTest; import compiler.testlibrary.rtm.RTMLockingStatistics; import compiler.testlibrary.rtm.RTMTestBase; -import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.cli.CommandLineOptionTest; @@ -149,7 +149,7 @@ public static class Test implements CompilableTest { private static int field = 0; private static final int ITERATIONS = 10000; private static final int RANGE_CHECK_AT = ITERATIONS / 2; - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private final XAbortProvoker xabort = new XAbortProvoker(); private final Object monitor = new Object(); @Override @@ -159,7 +159,8 @@ public String getMethodWithLockName() { @Override public String[] getMethodsToCompileNames() { - return new String[] { getMethodWithLockName() }; + return new String[] { getMethodWithLockName(), + XAbortProvoker.class.getName() + "::doAbort()" }; } public void forceAbort(int a[], boolean abort) { @@ -167,7 +168,7 @@ public void forceAbort(int a[], boolean abort) { synchronized(monitor) { a[0]++; if (abort) { - Test.field = Test.UNSAFE.pageSize(); + Test.field = xabort.doAbort(); } } } catch (Throwable t) { diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java index cc60c6b30ed..677456fae08 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,9 +33,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMDeoptOnHighAbortRatio + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMDeoptOnHighAbortRatio */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java index 944e7a98890..402ead2a640 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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,18 +32,18 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMDeoptOnLowAbortRatio + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMDeoptOnLowAbortRatio */ package compiler.rtm.locking; import compiler.testlibrary.rtm.AbortProvoker; +import compiler.testlibrary.rtm.XAbortProvoker; import compiler.testlibrary.rtm.CompilableTest; import compiler.testlibrary.rtm.RTMLockingStatistics; import compiler.testlibrary.rtm.RTMTestBase; -import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.cli.CommandLineOptionTest; @@ -124,7 +124,7 @@ private void verifyRTMDeopt(boolean useStackLock) throws Throwable { } public static class Test implements CompilableTest { - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private final XAbortProvoker xabort = new XAbortProvoker(); private final Object monitor = new Object(); @Override @@ -134,13 +134,14 @@ public String getMethodWithLockName() { @Override public String[] getMethodsToCompileNames() { - return new String[] { getMethodWithLockName() }; + return new String[] { getMethodWithLockName(), + XAbortProvoker.class.getName() + "::doAbort" }; } public void forceAbort(boolean abort) { synchronized(monitor) { if (abort) { - Test.UNSAFE.pageSize(); + xabort.doAbort(); } } } diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingCalculationDelay.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingCalculationDelay.java index af3df7c3a5b..25cf21ff64d 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingCalculationDelay.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingCalculationDelay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,9 +33,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMLockingCalculationDelay + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMLockingCalculationDelay */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingThreshold.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingThreshold.java index 626c840545e..65fc9eecea9 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingThreshold.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingThreshold.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,18 +33,18 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMLockingThreshold + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMLockingThreshold */ package compiler.rtm.locking; import compiler.testlibrary.rtm.AbortProvoker; +import compiler.testlibrary.rtm.XAbortProvoker; import compiler.testlibrary.rtm.CompilableTest; import compiler.testlibrary.rtm.RTMLockingStatistics; import compiler.testlibrary.rtm.RTMTestBase; -import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.cli.CommandLineOptionTest; @@ -134,10 +134,9 @@ public static class Test implements CompilableTest { @SuppressWarnings("UnsuedDeclaration") private static int field = 0; private static final int TOTAL_ITERATIONS = 10000; - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private final XAbortProvoker xabort = new XAbortProvoker(); private final Object monitor = new Object(); - @Override public String getMethodWithLockName() { return this.getClass().getName() + "::lock"; @@ -145,13 +144,14 @@ public String getMethodWithLockName() { @Override public String[] getMethodsToCompileNames() { - return new String[] { getMethodWithLockName() }; + return new String[] { getMethodWithLockName(), + XAbortProvoker.class.getName() + "::doAbort" }; } public void lock(boolean abort) { synchronized(monitor) { if (abort) { - Test.field += Test.UNSAFE.pageSize(); + Test.field += xabort.doAbort(); } } } diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMTotalCountIncrRate.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMTotalCountIncrRate.java index f25517a759c..2712bc4dd1e 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMTotalCountIncrRate.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestRTMTotalCountIncrRate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,18 +33,18 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestRTMTotalCountIncrRate + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestRTMTotalCountIncrRate */ package compiler.rtm.locking; import compiler.testlibrary.rtm.AbortProvoker; +import compiler.testlibrary.rtm.XAbortProvoker; import compiler.testlibrary.rtm.CompilableTest; import compiler.testlibrary.rtm.RTMLockingStatistics; import compiler.testlibrary.rtm.RTMTestBase; -import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.cli.CommandLineOptionTest; @@ -104,7 +104,7 @@ private void verifyLocksCount(int incrRate, boolean useStackLock) public static class Test implements CompilableTest { private static final long TOTAL_ITERATIONS = 10000L; - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private final XAbortProvoker xabort = new XAbortProvoker(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") @@ -117,7 +117,7 @@ public String getMethodWithLockName() { @Override public String[] getMethodsToCompileNames() { - return new String[] { getMethodWithLockName() }; + return new String[] { getMethodWithLockName(), "*.doAbort" }; } public void lock(boolean forceAbort) { @@ -129,7 +129,7 @@ public void lock(boolean forceAbort) { // If an actual JNI call will be replaced by // intrinsic - we'll be in trouble, since xabort // will be no longer called and test may fail. - UNSAFE.pageSize(); + xabort.doAbort(); } Test.field++; } diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMAfterLockInflation.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMAfterLockInflation.java index 8f9d4c6128f..0d92cfee490 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMAfterLockInflation.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMAfterLockInflation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,9 +33,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestUseRTMAfterLockInflation + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestUseRTMAfterLockInflation */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMDeopt.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMDeopt.java index b839f863889..294def6b37a 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMDeopt.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMDeopt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,9 +33,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestUseRTMDeopt + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestUseRTMDeopt */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForInflatedLocks.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForInflatedLocks.java index 805599c18ec..d76c8cf820f 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForInflatedLocks.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForInflatedLocks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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,8 +32,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI compiler.rtm.locking.TestUseRTMForInflatedLocks + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestUseRTMForInflatedLocks */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForStackLocks.java b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForStackLocks.java index 425d1c3bd26..77c55d04b2c 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForStackLocks.java +++ b/src/test/hotspot/jtreg/compiler/rtm/locking/TestUseRTMForStackLocks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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,9 +32,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.locking.TestUseRTMForStackLocks + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.locking.TestUseRTMForStackLocks */ package compiler.rtm.locking; diff --git a/src/test/hotspot/jtreg/compiler/rtm/method_options/TestNoRTMLockElidingOption.java b/src/test/hotspot/jtreg/compiler/rtm/method_options/TestNoRTMLockElidingOption.java index 34646f9b0bd..2a3cdf97961 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/method_options/TestNoRTMLockElidingOption.java +++ b/src/test/hotspot/jtreg/compiler/rtm/method_options/TestNoRTMLockElidingOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -33,9 +33,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.method_options.TestNoRTMLockElidingOption + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.method_options.TestNoRTMLockElidingOption */ package compiler.rtm.method_options; diff --git a/src/test/hotspot/jtreg/compiler/rtm/method_options/TestUseRTMLockElidingOption.java b/src/test/hotspot/jtreg/compiler/rtm/method_options/TestUseRTMLockElidingOption.java index 43c9a884927..71aae8d167c 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/method_options/TestUseRTMLockElidingOption.java +++ b/src/test/hotspot/jtreg/compiler/rtm/method_options/TestUseRTMLockElidingOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -34,9 +34,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.method_options.TestUseRTMLockElidingOption + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.method_options.TestUseRTMLockElidingOption */ package compiler.rtm.method_options; diff --git a/src/test/hotspot/jtreg/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java b/src/test/hotspot/jtreg/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java index fc6b58f048a..8c6a11b76f8 100644 --- a/src/test/hotspot/jtreg/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java +++ b/src/test/hotspot/jtreg/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -35,9 +35,9 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.print.TestPrintPreciseRTMLockingStatistics + * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * -XX:+WhiteBoxAPI + * compiler.rtm.print.TestPrintPreciseRTMLockingStatistics */ diff --git a/src/test/hotspot/jtreg/compiler/runtime/Test6859338.java b/src/test/hotspot/jtreg/compiler/runtime/Test6859338.java index 232313c3f02..ac2eefccfa5 100644 --- a/src/test/hotspot/jtreg/compiler/runtime/Test6859338.java +++ b/src/test/hotspot/jtreg/compiler/runtime/Test6859338.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 6859338 * @summary Assertion failure in sharedRuntime.cpp * + * @requires vm.compiler1.enabled | !vm.graal.enabled * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter * compiler.runtime.Test6859338 diff --git a/src/test/hotspot/jtreg/compiler/testlibrary/rtm/XAbortProvoker.java b/src/test/hotspot/jtreg/compiler/testlibrary/rtm/XAbortProvoker.java index 06bd7884548..23b7b779288 100644 --- a/src/test/hotspot/jtreg/compiler/testlibrary/rtm/XAbortProvoker.java +++ b/src/test/hotspot/jtreg/compiler/testlibrary/rtm/XAbortProvoker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,25 @@ package compiler.testlibrary.rtm; -import jdk.internal.misc.Unsafe; - /** * Current RTM locking implementation force transaction abort * before native method call by explicit xabort(0) call. */ -class XAbortProvoker extends AbortProvoker { +public class XAbortProvoker extends AbortProvoker { + + static { + try { + System.loadLibrary("XAbortProvoker"); + } catch (UnsatisfiedLinkError e) { + System.out.println("Could not load native library: " + e); + } + } + + public native int doAbort(); + // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") private static int field = 0; - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public XAbortProvoker() { this(new Object()); @@ -46,7 +54,7 @@ public XAbortProvoker(Object monitor) { @Override public void forceAbort() { synchronized(monitor) { - XAbortProvoker.field = UNSAFE.pageSize(); + XAbortProvoker.field = doAbort(); } } @@ -54,7 +62,7 @@ public void forceAbort() { public String[] getMethodsToCompileNames() { return new String[] { getMethodWithLockName(), - Unsafe.class.getName() + "::pageSize" + XAbortProvoker.class.getName() + "::doAbort" }; } } diff --git a/src/test/hotspot/jtreg/compiler/testlibrary/rtm/libXAbortProvoker.c b/src/test/hotspot/jtreg/compiler/testlibrary/rtm/libXAbortProvoker.c new file mode 100644 index 00000000000..b87882771d4 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/testlibrary/rtm/libXAbortProvoker.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "jni.h" + +/** + * Simply calling a JNI method from the JVM will abort any active transaction, + * so doAbort() does nothing special and only returns after being called. + * The transaction abortion happens right before the JNI method is called. + */ +JNIEXPORT int JNICALL +Java_compiler_testlibrary_rtm_XAbortProvoker_doAbort(JNIEnv *env, jobject o) { + return 0; +} diff --git a/src/test/hotspot/jtreg/compiler/tiered/ConstantGettersTransitionsTest.java b/src/test/hotspot/jtreg/compiler/tiered/ConstantGettersTransitionsTest.java index d2bad2eeede..8caac14c071 100644 --- a/src/test/hotspot/jtreg/compiler/tiered/ConstantGettersTransitionsTest.java +++ b/src/test/hotspot/jtreg/compiler/tiered/ConstantGettersTransitionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -40,13 +40,16 @@ package compiler.tiered; import compiler.whitebox.CompilerWhiteBoxTest; +import jtreg.SkippedException; import java.lang.reflect.Executable; import java.util.concurrent.Callable; public class ConstantGettersTransitionsTest extends LevelTransitionTest { public static void main(String[] args) { - assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false)); + if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { + throw new SkippedException("Test isn't applicable for non-tiered mode"); + } // run test cases for (TestCase testCase : ConstantGettersTestCase.values()) { diff --git a/src/test/hotspot/jtreg/compiler/tiered/Level2RecompilationTest.java b/src/test/hotspot/jtreg/compiler/tiered/Level2RecompilationTest.java new file mode 100644 index 00000000000..d6cb0a712ec --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/tiered/Level2RecompilationTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test Level2RecompilationTest + * @summary Test downgrading mechanism from level 3 to level 2 for those profiled methods. + * @library /test/lib / + * @modules java.base/jdk.internal.misc + * java.management + * + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay + * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* + * -XX:CompileCommand=print,compiler.whitebox.SimpleTestCaseHelper::* + * compiler.tiered.Level2RecompilationTest + */ + +package compiler.tiered; + +import compiler.whitebox.CompilerWhiteBoxTest; + +public class Level2RecompilationTest extends CompLevelsTest { + public static void main(String[] args) throws Throwable { + if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { + throw new RuntimeException("Test isn't applicable for non-tiered mode"); + } + String[] testcases = {"METHOD_TEST", "OSR_STATIC_TEST"}; + CompilerWhiteBoxTest.main(Level2RecompilationTest::new, testcases); + } + + protected Level2RecompilationTest(TestCase testCase) { + super(testCase); + // to prevent inlining of #method + WHITE_BOX.testSetDontInlineMethod(method, true); + } + + @Override + protected void test() throws Exception { + if (skipXcompOSR()) { + return; + } + + checkNotCompiled(); + int bci = WHITE_BOX.getMethodEntryBci(method); + WHITE_BOX.markMethodProfiled(method); + if (testCase.isOsr()) { + // for OSR compilation, it must be the begin of a BB. + // c1_GraphBulider.cpp:153 assert(method()->bci_block_start().at(cur_bci), ... + bci = 0; + } + + WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci); + checkCompiled(); + checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel()); + + for (int i=0; i<100; ++i) { + WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci); + waitBackgroundCompilation(); + checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel()); + } + } + + @Override + protected void checkLevel(int expected, int actual) { + if (expected == COMP_LEVEL_FULL_PROFILE + && actual == COMP_LEVEL_LIMITED_PROFILE) { + // for simple method full_profile may be replaced by limited_profile + if (IS_VERBOSE) { + System.out.printf("Level check: full profiling was replaced " + + "by limited profiling. Expected: %d, actual:%d\n", + expected, actual); + } + return; + } + super.checkLevel(expected, actual); + } +} + diff --git a/src/test/hotspot/jtreg/compiler/tiered/LevelTransitionTest.java b/src/test/hotspot/jtreg/compiler/tiered/LevelTransitionTest.java index 4bd62e7ba69..c47c56ce46f 100644 --- a/src/test/hotspot/jtreg/compiler/tiered/LevelTransitionTest.java +++ b/src/test/hotspot/jtreg/compiler/tiered/LevelTransitionTest.java @@ -43,6 +43,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; import compiler.whitebox.SimpleTestCase; +import jtreg.SkippedException; import java.lang.reflect.Executable; import java.lang.reflect.Method; @@ -57,7 +58,9 @@ public class LevelTransitionTest extends TieredLevelsTest { private int transitionCount; public static void main(String[] args) throws Throwable { - assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false)); + if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { + throw new SkippedException("Test isn't applicable for non-tiered mode"); + } CompilerWhiteBoxTest.main(LevelTransitionTest::new, args); // run extended test cases diff --git a/src/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java b/src/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java index cd5054d8294..303d899ae7f 100644 --- a/src/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java +++ b/src/test/hotspot/jtreg/compiler/tiered/NonTieredLevelsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, 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 @@ -42,6 +42,7 @@ import java.util.function.IntPredicate; import compiler.whitebox.CompilerWhiteBoxTest; import jdk.test.lib.Platform; +import jtreg.SkippedException; public class NonTieredLevelsTest extends CompLevelsTest { private static final int AVAILABLE_COMP_LEVEL; @@ -60,7 +61,7 @@ public class NonTieredLevelsTest extends CompLevelsTest { } public static void main(String[] args) throws Exception { if (CompilerWhiteBoxTest.skipOnTieredCompilation(true)) { - return; + throw new SkippedException("Test isn't applicable for tiered mode"); } CompilerWhiteBoxTest.main(NonTieredLevelsTest::new, args); } diff --git a/src/test/hotspot/jtreg/compiler/tiered/TieredLevelsTest.java b/src/test/hotspot/jtreg/compiler/tiered/TieredLevelsTest.java index 1e23648f907..5a8783ae96c 100644 --- a/src/test/hotspot/jtreg/compiler/tiered/TieredLevelsTest.java +++ b/src/test/hotspot/jtreg/compiler/tiered/TieredLevelsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, 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 @@ -40,11 +40,12 @@ package compiler.tiered; import compiler.whitebox.CompilerWhiteBoxTest; +import jtreg.SkippedException; public class TieredLevelsTest extends CompLevelsTest { public static void main(String[] args) throws Throwable { if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { - return; + throw new SkippedException("Test isn't applicable for non-tiered mode"); } CompilerWhiteBoxTest.main(TieredLevelsTest::new, args); } diff --git a/src/test/hotspot/jtreg/compiler/types/TestMeetIncompatibleInterfaceArrays.java b/src/test/hotspot/jtreg/compiler/types/TestMeetIncompatibleInterfaceArrays.java index f64253db950..28678c9ac9c 100644 --- a/src/test/hotspot/jtreg/compiler/types/TestMeetIncompatibleInterfaceArrays.java +++ b/src/test/hotspot/jtreg/compiler/types/TestMeetIncompatibleInterfaceArrays.java @@ -362,6 +362,12 @@ public static void main(String[] args) throws Exception { System.out.println((j + 1) + ". invokation of " + baseClassName + i + "ASM.test() [::" + r.getName() + "() should be '" + tier[pass][j] + "' compiled]"); + // Skip Profiling compilation (C1) when Tiered is disabled. + boolean profile = (level[pass][j] == CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE); + if (profile && CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { + continue; + } + WB.enqueueMethodForCompilation(r, level[pass][j]); try { diff --git a/src/test/hotspot/jtreg/compiler/unsafe/MismatchedUnsafeLoadFromNewObject.java b/src/test/hotspot/jtreg/compiler/unsafe/MismatchedUnsafeLoadFromNewObject.java new file mode 100644 index 00000000000..e1964423601 --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/unsafe/MismatchedUnsafeLoadFromNewObject.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8216549 + * @summary Mismatched unsafe access to non escaping object fails + * + * @modules java.base/jdk.internal.misc + * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation MismatchedUnsafeLoadFromNewObject + */ + +import java.lang.reflect.Field; +import jdk.internal.misc.Unsafe; + +public class MismatchedUnsafeLoadFromNewObject { + public volatile int f_int = -1; + public volatile int f_int2 = -1; + + public static Unsafe unsafe = Unsafe.getUnsafe(); + public static final long f_int_off; + public static final long f_int2_off; + + static { + Field f_int_field = null; + Field f_int2_field = null; + try { + f_int_field = MismatchedUnsafeLoadFromNewObject.class.getField("f_int"); + f_int2_field = MismatchedUnsafeLoadFromNewObject.class.getField("f_int2"); + } catch (Exception e) { + System.out.println("reflection failed " + e); + e.printStackTrace(); + } + f_int_off = unsafe.objectFieldOffset(f_int_field); + f_int2_off = unsafe.objectFieldOffset(f_int2_field); + } + + static public void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + byte res = test1(); + if (res != -1) { + throw new RuntimeException("Incorrect result: " + res); + } + res = test2(); + if (res != -1) { + throw new RuntimeException("Incorrect result: " + res); + } + int res2 = test3(); + if (res2 != -1) { + throw new RuntimeException("Incorrect result: " + res2); + } + } + } + + static byte test1() { + MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject(); + return unsafe.getByte(t, f_int_off); + } + + static byte test2() { + MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject(); + return unsafe.getByte(t, f_int_off+1); + } + + static int test3() { + MismatchedUnsafeLoadFromNewObject t = new MismatchedUnsafeLoadFromNewObject(); + if (f_int_off < f_int2_off) { + return unsafe.getIntUnaligned(t, f_int_off+1); + } else { + return unsafe.getIntUnaligned(t, f_int2_off+1); + } + } +} diff --git a/src/test/hotspot/jtreg/compiler/unsafe/TestUnsafeLoadWithZeroAddress.java b/src/test/hotspot/jtreg/compiler/unsafe/TestUnsafeLoadWithZeroAddress.java new file mode 100644 index 00000000000..ae4f7a6604c --- /dev/null +++ b/src/test/hotspot/jtreg/compiler/unsafe/TestUnsafeLoadWithZeroAddress.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8224658 + * @summary Test compilation of unsafe access with zero address. + * @modules java.base/jdk.internal.misc:+open + * @run main/othervm -Xcomp + * -XX:CompileCommand=compileonly,compiler.unsafe.TestUnsafeLoadWithZeroAddress::* + * compiler.unsafe.TestUnsafeLoadWithZeroAddress + * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:CompileCommand=compileonly,compiler.unsafe.TestUnsafeLoadWithZeroAddress::* + * compiler.unsafe.TestUnsafeLoadWithZeroAddress + */ + +package compiler.unsafe; + +import jdk.internal.misc.Unsafe; + +public class TestUnsafeLoadWithZeroAddress { + static final Unsafe UNSAFE = Unsafe.getUnsafe(); + static boolean f; + + public static void test1() { + if (f) { + // This branch is never executed but compiled due to -Xcomp + UNSAFE.getInt(0); + } + } + + public static void test2() { + if (f) { + // This branch is never executed but compiled due to -Xcomp + UNSAFE.putInt(0, 0); + } + } + + private static int getAddress() { + return 0; + } + + public static void test3() { + if (f) { + // This branch is never executed but compiled due to -Xcomp + UNSAFE.getInt(getAddress()); + } + } + + public static void test4() { + if (f) { + // This branch is never executed but compiled due to -Xcomp + UNSAFE.putInt(getAddress(), 0); + } + } + + static public void main(String[] args) { + test1(); + test2(); + test3(); + test4(); + } +} + diff --git a/src/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java b/src/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java index d645352a7ae..fea88f3115b 100644 --- a/src/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java +++ b/src/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 SAP SE. All rights reserved. + * Copyright (c) 2016, 2018, SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8150646 8153013 * @summary Add support for blocking compiles through whitebox API + * @requires vm.compiler1.enabled | !vm.graal.enabled * @modules java.base/jdk.internal.misc * @library /test/lib / * @build sun.hotspot.WhiteBox diff --git a/src/test/hotspot/jtreg/runtime/containers/cgroup/PlainRead.java b/src/test/hotspot/jtreg/containers/cgroup/PlainRead.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/cgroup/PlainRead.java rename to src/test/hotspot/jtreg/containers/cgroup/PlainRead.java diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/AttemptOOM.java b/src/test/hotspot/jtreg/containers/docker/AttemptOOM.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/AttemptOOM.java rename to src/test/hotspot/jtreg/containers/docker/AttemptOOM.java diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/CheckContainerized.java b/src/test/hotspot/jtreg/containers/docker/CheckContainerized.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/CheckContainerized.java rename to src/test/hotspot/jtreg/containers/docker/CheckContainerized.java diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java b/src/test/hotspot/jtreg/containers/docker/DockerBasicTest.java similarity index 89% rename from src/test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java rename to src/test/hotspot/jtreg/containers/docker/DockerBasicTest.java index ab9609be208..792418f074d 100644 --- a/src/test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java +++ b/src/test/hotspot/jtreg/containers/docker/DockerBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -33,6 +33,7 @@ * @build HelloDocker * @run driver DockerBasicTest */ +import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.Platform; @@ -40,9 +41,7 @@ public class DockerBasicTest { - private static final String imageNameAndTag = "jdk10-internal:test"; - // Diganostics: set to false to examine image after the test - private static final boolean removeImageAfterTest = true; + private static final String imageNameAndTag = Common.imageName("basic"); public static void main(String[] args) throws Exception { if (!DockerTestUtils.canTestDocker()) { @@ -55,8 +54,9 @@ public static void main(String[] args) throws Exception { testJavaVersion(); testHelloDocker(); } finally { - if (removeImageAfterTest) + if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { DockerTestUtils.removeDockerImage(imageNameAndTag); + } } } diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/HelloDocker.java b/src/test/hotspot/jtreg/containers/docker/HelloDocker.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/HelloDocker.java rename to src/test/hotspot/jtreg/containers/docker/HelloDocker.java diff --git a/src/test/hotspot/jtreg/containers/docker/JfrReporter.java b/src/test/hotspot/jtreg/containers/docker/JfrReporter.java new file mode 100644 index 00000000000..983fb50ba0a --- /dev/null +++ b/src/test/hotspot/jtreg/containers/docker/JfrReporter.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019, 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. + */ + +import java.nio.file.Paths; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; + + +// This class is intended to run inside a container +public class JfrReporter { + public static final String TEST_REPORTED_CORES="TEST_REPORTED_CORES"; + public static final String TEST_REPORTED_MEMORY="TEST_REPORTED_MEMORY"; + public static final String TEST_REPORTED_PID="TEST_REPORTED_PID"; + public static final String TESTCASE_CPU="cpu"; + public static final String TESTCASE_MEMORY="memory"; + public static final String TESTCASE_PROCESS="process"; + + public static void main(String[] args) throws Exception { + String testCase = args[0]; + System.out.println("Testcase: " + testCase); + switch (testCase) { + case TESTCASE_CPU: + RecordedEvent event = testEvent("jdk.CPUInformation", "cpu.jfr"); + System.out.println(TEST_REPORTED_CORES + "=" + event.getInt("cores")); + break; + case TESTCASE_MEMORY: + event = testEvent("jdk.PhysicalMemory", "memory.jfr"); + System.out.println(TEST_REPORTED_MEMORY + "=" + event.getLong("totalSize")); + break; + case TESTCASE_PROCESS: + event = testEvent("jdk.SystemProcess", "process.jfr"); + System.out.println(TEST_REPORTED_PID + "=" + event.getString("pid")); + break; + default: + throw new IllegalArgumentException("Invalid test case"); + } + } + + private static RecordedEvent testEvent(String event, String recordingPath) throws Exception { + System.out.println("========= Testing event: " + event); + Recording r = new Recording(); + r.enable(event); + r.setDestination(Paths.get("tmp", recordingPath)); + r.start(); + r.stop(); + + RecordedEvent recordedEvent = RecordingFile.readAllEvents(r.getDestination()).get(0); + System.out.println("RecordedEvent: " + recordedEvent); + return recordedEvent; + } +} diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/PrintContainerInfo.java b/src/test/hotspot/jtreg/containers/docker/PrintContainerInfo.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/PrintContainerInfo.java rename to src/test/hotspot/jtreg/containers/docker/PrintContainerInfo.java diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/TEST.properties b/src/test/hotspot/jtreg/containers/docker/TEST.properties similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/TEST.properties rename to src/test/hotspot/jtreg/containers/docker/TEST.properties diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java b/src/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java rename to src/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/TestCPUSets.java b/src/test/hotspot/jtreg/containers/docker/TestCPUSets.java similarity index 74% rename from src/test/hotspot/jtreg/runtime/containers/docker/TestCPUSets.java rename to src/test/hotspot/jtreg/containers/docker/TestCPUSets.java index 3c22a34a823..7d5bea4b961 100644 --- a/src/test/hotspot/jtreg/runtime/containers/docker/TestCPUSets.java +++ b/src/test/hotspot/jtreg/containers/docker/TestCPUSets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -44,7 +44,7 @@ import jdk.test.lib.Platform; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; - +import jtreg.SkippedException; public class TestCPUSets { private static final String imageName = Common.imageName("cpusets"); @@ -54,6 +54,7 @@ public static void main(String[] args) throws Exception { return; } + Common.prepareWhiteBox(); DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker"); @@ -72,22 +73,48 @@ private static void testTheSet(String setType) throws Exception { String cpuSetStr = CPUSetsReader.readFromProcStatus(setType); if (cpuSetStr == null) { - System.out.printf("The %s test is skipped %n", setType); - } else { - List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr); - - // Test subset of one, full subset, and half of the subset - testCpuSet(CPUSetsReader.listToString(cpuSet, 1)); - if (cpuSet.size() > 1) { - testCpuSet(CPUSetsReader.listToString(cpuSet)); - } - if (cpuSet.size() > 2) { - testCpuSet(CPUSetsReader.listToString(cpuSet, cpuSet.size()/2 )); - } + String msg = String.format("The %s test is skipped: cpuSetStr is null %n", setType); + throw new SkippedException(msg); + } + + List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr); + int availableProcessors = Runtime.getRuntime().availableProcessors(); + + // print diagnostic info + printSet(setType, cpuSet); + log("getNumCpus(): " + CPUSetsReader.getNumCpus()); + log("Runtime.getRuntime().availableProcessors(): " + availableProcessors); + + int maxSetSize = Math.min(cpuSet.size(), availableProcessors); + log("maxSetSize = " + maxSetSize); + + // Test subset of one, full set, and half of the set + testCpuSet(CPUSetsReader.listToString(cpuSet, 1)); + if (maxSetSize >= 2) { + String cpuSetParam = CPUSetsReader.listToString(cpuSet, maxSetSize); + log("Testing with cpuSetParam = " + cpuSetParam); + testCpuSet(cpuSetParam); + } + if (maxSetSize >= 4) { + String cpuSetParam = CPUSetsReader.listToString(cpuSet, maxSetSize/2); + log("Testing with cpuSetParam = " + cpuSetParam); + testCpuSet(cpuSetParam); } } + private static void printSet(String setType, List<Integer> set) { + System.out.print("printSet(): " + setType + ": "); + set.forEach( i -> System.out.print(i + ", ")); + System.out.println(""); + } + + + private static void log(String msg) { + System.out.println(msg); + } + + private static DockerRunOptions commonOpts() { DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "PrintContainerInfo"); diff --git a/src/test/hotspot/jtreg/containers/docker/TestJFREvents.java b/src/test/hotspot/jtreg/containers/docker/TestJFREvents.java new file mode 100644 index 00000000000..73e6ac178fa --- /dev/null +++ b/src/test/hotspot/jtreg/containers/docker/TestJFREvents.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test + * @summary Ensure that certain JFR events return correct results for resource values + * when run inside Docker container, such as available CPU and memory. + * Also make sure that PIDs are based on value provided by container, + * not by the host system. + * @requires (docker.support & os.maxMemory >= 2g) + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * jdk.jartool/sun.tools.jar + * @build JfrReporter + * @run driver TestJFREvents + */ +import jdk.test.lib.containers.docker.Common; +import jdk.test.lib.containers.docker.DockerRunOptions; +import jdk.test.lib.containers.docker.DockerTestUtils; +import jdk.test.lib.Utils; + + +public class TestJFREvents { + private static final String imageName = Common.imageName("jfr-events"); + private static final int availableCPUs = Runtime.getRuntime().availableProcessors(); + + public static void main(String[] args) throws Exception { + System.out.println("Test Environment: detected availableCPUs = " + availableCPUs); + if (!DockerTestUtils.canTestDocker()) { + return; + } + + DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker"); + + try { + // leave one CPU for system and tools, otherwise this test may be unstable + int maxNrOfAvailableCpus = availableCPUs - 1; + for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) { + testCPUInfo(i, i); + } + + long MB = 1024*1024; + testMemory("200m", "" + 200*MB); + testMemory("500m", "" + 500*MB); + testMemory("1g", "" + 1024*MB); + + testProcessInfo(); + + } finally { + DockerTestUtils.removeDockerImage(imageName); + } + } + + + private static void testCPUInfo(int valueToSet, int expectedValue) throws Exception { + Common.logNewTestCase("CPUInfo: --cpus = " + valueToSet); + DockerTestUtils.dockerRunJava( + commonDockerOpts() + .addDockerOpts("--cpus=" + valueToSet) + .addClassOptions(JfrReporter.TESTCASE_CPU)) + .shouldHaveExitValue(0) + .shouldContain(JfrReporter.TEST_REPORTED_CORES); + + // The following assertion is currently disabled due to JFR reporting incorrect values. + // JFR reports values for the host system as opposed to values for the container. + // @ignore 8219999 + // .shouldContain(JfrReporter.TEST_REPORTED_CORES + "=" + expectedValue); + } + + + private static void testMemory(String valueToSet, String expectedValue) throws Exception { + Common.logNewTestCase("Memory: --memory = " + valueToSet); + DockerTestUtils.dockerRunJava( + commonDockerOpts() + .addDockerOpts("--memory=" + valueToSet) + .addClassOptions(JfrReporter.TESTCASE_MEMORY)) + .shouldHaveExitValue(0) + .shouldContain(JfrReporter.TEST_REPORTED_MEMORY + "=" + expectedValue); + } + + + private static void testProcessInfo() throws Exception { + Common.logNewTestCase("ProcessInfo"); + DockerTestUtils.dockerRunJava( + commonDockerOpts() + .addClassOptions(JfrReporter.TESTCASE_PROCESS)) + .shouldHaveExitValue(0) + .shouldContain(JfrReporter.TEST_REPORTED_PID + "=1"); + + } + + + private static DockerRunOptions commonDockerOpts() { + return new DockerRunOptions(imageName, "/jdk/bin/java", "JfrReporter") + .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/") + .addJavaOpts("-cp", "/test-classes/"); + } +} diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/TestMemoryAwareness.java b/src/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/TestMemoryAwareness.java rename to src/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/TestMisc.java b/src/test/hotspot/jtreg/containers/docker/TestMisc.java similarity index 100% rename from src/test/hotspot/jtreg/runtime/containers/docker/TestMisc.java rename to src/test/hotspot/jtreg/containers/docker/TestMisc.java diff --git a/src/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java b/src/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java index cbf6bd15692..707673101b7 100644 --- a/src/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java +++ b/src/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,7 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; public class TestAggressiveHeap { @@ -88,9 +89,7 @@ private static boolean haveRequiredMemory() throws Exception { private static boolean canUseAggressiveHeapOption() throws Exception { if (!haveRequiredMemory()) { - System.out.println( - "Skipping test of " + option + " : insufficient memory"); - return false; + throw new SkippedException("Skipping test of " + option + " : insufficient memory"); } return true; } diff --git a/src/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java b/src/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java index b65079020f4..a08100dbbdb 100644 --- a/src/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java +++ b/src/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -43,6 +43,7 @@ import java.text.NumberFormat; import gc.testlibrary.Helpers; import static jdk.test.lib.Asserts.*; +import jtreg.SkippedException; public class TestHumongousShrinkHeap { @@ -61,13 +62,11 @@ public class TestHumongousShrinkHeap { public static void main(String[] args) { if (HUMON_COUNT == 0) { - System.out.println("Skipped. Heap is too small"); - return; + throw new SkippedException("Heap is too small"); } if (TOTAL_MEMORY + REGION_SIZE * HUMON_COUNT > MAX_MEMORY) { - System.out.println("Skipped. Initial heap size is to close to max heap size."); - return; + throw new SkippedException("Initial heap size is to close to max heap size."); } System.out.format("Running with %s initial heap size of %s maximum heap size. " diff --git a/src/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java b/src/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java index 997cc11a128..12972dffd16 100644 --- a/src/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java +++ b/src/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -43,6 +43,7 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Asserts; import jdk.test.lib.Platform; +import jtreg.SkippedException; import sun.hotspot.WhiteBox; public class TestLargePageUseForAuxMemory { @@ -134,13 +135,11 @@ public static void main(String[] args) throws Exception { final long heapAlignment = lcm(cardSize * smallPageSize, largePageSize); if (largePageSize == 0) { - System.out.println("Skip tests because large page support does not seem to be available on this platform."); - return; + throw new SkippedException("Large page support does not seem to be available on this platform."); } if (largePageSize == smallPageSize) { - System.out.println("Skip tests because large page support does not seem to be available on this platform." + - "Small and large page size are the same."); - return; + throw new SkippedException("Large page support does not seem to be available on this platform." + + "Small and large page size are the same."); } // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size). diff --git a/src/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/src/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java index cb25eac90d8..182a342e22b 100644 --- a/src/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java +++ b/src/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Utils; +import jtreg.SkippedException; + import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.MemoryUsage; @@ -69,10 +71,9 @@ protected void test() throws Exception { int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize())); if (maxCacheSize < hotCardTableSize) { - System.out.format("Skiping test for %d cache size due max cache size %d", - hotCardTableSize, maxCacheSize - ); - return; + throw new SkippedException(String.format( + "Skiping test for %d cache size due max cache size %d", + hotCardTableSize, maxCacheSize)); } printTestInfo(maxCacheSize); diff --git a/src/test/hotspot/jtreg/runtime/6819213/TestBootNativeLibraryPath.java b/src/test/hotspot/jtreg/runtime/6819213/TestBootNativeLibraryPath.java index 95f4c4b5d99..f43532b5dfd 100644 --- a/src/test/hotspot/jtreg/runtime/6819213/TestBootNativeLibraryPath.java +++ b/src/test/hotspot/jtreg/runtime/6819213/TestBootNativeLibraryPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, 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 @@ -24,12 +24,14 @@ /* * @test TestBootNativeLibraryPath.java * @bug 6819213 + * @summary verify sun.boot.native.library.path is expandable on 32 bit systems + * @author ksrini * @modules java.compiler + * @library /test/lib + * @requires vm.bits == 32 * @compile -XDignore.symbol.file TestBootNativeLibraryPath.java - * @summary verify sun.boot.native.library.path is expandable on 32 bit systems * @run main TestBootNativeLibraryPath - * @author ksrini -*/ + */ import java.io.BufferedReader; import java.io.File; @@ -108,10 +110,6 @@ static List<String> doExec(String... args) { public static void main(String[] args) { try { - if (!System.getProperty("sun.arch.data.model").equals("32")) { - System.out.println("Warning: test skipped for 64-bit systems\n"); - return; - } String osname = System.getProperty("os.name"); if (osname.startsWith("Windows")) { osname = "Windows"; diff --git a/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java b/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java index 97b15e296ae..1d396af3137 100644 --- a/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java +++ b/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java @@ -29,11 +29,13 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @run main CompressedClassPointers */ import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; public class CompressedClassPointers { @@ -139,17 +141,10 @@ public static void sharingTest() throws Exception { } public static void main(String[] args) throws Exception { - if (!Platform.is64bit()) { - // Can't test this on 32 bit, just pass - System.out.println("Skipping test on 32bit"); - return; - } - // Solaris 10 can't mmap compressed oops space without a base if (Platform.isSolaris()) { String name = System.getProperty("os.version"); if (name.equals("5.10")) { - System.out.println("Skipping test on Solaris 10"); - return; + throw new SkippedException("Solaris 10 can't mmap compressed oops space without a base"); } } smallHeapTest(); diff --git a/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java b/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java index 2d2b08dd00a..48cfc55b1e5 100644 --- a/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java +++ b/src/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,8 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @requires vm.bits == 64 + * @run main CompressedKlassPointerAndOops */ import jdk.test.lib.Platform; @@ -38,13 +40,6 @@ public class CompressedKlassPointerAndOops { public static void main(String[] args) throws Exception { - - if (!Platform.is64bit()) { - // Can't test this on 32 bit, just pass - System.out.println("Skipping test on 32bit"); - return; - } - runWithAlignment(16); runWithAlignment(32); runWithAlignment(64); diff --git a/src/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java b/src/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java index 2ec1df1ef6a..b4408b9d68c 100644 --- a/src/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java +++ b/src/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,15 @@ /* * @test - * @bug 8151486 + * @bug 8151486 8218266 * @summary Call Class.forName() on the system classloader from a class loaded * from a custom classloader, using the current class's protection domain. - * @library /test/jdk/lib/testlibrary - * @build jdk.testlibrary.Utils JarUtils + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @build jdk.test.lib.Utils + * jdk.test.lib.util.JarUtils * @build ClassForName ProtectionDomainCacheTest - * @run main/othervm/policy=test.policy -XX:+UnlockDiagnosticVMOptions -XX:VerifySubSet=dictionary -XX:+VerifyAfterGC -Xlog:gc+verify=debug,protectiondomain=trace,class+unload:gc.log -Djava.security.manager ProtectionDomainCacheTest + * @run main/othervm/policy=test.policy -Djava.security.manager ProtectionDomainCacheTest */ import java.net.URL; @@ -39,49 +41,71 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import jdk.testlibrary.Utils; +import jdk.test.lib.Utils; +import jdk.test.lib.util.JarUtils; +import java.io.File; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * Create .jar, load ClassForName from .jar using a URLClassLoader */ public class ProtectionDomainCacheTest { - private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR); - private static final String TESTCLASSES = System.getProperty("test.classes", "."); - private static final String CLASSFILENAME = "ClassForName.class"; + static class Test { + private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR); + private static final String TESTCLASSES = System.getProperty("test.classes", "."); + private static final String CLASSFILENAME = "ClassForName.class"; - // Use a new classloader to load the ClassForName class. - public static void loadAndRun(Path jarFilePath) - throws Exception { - ClassLoader classLoader = new URLClassLoader( - new URL[]{jarFilePath.toUri().toURL()}) { - @Override public String toString() { return "LeakedClassLoader"; } - }; + // Use a new classloader to load the ClassForName class. + public static void loadAndRun(Path jarFilePath) + throws Exception { + ClassLoader classLoader = new URLClassLoader( + new URL[]{jarFilePath.toUri().toURL()}) { + @Override public String toString() { return "LeakedClassLoader"; } + }; - Class<?> loadClass = Class.forName("ClassForName", true, classLoader); - loadClass.newInstance(); + Class<?> loadClass = Class.forName("ClassForName", true, classLoader); + loadClass.newInstance(); - System.out.println("returning : " + classLoader); - } + System.out.println("returning : " + classLoader); + } - public static void main(final String[] args) throws Exception { - // Create a temporary .jar file containing ClassForName.class - Path testClassesDir = Paths.get(TESTCLASSES); - Path jarFilePath = Files.createTempFile("cfn", ".jar"); - JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME); - jarFilePath.toFile().deleteOnExit(); + public static void main(final String[] args) throws Exception { + // Create a temporary .jar file containing ClassForName.class + Path testClassesDir = Paths.get(TESTCLASSES); + Path jarFilePath = Files.createTempFile("cfn", ".jar"); + JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME); + jarFilePath.toFile().deleteOnExit(); - // Remove the ClassForName.class file that jtreg built, to make sure - // we're loading from the tmp .jar - Path classFile = FileSystems.getDefault().getPath(TESTCLASSES, - CLASSFILENAME); - Files.delete(classFile); + // Remove the ClassForName.class file that jtreg built, to make sure + // we're loading from the tmp .jar + Path classFile = FileSystems.getDefault().getPath(TESTCLASSES, + CLASSFILENAME); + Files.delete(classFile); - loadAndRun(jarFilePath); + loadAndRun(jarFilePath); - // Give the GC a chance to unload protection domains - for (int i = 0; i < 100; i++) { - System.gc(); + // Give the GC a chance to unload protection domains + for (int i = 0; i < 100; i++) { + System.gc(); + } + System.out.println("All Classloaders and protection domain cache entries successfully unloaded"); } - System.out.println("All Classloaders and protection domain cache entries successfully unloaded"); + } + + public static void main(String args[]) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Djava.security.policy==" + System.getProperty("test.src") + File.separator + "test.policy", + "-Dtest.classes=" + System.getProperty("test.classes", "."), + "-XX:+UnlockDiagnosticVMOptions", + "-XX:VerifySubSet=dictionary", + "-XX:+VerifyAfterGC", + "-Xlog:gc+verify,protectiondomain=debug", + "-Djava.security.manager", + Test.class.getName()); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("PD in set is not alive"); + output.shouldHaveExitValue(0); } } diff --git a/src/test/hotspot/jtreg/runtime/Dictionary/test.policy b/src/test/hotspot/jtreg/runtime/Dictionary/test.policy index 46145b9fa41..06998b8bcae 100644 --- a/src/test/hotspot/jtreg/runtime/Dictionary/test.policy +++ b/src/test/hotspot/jtreg/runtime/Dictionary/test.policy @@ -1,5 +1,5 @@ grant { - permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete"; + permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute"; permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.util.PropertyPermission "*", "read"; /* for Utils */ diff --git a/src/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java b/src/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java index d820809a791..b5ccb718499 100644 --- a/src/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java +++ b/src/test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java @@ -66,7 +66,7 @@ public static void main(String[] args) throws Exception { String[] patterns = { "(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=", - "(SIGBUS|SIGSEGV|SIGILL|EXCEPTION_ACCESS_VIOLATION).* at pc=" + // -XX:ErrorHandlerTest=13 is too unreliable. It sometimes fails to crash in the expected way. // -XX:ErrorHandlerTest=14 is tested by SafeFetchInErrorHandlingTest.java // -XX:ErrorHandlerTest=15 is tested by SecondaryErrorTest.java // -XX:ErrorHandlerTest=16 is tested by ThreadsListHandleInErrorHandlingTest.java diff --git a/src/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java b/src/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java index fbb90854c6a..a54a63fa825 100644 --- a/src/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java +++ b/src/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,12 @@ /* * @test TestOnError + * @bug 8078470 * @summary Test using -XX:OnError=<cmd> * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.debug * @run main TestOnError - * @bug 8078470 */ import jdk.test.lib.process.ProcessTools; @@ -37,11 +38,6 @@ public class TestOnError { public static void main(String[] args) throws Exception { - if (!Platform.isDebugBuild()) { - System.out.println("Test requires a non-product build - skipping"); - return; - } - String msg = "Test Succeeded"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( diff --git a/src/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java b/src/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java index 636f3103569..dded8d37d67 100644 --- a/src/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java +++ b/src/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java @@ -67,7 +67,7 @@ private static void doTheTest(boolean usesCompressedClassSpace) throws Exception } output.shouldContain("Virtual space:"); output.shouldContain("Chunk freelists:"); - + output.shouldMatch("MaxMetaspaceSize:.*201.00.*MB"); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace"}); output = new OutputAnalyzer(pb.start()); diff --git a/src/test/hotspot/jtreg/runtime/NMT/SafepointPollingPages.java b/src/test/hotspot/jtreg/runtime/NMT/SafepointPollingPages.java new file mode 100644 index 00000000000..c4e70950ae2 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/NMT/SafepointPollingPages.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8208499 + * @summary NMT should report safepoint polling page(s) + * @key nmt jcmd + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @comment On ppc, with UseSIGTRAP on, no polling pages are used, but trap instructions instead. + * @run main/othervm -XX:-UseSIGTRAP -XX:+IgnoreUnrecognizedVMOptions -Xbootclasspath/a:. -XX:NativeMemoryTracking=summary -XX:+ThreadLocalHandshakes SafepointPollingPages + * @run main/othervm -XX:-UseSIGTRAP -XX:+IgnoreUnrecognizedVMOptions -Xbootclasspath/a:. -XX:NativeMemoryTracking=summary -XX:-ThreadLocalHandshakes SafepointPollingPages + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.JDKToolFinder; +import jdk.internal.misc.Unsafe; + +public class SafepointPollingPages { + public static void main(String args[]) throws Exception { + OutputAnalyzer output; + + // Grab my own PID + String pid = Long.toString(ProcessTools.getProcessId()); + ProcessBuilder pb = new ProcessBuilder(); + + // Run 'jcmd <pid> VM.native_memory summary' + pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Safepoint (reserved="); + } +} + diff --git a/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java b/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java index 517c0487490..3f3fc5cc34a 100644 --- a/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java +++ b/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java @@ -29,10 +29,12 @@ * is different from object alignment for creating a CDS file * should fail when loading. * @requires vm.cds + * @requires vm.bits == 64 * @library /test/lib * @bug 8025642 * @modules java.base/jdk.internal.misc * java.management + * @run main CdsDifferentObjectAlignment */ import jdk.test.lib.cds.CDSTestUtils; @@ -40,20 +42,12 @@ import jdk.test.lib.Platform; public class CdsDifferentObjectAlignment { + public static void main(String[] args) throws Exception { - String nativeWordSize = System.getProperty("sun.arch.data.model"); - if (!Platform.is64bit()) { - System.out.println("ObjectAlignmentInBytes for CDS is only " + - "supported on 64bit platforms; this plaform is " + - nativeWordSize); - System.out.println("Skipping the test"); - } else { - createAndLoadSharedArchive(16, 64); - createAndLoadSharedArchive(64, 32); - } + createAndLoadSharedArchive(16, 64); + createAndLoadSharedArchive(64, 32); } - // Parameters are object alignment expressed in bytes private static void createAndLoadSharedArchive(int createAlignment, int loadAlignment) diff --git a/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsSameObjectAlignment.java b/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsSameObjectAlignment.java index 791ea3e7501..fabeb20e4b5 100644 --- a/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsSameObjectAlignment.java +++ b/src/test/hotspot/jtreg/runtime/SharedArchiveFile/CdsSameObjectAlignment.java @@ -26,29 +26,24 @@ * @summary Testing CDS (class data sharing) using varying object alignment. * Using same object alignment for each dump/load pair * @requires vm.cds + * @requires vm.bits == 64 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @run main CdsSameObjectAlignment */ import jdk.test.lib.Platform; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; public class CdsSameObjectAlignment { public static void main(String[] args) throws Exception { - String nativeWordSize = System.getProperty("sun.arch.data.model"); - if (!Platform.is64bit()) { - System.out.println("ObjectAlignmentInBytes for CDS is only " + - "supported on 64bit platforms; this plaform is " + - nativeWordSize); - System.out.println("Skipping the test"); - } else { - dumpAndLoadSharedArchive(8); - dumpAndLoadSharedArchive(16); - dumpAndLoadSharedArchive(32); - dumpAndLoadSharedArchive(64); - } + dumpAndLoadSharedArchive(8); + dumpAndLoadSharedArchive(16); + dumpAndLoadSharedArchive(32); + dumpAndLoadSharedArchive(64); } private static void diff --git a/src/test/hotspot/jtreg/runtime/VtableTests/VTableTest.java b/src/test/hotspot/jtreg/runtime/VtableTests/VTableTest.java new file mode 100644 index 00000000000..2ca32e43f06 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/VtableTests/VTableTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8226798 + * @summary Check that the vTable for class C gets set up without causing + * an assertion failure. + * @compile pkg/A.java + * @run main VTableTest + */ + +public class VTableTest { + + interface Intf { + public default void m() { } + public default void unusedButNeededToReproduceIssue() { } + } + + static class B extends pkg.A implements Intf { + } + + static class C extends B { + public void m() { System.out.println("In C.m()"); } + } + + public static void main(String[] args) { + new C().m(); + } +} diff --git a/src/test/hotspot/jtreg/runtime/VtableTests/pkg/A.java b/src/test/hotspot/jtreg/runtime/VtableTests/pkg/A.java new file mode 100644 index 00000000000..a4b7f49e715 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/VtableTests/pkg/A.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public class A { + void m() { } +} diff --git a/src/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java b/src/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java index 62cc40968ba..71c14e1a737 100644 --- a/src/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java +++ b/src/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, 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 @@ -28,6 +28,7 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @requires os.family == "solaris" | os.family == "linux" | os.family == "mac" * @run main XCheckJSig */ @@ -36,15 +37,12 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; +import jtreg.SkippedException; public class XCheckJSig { public static void main(String args[]) throws Throwable { System.out.println("Regression test for bugs 7051189 and 8023393"); - if (!Platform.isSolaris() && !Platform.isLinux() && !Platform.isOSX()) { - System.out.println("Test only applicable on Solaris, Linux, and Mac OSX, skipping"); - return; - } String jdk_path = System.getProperty("test.jdk"); String os_arch = Platform.getOsArch(); @@ -69,8 +67,7 @@ public static void main(String args[]) throws Throwable { // Make sure the libjsig file exists. if (!(new File(libjsig).exists())) { - System.out.println("File " + libjsig + " not found, skipping"); - return; + throw new jtreg.SkippedException("File " + libjsig + " not found"); } ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-version"); diff --git a/src/test/hotspot/jtreg/runtime/appcds/TestCommon.java b/src/test/hotspot/jtreg/runtime/appcds/TestCommon.java index b15ea0c8a91..bae96055d1d 100644 --- a/src/test/hotspot/jtreg/runtime/appcds/TestCommon.java +++ b/src/test/hotspot/jtreg/runtime/appcds/TestCommon.java @@ -33,6 +33,7 @@ import jdk.test.lib.process.OutputAnalyzer; import java.io.File; import java.text.SimpleDateFormat; +import java.util.Arrays; import java.util.ArrayList; import java.util.Date; @@ -343,4 +344,22 @@ public static String getTestDir(String d) { } return dirFile.getPath(); } + + public static boolean checkOutputStrings(String outputString1, + String outputString2, + String split_regex) { + String[] sa1 = outputString1.split(split_regex); + String[] sa2 = outputString2.split(split_regex); + Arrays.sort(sa1); + Arrays.sort(sa2); + + int i = 0; + for (String s : sa1) { + if (!s.equals(sa2[i])) { + throw new RuntimeException(s + " is different from " + sa2[i]); + } + i ++; + } + return true; + } } diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleComboTest.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleComboTest.java new file mode 100644 index 00000000000..accf3327096 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleComboTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test + * @summary Test archived system module sub-graph and verify objects are archived. + * @requires vm.cds.archived.java.heap + * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @modules java.base/jdk.internal.misc + * java.management + * jdk.jartool/sun.tools.jar + * @build sun.hotspot.WhiteBox + * @compile CheckArchivedModuleApp.java + * @run driver ClassFileInstaller -jar app.jar CheckArchivedModuleApp + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox + * @run main ArchivedModuleComboTest + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import sun.hotspot.WhiteBox; + +public class ArchivedModuleComboTest { + public static void main(String[] args) throws Exception { + String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar"); + String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; + String appJar = ClassFileInstaller.getJarPath("app.jar"); + + Path userDir = Paths.get(System.getProperty("user.dir")); + Path moduleDir = Files.createTempDirectory(userDir, "mods"); + + // Dump without --module-path + OutputAnalyzer output = TestCommon.dump(appJar, + TestCommon.list("CheckArchivedModuleApp"), + use_whitebox_jar); + TestCommon.checkDump(output); + + // Test case 1) + // - Dump without --module-path + // - Run from -cp only, archived boot layer module ModuleDescriptors + // should be used. + System.out.println("----------------------- Test case 1 ----------------------"); + output = TestCommon.exec(appJar, use_whitebox_jar, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "CheckArchivedModuleApp", + "yes"); + TestCommon.checkExec(output); + + // Test case 2) + // - Dump without --module-path + // - Run from -cp only, archived boot layer module ModuleDescriptors + // should be used with --show-module-resolution (requires resolution). + System.out.println("----------------------- Test case 2 ----------------------"); + output = TestCommon.exec(appJar, use_whitebox_jar, + "--show-module-resolution", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "CheckArchivedModuleApp", + "yes"); + TestCommon.checkExec(output); + + // Test case 3) + // - Dump without --module-path + // - Run with --module-path, archived boot layer module ModuleDescriptors + // should be disabled. + System.out.println("----------------------- Test case 3 ----------------------"); + output = TestCommon.exec(appJar, use_whitebox_jar, + "--module-path", + moduleDir.toString(), + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "CheckArchivedModuleApp", + "no"); + TestCommon.checkExec(output); + + // Dump with --module-path specified (test case 4, 5). Use an + // empty directory as it's simple and still triggers the case + // where system module objects are not archived. + output = TestCommon.dump(appJar, + TestCommon.list("CheckArchivedModuleApp"), + "--module-path", + moduleDir.toString(), + use_whitebox_jar); + TestCommon.checkDump(output); + + // Test case 4) + // - Dump with --module-path + // - Run from -cp only, no archived boot layer module ModuleDescriptors + // should be found. + System.out.println("----------------------- Test case 4 ----------------------"); + output = TestCommon.exec(appJar, use_whitebox_jar, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "CheckArchivedModuleApp", + "no"); + TestCommon.checkExec(output); + + // Test case 5) + // - Dump with --module-path + // - Run with --module-path, no archived boot layer module ModuleDescriptors + // should be found. + System.out.println("----------------------- Test case 5 ----------------------"); + output = TestCommon.exec(appJar, use_whitebox_jar, + "--module-path", + moduleDir.toString(), + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "CheckArchivedModuleApp", + "no"); + TestCommon.checkExec(output); + } +} diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleCompareTest.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleCompareTest.java new file mode 100644 index 00000000000..d8cf4cbc271 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleCompareTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test + * @summary Compare archived system modules with non-archived. + * @requires vm.cds.archived.java.heap + * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @modules java.base/jdk.internal.misc + * java.management + * jdk.jartool/sun.tools.jar + * @compile PrintSystemModulesApp.java + * @run driver ClassFileInstaller -jar app.jar PrintSystemModulesApp + * @run main ArchivedModuleCompareTest + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class ArchivedModuleCompareTest { + public static void main(String[] args) throws Exception { + String appJar = ClassFileInstaller.getJarPath("app.jar"); + + // Test case 1) + // Compare the list of archived system module names with non-archived + // list. They must be the same. + System.out.println("---------------- Test case 1 -----------------"); + OutputAnalyzer output = TestCommon.dump(appJar, + TestCommon.list("PrintSystemModulesApp")); + TestCommon.checkDump(output); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-cp", appJar, + "-Xshare:off", + "PrintSystemModulesApp"); + output = TestCommon.executeAndLog(pb, "print.system.module.share.off"); + output.shouldHaveExitValue(0); + String bootModules1 = output.getStdout(); + + output = TestCommon.exec(appJar, + "PrintSystemModulesApp"); + TestCommon.checkExec(output); + if (output.getStderr().contains("sharing")) { + String bootModules2 = output.getStdout(); + TestCommon.checkOutputStrings(bootModules1, bootModules2, ", "); + } + + // Test case 2) + // Verify --show-module-resolution output with the output from + // -Xshare:off run + System.out.println("---------------- Test case 2 -----------------"); + pb = ProcessTools.createJavaProcessBuilder( + "-Xshare:off", + "--show-module-resolution", + "-version"); + output = TestCommon.executeAndLog(pb, "show.module.resolution.share.off"); + output.shouldHaveExitValue(0); + String moduleResolutionOut1 = output.getStdout(); + + output = TestCommon.exec(appJar, + "--show-module-resolution", + "-version"); + TestCommon.checkExec(output); + if (output.getStderr().contains("sharing")) { + String moduleResolutionOut2 = output.getStdout(); + TestCommon.checkOutputStrings( + moduleResolutionOut1, moduleResolutionOut2, "\n"); + } + } +} diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java new file mode 100644 index 00000000000..1a2e07103d3 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java @@ -0,0 +1,184 @@ +/** + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Test archived module graph with custom runtime image + * @requires vm.cds.archived.java.heap + * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @modules java.base/jdk.internal.module + * java.management + * jdk.jlink + * jdk.compiler + * @build sun.hotspot.WhiteBox + * @compile CheckArchivedModuleApp.java + * @run driver ClassFileInstaller -jar app.jar CheckArchivedModuleApp + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox + * @run main ArchivedModuleWithCustomImageTest + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class ArchivedModuleWithCustomImageTest { + private static final String JAVA_HOME = System.getProperty("java.home"); + private static final String TEST_MODULE = "test"; + private static final Path jdkHome = Paths.get(System.getProperty("test.jdk")); + private static final Path jdkMods = jdkHome.resolve("jmods"); + private static final Path testSrc = Paths.get(System.getProperty("test.src")); + private static final Path src = testSrc.resolve("src").resolve(TEST_MODULE); + private static final Path classes = Paths.get("classes"); + private static final Path jmods = Paths.get("jmods"); + + public static void main(String[] args) throws Throwable { + if (Files.notExists(jdkMods)) { + System.out.println("No jmods/ in test JDK, not supported."); + return; + } + + // compile test module class + if (!CompilerUtils.compile(src, classes)) { + throw new RuntimeException("Compilation failure."); + } + + // create custom runtime image named 'myimage' + Files.createDirectories(jmods); + Path image = Paths.get("myimage"); + runJmod(classes.toString(), TEST_MODULE); + runJlink(image, TEST_MODULE); + + // test using 'myimage' + testArchivedModuleUsingImage(image); + + Files.delete(jmods.resolve(TEST_MODULE + ".jmod")); + } + + private static void runJlink(Path image, String modName) throws Throwable { + Path jlink = Paths.get(JAVA_HOME, "bin", "jlink"); + OutputAnalyzer output = ProcessTools.executeProcess(jlink.toString(), + "--output", image.toString(), + "--add-modules", modName, + "--module-path", jdkMods + File.pathSeparator + jmods); + output.shouldHaveExitValue(0); + } + + private static void runJmod(String cp, String modName) throws Throwable { + Path jmod = Paths.get(JAVA_HOME, "bin", "jmod"); + OutputAnalyzer output = ProcessTools.executeProcess(jmod.toString(), + "create", + "--class-path", cp, + "--module-version", "1.0", + "--main-class", "jdk.test.Test", + jmods.resolve(modName + ".jmod").toString()); + output.shouldHaveExitValue(0); + } + + private static void testArchivedModuleUsingImage(Path image) + throws Throwable { + String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar"); + String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; + String appJar = ClassFileInstaller.getJarPath("app.jar"); + Path customJava = Paths.get(image.toString(), "bin", "java"); + + // -Xshare:dump with custom runtime image + String[] dumpCmd = { + customJava.toString(), + "-XX:SharedArchiveFile=./ArchivedModuleWithCustomImageTest.jsa", + "-Xshare:dump"}; + printCommand(dumpCmd); + ProcessBuilder pbDump = new ProcessBuilder(); + pbDump.command(dumpCmd); + OutputAnalyzer output = TestCommon.executeAndLog( + pbDump, "custom.runtime.image.dump"); + TestCommon.checkDump(output); + + // Test case 1): + // test archived module graph objects are used with custome runtime image + System.out.println("------------------- Test case 1 -------------------"); + String[] runCmd = {customJava.toString(), + use_whitebox_jar, + "-XX:SharedArchiveFile=./ArchivedModuleWithCustomImageTest.jsa", + "-cp", + appJar, + "-Xshare:on", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "CheckArchivedModuleApp", + "yes"}; + printCommand(runCmd); + ProcessBuilder pbRun = new ProcessBuilder(); + pbRun.command(runCmd); + output = TestCommon.executeAndLog(pbRun, "custom.runtime.image.run"); + output.shouldHaveExitValue(0); + + + // Test case 2): + // verify --show-module-resolution output + System.out.println("------------------- Test case 2 -------------------"); + + // myimage/bin/java -Xshare:off --show-module-resolution -version + String[] showModuleCmd1 = {customJava.toString(), + "-Xshare:off", + "--show-module-resolution", + "-version"}; + printCommand(showModuleCmd1); + pbRun = new ProcessBuilder(); + pbRun.command(showModuleCmd1); + output = TestCommon.executeAndLog( + pbRun, "custom.runtime.image.showModuleResolution.nocds"); + output.shouldHaveExitValue(0); + String moduleResolutionOut1 = output.getStdout(); + + // myimage/bin/java -Xshare:on --show-module-resolution -version + // -XX:SharedArchiveFile=./ArchivedModuleWithCustomImageTest.jsa + String[] showModuleCmd2 = { + customJava.toString(), + "-XX:SharedArchiveFile=./ArchivedModuleWithCustomImageTest.jsa", + "-Xshare:on", + "--show-module-resolution", + "-version"}; + printCommand(showModuleCmd2); + pbRun = new ProcessBuilder(); + pbRun.command(showModuleCmd2); + output = TestCommon.executeAndLog( + pbRun, "custom.runtime.image.showModuleResolution.cds"); + if (output.getStderr().contains("sharing")) { + String moduleResolutionOut2 = output.getStdout(); + TestCommon.checkOutputStrings( + moduleResolutionOut1, moduleResolutionOut2, "\n"); + } + } + + private static void printCommand(String opts[]) { + StringBuilder cmdLine = new StringBuilder(); + for (String cmd : opts) + cmdLine.append(cmd).append(' '); + System.out.println("Command line: [" + cmdLine.toString() + "]"); + } +} diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckArchivedModuleApp.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckArchivedModuleApp.java new file mode 100644 index 00000000000..144c71b9983 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckArchivedModuleApp.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +import java.io.File; +import java.lang.module.ModuleDescriptor; +import java.util.Set; +import sun.hotspot.WhiteBox; + +// +// Test archived system module graph when open archive heap objects are mapped: +// +public class CheckArchivedModuleApp { + static WhiteBox wb; + public static void main(String args[]) throws Exception { + wb = WhiteBox.getWhiteBox(); + + if (!wb.areOpenArchiveHeapObjectsMapped()) { + System.out.println("Archived open_archive_heap objects are not mapped."); + System.out.println("This may happen during normal operation. Test Skipped."); + return; + } + + boolean expectArchived = "yes".equals(args[0]); + checkModuleDescriptors(expectArchived); + } + + private static void checkModuleDescriptors(boolean expectArchived) { + Set<Module> modules = ModuleLayer.boot().modules(); + for (Module m : modules) { + ModuleDescriptor md = m.getDescriptor(); + String name = md.name(); + if (expectArchived) { + if (wb.isShared(md)) { + System.out.println(name + " is archived. Expected."); + } else { + throw new RuntimeException( + "FAILED. " + name + " is not archived. Expect archived."); + } + } else { + if (!wb.isShared(md)) { + System.out.println(name + " is not archived. Expected."); + } else { + throw new RuntimeException( + "FAILED. " + name + " is archived. Expect not archived."); + } + } + } + } +} diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/PrintSystemModulesApp.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/PrintSystemModulesApp.java new file mode 100644 index 00000000000..44d4cebf819 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/PrintSystemModulesApp.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// +// Print the system module names +// +public class PrintSystemModulesApp { + public static void main(String args[]) throws Exception { + String modules = ModuleLayer.boot().toString(); + System.out.println(modules + ", "); + } +} diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/src/test/jdk/test/Test.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/src/test/jdk/test/Test.java new file mode 100644 index 00000000000..9d1ab13daaf --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/src/test/jdk/test/Test.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test; + +public class Test { + public static void main(String[] args) { + ClassLoader scl = ClassLoader.getSystemClassLoader(); + ClassLoader cl1 = Test.class.getClassLoader(); + Module testModule = Test.class.getModule(); + ClassLoader cl2 = ModuleLayer.boot().findLoader(testModule.getName()); + + if (cl1 != scl) + throw new RuntimeException("Not loaded by system class loader"); + if (cl2 != scl) + throw new RuntimeException("Not associated with system class loader"); + + } +} diff --git a/src/test/hotspot/jtreg/runtime/appcds/cacheObject/src/test/module-info.java b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/src/test/module-info.java new file mode 100644 index 00000000000..1972e2c7379 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/appcds/cacheObject/src/test/module-info.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +module test { +} diff --git a/src/test/hotspot/jtreg/runtime/condy/staticInit/Example.jasm b/src/test/hotspot/jtreg/runtime/condy/staticInit/Example.jasm new file mode 100644 index 00000000000..708f5c65b45 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/condy/staticInit/Example.jasm @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// This class gets an initialization error in a condy invokestatic. Need jasm so that StaticInit isn't +// initialized before the condy call. +// Test that second invocation gets same error as first. + +public class Example + version 55:0 +{ + + +static Method $jacocoInit:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;" + stack 1 locals 3 +{ + invokestatic Method StaticInit.get:"()Ljava/lang/Object;"; + areturn; +} + +public static Method foo:"()V" + stack 1 locals 2 +{ + ldc Dynamic REF_invokeStatic:Example.$jacocoInit:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;":$jacocoData:"Ljava/lang/Object;"; + astore_1; + return; +} + +public static Method main:"([Ljava/lang/String;)V" + stack 1 locals 2 +{ + try t0; + invokestatic Method Example.foo:"()V"; + endtry t0; + goto L7; + catch t0 java/lang/Error; + stack_frame_type stack1; + stack_map class java/lang/Error; + astore_1; + aload_1; + invokevirtual Method java/lang/Error.printStackTrace:"()V"; + L7: stack_frame_type same; + invokestatic Method Example.foo:"()V"; + return; +} +} // end Class Example diff --git a/src/test/hotspot/jtreg/runtime/condy/staticInit/StaticInit.java b/src/test/hotspot/jtreg/runtime/condy/staticInit/StaticInit.java new file mode 100644 index 00000000000..7926c6997f6 --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/condy/staticInit/StaticInit.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +class StaticInit { + static { + if (true) + throw new RuntimeException(); + } + + static Object get() { + return new Object(); + } +} diff --git a/src/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java b/src/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java new file mode 100644 index 00000000000..39580a3d3ba --- /dev/null +++ b/src/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8228485 + * @summary Correctly handle initialization error for Condy BSM. + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @compile Example.jasm + * @compile StaticInit.java + * @run main/othervm TestInitException + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestInitException { + public static void main(java.lang.String[] unused) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("Example"); + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); + // First call stack trace + oa.shouldContain("at Example.$jacocoInit(Example.jasm)"); + oa.shouldContain("Caused by: java.lang.RuntimeException"); + oa.shouldContain("at StaticInit.<clinit>(StaticInit.java:27)"); + // Second call stack trace, with the message + oa.shouldContain("java.lang.ExceptionInInitializerError: $jacocoData"); + oa.shouldContain("at Example.foo(Example.jasm)"); + oa.shouldContain("at Example.main(Example.jasm)"); + oa.shouldHaveExitValue(1); + } +} + diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest b/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest deleted file mode 100644 index 166c969289e..00000000000 --- a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest +++ /dev/null @@ -1,8 +0,0 @@ -FROM oraclelinux:7.2 -MAINTAINER mikhailo.seledtsov@oracle.com - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-aarch64 b/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-aarch64 deleted file mode 100644 index 082a4d89ed0..00000000000 --- a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-aarch64 +++ /dev/null @@ -1,8 +0,0 @@ -# Use generic ubuntu Linux on AArch64 -FROM aarch64/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-ppc64le b/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-ppc64le deleted file mode 100644 index 57dfb0f86b9..00000000000 --- a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-ppc64le +++ /dev/null @@ -1,10 +0,0 @@ -# test on x86_64 uses Oracle Linux but we do not have this for ppc64le -# so use some other Linux where OpenJDK works -# FROM oraclelinux:7.2 -FROM ppc64le/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-s390x b/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-s390x deleted file mode 100644 index 940b36edebb..00000000000 --- a/src/test/hotspot/jtreg/runtime/containers/docker/Dockerfile-BasicTest-s390x +++ /dev/null @@ -1,7 +0,0 @@ -FROM s390x/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/hotspot/jtreg/runtime/jni/checked/TestCheckedEnsureLocalCapacity.java b/src/test/hotspot/jtreg/runtime/jni/checked/TestCheckedEnsureLocalCapacity.java index 87e5d7d1baf..e9b92578ba8 100644 --- a/src/test/hotspot/jtreg/runtime/jni/checked/TestCheckedEnsureLocalCapacity.java +++ b/src/test/hotspot/jtreg/runtime/jni/checked/TestCheckedEnsureLocalCapacity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -47,10 +47,13 @@ public class TestCheckedEnsureLocalCapacity { { 1, 45 } // bad: copies >> capacity }; + // Patterns EXCEED_WARNING and WARNING are not anchored to the beginning + // of lines to allow matching interleaved output. + private static final String EXCEED_WARNING = - "^WARNING: JNI local refs: \\d++, exceeds capacity:"; + "WARNING: JNI local refs: \\d++, exceeds capacity:"; - private static final String WARNING = "^WARNING: "; + private static final String WARNING = "WARNING:"; public static void main(String[] args) throws Throwable { if (args.length == 2) { diff --git a/src/test/hotspot/jtreg/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java b/src/test/hotspot/jtreg/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java index 1c3220333d4..a2c31e3993e 100644 --- a/src/test/hotspot/jtreg/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java +++ b/src/test/hotspot/jtreg/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -21,7 +21,6 @@ * questions. */ - /* * @test Testlibadimalloc.java * @bug 8141445 @@ -37,6 +36,7 @@ import java.nio.file.*; import java.util.*; import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; public class Testlibadimalloc { @@ -50,8 +50,7 @@ public static void main(String[] args) throws Throwable { // If the libadimalloc.so file does not exist, pass the test if (!(Files.isRegularFile(path) || Files.isSymbolicLink(path))) { - System.out.println("Test skipped; libadimalloc.so does not exist"); - return; + throw new SkippedException("libadimalloc.so does not exist"); } // Get the JDK, library and class path properties diff --git a/src/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java b/src/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java index 71511695359..b7dbf71b326 100644 --- a/src/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java +++ b/src/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, 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 @@ -24,6 +24,7 @@ /* @test TestLargePagesFlags * @summary Tests how large pages are choosen depending on the given large pages flag combinations. * @requires vm.gc != "Z" + * @requires os.family == "linux" * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -33,16 +34,12 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; + import java.util.ArrayList; public class TestLargePagesFlags { public static void main(String [] args) throws Exception { - if (!Platform.isLinux()) { - System.out.println("Skipping. TestLargePagesFlags has only been implemented for Linux."); - return; - } - testUseTransparentHugePages(); testUseHugeTLBFS(); testUseSHM(); diff --git a/src/test/hotspot/jtreg/runtime/os/AvailableProcessors.java b/src/test/hotspot/jtreg/runtime/os/AvailableProcessors.java index 29a496ccabb..8d88e0e6292 100644 --- a/src/test/hotspot/jtreg/runtime/os/AvailableProcessors.java +++ b/src/test/hotspot/jtreg/runtime/os/AvailableProcessors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -20,10 +20,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -import java.io.File; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import java.util.ArrayList; /* * @test @@ -34,6 +30,14 @@ * @library /test/lib * @run driver AvailableProcessors */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; + +import java.util.ArrayList; +import java.io.File; + public class AvailableProcessors { static final String SUCCESS_STRING = "Found expected processors: "; @@ -47,20 +51,18 @@ public static void main(String[] args) throws Exception { String taskset; final String taskset1 = "/bin/taskset"; final String taskset2 = "/usr/bin/taskset"; - if (new File(taskset1).exists()) + if (new File(taskset1).exists()) { taskset = taskset1; - else if (new File(taskset2).exists()) + } else if (new File(taskset2).exists()) { taskset = taskset2; - else { - System.out.println("Skipping test: could not find taskset command"); - return; + } else { + throw new SkippedException("Could not find taskset command"); } int available = Runtime.getRuntime().availableProcessors(); if (available == 1) { - System.out.println("Skipping test: only one processor available"); - return; + throw new SkippedException("only one processor available"); } // Get the java command we want to execute diff --git a/src/test/hotspot/jtreg/runtime/signal/SigTestDriver.java b/src/test/hotspot/jtreg/runtime/signal/SigTestDriver.java index ea548f3b97c..dffbf2a17fd 100644 --- a/src/test/hotspot/jtreg/runtime/signal/SigTestDriver.java +++ b/src/test/hotspot/jtreg/runtime/signal/SigTestDriver.java @@ -25,6 +25,7 @@ import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; import java.io.File; import java.nio.file.Path; @@ -40,8 +41,7 @@ public class SigTestDriver { public static void main(String[] args) { // No signal tests on Windows yet; so setting to no-op if (Platform.isWindows()) { - System.out.println("SKIPPED: no signal tests on Windows, ignore."); - return; + throw new SkippedException("no signal tests on Windows"); } // At least one argument should be specified @@ -54,16 +54,13 @@ public static void main(String[] args) { case "SIGWAITING": case "SIGKILL": case "SIGSTOP": { - System.out.println("SKIPPED: signals SIGWAITING, SIGKILL and SIGSTOP can't be tested, ignore."); - return; + throw new SkippedException("signals SIGWAITING, SIGKILL and SIGSTOP can't be tested"); } case "SIGUSR2": { if (Platform.isLinux()) { - System.out.println("SKIPPED: SIGUSR2 can't be tested on Linux, ignore."); - return; + throw new SkippedException("SIGUSR2 can't be tested on Linux"); } else if (Platform.isOSX()) { - System.out.println("SKIPPED: SIGUSR2 can't be tested on OS X, ignore."); - return; + throw new SkippedException("SIGUSR2 can't be tested on OS X"); } } } diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java b/src/test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java new file mode 100644 index 00000000000..a4f3c466d25 --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/dcmd/compiler/CodeHeapAnalyticsParams.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.dcmd.PidJcmdExecutor; + +/* + * @test CodeHeapAnalyticsParams + * @key jcmd + * @summary Test the Compiler.CodeHeap_Analytics command + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run driver CodeHeapAnalyticsParams + */ + +public class CodeHeapAnalyticsParams { + + public static void main(String args[]) throws Exception { + PidJcmdExecutor executor = new PidJcmdExecutor(); + executor.execute("Compiler.CodeHeap_Analytics all 1").shouldHaveExitValue(0); + executor.execute("Compiler.CodeHeap_Analytics all 0").shouldHaveExitValue(1); + executor.execute("Compiler.CodeHeap_Analytics all k").shouldHaveExitValue(1); + } +} diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java index d88ddffce71..5e159aaeb9e 100644 --- a/src/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -33,6 +33,7 @@ * @test * @summary Test of diagnostic command help (tests all DCMD executors) * @library /test/lib + * /vmTestbase * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -55,7 +56,13 @@ public void pid() { @Test public void mainClass() { - run(new MainClassJcmdExecutor()); + TestProcessLauncher t = new TestProcessLauncher(Process.class.getName()); + try { + t.launch(); + run(new MainClassJcmdExecutor(Process.class.getName())); + } finally { + t.quit(); + } } @Test @@ -68,4 +75,6 @@ public void jmx() { run(new JMXExecutor()); } + private static class Process extends process.TestJavaProcess { + } } diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java index 2536b4125aa..178216fe89c 100644 --- a/src/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -33,6 +33,7 @@ * @test * @summary Test of invalid diagnostic command (tests all DCMD executors) * @library /test/lib + * /vmTestbase * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -53,7 +54,13 @@ public void pid() { @Test public void mainClass() { - run(new MainClassJcmdExecutor()); + TestProcessLauncher t = new TestProcessLauncher(Process.class.getName()); + try { + t.launch(); + run(new MainClassJcmdExecutor(Process.class.getName())); + } finally { + t.quit(); + } } @Test @@ -65,4 +72,7 @@ public void file() { public void jmx() { run(new JMXExecutor()); } + + private static class Process extends process.TestJavaProcess { + } } diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties deleted file mode 100644 index 7cb4e8f69bf..00000000000 --- a/src/test/hotspot/jtreg/serviceability/dcmd/framework/TEST.properties +++ /dev/null @@ -1,2 +0,0 @@ -exclusiveAccess.dirs=. - diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessJarLauncher.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessJarLauncher.java new file mode 100644 index 00000000000..a5d9b05834f --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessJarLauncher.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.util.JarUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +/** + * Launches a new Java process using -jar Java option. + */ + +public class TestProcessJarLauncher extends TestProcessLauncher { + + private static final String JAR_FILE = "testprocess.jar"; + + + public TestProcessJarLauncher(String className) { + super(className); + } + + protected String prepareLaunch(String javaExec, String pipePort) { + try { + File jarFile = prepareJar(); + return javaExec + " -jar " + jarFile.getAbsolutePath() + " -pipe.port=" + pipePort; + } catch (IOException e) { + throw new RuntimeException("Failed to prepare a jar file", e); + } + } + + private File prepareJar() throws IOException { + Path jarFile = USER_DIR.resolve(JAR_FILE); + Manifest manifest = createManifest(); + Path testClass = TEST_CLASSES_DIR.resolve(className + ".class"); + JarUtils.createJarFile(jarFile, manifest, TEST_CLASSES_DIR, Paths.get(".")); + return jarFile.toFile(); + } + + private Manifest createManifest() { + Manifest manifest = new Manifest(); + manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, className); + return manifest; + } + + public String getJarFile() { + return JAR_FILE; + } +} diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java new file mode 100644 index 00000000000..6e3fd239abe --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java @@ -0,0 +1,88 @@ + +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import nsk.share.*; +import nsk.share.jpda.*; +import nsk.share.jdi.*; + +import java.nio.file.FileSystems; +import java.nio.file.Path; + +/** + * Launches a new Java process that uses a communication pipe to interact + * with the test. + */ + +public class TestProcessLauncher { + + protected static final Path USER_DIR = FileSystems.getDefault().getPath(System.getProperty("user.dir", ".")); + protected static final Path TEST_CLASSES_DIR = FileSystems.getDefault().getPath(System.getProperty("test.classes")); + + protected final String className; + private final ArgumentHandler argHandler; + + private IOPipe pipe; + + public TestProcessLauncher(String className, ArgumentHandler argHandler) { + this.className = className; + this.argHandler = argHandler; + } + + public TestProcessLauncher(String className) { + this(className, new ArgumentHandler(new String[0])); + } + + public Process launch() { + + String java = argHandler.getLaunchExecPath(); + + Log log = new Log(System.out, argHandler); + Binder binder = new Binder(argHandler, log); + binder.prepareForPipeConnection(argHandler); + + String cmd = prepareLaunch(java, argHandler.getPipePort()); + + Debugee debuggee = binder.startLocalDebugee(cmd); + debuggee.redirectOutput(log); + + pipe = new IOPipe(debuggee); + + String line = pipe.readln(); + if (!"ready".equals(line)) { + System.out.println("Wrong reply received:" + line); + } + return debuggee.getProcess(); + } + + public void quit() { + if (pipe != null) { + pipe.println("quit"); + } + } + + protected String prepareLaunch(String javaExec, String pipePort) { + return javaExec + " " + className + " -pipe.port=" + pipePort; + } + +} diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java new file mode 100644 index 00000000000..ac9125ab7ae --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.internal.module.ModuleInfoWriter; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.module.ModuleDescriptor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.stream.Stream; + +/* + * Launches a new Java process with a main class packed inside a module. + */ + +public class TestProcessModuleLauncher extends TestProcessLauncher { + + private static final Path TEST_MODULES = USER_DIR.resolve("testmodules"); + private static final String MODULE_NAME = "module1"; + + public TestProcessModuleLauncher(String className) { + super(className); + } + + protected String prepareLaunch(String javaExec, String pipePort) { + try { + prepareModule(); + return javaExec + " --module-path " + TEST_MODULES.toFile().getAbsolutePath() + + " -m " + MODULE_NAME + "/" + className + " -pipe.port=" + pipePort; + } catch (IOException e) { + throw new RuntimeException("Failed to prepare a jar file", e); + } + } + + private void prepareModule() throws IOException { + TEST_MODULES.toFile().mkdirs(); + Path moduleJar = TEST_MODULES.resolve("mod1.jar"); + ModuleDescriptor md = createModuleDescriptor(); + createModuleJarFile(moduleJar, md, TEST_CLASSES_DIR, Paths.get(".")); + } + + private ModuleDescriptor createModuleDescriptor() { + ModuleDescriptor.Builder builder + = ModuleDescriptor.newModule(MODULE_NAME).requires("java.base"); + return builder.build(); + } + + private static void createModuleJarFile(Path jarfile, ModuleDescriptor md, Path dir, Path... files) + throws IOException { + + Path parent = jarfile.getParent(); + if (parent != null) { + Files.createDirectories(parent); + } + + List<Path> entries = findAllRegularFiles(dir, files); + + try (OutputStream out = Files.newOutputStream(jarfile); + JarOutputStream jos = new JarOutputStream(out)) { + if (md != null) { + JarEntry je = new JarEntry("module-info.class"); + jos.putNextEntry(je); + ModuleInfoWriter.write(md, jos); + jos.closeEntry(); + } + + for (Path entry : entries) { + String name = toJarEntryName(entry); + jos.putNextEntry(new JarEntry(name)); + Files.copy(dir.resolve(entry), jos); + jos.closeEntry(); + } + } + } + + private static String toJarEntryName(Path file) { + Path normalized = file.normalize(); + return normalized.subpath(0, normalized.getNameCount()) + .toString() + .replace(File.separatorChar, '/'); + } + + private static List<Path> findAllRegularFiles(Path dir, Path[] files) throws IOException { + List<Path> entries = new ArrayList<>(); + for (Path file : files) { + try (Stream<Path> stream = Files.find(dir.resolve(file), Integer.MAX_VALUE, + (p, attrs) -> attrs.isRegularFile() && !p.getParent().equals(dir.resolve(".")))) { + stream.map(dir::relativize) + .forEach(entries::add); + } + } + return entries; + } + + public String getModuleName() { + return MODULE_NAME; + } +} diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java index d39f0de5263..ae25a54ddf5 100644 --- a/src/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -27,20 +27,27 @@ import jdk.test.lib.dcmd.MainClassJcmdExecutor; import jdk.test.lib.dcmd.FileJcmdExecutor; import jdk.test.lib.dcmd.JMXExecutor; +import nsk.share.jdi.ArgumentHandler; import org.testng.annotations.Test; /* * @test + * @bug 8221730 * @summary Test of diagnostic command VM.version (tests all DCMD executors) * @library /test/lib + * /vmTestbase * @modules java.base/jdk.internal.misc + * java.base/jdk.internal.module * java.compiler * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor * @run testng/othervm -XX:+UsePerfData VMVersionTest */ public class VMVersionTest { + + private static final String TEST_PROCESS_CLASS_NAME = process.TestJavaProcess.class.getName(); + public void run(CommandExecutor executor) { OutputAnalyzer output = executor.execute("VM.version"); output.shouldMatch(".*(?:HotSpot|OpenJDK).*VM.*"); @@ -53,7 +60,37 @@ public void pid() { @Test public void mainClass() { - run(new MainClassJcmdExecutor()); + TestProcessLauncher t = new TestProcessLauncher(TEST_PROCESS_CLASS_NAME); + try { + t.launch(); + run(new MainClassJcmdExecutor(TEST_PROCESS_CLASS_NAME)); + } finally { + t.quit(); + } + } + + @Test + public void mainClassForJar() { + TestProcessJarLauncher t = new TestProcessJarLauncher(TEST_PROCESS_CLASS_NAME); + try { + t.launch(); + String jarFile = t.getJarFile(); + run(new MainClassJcmdExecutor(jarFile)); + } finally { + t.quit(); + } + } + + @Test + public void mainClassForModule() { + TestProcessModuleLauncher t = new TestProcessModuleLauncher(TEST_PROCESS_CLASS_NAME); + try { + t.launch(); + String moduleName = t.getModuleName(); + run(new MainClassJcmdExecutor(moduleName)); + } finally { + t.quit(); + } } @Test @@ -65,4 +102,5 @@ public void file() { public void jmx() { run(new JMXExecutor()); } + } diff --git a/src/test/hotspot/jtreg/serviceability/dcmd/framework/process/TestJavaProcess.java b/src/test/hotspot/jtreg/serviceability/dcmd/framework/process/TestJavaProcess.java new file mode 100644 index 00000000000..da9d0940b7c --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/dcmd/framework/process/TestJavaProcess.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package process; + +import nsk.share.jdi.ArgumentHandler; +import nsk.share.jpda.IOPipe; + +/** + * A simple process that connects to a pipe and waits for command "quit" to + * be received. + * + * Usage: java TestJavaProcess -pipe.port <PIPE_PORT_NUMBER> + */ + +public class TestJavaProcess { + + static final int PASSED = 0; + static final int FAILED = 2; + + public static void main(String argv[]) { + + log("Test Java process started!"); + + ArgumentHandler argHandler = new ArgumentHandler(argv); + IOPipe pipe = argHandler.createDebugeeIOPipe(); + pipe.println("ready"); + log("Waiting for the quit command from the test ..."); + String cmd = pipe.readln(); + int exitCode = PASSED; + if (cmd.equals("quit")) { + log("'quit' received"); + } else { + log("Invalid command received " + cmd); + exitCode = FAILED; + } + System.exit(exitCode); + } + + private static void log(String message) { + System.out.println(message); + } +} diff --git a/src/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java b/src/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java index d18d52747b1..1f3cf82b296 100644 --- a/src/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java +++ b/src/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -20,11 +20,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -import java.io.PrintWriter; -import jdk.test.lib.JDKToolFinder; -import jdk.test.lib.Platform; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; /* * Test to verify GetObjectSize does not overflow on a 600M element int[] @@ -37,18 +32,23 @@ * java.instrument * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor + * @requires vm.bits == 64 * @build GetObjectSizeOverflowAgent * @run driver ClassFileInstaller GetObjectSizeOverflowAgent * @run main GetObjectSizeOverflow */ + +import java.io.PrintWriter; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; + public class GetObjectSizeOverflow { public static void main(String[] args) throws Exception { - if (!Platform.is64bit()) { - System.out.println("Test needs a 4GB heap and can only be run as a 64bit process, skipping."); - return; - } - PrintWriter pw = new PrintWriter("MANIFEST.MF"); pw.println("Premain-Class: GetObjectSizeOverflowAgent"); pw.close(); @@ -63,8 +63,7 @@ public static void main(String[] args) throws Exception { if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) { System.out.println("stdout: " + output.getStdout()); System.out.println("stderr: " + output.getStderr()); - System.out.println("Test could not reserve or allocate enough space, skipping"); - return; + throw new SkippedException("Test could not reserve or allocate enough space"); } output.stdoutShouldContain("GetObjectSizeOverflow passed"); diff --git a/src/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java b/src/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java index 5775784ff54..8bca84f1b93 100644 --- a/src/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java +++ b/src/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java @@ -29,7 +29,6 @@ * @summary Verifies the JVMTI Heap Monitor Thread information sanity. * @compile HeapMonitorThreadTest.java * @run main/othervm/native -Xmx512m -agentlib:HeapMonitorTest MyPackage.HeapMonitorThreadTest - * @requires !vm.gc.Z */ import java.util.List; diff --git a/src/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/NotifyFramePopTest.java b/src/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/NotifyFramePopTest.java index 0e4a770f3bc..3157c1a5103 100644 --- a/src/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/NotifyFramePopTest.java +++ b/src/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/NotifyFramePopTest.java @@ -24,10 +24,13 @@ /** * @test * @summary Verifies NotifyFramePop request is cleared if JVMTI_EVENT_FRAME_POP is disabled + * @library /test/lib * @compile NotifyFramePopTest.java * @run main/othervm/native -agentlib:NotifyFramePopTest NotifyFramePopTest */ +import jtreg.SkippedException; + public class NotifyFramePopTest { static { try { @@ -42,8 +45,7 @@ public class NotifyFramePopTest { public static void main(String args[]) { if (!canGenerateFramePopEvents()) { - log("FramePop event is not supported - skipping the test"); - return; + throw new SkippedException("FramePop event is not supported"); } // Sanity testing that FRAME_POP works. diff --git a/src/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineCondy.jasm b/src/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineCondy.jasm new file mode 100644 index 00000000000..2a37eb7269a --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineCondy.jasm @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +super public class RedefineCondy version 55:0 { + + public Method "<init>":"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)V" + stack 3 locals 4 { + aload_0; + invokespecial Method java/lang/Object."<init>":"()V"; + getstatic Field java/lang/System.out:"Ljava/io/PrintStream;"; + ldc String "In RedefineCondy <init> method"; + invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V"; + return; + } + + public static Method main:"([Ljava/lang/String;)V" stack 3 locals 1 { + new class RedefineCondy; + dup; + ldc Dynamic REF_newInvokeSpecial:RedefineCondy."<init>":"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)V":RedefineCondy:"Ljava/lang/Object;"; + return; + } + +} // end Class RedefineCondy diff --git a/src/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineCondy.java b/src/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineCondy.java new file mode 100644 index 00000000000..a888d68d1ec --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineCondy.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8228596 + * @summary Test redefining a class with a condy in its constant pool + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @modules java.compiler + * java.instrument + * jdk.jartool/sun.tools.jar + * @compile RedefineCondy.jasm + * @run main RedefineClassHelper + * @run main/othervm -javaagent:redefineagent.jar TestRedefineCondy + */ + +import jdk.test.lib.compiler.InMemoryJavaCompiler; + +// Test redefining a class that has a constant dynamic in its constant pool +// to a class that does not have a constant dynamic in its constant pool. +public class TestRedefineCondy { + + static final String DEST = System.getProperty("test.classes"); + static String newClass = + "public class RedefineCondy { " + + "public RedefineCondy(java.lang.invoke.MethodHandles.Lookup l, java.lang.String s, java.lang.Class c) { } " + + "public static void main(String argv[]) { } } "; + + public static void main(String[] args) throws Exception { + Class<?> classWithCondy = Class.forName("RedefineCondy"); + + try { + byte[] classBytes = InMemoryJavaCompiler.compile("RedefineCondy", newClass); + RedefineClassHelper.redefineClass(classWithCondy, classBytes); + } catch (Exception e) { + throw new RuntimeException("Unexpected exception: " + e.getMessage()); + } + } +} diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index 0013a9b2497..330708d23c4 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -54,6 +54,7 @@ import java.util.regex.Matcher; import jdk.internal.misc.Unsafe; import java.util.Scanner; +import jtreg.SkippedException; class CrashApp { public static void main(String[] args) { @@ -122,7 +123,7 @@ public static void main(String[] args) throws Exception { "Core files might not be generated. Please reset /proc/sys/kernel/core_pattern\n" + "to enable core generation. Skipping this test."); cleanup(); - return; + throw new SkippedException("This system uses a crash report tool"); } } } @@ -145,16 +146,14 @@ public static void main(String[] args) throws Exception { if (useSharedSpacesOutput == null) { // Output could be null due to attach permission issues. - System.out.println("Could not determine the UseSharedSpaces value - test skipped."); cleanup(); - return; + throw new SkippedException("Could not determine the UseSharedSpaces value"); } if (!useSharedSpacesOutput.contains("true")) { // CDS archive is not mapped. Skip the rest of the test. - System.out.println("The CDS archive is not mapped - test skipped."); cleanup(); - return; + throw new SkippedException("The CDS archive is not mapped"); } cmds = List.of("printmdo -a", "printall", "jstack -v"); @@ -189,6 +188,8 @@ public static void main(String[] args) throws Exception { unExpStrMap.put("jstack -v", List.of( "sun.jvm.hotspot.debugger.UnmappedAddressException")); test.runOnCore(TEST_CDS_CORE_FILE_NAME, cmds, expStrMap, unExpStrMap); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java index e918f634dff..debe1fa6383 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java @@ -37,6 +37,7 @@ import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; public class ClhsdbCDSJstackPrintAll { @@ -64,17 +65,15 @@ public static void main(String[] args) throws Exception { null, null); if (useSharedSpacesOutput == null) { - // Attach permission issues. - System.out.println("Could not determine the UseSharedSpaces value - test skipped."); LingeredApp.stopApp(theApp); - return; + // Attach permission issues. + throw new SkippedException("Could not determine the UseSharedSpaces value"); } if (!useSharedSpacesOutput.contains("true")) { // CDS archive is not mapped. Skip the rest of the test. - System.out.println("The CDS archive is not mapped - test skipped."); LingeredApp.stopApp(theApp); - return; + throw new SkippedException("The CDS archive is not mapped"); } cmds = List.of("jstack -v", "printall", "where -a"); @@ -113,6 +112,8 @@ public static void main(String[] args) throws Exception { "illegal code", "Failure occurred at bci")); test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java index de5270f4460..203196bd9b6 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java @@ -27,12 +27,12 @@ import java.util.ArrayList; import jdk.test.lib.apps.LingeredApp; - /** * @test * @bug 8193124 * @summary Test the clhsdb 'findpc' command * @requires vm.hasSA + * @requires vm.compiler1.enabled * @library /test/lib * @run main/othervm ClhsdbFindPC */ @@ -43,8 +43,13 @@ private static void testFindPC(boolean withXcomp) throws Exception { LingeredApp theApp = null; try { ClhsdbLauncher test = new ClhsdbLauncher(); - theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp")) - : LingeredApp.startApp(List.of("-Xint")); + + theApp = new LingeredAppWithTrivialMain(); + if (withXcomp) { + LingeredApp.startApp(List.of("-Xcomp"), theApp); + } else { + LingeredApp.startApp(List.of("-Xint"), theApp); + } System.out.print("Started LingeredApp "); if (withXcomp) { System.out.print("(-Xcomp) "); @@ -65,7 +70,7 @@ private static void testFindPC(boolean withXcomp) throws Exception { // attach permission issues. if (output != null) { String cmdStr = null; - String[] parts = output.split("LingeredApp.main"); + String[] parts = output.split("LingeredAppWithTrivialMain.main"); String[] tokens = parts[1].split(" "); for (String token : tokens) { if (token.contains("pc")) { @@ -80,7 +85,7 @@ private static void testFindPC(boolean withXcomp) throws Exception { Map<String, List<String>> expStrMap = new HashMap<>(); if (withXcomp) { expStrMap.put(cmdStr, List.of( - "In code in NMethod for jdk/test/lib/apps/LingeredApp.main", + "In code in NMethod for LingeredAppWithTrivialMain.main", "content:", "oops:", "frame size:")); diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java index 80c333e84db..dabc723d89c 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java @@ -21,12 +21,6 @@ * questions. */ -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import jdk.test.lib.apps.LingeredApp; - /** * @test * @bug 8192985 @@ -36,6 +30,13 @@ * @run main/othervm ClhsdbInspect */ +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ArrayList; +import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; + public class ClhsdbInspect { public static void main(String[] args) throws Exception { @@ -60,7 +61,7 @@ public static void main(String[] args) throws Exception { // Output could be null due to attach permission issues // and if we are skipping this. LingeredApp.stopApp(theApp); - return; + throw new SkippedException("attach permission issues"); } Map<String, String> tokensMap = new HashMap<>(); @@ -100,6 +101,8 @@ public static void main(String[] args) throws Exception { expStrMap.put(cmd, List.of(tokensMap.get(key))); test.run(theApp.getPid(), cmds, expStrMap, null); } + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java index 3dd39436a8b..6f02e7a9392 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java @@ -21,13 +21,6 @@ * questions. */ -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; - -import jdk.test.lib.apps.LingeredApp; - /** * @test * @bug 8193124 @@ -37,6 +30,14 @@ * @run main/othervm ClhsdbJdis */ +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ArrayList; + +import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; + public class ClhsdbJdis { public static void main(String[] args) throws Exception { @@ -58,33 +59,36 @@ public static void main(String[] args) throws Exception { // Output could be null if the test was skipped due to // attach permission issues. - if (output != null) { - String cmdStr = null; - String[] parts = output.split("LingeredApp.main"); - String[] tokens = parts[1].split(" "); - for (String token : tokens) { - if (token.contains("Method")) { - String[] address = token.split("="); - // address[1] represents the address of the Method - cmdStr = "jdis " + address[1]; - cmds.add(cmdStr); - break; - } + if (output == null) { + throw new SkippedException("attach permission issues"); + } + String cmdStr = null; + String[] parts = output.split("LingeredApp.main"); + String[] tokens = parts[1].split(" "); + for (String token : tokens) { + if (token.contains("Method")) { + String[] address = token.split("="); + // address[1] represents the address of the Method + cmdStr = "jdis " + address[1]; + cmds.add(cmdStr); + break; } + } - Map<String, List<String>> expStrMap = new HashMap<>(); - expStrMap.put(cmdStr, List.of( - "public static void main(java.lang.String[])", - "Holder Class", - "public class jdk.test.lib.apps.LingeredApp @", - "Bytecode", - "line bci bytecode", - "Exception Table", - "start bci end bci handler bci catch type", - "Constant Pool of [public class jdk.test.lib.apps.LingeredApp @")); + Map<String, List<String>> expStrMap = new HashMap<>(); + expStrMap.put(cmdStr, List.of( + "public static void main(java.lang.String[])", + "Holder Class", + "public class jdk.test.lib.apps.LingeredApp @", + "Bytecode", + "line bci bytecode", + "Exception Table", + "start bci end bci handler bci catch type", + "Constant Pool of [public class jdk.test.lib.apps.LingeredApp @")); - test.run(theApp.getPid(), cmds, expStrMap, null); - } + test.run(theApp.getPid(), cmds, expStrMap, null); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java index c576defabfe..29310121353 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java @@ -21,13 +21,6 @@ * questions. */ -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import jdk.test.lib.apps.LingeredApp; -import jdk.test.lib.Platform; - /** * @test * @bug 8190198 @@ -37,6 +30,14 @@ * @run main/othervm ClhsdbLongConstant */ +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.test.lib.apps.LingeredApp; +import jdk.test.lib.Platform; +import jtreg.SkippedException; + public class ClhsdbLongConstant { public static void main(String[] args) throws Exception { @@ -75,11 +76,11 @@ public static void main(String[] args) throws Exception { String longConstantOutput = test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap); if (longConstantOutput == null) { - // Output could be null due to attach permission issues - // and if we are skipping this. - return; + throw new SkippedException("attach permission issues"); } checkForTruncation(longConstantOutput); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java index f72fd66ade5..8474102d6d9 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java @@ -21,12 +21,6 @@ * questions. */ -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import jdk.test.lib.apps.LingeredApp; - /** * @test * @bug 8192985 @@ -36,6 +30,13 @@ * @run main/othervm ClhsdbPrintAs */ +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ArrayList; +import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; + public class ClhsdbPrintAs { public static void main(String[] args) throws Exception { @@ -55,10 +56,8 @@ public static void main(String[] args) throws Exception { String jstackOutput = test.run(theApp.getPid(), cmds, null, null); if (jstackOutput == null) { - // Output could be null due to attach permission issues - // and if we are skipping this. LingeredApp.stopApp(theApp); - return; + throw new SkippedException("attach permission issues"); } String[] snippets = jstackOutput.split("LingeredApp.main"); @@ -118,6 +117,8 @@ public static void main(String[] args) throws Exception { expStrMap.put(cmd, List.of ("ConstantPoolCache", "_pool_holder", "InstanceKlass*")); test.run(theApp.getPid(), cmds, expStrMap, null); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java index 90f573bc48b..904c64f701b 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java @@ -21,12 +21,6 @@ * questions. */ -import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import jdk.test.lib.apps.LingeredApp; - /** * @test * @bug 8175312 @@ -36,6 +30,13 @@ * @run main/othervm/timeout=2400 ClhsdbRegionDetailsScanOopsForG1 */ +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; + public class ClhsdbRegionDetailsScanOopsForG1 { public static void main(String[] args) throws Exception { @@ -70,10 +71,8 @@ public static void main(String[] args) throws Exception { String regionDetailsOutput = test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap); if (regionDetailsOutput == null) { - // Output could be null due to attach permission issues - // and if we are skipping this. LingeredApp.stopApp(theApp); - return; + throw new SkippedException("attach permission issues"); } // Test the output of 'scanoops' -- get the start and end addresses @@ -87,6 +86,8 @@ public static void main(String[] args) throws Exception { expStrMap = new HashMap<>(); expStrMap.put(cmd, List.of("[Ljava/lang/String")); test.run(theApp.getPid(), List.of(cmd), expStrMap, null); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { diff --git a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java index a74c6afbc6c..d0d6613ac9f 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java +++ b/src/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java @@ -21,13 +21,6 @@ * questions. */ -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import jdk.test.lib.Utils; -import jdk.test.lib.apps.LingeredApp; - /** * @test * @bug 8192985 @@ -37,6 +30,14 @@ * @run main/othervm/timeout=1200 ClhsdbScanOops */ +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ArrayList; +import jdk.test.lib.Utils; +import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; + public class ClhsdbScanOops { private static void testWithGcType(String gc) throws Exception { @@ -58,10 +59,8 @@ private static void testWithGcType(String gc) throws Exception { String universeOutput = test.run(theApp.getPid(), cmds, null, null); if (universeOutput == null) { - // Output could be null due to attach permission issues - // and if we are skipping this. LingeredApp.stopApp(theApp); - return; + throw new SkippedException("attach permission issues"); } cmds = new ArrayList<String>(); @@ -97,6 +96,8 @@ private static void testWithGcType(String gc) throws Exception { unExpStrMap.put(cmd, List.of("java/lang/Thread")); test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap); + } catch (SkippedException e) { + throw e; } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally { @@ -106,12 +107,8 @@ private static void testWithGcType(String gc) throws Exception { public static void main(String[] args) throws Exception { System.out.println("Starting the ClhsdbScanOops test"); - try { - testWithGcType("-XX:+UseParallelGC"); - testWithGcType("-XX:+UseSerialGC"); - } catch (Exception e) { - throw new Error("Test failed with " + e); - } + testWithGcType("-XX:+UseParallelGC"); + testWithGcType("-XX:+UseSerialGC"); System.out.println("Test PASSED"); } } diff --git a/src/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java b/src/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java index 5ad5487d8f2..a67e654e1bd 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java +++ b/src/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java @@ -21,11 +21,21 @@ * questions. */ +/** + * @test + * @summary Test deadlock detection + * @requires vm.hasSAandCanAttach + * @requires os.family != "mac" + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @modules java.management + * @run main DeadlockDetectionTest + */ + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; - import jdk.test.lib.apps.LingeredApp; import jdk.test.lib.apps.LingeredAppWithDeadlock; @@ -35,15 +45,7 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -/** - * @test - * @summary Test deadlock detection - * @requires vm.hasSAandCanAttach - * @library /test/lib - * @modules java.base/jdk.internal.misc - * @modules java.management - * @run main DeadlockDetectionTest - */ +import jtreg.SkippedException; public class DeadlockDetectionTest { @@ -70,13 +72,6 @@ private static OutputAnalyzer jstack(String... toolArgs) throws Exception { public static void main(String[] args) throws Exception { System.out.println("Starting DeadlockDetectionTest"); - if (Platform.isOSX()) { - // Coredump stackwalking is not implemented for Darwin - System.out.println("This test is not expected to work on OS X. Skipping"); - return; - } - - if (!LingeredApp.isLastModifiedWorking()) { // Exact behaviour of the test depends on operating system and the test nature, // so just print the warning and continue @@ -94,9 +89,8 @@ public static void main(String[] args) throws Exception { System.out.println(output.getOutput()); if (output.getExitValue() == 3) { - System.out.println("Test can't run for some reason. Skipping"); - } - else { + throw new SkippedException("Test can't run for some reason"); + } else { output.shouldHaveExitValue(0); output.shouldContain("Found a total of 1 deadlock."); } diff --git a/src/test/hotspot/jtreg/serviceability/sa/LingeredAppWithTrivialMain.java b/src/test/hotspot/jtreg/serviceability/sa/LingeredAppWithTrivialMain.java new file mode 100644 index 00000000000..a53116fa9ef --- /dev/null +++ b/src/test/hotspot/jtreg/serviceability/sa/LingeredAppWithTrivialMain.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.apps.LingeredApp; + +/** + * This is a wrapper around LingeredApp.main to ensure we reliably get a + * compiled main nmethod in the stack trace on all platforms when using + * -Xcomp. + */ +public class LingeredAppWithTrivialMain extends LingeredApp { + public static void main(String args[]) { + LingeredApp.main(args); + } + } diff --git a/src/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/src/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index af6014d0cbe..7fc98c81e03 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/src/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -37,6 +37,7 @@ import jdk.test.lib.hprof.HprofParser; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; import java.io.File; @@ -103,8 +104,7 @@ static void test(String type) throws Throwable { String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1); core = new File("cores/core." + pid); if (!core.exists()) { - System.out.println("Has not been able to find coredump. Test skipped."); - return; + throw new SkippedException("Has not been able to find coredump"); } } else { Asserts.assertTrue(cores.length == 1, diff --git a/src/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java b/src/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java index d2c419e48d9..60dbcea9e91 100644 --- a/src/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java +++ b/src/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java @@ -23,9 +23,11 @@ /** * @test + * @bug 8163805 8224252 * @summary Checks that the jshdb debugd utility sucessfully starts * and tries to attach to a running process * @requires vm.hasSAandCanAttach + * @requires os.family != "windows" * @modules java.base/jdk.internal.misc * @library /test/lib * @@ -40,7 +42,7 @@ public class SADebugDTest { - private static final String GOLDEN = "Attaching to process"; + private static final String GOLDEN = "Debugger attached"; public static void main(String[] args) throws Exception { LingeredApp app = null; @@ -62,10 +64,9 @@ public static void main(String[] args) throws Exception { // If we are here, this means we have received the golden line and the test has passed // The debugd remains running, we have to kill it debugd.destroy(); + debugd.waitFor(); } finally { - if (app != null) { - LingeredApp.stopApp(app); - } + LingeredApp.stopApp(app); } } diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/VERSION b/src/test/hotspot/jtreg/serviceability/sa/sadebugd/TEST.properties similarity index 81% rename from src/test/jdk/sun/util/calendar/zi/tzdata/VERSION rename to src/test/hotspot/jtreg/serviceability/sa/sadebugd/TEST.properties index e3fa9222bcf..5280029a8db 100644 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/VERSION +++ b/src/test/hotspot/jtreg/serviceability/sa/sadebugd/TEST.properties @@ -1,11 +1,10 @@ # +# Copyright (c) 2019, 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. +# published by the Free Software Foundation. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -21,4 +20,5 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2018g + +exclusiveAccess.dirs=. diff --git a/src/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/UnloadingTest.java b/src/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/UnloadingTest.java index d1b30a504e5..9f84a795090 100644 --- a/src/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/UnloadingTest.java +++ b/src/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/UnloadingTest.java @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package gc.g1.unloading; import java.lang.Thread.UncaughtExceptionHandler; @@ -33,12 +34,13 @@ import gc.g1.unloading.check.AssertionContainer; import gc.g1.unloading.check.ClassAssertion; import gc.g1.unloading.configuration.*; +import gc.g1.unloading.loading.*; import nsk.share.gc.GCTestBase; import nsk.share.test.ExecutionController; import nsk.share.test.Stresser; import nsk.share.test.Tests; -import gc.g1.unloading.loading.*; +import jtreg.SkippedException; /** * This class contains main method. It's entry point for all configurations. @@ -165,8 +167,7 @@ private static void checkGCCounters() { private void checkIfG1Used() { for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { if (!bean.getName().contains("G1")) { - System.err.println("This test was created to cover G1 class unloading feature. It should be ran with -XX:+UseG1GC. Skipping silently."); - System.exit(0); + throw new SkippedException("This test was created to cover G1 class unloading feature. It should be ran with -XX:+UseG1GC"); } } } diff --git a/src/test/hotspot/jtreg/vmTestbase/jit/tiered/tieredTest.sh b/src/test/hotspot/jtreg/vmTestbase/jit/tiered/tieredTest.sh index 2c91754e98e..7d3ce0dbbc5 100644 --- a/src/test/hotspot/jtreg/vmTestbase/jit/tiered/tieredTest.sh +++ b/src/test/hotspot/jtreg/vmTestbase/jit/tiered/tieredTest.sh @@ -46,6 +46,11 @@ if grep "Client VM" $log; then exit 0 fi +if grep "TieredCompilation not supported in this VM" $log; then + echo "TEST PASSED: Non-tiered Server VM. The test is useless" + exit 0 +fi + if ! egrep '^[0-9.]+: \[compile level=[0-9]' $log; then if [ "${tiered}" == "on" ]; then echo "TEST FAILED: No PrintTieredEvents output" diff --git a/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach004/TestDriver.java b/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach004/TestDriver.java index 7cc94acbf83..b8efbd18403 100644 --- a/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach004/TestDriver.java +++ b/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach004/TestDriver.java @@ -25,6 +25,7 @@ import jdk.test.lib.JDKToolFinder; import jdk.test.lib.Utils; +import jtreg.SkippedException; import nsk.share.jdi.ArgumentHandler; import java.io.BufferedReader; @@ -63,23 +64,23 @@ public static void main(String[] args) throws InterruptedException { "-arch=" + arch }; - if (isTransportSupported(jdiArgs)) { - System.out.println("Transport is supported on this platform, execute test"); - String suspend = args[2]; - Process debuggee = startDebuggee(jdiArgs, transport, suspend); - Process debugger = startDebugger(jdiArgs, Arrays.copyOfRange(args, 3, args.length), debuggee.pid()); + if (!isTransportSupported(jdiArgs)) { + throw new SkippedException("Transport isn't supported on this platform"); + } - int debuggerExit = debugger.waitFor(); - if (debuggerExit != 95) { - throw new Error("debugger exit code is " + debuggerExit); - } + System.out.println("Transport is supported on this platform, execute test"); + String suspend = args[2]; + Process debuggee = startDebuggee(jdiArgs, transport, suspend); + Process debugger = startDebugger(jdiArgs, Arrays.copyOfRange(args, 3, args.length), debuggee.pid()); - int debuggeeExit = debuggee.waitFor(); - if (debuggeeExit != 95) { - throw new Error("debuggee exit code is " + debuggeeExit); - } - } else { - System.out.println("SKIPPED: Transport isn't supported on this platform, treat test as passed"); + int debuggerExit = debugger.waitFor(); + if (debuggerExit != 95) { + throw new Error("debugger exit code is " + debuggerExit); + } + + int debuggeeExit = debuggee.waitFor(); + if (debuggeeExit != 95) { + throw new Error("debuggee exit code is " + debuggeeExit); } } diff --git a/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq001.java b/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq001.java index 0e0e1b64ebf..e3553df154a 100644 --- a/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq001.java +++ b/src/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -166,7 +166,10 @@ private int runIt(String args[], PrintStream out) { } enabledStepRequests.forEach(s -> erManager.deleteEventRequest(s)); - + // There is a chance that a single step event had been posted after + // the step request was created and before it was deleted. In this + // case the debuggee VM is in the suspended state. + vm.resume(); return quitDebuggee(tot_res); } diff --git a/src/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java b/src/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java index 7ef47df8b00..a0111ad3fc1 100644 --- a/src/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java +++ b/src/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java @@ -106,8 +106,9 @@ public static int run(String[] argv, PrintStream out) { printStackTrace(snapshot); testFailed = true; } - } else + } else { log.display("Thread " + j + " is dead, skipping it."); + } } // Let all threads to complete their job diff --git a/src/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java b/src/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java index 01c4df801ea..f5cfd11c56e 100644 --- a/src/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java +++ b/src/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -175,7 +175,7 @@ public static void waitForThread(Thread thr, long millisecs, Log.Logger logger) * Make preperation for IOPipe connection before starting debugee VM process. * May change options in the passed <code>argumentHandler</code>. */ - protected void prepareForPipeConnection(DebugeeArgumentHandler argumentHandler) { + public void prepareForPipeConnection(DebugeeArgumentHandler argumentHandler) { if (argumentHandler.isTransportAddressDynamic()) { try { pipeServerSocket = new ServerSocket(); diff --git a/src/test/jaxp/javax/xml/jaxp/unittest/dom/DocumentTest.java b/src/test/jaxp/javax/xml/jaxp/unittest/dom/DocumentTest.java new file mode 100644 index 00000000000..bd8cb264141 --- /dev/null +++ b/src/test/jaxp/javax/xml/jaxp/unittest/dom/DocumentTest.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package dom; + +import com.sun.org.apache.xerces.internal.dom.AttrImpl; +import com.sun.org.apache.xerces.internal.dom.DocumentImpl; +import com.sun.org.apache.xerces.internal.dom.ElementImpl; +import com.sun.org.apache.xerces.internal.dom.events.MutationEventImpl; +import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.testng.Assert; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.events.Event; +import org.w3c.dom.events.EventListener; + +/* + * @test + * @bug 8213117 8222743 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @modules java.xml + * @modules java.xml/com.sun.org.apache.xerces.internal.dom + * @modules java.xml/com.sun.org.apache.xerces.internal.dom.events + * @modules java.xml/com.sun.org.apache.xerces.internal.jaxp + * @run testng dom.DocumentTest + * @summary Tests functionalities for Document. + */ +@Listeners({jaxp.library.BasePolicy.class}) +public class DocumentTest { + static final int DOC1 = 1; + static final int DOC2 = 2; + + /** + * Verifies the adoptNode method. Before a node from a deferred DOM can be + * adopted, it needs to be fully expanded. + */ + @Test + public void testAdoptNode() throws Exception { + String xml1 = "<root><oldNode oldAttrib1=\"old value 1\" oldAttrib2=\"old value 2\"></oldNode></root>"; + String xml2 = "<root><newNode newAttrib=\"new value\"></newNode></root>"; + + Document doc1 = getDocument(xml1); + Document doc2 = getDocument(xml2); + + Element newNode = (Element) doc2.getFirstChild().getFirstChild(); + Element replacementNode = (Element) doc1.adoptNode(newNode); + + Node oldNode = doc1.getFirstChild().getFirstChild(); + doc1.getDocumentElement().replaceChild(replacementNode, oldNode); + + String attrValue = doc1.getFirstChild().getFirstChild().getAttributes() + .getNamedItem("newAttrib").getNodeValue(); + Assert.assertEquals(attrValue, "new value"); + } + + /** + * Verifies that the lookupNamespaceURI method returns null (not empty string) + * for unbound prefix. + * + * Specification for lookupNamespaceURI: + * Returns the associated namespace URI or null if none is found. + * + * @throws Exception + */ + @Test + public void testUnboundNamespaceURI() throws Exception { + String xml = "<?xml version='1.1'?>" + + "<root><e1 xmlns='' xmlns:p1='' xmlns:p2='uri2'><e2/></e1></root>"; + + DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document doc = getDocument(xml); + Element e1 = doc.getDocumentElement(); + Element e2 = (Element)e1.getFirstChild().getFirstChild(); + + Assert.assertEquals(e1.lookupNamespaceURI(null), null); + Assert.assertEquals(e2.lookupNamespaceURI(null), null); + + Assert.assertEquals(e1.lookupNamespaceURI("p1"), null); + Assert.assertEquals(e2.lookupNamespaceURI("p1"), null); + + Assert.assertEquals(e1.lookupNamespaceURI("p2"), null); + Assert.assertEquals(e2.lookupNamespaceURI("p2"), "uri2"); + } + + /** + * Verifies that calling namespace methods on an empty document won't result + * in a NPE. + * @throws Exception + */ + @Test + public void testNamespaceNPE() throws Exception { + Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document.lookupNamespaceURI("prefix"); + document.lookupPrefix("uri"); + document.isDefaultNamespace("uri"); + } + + /** + * Verifies that manipulating an independent document from within a mutation + * listener does not modify the original event object. + */ + @Test + public void testMutation() throws Exception { + String xml1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<root><a a_attr=\"a_attr_value\"/></root>"; + String xml2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<root><b b_attr=\"b_attr_value\"/></root>"; + DocumentBuilder db = DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder(); + DocumentImpl doc1 = (DocumentImpl)getDocument(xml1); + DocumentImpl doc2 = (DocumentImpl)getDocument(xml2); + ElementImpl a = (ElementImpl) doc1.getDocumentElement().getFirstChild(); + AttrImpl attr = (AttrImpl) a.getAttributeNode("a_attr"); + attr.addEventListener(MutationEventImpl.DOM_NODE_REMOVED, new MyEventListener(DOC1, doc2), false); + doc2.addEventListener(MutationEventImpl.DOM_ATTR_MODIFIED, new MyEventListener(DOC2), true); + + // make a change to doc1 to trigger the event + Element a1 = (Element) doc1.getDocumentElement().getFirstChild(); + a1.setAttribute("a_attr", "a_attr_newvalue"); + } + + private static Document getDocument(String xml) throws Exception { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + DocumentBuilder db = dbf.newDocumentBuilder(); + InputStream a = new ByteArrayInputStream(xml.getBytes()); + Document out = db.parse(a); + return out; + } + + // EventListener that mutates an unrelated document when an event is received. + static class MyEventListener implements EventListener { + + private int docId; + private Document doc = null; + + public MyEventListener(int docId) { + this.docId = docId; + } + + public MyEventListener(int docId, Document doc) { + this.docId = docId; + this.doc = doc; + } + + public void handleEvent(Event evt) { + if (docId == DOC1) { + //check the related node before making changes + checkRelatedNode(evt, "a_attr_value"); + //make a change to doc2 + Element ele = (Element)doc.getDocumentElement().getFirstChild(); + ele.setAttribute("b_attr", "value for b_attr in doc2"); + //check the related node again after the change + checkRelatedNode(evt, "a_attr_value"); + } else { //DOC2 + checkRelatedNode(evt, "value for b_attr in doc2"); + } + } + + } + + // Utility method to display an event + public static void checkRelatedNode(Event evt, String expected) { + //System.out.println(" Event: " + evt + ", on " + evt.getTarget()); + if (evt instanceof MutationEventImpl) { + MutationEventImpl mutation = (MutationEventImpl) evt; + //System.out.println(" + Related: " + mutation.getRelatedNode()); + Assert.assertTrue(mutation.getRelatedNode().toString().contains(expected)); + } + } +} diff --git a/src/test/jaxp/javax/xml/jaxp/unittest/parsers/BaseParsingTest.java b/src/test/jaxp/javax/xml/jaxp/unittest/parsers/BaseParsingTest.java index 2d15fda1b0e..92e960bff3b 100644 --- a/src/test/jaxp/javax/xml/jaxp/unittest/parsers/BaseParsingTest.java +++ b/src/test/jaxp/javax/xml/jaxp/unittest/parsers/BaseParsingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -22,19 +22,22 @@ */ package parsers; +import java.io.ByteArrayInputStream; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamReader; +import static org.testng.Assert.assertEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; +import org.w3c.dom.Document; import org.xml.sax.InputSource; /** * @test - * @bug 8169450 + * @bug 8169450 8222415 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true parsers.BaseParsingTest * @run testng/othervm parsers.BaseParsingTest @@ -143,7 +146,7 @@ public void test(String xml) throws Exception { * @bug 8169450 * This particular issue does not appear in DOM parsing since the spaces are * normalized during version detection. This test case then serves as a guard - * against such an issue from occuring in the version detection. + * against such an issue from occurring in the version detection. * * @param xml the test xml * @throws Exception if the parser fails to parse the xml @@ -151,8 +154,24 @@ public void test(String xml) throws Exception { @Test(dataProvider = "xmlDeclarations") public void testWithDOM(String xml) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setValidating(true); DocumentBuilder db = dbf.newDocumentBuilder(); db.parse(new InputSource(new StringReader(xml))); } + + /** + * @bug 8222415 + * Verifies that the parser is configured properly for UTF-16BE or LE. + * @throws Exception + */ + @Test + public void testEncoding() throws Exception { + ByteArrayInputStream bis = new ByteArrayInputStream( + "<?xml version=\"1.0\" encoding=\"UTF-16\"?> <a/>".getBytes("UnicodeLittle")); + InputSource is = new InputSource(bis); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + Document doc = db.parse(is); + assertEquals("UTF-16LE", doc.getInputEncoding()); + } } diff --git a/src/test/jaxp/javax/xml/jaxp/unittest/sax/SAXParserTest.java b/src/test/jaxp/javax/xml/jaxp/unittest/sax/SAXParserTest.java new file mode 100644 index 00000000000..319f17a9010 --- /dev/null +++ b/src/test/jaxp/javax/xml/jaxp/unittest/sax/SAXParserTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sax; + +import static jaxp.library.JAXPTestUtilities.getSystemProperty; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @test + * @bug 8213734 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng sax.SAXParserTest + * @summary Tests functionalities for SAXParser. + */ +@Listeners({ jaxp.library.BasePolicy.class }) +public class SAXParserTest { + + /* + * @bug 8213734 + * Verifies that files opened by the SAXParser is closed when Exception + * occurs. + */ + @Test + public void testCloseReaders() throws Exception { + if (!getSystemProperty("os.name").contains("Windows")) { + System.out.println("This test only needs to be run on Windows."); + return; + } + Path testFile = createTestFile(null, "Test"); + System.out.println("Test file: " + testFile.toString()); + SAXParserFactory factory = SAXParserFactory.newDefaultInstance(); + SAXParser parser = factory.newSAXParser(); + try { + parser.parse(testFile.toFile(), new DefaultHandler() { + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + throw new SAXException("Stop the parser."); + } + }); + } catch (SAXException e) { + // Do nothing + } + + // deletion failes on Windows when the file is not closed + Files.deleteIfExists(testFile); + } + + private static Path createTestFile(Path dir, String name) throws IOException { + Path path = Files.createTempFile(name, ".xml"); + byte[] bytes = "<?xml version=\"1.0\"?><test a1=\"x\" a2=\"y\"/>" + .getBytes(StandardCharsets.UTF_8); + + Files.write(path, bytes); + return path; + } +} diff --git a/src/test/jaxp/javax/xml/jaxp/unittest/transform/ResetTest.java b/src/test/jaxp/javax/xml/jaxp/unittest/transform/ResetTest.java new file mode 100644 index 00000000000..aea7abeaeb1 --- /dev/null +++ b/src/test/jaxp/javax/xml/jaxp/unittest/transform/ResetTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package transform; + +import java.io.ByteArrayInputStream; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.testng.annotations.Test; +import javax.xml.transform.OutputKeys; +import org.testng.Assert; + +/* + * @test + * @bug 8180901 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng/othervm transform.ResetTest + * @summary Verifies reset functions + */ +public class ResetTest { + + private static final String INPUT_XML = "<a><b>123</b><c/></a>"; + /* + * Verifies that the reset method sets the Transformer to its original state + * properly. + */ + @Test + public void testReset() throws Exception { + TransformerFactory transformerFactory = + new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl(); + + // run #1 + Transformer transformer = transformerFactory.newTransformer(); + + setDefaultOutputProperties(transformer); + String outputXml1 = transform(INPUT_XML, transformer); + System.out.println("#1 output XML: " + outputXml1); + + // run #2 + transformer.reset(); + + setDefaultOutputProperties(transformer); + // use different output properties in run #2 (after the 1st reset): + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + String outputXml2 = transform(INPUT_XML, transformer); + System.out.println("#2 output XML: " + outputXml2); + + // run #3 + transformer.reset(); + + setDefaultOutputProperties(transformer); + // use same output properties as run #1 => expect same output + String outputXml3 = transform(INPUT_XML, transformer); + System.out.println("#3 output XML: " + outputXml3); + Assert.assertEquals(outputXml3, outputXml1, "Output is expected to be equal after reset."); + } + + private static void setDefaultOutputProperties(Transformer transformer) { + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + } + + private static String transform(String xml, Transformer transformer) + throws TransformerException, UnsupportedEncodingException { + StringWriter writer = new StringWriter(); + transformer.transform(new StreamSource(new ByteArrayInputStream(xml.getBytes("UTF-8"))), + new StreamResult(writer)); + return writer.toString(); + } +} diff --git a/src/test/jaxp/javax/xml/jaxp/unittest/validation/SchemaTest.java b/src/test/jaxp/javax/xml/jaxp/unittest/validation/SchemaTest.java index e9cd6473d3b..465d4c2e3c4 100644 --- a/src/test/jaxp/javax/xml/jaxp/unittest/validation/SchemaTest.java +++ b/src/test/jaxp/javax/xml/jaxp/unittest/validation/SchemaTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -24,23 +24,70 @@ package validation; import java.io.File; - +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; import javax.xml.XMLConstants; +import javax.xml.transform.stream.StreamSource; import javax.xml.validation.SchemaFactory; - +import org.testng.Assert; import org.testng.annotations.Listeners; import org.testng.annotations.Test; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; /* * @test + * @bug 8149915 8222991 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest - * @run testng/othervm -DrunSecMngr=true validation.SchemaTest * @run testng/othervm validation.SchemaTest * @summary Test Schema creation - * @bug 8149915 */ @Listeners({jaxp.library.FilePolicy.class}) public class SchemaTest { + /** + * Verifies that an over-the-limit value of an enumeration is caught as a + * warning. + * @throws Exception if the test fails + */ + @Test + public void testSchema() throws Exception { + String xsd = "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" + + " <xsd:simpleType name=\"PaymentStatus\">\n" + + " <xsd:restriction base=\"xsd:string\">\n" + + " <xsd:maxLength value=\"15\"/>\n" + + " <xsd:enumeration value=\"AWAIT_PAY_INFO\"/>\n" + + " <xsd:enumeration value=\"AWAIT_AUTH\"/>\n" + + " <xsd:enumeration value=\"REQUESTED_AUTH\"/>\n" + + " <xsd:enumeration value=\"REQUESTED_CHARGE\"/>\n" + + " <xsd:enumeration value=\"PAID\"/>\n" + + " </xsd:restriction>\n" + + " </xsd:simpleType> \n" + + "</xsd:schema>"; + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + final List<SAXParseException> exceptions = new ArrayList<>(); + + factory.setErrorHandler(new ErrorHandler() + { + @Override + public void warning(SAXParseException exception) throws SAXException + { + exceptions.add(exception); + } + + @Override + public void fatalError(SAXParseException exception) throws SAXException + {} + + @Override + public void error(SAXParseException exception) throws SAXException + {} + }); + factory.newSchema(new StreamSource(new StringReader(xsd))); + Assert.assertTrue(exceptions.get(0).toString().contains("FacetsContradict"), + "Report warning when the maxLength limit is exceeded in an enumeration"); + } /* * @bug 8149915 diff --git a/src/test/jdk/ProblemList.txt b/src/test/jdk/ProblemList.txt index 645eb42f057..d09f9cf8e38 100644 --- a/src/test/jdk/ProblemList.txt +++ b/src/test/jdk/ProblemList.txt @@ -114,8 +114,6 @@ # jdk_awt -java/awt/BasicStroke/DashScaleMinWidth.java 8198411 windows-all -java/awt/BasicStroke/DashZeroWidth.java 8198411 windows-all java/awt/event/MouseEvent/MouseClickTest/MouseClickTest.html 8168389 windows-all,macosx-all java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java 8168408 windows-all,macosx-all java/awt/Focus/FocusOwnerFrameOnClick/FocusOwnerFrameOnClick.java 8081489 generic-all @@ -620,78 +618,45 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all sun/security/pkcs11/Secmod/AddTrustedCert.java 8180837 generic-all sun/security/pkcs11/tls/TestKeyMaterial.java 8180837 generic-all +sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all +javax/net/ssl/ServerName/SSLEngineExplorerMatchedSNI.java 8212096 generic-all javax/net/ssl/DTLS/PacketLossRetransmission.java 8169086 macosx-x64 javax/net/ssl/DTLS/RespondToRetransmit.java 8169086 macosx-x64 javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 sun/security/provider/KeyStore/DKSTest.sh 8180266 windows-all -sun/security/pkcs11/Cipher/ReinitCipher.java 8204203 windows-all -sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java 8204203 windows-all -sun/security/pkcs11/Cipher/TestRSACipher.java 8204203 windows-all -sun/security/pkcs11/Cipher/TestRSACipherWrap.java 8204203 windows-all -sun/security/pkcs11/Cipher/TestRawRSACipher.java 8204203 windows-all -sun/security/pkcs11/Cipher/TestSymmCiphers.java 8204203 windows-all -sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java 8204203 windows-all -sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java 8204203 windows-all -sun/security/pkcs11/KeyAgreement/TestDH.java 8204203 windows-all -sun/security/pkcs11/KeyAgreement/TestInterop.java 8204203 windows-all -sun/security/pkcs11/KeyAgreement/TestShort.java 8204203 windows-all -sun/security/pkcs11/KeyAgreement/UnsupportedDHKeys.java 8204203 windows-all -sun/security/pkcs11/KeyGenerator/DESParity.java 8204203 windows-all -sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java 8204203 windows-all -sun/security/pkcs11/KeyPairGenerator/TestDH2048.java 8204203 windows-all -sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8204203,8209398 generic-all -sun/security/pkcs11/Mac/MacKAT.java 8204203 windows-all -sun/security/pkcs11/Mac/MacSameTest.java 8204203 windows-all -sun/security/pkcs11/Mac/ReinitMac.java 8204203 windows-all -sun/security/pkcs11/MessageDigest/ByteBuffers.java 8204203 windows-all -sun/security/pkcs11/MessageDigest/DigestKAT.java 8204203 windows-all -sun/security/pkcs11/MessageDigest/ReinitDigest.java 8204203 windows-all -sun/security/pkcs11/MessageDigest/TestCloning.java 8204203 windows-all -sun/security/pkcs11/Provider/ConfigQuotedString.sh 8204203 windows-all -sun/security/pkcs11/Provider/Login.sh 8204203 windows-all -sun/security/pkcs11/SampleTest.java 8204203 windows-all -sun/security/pkcs11/Secmod/AddPrivateKey.java 8204203 windows-all -sun/security/pkcs11/Secmod/Crypto.java 8204203 windows-all -sun/security/pkcs11/Secmod/GetPrivateKey.java 8204203 windows-all -sun/security/pkcs11/Secmod/JksSetPrivateKey.java 8204203 windows-all -sun/security/pkcs11/Secmod/LoadKeystore.java 8204203 windows-all -sun/security/pkcs11/Secmod/TestNssDbSqlite.java 8204203 windows-all -sun/security/pkcs11/SecureRandom/Basic.java 8204203 windows-all -sun/security/pkcs11/SecureRandom/TestDeserialization.java 8204203 windows-all -sun/security/pkcs11/Serialize/SerializeProvider.java 8204203 windows-all -sun/security/pkcs11/Signature/ByteBuffers.java 8204203 windows-all -sun/security/pkcs11/Signature/ReinitSignature.java 8204203 windows-all -sun/security/pkcs11/Signature/TestDSA.java 8204203 windows-all -sun/security/pkcs11/Signature/TestDSAKeyLength.java 8204203 windows-all -sun/security/pkcs11/Signature/TestRSAKeyLength.java 8204203 windows-all -sun/security/pkcs11/ec/ReadCertificates.java 8204203 windows-all -sun/security/pkcs11/ec/ReadPKCS12.java 8204203 windows-all -sun/security/pkcs11/ec/TestCurves.java 8204203 windows-all -sun/security/pkcs11/ec/TestECDH.java 8204203 windows-all -sun/security/pkcs11/ec/TestECDH2.java 8204203 windows-all -sun/security/pkcs11/ec/TestECDSA.java 8204203 windows-all -sun/security/pkcs11/ec/TestECDSA2.java 8204203 windows-all -sun/security/pkcs11/ec/TestECGenSpec.java 8204203 windows-all -sun/security/pkcs11/rsa/KeyWrap.java 8204203 windows-all -sun/security/pkcs11/rsa/TestCACerts.java 8204203 windows-all -sun/security/pkcs11/rsa/TestKeyFactory.java 8204203 windows-all -sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8204203 windows-all -sun/security/pkcs11/rsa/TestSignatures.java 8204203 windows-all -sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8204203 windows-all -sun/security/pkcs11/tls/TestLeadingZeroesP11.java 8204203 windows-all -sun/security/pkcs11/tls/TestMasterSecret.java 8204203 windows-all -sun/security/pkcs11/tls/TestPRF.java 8204203 windows-all -sun/security/pkcs11/tls/TestPremaster.java 8204203 windows-all +sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 8209398 generic-all security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java 8224768 generic-all +sun/security/smartcardio/TestChannel.java 8039280 generic-all +sun/security/smartcardio/TestConnect.java 8039280 generic-all +sun/security/smartcardio/TestConnectAgain.java 8039280 generic-all +sun/security/smartcardio/TestControl.java 8039280 generic-all +sun/security/smartcardio/TestDefault.java 8039280 generic-all +sun/security/smartcardio/TestDirect.java 8039280 generic-all +sun/security/smartcardio/TestExclusive.java 8039280 generic-all +sun/security/smartcardio/TestMultiplePresent.java 8039280 generic-all +sun/security/smartcardio/TestPresent.java 8039280 generic-all +sun/security/smartcardio/TestTransmit.java 8039280 generic-all +com/sun/crypto/provider/Cipher/DES/PerformanceTest.java 8039280 generic-all +com/sun/security/auth/callback/TextCallbackHandler/Default.java 8039280 generic-all +com/sun/security/auth/callback/TextCallbackHandler/Password.java 8039280 generic-all +com/sun/security/sasl/gsskerb/AuthOnly.java 8039280 generic-all +com/sun/security/sasl/gsskerb/ConfSecurityLayer.java 8039280 generic-all +com/sun/security/sasl/gsskerb/NoSecurityLayer.java 8039280 generic-all +javax/security/auth/kerberos/KerberosHashEqualsTest.java 8039280 generic-all +javax/security/auth/kerberos/KerberosTixDateTest.java 8039280 generic-all +sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.java 8039280 generic-all +sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-all +sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all + ############################################################################ # jdk_sound diff --git a/src/test/jdk/java/awt/BasicStroke/DashOffset.java b/src/test/jdk/java/awt/BasicStroke/DashOffset.java index a7183e249df..19edb9cf554 100644 --- a/src/test/jdk/java/awt/BasicStroke/DashOffset.java +++ b/src/test/jdk/java/awt/BasicStroke/DashOffset.java @@ -29,6 +29,7 @@ import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.image.BufferedImage; +import java.awt.image.IndexColorModel; import java.awt.image.VolatileImage; import java.io.File; import java.io.IOException; @@ -40,7 +41,8 @@ /* * @test - * @bug 4469881 8217263 + * @bug 4469881 8217263 8218682 + * @key headful * @summary Verifies that dashed rectangles drawn to the screen line * up with their undashed counterparts * @author flar @@ -79,16 +81,16 @@ public static void main(String[] argv) throws Exception { } } - if (GraphicsEnvironment.isHeadless()) { - return; - } - BufferedImage snapshot = null; try { final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .getDefaultConfiguration(); + if (gc.getColorModel() instanceof IndexColorModel) { + System.err.println("Skipping VolatileImage because of IndexColorModel"); + return; + } VolatileImage vi = gc.createCompatibleVolatileImage(WIDTH, HEIGHT); int attempt = 0; @@ -102,7 +104,7 @@ public static void main(String[] argv) throws Exception { } validate(snapshot); } finally { - if (saveImage) { + if (saveImage && snapshot != null) { save(snapshot, "volatileImage.png"); } } diff --git a/src/test/jdk/java/awt/BasicStroke/DashScaleMinWidth.java b/src/test/jdk/java/awt/BasicStroke/DashScaleMinWidth.java index ef7dded92e0..cf0df50d9f6 100644 --- a/src/test/jdk/java/awt/BasicStroke/DashScaleMinWidth.java +++ b/src/test/jdk/java/awt/BasicStroke/DashScaleMinWidth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,13 +29,15 @@ import java.awt.Image; import java.awt.geom.Line2D; import java.awt.image.BufferedImage; +import java.awt.image.IndexColorModel; import java.awt.image.VolatileImage; import static java.awt.image.BufferedImage.TYPE_INT_ARGB; /** * @test - * @bug 4917097 8019816 + * @bug 4917097 8019816 8198411 + * @key headful * @summary 1.4.1 REGRESSION: BasicStroke Dashes don't show when scale * line width = 1.0 * @run main/othervm -Dsun.java2d.uiScale=1 DashScaleMinWidth */ @@ -46,13 +48,13 @@ public static void main(final String[] args) { draw(img); validate(img); - if (GraphicsEnvironment.isHeadless()) { - return; - } - GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); + if (gc.getColorModel() instanceof IndexColorModel) { + System.err.println("Skipping VolatileImage because of IndexColorModel"); + return; + } VolatileImage vi = gc.createCompatibleVolatileImage(200, 40); BufferedImage snapshot; diff --git a/src/test/jdk/java/awt/BasicStroke/DashZeroWidth.java b/src/test/jdk/java/awt/BasicStroke/DashZeroWidth.java index fb0f51ce4a1..556ed8730e4 100644 --- a/src/test/jdk/java/awt/BasicStroke/DashZeroWidth.java +++ b/src/test/jdk/java/awt/BasicStroke/DashZeroWidth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,13 +29,15 @@ import java.awt.Image; import java.awt.geom.Line2D; import java.awt.image.BufferedImage; +import java.awt.image.IndexColorModel; import java.awt.image.VolatileImage; import static java.awt.image.BufferedImage.TYPE_INT_ARGB; /** * @test - * @bug 4779211 8019816 + * @bug 4779211 8019816 8198411 + * @key headful * @summary REGRESSION: 1.4 Dashed lines disappear if BasicStroke width=0.0 * @run main/othervm -Dsun.java2d.uiScale=1 DashZeroWidth */ @@ -46,13 +48,13 @@ public static void main(final String[] args) { draw(img); validate(img); - if (GraphicsEnvironment.isHeadless()) { - return; - } - GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); + if (gc.getColorModel() instanceof IndexColorModel) { + System.err.println("Skipping VolatileImage because of IndexColorModel"); + return; + } VolatileImage vi = gc.createCompatibleVolatileImage(200, 40); BufferedImage snapshot; diff --git a/src/test/jdk/java/awt/Color/AlphaColorTest.java b/src/test/jdk/java/awt/Color/AlphaColorTest.java index 6732827e014..e678a0d23a9 100644 --- a/src/test/jdk/java/awt/Color/AlphaColorTest.java +++ b/src/test/jdk/java/awt/Color/AlphaColorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -24,7 +24,7 @@ /** * @test * @key headful - * @bug 8204931 + * @bug 8204931 8227392 8224825 * @summary test alpha colors are blended with background. */ @@ -73,8 +73,14 @@ public static void main(String args[]) throws Exception { static Frame frame; private static void createAndShowGUI() { - frame = new Frame("Alpha Color Test"); - frame.setBackground(Color.black); + frame = new Frame("Alpha Color Test") { + @Override + public void paint(Graphics g) { + g.setColor(Color.black); + g.fillRect(0, 0, getWidth(), getHeight()); + super.paint(g); + } + }; Color color = new Color(255, 255, 255, 127); frame.add("Center", new AlphaColorTest(color)); frame.pack(); diff --git a/src/test/jdk/java/awt/image/DrawImage/IncorrectManagedImageSourceOffset.java b/src/test/jdk/java/awt/image/DrawImage/IncorrectManagedImageSourceOffset.java new file mode 100644 index 00000000000..5c5180e00b2 --- /dev/null +++ b/src/test/jdk/java/awt/image/DrawImage/IncorrectManagedImageSourceOffset.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.Raster; +import java.awt.image.VolatileImage; +import java.awt.image.WritableRaster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import sun.awt.image.SunWritableRaster; + +import static java.awt.Transparency.BITMASK; +import static java.awt.Transparency.OPAQUE; +import static java.awt.Transparency.TRANSLUCENT; +import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE; +import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY; +import static java.awt.image.BufferedImage.TYPE_BYTE_INDEXED; +import static java.awt.image.BufferedImage.TYPE_CUSTOM; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE; +import static java.awt.image.BufferedImage.TYPE_INT_BGR; +import static java.awt.image.BufferedImage.TYPE_INT_RGB; + +/** + * @test + * @key headful + * @bug 8029253 6207877 + * @summary Tests asymmetric source offsets when managed image is drawn to VI. + * Results of the blit to compatibleImage are used for comparison. + * @author Sergey Bylokhov + * @modules java.desktop/sun.awt.image + * @run main/othervm -Dsun.java2d.accthreshold=0 IncorrectManagedImageSourceOffset + * @run main/othervm -Dsun.java2d.accthreshold=0 -Dsun.java2d.uiScale=1 IncorrectManagedImageSourceOffset + * @run main/othervm -Dsun.java2d.accthreshold=0 -Dsun.java2d.uiScale=2 IncorrectManagedImageSourceOffset + */ +public final class IncorrectManagedImageSourceOffset { + + // See the same test for unmanaged images: IncorrectUnmanagedImageSourceOffset + + private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB, + TYPE_INT_ARGB_PRE, TYPE_INT_BGR, + TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, + TYPE_4BYTE_ABGR_PRE, + /*TYPE_USHORT_565_RGB, + TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY, + TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY, + TYPE_BYTE_INDEXED, TYPE_CUSTOM}; + private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT}; + + public static void main(final String[] args) throws IOException { + for (final int viType : TRANSPARENCIES) { + for (final int biType : TYPES) { + BufferedImage bi = makeManagedBI(biType); + fill(bi); + test(bi, viType); + } + } + } + + private static void test(BufferedImage bi, int type) + throws IOException { + GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + GraphicsConfiguration gc = ge.getDefaultScreenDevice() + .getDefaultConfiguration(); + VolatileImage vi = gc.createCompatibleVolatileImage(511, 255, type); + BufferedImage gold = gc.createCompatibleImage(511, 255, type); + // draw to compatible Image + Graphics2D big = gold.createGraphics(); + // force scaled blit + big.drawImage(bi, 7, 11, 127, 111, 7, 11, 127 * 2, 111, null); + big.dispose(); + // draw to volatile image + BufferedImage snapshot; + while (true) { + vi.validate(gc); + if (vi.validate(gc) != VolatileImage.IMAGE_OK) { + try { + Thread.sleep(100); + } catch (final InterruptedException ignored) { + } + continue; + } + Graphics2D vig = vi.createGraphics(); + // force scaled blit + vig.drawImage(bi, 7, 11, 127, 111, 7, 11, 127 * 2, 111, null); + vig.dispose(); + snapshot = vi.getSnapshot(); + if (vi.contentsLost()) { + try { + Thread.sleep(100); + } catch (final InterruptedException ignored) { + } + continue; + } + break; + } + // validate images + for (int x = 7; x < 127; ++x) { + for (int y = 11; y < 111; ++y) { + if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) { + ImageIO.write(gold, "png", new File("gold.png")); + ImageIO.write(snapshot, "png", new File("bi.png")); + throw new RuntimeException("Test failed."); + } + } + } + } + + private static BufferedImage makeManagedBI(final int type) { + final BufferedImage bi; + if (type == TYPE_CUSTOM) { + bi = makeCustomManagedBI(); + } else { + bi = new BufferedImage(511, 255, type); + } + bi.setAccelerationPriority(1.0f); + return bi; + } + + /** + * Returns the custom buffered image, which mostly identical to + * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride. + * This means that the raster will have gaps, between the rows. + */ + private static BufferedImage makeCustomManagedBI() { + int w = 511, h = 255; + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + int[] nBits = {8, 8, 8}; + int[] bOffs = {2, 1, 0}; + ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false, + Transparency.OPAQUE, + DataBuffer.TYPE_BYTE); + WritableRaster raster = + Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, + w * 3 + 2, 3, bOffs, null); + BufferedImage bi = new BufferedImage(colorModel, raster, true, null); + SunWritableRaster.makeTrackable(raster.getDataBuffer()); + SunWritableRaster.markDirty(bi); + return bi; + } + + private static void fill(final Image image) { + final Graphics2D graphics = (Graphics2D) image.getGraphics(); + graphics.setComposite(AlphaComposite.Src); + for (int i = 0; i < image.getHeight(null); ++i) { + graphics.setColor(new Color(i, 0, 0)); + graphics.fillRect(0, i, image.getWidth(null), 1); + } + graphics.dispose(); + } +} diff --git a/src/test/jdk/java/awt/image/DrawImage/IncorrectUnmanagedImageSourceOffset.java b/src/test/jdk/java/awt/image/DrawImage/IncorrectUnmanagedImageSourceOffset.java index 486d3449042..d0c49c94686 100644 --- a/src/test/jdk/java/awt/image/DrawImage/IncorrectUnmanagedImageSourceOffset.java +++ b/src/test/jdk/java/awt/image/DrawImage/IncorrectUnmanagedImageSourceOffset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -27,30 +27,52 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Image; +import java.awt.Transparency; +import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; import java.awt.image.DataBuffer; import java.awt.image.DataBufferByte; import java.awt.image.DataBufferInt; import java.awt.image.DataBufferShort; +import java.awt.image.Raster; import java.awt.image.VolatileImage; +import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; -import static java.awt.Transparency.*; -import static java.awt.image.BufferedImage.*; +import static java.awt.Transparency.BITMASK; +import static java.awt.Transparency.OPAQUE; +import static java.awt.Transparency.TRANSLUCENT; +import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE; +import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY; +import static java.awt.image.BufferedImage.TYPE_BYTE_INDEXED; +import static java.awt.image.BufferedImage.TYPE_CUSTOM; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE; +import static java.awt.image.BufferedImage.TYPE_INT_BGR; +import static java.awt.image.BufferedImage.TYPE_INT_RGB; /** * @test * @key headful - * @bug 8029253 + * @bug 8029253 6207877 * @summary Tests asymmetric source offsets when unmanaged image is drawn to VI. * Results of the blit to compatibleImage are used for comparison. * @author Sergey Bylokhov + * @run main/othervm IncorrectUnmanagedImageSourceOffset + * @run main/othervm -Dsun.java2d.uiScale=1 IncorrectUnmanagedImageSourceOffset + * @run main/othervm -Dsun.java2d.uiScale=2 IncorrectUnmanagedImageSourceOffset */ public final class IncorrectUnmanagedImageSourceOffset { + // See the same test for managed images: IncorrectManagedImageSourceOffset + private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, @@ -58,7 +80,7 @@ public final class IncorrectUnmanagedImageSourceOffset { /*TYPE_USHORT_565_RGB, TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY, TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY, - TYPE_BYTE_INDEXED}; + TYPE_BYTE_INDEXED, TYPE_CUSTOM}; private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT}; public static void main(final String[] args) throws IOException { @@ -122,7 +144,12 @@ private static void test(BufferedImage bi, int type) } private static BufferedImage makeUnmanagedBI(final int type) { - final BufferedImage bi = new BufferedImage(511, 255, type); + final BufferedImage bi; + if (type == TYPE_CUSTOM) { + bi = makeCustomUnmanagedBI(); + } else { + bi = new BufferedImage(511, 255, type); + } final DataBuffer db = bi.getRaster().getDataBuffer(); if (db instanceof DataBufferInt) { ((DataBufferInt) db).getData(); @@ -130,15 +157,30 @@ private static BufferedImage makeUnmanagedBI(final int type) { ((DataBufferShort) db).getData(); } else if (db instanceof DataBufferByte) { ((DataBufferByte) db).getData(); - } else { - try { - bi.setAccelerationPriority(0.0f); - } catch (final Throwable ignored) { - } } + bi.setAccelerationPriority(0.0f); return bi; } + /** + * Returns the custom buffered image, which mostly identical to + * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride. + * This means that the raster will have gaps, between the rows. + */ + private static BufferedImage makeCustomUnmanagedBI() { + int w = 511, h = 255; + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + int[] nBits = {8, 8, 8}; + int[] bOffs = {2, 1, 0}; + ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false, + Transparency.OPAQUE, + DataBuffer.TYPE_BYTE); + WritableRaster raster = + Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, + w * 3 + 2, 3, bOffs, null); + return new BufferedImage(colorModel, raster, true, null); + } + private static void fill(final Image image) { final Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.setComposite(AlphaComposite.Src); diff --git a/src/test/jdk/java/awt/image/DrawImage/SimpleManagedImage.java b/src/test/jdk/java/awt/image/DrawImage/SimpleManagedImage.java new file mode 100644 index 00000000000..e0fefa74306 --- /dev/null +++ b/src/test/jdk/java/awt/image/DrawImage/SimpleManagedImage.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.Raster; +import java.awt.image.VolatileImage; +import java.awt.image.WritableRaster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import sun.awt.image.SunWritableRaster; + +import static java.awt.Transparency.BITMASK; +import static java.awt.Transparency.OPAQUE; +import static java.awt.Transparency.TRANSLUCENT; +import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE; +import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY; +import static java.awt.image.BufferedImage.TYPE_BYTE_INDEXED; +import static java.awt.image.BufferedImage.TYPE_CUSTOM; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE; +import static java.awt.image.BufferedImage.TYPE_INT_BGR; +import static java.awt.image.BufferedImage.TYPE_INT_RGB; + +/** + * @test + * @key headful + * @bug 8029253 6207877 + * @summary Tests the case when managed image is drawn to VI. + * Results of the blit to compatibleImage are used for comparison. + * @author Sergey Bylokhov + * @modules java.desktop/sun.awt.image + * @run main/othervm -Dsun.java2d.accthreshold=0 SimpleManagedImage + * @run main/othervm -Dsun.java2d.accthreshold=0 -Dsun.java2d.uiScale=1 SimpleManagedImage + * @run main/othervm -Dsun.java2d.accthreshold=0 -Dsun.java2d.uiScale=2 SimpleManagedImage + */ +public final class SimpleManagedImage { + + // See the same test for unmanaged images: SimpleUnmanagedImage + + private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB, + TYPE_INT_ARGB_PRE, TYPE_INT_BGR, + TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, + TYPE_4BYTE_ABGR_PRE, + /*TYPE_USHORT_565_RGB, + TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY, + TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY, + TYPE_BYTE_INDEXED, TYPE_CUSTOM}; + private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT}; + + public static void main(final String[] args) throws IOException { + for (final int viType : TRANSPARENCIES) { + for (final int biType : TYPES) { + BufferedImage bi = makeManagedBI(biType); + fill(bi); + test(bi, viType); + } + } + } + + private static void test(BufferedImage bi, int type) + throws IOException { + GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + GraphicsConfiguration gc = ge.getDefaultScreenDevice() + .getDefaultConfiguration(); + VolatileImage vi = gc.createCompatibleVolatileImage(1000, 1000, type); + BufferedImage gold = gc.createCompatibleImage(1000, 1000, type); + // draw to compatible Image + init(gold); + Graphics2D big = gold.createGraphics(); + big.drawImage(bi, 7, 11, null); + big.dispose(); + // draw to volatile image + BufferedImage snapshot; + while (true) { + vi.validate(gc); + if (vi.validate(gc) != VolatileImage.IMAGE_OK) { + try { + Thread.sleep(100); + } catch (final InterruptedException ignored) { + } + continue; + } + init(vi); + Graphics2D vig = vi.createGraphics(); + vig.drawImage(bi, 7, 11, null); + vig.dispose(); + snapshot = vi.getSnapshot(); + if (vi.contentsLost()) { + try { + Thread.sleep(100); + } catch (final InterruptedException ignored) { + } + continue; + } + break; + } + // validate images + for (int x = 0; x < 1000; ++x) { + for (int y = 0; y < 1000; ++y) { + if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) { + ImageIO.write(gold, "png", new File("gold.png")); + ImageIO.write(snapshot, "png", new File("bi.png")); + throw new RuntimeException("Test failed."); + } + } + } + } + + private static BufferedImage makeManagedBI(final int type) { + final BufferedImage bi; + if (type == TYPE_CUSTOM) { + bi = makeCustomManagedBI(); + } else { + bi = new BufferedImage(511, 255, type); + } + bi.setAccelerationPriority(1.0f); + return bi; + } + + /** + * Returns the custom buffered image, which mostly identical to + * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride. + * This means that the raster will have gaps, between the rows. + */ + private static BufferedImage makeCustomManagedBI() { + int w = 511, h = 255; + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + int[] nBits = {8, 8, 8}; + int[] bOffs = {2, 1, 0}; + ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false, + Transparency.OPAQUE, + DataBuffer.TYPE_BYTE); + WritableRaster raster = + Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, + w * 3 + 2, 3, bOffs, null); + BufferedImage bi = new BufferedImage(colorModel, raster, true, null); + SunWritableRaster.makeTrackable(raster.getDataBuffer()); + SunWritableRaster.markDirty(bi); + return bi; + } + + private static void init(final Image image) { + final Graphics2D graphics = (Graphics2D) image.getGraphics(); + graphics.setComposite(AlphaComposite.Src); + graphics.setColor(new Color(0, 0, 0, 0)); + graphics.fillRect(0, 0, image.getWidth(null), image.getHeight(null)); + graphics.dispose(); + } + + private static void fill(final Image image) { + final Graphics2D graphics = (Graphics2D) image.getGraphics(); + graphics.setComposite(AlphaComposite.Src); + for (int i = 0; i < image.getHeight(null); ++i) { + graphics.setColor(new Color(i, 0, 0)); + graphics.fillRect(0, i, image.getWidth(null), 1); + } + graphics.dispose(); + } +} diff --git a/src/test/jdk/java/awt/image/DrawImage/SimpleUnmanagedImage.java b/src/test/jdk/java/awt/image/DrawImage/SimpleUnmanagedImage.java new file mode 100644 index 00000000000..01921249460 --- /dev/null +++ b/src/test/jdk/java/awt/image/DrawImage/SimpleUnmanagedImage.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBufferShort; +import java.awt.image.Raster; +import java.awt.image.VolatileImage; +import java.awt.image.WritableRaster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import static java.awt.Transparency.BITMASK; +import static java.awt.Transparency.OPAQUE; +import static java.awt.Transparency.TRANSLUCENT; +import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR; +import static java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE; +import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY; +import static java.awt.image.BufferedImage.TYPE_BYTE_INDEXED; +import static java.awt.image.BufferedImage.TYPE_CUSTOM; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE; +import static java.awt.image.BufferedImage.TYPE_INT_BGR; +import static java.awt.image.BufferedImage.TYPE_INT_RGB; + +/** + * @test + * @key headful + * @bug 8029253 6207877 + * @summary Tests the case when unmanaged image is drawn to VI. + * Results of the blit to compatibleImage are used for comparison. + * @author Sergey Bylokhov + * @run main/othervm SimpleUnmanagedImage + * @run main/othervm -Dsun.java2d.uiScale=1 SimpleUnmanagedImage + * @run main/othervm -Dsun.java2d.uiScale=2 SimpleUnmanagedImage + */ +public final class SimpleUnmanagedImage { + + // See the same test for managed images: SimpleManagedImage + + private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB, + TYPE_INT_ARGB_PRE, TYPE_INT_BGR, + TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, + TYPE_4BYTE_ABGR_PRE, + /*TYPE_USHORT_565_RGB, + TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY, + TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY, + TYPE_BYTE_INDEXED, TYPE_CUSTOM}; + private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT}; + + public static void main(final String[] args) throws IOException { + for (final int viType : TRANSPARENCIES) { + for (final int biType : TYPES) { + BufferedImage bi = makeUnmanagedBI(biType); + fill(bi); + test(bi, viType); + } + } + } + + private static void test(BufferedImage bi, int type) + throws IOException { + GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + GraphicsConfiguration gc = ge.getDefaultScreenDevice() + .getDefaultConfiguration(); + VolatileImage vi = gc.createCompatibleVolatileImage(1000, 1000, type); + BufferedImage gold = gc.createCompatibleImage(1000, 1000, type); + // draw to compatible Image + init(gold); + Graphics2D big = gold.createGraphics(); + big.drawImage(bi, 7, 11, null); + big.dispose(); + // draw to volatile image + BufferedImage snapshot; + while (true) { + vi.validate(gc); + if (vi.validate(gc) != VolatileImage.IMAGE_OK) { + try { + Thread.sleep(100); + } catch (final InterruptedException ignored) { + } + continue; + } + init(vi); + Graphics2D vig = vi.createGraphics(); + vig.drawImage(bi, 7, 11, null); + vig.dispose(); + snapshot = vi.getSnapshot(); + if (vi.contentsLost()) { + try { + Thread.sleep(100); + } catch (final InterruptedException ignored) { + } + continue; + } + break; + } + // validate images + for (int x = 0; x < 1000; ++x) { + for (int y = 0; y < 1000; ++y) { + if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) { + ImageIO.write(gold, "png", new File("gold.png")); + ImageIO.write(snapshot, "png", new File("bi.png")); + throw new RuntimeException("Test failed."); + } + } + } + } + + private static BufferedImage makeUnmanagedBI(final int type) { + final BufferedImage bi; + if (type == TYPE_CUSTOM) { + bi = makeCustomUnmanagedBI(); + } else { + bi = new BufferedImage(511, 255, type); + } + final DataBuffer db = bi.getRaster().getDataBuffer(); + if (db instanceof DataBufferInt) { + ((DataBufferInt) db).getData(); + } else if (db instanceof DataBufferShort) { + ((DataBufferShort) db).getData(); + } else if (db instanceof DataBufferByte) { + ((DataBufferByte) db).getData(); + } + bi.setAccelerationPriority(0.0f); + return bi; + } + + /** + * Returns the custom buffered image, which mostly identical to + * BufferedImage.(w,h,TYPE_3BYTE_BGR), but uses the bigger scanlineStride. + * This means that the raster will have gaps, between the rows. + */ + private static BufferedImage makeCustomUnmanagedBI() { + int w = 511, h = 255; + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + int[] nBits = {8, 8, 8}; + int[] bOffs = {2, 1, 0}; + ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false, + Transparency.OPAQUE, + DataBuffer.TYPE_BYTE); + WritableRaster raster = + Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, + w * 3 + 2, 3, bOffs, null); + return new BufferedImage(colorModel, raster, true, null); + } + + private static void init(final Image image) { + final Graphics2D graphics = (Graphics2D) image.getGraphics(); + graphics.setComposite(AlphaComposite.Src); + graphics.setColor(new Color(0, 0, 0, 0)); + graphics.fillRect(0, 0, image.getWidth(null), image.getHeight(null)); + graphics.dispose(); + } + + private static void fill(final Image image) { + final Graphics2D graphics = (Graphics2D) image.getGraphics(); + graphics.setComposite(AlphaComposite.Src); + for (int i = 0; i < image.getHeight(null); ++i) { + graphics.setColor(new Color(i, 0, 0)); + graphics.fillRect(0, i, image.getWidth(null), 1); + } + graphics.dispose(); + } +} diff --git a/src/test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java b/src/test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java index b782e832e8c..2b182266234 100644 --- a/src/test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java +++ b/src/test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java @@ -23,10 +23,10 @@ /* * @test - * @bug 8153732 8212202 8221263 8221412 + * @bug 8153732 8212202 8221263 8221412 8222108 * @requires (os.family == "Windows") * @summary Windows remote printer changes do not reflect in lookupPrintServices() - * @run main/manual RemotePrinterStatusRefresh + * @run main/manual/othervm -Dsun.java2d.print.minRefreshTime=120 RemotePrinterStatusRefresh */ import java.awt.BorderLayout; @@ -63,6 +63,9 @@ public class RemotePrinterStatusRefresh extends WindowAdapter { + private static final long DEFAULT_REFRESH_TIME = 240L; + private static final long MINIMAL_REFRESH_TIME = 120L; + private static final long refreshTime = getRefreshTime(); private static final long TIMEOUT = refreshTime * 4 + 60; @@ -181,7 +184,7 @@ public Component getListCellRendererComponent(JList<?> list, + "configured printers.\n" + "Step 1: Add or Remove a network printer using " + "Windows Control Panel.\n" - + "Step 2: Wait for 4 minutes after adding or removing.\n" + + "Step 2: Wait for 2\u20134 minutes after adding or removing.\n" + " \"Next printer refresh in\" gives you a " + "rough estimation on when update will happen.\n" + "Step 3: Click Refresh." @@ -195,7 +198,7 @@ public Component getListCellRendererComponent(JList<?> list, + "Step 5: Click Pass if the list of printers is correctly " + "updated.\n" + "Step 6: If the list is not updated, wait for another " - + "4 minutes, and then click Refresh again.\n" + + "2\u20134 minutes, and then click Refresh again.\n" + "Step 7: If the list does not update, click Fail.\n" + "\n" + "You have to click Refresh to enable Pass and Fail buttons. " @@ -215,12 +218,13 @@ public static void main(String[] args) throws Exception { private static long getRefreshTime() { String refreshTime = - System.getProperty("sun.java2d.print.minRefreshTime", "240"); + System.getProperty("sun.java2d.print.minRefreshTime", + Long.toString(DEFAULT_REFRESH_TIME)); try { long value = Long.parseLong(refreshTime); - return value < 240L ? 240L : value; + return value < MINIMAL_REFRESH_TIME ? MINIMAL_REFRESH_TIME : value; } catch (NumberFormatException e) { - return 240L; + return DEFAULT_REFRESH_TIME; } } diff --git a/src/test/jdk/java/beans/PropertyEditor/Test6397609.java b/src/test/jdk/java/beans/PropertyEditor/Test6397609.java index 6893f66edf9..82f1411320a 100644 --- a/src/test/jdk/java/beans/PropertyEditor/Test6397609.java +++ b/src/test/jdk/java/beans/PropertyEditor/Test6397609.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2019, 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,31 +32,38 @@ */ import java.beans.PropertyEditorManager; +import java.lang.ref.WeakReference; public class Test6397609 { public static void main(String[] args) throws Exception { - MemoryClassLoader loader = new MemoryClassLoader(); - PropertyEditorManager.registerEditor( - Object.class, - loader.compile("Editor", - "public class Editor extends java.beans.PropertyEditorSupport {}")); + Class<?> targetClass = Object.class; + Class<?> editorClass = new MemoryClassLoader().compile("Editor", + "public class Editor extends java.beans.PropertyEditorSupport {}"); + PropertyEditorManager.registerEditor(targetClass, editorClass); - if (!isEditorExist(Object.class)) { + // trigger a gc + Object object = new Object(); + var r = new WeakReference<Object>(object); + object = null; + while (r.get() != null) { + System.gc(); + Thread.sleep(100); + } + + if (PropertyEditorManager.findEditor(targetClass) == null) { throw new Error("the editor is lost"); } - loader = null; // clean the reference - if (isEditorExist(Object.class)) { - throw new Error("unexpected editor is found"); + + // allow, and wait for, Editor class to be unloaded + var ref = new WeakReference<Class<?>>(editorClass); + editorClass = null; + while (ref.get() != null) { + System.gc(); + Thread.sleep(100); } - } - private static boolean isEditorExist(Class type) { - for (int i = 0; i < 10; i++) { - System.gc(); // clean all weak references - if (null == PropertyEditorManager.findEditor(type)) { - return false; - } + if (PropertyEditorManager.findEditor(targetClass) != null) { + throw new Error("unexpected editor is found"); } - return true; } } diff --git a/src/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java b/src/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java new file mode 100644 index 00000000000..d735e78f684 --- /dev/null +++ b/src/test/jdk/java/io/LineNumberReader/MarkSplitCRLF.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8218280 + * @summary Make sure marking a line feed within a CRLF sequence works correctly + * @run testng MarkSplitCRLF + */ + +import java.io.IOException; +import java.io.LineNumberReader; +import java.io.Reader; +import java.io.StringReader; + +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +public class MarkSplitCRLF { + @Test + public static void testSpecifiedBufferSize() throws IOException { + final String string = "foo\r\nbar"; + try (Reader reader = + new LineNumberReader(new StringReader(string), 5)) { + reader.read(); // 'f' + reader.read(); // 'o' + reader.read(); // 'o' + reader.read(); // '\r' -> '\n' + reader.mark(1); // mark position of '\n' + reader.read(); // 'b' + reader.reset(); // reset to '\n' position + assertEquals(reader.read(), 'b'); + assertEquals(reader.read(), 'a'); + assertEquals(reader.read(), 'r'); + } + } + + @Test + public static void testCRNotFollowedByLF() throws IOException { + final String string = "foo\rbar"; + try (Reader reader = + new LineNumberReader(new StringReader(string), 5)) { + reader.read(); // 'f' + reader.read(); // 'o' + reader.read(); // 'o' + reader.read(); // '\r' + reader.mark(1); // mark position of next character + reader.read(); // 'b' + reader.reset(); // reset to position after '\r' + assertEquals(reader.read(), 'b'); + assertEquals(reader.read(), 'a'); + assertEquals(reader.read(), 'r'); + } + } + + @Test + public static void testDefaultBufferSize() throws IOException { + StringBuilder sb = new StringBuilder(8195); + for (int i = 0; i < 8190; i++) { + char c = (char)i; + sb.append(c); + } + sb.append('\r'); + sb.append('\n'); + sb.append('X'); + sb.append('Y'); + sb.append('Z'); + final String string = sb.toString(); + try (Reader reader = new LineNumberReader(new StringReader(string))) { + for (int i = 0; i < 8191; i++) reader.read(); + reader.mark(1); + reader.read(); + reader.reset(); + assertEquals(reader.read(), 'X'); + assertEquals(reader.read(), 'Y'); + assertEquals(reader.read(), 'Z'); + } + } +} diff --git a/src/test/jdk/java/net/DatagramSocket/ReuseAddressTest.java b/src/test/jdk/java/net/DatagramSocket/ReuseAddressTest.java index 86cefa05805..22535a4cf4d 100644 --- a/src/test/jdk/java/net/DatagramSocket/ReuseAddressTest.java +++ b/src/test/jdk/java/net/DatagramSocket/ReuseAddressTest.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2016, 2019, 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 @@ -116,7 +116,7 @@ public void DatagramSocket0030() throws Exception { MulticastSocket ms1 = null; MulticastSocket ms2 = null; try { - InetSocketAddress addr = createSocketAddress(5050); + InetSocketAddress addr = createSocketAddress(0); ms1 = new MulticastSocket(null); ms1.setReuseAddress(true); @@ -132,6 +132,7 @@ public void DatagramSocket0030() throws Exception { + " unexpected " + e); } + addr = createSocketAddress(ms1.getLocalPort()); ms2 = new MulticastSocket(null); ms2.setReuseAddress(true); if (!ms2.getReuseAddress()) { @@ -186,7 +187,7 @@ public void DatagramSocket0031() throws Exception { MulticastSocket ms1 = null; MulticastSocket ms2 = null; try { - InetSocketAddress addr = createSocketAddress(6060); + InetSocketAddress addr = createSocketAddress(0); ms1 = new MulticastSocket(null); try { @@ -196,6 +197,7 @@ public void DatagramSocket0031() throws Exception { + " unexpected " + e); } + addr = createSocketAddress(ms1.getLocalPort()); ms2 = new MulticastSocket(null); ms2.setReuseAddress(false); // method under test @@ -243,15 +245,13 @@ public void DatagramSocket0032() throws Exception { DatagramSocket ds2 = null; try { - InetSocketAddress isa = createSocketAddress(7070); - InetAddress addr = isa.getAddress(); + InetSocketAddress isa1 = createSocketAddress(0); + InetAddress addr = isa1.getAddress(); InetAddress wildcard = InetAddress.getByName("0.0.0.0"); if (addr.equals(wildcard) || addr.isLoopbackAddress()) { System.out.println("Cannot check: addresses are equal"); } - InetSocketAddress isa1 = new InetSocketAddress(addr, isa.getPort()); - InetSocketAddress isa2 = new InetSocketAddress(wildcard, isa.getPort()); ds1 = new DatagramSocket(null); ds1.setReuseAddress(true); // method under test @@ -261,6 +261,8 @@ public void DatagramSocket0032() throws Exception { } ds1.bind(isa1); + InetSocketAddress isa2 = new InetSocketAddress(wildcard, ds1.getLocalPort()); + ds2 = new DatagramSocket(null); ds2.setReuseAddress(true); // method under test if (!ds2.getReuseAddress()) { @@ -275,8 +277,8 @@ public void DatagramSocket0032() throws Exception { + " unexpected " + e); } - if (ds1.getLocalPort() != isa.getPort() || !ds1.isBound() - || ds2.getLocalPort() != isa.getPort() || !ds2.isBound()) { + if (ds1.getLocalPort() != ds2.getLocalPort() || !ds1.isBound() + || !ds2.isBound()) { System.out.println("bind() fails with: " + addr); System.out.println(" ds1 [" + getInfo(ds1) + "]"); System.out.println(" ds2 [" + getInfo(ds2) + "]"); diff --git a/src/test/jdk/java/net/URL/NonOverridableHandlerFactory.java b/src/test/jdk/java/net/URL/NonOverridableHandlerFactory.java new file mode 100644 index 00000000000..bcf0a5348c2 --- /dev/null +++ b/src/test/jdk/java/net/URL/NonOverridableHandlerFactory.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8217364 + * @summary Custom URLStreamHandler for jrt or file protocol can override default handler + * @modules java.base/java.net:open + * @run main/othervm NonOverridableHandlerFactory + */ + +import java.io.*; +import java.net.*; + +public class NonOverridableHandlerFactory implements URLStreamHandlerFactory { + @Override + public URLStreamHandler createURLStreamHandler(String protocol) { + return new NonOverridableHandler(); + } + + private static class NonOverridableHandler extends URLStreamHandler { + @Override + protected URLConnection openConnection(URL u) throws IOException { + throw new RuntimeException("CustomURLStreamHandler used for " + u); + } + } + + public static void main(String[] args) { + URL.setURLStreamHandlerFactory(new NonOverridableHandlerFactory()); + for (String protocol : new String[] {"file", "jrt"}) { + String urlString = protocol + ":///test/somefile"; + try { + new URL(urlString).openConnection(); + } catch(RuntimeException r) { + throw r; + } catch(Throwable t) { + // possible jrt initialization issue on exploded binary image etc. + System.out.println("encountered: " + t + + "(testing: " + urlString + ")"); + } + System.out.println("Default URLStreamHandler used for " + urlString); + } + } +} diff --git a/src/test/jdk/java/net/httpclient/ByteArrayPublishers.java b/src/test/jdk/java/net/httpclient/ByteArrayPublishers.java new file mode 100644 index 00000000000..2ac62f2e530 --- /dev/null +++ b/src/test/jdk/java/net/httpclient/ByteArrayPublishers.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8222968 + * @summary ByteArrayPublisher is not thread-safe resulting in broken re-use of HttpRequests + * @run main/othervm ByteArrayPublishers + */ + +import java.net.InetAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.ArrayList; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.CompletableFuture; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; +import static java.net.http.HttpRequest.BodyPublisher; +import static java.net.http.HttpRequest.BodyPublishers; + +public class ByteArrayPublishers { + private static final BodyPublisher BODY_PUBLISHER = + BodyPublishers.ofByteArray("abcdefghijklmnopqrstuvwxyz".getBytes()); + + static int LOOPS = 100; + + public static void main(String[] args) throws Exception { + HttpServer server = null; + try { + InetAddress loopBack = InetAddress.getLoopbackAddress(); + String lpBackStr = loopBack.getHostAddress(); + InetSocketAddress serverAddr = new InetSocketAddress(loopBack, 0); + server = HttpServer.create(serverAddr, 500); + server.createContext("/", (HttpExchange e) -> { + e.getRequestBody().readAllBytes(); + String response = "Hello world"; + e.sendResponseHeaders(200, response.length()); + e.getResponseBody().write(response.getBytes(StandardCharsets.ISO_8859_1)); + e.close(); + }); + server.start(); + var address = server.getAddress(); + URI dest = new URI("http://" + lpBackStr + ":" + + Integer.toString(address.getPort()) + "/"); + + HttpClient client = createClient(); + + ArrayList<CompletableFuture<HttpResponse<Void>>> futures = new ArrayList<>(LOOPS); + LinkedBlockingQueue<Object> results = new LinkedBlockingQueue<Object>(); + for (int i=0;i<LOOPS;i++) { + futures.add( + client.sendAsync(createRequest(dest), HttpResponse.BodyHandlers.discarding()) + .handle((v, t) -> { + if (t != null) + results.add(t); + else + results.add(v); + return null; + })); + } + + for (int i=0; i<LOOPS; i++) { + Object o = results.take(); + if (o instanceof Exception) { + throw new RuntimeException((Exception)o); + } + } + } finally { + server.stop(1); + } + } + + private static HttpRequest createRequest(URI uri) throws URISyntaxException { + HttpRequest.Builder builder = HttpRequest.newBuilder(uri) + .method("POST", BODY_PUBLISHER) + .version(HttpClient.Version.HTTP_1_1); + builder.header("content-type", "text/plain"); + return builder.build(); + } + + private static HttpClient createClient() { + return HttpClient.newBuilder() + .version(HttpClient.Version.HTTP_1_1) + .build(); + + } +} diff --git a/src/test/jdk/java/net/httpclient/UnknownBodyLengthTest.java b/src/test/jdk/java/net/httpclient/UnknownBodyLengthTest.java index 8962024d24b..cd2ebe8f3d4 100644 --- a/src/test/jdk/java/net/httpclient/UnknownBodyLengthTest.java +++ b/src/test/jdk/java/net/httpclient/UnknownBodyLengthTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -35,6 +35,9 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + import jdk.testlibrary.SimpleSSLContext; /** @@ -42,10 +45,14 @@ * @bug 8207966 * @library /lib/testlibrary * @build jdk.testlibrary.SimpleSSLContext - * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain false - * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL false - * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain true - * @run main/othervm -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL true + * @run main/othervm -Djdk.httpclient.enableAllMethodRetry + * -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain false + * @run main/othervm -Djdk.httpclient.enableAllMethodRetry + * -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL false + * @run main/othervm -Djdk.httpclient.enableAllMethodRetry + * -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest plain true + * @run main/othervm -Djdk.httpclient.enableAllMethodRetry + * -Djdk.tls.acknowledgeCloseNotify=true UnknownBodyLengthTest SSL true */ public class UnknownBodyLengthTest { @@ -56,6 +63,7 @@ public class UnknownBodyLengthTest { volatile String clientURL; volatile int port; final ServerSocket ss; + final List<Socket> acceptedList = new CopyOnWriteArrayList<>(); UnknownBodyLengthTest(boolean useSSL) throws Exception { ctx = new SimpleSSLContext().get(); @@ -84,46 +92,64 @@ static void checkBuf(byte[] buf) { throw new RuntimeException("error at position " + i); } + volatile boolean stopped; + void server(final boolean withContentLength) { fillBuf(BUF); try { - Socket s = ss.accept(); - s.setTcpNoDelay(true); - s.setSoLinger(true, 1); - System.out.println("Accepted: "+s.getRemoteSocketAddress()); - System.out.println("Accepted: "+s); - OutputStream os = s.getOutputStream(); - InputStream is = s.getInputStream(); - boolean done = false; - byte[] buf = new byte[1024]; - String rsp = ""; - while (!done) { - int c = is.read(buf); - if (c < 0) break; - String s1 = new String(buf, 0, c, "ISO-8859-1"); - rsp += s1; - done = rsp.endsWith("!#!#"); + while (!stopped) { + try { + Socket s = ss.accept(); + acceptedList.add(s); + s.setTcpNoDelay(true); + // if we use linger=1 we still see some + // intermittent failures caused by IOException + // "Connection reset by peer". + // The client side is expecting EOF, but gets reset instead. + // 30 is a 'magic' value that may need to be adjusted again. + s.setSoLinger(true, 30); + System.out.println("Accepted: " + s.getRemoteSocketAddress()); + System.out.println("Accepted: " + s); + OutputStream os = s.getOutputStream(); + InputStream is = s.getInputStream(); + boolean done = false; + byte[] buf = new byte[1024]; + String rsp = ""; + while (!done) { + int c = is.read(buf); + if (c < 0) break; + String s1 = new String(buf, 0, c, "ISO-8859-1"); + rsp += s1; + done = rsp.endsWith("!#!#"); + } + String r = "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type:" + + " text/xml; charset=UTF-8\r\n"; + os.write(r.getBytes()); + String chdr = "Content-Length: " + Integer.toString(BUF.length) + + "\r\n"; + System.out.println(chdr); + if (withContentLength) + os.write(chdr.getBytes()); + os.write("\r\n".getBytes()); + os.write(BUF); + if (is.available() > 0) { + System.out.println("Draining input: " + s); + is.read(buf); + } + os.flush(); + s.shutdownOutput(); + System.out.println("Closed output: " + s); + } catch(Exception e) { + if (!stopped) { + System.out.println("Unexpected server exception: " + e); + e.printStackTrace(); + } + } } - String r = "HTTP/1.0 200 OK\r\nConnection: close\r\nContent-Type:" + - " text/xml; charset=UTF-8\r\n"; - os.write(r.getBytes()); - String chdr = "Content-Length: " + Integer.toString(BUF.length) + - "\r\n"; - System.out.println(chdr); - if(withContentLength) - os.write(chdr.getBytes()); - os.write("\r\n".getBytes()); - os.write(BUF); - if (is.available() > 0) - is.read(buf); - os.flush(); - os.close(); - s.shutdownOutput(); - s.close(); } catch(final Throwable t) { - t.printStackTrace(); + if (!stopped) t.printStackTrace(); } finally { - try {ss.close(); } catch (Exception e) {} + stop(); } } @@ -154,11 +180,23 @@ public static void main(final String[] args) throws Exception { boolean ssl = args[0].equals("SSL"); boolean fixedlen = args[1].equals("true"); UnknownBodyLengthTest test = new UnknownBodyLengthTest(ssl); - test.run(ssl, fixedlen); + try { + test.run(ssl, fixedlen); + } finally { + test.stop(); + } } public void run(boolean ssl, boolean fixedlen) throws Exception { new Thread(()->server(fixedlen)).start(); client(ssl); } + + public void stop() { + stopped = true; + try { ss.close(); } catch (Throwable t) { } + for (Socket s : acceptedList) { + try { s.close(); } catch (Throwable t) { } + } + } } diff --git a/src/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java b/src/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java new file mode 100644 index 00000000000..7abbf064b40 --- /dev/null +++ b/src/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8202252 + * @run testng CompletionHandlerRelease + * @summary Verify that reference to CompletionHandler is cleared after use + */ + +import java.io.Closeable; +import java.io.IOException; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import static java.net.StandardSocketOptions.*; +import java.nio.ByteBuffer; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.CompletionHandler; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class CompletionHandlerRelease { + @Test + public void testConnect() throws Exception { + try (Server server = new Server()) { + try (AsynchronousSocketChannel ch = + AsynchronousSocketChannel.open(GROUP)) { + CountDownLatch latch = new CountDownLatch(1); + Handler<Void,Object> handler = + new Handler<Void,Object>("connect", latch); + ReferenceQueue queue = new ReferenceQueue<WeakReference>(); + WeakReference<Object> ref = + new WeakReference<Object>(handler, queue); + + ch.connect(server.address(), null, handler); + + try { latch.await(); } catch (InterruptedException ignore) { } + + handler = null; + waitForRefToClear(ref, queue); + + server.accept().get().close(); + } + } + } + + @Test + public void testWrite() throws Exception { + try (Server server = new Server(); + AsynchronousSocketChannel ch = + AsynchronousSocketChannel.open(GROUP)) { + ch.connect(server.address()).get(); + + try (AsynchronousSocketChannel sc = server.accept().get()) { + ByteBuffer src = ByteBuffer.wrap("hello".getBytes("UTF-8")); + sc.setOption(SO_SNDBUF, src.remaining()); + + CountDownLatch latch = new CountDownLatch(1); + Handler<Integer,Object> handler = + new Handler<Integer,Object>("write", latch); + ReferenceQueue queue = new ReferenceQueue<WeakReference>(); + WeakReference<Object> ref = + new WeakReference<Object>(handler, queue); + + sc.write(src, null, handler); + + try { latch.await(); } catch (InterruptedException ignore) { } + + handler = null; + waitForRefToClear(ref, queue); + } + } + } + + @Test + public void testRead() throws Exception { + try (Server server = new Server(); + AsynchronousSocketChannel ch = + AsynchronousSocketChannel.open(GROUP)) { + ch.connect(server.address()).get(); + + try (AsynchronousSocketChannel sc = server.accept().get()) { + ByteBuffer src = ByteBuffer.wrap("hello".getBytes("UTF-8")); + sc.setOption(SO_SNDBUF, src.remaining()); + sc.write(src).get(); + + CountDownLatch latch = new CountDownLatch(1); + Handler<Integer,Object> handler = + new Handler<Integer,Object>("read", latch); + ReferenceQueue queue = new ReferenceQueue<WeakReference>(); + WeakReference<Object> ref = + new WeakReference<Object>(handler, queue); + + ByteBuffer dst = ByteBuffer.allocate(64); + ch.read(dst, null, handler); + + try { latch.await(); } catch (InterruptedException ignore) { } + + handler = null; + waitForRefToClear(ref, queue); + } + } + } + + private AsynchronousChannelGroup GROUP; + + @BeforeTest + void setup() throws IOException { + GROUP = AsynchronousChannelGroup.withFixedThreadPool(2, + Executors.defaultThreadFactory()); + } + + @AfterTest + void cleanup() throws IOException { + GROUP.shutdownNow(); + } + + class Server implements Closeable { + private final AsynchronousServerSocketChannel ssc; + private final InetSocketAddress address; + + Server() throws IOException { + this(0); + } + + Server(int recvBufSize) throws IOException { + ssc = AsynchronousServerSocketChannel.open(GROUP); + if (recvBufSize > 0) { + ssc.setOption(SO_RCVBUF, recvBufSize); + } + ssc.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), + 0)); + address = (InetSocketAddress)ssc.getLocalAddress(); + } + + InetSocketAddress address() { + return address; + } + + Future<AsynchronousSocketChannel> accept() throws IOException { + return ssc.accept(); + } + + public void close() throws IOException { + ssc.close(); + } + } + + static class Handler<V,A> implements CompletionHandler<V,A> { + private final String name; + private final CountDownLatch latch; + + Handler(String name, CountDownLatch latch) { + this.name = name; + this.latch = latch; + } + + public void completed(V result, A attachment) { + System.out.format("%s completed(%s, %s)%n", + name, result, attachment); + latch.countDown(); + } + + public void failed(Throwable exc, A attachment) { + System.out.format("%s failed(%s, %s)%n", + name, exc, attachment); + exc.printStackTrace(); + latch.countDown(); + } + } + + private void waitForRefToClear(Reference ref, ReferenceQueue queue) + throws InterruptedException { + Reference r; + while ((r = queue.remove(20)) == null) { + System.gc(); + } + assertEquals(r, ref); + assertNull(r.get()); + } +} diff --git a/src/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java b/src/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java index 67cdc2dce35..85d26609fb1 100644 --- a/src/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java +++ b/src/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 8199433 + * @bug 8199433 8208780 * @run testng SelectWithConsumer * @summary Unit test for Selector select(Consumer), select(Consumer,long) and * selectNow(Consumer) @@ -62,9 +62,19 @@ void testActionInvoked(SelectionKey key, int expectedOps) throws Exception { var interestOps = key.interestOps(); var notifiedOps = new AtomicInteger(); + if (expectedOps == 0) { + // ensure select(Consumer) does not block indefinitely + sel.wakeup(); + } else { + // ensure that the channel is ready for all expected operations + sel.select(); + while ((key.readyOps() & interestOps) != expectedOps) { + Thread.sleep(100); + sel.select(); + } + } + // select(Consumer) - if (expectedOps == 0) - sel.wakeup(); // ensure select does not block notifiedOps.set(0); int n = sel.select(k -> { assertTrue(Thread.currentThread() == callerThread); diff --git a/src/test/jdk/java/rmi/testlibrary/TestSocketFactory.java b/src/test/jdk/java/rmi/testlibrary/TestSocketFactory.java index 42a7146b0cc..ef44585a908 100644 --- a/src/test/jdk/java/rmi/testlibrary/TestSocketFactory.java +++ b/src/test/jdk/java/rmi/testlibrary/TestSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -92,7 +92,8 @@ public class TestSocketFactory extends RMISocketFactory static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; - public static final boolean DEBUG = false; + // True to enable logging of matches and replacements. + private static volatile boolean debugLogging = false; /** * Debugging output can be synchronized with logging of RMI actions. @@ -100,8 +101,8 @@ public class TestSocketFactory extends RMISocketFactory * @param format a printf format * @param args any args */ - private static void DEBUG(String format, Object... args) { - if (DEBUG) { + public static void DEBUG(String format, Object... args) { + if (debugLogging) { System.err.printf(format, args); } } @@ -116,6 +117,17 @@ public TestSocketFactory() { this.replaceBytes = EMPTY_BYTE_ARRAY; } + /** + * Set debug to true to generate logging output of matches and substitutions. + * @param debug {@code true} to generate logging output + * @return the previous value + */ + public static boolean setDebug(boolean debug) { + boolean oldDebug = debugLogging; + debugLogging = debug; + return oldDebug; + } + /** * Set the match and replacement bytes, with an empty trigger. * The match and replacements are propagated to all existing sockets. diff --git a/src/test/jdk/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java b/src/test/jdk/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java index 05be7b61f6f..dd39b6a629e 100644 --- a/src/test/jdk/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java +++ b/src/test/jdk/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4404702 + * @bug 4404702 8216528 * @summary When the RMI runtime (lazily) spawns system threads that could * outlive the application context in which they were (happened to be) * created, such threads should not inherit (thread local) data specific to @@ -106,7 +106,10 @@ public static void main(String[] args) { * context class loader-- by giving it a chance to pass away. */ Thread.sleep(2000); - System.gc(); + while (loaderRef.get() != null) { + System.gc(); + Thread.sleep(100); + } System.err.println( "waiting to be notified of loader being weakly reachable..."); diff --git a/src/test/jdk/java/security/Signature/SignatureGetInstance.java b/src/test/jdk/java/security/Signature/SignatureGetInstance.java new file mode 100644 index 00000000000..c246773f83a --- /dev/null +++ b/src/test/jdk/java/security/Signature/SignatureGetInstance.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8216039 + * @summary Ensure the BC provider-reselection workaround in Signature class + * functions correctly + * @modules java.base/sun.security.util + * @run main/othervm SignatureGetInstance + */ +import java.security.*; +import java.security.interfaces.*; +import java.security.spec.*; +import sun.security.util.SignatureUtil; + +public class SignatureGetInstance { + + private static final String SIGALG = "RSASSA-PSS"; + + public static void main(String[] args) throws Exception { + Provider testProvider = new TestProvider(); + // put test provider before SunRsaSign provider + Security.insertProviderAt(testProvider, 1); + //Security.addProvider(testProvider); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); + KeyPair kp = kpg.generateKeyPair(); + + MyPrivKey testPriv = new MyPrivKey(); + MyPubKey testPub = new MyPubKey(); + + testDblInit(testPriv, testPub, true, "TestProvider"); + testDblInit(kp.getPrivate(), kp.getPublic(), true, "SunRsaSign"); + testDblInit(testPriv, kp.getPublic(), false, null); + testDblInit(kp.getPrivate(), testPub, false, null); + + testSetAndInit(null, testPriv, true); + testSetAndInit(null, testPub, true); + testSetAndInit(null, kp.getPrivate(), true); + testSetAndInit(null, kp.getPublic(), true); + + String provName = "SunRsaSign"; + testSetAndInit(provName, testPriv, false); + testSetAndInit(provName, testPub, false); + testSetAndInit(provName, kp.getPrivate(), true); + testSetAndInit(provName, kp.getPublic(), true); + + provName = "TestProvider"; + testSetAndInit(provName, testPriv, true); + testSetAndInit(provName, testPub, true); + testSetAndInit(provName, kp.getPrivate(), false); + testSetAndInit(provName, kp.getPublic(), false); + + System.out.println("Test Passed"); + } + + private static void checkName(Signature s, String name) { + if (name != null && + !(name.equals(s.getProvider().getName()))) { + throw new RuntimeException("Fail: provider name mismatch"); + } + } + + private static void testDblInit(PrivateKey key1, PublicKey key2, + boolean shouldPass, String expectedProvName) throws Exception { + Signature sig = Signature.getInstance(SIGALG); + SignatureUtil.initSignWithParam(sig, key1, PSSParameterSpec.DEFAULT, null); + try { + sig.initVerify(key2); + if (!shouldPass) { + throw new RuntimeException("Fail: should throw InvalidKeyException"); + } + checkName(sig, expectedProvName); + } catch (InvalidKeyException ike) { + if (shouldPass) { + System.out.println("Fail: Unexpected InvalidKeyException"); + throw ike; + } + } + } + + private static void testSetAndInit(String provName, Key key, + boolean shouldPass) throws Exception { + Signature sig; + if (provName == null) { + sig = Signature.getInstance(SIGALG); + } else { + sig = Signature.getInstance(SIGALG, provName); + } + AlgorithmParameterSpec params = PSSParameterSpec.DEFAULT; + boolean doSign = (key instanceof PrivateKey); + try { + if (doSign) { + SignatureUtil.initSignWithParam(sig, (PrivateKey)key, params, null); + } else { + SignatureUtil.initVerifyWithParam(sig, (PublicKey)key, params); + } + if (!shouldPass) { + throw new RuntimeException("Fail: should throw InvalidKeyException"); + } + checkName(sig, provName); + // check that the earlier parameter is still there + if (sig.getParameters() == null) { + throw new RuntimeException("Fail: parameters not preserved"); + } + } catch (InvalidKeyException ike) { + if (shouldPass) { + System.out.println("Fail: Unexpected InvalidKeyException"); + throw ike; + } + } + } + + // Test provider which only accepts its own Key objects + // Registered to be more preferred than SunRsaSign provider + // for testing deferred provider selection + public static class TestProvider extends Provider { + TestProvider() { + super("TestProvider", "1.0", "provider for SignatureGetInstance"); + put("Signature.RSASSA-PSS", + "SignatureGetInstance$MySigImpl"); + } + } + + public static class MyPrivKey implements PrivateKey { + public String getAlgorithm() { return "RSASSA-PSS"; } + public String getFormat() { return "MyOwn"; } + public byte[] getEncoded() { return null; } + } + + public static class MyPubKey implements PublicKey { + public String getAlgorithm() { return "RSASSA-PSS"; } + public String getFormat() { return "MyOwn"; } + public byte[] getEncoded() { return null; } + } + + public static class MySigImpl extends SignatureSpi { + // simulate BC behavior of only using params set before init calls + AlgorithmParameterSpec initParamSpec = null; + AlgorithmParameterSpec paramSpec = null; + + public MySigImpl() { + super(); + } + + @Override + protected void engineInitVerify(PublicKey publicKey) + throws InvalidKeyException { + if (!(publicKey instanceof MyPubKey)) { + throw new InvalidKeyException("Must be MyPubKey"); + } + initParamSpec = paramSpec; + } + + @Override + protected void engineInitSign(PrivateKey privateKey) + throws InvalidKeyException { + if (!(privateKey instanceof MyPrivKey)) { + throw new InvalidKeyException("Must be MyPrivKey"); + } + initParamSpec = paramSpec; + } + + @Override + protected void engineUpdate(byte b) throws SignatureException { + } + + @Override + protected void engineUpdate(byte[] b, int off, int len) + throws SignatureException { + } + + @Override + protected byte[] engineSign() + throws SignatureException { + return new byte[0]; + } + + @Override + protected boolean engineVerify(byte[] sigBytes) + throws SignatureException { + return false; + } + + @Override + @Deprecated + protected void engineSetParameter(String param, Object value) + throws InvalidParameterException { + } + + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + paramSpec = params; + } + + @Override + @Deprecated + protected AlgorithmParameters engineGetParameter(String param) + throws InvalidParameterException { + return null; + } + + @Override + protected AlgorithmParameters engineGetParameters() { + if (initParamSpec != null) { + try { + AlgorithmParameters ap = + AlgorithmParameters.getInstance("RSASSA-PSS"); + ap.init(initParamSpec); + return ap; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return null; + } + } +} diff --git a/src/test/jdk/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java b/src/test/jdk/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java index 87d8524f652..ec238cb40c9 100644 --- a/src/test/jdk/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java +++ b/src/test/jdk/java/security/cert/CertPathBuilder/selfIssued/KeyUsageMatters.java @@ -29,13 +29,13 @@ /** * @test - * @bug 6852744 + * @bug 6852744 8133489 * @summary PIT b61: PKI test suite fails because self signed certificates * are being rejected * @modules java.base/sun.security.util - * @run main/othervm KeyUsageMatters subca - * @run main/othervm KeyUsageMatters subci - * @run main/othervm KeyUsageMatters alice + * @run main/othervm -Djava.security.debug=certpath KeyUsageMatters subca + * @run main/othervm -Djava.security.debug=certpath KeyUsageMatters subci + * @run main/othervm -Djava.security.debug=certpath KeyUsageMatters alice * @author Xuelei Fan */ diff --git a/src/test/jdk/java/security/testlibrary/Proc.java b/src/test/jdk/java/security/testlibrary/Proc.java index abbc86a33be..cff7e790e7e 100644 --- a/src/test/jdk/java/security/testlibrary/Proc.java +++ b/src/test/jdk/java/security/testlibrary/Proc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -110,6 +113,7 @@ public class Proc { private List<String> args = new ArrayList<>(); private Map<String,String> env = new HashMap<>(); private Map<String,String> prop = new HashMap(); + private Map<String,String> secprop = new HashMap(); private boolean inheritIO = false; private boolean noDump = false; @@ -176,6 +180,11 @@ public Proc prop(String a, String b) { prop.put(a, b); return this; } + // Specifies a security property. Can be called multiple times. + public Proc secprop(String a, String b) { + secprop.put(a, b); + return this; + } // Inherit the value of a system property public Proc inheritProp(String k) { String v = System.getProperty(k); @@ -282,6 +291,17 @@ public Proc start() throws IOException { cmd.add(cp.stream().collect(Collectors.joining(File.pathSeparator))); } + if (!secprop.isEmpty()) { + Path p = Path.of(getId("security")); + try (OutputStream fos = Files.newOutputStream(p); + PrintStream ps = new PrintStream(fos)) { + secprop.forEach((k,v) -> ps.println(k + "=" + v)); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + prop.put("java.security.properties", p.toString()); + } + for (Entry<String,String> e: prop.entrySet()) { cmd.add("-D" + e.getKey() + "=" + e.getValue()); } @@ -380,6 +400,12 @@ public int waitFor() throws Exception { } return p.waitFor(); } + // Wait for process end with expected exit code + public void waitFor(int expected) throws Exception { + if (p.waitFor() != expected) { + throw new RuntimeException("Exit code not " + expected); + } + } // The following methods are used inside a proc diff --git a/src/test/jdk/java/text/Format/NumberFormat/TestPeruCurrencyFormat.java b/src/test/jdk/java/text/Format/NumberFormat/TestPeruCurrencyFormat.java new file mode 100644 index 00000000000..246208b7aaf --- /dev/null +++ b/src/test/jdk/java/text/Format/NumberFormat/TestPeruCurrencyFormat.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8206879 + * @summary Currency decimal marker incorrect for Peru. + * @modules jdk.localedata + * @run main/othervm -Djava.locale.providers=JRE TestPeruCurrencyFormat + */ + +import java.text.NumberFormat; +import java.util.Locale; + +public class TestPeruCurrencyFormat { + + public static void main(String[] args) { + final String expected = "S/.1,234.56"; + NumberFormat currencyFmt = + NumberFormat.getCurrencyInstance(new Locale("es", "PE")); + String s = currencyFmt.format(1234.56); + + if (!s.equals(expected)) { + throw new RuntimeException("Currency format for Peru failed, expected " + expected + ", got " + s); + } + } +} diff --git a/src/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java b/src/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java index cdeaa3e1352..8f990c1af5b 100644 --- a/src/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java +++ b/src/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java @@ -191,7 +191,7 @@ public void test_lenientEraYear(Chronology chrono, String lenient, String strict String mdStr = "-01-01"; DateTimeFormatter dtf = new DateTimeFormatterBuilder() .appendPattern("GGGG y-M-d") - .toFormatter() + .toFormatter(Locale.ROOT) .withChronology(chrono); DateTimeFormatter dtfLenient = dtf.withResolverStyle(ResolverStyle.LENIENT); assertEquals(LocalDate.parse(lenient+mdStr, dtfLenient), LocalDate.parse(strict+mdStr, dtf)); diff --git a/src/test/jdk/java/time/test/java/time/zone/TestZoneRules.java b/src/test/jdk/java/time/test/java/time/zone/TestZoneRules.java new file mode 100644 index 00000000000..e2adfaabf5d --- /dev/null +++ b/src/test/jdk/java/time/test/java/time/zone/TestZoneRules.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.java.time.zone; + +import static org.testng.Assert.assertEquals; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZonedDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.zone.ZoneOffsetTransition; +import java.time.zone.ZoneRules; + +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @summary Test ZoneRules whether the savings are positive in time zones that have + * negative savings in the source TZ files. Also, check the transition cutover + * time beyond 24:00, which should translate into the next day. + * + * @bug 8212970 + */ +@Test +public class TestZoneRules { + + private static final ZoneId DUBLIN = ZoneId.of("Europe/Dublin"); + private static final ZoneId PRAGUE = ZoneId.of("Europe/Prague"); + private static final ZoneId WINDHOEK = ZoneId.of("Africa/Windhoek"); + private static final ZoneId CASABLANCA = ZoneId.of("Africa/Casablanca"); + + private static final ZoneId TOKYO = ZoneId.of("Asia/Tokyo"); + private static final LocalTime ONE_AM = LocalTime.of(1, 0); + + @DataProvider + private Object[][] negativeDST () { + return new Object[][] { + // ZoneId, localDate, offset, standard offset, isDaylightSavings + // Europe/Dublin for the Rule "Eire" + {DUBLIN, LocalDate.of(1970, 6, 23), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {DUBLIN, LocalDate.of(1971, 6, 23), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {DUBLIN, LocalDate.of(1971, 11, 1), ZoneOffset.ofHours(0), ZoneOffset.ofHours(0), false}, + {DUBLIN, LocalDate.of(2019, 6, 23), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {DUBLIN, LocalDate.of(2019, 12, 23), ZoneOffset.ofHours(0), ZoneOffset.ofHours(0), false}, + + // Europe/Prague which contains fixed negative savings (not a named Rule) + {PRAGUE, LocalDate.of(1946, 9, 30), ZoneOffset.ofHours(2), ZoneOffset.ofHours(1), true}, + {PRAGUE, LocalDate.of(1946, 10, 10), ZoneOffset.ofHours(1), ZoneOffset.ofHours(1), false}, + {PRAGUE, LocalDate.of(1946, 12, 3), ZoneOffset.ofHours(0), ZoneOffset.ofHours(0), false}, + {PRAGUE, LocalDate.of(1947, 2, 25), ZoneOffset.ofHours(1), ZoneOffset.ofHours(1), false}, + {PRAGUE, LocalDate.of(1947, 4, 30), ZoneOffset.ofHours(2), ZoneOffset.ofHours(1), true}, + + // Africa/Windhoek for the Rule "Namibia" + {WINDHOEK, LocalDate.of(1994, 3, 23), ZoneOffset.ofHours(1), ZoneOffset.ofHours(1), false}, + {WINDHOEK, LocalDate.of(2016, 9, 23), ZoneOffset.ofHours(2), ZoneOffset.ofHours(1), true}, + + // Africa/Casablanca for the Rule "Morocco" Defines negative DST till 2037 as of 2019a. + {CASABLANCA, LocalDate.of(1939, 9, 13), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {CASABLANCA, LocalDate.of(1939, 11, 20), ZoneOffset.ofHours(0), ZoneOffset.ofHours(0), false}, + {CASABLANCA, LocalDate.of(2018, 6, 18), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {CASABLANCA, LocalDate.of(2019, 1, 1), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {CASABLANCA, LocalDate.of(2019, 5, 6), ZoneOffset.ofHours(0), ZoneOffset.ofHours(0), false}, + {CASABLANCA, LocalDate.of(2037, 10, 5), ZoneOffset.ofHours(0), ZoneOffset.ofHours(0), false}, + {CASABLANCA, LocalDate.of(2037, 11, 16), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + {CASABLANCA, LocalDate.of(2038, 11, 1), ZoneOffset.ofHours(1), ZoneOffset.ofHours(0), true}, + }; + } + + @DataProvider + private Object[][] transitionBeyondDay() { + return new Object[][] { + // ZoneId, LocalDateTime, beforeOffset, afterOffset + + // Asserts that the rule: + // Rule Japan 1948 1951 - Sep Sat>=8 25:00 0 S + // translates to the next day. + {TOKYO, LocalDateTime.of(LocalDate.of(1948, 9, 12), ONE_AM), ZoneOffset.ofHours(10), ZoneOffset.ofHours(9)}, + {TOKYO, LocalDateTime.of(LocalDate.of(1949, 9, 11), ONE_AM), ZoneOffset.ofHours(10), ZoneOffset.ofHours(9)}, + {TOKYO, LocalDateTime.of(LocalDate.of(1950, 9, 10), ONE_AM), ZoneOffset.ofHours(10), ZoneOffset.ofHours(9)}, + {TOKYO, LocalDateTime.of(LocalDate.of(1951, 9, 9), ONE_AM), ZoneOffset.ofHours(10), ZoneOffset.ofHours(9)}, + }; + } + + @Test(dataProvider="negativeDST") + public void test_NegativeDST(ZoneId zid, LocalDate ld, ZoneOffset offset, ZoneOffset stdOffset, boolean isDST) { + Instant i = Instant.from(ZonedDateTime.of(ld, LocalTime.MIN, zid)); + ZoneRules zr = zid.getRules(); + assertEquals(zr.getOffset(i), offset); + assertEquals(zr.getStandardOffset(i), stdOffset); + assertEquals(zr.isDaylightSavings(i), isDST); + } + + @Test(dataProvider="transitionBeyondDay") + public void test_TransitionBeyondDay(ZoneId zid, LocalDateTime ldt, ZoneOffset before, ZoneOffset after) { + ZoneOffsetTransition zot = ZoneOffsetTransition.of(ldt, before, after); + ZoneRules zr = zid.getRules(); + assertTrue(zr.getTransitions().contains(zot)); + } +} diff --git a/src/test/jdk/java/util/Collections/NCopies.java b/src/test/jdk/java/util/Collections/NCopies.java index 4d054113d5a..e415127f006 100644 --- a/src/test/jdk/java/util/Collections/NCopies.java +++ b/src/test/jdk/java/util/Collections/NCopies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, 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 @@ -28,8 +28,11 @@ * @author Martin Buchholz */ +import java.util.ArrayList; import java.util.Collections; +import java.util.AbstractList; import java.util.List; +import java.util.Objects; public class NCopies { static volatile int passed = 0, failed = 0; @@ -82,6 +85,56 @@ private static void checkFoos(List<String> x) { checkEmpty(x.subList(x.size()/2, x.size()/2)); } + private static <T> List<T> referenceNCopies(int n, T o) { + // A simplest correct implementation of nCopies to compare with the actual optimized implementation + return new AbstractList<>() { + public int size() { return n; } + + public T get(int index) { + Objects.checkIndex(index, n); + return o; + } + }; + } + + private static void checkHashCode() { + int[] sizes = {0, 1, 2, 3, 5, 10, 31, 32, 100, 1000}; + String[] elements = {null, "non-null"}; + for (int size : sizes) { + for (String element : elements) { + int expectedHashCode = referenceNCopies(size, element).hashCode(); + int actualHashCode = Collections.nCopies(size, element).hashCode(); + check(expectedHashCode == actualHashCode, + "Collections.nCopies(" + size + ", " + element + ").hashCode()"); + } + } + } + + private static void checkEquals() { + int[][] sizePairs = {{0, 0}, {0, 1}, {1, 0}, {1, 1}, {1, 2}, {2, 1}}; + String[] elements = {null, "non-null"}; + for (int[] pair : sizePairs) { + for (String element : elements) { + boolean equal = pair[0] == pair[1]; + String msg = "[" + pair[0] + ", " + element + "] <=> [" + pair[1] + ", " + element + "]"; + check(equal == Collections.nCopies(pair[0], element).equals(Collections.nCopies(pair[1], element)), msg); + check(equal == Collections.nCopies(pair[0], element).equals(referenceNCopies(pair[1], element)), msg); + check(equal == referenceNCopies(pair[0], element).equals(Collections.nCopies(pair[1], element)), msg); + } + } + List<String> nulls = Collections.nCopies(10, null); + List<String> nonNulls = Collections.nCopies(10, "non-null"); + List<String> nullsButOne = new ArrayList<>(nulls); + nullsButOne.set(9, "non-null"); + List<String> nonNullsButOne = new ArrayList<>(nonNulls); + nonNullsButOne.set(9, null); + check(!nulls.equals(nonNulls)); + check(!nulls.equals(nullsButOne)); + check(!nulls.equals(nonNullsButOne)); + check(!nonNulls.equals(nonNullsButOne)); + check(Collections.nCopies(0, null).equals(Collections.nCopies(0, "non-null"))); + } + public static void main(String[] args) { try { List<String> empty = Collections.nCopies(0, "foo"); @@ -92,6 +145,10 @@ public static void main(String[] args) { check(foos.size() == 42); checkFoos(foos.subList(foos.size()/2, foos.size()-1)); + checkHashCode(); + + checkEquals(); + } catch (Throwable t) { unexpected(t); } System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); diff --git a/src/test/jdk/java/util/Locale/Bug8040211.java b/src/test/jdk/java/util/Locale/Bug8040211.java index a131dfd65e8..4a7a099b2d1 100644 --- a/src/test/jdk/java/util/Locale/Bug8040211.java +++ b/src/test/jdk/java/util/Locale/Bug8040211.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,9 @@ /* * @test - * @bug 8040211 8191404 8203872 + * @bug 8040211 8191404 8203872 8222980 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2018-04-23) with Locale and Locale.LanguageRange + * (LSR Revision: 2019-04-03) with Locale and Locale.LanguageRange * class methods. * @run main Bug8040211 */ @@ -115,7 +115,6 @@ private static void test_parse() { expected.add(new LanguageRange("taj", 0.9)); expected.add(new LanguageRange("tsf", 0.9)); expected.add(new LanguageRange("ar-hyw", 0.8)); - expected.add(new LanguageRange("ar-arevmda", 0.8)); expected.add(new LanguageRange("yug", 0.5)); expected.add(new LanguageRange("yuu", 0.5)); expected.add(new LanguageRange("gfx", 0.4)); @@ -188,7 +187,7 @@ private static void test_filter() { List<Locale> tagList = generateLocales(tags); String actualLocales = showLocales(Locale.filter(priorityList, tagList, mode)); - String expectedLocales = "mtm-RU, ymt-RU, en-GB-oxendict, nts, pij, ar-arevela"; + String expectedLocales = "mtm-RU, ymt-RU, en-GB-oxendict, nts, pij"; if (!expectedLocales.equals(actualLocales)) { error = true; diff --git a/src/test/jdk/java/util/Locale/LocaleProviders.java b/src/test/jdk/java/util/Locale/LocaleProviders.java index 230d11c320c..c1558930b4d 100644 --- a/src/test/jdk/java/util/Locale/LocaleProviders.java +++ b/src/test/jdk/java/util/Locale/LocaleProviders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -72,6 +72,10 @@ public static void main(String[] args) { bug8027289Test(args[1]); break; + case "bug8220227Test": + bug8220227Test(); + break; + default: throw new RuntimeException("Test method '"+methodName+"' not found."); } @@ -245,4 +249,15 @@ static void bug8027289Test(String expectedCodePoint) { throw new RuntimeException("Unexpected Chinese currency symbol. returned: " + formatted + ", expected: " + expectedSymbol[0]); } } + + static void bug8220227Test() { + if (System.getProperty("os.name").startsWith("Windows")) { + Locale l = new Locale("xx","XX"); + String country = l.getDisplayCountry(); + if (country.endsWith("(XX)")) { + throw new RuntimeException( + "Unexpected Region name: " + country); + } + } + } } diff --git a/src/test/jdk/java/util/Locale/LocaleProviders.sh b/src/test/jdk/java/util/Locale/LocaleProviders.sh index cb8a7c6b9fd..652dadf0d81 100644 --- a/src/test/jdk/java/util/Locale/LocaleProviders.sh +++ b/src/test/jdk/java/util/Locale/LocaleProviders.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ # @test # @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577 # 8010666 8013086 8013233 8013903 8015960 8028771 8054482 8062006 -# 8150432 +# 8150432 8220227 # @summary tests for "java.locale.providers" system property # @modules java.base/sun.util.locale # java.base/sun.util.locale.provider @@ -367,4 +367,15 @@ if [ "${DEFFMTLANG}" = "zh" ] && [ "${DEFFMTCTRY}" = "CN" ]; then runTest fi +# testing 8220227 fix. (Windows only) +if [ "${DEFFMTLANG}" != "en" ]; then + METHODNAME=bug8220227Test + PREFLIST=HOST + PARAM1= + PARAM2= + PARAM3= + SPICLASSES= + runTest +fi + exit $result diff --git a/src/test/jdk/java/util/Properties/CompatibilityTest.java b/src/test/jdk/java/util/Properties/CompatibilityTest.java deleted file mode 100644 index 46d8a10c92c..00000000000 --- a/src/test/jdk/java/util/Properties/CompatibilityTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8005280 8004371 - * @summary Compatibility test - */ - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * This is a behavior compatibility test. - * Although not defined by the properties.dtd, the constructs - * in Compatibility.xml are supported by the regular JDK XML - * Provider. - * - * @author: Joe Wang - */ -public class CompatibilityTest { - - public static void main(String[] args) { - testInternalDTD(); - } - - /* - * Not in the spec, but the constructs work with the current JDK - */ - static void testInternalDTD() { - String src = System.getProperty("test.src"); - if (src == null) { - src = "."; - } - loadPropertyFile(src + "/Compatibility.xml"); - } - - /* - * 'Store' the populated 'Property' with the specified 'Encoding Type' as an - * XML file. Retrieve the same XML file and 'load' onto a new 'Property' object. - */ - static void loadPropertyFile(String filename) { - try (InputStream in = new FileInputStream(filename)) { - Properties prop = new Properties(); - prop.loadFromXML(in); - verifyProperites(prop); - } catch (IOException ex) { - fail(ex.getMessage()); - } - } - - /* - * This method verifies the first key-value with the original string. - */ - static void verifyProperites(Properties prop) { - try { - for (String key : prop.stringPropertyNames()) { - String val = prop.getProperty(key); - if (key.equals("Key1")) { - if (!val.equals("value1")) { - fail("Key:" + key + "'s value: \nExpected: value1\nFound: " + val); - } - } else if (key.equals("Key2")) { - if (!val.equals("<value2>")) { - fail("Key:" + key + "'s value: \nExpected: <value2>\nFound: " + val); - } - } else if (key.equals("Key3")) { - if (!val.equals("value3")) { - fail("Key:" + key + "'s value: \nExpected: value3\nFound: " + val); - } - } - } - } catch (Exception e) { - fail(e.getMessage()); - } - - } - - static void fail(String err) { - throw new RuntimeException(err); - } - -} diff --git a/src/test/jdk/java/util/Properties/invalidxml/IllegalElement.xml b/src/test/jdk/java/util/Properties/invalidxml/IllegalElement.xml new file mode 100644 index 00000000000..e09d4d2ab9d --- /dev/null +++ b/src/test/jdk/java/util/Properties/invalidxml/IllegalElement.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf8" standalone="no"?> +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> + +<!-- The dtd requires a properties root, but not element --> + +<properties> +<comment>comment</comment> + <properties> + <entry key="firstKey">value of the first key</entry> + </properties> +</properties> diff --git a/src/test/jdk/java/util/Properties/Compatibility.xml b/src/test/jdk/java/util/Properties/invalidxml/invalidDTD.xml similarity index 100% rename from src/test/jdk/java/util/Properties/Compatibility.xml rename to src/test/jdk/java/util/Properties/invalidxml/invalidDTD.xml diff --git a/src/test/jdk/java/util/ResourceBundle/Bug6299235Test.java b/src/test/jdk/java/util/ResourceBundle/Bug6299235/Bug6299235Test.java similarity index 84% rename from src/test/jdk/java/util/ResourceBundle/Bug6299235Test.java rename to src/test/jdk/java/util/ResourceBundle/Bug6299235/Bug6299235Test.java index ed42ee3a7e7..529c902ed92 100644 --- a/src/test/jdk/java/util/ResourceBundle/Bug6299235Test.java +++ b/src/test/jdk/java/util/ResourceBundle/Bug6299235/Bug6299235Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, 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 @@ -21,6 +21,17 @@ * questions. */ +/* + * @test + * @bug 6299235 8210408 + * @summary test Bug 6299235 to make sure the third-party provided sun resources + * could be picked up. + * @modules java.desktop + * @library patches + * @build java.desktop/sun.awt.resources.awt_ru_RU + * @run main Bug6299235Test + */ + import java.awt.Toolkit; import java.util.Locale; @@ -35,7 +46,7 @@ */ public class Bug6299235Test { - static final Locale ru_RU = new Locale("ru", "RU"); + private static final Locale ru_RU = new Locale("ru", "RU"); public static void main(String args[]) { Locale locale = Locale.getDefault(); diff --git a/src/test/jdk/java/util/ResourceBundle/Bug6299235/patches/java.desktop/sun/awt/resources/awt_ru_RU.java b/src/test/jdk/java/util/ResourceBundle/Bug6299235/patches/java.desktop/sun/awt/resources/awt_ru_RU.java new file mode 100644 index 00000000000..c32d7ef88c4 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/Bug6299235/patches/java.desktop/sun/awt/resources/awt_ru_RU.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.awt.resources; + +import java.util.ListResourceBundle; + +/** + * A faked sun.awt.resources.awt_ru_RU resource file. + */ +public class awt_ru_RU extends ListResourceBundle { + @Override + public Object[][] getContents() { + return new Object[][] { + { "foo", "bar" } + }; + } +} diff --git a/src/test/jdk/java/util/ResourceBundle/Bug6299235Test.sh b/src/test/jdk/java/util/ResourceBundle/Bug6299235Test.sh deleted file mode 100644 index 354093c4f4b..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/Bug6299235Test.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -# Copyright (c) 2007, 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. -# -# 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. -# -#!/bin/sh -# -# @test -# @bug 6299235 -# @summary test Bug 6299235 to make sure the third-party provided sun resources could be picked up. -# @modules java.desktop -# @build Bug6299235Test -# @run shell Bug6299235Test.sh - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin | AIX ) - PATHSEP=":" - FILESEP="/" - ;; - Windows* | CYGWIN* ) - PATHSEP=";" - FILESEP="\\" - ;; - * ) - echo "${OS} is unrecognized system!" - exit 1; - ;; -esac - -if [ -z "${TESTSRC}" ]; then - echo "TESTSRC undefined: defaulting to ." - TESTSRC=. -fi - -if [ -z "${TESTJAVA}" ]; then - echo "TESTJAVA undefined: can't continue." - exit 1 -fi - -echo "TESTJAVA=${TESTJAVA}" -echo "TESTSRC=${TESTSRC}" -echo "TESTCLASSES=${TESTCLASSES}" - -PATCHDIR=${TESTCLASSES}/patches -rm -rf $PATCHDIR -mkdir -p $PATCHDIR/java.desktop - -cd ${PATCHDIR}/java.desktop -${TESTJAVA}/bin/jar xf ${TESTSRC}/awtres.jar - -echo -${TESTJAVA}/bin/java ${TESTVMOPTS} --patch-module java.desktop=${PATCHDIR}/java.desktop \ - -cp ${TESTCLASSES} Bug6299235Test - -if [ $? -ne 0 ] - then - echo "Test fails: exception thrown!" - exit 1 -fi - -exit 0 diff --git a/src/test/jdk/java/util/ResourceBundle/Control/XmlRB.xml b/src/test/jdk/java/util/ResourceBundle/Control/XmlRB.xml index a96efe144c6..15a0a1534c9 100644 --- a/src/test/jdk/java/util/ResourceBundle/Control/XmlRB.xml +++ b/src/test/jdk/java/util/ResourceBundle/Control/XmlRB.xml @@ -2,15 +2,7 @@ <!----> -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Test data for XMLResourceBundleTest.java</comment> <entry key="type">XML</entry> diff --git a/src/test/jdk/java/util/ResourceBundle/Control/XmlRB_ja.xml b/src/test/jdk/java/util/ResourceBundle/Control/XmlRB_ja.xml index 2dc7dc5828c..91511d31336 100644 --- a/src/test/jdk/java/util/ResourceBundle/Control/XmlRB_ja.xml +++ b/src/test/jdk/java/util/ResourceBundle/Control/XmlRB_ja.xml @@ -2,15 +2,7 @@ <!----> -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Test data for XMLResourceBundleTest.java</comment> <entry key="type">XML</entry> diff --git a/src/test/jdk/java/util/ResourceBundle/awtres.jar b/src/test/jdk/java/util/ResourceBundle/awtres.jar deleted file mode 100644 index 4315634a03c..00000000000 Binary files a/src/test/jdk/java/util/ResourceBundle/awtres.jar and /dev/null differ diff --git a/src/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java b/src/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java new file mode 100644 index 00000000000..e00b732df4c --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Stream; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.process.ProcessTools; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; + +public class ModuleTestUtil { + + private ModuleTestUtil() { + // Private constructor to prevent class instantiation + } + + /** + * Compile all the java sources and copy the resource files in the module. + * + * @param src path to the source directory + * @param dest path to the destination directory + * @param mn module name + * @param resFormat resource format + */ + public static void prepareModule(Path src, Path dest, String mn, + String resFormat) { + compileModule(src, dest, mn); + copyResFiles(src, dest, mn, resFormat); + } + + /** + * Compile all the java sources in the module. + * + * @param src path to the source directory + * @param dest path to the destination directory + * @param mn module name + */ + public static void compileModule(Path src, Path dest, String mn) { + try { + boolean compiled = CompilerUtils.compile(src.resolve(mn), dest, + "--module-source-path", src.toString()); + if (!compiled) { + throw new RuntimeException("Compile module " + mn + " failed."); + } + } catch (IOException e) { + throw new RuntimeException("Compile module " + mn + " failed."); + } + } + + /** + * Compile all the java sources in the unnamed package. + * + * @param src path to the source directory + * @param dest path to the destination directory + * @param pn package name + */ + public static void compilePkg(Path src, Path dest, String pn) { + try { + boolean compiled = CompilerUtils.compile(src.resolve(pn), + dest.resolve(pn)); + if (!compiled) { + throw new RuntimeException("Compile package " + pn + " failed."); + } + } catch (IOException e) { + throw new RuntimeException("Compile package " + pn + " failed."); + } + } + + /** + * Copy all the resource files. + * + * @param src path to the source directory + * @param dest path to the destination directory + * @param mn module name + * @param resFormat resource format + */ + public static void copyResFiles(Path src, Path dest, String mn, + String resFormat) { + try (Stream<Path> stream = Files.walk(src.resolve(mn)) + .filter(path -> path.toString().endsWith(resFormat))) { + stream.forEach(f -> { + String resName = f.toString(); + String relativePath = resName.substring(src.toString().length()); + Path destFile = Paths.get(dest.toString() + relativePath); + try { + Path destParentDir = destFile.getParent(); + if (Files.notExists(destParentDir)) { + Files.createDirectories(destParentDir); + } + Files.copy(f, destFile, REPLACE_EXISTING); + } catch (IOException e) { + throw new RuntimeException("Copy " + f.toString() + " to " + + destFile.toString() + " failed."); + } + }); + } catch (IOException e) { + throw new RuntimeException("Copy resource files failed."); + } + } + + /** + * Run the module test. + * + * @param mp module path + * @param mn module name + * @param localeList locale list + */ + public static void runModule(String mp, String mn, List<String> localeList) + throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); + launcher.addToolArg("-p") + .addToolArg(mp) + .addToolArg("-m") + .addToolArg(mn); + localeList.forEach(launcher::addToolArg); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Execution of the test failed. " + + "Unexpected exit code: " + exitCode); + } + } + + /** + * Run the module test with a jar file specified by the classpath. + * + * @param cp classpath + * @param mp module path + * @param mn module name + * @param localeList locale list + * @param expected expected execution status + */ + public static void runModuleWithCp(String cp, String mp, String mn, + List<String> localeList, boolean expected) throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); + launcher.addToolArg("-cp") + .addToolArg(cp) + .addToolArg("-p") + .addToolArg(mp) + .addToolArg("-m") + .addToolArg(mn); + localeList.forEach(launcher::addToolArg); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (expected) { + if (exitCode != 0) { + throw new RuntimeException("Execution of the test loads bundles " + + "from the jar file specified by the class-path failed. " + + "Unexpected exit code: " + exitCode); + } + } else { + if (exitCode == 0) { + throw new RuntimeException("Execution of the test not loads bundles " + + "from the jar file specified by the class-path failed. " + + "Unexpected exit code: " + exitCode); + } + } + } +} \ No newline at end of file diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/appbasic.sh b/src/test/jdk/java/util/ResourceBundle/modules/appbasic/appbasic.sh deleted file mode 100644 index 634324be4e8..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/appbasic.sh +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8044767 -# @summary Basic test for ResourceBundle with modules; named module "test" -# contains resource bundles for root and en, and separate named modules -# "eubundles" and "asiabundles" contain other resource bundles. - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" - - -for I in eu asia -do - B=${I}bundles - mkdir -p mods/$B - CLASSES="`find $TESTSRC/src/$B -name '*.java'`" - if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src -cp mods/test $CLASSES - fi - PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" - if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$B/$D - cp $TESTSRC/src/$B/$P mods/$B/$D/ - done - fi -done - -mkdir -p mods/test -$JAVAC -g -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` - -$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de - -exit $? diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh b/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh deleted file mode 100644 index d6096833ebf..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/appbasic2.sh +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8044767 -# @summary Basic test for ResourceBundle with modules; named module "test" -# contains resource bundles for root and en, and separate named modules -# "eubundles" and "asiabundles" contain other resource bundles. - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" - - -for I in eu asia -do - B=${I}bundles - mkdir -p mods/$B - CLASSES="`find $TESTSRC/src/$B -name '*.java'`" - if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src -cp mods/test $CLASSES - fi - PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" - if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$B/$D - cp $TESTSRC/src/$B/$P mods/$B/$D/ - done - fi -done - -mkdir -p mods/test -$JAVAC -g -d mods --module-source-path $TESTSRC/src `find $TESTSRC/src/test -name "*.java"` - -$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de - -exit $? diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java new file mode 100644 index 00000000000..29c01a58092 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/BasicTest.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8044767 8139067 8210408 + * @summary Basic tests for ResourceBundle with modules: + * 1) Named module "test" contains resource bundles for root and en, + * and separate named modules "eubundles" and "asiabundles" contain + * other resource bundles. + * 2) ResourceBundle.getBundle caller is in named module "test", + * resource bundles are grouped in main (module "mainbundles"), + * EU (module "eubundles"), and Asia (module "asiabundles"). + * 3) ResourceBundle.getBundle caller is in named module "test" and all + * resource bundles are in single named module "bundles". + * 4) ResourceBundle.getBundle caller is in named module "test" and all + * resource bundles in xml format are in single named module "bundles". + * 5) Resource bundles in a local named module with no ResourceBundleProviders. + * @library /test/lib + * .. + * @build jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Utils + * jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.process.ProcessTools + * ModuleTestUtil + * @run testng BasicTest + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.Utils; +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.process.ProcessTools; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static jdk.test.lib.Asserts.assertEquals; +import static org.testng.Assert.assertTrue; + +@Test +public class BasicTest { + private static final String SRC_DIR_APPBASIC = "srcAppbasic"; + private static final String SRC_DIR_APPBASIC2 = "srcAppbasic2"; + private static final String SRC_DIR_BASIC = "srcBasic"; + private static final String SRC_DIR_SIMPLE = "srcSimple"; + private static final String SRC_DIR_XML = "srcXml"; + private static final String SRC_DIR_MODLOCAL = "srcModlocal"; + + private static final String MODS_DIR_APPBASIC = "modsAppbasic"; + private static final String MODS_DIR_APPBASIC2 = "modsAppbasic2"; + private static final String MODS_DIR_BASIC = "modsBasic"; + private static final String MODS_DIR_SIMPLE = "modsSimple"; + private static final String MODS_DIR_XML = "modsXml"; + private static final String MODS_DIR_MODLOCAL = "modsModlocal"; + + private static final String EXTRA_JAR_BASIC = "extra_basic.jar"; + private static final String EXTRA_JAR_MODLOCAL = "extra_modlocal.jar"; + + private static final List<String> LOCALE_LIST = List.of("de", "fr", "ja", + "zh-tw", "en", "de"); + private static final List<String> LOCALE_LIST_BASIC = List.of("de", "fr", + "ja", "ja-jp", "zh-tw", "en", "de", "ja-jp"); + + private static final List<String> MODULE_LIST = List.of("asiabundles", + "eubundles", "test"); + private static final List<String> MODULE_LIST_BASIC = List.of("mainbundles", + "asiabundles", "eubundles", "test"); + private static final List<String> MODULE_LIST_SIMPLE = List.of("bundles", "test"); + + private static final String MAIN = "test/jdk.test.Main"; + + @DataProvider(name = "basicTestData") + Object[][] basicTestData() { + return new Object[][] { + // Named module "test" contains resource bundles for root and en, + // and separate named modules "eubundles" and "asiabundles" + // contain other resource bundles. + {SRC_DIR_APPBASIC, MODS_DIR_APPBASIC, MODULE_LIST, LOCALE_LIST, + ".properties"}, + {SRC_DIR_APPBASIC2, MODS_DIR_APPBASIC2, MODULE_LIST, LOCALE_LIST, + ".properties"}, + + // Resource bundles are grouped in main (module "mainbundles"), + // EU (module "eubundles"), and Asia (module "asiabundles"). + {SRC_DIR_BASIC, MODS_DIR_BASIC, MODULE_LIST_BASIC, LOCALE_LIST_BASIC, + ".properties"}, + + // All resource bundles are in single named module "bundles". + {SRC_DIR_SIMPLE, MODS_DIR_SIMPLE, MODULE_LIST_SIMPLE, LOCALE_LIST, + ".properties"}, + + // All resource bundles in xml format are in single named + // module "bundles". + {SRC_DIR_XML, MODS_DIR_XML, MODULE_LIST_SIMPLE, LOCALE_LIST, ".xml"}, + + // Resource bundles local in named module "test". + {SRC_DIR_MODLOCAL, MODS_DIR_MODLOCAL, List.of("test"), LOCALE_LIST, + ".properties"}, + }; + } + + @Test(dataProvider = "basicTestData") + public void runBasicTest(String src, String mod, List<String> moduleList, + List<String> localeList, String resFormat) throws Throwable { + Path srcPath = Paths.get(Utils.TEST_SRC, src); + Path modPath = Paths.get(Utils.TEST_CLASSES, mod); + moduleList.forEach(mn -> ModuleTestUtil.prepareModule(srcPath, modPath, + mn, resFormat)); + ModuleTestUtil.runModule(modPath.toString(), MAIN, localeList); + } + + @Test + public void RunBasicTestWithCp() throws Throwable { + Path jarPath = Paths.get(Utils.TEST_CLASSES, EXTRA_JAR_BASIC); + Path srcPath = Paths.get(Utils.TEST_SRC, SRC_DIR_BASIC); + Path modPath = Paths.get(Utils.TEST_CLASSES, MODS_DIR_BASIC); + Path classPath = Paths.get(Utils.TEST_CLASSES).resolve("classes") + .resolve("basic"); + + jarBasic(srcPath, classPath, jarPath); + // jdk.test.Main should NOT load bundles from the jar file specified + // by the class-path. + ModuleTestUtil.runModuleWithCp(jarPath.toString(), modPath.toString(), + MAIN, List.of("es", "vi"), false); + } + + @Test + public void runModLocalTestWithCp() throws Throwable { + Path jarPath = Paths.get(Utils.TEST_CLASSES, EXTRA_JAR_MODLOCAL); + Path srcPath = Paths.get(Utils.TEST_SRC, SRC_DIR_MODLOCAL); + Path modPath = Paths.get(Utils.TEST_CLASSES, MODS_DIR_MODLOCAL); + + jarModLocal(srcPath, jarPath); + // jdk.test.Main should load bundles from the jar file specified by + // the class-path. + ModuleTestUtil.runModuleWithCp(jarPath.toString(), modPath.toString(), + MAIN, List.of("vi"), true); + } + + /** + * Create extra_basic.jar to be added to the class path. It contains .class + * and .properties resource bundles. + */ + private static void jarBasic(Path srcPath, Path classPath, Path jarPath) + throws Throwable { + boolean compiled = CompilerUtils.compile(srcPath.resolve("extra"), + classPath); + assertTrue(compiled, "Compile Java files for extra_basic.jar failed."); + + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jar"); + launcher.addToolArg("-cf") + .addToolArg(jarPath.toString()) + .addToolArg("-C") + .addToolArg(classPath.toString()) + .addToolArg("jdk/test/resources/eu") + .addToolArg("-C") + .addToolArg(srcPath.resolve("extra").toString()) + .addToolArg("jdk/test/resources/asia"); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + assertEquals(exitCode, 0, "Create extra_basic.jar failed. " + + "Unexpected exit code: " + exitCode); + } + + /** + * Create extra_modlocal.jar to be added to the class path. Expected + * properties files are picked up from the class path. + */ + private static void jarModLocal(Path srcPath, Path jarPath) throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jar"); + launcher.addToolArg("-cf") + .addToolArg(jarPath.toString()) + .addToolArg("-C") + .addToolArg(srcPath.resolve("extra").toString()) + .addToolArg("jdk/test/resources"); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + assertEquals(exitCode, 0, "Create extra_modlocal.jar failed. " + + "Unexpected exit code: " + exitCode); + } +} \ No newline at end of file diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/basic.sh b/src/test/jdk/java/util/ResourceBundle/modules/basic/basic.sh deleted file mode 100644 index 95f0c5bd0ad..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/basic/basic.sh +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8044767 8139067 -# @summary Basic test case for ResourceBundle with modules; -# ResourceBundle.getBundle caller is in module named "test", -# resource bundles are grouped in main (module "mainbundles"), -# EU (module "eubundles"), and Asia (module "asiabundles"). -# Also adds a jar file containing resource bundles to the class path. - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAR="$COMPILEJAVA/bin/jar" -JAVA="$TESTJAVA/bin/java" - -rm -rf mods - -CP= -for I in main eu asia -do - B=${I}bundles - mkdir -p mods/$B - CLASSES="`find $TESTSRC/src/$B -name '*.java'`" - if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src $CP $CLASSES - fi - PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" - if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$B/$D - cp $TESTSRC/src/$B/$P mods/$B/$D/ - done - fi - CP="-cp mods/mainbundles" -done - -mkdir -p mods/test -$JAVAC -g -cp mods/mainbundles -d mods --module-source-path $TESTSRC/src \ - `find $TESTSRC/src/test -name "*.java"` - -# Create a jar to be added to the class path. Expected only properties files are -# picked up from the class path. -rm -f extra.jar -mkdir -p classes -$JAVAC -d classes $TESTSRC/src/extra/jdk/test/resources/eu/*.java -$JAR -cf extra.jar -C classes jdk/test/resources/eu \ - -C $TESTSRC/src/extra jdk/test/resources/asia - -STATUS=0 - -echo "jdk.test.Main should load bundles using ResourceBundleProviders." -$JAVA -p mods -m test/jdk.test.Main de fr ja ja-jp zh-tw en de ja-jp || STATUS=1 - -echo "jdk.test.Main should NOT load bundles from the jar file specified by the class-path." -$JAVA -cp extra.jar -p mods -m test/jdk.test.Main es vi && STATUS=1 - -exit $STATUS diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResources_ja.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResources_ja.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResources_ja.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResources_ja.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResources_zh.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResources_zh.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResources_zh.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResources_zh.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/asiabundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/asiabundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/jdk/test/resources/eu/MyResourcesEU.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/jdk/test/resources/eu/MyResourcesEU.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/jdk/test/resources/eu/MyResources_de.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/jdk/test/resources/eu/MyResources_de.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/jdk/test/resources/eu/MyResources_de.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/jdk/test/resources/eu/MyResources_de.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/jdk/test/resources/eu/MyResources_fr.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/jdk/test/resources/eu/MyResources_fr.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/jdk/test/resources/eu/MyResources_fr.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/jdk/test/resources/eu/MyResources_fr.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/eubundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/eubundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/Main.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/Main.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/Main.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/MyResources.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/MyResources.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/MyResources.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/MyResources.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/MyResourcesProviderImpl.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/MyResourcesProviderImpl.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/MyResourcesProviderImpl.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/MyResourcesProviderImpl.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/MyResources_en.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/MyResources_en.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/MyResources_en.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/MyResources_en.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/spi/MyResourcesProvider.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/spi/MyResourcesProvider.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/jdk/test/resources/spi/MyResourcesProvider.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/jdk/test/resources/spi/MyResourcesProvider.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic/src/test/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic/test/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResources_ja.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResources_ja.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResources_ja.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResources_ja.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResources_zh.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResources_zh.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResources_zh.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResources_zh.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/asiabundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/asiabundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/jdk/test/resources/eu/MyResourcesEU.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/jdk/test/resources/eu/MyResourcesEU.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/jdk/test/resources/eu/MyResourcesEU.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/jdk/test/resources/eu/MyResourcesEU.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/jdk/test/resources/eu/MyResources_de.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/jdk/test/resources/eu/MyResources_de.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/jdk/test/resources/eu/MyResources_de.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/jdk/test/resources/eu/MyResources_de.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/jdk/test/resources/eu/MyResources_fr.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/jdk/test/resources/eu/MyResources_fr.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/jdk/test/resources/eu/MyResources_fr.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/jdk/test/resources/eu/MyResources_fr.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/eubundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/eubundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/Main.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/Main.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/Main.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/MyResources.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/MyResources.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/MyResources.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/MyResources.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/MyResourcesProviderImpl.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/MyResourcesProviderImpl.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/MyResourcesProviderImpl.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/MyResourcesProviderImpl.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/MyResources_en.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/MyResources_en.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/MyResources_en.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/MyResources_en.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/spi/MyResourcesProvider.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/spi/MyResourcesProvider.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/jdk/test/resources/spi/MyResourcesProvider.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/jdk/test/resources/spi/MyResourcesProvider.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/appbasic2/src/test/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcAppbasic2/test/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResourcesAsia.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_ja.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_ja.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_ja.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_ja.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_ja_JP.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_ja_JP.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_ja_JP.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_ja_JP.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_zh.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_zh.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_zh.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_zh.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/jdk/test/resources/asia/MyResources_zh_TW.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/asiabundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/asiabundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/jdk/test/resources/eu/MyResourcesEU.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/jdk/test/resources/eu/MyResourcesEU.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResourcesEU.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/jdk/test/resources/eu/MyResources_de.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_de.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/jdk/test/resources/eu/MyResources_de.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_de.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/jdk/test/resources/eu/MyResources_fr.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_fr.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/jdk/test/resources/eu/MyResources_fr.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/jdk/test/resources/eu/MyResources_fr.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/eubundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/eubundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/extra/jdk/test/resources/asia/MyResources_vi.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/extra/jdk/test/resources/asia/MyResources_vi.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/extra/jdk/test/resources/asia/MyResources_vi.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/extra/jdk/test/resources/asia/MyResources_vi.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/extra/jdk/test/resources/eu/MyResources_es.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/extra/jdk/test/resources/eu/MyResources_es.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/extra/jdk/test/resources/eu/MyResources_es.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/extra/jdk/test/resources/eu/MyResources_es.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/MyResources.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/MyResources.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/MyResources.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/MyResources.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/MyResourcesMain.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/MyResourcesMain.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/MyResourcesMain.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/MyResourcesMain.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/MyResources_en.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/MyResources_en.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/MyResources_en.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/MyResources_en.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/spi/MyResourcesProvider.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/spi/MyResourcesProvider.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/jdk/test/resources/spi/MyResourcesProvider.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/jdk/test/resources/spi/MyResourcesProvider.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/mainbundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/mainbundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/test/jdk/test/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/jdk/test/Main.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/test/jdk/test/Main.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/jdk/test/Main.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/src/test/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/basic/src/test/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcBasic/test/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/extra/jdk/test/resources/MyResources_vi.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/extra/jdk/test/resources/MyResources_vi.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/extra/jdk/test/resources/MyResources_vi.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/extra/jdk/test/resources/MyResources_vi.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/Main.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/Main.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/Main.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_de.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_de.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_de.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_de.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_en.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_en.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_en.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_en.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_fr.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_fr.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_fr.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_fr.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_ja.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_ja.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_ja.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_ja.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_zh.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_zh.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_zh.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_zh.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_zh_TW.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_zh_TW.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/jdk/test/resources/MyResources_zh_TW.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/jdk/test/resources/MyResources_zh_TW.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/modlocal/src/test/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcModlocal/test/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_de.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_de.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_de.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_de.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_en.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_en.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_en.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_en.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_fr.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_fr.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_fr.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_fr.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_ja.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_ja.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_ja.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_ja.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_zh.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_zh.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_zh.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_zh.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_zh_TW.properties b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_zh_TW.properties similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/MyResources_zh_TW.properties rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/MyResources_zh_TW.properties diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/spi/MyResourcesProvider.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/spi/MyResourcesProvider.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/jdk/test/resources/spi/MyResourcesProvider.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/jdk/test/resources/spi/MyResourcesProvider.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/bundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/bundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/test/jdk/test/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/test/jdk/test/Main.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/test/jdk/test/Main.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/test/jdk/test/Main.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/src/test/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/test/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/simple/src/test/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcSimple/test/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources.xml new file mode 100644 index 00000000000..5f8609ebcb4 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle</comment> + <entry key="key">root: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_de.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_de.xml new file mode 100644 index 00000000000..44e869f98f1 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_de.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle</comment> + <entry key="key">de: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_en.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_en.xml new file mode 100644 index 00000000000..9a828dab28a --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_en.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle</comment> + <entry key="key">en: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_fr.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_fr.xml new file mode 100644 index 00000000000..e7a5c40620d --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_fr.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle</comment> + <entry key="key">fr: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_ja.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_ja.xml new file mode 100644 index 00000000000..cf102c1c859 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_ja.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle in named modules.</comment> + <entry key="key">ja: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh.xml new file mode 100644 index 00000000000..fae6c5b126d --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle in named modules.</comment> + <entry key="key">zh: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh_TW.xml b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh_TW.xml new file mode 100644 index 00000000000..adc0d667233 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh_TW.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!----> + +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> +<properties> + <comment>Test data for ResourceBundle in named modules.</comment> + <entry key="key">zh-TW: message</entry> +</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/spi/MyResourcesProvider.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/spi/MyResourcesProvider.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/spi/MyResourcesProvider.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/spi/MyResourcesProvider.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/test/jdk/test/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/test/jdk/test/Main.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/test/jdk/test/Main.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/test/jdk/test/Main.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/test/module-info.java b/src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/test/module-info.java similarity index 100% rename from src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/test/module-info.java rename to src/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/test/module-info.java diff --git a/src/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java b/src/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java new file mode 100644 index 00000000000..7b9c828c44d --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8180375 8185251 8210408 + * @summary Tests resource bundles are correctly loaded from modules through + * "<packageName>.spi.<simpleName>Provider" types. + * @library /test/lib + * .. + * @build jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Utils + * jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.process.ProcessTools + * ModuleTestUtil + * @run main LayerTest + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; + +public class LayerTest { + private static final Path SRC_DIR = Paths.get(Utils.TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get(Utils.TEST_CLASSES, "mods"); + private static final List<String> MODULE_LIST = List.of("m1", "m2"); + + public static void main(String[] args) throws Throwable { + MODULE_LIST.forEach(mn -> ModuleTestUtil.prepareModule(SRC_DIR, + MODS_DIR, mn, ".properties")); + compileCmd(); + runCmd(); + } + + private static void compileCmd() throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("javac"); + launcher.addToolArg("-d") + .addToolArg(Utils.TEST_CLASSES) + .addToolArg(SRC_DIR.resolve("Main.java").toString()); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Compile of the test failed. " + + "Unexpected exit code: " + exitCode); + } + } + + private static void runCmd() throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); + launcher.addToolArg("-cp") + .addToolArg(Utils.TEST_CLASSES) + .addToolArg("Main") + .addToolArg(Utils.TEST_CLASSES); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Execution of the test failed. " + + "Unexpected exit code: " + exitCode); + } + } +} \ No newline at end of file diff --git a/src/test/jdk/java/util/ResourceBundle/modules/layer/src/Main.java b/src/test/jdk/java/util/ResourceBundle/modules/layer/src/Main.java index a0fb8c15305..3e78803c4a9 100644 --- a/src/test/jdk/java/util/ResourceBundle/modules/layer/src/Main.java +++ b/src/test/jdk/java/util/ResourceBundle/modules/layer/src/Main.java @@ -31,7 +31,7 @@ public class Main { public static void main(String... args) throws Exception { - ModuleFinder afterFinder = ModuleFinder.of(Paths.get("mods")); + ModuleFinder afterFinder = ModuleFinder.of(Paths.get(args[0], "mods")); Configuration cf = ModuleLayer.boot().configuration() .resolveAndBind(ModuleFinder.of(), afterFinder, diff --git a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/modlocal.sh b/src/test/jdk/java/util/ResourceBundle/modules/modlocal/modlocal.sh deleted file mode 100644 index bc75ee61c93..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/modlocal/modlocal.sh +++ /dev/null @@ -1,78 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8044767 8139067 -# @summary Test case for having resource bundles in a local named module -# with no ResourceBundleProviders. - - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAR="$COMPILEJAVA/bin/jar" -JAVA="$TESTJAVA/bin/java" - -rm -rf mods -mkdir -p mods/test - -# -# Copy .properties files -# -PROPS="`(cd $TESTSRC/src; find . -name '*.properties')`" -if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$D - cp $TESTSRC/src/$P mods/$D/ - done -fi - -$JAVAC -g -d mods --module-source-path $TESTSRC/src \ - -cp mods/bundles `find $TESTSRC/src/test -name "*.java"` - -# Create a jar to be added to the class path. Expected properties files are -# picked up from the class path. -rm -f extra.jar -mkdir -p classes -$JAR -cf extra.jar -C $TESTSRC/src/extra jdk/test/resources - -STATUS=0 - -echo 'jdk.test.Main should load bundles local to named module "test".' -$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de || STATUS=1 - -echo "jdk.test.Main should load bundles from the jar file specified by the class-path." -$JAVA -cp extra.jar -p mods -m test/jdk.test.Main vi || STATUS=1 - - -exit $STATUS diff --git a/src/test/jdk/java/util/ResourceBundle/modules/simple/simple.sh b/src/test/jdk/java/util/ResourceBundle/modules/simple/simple.sh deleted file mode 100644 index 08f3a945ce6..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/simple/simple.sh +++ /dev/null @@ -1,70 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8044767 -# @summary Simple test case for ResourceBundle with named modules; -# ResourceBundle.getBundle caller is in named module "test" and -# all resource bundles are in single named module "bundles" with -# service providers. - - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" - -rm -rf mods - -mkdir -p mods/test - -B=bundles -mkdir -p mods/$B -CLASSES="`find $TESTSRC/src/$B -name '*.java'`" -if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES -fi -PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" -if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$B/$D - cp $TESTSRC/src/$B/$P mods/$B/$D/ - done -fi - -$JAVAC -g -d mods --module-source-path $TESTSRC/src \ - -cp mods/bundles `find $TESTSRC/src/test -name "*.java"` - -$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de - -exit $? diff --git a/src/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java b/src/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java new file mode 100644 index 00000000000..c84508220b9 --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8210408 + * @summary Test unnamed module to find resource bundles exported from a named + * module. + * @library /test/lib + * .. + * @build jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Utils + * jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.process.ProcessTools + * ModuleTestUtil + * @run main UnNamedTest + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; + +public class UnNamedTest { + private static final Path SRC_DIR = Paths.get(Utils.TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get(Utils.TEST_CLASSES, "mods"); + + private static final List<String> LOCALE_LIST = List.of("de", "fr", "ja", + "zh-tw", "en", "de"); + + public static void main(String[] args) throws Throwable { + ModuleTestUtil.prepareModule(SRC_DIR, MODS_DIR, "bundles", ".properties"); + compileCmd(); + runCmd(); + } + + private static void compileCmd() throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("javac"); + launcher.addToolArg("-d") + .addToolArg(Utils.TEST_CLASSES) + .addToolArg(Paths.get(Utils.TEST_SRC, "Main.java").toString()); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Compile of the test failed. " + + "Unexpected exit code: " + exitCode); + } + } + + private static void runCmd() throws Throwable { + // access resource bundles that are exported private unconditionally. + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); + launcher.addToolArg("-cp") + .addToolArg(Utils.TEST_CLASSES) + .addToolArg("--module-path") + .addToolArg(MODS_DIR.toString()) + .addToolArg("--add-modules") + .addToolArg("bundles") + .addToolArg("Main"); + LOCALE_LIST.forEach(launcher::addToolArg); + + int exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Execution of the test1 failed. " + + "Unexpected exit code: " + exitCode); + } + + // --add-exports can't open resources + launcher = JDKToolLauncher.createUsingTestJDK("java"); + launcher.addToolArg("-cp") + .addToolArg(Utils.TEST_CLASSES) + .addToolArg("--module-path") + .addToolArg(MODS_DIR.toString()) + .addToolArg("--add-modules") + .addToolArg("bundles") + .addToolArg("--add-opens") + .addToolArg("bundles/jdk.test.internal.resources=ALL-UNNAMED") + .addToolArg("Main"); + LOCALE_LIST.forEach(launcher::addToolArg); + + exitCode = ProcessTools.executeCommand(launcher.getCommand()) + .getExitValue(); + if (exitCode != 0) { + throw new RuntimeException("Execution of the test2 failed. " + + "Unexpected exit code: " + exitCode); + } + } +} \ No newline at end of file diff --git a/src/test/jdk/java/util/ResourceBundle/modules/unnamed/unnamed.sh b/src/test/jdk/java/util/ResourceBundle/modules/unnamed/unnamed.sh deleted file mode 100644 index 1860589f7f1..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/unnamed/unnamed.sh +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @summary Test unnamed module to find resource bundles exported -# from a named module - - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" - -rm -rf mods - -mkdir -p mods/test - -B=bundles -mkdir -p mods/$B -CLASSES="`find $TESTSRC/src/$B -name '*.java'`" -if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES -fi -PROPS="`(cd $TESTSRC/src/$B; find . -name '*.properties')`" -if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$B/$D - cp $TESTSRC/src/$B/$P mods/$B/$D/ - done -fi - -mkdir classes -$JAVAC -d classes $TESTSRC/Main.java - -# access resource bundles that are exported private unconditionally -$JAVA -cp classes --module-path mods --add-modules bundles \ - Main de fr ja zh-tw en de - -# --add-exports can't open resources -$JAVA -cp classes --module-path mods --add-modules bundles \ - --add-opens bundles/jdk.test.internal.resources=ALL-UNNAMED \ - Main de fr ja zh-tw en de - -exit $? diff --git a/src/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java b/src/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java new file mode 100644 index 00000000000..1ade26104eb --- /dev/null +++ b/src/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8137317 8139238 8210408 + * @summary Visibility tests for ResourceBundle.getBundle with and without + * an unnamed module argument. + * @library /test/lib + * .. + * @build jdk.test.lib.JDKToolLauncher + * jdk.test.lib.Utils + * jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.process.ProcessTools + * ModuleTestUtil + * @run testng VisibilityTest + */ + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test +public class VisibilityTest { + private static final Path SRC_DIR = Paths.get(Utils.TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get(Utils.TEST_CLASSES, "mods"); + private static final Path CLASSES_DIR = Paths.get(Utils.TEST_CLASSES, "classes"); + private static final Path NAMED_BUNDLES_DIR = MODS_DIR.resolve("named.bundles"); + private static final Path EXPORTED_NAMED_BUNDLES_DIR = MODS_DIR.resolve("exported.named.bundles"); + + private static final List<String> MODULE_LIST = List.of("embargo", + "exported.named.bundles", "named.bundles", "test"); + + @BeforeTest + public void prepareTestEnv() throws Throwable { + MODULE_LIST.forEach(mn -> ModuleTestUtil.prepareModule(SRC_DIR, + MODS_DIR, mn, ".properties")); + + // Prepare resource bundles in an unnamed module + ModuleTestUtil.compilePkg(SRC_DIR, CLASSES_DIR, "pkg"); + ModuleTestUtil.copyResFiles(SRC_DIR, CLASSES_DIR, "pkg", ".properties"); + + } + + /** + * Package jdk.test is in named module "test". + * Package jdk.embargo is in named module "embargo". + * + * jdk.{test,embargo}.TestWithUnnamedModuleArg call: + * ResourceBundle.getBundle(basename, classloader.getUnnamedModule()) + * where classloader is the TCCL or system class loader. + * jdk.{test,embargo}.TestWithNoModuleArg call: + * ResourceBundle.getBundle(basename) + * + * jdk.test.resources[.exported].classes.* are class-based resource bundles. + * jdk.test.resources[.exported].props.* are properties file-based resource bundles. + * + * Packages jdk.test.resources.{classes,props} in named module "named.bundles" + * are exported only to named module "test". + * Packages jdk.test.resources.exported.{classes,props} in named module + * "exported.named.bundle" are exported to unnamed modules. + */ + + @DataProvider(name = "RunWithTestResData") + Object[][] RunWithTestResData() { + return new Object[][] { + // Tests using jdk.test.TestWithNoModuleArg and jdk.embargo.TestWithNoModuleArg. + // Neither of which specifies an unnamed module with ResourceBundle.getBundle(). + + // jdk.test.resources.{classes,props}.* are available only to + // named module "test" by ResourceBundleProvider. + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.classes.MyResources", "true")}, + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.props.MyResources", "true")}, + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.classes.MyResources", "false")}, + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.props.MyResources", "false")}, + + // Add mods/named.bundles to the class path. + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.classes.MyResources", "true")}, + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.props.MyResources", "true")}, + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.classes.MyResources", "true")}, + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.props.MyResources", "true")}, + + // Tests using jdk.test.TestWithUnnamedModuleArg and + // jdk.embargo.TestWithUnnamedModuleArg. + // Both of which specify an unnamed module with ResourceBundle.getBundle. + + // jdk.test.resources.classes is exported to named module "test". + // IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.classes.MyResources", "false")}, + + // jdk.test.resources.props is exported to named module "test". + // loader.getResource() doesn't find jdk.test.resources.props.MyResources. + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.props.MyResources", "false")}, + + // IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.classes.MyResources", "false")}, + + // jdk.test.resources.props is exported to named module "test". + // loader.getResource() doesn't find jdk.test.resources.props.MyResources. + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.props.MyResources", "false")}, + + // Add mods/named.bundles to the class path. + + // IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.classes.MyResources", "false")}, + + // loader.getResource() finds jdk.test.resources.exported.props.MyResources. + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.props.MyResources", "true")}, + + // jdk.test.resources.exported.classes.MyResources is treated + // as if the class is in an unnamed module. + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.classes.MyResources", "true")}, + + // loader.getResource() finds jdk.test.resources.exported.props.MyResources. + {List.of("-cp", NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.props.MyResources", "true")}, + }; + } + + @DataProvider(name = "RunWithExportedResData") + Object[][] RunWithExportedResData() { + return new Object[][] { + // Tests using jdk.test.TestWithNoModuleArg and jdk.embargo.TestWithNoModuleArg + // neither of which specifies an unnamed module with ResourceBundle.getBundle. + + // None of jdk.test.resources.exported.** is available to the named modules. + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.exported.classes.MyResources", "false")}, + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.exported.props.MyResources", "false")}, + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.exported.classes.MyResources", "false")}, + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.exported.props.MyResources", "false")}, + + // Add mods/exported.named.bundles to the class path. + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.exported.classes.MyResources", "true")}, + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithNoModuleArg", + "jdk.test.resources.exported.props.MyResources", "true")}, + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.exported.classes.MyResources", "true")}, + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithNoModuleArg", + "jdk.test.resources.exported.props.MyResources", "true")}, + + // Tests using jdk.test.TestWithUnnamedModuleArg and + // jdk.embargo.TestWithUnnamedModuleArg which specify + // an unnamed module with ResourceBundle.getBundle. + + // loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources + // and throws a ClassNotFoundException. + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.classes.MyResources", "false")}, + + // The properties files in jdk.test.resources.exported.props + // are not found with loader.getResource(). + {List.of("-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.props.MyResources", "false")}, + + // loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources + // and throws a ClassNotFoundException. + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.classes.MyResources", "false")}, + + // The properties files in jdk.test.resources.exported.props are not found + // with loader.getResource(). + {List.of("-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.props.MyResources", "false")}, + + // Add mods/exported.named.bundles to the class path. + + // jdk.test.resources.exported.classes.MyResources.getModule().isNamed() + // returns false. + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.classes.MyResources", "true")}, + + // loader.getResource() finds jdk.test.resources.exported.props.MyResources. + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "test/jdk.test.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.props.MyResources", "true")}, + + // jdk.test.resources.exported.classes.MyResources.getModule().isNamed() + // returns false. + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.classes.MyResources", "true")}, + + // loader.getResource() finds jdk.test.resources.exported.props.MyResources. + {List.of("-cp", EXPORTED_NAMED_BUNDLES_DIR.toString(), + "-p", MODS_DIR.toString(), + "-m", "embargo/jdk.embargo.TestWithUnnamedModuleArg", + "jdk.test.resources.exported.props.MyResources", "true")}, + + }; + } + + @DataProvider(name = "RunWithPkgResData") + Object[][] RunWithPkgResData() { + return new Object[][] { + // jdk.pkg.resources.* are in an unnamed module. + // jdk.pkg.test.Main calls ResourceBundle.getBundle with an unnamed module. + { List.of("-cp", CLASSES_DIR.resolve("pkg").toString(), "jdk.pkg.test.Main", + "jdk.pkg.resources.classes.MyResources", "true")}, + { List.of("-cp", CLASSES_DIR.resolve("pkg").toString(), "jdk.pkg.test.Main", + "jdk.pkg.resources.props.MyResources", "true")}, + }; + } + + /** + * Test cases with jdk.test.resources.* + */ + @Test(dataProvider = "RunWithTestResData") + public void RunWithTestRes(List<String> argsList) throws Throwable { + int exitCode = runCmd(argsList); + assertEquals(exitCode, 0, "Execution of the tests with " + + "jdk.test.resources.* failed. " + + "Unexpected exit code: " + exitCode); + } + + /** + * Test cases with jdk.test.resources.exported.* + */ + @Test(dataProvider = "RunWithExportedResData") + public void RunWithExportedRes(List<String> argsList) throws Throwable { + int exitCode = runCmd(argsList); + assertEquals(exitCode, 0, "Execution of the tests with " + + "jdk.test.resources.exported.* failed. " + + "Unexpected exit code: " + exitCode); + } + + /** + * Test cases with jdk.pkg.resources.* + */ + @Test(dataProvider = "RunWithPkgResData") + public void RunWithPkgRes(List<String> argsList) throws Throwable { + int exitCode = runCmd(argsList); + assertEquals(exitCode, 0, "Execution of the tests with " + + "jdk.pkg.resources.* failed. " + + "Unexpected exit code: " + exitCode); + } + + private int runCmd(List<String> argsList) throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); + argsList.forEach(launcher::addToolArg); + + return ProcessTools.executeCommand(launcher.getCommand()).getExitValue(); + } +} \ No newline at end of file diff --git a/src/test/jdk/java/util/ResourceBundle/modules/visibility/visibility.sh b/src/test/jdk/java/util/ResourceBundle/modules/visibility/visibility.sh deleted file mode 100644 index 7aeaf827d60..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/visibility/visibility.sh +++ /dev/null @@ -1,233 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8137317 8139238 -# @summary Visibility tests for ResourceBundle.getBundle with and without -# an unnamed module argument. - - -set -e -STATUS=0 - -runJava() -{ - echo "Executing java $@" - $JAVA $@ || STATUS=1 - echo -} - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" - -rm -rf mods classes - -MODS=`cd $TESTSRC/src; find . -name module-info.java -exec dirname {} \; | sed 's:\./::'` - -for M in $MODS -do - mkdir -p mods/$M - CLASSES="`find $TESTSRC/src/$M -name '*.java'`" - if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES - fi - PROPS="`(cd $TESTSRC/src/$M; find . -name '*.properties')`" - if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$M/$D - cp $TESTSRC/src/$M/$P mods/$M/$D/ - done - fi -done - -# Package jdk.test is in named module "test". -# Package jdk.embargo is in named module "embargo". - -# jdk.{test,embargo}.TestWithUnnamedModuleArg call: -# ResourceBundle.getBundle(basename, classloader.getUnnamedModule()) -# where classloader is the TCCL or system class loader. -# jdk.{test,embargo}.TestWithNoModuleArg call: -# ResourceBundle.getBundle(basename) - -# jdk.test.resources[.exported].classes.* are class-based resource bundles. -# jdk.test.resources[.exported].props.* are properties file-based resource bundles. - -# Packages jdk.test.resources.{classes,props} in named module "named.bundles" -# are exported only to named module "test". -# Packages jdk.test.resources.exported.{classes,props} in named module -# "exported.named.bundle" are exported to unnamed modules. - -######################################## -# Test cases with jdk.test.resources.* # -######################################## - -# Tests using jdk.test.TestWithNoModuleArg and jdk.embargo.TestWithNoModuleArg -# neither of which specifies an unnamed module with ResourceBundle.getBundle(). - -# jdk.test.resources.{classes,props}.* are available only to named module "test" -# by ResourceBundleProvider. -runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.classes.MyResources true -runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.props.MyResources true -runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.classes.MyResources false -runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.props.MyResources false - -# Add mods/named.bundles to the class path. -runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.classes.MyResources true -runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.props.MyResources true -runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.classes.MyResources true -runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.props.MyResources true - -# Tests using jdk.test.TestWithUnnamedModuleArg and jdk.embargo.TestWithUnnamedModuleArg -# both of which specify an unnamed module with ResourceBundle.getBundle. - -# jdk.test.resources.classes is exported to named module "test". -# IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). -runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.classes.MyResources false - -# jdk.test.resources.props is exported to named module "test". -# loader.getResource() doesn't find jdk.test.resources.props.MyResources. -runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.props.MyResources false - -# IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). -runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.classes.MyResources false -# jdk.test.resources.props is exported to named module "test". -# loader.getResource() doesn't find jdk.test.resources.props.MyResources. -runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.props.MyResources false - -# Add mods/named.bundles to the class path - -# IllegalAccessException is thrown in ResourceBundle.Control.newBundle(). -runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.classes.MyResources false -# loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.props.MyResources true - -# jdk.test.resources.exported.classes.MyResources is treated -# as if the class is in an unnamed module. -runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.classes.MyResources true -# loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.props.MyResources true - -################################################# -# Test cases with jdk.test.resources.exported.* # -################################################# -# Tests using jdk.test.TestWithNoModuleArg and jdk.embargo.TestWithNoModuleArg -# neither of which specifies an unnamed module with ResourceBundle.getBundle. - -# None of jdk.test.resources.exported.** is available to the named modules. -runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.exported.classes.MyResources false -runJava -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.exported.props.MyResources false -runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.exported.classes.MyResources false -runJava -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.exported.props.MyResources false - -# Add mods/exported.named.bundles to the class path. -runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.exported.classes.MyResources true -runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithNoModuleArg \ - jdk.test.resources.exported.props.MyResources true -runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.exported.classes.MyResources true -runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithNoModuleArg \ - jdk.test.resources.exported.props.MyResources true - -# Tests using jdk.test.TestWithUnnamedModuleArg and jdk.embargo.TestWithUnnamedModuleArg -# which specify an unnamed module with ResourceBundle.getBundle. - -# loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources -# and throws a ClassNotFoundException. -runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.classes.MyResources false -# The properties files in jdk.test.resources.exported.props are not found with loader.getResource(). -runJava -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.props.MyResources false - - -# loader.loadClass() doesn't find jdk.test.resources.exported.classes.MyResources -# and throws a ClassNotFoundException. -runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.classes.MyResources false -# The properties files in jdk.test.resources.exported.props are not found -# with loader.getResource(). -runJava -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.props.MyResources false - -# Add mods/exported.named.bundles to the class path. - -# jdk.test.resources.exported.classes.MyResources.getModule().isNamed() returns false. -runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.classes.MyResources true -# loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/exported.named.bundles -p mods -m test/jdk.test.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.props.MyResources true - -# jdk.test.resources.exported.classes.MyResources.getModule().isNamed() returns false. -runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.classes.MyResources true -# loader.getResource() finds jdk.test.resources.exported.props.MyResources. -runJava -cp mods/exported.named.bundles -p mods -m embargo/jdk.embargo.TestWithUnnamedModuleArg \ - jdk.test.resources.exported.props.MyResources true - -####################################### -# Test cases with jdk.pkg.resources.* # -####################################### -# Prepare resource bundles in an unnamed module -PKG=$TESTSRC/src/pkg -mkdir -p classes/jdk/pkg/resources/props -$JAVAC -g -d classes $PKG/jdk/pkg/test/Main.java $PKG/jdk/pkg/resources/classes/MyResources.java -cp $PKG/jdk/pkg/resources/props/MyResources.properties classes/jdk/pkg/resources/props - -# jdk.pkg.resources.* are in an unnamed module. -# jdk.pkg.test.Main calls ResourceBundle.getBundle with an unnamed module. -runJava -cp classes jdk.pkg.test.Main jdk.pkg.resources.classes.MyResources true -runJava -cp classes jdk.pkg.test.Main jdk.pkg.resources.props.MyResources true - -exit $STATUS diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources.xml deleted file mode 100644 index dc4be6b78c3..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle</comment> - <entry key="key">root: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_de.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_de.xml deleted file mode 100644 index cfaa5dda5a1..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_de.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle</comment> - <entry key="key">de: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_en.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_en.xml deleted file mode 100644 index 0213a2126ba..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_en.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle</comment> - <entry key="key">en: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_fr.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_fr.xml deleted file mode 100644 index d6b57efc7cf..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_fr.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle</comment> - <entry key="key">fr: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_ja.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_ja.xml deleted file mode 100644 index 6d82961e83d..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_ja.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle in named modules.</comment> - <entry key="key">ja: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_zh.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_zh.xml deleted file mode 100644 index df1a2b727d6..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_zh.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle in named modules.</comment> - <entry key="key">zh: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_zh_TW.xml b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_zh_TW.xml deleted file mode 100644 index 5ce424a187c..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/src/bundles/jdk/test/resources/MyResources_zh_TW.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!----> - -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - -<properties> - <comment>Test data for ResourceBundle in named modules.</comment> - <entry key="key">zh-TW: message</entry> -</properties> diff --git a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh b/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh deleted file mode 100644 index 4c5c7b13843..00000000000 --- a/src/test/jdk/java/util/ResourceBundle/modules/xmlformat/xmlformat.sh +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @summary Simple test case for ResourceBundle with modules; -# ResourceBundle.getBundle caller is in module named "test" and -# all resource bundles are in single module named "bundles". - - -set -e - -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi - -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" - -rm -rf mods - -mkdir -p mods/test - -B=bundles -mkdir -p mods/$B -CLASSES="`find $TESTSRC/src/$B -name '*.java'`" -if [ "x$CLASSES" != x ]; then - $JAVAC -g -d mods --module-source-path $TESTSRC/src $CLASSES -fi -PROPS="`(cd $TESTSRC/src/$B; find . -name '*.xml')`" -if [ "x$PROPS" != x ]; then - for P in $PROPS - do - D=`dirname $P` - mkdir -p mods/$B/$D - cp $TESTSRC/src/$B/$P mods/$B/$D/ - done -fi - -$JAVAC -g -d mods --module-source-path $TESTSRC/src \ - -cp mods/bundles `find $TESTSRC/src/test -name "*.java"` - -$JAVA -p mods -m test/jdk.test.Main de fr ja zh-tw en de - -exit $? diff --git a/src/test/jdk/java/util/TimeZone/CLDRDisplayNamesTest.java b/src/test/jdk/java/util/TimeZone/CLDRDisplayNamesTest.java index 85c70f36b4a..06a3c00bdb7 100644 --- a/src/test/jdk/java/util/TimeZone/CLDRDisplayNamesTest.java +++ b/src/test/jdk/java/util/TimeZone/CLDRDisplayNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8005471 8008577 8129881 8130845 8136518 8181157 8210490 + * @bug 8005471 8008577 8129881 8130845 8136518 8181157 8210490 8220037 * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=CLDR CLDRDisplayNamesTest * @summary Make sure that localized time zone names of CLDR are used @@ -73,6 +73,8 @@ public class CLDRDisplayNamesTest { }, }; + private static final String NO_INHERITANCE_MARKER = "\u2205\u2205\u2205"; + public static void main(String[] args) { // Make sure that localized time zone names of CLDR are used // if specified. @@ -128,6 +130,40 @@ public static void main(String[] args) { System.err.printf("Wrong display name for timezone Etc/GMT-5 : expected GMT+05:00, Actual " + displayName); errors++; } + + // 8217366: No "no inheritance marker" should be left in the returned array + // from DateFormatSymbols.getZoneStrings() + errors += List.of(Locale.ROOT, + Locale.CHINA, + Locale.GERMANY, + Locale.JAPAN, + Locale.UK, + Locale.US, + Locale.forLanguageTag("hi-IN"), + Locale.forLanguageTag("es-419")).stream() + .peek(System.out::println) + .map(l -> DateFormatSymbols.getInstance(l).getZoneStrings()) + .flatMap(zoneStrings -> Arrays.stream(zoneStrings)) + .filter(namesArray -> Arrays.stream(namesArray) + .anyMatch(aName -> aName.equals(NO_INHERITANCE_MARKER))) + .peek(marker -> { + System.err.println("No-inheritance-marker is detected with tzid: " + + marker[0]); + }) + .count(); + + // 8220037: Make sure CLDRConverter uniquely produces bundles, regardless of the + // source file enumeration order. + tz = TimeZone.getTimeZone("America/Argentina/La_Rioja"); + if (!"ARST".equals(tz.getDisplayName(true, TimeZone.SHORT, + new Locale.Builder() + .setLanguage("en") + .setRegion("CA") + .build()))) { + System.err.println("Short display name of \"" + tz.getID() + "\" was not \"ARST\""); + errors++; + } + if (errors > 0) { throw new RuntimeException("test failed"); } diff --git a/src/test/jdk/java/util/TimeZone/NegativeDSTTest.java b/src/test/jdk/java/util/TimeZone/NegativeDSTTest.java new file mode 100644 index 00000000000..b237f0fd4ee --- /dev/null +++ b/src/test/jdk/java/util/TimeZone/NegativeDSTTest.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import static org.testng.Assert.assertEquals; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZonedDateTime; +import java.time.ZoneId; +import java.util.Date; +import java.util.TimeZone; + +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; +import static org.testng.Assert.assertEquals; + +/** + * @test + * @bug 8212970 + * @summary Test whether the savings are positive in time zones that have + * negative savings in the source TZ files. + * @run testng NegativeDSTTest + */ +@Test +public class NegativeDSTTest { + + private static final TimeZone DUBLIN = TimeZone.getTimeZone("Europe/Dublin"); + private static final TimeZone PRAGUE = TimeZone.getTimeZone("Europe/Prague"); + private static final TimeZone WINDHOEK = TimeZone.getTimeZone("Africa/Windhoek"); + private static final TimeZone CASABLANCA = TimeZone.getTimeZone("Africa/Casablanca"); + private static final int ONE_HOUR = 3600_000; + + @DataProvider + private Object[][] negativeDST () { + return new Object[][] { + // TimeZone, localDate, offset, isDaylightSavings + // Europe/Dublin for the Rule "Eire" + {DUBLIN, LocalDate.of(1970, 6, 23), ONE_HOUR, true}, + {DUBLIN, LocalDate.of(1971, 6, 23), ONE_HOUR, true}, + {DUBLIN, LocalDate.of(1971, 11, 1), 0, false}, + {DUBLIN, LocalDate.of(2019, 6, 23), ONE_HOUR, true}, + {DUBLIN, LocalDate.of(2019, 12, 23), 0, false}, + + // Europe/Prague which contains fixed negative savings (not a named Rule) + {PRAGUE, LocalDate.of(1946, 9, 30), 2 * ONE_HOUR, true}, + {PRAGUE, LocalDate.of(1946, 10, 10), ONE_HOUR, false}, + {PRAGUE, LocalDate.of(1946, 12, 3), 0, false}, + {PRAGUE, LocalDate.of(1947, 2, 25), ONE_HOUR, false}, + {PRAGUE, LocalDate.of(1947, 4, 30), 2 * ONE_HOUR, true}, + + // Africa/Windhoek for the Rule "Namibia" + {WINDHOEK, LocalDate.of(1994, 3, 23), ONE_HOUR, false}, + {WINDHOEK, LocalDate.of(2016, 9, 23), 2 * ONE_HOUR, true}, + + // Africa/Casablanca for the Rule "Morocco" Defines negative DST till 2037 as of 2019a. + {CASABLANCA, LocalDate.of(1939, 9, 13), ONE_HOUR, true}, + {CASABLANCA, LocalDate.of(1939, 11, 20), 0, false}, + {CASABLANCA, LocalDate.of(2018, 6, 18), ONE_HOUR, true}, + {CASABLANCA, LocalDate.of(2019, 1, 1), ONE_HOUR, true}, + {CASABLANCA, LocalDate.of(2019, 5, 6), 0, false}, + {CASABLANCA, LocalDate.of(2037, 10, 5), 0, false}, + {CASABLANCA, LocalDate.of(2037, 11, 16), ONE_HOUR, true}, + {CASABLANCA, LocalDate.of(2038, 11, 1), ONE_HOUR, true}, + }; + } + + @Test(dataProvider="negativeDST") + public void test_NegativeDST(TimeZone tz, LocalDate ld, int offset, boolean isDST) { + Date d = Date.from(Instant.from(ZonedDateTime.of(ld, LocalTime.MIN, tz.toZoneId()))); + assertEquals(tz.getOffset(d.getTime()), offset); + assertEquals(tz.inDaylightTime(d), isDST); + } +} diff --git a/src/test/jdk/java/util/TimeZone/TimeZoneTest.java b/src/test/jdk/java/util/TimeZone/TimeZoneTest.java index 976958f078e..146dbbfd12c 100644 --- a/src/test/jdk/java/util/TimeZone/TimeZoneTest.java +++ b/src/test/jdk/java/util/TimeZone/TimeZoneTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 4028006 4044013 4096694 4107276 4107570 4112869 4130885 7039469 7126465 7158483 * 8008577 8077685 8098547 8133321 8138716 8148446 8151876 8159684 8166875 8181157 + * 8228469 * @modules java.base/sun.util.resources * @library /java/text/testlib * @summary test TimeZone @@ -113,7 +114,7 @@ public void TestShortZoneIDs() throws Exception { new ZoneDescriptor("PRT", -240, false), new ZoneDescriptor("CNT", -210, true), new ZoneDescriptor("AGT", -180, false), - new ZoneDescriptor("BET", -180, true), + new ZoneDescriptor("BET", -180, false), // new ZoneDescriptor("CAT", -60, false), // Wrong: // As of bug 4130885, fix CAT (Central Africa) new ZoneDescriptor("CAT", 120, false), // Africa/Harare diff --git a/src/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/src/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java index c0b938cf8f2..421f41f365c 100644 --- a/src/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java +++ b/src/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorTest.java @@ -2011,4 +2011,49 @@ public void testStandardRejectedExecutionHandlers() { assertTrue(p.getQueue().isEmpty()); } + public void testThreadFactoryReturnsTerminatedThread_shouldThrow() { + if (!testImplementationDetails) + return; + + ThreadFactory returnsTerminatedThread = runnableIgnored -> { + Thread thread = new Thread(() -> {}); + thread.start(); + try { thread.join(); } + catch (InterruptedException ex) { throw new Error(ex); } + return thread; + }; + ThreadPoolExecutor p = + new ThreadPoolExecutor(1, 1, 1, SECONDS, + new ArrayBlockingQueue<Runnable>(1), + returnsTerminatedThread); + try (PoolCleaner cleaner = cleaner(p)) { + assertThrows(IllegalThreadStateException.class, + () -> p.execute(() -> {})); + } + } + + public void testThreadFactoryReturnsStartedThread_shouldThrow() { + if (!testImplementationDetails) + return; + + CountDownLatch latch = new CountDownLatch(1); + Runnable awaitLatch = () -> { + try { latch.await(); } + catch (InterruptedException ex) { throw new Error(ex); }}; + ThreadFactory returnsStartedThread = runnable -> { + Thread thread = new Thread(awaitLatch); + thread.start(); + return thread; + }; + ThreadPoolExecutor p = + new ThreadPoolExecutor(1, 1, 1, SECONDS, + new ArrayBlockingQueue<Runnable>(1), + returnsStartedThread); + try (PoolCleaner cleaner = cleaner(p)) { + assertThrows(IllegalThreadStateException.class, + () -> p.execute(() -> {})); + latch.countDown(); + } + } + } diff --git a/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml b/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml index 5382313ad99..585757402e3 100644 --- a/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml +++ b/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml @@ -25,15 +25,7 @@ --> <!----> -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Test data for UserDefaultControlTest.java</comment> <entry key="type">XML</entry> diff --git a/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml b/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml index ed607377325..2fbb7e8b87c 100644 --- a/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml +++ b/src/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml @@ -25,15 +25,7 @@ --> <!----> -<!-- DTD for properties --> -<!DOCTYPE properties [ -<!ELEMENT properties ( comment?, entry* ) > -<!ATTLIST properties version CDATA #FIXED "1.0"> -<!ELEMENT comment (#PCDATA) > -<!ELEMENT entry (#PCDATA) > -<!ATTLIST entry key CDATA #REQUIRED> -]> - +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Test data for UserDefaultControlTest.java</comment> <entry key="type">XML</entry> diff --git a/src/test/jdk/java/util/zip/ZipFile/MultiThreadedReadTest.java b/src/test/jdk/java/util/zip/ZipFile/MultiThreadedReadTest.java index 0a660e373aa..80a66648a8d 100644 --- a/src/test/jdk/java/util/zip/ZipFile/MultiThreadedReadTest.java +++ b/src/test/jdk/java/util/zip/ZipFile/MultiThreadedReadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -28,14 +28,14 @@ * @build jdk.test.lib.Platform * jdk.test.lib.util.FileUtils * @run main MultiThreadedReadTest - * @key randomness */ +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.nio.file.Paths; -import java.util.Random; +import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; @@ -44,7 +44,8 @@ public class MultiThreadedReadTest extends Thread { private static final int NUM_THREADS = 10; - private static final String ZIPFILE_NAME = "large.zip"; + private static final String ZIPFILE_NAME = + System.currentTimeMillis() + "-bug8038491-tmp.large.zip"; private static final String ZIPENTRY_NAME = "random.txt"; private static InputStream is = null; @@ -63,23 +64,30 @@ public static void main(String args[]) throws Exception { threadArray[i].join(); } } finally { + long t = System.currentTimeMillis(); FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME)); + System.out.println("Deleting zip file took:" + + (System.currentTimeMillis() - t) + "ms"); } } private static void createZipFile() throws Exception { - try (ZipOutputStream zos = - new ZipOutputStream(new FileOutputStream(ZIPFILE_NAME))) { - - zos.putNextEntry(new ZipEntry(ZIPENTRY_NAME)); - StringBuilder sb = new StringBuilder(); - Random rnd = new Random(); - for(int i = 0; i < 1000; i++) { - // append some random string for ZipEntry - sb.append(Long.toString(rnd.nextLong())); - } - byte[] b = sb.toString().getBytes(); - zos.write(b, 0, b.length); + CRC32 crc32 = new CRC32(); + long t = System.currentTimeMillis(); + File zipFile = new File(ZIPFILE_NAME); + try (FileOutputStream fos = new FileOutputStream(zipFile); + BufferedOutputStream bos = new BufferedOutputStream(fos); + ZipOutputStream zos = new ZipOutputStream(bos)) { + ZipEntry e = new ZipEntry(ZIPENTRY_NAME); + e.setMethod(ZipEntry.STORED); + byte[] toWrite = "BLAH".repeat(10_000).getBytes(); + e.setTime(t); + e.setSize(toWrite.length); + crc32.reset(); + crc32.update(toWrite); + e.setCrc(crc32.getValue()); + zos.putNextEntry(e); + zos.write(toWrite); } } @@ -88,6 +96,7 @@ public void run() { try { while (is.read() != -1) { } } catch (Exception e) { + System.out.println("read exception:" + e); // Swallow any Exceptions (which are expected) - we're only interested in the crash } } diff --git a/src/test/jdk/java/util/zip/ZipFile/Zip64SizeTest.java b/src/test/jdk/java/util/zip/ZipFile/Zip64SizeTest.java new file mode 100644 index 00000000000..be701e4805b --- /dev/null +++ b/src/test/jdk/java/util/zip/ZipFile/Zip64SizeTest.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +import static org.testng.Assert.assertTrue; + +/** + * @test + * @bug 8226530 + * @summary ZIP File System tests that leverage DirectoryStream + * @modules java.base + * @compile Zip64SizeTest.java + * @run testng Zip64SizeTest + */ +public class Zip64SizeTest { + + private static final int BUFFER_SIZE = 2048; + // ZIP file to create + private static final String ZIP_FILE_NAME = "Zip64SizeTest.zip"; + // File that will be created with a size greater than 0xFFFFFFFF + private static final String LARGE_FILE_NAME = "LargeZipEntry.txt"; + // File that will be created with a size less than 0xFFFFFFFF + private static final String SMALL_FILE_NAME = "SmallZipEntry.txt"; + // List of files to be added to the ZIP file + private static final List<String> ZIP_ENTRIES = List.of(LARGE_FILE_NAME, + SMALL_FILE_NAME); + private static final long LARGE_FILE_SIZE = 5L * 1024L * 1024L * 1024L; // 5GB + private static final long SMALL_FILE_SIZE = 0x100000L; // 1024L x 1024L; + + /** + * Validate that if the size of a ZIP entry exceeds 0xFFFFFFFF, that the + * correct size is returned from the ZIP64 Extended information. + * @throws IOException + */ + @Test + private static void validateZipEntrySizes() throws IOException { + createFiles(); + createZipFile(); + System.out.println("Validating Zip Entry Sizes"); + try (ZipFile zip = new ZipFile(ZIP_FILE_NAME)) { + ZipEntry ze = zip.getEntry(LARGE_FILE_NAME); + System.out.printf("Entry: %s, size= %s%n", ze.getName(), ze.getSize()); + assertTrue(ze.getSize() == LARGE_FILE_SIZE); + ze = zip.getEntry(SMALL_FILE_NAME); + System.out.printf("Entry: %s, size= %s%n", ze.getName(), ze.getSize()); + assertTrue(ze.getSize() == SMALL_FILE_SIZE); + + } + } + + /** + * Delete the files created for use by the test + * @throws IOException if an error occurs deleting the files + */ + private static void deleteFiles() throws IOException { + Files.deleteIfExists(Path.of(ZIP_FILE_NAME)); + Files.deleteIfExists(Path.of(LARGE_FILE_NAME)); + Files.deleteIfExists(Path.of(SMALL_FILE_NAME)); + } + + /** + * Create the ZIP file adding an entry whose size exceeds 0xFFFFFFFF + * @throws IOException if an error occurs creating the ZIP File + */ + private static void createZipFile() throws IOException { + try (FileOutputStream fos = new FileOutputStream(ZIP_FILE_NAME); + ZipOutputStream zos = new ZipOutputStream(fos)) { + System.out.printf("Creating Zip file: %s%n", ZIP_FILE_NAME); + for (String srcFile : ZIP_ENTRIES) { + System.out.printf("...Adding Entry: %s%n", srcFile); + File fileToZip = new File(srcFile); + try (FileInputStream fis = new FileInputStream(fileToZip)) { + ZipEntry zipEntry = new ZipEntry(fileToZip.getName()); + zipEntry.setSize(fileToZip.length()); + zos.putNextEntry(zipEntry); + byte[] bytes = new byte[BUFFER_SIZE]; + int length; + while ((length = fis.read(bytes)) >= 0) { + zos.write(bytes, 0, length); + } + } + } + } + } + + /** + * Create the files that will be added to the ZIP file + * @throws IOException if there is a problem creating the files + */ + private static void createFiles() throws IOException { + try (RandomAccessFile largeFile = new RandomAccessFile(LARGE_FILE_NAME, "rw"); + RandomAccessFile smallFile = new RandomAccessFile(SMALL_FILE_NAME, "rw")) { + System.out.printf("Creating %s%n", LARGE_FILE_NAME); + largeFile.setLength(LARGE_FILE_SIZE); + System.out.printf("Creating %s%n", SMALL_FILE_NAME); + smallFile.setLength(SMALL_FILE_SIZE); + } + } + + /** + * Make sure the needed test files do not exist prior to executing the test + * @throws IOException + */ + @BeforeMethod + public void setUp() throws IOException { + deleteFiles(); + } + + /** + * Remove the files created for the test + * @throws IOException + */ + @AfterMethod + public void tearDown() throws IOException { + deleteFiles(); + } +} \ No newline at end of file diff --git a/src/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java b/src/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java new file mode 100644 index 00000000000..356beb31a53 --- /dev/null +++ b/src/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8218723 + * @summary Use SunJCE Mac in SecretKeyFactory PBKDF2 implementation + * @library evilprov.jar + * @library /test/lib + * @build jdk.test.lib.Convert + * @run main/othervm SecKeyFacSunJCEPrf + */ + +import java.util.Arrays; +import javax.crypto.SecretKeyFactory; +import javax.crypto.SecretKey; +import javax.crypto.spec.PBEKeySpec; +import java.security.Provider; +import java.security.Security; +import com.evilprovider.*; +import jdk.test.lib.Convert; + +public class SecKeyFacSunJCEPrf { + + // One of the PBKDF2 HMAC-SHA1 test vectors from RFC 6070 + private static final byte[] SALT = "salt".getBytes(); + private static final char[] PASS = "password".toCharArray(); + private static final int ITER = 4096; + private static final byte[] EXP_OUT = Convert.hexStringToByteArray( + "4B007901B765489ABEAD49D926F721D065A429C1"); + + public static void main(String[] args) throws Exception { + // Instantiate the Evil Provider and insert it in the + // most-preferred position. + Provider evilProv = new EvilProvider(); + System.out.println("3rd Party Provider: " + evilProv); + Security.insertProviderAt(evilProv, 1); + + SecretKeyFactory pbkdf2 = + SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", "SunJCE"); + PBEKeySpec pbks = new PBEKeySpec(PASS, SALT, ITER, 160); + + SecretKey secKey1 = pbkdf2.generateSecret(pbks); + System.out.println("PBKDF2WithHmacSHA1:\n" + + Convert.byteArrayToHexString(secKey1.getEncoded())); + if (Arrays.equals(secKey1.getEncoded(), EXP_OUT)) { + System.out.println("Test Vector Passed"); + } else { + System.out.println("Test Vector Failed"); + System.out.println("Expected Output:\n" + + Convert.byteArrayToHexString(EXP_OUT)); + throw new RuntimeException(); + } + } +} + diff --git a/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov.jar b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov.jar new file mode 100644 index 00000000000..5d73de23ee3 Binary files /dev/null and b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov.jar differ diff --git a/src/test/jdk/java/util/ResourceBundle/modules/layer/run.sh b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/Makefile similarity index 55% rename from src/test/jdk/java/util/ResourceBundle/modules/layer/run.sh rename to src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/Makefile index a604e412c5c..918c31f0947 100644 --- a/src/test/jdk/java/util/ResourceBundle/modules/layer/run.sh +++ b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 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 @@ -21,32 +21,35 @@ # questions. # -# @test -# @bug 8180375 8185251 -# @summary Tests resource bundles are correctly loaded from -# modules through "<packageName>.spi.<simpleName>Provider" types. +# Java paths +#JAVA_BASE=PATH_TO_JAVA_IMG_DIR +JAVABIN=$(JAVA_BASE)/bin +JAVAC=$(JAVABIN)/javac +JAVA=$(JAVABIN)/java +JAR=$(JAVABIN)/jar +JARSIGNER=$(JAVABIN)/jarsigner -set -e +# Compile-time flags and paths +JFLAGS=-Xlint:all +SRCPATH=com/evilprovider +CLASSDST=classes -if [ -z "$TESTJAVA" ]; then - if [ $# -lt 1 ]; then exit 1; fi - TESTJAVA="$1"; shift - COMPILEJAVA="${TESTJAVA}" - TESTSRC="`pwd`" - TESTCLASSES="`pwd`" -fi +PROVJAR=evilprov.jar +KSTORE=PATH_TO_KEYSTORE +KALIAS=PLACE_SIGNING_ALIAS_HERE +MODVER=1.0 -JAVAC="$COMPILEJAVA/bin/javac" -JAVA="$TESTJAVA/bin/java" +all: $(PROVJAR) -rm -rf mods -$JAVAC --module-source-path $TESTSRC/src -d mods --module m1,m2 +%.class: %.java + mkdir -p $(CLASSDST) + $(JAVAC) -d $(CLASSDST) $(JFLAGS) $< -mkdir -p mods/m1/p/resources mods/m2/p/resources -cp $TESTSRC/src/m1/p/resources/*.properties mods/m1/p/resources -cp $TESTSRC/src/m2/p/resources/*.properties mods/m2/p/resources +$(PROVJAR): $(SRCPATH)/EvilHmacSHA1.class $(SRCPATH)/EvilProvider.class module-info.class + $(JAR) --create --file $(PROVJAR) --module-version $(MODVER) -C $(CLASSDST) . -mkdir classes -$JAVAC -d classes $TESTSRC/src/Main.java +signed: $(PROVJAR) + jarsigner -keystore $(KSTORE) $(PROVJAR).jar $(KALIAS) -$JAVA -cp classes Main +clean: + rm -rf $(CLASSDST) $(PROVJAR) diff --git a/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/README b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/README new file mode 100644 index 00000000000..3bc33a4529e --- /dev/null +++ b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/README @@ -0,0 +1,15 @@ +Everything in this directory is dedicated to building the EvilProvider +used with the SecKeyFacSunJCEPRF test (JDK-8218723). + +The makefile does require a JDK image path to be provided through the +JAVA_BASE makefile variable. As an example: + +make JAVA_BASE=/usr/java/jdk-11.0.1 evilprov + +Since the EvilProvider is a modular jar, JDK 9 or later should be used. + +For OpenJDK, no signing is required. If signing is required (for use +with Oracle JDK, for instance), you must obtain a JCE signing certificate +and place it in a keystore, then run the "signed" makefile target (it will +build the jar file if it does not already exist). + diff --git a/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java new file mode 100644 index 00000000000..017535a8bc4 --- /dev/null +++ b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.evilprovider; + +import java.security.*; +import java.security.spec.*; +import java.nio.ByteBuffer; + +import javax.crypto.*; + +public final class EvilHmacSHA1 extends MacSpi { + private final Mac internalMac; + + public EvilHmacSHA1() throws GeneralSecurityException { + internalMac = Mac.getInstance("HmacSHA1", "SunJCE"); + } + + @Override + protected byte[] engineDoFinal() { + return internalMac.doFinal(); + } + + @Override + protected int engineGetMacLength() { + return internalMac.getMacLength(); + } + + @Override + protected void engineInit(Key key, AlgorithmParameterSpec spec) + throws InvalidKeyException, InvalidAlgorithmParameterException { + SecretKey sKey; + if (key instanceof SecretKey) { + sKey = (SecretKey)key; + } else { + throw new IllegalArgumentException("Key must be a SecretKey"); + } + + byte[] sKeyEnc = sKey.getEncoded(); + int keyBits = sKeyEnc.length * 8; + if (keyBits < 160) { + throw new IllegalArgumentException("Key must be at least 160 bits"); + } + + // Pass through to init + internalMac.init(key, spec); + } + + @Override + protected void engineReset() { + internalMac.reset(); + } + + @Override + protected void engineUpdate(byte input) { + internalMac.update(input); + } + + @Override + protected void engineUpdate(byte[] input, int offset, int len) { + internalMac.update(input, offset, len); + } + + @Override + protected void engineUpdate(ByteBuffer input) { + internalMac.update(input); + } +} diff --git a/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilProvider.java b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilProvider.java new file mode 100644 index 00000000000..2976e8db206 --- /dev/null +++ b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.evilprovider; + +import java.security.*; + +public final class EvilProvider extends Provider { + + private static final long serialVersionUID = 11223344550000L; + + public EvilProvider() { + super("EvilProvider", "1.0", "Evil Provider"); + putService(new Provider.Service(this, "Mac", "HmacSHA1", + "com.evilprovider.EvilHmacSHA1", null, null)); + } +} + diff --git a/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/module-info.java b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/module-info.java new file mode 100644 index 00000000000..d971726946c --- /dev/null +++ b/src/test/jdk/javax/crypto/SecretKeyFactory/evilprov/module-info.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019, 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. + */ + +/** + * Provides the evil provider + * + * @provides java.security.Provider + * + * @moduleGraph + */ +module jdk.evilprovider { + provides java.security.Provider with com.evilprovider.EvilProvider; +} diff --git a/src/test/jdk/javax/net/ssl/SSLSocket/InputStreamClosure.java b/src/test/jdk/javax/net/ssl/SSLSocket/InputStreamClosure.java new file mode 100644 index 00000000000..4644a479e12 --- /dev/null +++ b/src/test/jdk/javax/net/ssl/SSLSocket/InputStreamClosure.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// +// Please run in othervm mode. SunJSSE does not support dynamic system +// properties, no way to re-use system properties in samevm/agentvm mode. +// + +/* + * @test + * @bug 8216326 + * @modules jdk.crypto.ec + * @library /javax/net/ssl/templates + * @summary SSLSocket stream close() does not close the associated socket + * @run main/othervm InputStreamClosure + */ +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLSocket; + +public class InputStreamClosure extends SSLSocketTemplate { + + // Run the test case. + public static void main(String[] args) throws Exception { + (new InputStreamClosure()).run(); + } + + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + // here comes the test logic + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslIS.read(); + sslOS.write(85); + sslOS.flush(); + } + + /* + * Define the client side application of the test for the specified socket. + * This method is used if the returned value of + * isCustomizedClientConnection() is false. + * + * @param socket may be null is no client socket is generated. + * + * @see #isCustomizedClientConnection() + */ + protected void runClientApplication(SSLSocket socket) throws Exception { + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslOS.write(280); + sslOS.flush(); + sslIS.read(); + + sslIS.close(); + if (!socket.isClosed()) { + throw new Exception("Closing the SSLSocket InputStream does " + + "not close the associated socket"); + } + } +} diff --git a/src/test/jdk/javax/net/ssl/SSLSocket/OutputStreamClosure.java b/src/test/jdk/javax/net/ssl/SSLSocket/OutputStreamClosure.java new file mode 100644 index 00000000000..83b0aceaf38 --- /dev/null +++ b/src/test/jdk/javax/net/ssl/SSLSocket/OutputStreamClosure.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// +// Please run in othervm mode. SunJSSE does not support dynamic system +// properties, no way to re-use system properties in samevm/agentvm mode. +// + +/* + * @test + * @bug 8216326 + * @modules jdk.crypto.ec + * @library /javax/net/ssl/templates + * @summary SSLSocket stream close() does not close the associated socket + * @run main/othervm OutputStreamClosure + */ +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLSocket; + +public class OutputStreamClosure extends SSLSocketTemplate { + + // Run the test case. + public static void main(String[] args) throws Exception { + (new OutputStreamClosure()).run(); + } + + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + // here comes the test logic + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslIS.read(); + sslOS.write(85); + sslOS.flush(); + } + + /* + * Define the client side application of the test for the specified socket. + * This method is used if the returned value of + * isCustomizedClientConnection() is false. + * + * @param socket may be null is no client socket is generated. + * + * @see #isCustomizedClientConnection() + */ + protected void runClientApplication(SSLSocket socket) throws Exception { + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslOS.write(280); + sslOS.flush(); + sslIS.read(); + + sslOS.close(); + if (!socket.isClosed()) { + throw new Exception("Closing the SSLSocket OutputStream does " + + "not close the associated socket"); + } + } +} diff --git a/src/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java b/src/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java new file mode 100644 index 00000000000..1d6317f4bc6 --- /dev/null +++ b/src/test/jdk/javax/net/ssl/SSLSocket/Tls13PacketSize.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// +// Please run in othervm mode. SunJSSE does not support dynamic system +// properties, no way to re-use system properties in samevm/agentvm mode. +// + +/* + * @test + * @bug 8221253 + * @summary TLSv1.3 may generate TLSInnerPlainText longer than 2^14+1 bytes + * @modules jdk.crypto.ec + * @library /javax/net/ssl/templates + * @run main/othervm Tls13PacketSize + */ +import java.io.InputStream; +import java.io.OutputStream; +import javax.net.ssl.SSLSocket; + +public class Tls13PacketSize extends SSLSocketTemplate { + private static final byte[] appData = new byte[16385]; + static { + for (int i = 0; i < appData.length; i++) { + appData[i] = (byte)('A' + (i % 26)); + } + } + + // Run the test case. + public static void main(String[] args) throws Exception { + (new Tls13PacketSize()).run(); + } + + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + // here comes the test logic + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslIS.read(); + int extra = sslIS.available(); + System.out.println("Server input bytes: " + extra); + // Considering the padding impact, the record plaintext is less + // than the TLSPlaintext.fragment length (2^14). + if (extra >= 16383) { // 16383: 2^14 - 1 byte read above + throw new Exception( + "Client record plaintext exceeds 2^14 octets: " + extra); + } + + sslOS.write(appData); + sslOS.flush(); + } + + /* + * Define the client side application of the test for the specified socket. + * This method is used if the returned value of + * isCustomizedClientConnection() is false. + * + * @param socket may be null is no client socket is generated. + * + * @see #isCustomizedClientConnection() + */ + protected void runClientApplication(SSLSocket socket) throws Exception { + socket.setEnabledProtocols(new String[] {"TLSv1.3"}); + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslOS.write(appData); + sslOS.flush(); + + sslIS.read(); + int extra = sslIS.available(); + System.out.println("Client input bytes: " + extra); + // Considering the padding impact, the record plaintext is less + // than the TLSPlaintext.fragment length (2^14). + if (extra >= 16383) { // 16383: 2^14 - 1 byte read above + throw new Exception( + "Server record plaintext exceeds 2^14 octets: " + extra); + } + } +} diff --git a/src/test/jdk/javax/security/sasl/Sasl/DisabledMechanisms.java b/src/test/jdk/javax/security/sasl/Sasl/DisabledMechanisms.java new file mode 100644 index 00000000000..d38f334f4c0 --- /dev/null +++ b/src/test/jdk/javax/security/sasl/Sasl/DisabledMechanisms.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8200400 + * @modules java.security.sasl + * @library /test/lib + * @run main/othervm DisabledMechanisms + * DIGEST-MD5 DIGEST-MD5 + * @run main/othervm -DdisabledMechanisms= DisabledMechanisms + * DIGEST-MD5 DIGEST-MD5 + * @run main/othervm -DdisabledMechanisms=DIGEST-MD5,NTLM DisabledMechanisms + * null null + * @run main/othervm -DdisabledMechanisms=DIGEST-MD5 DisabledMechanisms + * NTLM null + * @run main/othervm -DdisabledMechanisms=NTLM DisabledMechanisms + * DIGEST-MD5 DIGEST-MD5 + */ + +import java.security.Security; +import java.util.Collections; +import java.util.Map; +import javax.security.auth.callback.PasswordCallback; +import javax.security.sasl.Sasl; +import javax.security.sasl.SaslClient; +import javax.security.sasl.SaslServer; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; + +import jdk.test.lib.Asserts; + +public class DisabledMechanisms { + + public static void main(String[] args) throws Exception { + + String authorizationId = "username"; + String protocol = "ldap"; + String serverName = "server1"; + Map props = Collections.emptyMap(); + + String disabled = System.getProperty("disabledMechanisms"); + if (disabled != null) { + Security.setProperty("jdk.sasl.disabledMechanisms", disabled); + } + + CallbackHandler callbackHandler = callbacks -> { + for (Callback cb : callbacks) { + if (cb instanceof PasswordCallback) { + ((PasswordCallback) cb).setPassword("password".toCharArray()); + } + } + }; + + SaslClient client = Sasl.createSaslClient( + new String[]{"DIGEST-MD5", "NTLM"}, authorizationId, + protocol, serverName, props, callbackHandler); + Asserts.assertEQ(client == null ? null : client.getMechanismName(), + args[0].equals("null") ? null : args[0]); + + SaslServer server = Sasl.createSaslServer( + "DIGEST-MD5", protocol, serverName, props, callbackHandler); + Asserts.assertEQ(server == null ? null : server.getMechanismName(), + args[1].equals("null") ? null : args[1]); + } +} diff --git a/src/test/jdk/javax/swing/SwingUtilities/TestTextPosInPrint.java b/src/test/jdk/javax/swing/SwingUtilities/TestTextPosInPrint.java new file mode 100644 index 00000000000..8a41dc2dfae --- /dev/null +++ b/src/test/jdk/javax/swing/SwingUtilities/TestTextPosInPrint.java @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 8214702 + @summary Verifies text position for whitespaced string in printing Swing text + @run main/manual TestTextPosInPrint + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Font; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.Printable; +import java.awt.print.PageFormat; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.swing.JFrame; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.Timer; +import javax.swing.WindowConstants; +import javax.swing.SwingConstants; +import javax.swing.UIManager; + +public class TestTextPosInPrint implements Printable { + private static final CountDownLatch testEndedSignal = new CountDownLatch(1); + private static final int testTimeout = 300000; + private static volatile String testFailureMsg; + private static volatile boolean testPassed; + private static volatile boolean testFinished; + private static PrinterJob job; + private static JPanel panel; + private static JFrame f; + + public static void main(String[] args) throws Exception { + job = PrinterJob.getPrinterJob(); + if (job.getPrintService() == null) { + System.out.println("This test requires printers to be installed. Exiting."); + return; + } + SwingUtilities.invokeLater(() -> createAndShowTestDialog()); + + try { + if (!testEndedSignal.await(testTimeout, TimeUnit.MILLISECONDS)) { + throw new RuntimeException(String.format( + "Test timeout '%d ms' elapsed.", testTimeout)); + } + if (!testPassed) { + String failureMsg = testFailureMsg; + if ((failureMsg != null) && (!failureMsg.trim().isEmpty())) { + throw new RuntimeException(failureMsg); + } else { + throw new RuntimeException("Test failed."); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException(ie); + } finally { + testFinished = true; + SwingUtilities.invokeAndWait(() -> f.dispose()); + } + } + + private static void doTest() throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + f = new JFrame(); + f.setLocationRelativeTo(null); + panel = new JPanel(); + panel.setLayout(new BorderLayout()); + Font font = new Font("Serif", Font.PLAIN, 12); + JLabel l1 = new JLabel(" 1. ABCDE"); + l1.setHorizontalAlignment(SwingConstants.LEFT); + JLabel l2 = new JLabel(" 2. ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); + l2.setHorizontalAlignment(SwingConstants.LEFT); + //JLabel l3 = new JLabel(" 3. ABCDE "); + JLabel l3 = new JLabel(" 3. ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); + l3.setHorizontalAlignment(SwingConstants.LEFT); + panel.add(BorderLayout.NORTH, l1); + panel.add(BorderLayout.CENTER, l2); + panel.add(BorderLayout.SOUTH, l3); + f.getContentPane().add(BorderLayout.NORTH, panel); + f.setSize(400, 300); + f.setVisible(true); + + job.setPrintable(new TestTextPosInPrint()); + if (job.printDialog()) { + try { + job.print(); + } catch (PrinterException pe) { + throw new RuntimeException(pe); + } + } + } + + private static void pass() { + testPassed = true; + testEndedSignal.countDown(); + } + + private static void fail(String failureMsg) { + testFailureMsg = failureMsg; + testPassed = false; + testEndedSignal.countDown(); + } + + private static String convertMillisToTimeStr(int millis) { + if (millis < 0) { + return "00:00:00"; + } + int hours = millis / 3600000; + int minutes = (millis - hours * 3600000) / 60000; + int seconds = (millis - hours * 3600000 - minutes * 60000) / 1000; + return String.format("%02d:%02d:%02d", hours, minutes, seconds); + } + + private static void createAndShowTestDialog() { + String description = + " 1. Click on \"Start Test\" button.\r\n" + + " 2. Multiple strings will be displayed on console.\r\n" + + " 3. A print dialog will be shown. Select any printer to print. " + + "\r\n" + + " If the printed output of the strings are same without any alignment issue, click on \"PASS\"\r\n" + + " button, otherwise click on \"FAIL\" button."; + + final JDialog dialog = new JDialog(); + dialog.setTitle("SaveFileWithoutPrinter"); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + dialog.dispose(); + fail("Main dialog was closed."); + } + }); + + final JLabel testTimeoutLabel = new JLabel(String.format( + "Test timeout: %s", convertMillisToTimeStr(testTimeout))); + final long startTime = System.currentTimeMillis(); + final Timer timer = new Timer(0, null); + timer.setDelay(1000); + timer.addActionListener((e) -> { + int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime); + if ((leftTime < 0) || testFinished) { + timer.stop(); + dialog.dispose(); + } + testTimeoutLabel.setText(String.format( + "Test timeout: %s", convertMillisToTimeStr(leftTime))); + }); + timer.start(); + + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + final JButton failButton = new JButton("FAIL"); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + new Thread(() -> { + try { + doTest(); + + SwingUtilities.invokeLater(() -> { + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + } catch (Throwable t) { + t.printStackTrace(); + dialog.dispose(); + fail("Exception occurred in a thread executing the test."); + } + }).start(); + }); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail("Printed texts are not aligned as shown in console"); + }); + + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel labelPanel = new JPanel(new FlowLayout()); + labelPanel.add(testTimeoutLabel); + mainPanel.add(labelPanel, BorderLayout.NORTH); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + + dialog.pack(); + dialog.setVisible(true); + } + + @Override + public int print(Graphics pg, PageFormat pf, int pageNum) + throws PrinterException { + if (pageNum > 0){ + return Printable.NO_SUCH_PAGE; + } + + Graphics2D g2 = (Graphics2D) pg; + g2.translate(pf.getImageableX(), pf.getImageableY()); + panel.paint(g2); + return Printable.PAGE_EXISTS; + } +} diff --git a/src/test/jdk/jdk/internal/loader/URLClassPath/JarClassPathFileEntry.java b/src/test/jdk/jdk/internal/loader/URLClassPath/JarClassPathFileEntry.java new file mode 100644 index 00000000000..43e8dc3d5d5 --- /dev/null +++ b/src/test/jdk/jdk/internal/loader/URLClassPath/JarClassPathFileEntry.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.jar.Attributes; +import java.util.jar.Manifest; +import jdk.test.lib.util.JarUtils; +import jdk.test.lib.compiler.InMemoryJavaCompiler; + +/* + * @test + * @bug 8216401 + * @summary Test loading of JAR Class-Path entry with file: scheme + * @library /test/lib + * + * @run main/othervm JarClassPathFileEntry + * @run main/othervm -Djdk.net.URLClassPath.disableClassPathURLCheck=true JarClassPathFileEntry + * @run main/othervm -Djdk.net.URLClassPath.disableClassPathURLCheck=false JarClassPathFileEntry + */ + +public class JarClassPathFileEntry { + private final static boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows"); + + private final static String TEST_CLASSES = System.getProperty("test.classes"); + private final static String OTHER_DIR = TEST_CLASSES + "/OTHER/"; + + private final static Path OTHER_JAR_PATH = Paths.get(OTHER_DIR, "Other.jar"); + private final static Path CONTEXT_JAR_PATH = Paths.get(TEST_CLASSES, "Context.jar"); + + public static void main(String[] args) throws Throwable { + // Create Other.class in OTHER_DIR, off the default classpath + byte klassbuf[] = InMemoryJavaCompiler.compile("Other", + "public class Other {}"); + ClassFileInstaller.writeClassToDisk("Other", klassbuf, OTHER_DIR); + + // Create Other.jar in OTHER_DIR + JarUtils.createJarFile(OTHER_JAR_PATH, + Paths.get(OTHER_DIR), + Paths.get(OTHER_DIR, "Other.class")); + + // Create Context.class + klassbuf = InMemoryJavaCompiler.compile("Context", + "public class Context {}"); + ClassFileInstaller.writeClassToDisk("Context", klassbuf, TEST_CLASSES); + + // Create Context.jar w/ "file:" entry for Other.jar + Manifest mf = new Manifest(); + Attributes attrs = mf.getMainAttributes(); + attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); + + String classPathEntry = "file:" + (IS_WINDOWS ? toUnixPath(OTHER_JAR_PATH.toString()) + : OTHER_JAR_PATH.toString()); + attrs.put(Attributes.Name.CLASS_PATH, classPathEntry); + + System.out.println("Creating Context.jar with Class-Path: " + classPathEntry); + JarUtils.createJarFile(CONTEXT_JAR_PATH, mf, + Paths.get(TEST_CLASSES), + Paths.get(TEST_CLASSES, "Context.class")); + + // Use URLClassLoader w/ Context.jar to load Other.class, which will + // load via the Class-Path entry + URL url = CONTEXT_JAR_PATH.toUri().toURL(); + URLClassLoader ucl = new URLClassLoader("TestURLClassLoader", + new URL[]{ url }, + null); // don't delegate to App CL + Class<?> otherClass = Class.forName("Other", true, ucl); // ClassNotFoundException -> fail + System.out.println("Loaded: " + otherClass); + } + + /* Convert a Windows path to a unix-style path, and remove any drive letter */ + private static String toUnixPath(String orig) { + String retVal = new File(orig).toURI().getPath(); + int colonAt = retVal.indexOf(':'); + + if (colonAt != -1 && colonAt < 3) { + retVal = retVal.substring(colonAt + 1); // Start after the drive letter + } + return retVal; + } +} diff --git a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest b/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest deleted file mode 100644 index 166c969289e..00000000000 --- a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest +++ /dev/null @@ -1,8 +0,0 @@ -FROM oraclelinux:7.2 -MAINTAINER mikhailo.seledtsov@oracle.com - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-aarch64 b/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-aarch64 deleted file mode 100644 index 082a4d89ed0..00000000000 --- a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-aarch64 +++ /dev/null @@ -1,8 +0,0 @@ -# Use generic ubuntu Linux on AArch64 -FROM aarch64/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-ppc64le b/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-ppc64le deleted file mode 100644 index 57dfb0f86b9..00000000000 --- a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-ppc64le +++ /dev/null @@ -1,10 +0,0 @@ -# test on x86_64 uses Oracle Linux but we do not have this for ppc64le -# so use some other Linux where OpenJDK works -# FROM oraclelinux:7.2 -FROM ppc64le/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-s390x b/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-s390x deleted file mode 100644 index 940b36edebb..00000000000 --- a/src/test/jdk/jdk/internal/platform/docker/Dockerfile-BasicTest-s390x +++ /dev/null @@ -1,7 +0,0 @@ -FROM s390x/ubuntu - -COPY /jdk /jdk - -ENV JAVA_HOME=/jdk - -CMD ["/bin/bash"] diff --git a/src/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java b/src/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java index 95bfe2ea7e4..d4c9c3497ee 100644 --- a/src/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java +++ b/src/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java @@ -64,10 +64,15 @@ private static void testMemoryFailCount() { long count = Metrics.systemMetrics().getMemoryFailCount(); // Allocate 512M of data - long[][] longs = new long[64][]; - for (int i = 1; i <= 64; i++) { + byte[][] bytes = new byte[64][]; + for (int i = 0; i < 64; i++) { try { - longs[i] = new long[8 * 1024 * 1024]; + bytes[i] = new byte[8 * 1024 * 1024]; + // Break out as soon as we see an increase in failcount + // to avoid getting killed by the OOM killer. + if (Metrics.systemMetrics().getMemoryFailCount() > count) { + break; + } } catch (Error e) { // OOM error break; } diff --git a/src/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java b/src/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java index ee3b5a35f04..2a4b44fb917 100644 --- a/src/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java +++ b/src/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java @@ -90,6 +90,7 @@ private static void testMemoryFailCount(String value) throws Exception { new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsMemoryTester"); opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/") .addDockerOpts("--memory=" + value) + .addJavaOpts("-Xmx" + value) .addJavaOpts("-cp", "/test-classes/") .addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED") .addClassOptions("failcount"); diff --git a/src/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java b/src/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java index 5f50060f403..824a520956d 100644 --- a/src/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java +++ b/src/test/jdk/jdk/jfr/event/metadata/TestDefaultConfigurations.java @@ -173,6 +173,10 @@ private static Document createDocument(String content) throws ParserConfiguratio insertSetting(doc, EventNames.ActiveRecording, "threshold", "0 ns"); insertSetting(doc, EventNames.JavaExceptionThrow, "threshold", "0 ns"); insertSetting(doc, EventNames.JavaErrorThrow, "threshold", "0 ns"); + insertSetting(doc, EventNames.SecurityProperty, "threshold", "0 ns"); + insertSetting(doc, EventNames.TLSHandshake, "threshold", "0 ns"); + insertSetting(doc, EventNames.X509Certificate, "threshold", "0 ns"); + insertSetting(doc, EventNames.X509Validation, "threshold", "0 ns"); return doc; } diff --git a/src/test/jdk/jdk/jfr/event/os/TestCPUInformation.java b/src/test/jdk/jdk/jfr/event/os/TestCPUInformation.java index bb3ca93a2d0..7990c49a1f6 100644 --- a/src/test/jdk/jdk/jfr/event/os/TestCPUInformation.java +++ b/src/test/jdk/jdk/jfr/event/os/TestCPUInformation.java @@ -55,7 +55,7 @@ public static void main(String[] args) throws Throwable { Events.assertField(event, "cores").atLeast(1); Events.assertField(event, "sockets").atLeast(1); Events.assertField(event, "cpu").containsAny("Intel", "AMD", "Unknown x86", "sparc", "ARM", "PPC", "PowerPC", "AArch64", "s390"); - Events.assertField(event, "description").containsAny("Intel", "AMD", "Unknown x86", "SPARC", "ARM", "PPC", "PowerPC", "AArch64", "zArch"); + Events.assertField(event, "description").containsAny("Intel", "AMD", "Unknown x86", "SPARC", "ARM", "PPC", "PowerPC", "AArch64", "s390"); } } } diff --git a/src/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java b/src/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java index 2ca3fe4c236..574b34409ef 100644 --- a/src/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java +++ b/src/test/jdk/jdk/jfr/event/runtime/TestActiveSettingEvent.java @@ -201,6 +201,10 @@ private static void testSettingConfiguration(String configurationName) throws Ex settingValues.put(EventNames.ActiveRecording + "#threshold", "0 ns"); settingValues.put(EventNames.JavaExceptionThrow + "#threshold", "0 ns"); settingValues.put(EventNames.JavaErrorThrow + "#threshold", "0 ns"); + settingValues.put(EventNames.SecurityProperty + "#threshold", "0 ns"); + settingValues.put(EventNames.TLSHandshake + "#threshold", "0 ns"); + settingValues.put(EventNames.X509Certificate + "#threshold", "0 ns"); + settingValues.put(EventNames.X509Validation + "#threshold", "0 ns"); try (Recording recording = new Recording(c)) { Map<Long, EventType> eventTypes = new HashMap<>(); diff --git a/src/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java b/src/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java index ddc6d119e42..9dc09ead243 100644 --- a/src/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java +++ b/src/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java @@ -64,8 +64,8 @@ private static void verifyRequiredModules() throws Throwable { recording.stop(); List<RecordedEvent> events = Events.fromRecording(recording); - assertDependency(events, "jdk.jfr", "java.base"); // jdk.jfr requires java.base (by edfault) - assertDependency(events, "java.base", "jdk.jfr"); // java.base require jdk.jfr for JDK events, i.e. FileRead + assertDependency(events, "jdk.jfr", "java.base"); // jdk.jfr requires java.base (by default) + assertDependency(events, "java.base", "jdk.jfr"); // java.base requires jdk.jfr for JDK events, i.e. FileRead recording.close(); } @@ -97,8 +97,9 @@ private static void verifyExportedModules() throws Throwable { events.stream().forEach((ev) -> { String exportedPackage = getValue(ev.getValue("exportedPackage"), "name", UNNAMED); String toModule = getValue(ev.getValue("targetModule"), "name", UNNAMED); - - edges.put(exportedPackage, toModule); + if (!toModule.equals("jdk.proxy1")) { // ignore jdk.proxy1 module + edges.put(exportedPackage, toModule); + } }); // We expect diff --git a/src/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java b/src/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java new file mode 100644 index 00000000000..ba1f3c9ed28 --- /dev/null +++ b/src/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.event.security; + +import java.security.Security; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.security.JDKSecurityProperties; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm jdk.jfr.event.security.TestSecurityPropertyModificationEvent + */ +public class TestSecurityPropertyModificationEvent { + + static List<String> keys = JDKSecurityProperties.getKeys(); + static String keyValue = "shouldBecomeAnEvent"; + + public static void main(String[] args) throws Exception { + try (Recording recording = new Recording()) { + recording.enable(EventNames.SecurityProperty); + recording.start(); + for (String key: keys) { + Security.setProperty(key, keyValue); + } + recording.stop(); + + List<RecordedEvent> events = Events.fromRecording(recording); + Asserts.assertEquals(events.size(), keys.size(), + "Incorrect number of events"); + assertEvent(events); + } + } + + private static void assertEvent(List<RecordedEvent> events) throws Exception { + int i = 1; + for (RecordedEvent e : events) { + if (keys.contains(e.getString("key"))) { + Events.assertField(e, "value").equal(keyValue); + i++; + } else { + System.out.println(events); + throw new Exception("Unexpected event at index:" + i); + } + } + } +} diff --git a/src/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java b/src/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java new file mode 100644 index 00000000000..4565e553362 --- /dev/null +++ b/src/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.event.security; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.security.TestTLSHandshake; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm jdk.jfr.event.security.TestTLSHandshakeEvent + */ +public class TestTLSHandshakeEvent { + public static void main(String[] args) throws Exception { + try (Recording recording = new Recording()) { + recording.enable(EventNames.TLSHandshake); + recording.start(); + TestTLSHandshake handshake = new TestTLSHandshake(); + handshake.run(); + recording.stop(); + + List<RecordedEvent> events = Events.fromRecording(recording); + Events.hasEvents(events); + assertEvent(events, handshake); + } + } + + private static void assertEvent(List<RecordedEvent> events, TestTLSHandshake handshake) throws Exception { + System.out.println(events); + for (RecordedEvent e : events) { + if (handshake.peerHost.equals(e.getString("peerHost"))) { + Events.assertField(e, "peerPort").equal(handshake.peerPort); + Events.assertField(e, "protocolVersion").equal(handshake.protocolVersion); + Events.assertField(e, "certificateId").equal(TestTLSHandshake.HASHCODE); + Events.assertField(e, "cipherSuite").equal(TestTLSHandshake.CIPHER_SUITE); + return; + } + } + System.out.println(events); + throw new Exception("Could not find event with hostname: " + handshake.peerHost); + } +} diff --git a/src/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java b/src/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java new file mode 100644 index 00000000000..7d771d5ab2d --- /dev/null +++ b/src/test/jdk/jdk/jfr/event/security/TestX509CertificateEvent.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.event.security; + +import java.security.cert.CertificateFactory; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.security.TestCertificate; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm jdk.jfr.event.security.TestX509CertificateEvent + */ +public class TestX509CertificateEvent { + public static void main(String[] args) throws Exception { + try (Recording recording = new Recording()) { + recording.enable(EventNames.X509Certificate); + recording.start(); + + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + TestCertificate.ONE.generate(cf); + TestCertificate.TWO.generate(cf); + // Generate twice to make sure only one event per certificate is generated + TestCertificate.ONE.generate(cf); + TestCertificate.TWO.generate(cf); + + recording.stop(); + + List<RecordedEvent> events = Events.fromRecording(recording); + Asserts.assertEquals(events.size(), 2, "Incorrect number of X509Certificate events"); + assertEvent(events, TestCertificate.ONE); + assertEvent(events, TestCertificate.TWO); + } + } + + private static void assertEvent(List<RecordedEvent> events, TestCertificate cert) throws Exception { + for (RecordedEvent e : events) { + if (e.getLong("certificateId") == cert.certId) { + Events.assertField(e, "algorithm").equal(cert.algorithm); + Events.assertField(e, "subject").equal(cert.subject); + Events.assertField(e, "issuer").equal(cert.issuer); + Events.assertField(e, "keyType").equal(cert.keyType); + Events.assertField(e, "keyLength").equal(cert.keyLength); + Events.assertField(e, "serialNumber").equal(cert.serialNumber); + return; + } + } + System.out.println(events); + throw new Exception("Could not find event with cert Id: " + cert.certId); + } +} diff --git a/src/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java b/src/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java new file mode 100644 index 00000000000..14fbca926b8 --- /dev/null +++ b/src/test/jdk/jdk/jfr/event/security/TestX509ValidationEvent.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.event.security; + +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.security.TestCertificate; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @modules jdk.jfr/jdk.jfr.events + * @run main/othervm jdk.jfr.event.security.TestX509ValidationEvent + */ +public class TestX509ValidationEvent { + public static void main(String[] args) throws Exception { + try (Recording recording = new Recording()) { + recording.enable(EventNames.X509Validation); + recording.start(); + // intermeditate certificate test + TestCertificate.generateChain(false); + recording.stop(); + List<RecordedEvent> events = Events.fromRecording(recording); + Asserts.assertEquals(events.size(), 3, "Incorrect number of events"); + assertEvent1(events); + } + + try (Recording recording = new Recording()) { + recording.enable(EventNames.X509Validation); + recording.start(); + // self signed certificate test + TestCertificate.generateChain(true); + recording.stop(); + List<RecordedEvent> events = Events.fromRecording(recording); + Asserts.assertEquals(events.size(), 2, "Incorrect number of events"); + assertEvent2(events); + } + } + + private static void assertEvent1(List<RecordedEvent> events) throws Exception { + for (RecordedEvent e : events) { + int pos = e.getInt("certificatePosition"); + switch (pos) { + case 1: + Events.assertField(e, "certificateId") + .equal(TestCertificate.ROOT_CA.certId); + break; + case 2: + Events.assertField(e, "certificateId") + .equal(TestCertificate.TWO.certId); + break; + case 3: + Events.assertField(e, "certificateId") + .equal(TestCertificate.ONE.certId); + break; + default: + System.out.println(events); + throw new Exception("Unexpected position:" + pos); + } + } + } + + /* + * Self signed certificate test + */ + private static void assertEvent2(List<RecordedEvent> events) throws Exception { + for (RecordedEvent e : events) { + int pos = e.getInt("certificatePosition"); + switch (pos) { + case 1: + case 2: + Events.assertField(e, "certificateId") + .equal(TestCertificate.ROOT_CA.certId); + break; + default: + System.out.println(events); + throw new Exception("Unexpected position:" + pos); + } + } + } +} diff --git a/src/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java b/src/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java new file mode 100644 index 00000000000..691e5317442 --- /dev/null +++ b/src/test/jdk/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.jcmd; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Stream; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @bug 8220657 + * @key jfr + * @requires vm.hasJFR + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.jcmd.TestJcmdDumpWithFileName + */ +public class TestJcmdDumpWithFileName { + + public static void main(String[] args) throws Exception { + testDumpAll(); + testDumpNamed(); + testDumpNamedWithFilename(); + } + + private static void testDumpAll() throws Exception { + Path p = Path.of("testDumpAll.jfr").toAbsolutePath(); + try (Recording r = new Recording()) { + r.setName("testDumpAll"); + r.setDestination(p); + r.start(); + + JcmdHelper.jcmd("JFR.dump"); + + Asserts.assertFalse(namedFile(p), "Unexpected file: " + p.toString()); + Asserts.assertTrue(generatedFile(), "Expected generated file"); + } + cleanup(); + } + + private static void testDumpNamed() throws Exception { + Path p = Path.of("testDumpNamed.jfr").toAbsolutePath(); + try (Recording r = new Recording()) { + r.setName("testDumpNamed"); + r.setDestination(p); + r.start(); + + JcmdHelper.jcmd("JFR.dump", "name=testDumpNamed"); + + Asserts.assertTrue(namedFile(p), "Expected file: " + p.toString()); + Asserts.assertFalse(generatedFile(), "Unexpected generated file"); + } + cleanup(); + } + + private static void testDumpNamedWithFilename() throws Exception { + Path p = Path.of("testDumpNamedWithFilename.jfr").toAbsolutePath(); + Path override = Path.of("override.jfr").toAbsolutePath(); + try (Recording r = new Recording()) { + r.setName("testDumpNamedWithFilename"); + r.setDestination(p); + r.start(); + + JcmdHelper.jcmd("JFR.dump", "name=testDumpNamedWithFilename", "filename=" + override.toString()); + + Asserts.assertFalse(namedFile(p), "Unexpected file: " + p.toString()); + Asserts.assertTrue(namedFile(override), "Expected file: " + override.toString()); + Asserts.assertFalse(generatedFile(), "Unexpected generated file"); + } + cleanup(); + } + + private static boolean namedFile(Path dumpFile) throws IOException { + return Files.exists(dumpFile) && (Files.size(dumpFile) > 0); + } + + private static boolean generatedFile() throws IOException { + long pid = ProcessHandle.current().pid(); + Stream<Path> stream = Files.find(Path.of("."), 1, (p, a) -> p.toString() + .matches("^.*hotspot-pid-" + pid + "-[0-9_]+\\.jfr$") && (a.size() > 0L)); + try (stream) { + return stream.findAny() + .isPresent(); + } + } + + private static void cleanup() throws IOException { + Stream<Path> stream = Files.find(Path.of("."), 1, (p, a) -> p.toString().endsWith(".jfr")); + try (stream) { + stream.forEach(p -> p.toFile().delete()); + } + } + +} diff --git a/src/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java b/src/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java index 9a5d63dcd20..298dca2b254 100644 --- a/src/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java +++ b/src/test/jdk/jdk/jfr/jvm/TestGetAllEventClasses.java @@ -104,8 +104,9 @@ private static void assertEventsIncluded(JVM jvm, Class<? extends Event>... targ } @SafeVarargs + @SuppressWarnings("rawtypes") private static void assertEvents(JVM jvm, boolean inclusion, Class<? extends Event>... targetEvents) { - final List<Class<? extends Event>> list = jvm.getAllEventClasses(); + final List list = jvm.getAllEventClasses(); for (Class<? extends Event> ev : targetEvents) { if (list.contains(ev)) { if (inclusion) { diff --git a/src/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java b/src/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java new file mode 100644 index 00000000000..e351e658356 --- /dev/null +++ b/src/test/jdk/jdk/nio/zipfs/UpdateEntryTest.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +import org.testng.annotations.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.spi.ToolProvider; +import java.util.zip.CRC32; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +import static org.testng.Assert.*; + +/** + * @test + * @bug 8229887 + * @summary Validate ZIP FileSystem can replace existing STORED and DEFLATED entries + * @modules jdk.zipfs + * @run testng UpdateEntryTest + */ +@Test +public class UpdateEntryTest { + + private static final Path HERE = Path.of("."); + + // Use the ToolProvider interface for accessing the jar tool + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> new RuntimeException("jar tool not found") + ); + + /** + * Represents an entry in a ZIP file. An entry encapsulates a name, a + * compression method, and its contents/data. + */ + static class Entry { + private final String name; + private final int method; + private final byte[] bytes; + + Entry(String name, int method, String contents) { + this.name = name; + this.method = method; + this.bytes = contents.getBytes(StandardCharsets.UTF_8); + } + + static Entry of(String name, int method, String contents) { + return new Entry(name, method, contents); + } + + /** + * Returns a new Entry with the same name and compression method as this + * Entry but with the given content. + */ + Entry content(String contents) { + return new Entry(name, method, contents); + } + + /** + * Writes this entry to the given ZIP output stream. + */ + ZipEntry put(ZipOutputStream zos) throws IOException { + ZipEntry e = new ZipEntry(name); + e.setMethod(method); + e.setTime(System.currentTimeMillis()); + if (method == ZipEntry.STORED) { + var crc = new CRC32(); + crc.update(bytes); + e.setCrc(crc.getValue()); + e.setSize(bytes.length); + } + zos.putNextEntry(e); + zos.write(bytes); + return e; + } + } + + /** + * Validate that you can replace an existing entry in a JAR file that + * was added with the STORED(no-compression) option + */ + public void testReplaceStoredEntry() throws IOException { + String jarFileName = "updateStoredEntry.jar"; + String storedFileName = "storedFile.txt"; + String replacedValue = "bar"; + Path zipFile = Path.of(jarFileName); + + // Create JAR file with a STORED(non-compressed) entry + Files.writeString(Path.of(storedFileName), "foobar"); + int rc = JAR_TOOL.run(System.out, System.err, + "cM0vf", jarFileName, storedFileName); + + // Replace the STORED entry + try (FileSystem fs = FileSystems.newFileSystem(zipFile, null)) { + Files.writeString(fs.getPath(storedFileName), replacedValue); + } + Entry e1 = Entry.of(storedFileName, ZipEntry.STORED, replacedValue); + verify(zipFile, e1); + } + + /** + * Test updating an entry that is STORED (not compressed) + */ + public void test1() throws IOException { + Entry e1 = Entry.of("foo", ZipEntry.STORED, "hello"); + Entry e2 = Entry.of("bar", ZipEntry.STORED, "world"); + test(e1, e2); + } + + /** + * Test updating an entry that is DEFLATED (compressed) + */ + public void test2() throws IOException { + Entry e1 = Entry.of("foo", ZipEntry.DEFLATED, "hello"); + Entry e2 = Entry.of("bar", ZipEntry.STORED, "world"); + test(e1, e2); + } + + private void test(Entry e1, Entry e2) throws IOException { + Path zipfile = Files.createTempFile(HERE, "test", "zip"); + + // create zip file + try (OutputStream out = Files.newOutputStream(zipfile); + ZipOutputStream zos = new ZipOutputStream(out)) { + e1.put(zos); + e2.put(zos); + } + + verify(zipfile, e1, e2); + + String newContents = "hi"; + + // replace contents of e1 + try (FileSystem fs = FileSystems.newFileSystem(zipfile, null)) { + Path foo = fs.getPath(e1.name); + Files.writeString(foo, newContents); + } + + verify(zipfile, e1.content(newContents), e2); + } + + + /** + * Verify that the given path is a zip files containing exactly the + * given entries. + */ + private static void verify(Path zipfile, Entry... entries) throws IOException { + // check entries with zip API + try (ZipFile zf = new ZipFile(zipfile.toFile())) { + // check entry count + assertTrue(zf.size() == entries.length); + + // check compression method and content of each entry + for (Entry e : entries) { + ZipEntry ze = zf.getEntry(e.name); + assertTrue(ze != null); + assertTrue(ze.getMethod() == e.method); + try (InputStream in = zf.getInputStream(ze)) { + byte[] bytes = in.readAllBytes(); + assertTrue(Arrays.equals(bytes, e.bytes)); + } + } + } + + // check entries with FileSystem API + try (FileSystem fs = FileSystems.newFileSystem(zipfile, null)) { + // check entry count + Path top = fs.getPath("/"); + long count = Files.find(top, Integer.MAX_VALUE, + (path, attrs) -> attrs.isRegularFile()).count(); + assertTrue(count == entries.length); + + // check content of each entry + for (Entry e : entries) { + Path file = fs.getPath(e.name); + byte[] bytes = Files.readAllBytes(file); + assertTrue(Arrays.equals(bytes, e.bytes)); + } + } + } +} diff --git a/src/test/jdk/jdk/security/logging/LogJvm.java b/src/test/jdk/jdk/security/logging/LogJvm.java new file mode 100644 index 00000000000..d814f227392 --- /dev/null +++ b/src/test/jdk/jdk/security/logging/LogJvm.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.security.logging; + +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public final class LogJvm { + private final static String LOGGING_ENABLED= "LOGGING_ENABLED"; + private final static String LOGGING_DISABLED= "LOGGING_DISABLED"; + + private final static boolean debug = false; + + private final List<String> expectedLogMessages = new ArrayList<>(); + private final Class<?> clazz; + private final boolean loggingEnabled; + + public LogJvm(Class<?> clazz, String[] args) { + this.clazz = clazz; + this.loggingEnabled = Arrays.asList(args).contains(LOGGING_ENABLED); + ensureLogging(args); + } + + private void ensureLogging(String[] args) { + for(String s : args) { + if (s.equals(LOGGING_ENABLED) || s.equals(LOGGING_DISABLED)) { + return; + } + } + throw new RuntimeException(LogJvm.class.getName() + + " requires command line parameter " + LOGGING_ENABLED + + " or " + LOGGING_DISABLED); + } + + public void addExpected(String logMsg) { + expectedLogMessages.add(logMsg); + } + + public void testExpected() throws Exception { + OutputAnalyzer out = launchJVM(); + if (debug) { + System.out.println("STDOUT DEBUG:\n " + out.getStdout()); + System.out.println("\nSTDERR DEBUG:\n " + out.getStderr()); + } + if (loggingEnabled) { + testLoggingEnabled(out); + } else { + testLoggingDisabled(out); + } + } + + public OutputAnalyzer launchJVM() throws Exception { + List<String> args = new ArrayList<>(); + if (loggingEnabled) { + args.add("-Djava.util.logging.config.file=" + + Paths.get(System.getProperty("test.src", "."), "logging.properties")); + } + args.add("--add-exports"); + args.add("java.base/jdk.internal.event=ALL-UNNAMED"); + args.add(clazz.getName()); + System.out.println(args); + OutputAnalyzer out = ProcessTools.executeTestJava(args.toArray(new String[0])); + out.shouldHaveExitValue(0); + return out; + } + + private void testLoggingDisabled(OutputAnalyzer out) { + for (String expected : expectedLogMessages) { + out.shouldNotContain(expected); + } + } + + private void testLoggingEnabled(OutputAnalyzer out) { + for (String expected : expectedLogMessages) { + out.shouldContain(expected); + } + } +} diff --git a/src/test/jdk/jdk/security/logging/TestSecurityPropertyModificationLog.java b/src/test/jdk/jdk/security/logging/TestSecurityPropertyModificationLog.java new file mode 100644 index 00000000000..cc3b40828fd --- /dev/null +++ b/src/test/jdk/jdk/security/logging/TestSecurityPropertyModificationLog.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.security.logging; + +import java.security.Security; +import java.util.List; + +import jdk.test.lib.security.JDKSecurityProperties; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @library /test/lib /test/jdk + * @run main/othervm jdk.security.logging.TestSecurityPropertyModificationLog LOGGING_ENABLED + * @run main/othervm jdk.security.logging.TestSecurityPropertyModificationLog LOGGING_DISABLED + */ +public class TestSecurityPropertyModificationLog { + + static List<String> keys = JDKSecurityProperties.getKeys(); + static String keyValue = "shouldBecomeAnEvent"; + + public static void main(String[] args) throws Exception { + LogJvm l = new LogJvm(SetSecurityProperty.class, args); + for (String s: keys) { + l.addExpected("FINE: SecurityPropertyModification: key:" + + s + ", value:" + keyValue); + } + l.testExpected(); + } + + public static class SetSecurityProperty { + public static void main(String[] args) { + for (String s: keys) { + Security.setProperty(s, keyValue); + } + } + } +} diff --git a/src/test/jdk/jdk/security/logging/TestTLSHandshakeLog.java b/src/test/jdk/jdk/security/logging/TestTLSHandshakeLog.java new file mode 100644 index 00000000000..086709dd95f --- /dev/null +++ b/src/test/jdk/jdk/security/logging/TestTLSHandshakeLog.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.security.logging; + +import jdk.test.lib.security.TestTLSHandshake; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @library /test/lib /test/jdk + * @run main/othervm jdk.security.logging.TestTLSHandshakeLog LOGGING_ENABLED + * @run main/othervm jdk.security.logging.TestTLSHandshakeLog LOGGING_DISABLED + */ +public class TestTLSHandshakeLog { + public static void main(String[] args) throws Exception { + LogJvm l = new LogJvm(TLSHandshake.class, args); + l.addExpected("FINE: X509Certificate: Alg:SHA256withRSA, Serial:" + TestTLSHandshake.CERT_SERIAL); + l.addExpected("Subject:CN=Regression Test"); + l.addExpected("Key type:EC, Length:256"); + l.addExpected("FINE: ValidationChain: " + + TestTLSHandshake.ANCHOR_HASHCODE + + ", " + TestTLSHandshake.HASHCODE); + l.addExpected("SunJSSE Test Serivce"); + l.addExpected("TLSHandshake:"); + l.addExpected("TLSv1.2"); + l.addExpected(TestTLSHandshake.CIPHER_SUITE +", " + TestTLSHandshake.HASHCODE); + l.testExpected(); + } + + public static class TLSHandshake { + public static void main(String[] args) throws Exception { + TestTLSHandshake handshake = new TestTLSHandshake(); + handshake.run(); + } + } +} \ No newline at end of file diff --git a/src/test/jdk/jdk/security/logging/TestX509CertificateLog.java b/src/test/jdk/jdk/security/logging/TestX509CertificateLog.java new file mode 100644 index 00000000000..215e62f4a3e --- /dev/null +++ b/src/test/jdk/jdk/security/logging/TestX509CertificateLog.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.security.logging; + +import java.security.cert.CertificateFactory; +import jdk.test.lib.security.TestCertificate; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @library /test/lib /test/jdk + * @run main/othervm jdk.security.logging.TestX509CertificateLog LOGGING_ENABLED + * @run main/othervm jdk.security.logging.TestX509CertificateLog LOGGING_DISABLED + */ +public class TestX509CertificateLog { + public static void main(String[] args) throws Exception { + LogJvm l = new LogJvm(GenerateX509Certicate.class, args); + l.addExpected( + "FINE: X509Certificate: Alg:" + TestCertificate.ONE.algorithm + + ", Serial:" + TestCertificate.ONE.serialNumber + + ", Subject:" + TestCertificate.ONE.subject + + ", Issuer:" + TestCertificate.ONE.issuer + + ", Key type:" + TestCertificate.ONE.keyType + + ", Length:" + TestCertificate.ONE.keyLength + + ", Cert Id:" + TestCertificate.ONE.certId); + l.addExpected( + "FINE: X509Certificate: Alg:" + TestCertificate.TWO.algorithm + + ", Serial:" + TestCertificate.TWO.serialNumber + + ", Subject:" + TestCertificate.TWO.subject + + ", Issuer:" + TestCertificate.TWO.issuer + + ", Key type:" + TestCertificate.TWO.keyType + + ", Length:" + TestCertificate.TWO.keyLength + + ", Cert Id:" + TestCertificate.TWO.certId); + l.testExpected(); + } + + public static class GenerateX509Certicate { + public static void main(String[] args) throws Exception { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + TestCertificate.ONE.generate(cf); + TestCertificate.TWO.generate(cf); + } + } +} diff --git a/src/test/jdk/jdk/security/logging/TestX509ValidationLog.java b/src/test/jdk/jdk/security/logging/TestX509ValidationLog.java new file mode 100644 index 00000000000..7fe659764b8 --- /dev/null +++ b/src/test/jdk/jdk/security/logging/TestX509ValidationLog.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.security.logging; + +import jdk.test.lib.security.TestCertificate; + +/* + * @test + * @bug 8148188 + * @summary Enhance the security libraries to record events of interest + * @library /test/lib /test/jdk + * @run main/othervm jdk.security.logging.TestX509ValidationLog LOGGING_ENABLED + * @run main/othervm jdk.security.logging.TestX509ValidationLog LOGGING_DISABLED + */ +public class TestX509ValidationLog { + public static void main(String[] args) throws Exception { + LogJvm l = new LogJvm(GenerateCertificateChain.class, args); + l.addExpected("FINE: ValidationChain: " + + TestCertificate.ROOT_CA.certId + ", " + + TestCertificate.TWO.certId + ", " + + TestCertificate.ONE.certId); + l.addExpected("FINE: ValidationChain: " + + TestCertificate.ROOT_CA.certId + ", " + + TestCertificate.ROOT_CA.certId); + l.testExpected(); + } + + public static class GenerateCertificateChain { + public static void main(String[] args) throws Exception { + TestCertificate.generateChain(false); + // self signed test + TestCertificate.generateChain(true); + } + } +} diff --git a/src/test/jdk/jdk/security/logging/logging.properties b/src/test/jdk/jdk/security/logging/logging.properties new file mode 100644 index 00000000000..0ab0c516b1a --- /dev/null +++ b/src/test/jdk/jdk/security/logging/logging.properties @@ -0,0 +1,13 @@ +############################################################ +# Configuration file for log testing +# +############################################################ + +handlers= java.util.logging.ConsoleHandler + +.level= FINE + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +jdk.event.security.level = FINE diff --git a/src/test/jdk/sun/java2d/marlin/ClipShapeTest.java b/src/test/jdk/sun/java2d/marlin/ClipShapeTest.java index add7e7c1348..061fd1cfbb0 100644 --- a/src/test/jdk/sun/java2d/marlin/ClipShapeTest.java +++ b/src/test/jdk/sun/java2d/marlin/ClipShapeTest.java @@ -24,11 +24,14 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; -import java.awt.Shape; import java.awt.Stroke; +import java.awt.Shape; +import java.awt.geom.CubicCurve2D; import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.PathIterator; +import java.awt.geom.QuadCurve2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.io.File; @@ -69,28 +72,31 @@ */ public final class ClipShapeTest { - static boolean TX_SCALE = false; - static boolean TX_SHEAR = false; + // test options: + static int NUM_TESTS; + + // shape settings: + static ShapeMode SHAPE_MODE; + + static boolean USE_DASHES; + static boolean USE_VAR_STROKE; + + static int THRESHOLD_DELTA; + static long THRESHOLD_NBPIX; + + // constants: + static final boolean DO_FAIL = Boolean.valueOf(System.getProperty("ClipShapeTest.fail", "true")); static final boolean TEST_STROKER = true; static final boolean TEST_FILLER = true; - // complementary tests in slow mode: - static boolean USE_DASHES = false; - static boolean USE_VAR_STROKE = false; + static final boolean SUBDIVIDE_CURVE = true; + static final double SUBDIVIDE_LEN_TH = 50.0; + static final boolean TRACE_SUBDIVIDE_CURVE = false; - static int NUM_TESTS = 5000; static final int TESTW = 100; static final int TESTH = 100; - // shape settings: - static ShapeMode SHAPE_MODE = ShapeMode.NINE_LINE_POLYS; - - static int THRESHOLD_DELTA; - static long THRESHOLD_NBPIX; - - static final boolean SHAPE_REPEAT = true; - // dump path on console: static final boolean DUMP_SHAPE = true; @@ -103,7 +109,8 @@ public final class ClipShapeTest { static final int MAX_SAVE_FRAMES = 100; // use fixed seed to reproduce always same polygons between tests - static final boolean FIXED_SEED = false; + static final boolean FIXED_SEED = true; + static final double RAND_SCALE = 3.0; static final double RANDW = TESTW * RAND_SCALE; static final double OFFW = (TESTW - RANDW) / 2.0; @@ -126,6 +133,7 @@ static enum ShapeMode { static final File OUTPUT_DIR = new File("."); static final AtomicBoolean isMarlin = new AtomicBoolean(); + static final AtomicBoolean isMarlinFloat = new AtomicBoolean(); static final AtomicBoolean isClipRuntime = new AtomicBoolean(); static { @@ -143,6 +151,7 @@ public void publish(LogRecord record) { // last space to avoid matching other settings: if (msg.startsWith("sun.java2d.renderer ")) { isMarlin.set(msg.contains("MarlinRenderingEngine")); + isMarlinFloat.set(!msg.contains("DMarlinRenderingEngine")); } if (msg.startsWith("sun.java2d.renderer.clip.runtime.enable")) { isClipRuntime.set(msg.contains("true")); @@ -186,12 +195,22 @@ public void close() throws SecurityException { // curve length max error: System.setProperty("sun.java2d.renderer.curve_len_err", "1e-4"); + // cubic min/max error: + System.setProperty("sun.java2d.renderer.cubic_dec_d2", "1e-3"); + System.setProperty("sun.java2d.renderer.cubic_inc_d1", "1e-4"); + // quad max error: System.setProperty("sun.java2d.renderer.quad_dec_d2", "5e-4"); + } - // cubic min/max error: - System.setProperty("sun.java2d.renderer.cubic_dec_d2", "1e-3"); - System.setProperty("sun.java2d.renderer.cubic_inc_d1", "1e-4"); // or disabled ~ 1e-6 + private static void resetOptions() { + NUM_TESTS = Integer.getInteger("ClipShapeTest.numTests", 5000); + + // shape settings: + SHAPE_MODE = ShapeMode.NINE_LINE_POLYS; + + USE_DASHES = false; + USE_VAR_STROKE = false; } /** @@ -199,79 +218,119 @@ public void close() throws SecurityException { * @param args */ public static void main(String[] args) { + { + // Bootstrap: init Renderer now: + final BufferedImage img = newImage(TESTW, TESTH); + final Graphics2D g2d = initialize(img, null); + + try { + paintShape(new Line2D.Double(0,0,100,100), g2d, true, false); + } finally { + g2d.dispose(); + } + + if (!isMarlin.get()) { + throw new RuntimeException("Marlin renderer not used at runtime !"); + } + if (!isClipRuntime.get()) { + throw new RuntimeException("Marlin clipping not enabled at runtime !"); + } + } + + System.out.println("---------------------------------------"); + System.out.println("ClipShapeTest: image = " + TESTW + " x " + TESTH); + + resetOptions(); + boolean runSlowTests = false; for (String arg : args) { if ("-slow".equals(arg)) { - System.out.println("slow: enabled."); runSlowTests = true; - } else if ("-doScale".equals(arg)) { - System.out.println("doScale: enabled."); - TX_SCALE = true; - } else if ("-doShear".equals(arg)) { - System.out.println("doShear: enabled."); - TX_SHEAR = true; } else if ("-doDash".equals(arg)) { - System.out.println("doDash: enabled."); USE_DASHES = true; } else if ("-doVarStroke".equals(arg)) { - System.out.println("doVarStroke: enabled."); USE_VAR_STROKE = true; - } - // shape mode: - else if (arg.equalsIgnoreCase("-poly")) { - SHAPE_MODE = ShapeMode.NINE_LINE_POLYS; - } else if (arg.equalsIgnoreCase("-bigpoly")) { - SHAPE_MODE = ShapeMode.FIFTY_LINE_POLYS; - } else if (arg.equalsIgnoreCase("-quad")) { - SHAPE_MODE = ShapeMode.FOUR_QUADS; - } else if (arg.equalsIgnoreCase("-cubic")) { - SHAPE_MODE = ShapeMode.TWO_CUBICS; - } else if (arg.equalsIgnoreCase("-mixed")) { - SHAPE_MODE = ShapeMode.MIXED; + } else { + // shape mode: + if (arg.equalsIgnoreCase("-poly")) { + SHAPE_MODE = ShapeMode.NINE_LINE_POLYS; + } else if (arg.equalsIgnoreCase("-bigpoly")) { + SHAPE_MODE = ShapeMode.FIFTY_LINE_POLYS; + } else if (arg.equalsIgnoreCase("-quad")) { + SHAPE_MODE = ShapeMode.FOUR_QUADS; + } else if (arg.equalsIgnoreCase("-cubic")) { + SHAPE_MODE = ShapeMode.TWO_CUBICS; + } else if (arg.equalsIgnoreCase("-mixed")) { + SHAPE_MODE = ShapeMode.MIXED; + } } } System.out.println("Shape mode: " + SHAPE_MODE); // adjust image comparison thresholds: - switch(SHAPE_MODE) { + switch (SHAPE_MODE) { case TWO_CUBICS: // Define uncertainty for curves: - THRESHOLD_DELTA = 32; // / 256 - THRESHOLD_NBPIX = 128; // / 10000 + THRESHOLD_DELTA = 32; + THRESHOLD_NBPIX = (USE_DASHES) ? 50 : 200; + if (SUBDIVIDE_CURVE) { + THRESHOLD_NBPIX = 4; + } break; case FOUR_QUADS: case MIXED: // Define uncertainty for quads: // curve subdivision causes curves to be smaller // then curve offsets are different (more accurate) - THRESHOLD_DELTA = 64; // 64 / 256 - THRESHOLD_NBPIX = 256; // 256 / 10000 + THRESHOLD_DELTA = 64; + THRESHOLD_NBPIX = (USE_DASHES) ? 40 : 420; + if (SUBDIVIDE_CURVE) { + THRESHOLD_NBPIX = 10; + } break; default: // Define uncertainty for lines: // float variant have higher uncertainty - THRESHOLD_DELTA = 8; - THRESHOLD_NBPIX = 8; + THRESHOLD_DELTA = 2; + THRESHOLD_NBPIX = (USE_DASHES) ? + // float variant have higher uncertainty + ((isMarlinFloat.get()) ? 30 : 6) // low for double + : (isMarlinFloat.get()) ? 10 : 0; } - System.out.println("THRESHOLD_DELTA: "+THRESHOLD_DELTA); - System.out.println("THRESHOLD_NBPIX: "+THRESHOLD_NBPIX); +// Visual inspection (low threshold): +// THRESHOLD_NBPIX = 2; + + System.out.println("THRESHOLD_DELTA: " + THRESHOLD_DELTA); + System.out.println("THRESHOLD_NBPIX: " + THRESHOLD_NBPIX); if (runSlowTests) { NUM_TESTS = 10000; // or 100000 (very slow) - USE_DASHES = true; USE_VAR_STROKE = true; } - System.out.println("ClipShapeTests: image = " + TESTW + " x " + TESTH); + System.out.println("NUM_TESTS: " + NUM_TESTS); + + if (USE_DASHES) { + System.out.println("USE_DASHES: enabled."); + } + if (USE_VAR_STROKE) { + System.out.println("USE_VAR_STROKE: enabled."); + } + if (!DO_FAIL) { + System.out.println("DO_FAIL: disabled."); + } + + System.out.println("---------------------------------------"); + + final DiffContext allCtx = new DiffContext("All Test setups"); + final DiffContext allWorstCtx = new DiffContext("Worst(All Test setups)"); int failures = 0; final long start = System.nanoTime(); try { - // TODO: test affine transforms ? - if (TEST_STROKER) { final float[][] dashArrays = (USE_DASHES) ? // small @@ -291,7 +350,7 @@ else if (arg.equalsIgnoreCase("-poly")) { int nsw = 0; if (USE_VAR_STROKE) { - for (float width = 0.1f; width < 110f; width *= 5f) { + for (float width = 0.25f; width < 110f; width *= 5f) { strokeWidths[nsw++] = width; } } else { @@ -310,8 +369,8 @@ else if (arg.equalsIgnoreCase("-poly")) { for (int join = 0; join <= 2; join++) { - failures += paintPaths(new TestSetup(SHAPE_MODE, false, width, cap, join, dashes)); - failures += paintPaths(new TestSetup(SHAPE_MODE, true, width, cap, join, dashes)); + failures += paintPaths(allCtx, allWorstCtx, new TestSetup(SHAPE_MODE, false, width, cap, join, dashes)); + failures += paintPaths(allCtx, allWorstCtx, new TestSetup(SHAPE_MODE, true, width, cap, join, dashes)); } } } @@ -320,29 +379,26 @@ else if (arg.equalsIgnoreCase("-poly")) { if (TEST_FILLER) { // Filler tests: - failures += paintPaths(new TestSetup(SHAPE_MODE, false, Path2D.WIND_NON_ZERO)); - failures += paintPaths(new TestSetup(SHAPE_MODE, true, Path2D.WIND_NON_ZERO)); + failures += paintPaths(allCtx, allWorstCtx, new TestSetup(SHAPE_MODE, false, Path2D.WIND_NON_ZERO)); + failures += paintPaths(allCtx, allWorstCtx, new TestSetup(SHAPE_MODE, true, Path2D.WIND_NON_ZERO)); - failures += paintPaths(new TestSetup(SHAPE_MODE, false, Path2D.WIND_EVEN_ODD)); - failures += paintPaths(new TestSetup(SHAPE_MODE, true, Path2D.WIND_EVEN_ODD)); + failures += paintPaths(allCtx, allWorstCtx, new TestSetup(SHAPE_MODE, false, Path2D.WIND_EVEN_ODD)); + failures += paintPaths(allCtx, allWorstCtx, new TestSetup(SHAPE_MODE, true, Path2D.WIND_EVEN_ODD)); } } catch (IOException ioe) { throw new RuntimeException(ioe); } System.out.println("main: duration= " + (1e-6 * (System.nanoTime() - start)) + " ms."); - if (!isMarlin.get()) { - throw new RuntimeException("Marlin renderer not used at runtime !"); - } - if (!isClipRuntime.get()) { - throw new RuntimeException("Marlin clipping not enabled at runtime !"); - } - if (failures != 0) { + allWorstCtx.dump(); + allCtx.dump(); + + if (DO_FAIL && (failures != 0)) { throw new RuntimeException("Clip test failures : " + failures); } } - static int paintPaths(final TestSetup ts) throws IOException { + static int paintPaths(final DiffContext allCtx, final DiffContext allWorstCtx, final TestSetup ts) throws IOException { final long start = System.nanoTime(); if (FIXED_SEED) { @@ -356,19 +412,24 @@ static int paintPaths(final TestSetup ts) throws IOException { final boolean fill = !ts.isStroke(); final Path2D p2d = new Path2D.Double(ts.windingRule); + final Stroke stroke = (!fill) ? createStroke(ts) : null; + final BufferedImage imgOn = newImage(TESTW, TESTH); - final Graphics2D g2dOn = initialize(imgOn, ts); + final Graphics2D g2dOn = initialize(imgOn, stroke); final BufferedImage imgOff = newImage(TESTW, TESTH); - final Graphics2D g2dOff = initialize(imgOff, ts); + final Graphics2D g2dOff = initialize(imgOff, stroke); final BufferedImage imgDiff = newImage(TESTW, TESTH); - final DiffContext globalCtx = new DiffContext("All tests"); + final DiffContext testSetupCtx = new DiffContext("Test setup"); + final DiffContext testWorstCtx = new DiffContext("Worst"); + final DiffContext testWorstThCtx = new DiffContext("Worst(>threshold)"); int nd = 0; try { final DiffContext testCtx = new DiffContext("Test"); + final DiffContext testThCtx = new DiffContext("Test(>threshold)"); BufferedImage diffImage; for (int n = 0; n < NUM_TESTS; n++) { @@ -381,15 +442,24 @@ static int paintPaths(final TestSetup ts) throws IOException { paintShape(p2d, g2dOn, fill, true); /* compute image difference if possible */ - diffImage = computeDiffImage(testCtx, imgOn, imgOff, imgDiff, globalCtx); - - final String testName = "Setup_" + ts.id + "_test_" + n; + diffImage = computeDiffImage(testCtx, testThCtx, imgOn, imgOff, imgDiff); + // Worst (total) + if (testCtx.isDiff()) { + if (testWorstCtx.isWorse(testCtx, false)) { + testWorstCtx.set(testCtx); + } + if (testWorstThCtx.isWorse(testCtx, true)) { + testWorstThCtx.set(testCtx); + } + // accumulate data: + testSetupCtx.add(testCtx); + } if (diffImage != null) { nd++; - final double ratio = (100.0 * testCtx.histPix.count) / testCtx.histAll.count; - System.out.println("Diff ratio: " + testName + " = " + trimTo3Digits(ratio) + " %"); + testThCtx.dump(); + testCtx.dump(); if (nd < MAX_SHOW_FRAMES) { if (SHOW_DETAILS) { @@ -401,9 +471,12 @@ static int paintPaths(final TestSetup ts) throws IOException { if (DUMP_SHAPE) { dumpShape(p2d); } + + final String testName = "Setup_" + ts.id + "_test_" + n; + saveImage(imgOff, OUTPUT_DIR, testName + "-off.png"); saveImage(imgOn, OUTPUT_DIR, testName + "-on.png"); - saveImage(diffImage, OUTPUT_DIR, testName + "-diff.png"); + saveImage(imgDiff, OUTPUT_DIR, testName + "-diff.png"); } } } @@ -418,13 +491,25 @@ static int paintPaths(final TestSetup ts) throws IOException { + " ratio = " + (100f * nd) / NUM_TESTS + " %"); } - globalCtx.dump(); + if (testWorstCtx.isDiff()) { + testWorstCtx.dump(); + if (testWorstThCtx.isDiff() && testWorstThCtx.histPix.sum != testWorstCtx.histPix.sum) { + testWorstThCtx.dump(); + } + if (allWorstCtx.isWorse(testWorstThCtx, true)) { + allWorstCtx.set(testWorstThCtx); + } + } + testSetupCtx.dump(); + + // accumulate data: + allCtx.add(testSetupCtx); } System.out.println("paintPaths: duration= " + (1e-6 * (System.nanoTime() - start)) + " ms."); return nd; } - private static void paintShape(final Path2D p2d, final Graphics2D g2d, + private static void paintShape(final Shape p2d, final Graphics2D g2d, final boolean fill, final boolean clip) { reset(g2d); @@ -438,26 +523,20 @@ private static void paintShape(final Path2D p2d, final Graphics2D g2d, } private static Graphics2D initialize(final BufferedImage img, - final TestSetup ts) { + final Stroke s) { final Graphics2D g2d = (Graphics2D) img.getGraphics(); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, - RenderingHints.VALUE_STROKE_PURE); +// Test normalize: +// RenderingHints.VALUE_STROKE_NORMALIZE + RenderingHints.VALUE_STROKE_PURE + ); - if (ts.isStroke()) { - g2d.setStroke(createStroke(ts)); - } - g2d.setColor(Color.GRAY); - - // Test scale - if (TX_SCALE) { - g2d.scale(1.2, 1.2); - } - // Test shear - if (TX_SHEAR) { - g2d.shear(0.1, 0.2); + if (s != null) { + g2d.setStroke(s); } + g2d.setColor(Color.BLACK); return g2d; } @@ -482,20 +561,35 @@ private static void setClip(final Graphics2D g2d, final boolean clip) { static void genShape(final Path2D p2d, final TestSetup ts) { p2d.reset(); - final int end = (SHAPE_REPEAT) ? 2 : 1; + /* + Test closed path: + 0: moveTo + (draw)To + closePath + 1: (draw)To + closePath (closePath + (draw)To sequence) + */ + final int end = (ts.closed) ? 2 : 1; + + final double[] in = new double[8]; + + double sx0 = 0.0, sy0 = 0.0, x0 = 0.0, y0 = 0.0; for (int p = 0; p < end; p++) { - p2d.moveTo(randX(), randY()); + if (p <= 0) { + x0 = randX(); y0 = randY(); + p2d.moveTo(x0, y0); + sx0 = x0; sy0 = y0; + } switch (ts.shapeMode) { case MIXED: - case FIFTY_LINE_POLYS: - case NINE_LINE_POLYS: case FIVE_LINE_POLYS: + case NINE_LINE_POLYS: + case FIFTY_LINE_POLYS: p2d.lineTo(randX(), randY()); p2d.lineTo(randX(), randY()); p2d.lineTo(randX(), randY()); p2d.lineTo(randX(), randY()); + x0 = randX(); y0 = randY(); + p2d.lineTo(x0, y0); if (ts.shapeMode == ShapeMode.FIVE_LINE_POLYS) { // And an implicit close makes 5 lines break; @@ -503,29 +597,75 @@ static void genShape(final Path2D p2d, final TestSetup ts) { p2d.lineTo(randX(), randY()); p2d.lineTo(randX(), randY()); p2d.lineTo(randX(), randY()); - p2d.lineTo(randX(), randY()); + x0 = randX(); y0 = randY(); + p2d.lineTo(x0, y0); if (ts.shapeMode == ShapeMode.NINE_LINE_POLYS) { // And an implicit close makes 9 lines break; } if (ts.shapeMode == ShapeMode.FIFTY_LINE_POLYS) { for (int i = 0; i < 41; i++) { - p2d.lineTo(randX(), randY()); + x0 = randX(); y0 = randY(); + p2d.lineTo(x0, y0); } // And an implicit close makes 50 lines break; } case TWO_CUBICS: - p2d.curveTo(randX(), randY(), randX(), randY(), randX(), randY()); - p2d.curveTo(randX(), randY(), randX(), randY(), randX(), randY()); + if (SUBDIVIDE_CURVE) { + in[0] = x0; in[1] = y0; + in[2] = randX(); in[3] = randY(); + in[4] = randX(); in[5] = randY(); + x0 = randX(); y0 = randY(); + in[6] = x0; in[7] = y0; + subdivide(p2d, 8, in); + in[0] = x0; in[1] = y0; + in[2] = randX(); in[3] = randY(); + in[4] = randX(); in[5] = randY(); + x0 = randX(); y0 = randY(); + in[6] = x0; in[7] = y0; + subdivide(p2d, 8, in); + } else { + x0 = randX(); y0 = randY(); + p2d.curveTo(randX(), randY(), randX(), randY(), x0, y0); + x0 = randX(); y0 = randY(); + p2d.curveTo(randX(), randY(), randX(), randY(), x0, y0); + } if (ts.shapeMode == ShapeMode.TWO_CUBICS) { break; } case FOUR_QUADS: - p2d.quadTo(randX(), randY(), randX(), randY()); - p2d.quadTo(randX(), randY(), randX(), randY()); - p2d.quadTo(randX(), randY(), randX(), randY()); - p2d.quadTo(randX(), randY(), randX(), randY()); + if (SUBDIVIDE_CURVE) { + in[0] = x0; in[1] = y0; + in[2] = randX(); in[3] = randY(); + x0 = randX(); y0 = randY(); + in[4] = x0; in[5] = y0; + subdivide(p2d, 6, in); + in[0] = x0; in[1] = y0; + in[2] = randX(); in[3] = randY(); + x0 = randX(); y0 = randY(); + in[4] = x0; in[5] = y0; + subdivide(p2d, 6, in); + in[0] = x0; in[1] = y0; + in[2] = randX(); in[3] = randY(); + x0 = randX(); y0 = randY(); + in[4] = x0; in[5] = y0; + subdivide(p2d, 6, in); + in[0] = x0; in[1] = y0; + in[2] = randX(); in[3] = randY(); + x0 = randX(); y0 = randY(); + in[4] = x0; in[5] = y0; + subdivide(p2d, 6, in); + } else { + x0 = randX(); y0 = randY(); + p2d.quadTo(randX(), randY(), x0, y0); + x0 = randX(); y0 = randY(); + p2d.quadTo(randX(), randY(), x0, y0); + x0 = randX(); y0 = randY(); + p2d.quadTo(randX(), randY(), x0, y0); + x0 = randX(); y0 = randY(); + p2d.quadTo(randX(), randY(), x0, y0); + } if (ts.shapeMode == ShapeMode.FOUR_QUADS) { break; } @@ -534,6 +674,111 @@ static void genShape(final Path2D p2d, final TestSetup ts) { if (ts.closed) { p2d.closePath(); + x0 = sx0; y0 = sy0; + } + } + } + + static final int SUBDIVIDE_LIMIT = 5; + static final double[][] SUBDIVIDE_CURVES = new double[SUBDIVIDE_LIMIT + 1][]; + + static { + for (int i = 0, n = 1; i < SUBDIVIDE_LIMIT; i++, n *= 2) { + SUBDIVIDE_CURVES[i] = new double[8 * n]; + } + } + + static void subdivide(final Path2D p2d, final int type, final double[] in) { + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("subdivide: " + Arrays.toString(Arrays.copyOf(in, type))); + } + + double curveLen = ((type == 8) + ? curvelen(in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]) + : quadlen(in[0], in[1], in[2], in[3], in[4], in[5])); + + if (curveLen > SUBDIVIDE_LEN_TH) { + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("curvelen: " + curveLen); + } + + System.arraycopy(in, 0, SUBDIVIDE_CURVES[0], 0, 8); + + int level = 0; + while (curveLen >= SUBDIVIDE_LEN_TH) { + level++; + curveLen /= 2.0; + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("curvelen: " + curveLen); + } + } + + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("level: " + level); + } + + if (level > SUBDIVIDE_LIMIT) { + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("max level reached : " + level); + } + level = SUBDIVIDE_LIMIT; + } + + for (int l = 0; l < level; l++) { + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("level: " + l); + } + + double[] src = SUBDIVIDE_CURVES[l]; + double[] dst = SUBDIVIDE_CURVES[l + 1]; + + for (int i = 0, j = 0; i < src.length; i += 8, j += 16) { + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("subdivide: " + Arrays.toString(Arrays.copyOfRange(src, i, i + type))); + } + if (type == 8) { + CubicCurve2D.subdivide(src, i, dst, j, dst, j + 8); + } else { + QuadCurve2D.subdivide(src, i, dst, j, dst, j + 8); + } + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("left: " + Arrays.toString(Arrays.copyOfRange(dst, j, j + type))); + System.out.println("right: " + Arrays.toString(Arrays.copyOfRange(dst, j + 8, j + 8 + type))); + } + } + } + + // Emit curves at last level: + double[] src = SUBDIVIDE_CURVES[level]; + + double len = 0.0; + + for (int i = 0; i < src.length; i += 8) { + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("curve: " + Arrays.toString(Arrays.copyOfRange(src, i, i + type))); + } + + if (type == 8) { + if (TRACE_SUBDIVIDE_CURVE) { + len += curvelen(src[i + 0], src[i + 1], src[i + 2], src[i + 3], src[i + 4], src[i + 5], src[i + 6], src[i + 7]); + } + p2d.curveTo(src[i + 2], src[i + 3], src[i + 4], src[i + 5], src[i + 6], src[i + 7]); + } else { + if (TRACE_SUBDIVIDE_CURVE) { + len += quadlen(src[i + 0], src[i + 1], src[i + 2], src[i + 3], src[i + 4], src[i + 5]); + } + p2d.quadTo(src[i + 2], src[i + 3], src[i + 4], src[i + 5]); + } + } + + if (TRACE_SUBDIVIDE_CURVE) { + System.out.println("curveLen (final) = " + len); + } + } else { + if (type == 8) { + p2d.curveTo(in[2], in[3], in[4], in[5], in[6], in[7]); + } else { + p2d.quadTo(in[2], in[3], in[4], in[5]); } } } @@ -754,18 +999,19 @@ public static BufferedImage newImage(final int w, final int h) { return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); } - public static BufferedImage computeDiffImage(final DiffContext localCtx, + public static BufferedImage computeDiffImage(final DiffContext testCtx, + final DiffContext testThCtx, final BufferedImage tstImage, final BufferedImage refImage, - final BufferedImage diffImage, - final DiffContext globalCtx) { + final BufferedImage diffImage) { final int[] aRefPix = ((DataBufferInt) refImage.getRaster().getDataBuffer()).getData(); final int[] aTstPix = ((DataBufferInt) tstImage.getRaster().getDataBuffer()).getData(); final int[] aDifPix = ((DataBufferInt) diffImage.getRaster().getDataBuffer()).getData(); - // reset local diff context: - localCtx.reset(); + // reset diff contexts: + testCtx.reset(); + testThCtx.reset(); int ref, tst, dg, v; for (int i = 0, len = aRefPix.length; i < len; i++) { @@ -777,24 +1023,24 @@ public static BufferedImage computeDiffImage(final DiffContext localCtx, // max difference on grayscale values: v = (int) Math.ceil(Math.abs(dg / 3.0)); - -// TODO: count warnings if (v <= THRESHOLD_DELTA) { aDifPix[i] = 0; } else { aDifPix[i] = toInt(v, v, v); + testThCtx.add(v); + } - localCtx.add(v); + if (v != 0) { + testCtx.add(v); } - globalCtx.add(v); } - if (!localCtx.isDiff() || (localCtx.histPix.count <= THRESHOLD_NBPIX)) { + testCtx.addNbPix(testThCtx.histPix.count); + + if (!testThCtx.isDiff() || (testThCtx.histPix.count <= THRESHOLD_NBPIX)) { return null; } - localCtx.dump(); - return diffImage; } @@ -895,6 +1141,17 @@ void add(long val) { } } + void add(StatInteger stat) { + count += stat.count; + sum += stat.sum; + if (stat.min < min) { + min = stat.min; + } + if (stat.max > max) { + max = stat.max; + } + } + public final double average() { return ((double) sum) / count; } @@ -908,8 +1165,11 @@ public String toString() { public final StringBuilder toString(final StringBuilder sb) { sb.append(name).append("[n: ").append(count); - sb.append("] sum: ").append(sum).append(" avg: ").append(trimTo3Digits(average())); - sb.append(" [").append(min).append(" | ").append(max).append("]"); + sb.append("] "); + if (count != 0) { + sb.append("sum: ").append(sum).append(" avg: ").append(trimTo3Digits(average())); + sb.append(" [").append(min).append(" | ").append(max).append("]"); + } return sb; } @@ -921,6 +1181,7 @@ final static class Histogram extends StatInteger { static final int MAX = 20; static final int LAST = MAX - 1; static final int[] STEPS = new int[MAX]; + static final int BUCKET_TH; static { STEPS[0] = 0; @@ -930,6 +1191,12 @@ final static class Histogram extends StatInteger { STEPS[i] = STEPS[i - 1] * BUCKET; } // System.out.println("Histogram.STEPS = " + Arrays.toString(STEPS)); + + if (THRESHOLD_DELTA % 2 != 0) { + throw new IllegalStateException("THRESHOLD_DELTA must be odd"); + } + + BUCKET_TH = bucket(THRESHOLD_DELTA); } static int bucket(int val) { @@ -969,6 +1236,37 @@ final void add(long val) { add((int) val); } + void add(Histogram hist) { + super.add(hist); + for (int i = 0; i < MAX; i++) { + stats[i].add(hist.stats[i]); + } + } + + boolean isWorse(Histogram hist, boolean useTh) { + boolean worst = false; + if (!useTh && (hist.sum > sum)) { + worst = true; + } else { + long sumLoc = 0l; + long sumHist = 0l; + // use running sum: + for (int i = MAX - 1; i >= BUCKET_TH; i--) { + sumLoc += stats[i].sum; + sumHist += hist.stats[i].sum; + } + if (sumHist > sumLoc) { + worst = true; + } + } + /* + System.out.println("running sum worst:"); + System.out.println("this ? " + toString()); + System.out.println("worst ? " + hist.toString()); + */ + return worst; + } + @Override public final String toString() { final StringBuilder sb = new StringBuilder(2048); @@ -995,38 +1293,88 @@ static double trimTo3Digits(final double value) { static final class DiffContext { - public final Histogram histAll; public final Histogram histPix; + public final StatInteger nbPix; + DiffContext(String name) { - histAll = new Histogram("All Pixels [" + name + "]"); histPix = new Histogram("Diff Pixels [" + name + "]"); + nbPix = new StatInteger("NbPixels [" + name + "]"); } void reset() { - histAll.reset(); histPix.reset(); + nbPix.reset(); } void dump() { if (isDiff()) { - System.out.println("Differences [" + histAll.name + "]:"); - System.out.println("Total [all pixels]:\n" + histAll.toString()); - System.out.println("Total [different pixels]:\n" + histPix.toString()); + System.out.println("Differences [" + histPix.name + "]:\n" + + ((nbPix.count != 0) ? (nbPix.toString() + "\n") : "") + + histPix.toString() + ); } else { - System.out.println("No difference for [" + histAll.name + "]."); + System.out.println("No difference for [" + histPix.name + "]."); } } void add(int val) { - histAll.add(val); - if (val != 0) { - histPix.add(val); + histPix.add(val); + } + + void add(DiffContext ctx) { + histPix.add(ctx.histPix); + if (ctx.nbPix.count != 0L) { + nbPix.add(ctx.nbPix); } } + void addNbPix(long val) { + if (val != 0L) { + nbPix.add(val); + } + } + + void set(DiffContext ctx) { + reset(); + add(ctx); + } + + boolean isWorse(DiffContext ctx, boolean useTh) { + return histPix.isWorse(ctx.histPix, useTh); + } + boolean isDiff() { - return histAll.sum != 0l; + return histPix.sum != 0l; } } + + + static double linelen(final double x0, final double y0, + final double x1, final double y1) + { + final double dx = x1 - x0; + final double dy = y1 - y0; + return Math.sqrt(dx * dx + dy * dy); + } + + static double quadlen(final double x0, final double y0, + final double x1, final double y1, + final double x2, final double y2) + { + return (linelen(x0, y0, x1, y1) + + linelen(x1, y1, x2, y2) + + linelen(x0, y0, x2, y2)) / 2.0d; + } + + static double curvelen(final double x0, final double y0, + final double x1, final double y1, + final double x2, final double y2, + final double x3, final double y3) + { + return (linelen(x0, y0, x1, y1) + + linelen(x1, y1, x2, y2) + + linelen(x2, y2, x3, y3) + + linelen(x0, y0, x3, y3)) / 2.0d; + } } diff --git a/src/test/jdk/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java b/src/test/jdk/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java index b2769e2c02a..13949149647 100644 --- a/src/test/jdk/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java +++ b/src/test/jdk/sun/management/HotspotRuntimeMBean/GetTotalSafepointTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -40,47 +40,33 @@ public class GetTotalSafepointTime { private static HotspotRuntimeMBean mbean = (HotspotRuntimeMBean)ManagementFactoryHelper.getHotspotRuntimeMBean(); - private static final long NUM_THREAD_DUMPS = 100; - // Careful with these values. private static final long MIN_VALUE_FOR_PASS = 1; - private static final long MAX_VALUE_FOR_PASS = Long.MAX_VALUE; - private static boolean trace = false; + // Thread.getAllStackTraces() should cause safepoints. + // If this test is failing because it doesn't, + // MIN_VALUE_FOR_PASS should be reset to 0 + public static long executeThreadDumps(long initial_value) { + long value; + do { + Thread.getAllStackTraces(); + value = mbean.getTotalSafepointTime(); + } while (value == initial_value); + return value; + } public static void main(String args[]) throws Exception { - if (args.length > 0 && args[0].equals("trace")) { - trace = true; - } - - // Thread.getAllStackTraces() should cause safepoints. - // If this test is failing because it doesn't, - // MIN_VALUE_FOR_PASS should be reset to 0 - for (int i = 0; i < NUM_THREAD_DUMPS; i++) { - Thread.getAllStackTraces(); - } - - long value = mbean.getTotalSafepointTime(); + long value = executeThreadDumps(0); + System.out.println("Total safepoint time (ms): " + value); - if (trace) { - System.out.println("Total safepoint time (ms): " + value); - } - - if (value < MIN_VALUE_FOR_PASS || value > MAX_VALUE_FOR_PASS) { + if (value < MIN_VALUE_FOR_PASS) { throw new RuntimeException("Total safepoint time " + "illegal value: " + value + " ms " + - "(MIN = " + MIN_VALUE_FOR_PASS + "; " + - "MAX = " + MAX_VALUE_FOR_PASS + ")"); + "(MIN = " + MIN_VALUE_FOR_PASS + ")"); } - for (int i = 0; i < 2 * NUM_THREAD_DUMPS; i++) { - Thread.getAllStackTraces(); - } - long value2 = mbean.getTotalSafepointTime(); - - if (trace) { - System.out.println("Total safepoint time2 (ms): " + value2); - } + long value2 = executeThreadDumps(value); + System.out.println("Total safepoint time (ms): " + value2); if (value2 <= value) { throw new RuntimeException("Total safepoint time " + diff --git a/src/test/jdk/sun/net/www/protocol/http/TestTransparentNTLM.java b/src/test/jdk/sun/net/www/protocol/http/TestTransparentNTLM.java new file mode 100644 index 00000000000..0df834765c8 --- /dev/null +++ b/src/test/jdk/sun/net/www/protocol/http/TestTransparentNTLM.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8225425 + * @summary Verifies that transparent NTLM (on Windows) is not used by default, + * and is used only when the relevant property is set. + * @requires os.family == "windows" + * @library /test/lib + * @run testng/othervm + * -Dtest.auth.succeed=false + * TestTransparentNTLM + * @run testng/othervm + * -Djdk.http.ntlm.transparentAuth=allHosts + * -Dtest.auth.succeed=true + * TestTransparentNTLM + * @run testng/othervm + * -Djdk.http.ntlm.transparentAuth=blahblah + * -Dtest.auth.succeed=false + * TestTransparentNTLM + * @run testng/othervm + * -Djdk.http.ntlm.transparentAuth=trustedHosts + * -Dtest.auth.succeed=false + * TestTransparentNTLM + */ + +// Run with `trustedHosts` to exercise the native code, nothing more. + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URL; +import jdk.test.lib.net.URIBuilder; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; +import org.testng.SkipException; +import static java.lang.System.out; +import static java.net.Proxy.NO_PROXY; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +public class TestTransparentNTLM { + + boolean succeed; // true if authentication is expected to succeed + Server server; + URL url; + + @Test + public void testNTLM() throws IOException { + out.println("connecting to url: " + url); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(NO_PROXY); + int respCode = uc.getResponseCode(); + out.println("received: " + respCode); + + if (succeed) { + assertEquals(respCode, HttpURLConnection.HTTP_OK); + String body = new String(uc.getInputStream().readAllBytes(), UTF_8); + out.println("received body: " + body); + } else { + assertEquals(respCode, HttpURLConnection.HTTP_UNAUTHORIZED); + } + } + + static class Server extends Thread implements Closeable { + + static final InetAddress LOOPBACK = InetAddress.getLoopbackAddress(); + final ServerSocket serverSocket; + final boolean expectAuthToSucceed; + + Server(boolean expectAuthToSucceed) throws IOException { + super("TestTransparentNTLM-Server"); + serverSocket = new ServerSocket(); + serverSocket.bind(new InetSocketAddress(LOOPBACK, 0)); + this.expectAuthToSucceed = expectAuthToSucceed; + } + + int port() { + return serverSocket.getLocalPort(); + } + + static final String AUTH_REQUIRED = + "HTTP/1.1 401 Unauthorized\r\n" + + "Content-Length: 0\r\n" + + "Connection: close\r\n" + + "WWW-Authenticate: NTLM\r\n\r\n"; + + static final String AUTH_STAGE_TWO = + "HTTP/1.1 401 Unauthorized\r\n" + + "Content-Length: 0\r\n" + + "WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAAAAACgAAAABggAAU3J2Tm9uY2UAAAAAAAAAAA==\r\n\r\n"; + + static final String AUTH_SUCCESSFUL = + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 11\r\n\r\n" + + "Hello world"; + + @Override + public void run() { + try { + try (Socket s = serverSocket.accept()) { + out.println("Server accepted connection - 1"); + readRequestHeaders(s.getInputStream()); + s.getOutputStream().write(AUTH_REQUIRED.getBytes(UTF_8)); + } + + if (expectAuthToSucceed) { + // await the second follow up connection + try (Socket s = serverSocket.accept()) { + out.println("Server accepted connection - 2"); + readRequestHeaders(s.getInputStream()); + s.getOutputStream().write(AUTH_STAGE_TWO.getBytes(UTF_8)); + readRequestHeaders(s.getInputStream()); + s.getOutputStream().write(AUTH_SUCCESSFUL.getBytes(UTF_8)); + } + } + } catch (IOException e) { + fail("Unexpected exception", e); + } + } + + @Override + public void close() throws IOException { + serverSocket.close(); + } + + static final byte[] REQUEST_END = new byte[] {'\r', '\n', '\r', '\n'}; + + // Read until the end of the HTTP request headers + static void readRequestHeaders(InputStream is) throws IOException { + int requestEndCount = 0, r; + while ((r = is.read()) != -1) { + if (r == REQUEST_END[requestEndCount]) { + requestEndCount++; + if (requestEndCount == 4) { + break; + } + } else { + requestEndCount = 0; + } + } + } + } + + @BeforeTest + public void setup() throws Exception { + succeed = System.getProperty("test.auth.succeed").equals("true"); + if (succeed) + out.println("Expect client to succeed, with 200 Ok"); + else + out.println("Expect client to fail, with 401 Unauthorized"); + + server = new Server(succeed); + server.start(); + url = URIBuilder.newBuilder() + .scheme("http") + .loopback() + .port(server.port()) + .path("/xxyyzz") + .toURL(); + } + + @AfterTest + public void teardown() throws Exception { + server.close(); + server.join(); + } +} diff --git a/src/test/jdk/sun/security/ec/SignatureDigestTruncate.java b/src/test/jdk/sun/security/ec/SignatureDigestTruncate.java new file mode 100644 index 00000000000..aa58a9b7169 --- /dev/null +++ b/src/test/jdk/sun/security/ec/SignatureDigestTruncate.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.Convert; + +import java.security.*; +import java.security.spec.*; +import java.math.*; +import java.util.*; + +/* + * @test + * @bug 8147502 + * @summary Test that digests are properly truncated before the signature + * is applied. The digest should be truncated to the bit length of the + * group order. + * @library /test/lib + * @build jdk.test.lib.Convert + * @run main SignatureDigestTruncate + */ +public class SignatureDigestTruncate { + + /* + * A SecureRandom that produces nextBytes in a way that causes the nonce + * to be set to the value supplied to the constructor. This class + * is specific to the way that the native ECDSA implementation in + * SunEC produces nonces from random input. It may not work for all + * test cases, and it will need to be updated when the behavior of + * SunEC changes. + */ + private static class FixedRandom extends SecureRandom { + + private final byte[] val; + + public FixedRandom(byte[] val) { + // SunEC adds one to the value returned, so subtract one here in + // order to get back to the correct value. + BigInteger biVal = new BigInteger(1, val); + biVal = biVal.subtract(BigInteger.ONE); + byte[] temp = biVal.toByteArray(); + this.val = new byte[val.length]; + int inStartPos = Math.max(0, temp.length - val.length); + int outStartPos = Math.max(0, val.length - temp.length); + System.arraycopy(temp, inStartPos, this.val, outStartPos, + temp.length - inStartPos); + } + + @Override + public void nextBytes(byte[] bytes) { + // SunEC samples (n + 1) * 2 bytes, but only n*2 bytes are used by + // the native implementation. So the value must be offset slightly. + Arrays.fill(bytes, (byte) 0); + int copyLength = Math.min(val.length, bytes.length - 2); + System.arraycopy(val, 0, bytes, bytes.length - copyLength - 2, + copyLength); + } + } + + private static void assertEquals(byte[] expected, byte[] actual, + String name) { + if (!Arrays.equals(actual, expected)) { + System.out.println("expect: " + + Convert.byteArrayToHexString(expected)); + System.out.println("actual: " + + Convert.byteArrayToHexString(actual)); + throw new RuntimeException("Incorrect " + name + " value"); + } + } + + private static void runTest(String alg, String curveName, + String privateKeyStr, String msgStr, String kStr, String sigStr) + throws Exception { + + byte[] privateKey = Convert.hexStringToByteArray(privateKeyStr); + byte[] msg = Convert.hexStringToByteArray(msgStr); + byte[] k = Convert.hexStringToByteArray(kStr); + byte[] expectedSig = Convert.hexStringToByteArray(sigStr); + + AlgorithmParameters params = AlgorithmParameters.getInstance("EC"); + params.init(new ECGenParameterSpec(curveName)); + ECParameterSpec ecParams = + params.getParameterSpec(ECParameterSpec.class); + + KeyFactory kf = KeyFactory.getInstance("EC"); + BigInteger s = new BigInteger(1, privateKey); + ECPrivateKeySpec privKeySpec = new ECPrivateKeySpec(s, ecParams); + PrivateKey privKey = kf.generatePrivate(privKeySpec); + + Signature sig = Signature.getInstance(alg); + sig.initSign(privKey, new FixedRandom(k)); + sig.update(msg); + byte[] computedSig = sig.sign(); + assertEquals(expectedSig, computedSig, "signature"); + } + + public static void main(String[] args) throws Exception { + runTest("SHA384withECDSAinP1363Format", "sect283r1", + "abcdef10234567", "010203040506070809", + "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d" + + "1e1f20212223", + "01d7544b5d3935216bd45e2f8042537e1e0296a11e0eb96666199281b409" + + "42abccd5358a035de8a314d3e6c2a97614daebf5fb1313540eec3f9a3272" + + "068aa10922ccae87d255c84c"); + } +} diff --git a/src/test/jdk/sun/security/pkcs11/PKCS11Test.java b/src/test/jdk/sun/security/pkcs11/PKCS11Test.java index 3259663051e..e0ba86f3061 100644 --- a/src/test/jdk/sun/security/pkcs11/PKCS11Test.java +++ b/src/test/jdk/sun/security/pkcs11/PKCS11Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -366,11 +366,14 @@ protected static void safeReload(String lib) throws Exception { static boolean loadNSPR(String libdir) throws Exception { // load NSS softoken dependencies in advance to avoid resolver issues - safeReload(libdir + System.mapLibraryName("nspr4")); - safeReload(libdir + System.mapLibraryName("plc4")); - safeReload(libdir + System.mapLibraryName("plds4")); - safeReload(libdir + System.mapLibraryName("sqlite3")); - safeReload(libdir + System.mapLibraryName("nssutil3")); + String dir = libdir.endsWith(File.separator) + ? libdir + : libdir + File.separator; + safeReload(dir + System.mapLibraryName("nspr4")); + safeReload(dir + System.mapLibraryName("plc4")); + safeReload(dir + System.mapLibraryName("plds4")); + safeReload(dir + System.mapLibraryName("sqlite3")); + safeReload(dir + System.mapLibraryName("nssutil3")); return true; } @@ -886,21 +889,21 @@ private static String fetchNssLib(Class<?> clazz) { @Artifact( organization = "jpg.tests.jdk.nsslib", name = "nsslib-windows_x64", - revision = "3.35", + revision = "3.41-VS2017", extension = "zip") private static class WINDOWS_X64 { } @Artifact( organization = "jpg.tests.jdk.nsslib", name = "nsslib-windows_x86", - revision = "3.35", + revision = "3.41-VS2017", extension = "zip") private static class WINDOWS_X86 { } @Artifact( organization = "jpg.tests.jdk.nsslib", name = "nsslib-macosx_x64", - revision = "3.35", + revision = "3.41", extension = "zip") private static class MACOSX_X64 { } } diff --git a/src/test/jdk/sun/security/pkcs11/fips/TestTLS12.java b/src/test/jdk/sun/security/pkcs11/fips/TestTLS12.java index 73f9fb10b88..47655d8d44e 100644 --- a/src/test/jdk/sun/security/pkcs11/fips/TestTLS12.java +++ b/src/test/jdk/sun/security/pkcs11/fips/TestTLS12.java @@ -376,15 +376,20 @@ private static void runDelegatedTasks(SSLEngineResult result, private static SSLEngine[][] getSSLEnginesToTest() throws Exception { SSLEngine[][] enginesToTest = new SSLEngine[2][2]; + // TLS_RSA_WITH_AES_128_GCM_SHA256 ciphersuite is available but + // must not be chosen for the TLS connection if not supported. + // See JDK-8222937. String[][] preferredSuites = new String[][]{ new String[] { + "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256" }, new String[] { + "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" }}; for (int i = 0; i < enginesToTest.length; i++) { enginesToTest[i][0] = createSSLEngine(true); enginesToTest[i][1] = createSSLEngine(false); - enginesToTest[i][0].setEnabledCipherSuites(preferredSuites[i]); + // All CipherSuites enabled for the client. enginesToTest[i][1].setEnabledCipherSuites(preferredSuites[i]); } return enginesToTest; diff --git a/src/test/jdk/sun/security/ssl/SSLSessionContextImpl/DefautlCacheSize.java b/src/test/jdk/sun/security/ssl/SSLSessionContextImpl/DefautlCacheSize.java new file mode 100644 index 00000000000..184db8f9304 --- /dev/null +++ b/src/test/jdk/sun/security/ssl/SSLSessionContextImpl/DefautlCacheSize.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8210985 + * @summary Update the default SSL session cache size to 20480 + * @run main/othervm DefautlCacheSize + */ + +// The SunJSSE provider cannot use System Properties in samevm/agentvm mode. +// Please run JSSE test in othervm mode. + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSessionContext; + +public class DefautlCacheSize { + + public static void main(String[] args) throws Exception { + SSLServerSocketFactory sssf = + (SSLServerSocketFactory)SSLServerSocketFactory.getDefault(); + + try (SSLServerSocket serverSocket = + (SSLServerSocket)sssf.createServerSocket()) { + + String[] protocols = serverSocket.getSupportedProtocols(); + for (int i = 0; i < protocols.length; i++) { + if (protocols[i].equals("SSLv2Hello")) { + continue; + } + SSLContext sslContext = SSLContext.getInstance(protocols[i]); + SSLSessionContext sessionContext = + sslContext.getServerSessionContext(); + if (sessionContext.getSessionCacheSize() == 0) { + throw new Exception( + "the default server session cache size is infinite"); + } + + sessionContext = sslContext.getClientSessionContext(); + if (sessionContext.getSessionCacheSize() == 0) { + throw new Exception( + "the default client session cache size is infinite"); + } + } + } + } +} diff --git a/src/test/jdk/sun/security/tools/keytool/pss/PSS.java b/src/test/jdk/sun/security/tools/keytool/pss/PSS.java new file mode 100644 index 00000000000..858aacda212 --- /dev/null +++ b/src/test/jdk/sun/security/tools/keytool/pss/PSS.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8215694 8222987 8225257 + * @summary keytool cannot generate RSASSA-PSS certificates + * @library /test/lib + * @build java.base/sun.security.rsa.RSAKeyPairGenerator + * @modules java.base/sun.security.util + * java.base/sun.security.x509 + * @requires os.family != "solaris" + * @run main PSS + */ + +// This test is excluded from Solaris because the 8192-bit RSA key pair +// generator is extremely slow there. + +import jdk.test.lib.Asserts; +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.security.DerUtils; +import sun.security.util.ObjectIdentifier; +import sun.security.x509.AlgorithmId; + +import java.io.File; +import java.security.KeyStore; +import java.security.cert.X509Certificate; + +public class PSS { + + public static void main(String[] args) throws Exception { + + genkeypair("p", "-keyalg RSASSA-PSS -sigalg RSASSA-PSS") + .shouldHaveExitValue(0); + + genkeypair("a", "-keyalg RSA -sigalg RSASSA-PSS -keysize 2048") + .shouldHaveExitValue(0); + + genkeypair("b", "-keyalg RSA -sigalg RSASSA-PSS -keysize 4096") + .shouldHaveExitValue(0); + + genkeypair("c", "-keyalg RSA -sigalg RSASSA-PSS -keysize 8192") + .shouldHaveExitValue(0); + + KeyStore ks = KeyStore.getInstance( + new File("ks"), "changeit".toCharArray()); + + check((X509Certificate)ks.getCertificate("p"), "RSASSA-PSS", + AlgorithmId.SHA256_oid); + + check((X509Certificate)ks.getCertificate("a"), "RSA", + AlgorithmId.SHA256_oid); + + check((X509Certificate)ks.getCertificate("b"), "RSA", + AlgorithmId.SHA384_oid); + + check((X509Certificate)ks.getCertificate("c"), "RSA", + AlgorithmId.SHA512_oid); + + // More commands + kt("-certreq -alias p -sigalg RSASSA-PSS -file p.req") + .shouldHaveExitValue(0); + + kt("-gencert -alias a -sigalg RSASSA-PSS -infile p.req -outfile p.cert") + .shouldHaveExitValue(0); + + kt("-importcert -alias p -file p.cert") + .shouldHaveExitValue(0); + + kt("-selfcert -alias p -sigalg RSASSA-PSS") + .shouldHaveExitValue(0); + } + + static OutputAnalyzer genkeypair(String alias, String options) + throws Exception { + String patchArg = "-J--patch-module=java.base=" + System.getProperty("test.classes") + + File.separator + "patches" + File.separator + "java.base"; + return kt(patchArg + " -genkeypair -alias " + alias + + " -dname CN=" + alias + " " + options); + } + + static OutputAnalyzer kt(String cmd) + throws Exception { + return SecurityTools.keytool("-storepass changeit -keypass changeit " + + "-keystore ks " + cmd); + } + + static void check(X509Certificate cert, String expectedKeyAlg, + ObjectIdentifier expectedMdAlg) throws Exception { + Asserts.assertEQ(cert.getPublicKey().getAlgorithm(), expectedKeyAlg); + Asserts.assertEQ(cert.getSigAlgName(), "RSASSA-PSS"); + DerUtils.checkAlg(cert.getSigAlgParams(), "000", expectedMdAlg); + } +} diff --git a/src/test/jdk/sun/security/tools/keytool/pss/java.base/sun/security/rsa/RSAKeyPairGenerator.java b/src/test/jdk/sun/security/tools/keytool/pss/java.base/sun/security/rsa/RSAKeyPairGenerator.java new file mode 100644 index 00000000000..d73308f8727 --- /dev/null +++ b/src/test/jdk/sun/security/tools/keytool/pss/java.base/sun/security/rsa/RSAKeyPairGenerator.java @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.security.rsa; + +import java.math.BigInteger; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.RSAKeyGenParameterSpec; + +import sun.security.jca.JCAUtil; +import sun.security.x509.AlgorithmId; +import static sun.security.rsa.RSAUtil.KeyType; + +/** + * Fake RSA keypair generation. + */ +public abstract class RSAKeyPairGenerator extends KeyPairGeneratorSpi { + + // public exponent to use + private BigInteger publicExponent; + + // size of the key to generate, >= RSAKeyFactory.MIN_MODLEN + private int keySize; + + private final KeyType type; + private AlgorithmId rsaId; + + RSAKeyPairGenerator(KeyType type, int defKeySize) { + this.type = type; + // initialize to default in case the app does not call initialize() + initialize(defKeySize, null); + } + + // initialize the generator. See JCA doc + public void initialize(int keySize, SecureRandom random) { + try { + initialize(new RSAKeyGenParameterSpec(keySize, + RSAKeyGenParameterSpec.F4), random); + } catch (InvalidAlgorithmParameterException iape) { + throw new InvalidParameterException(iape.getMessage()); + } + } + + // second initialize method. See JCA doc. + public void initialize(AlgorithmParameterSpec params, SecureRandom random) + throws InvalidAlgorithmParameterException { + if (params instanceof RSAKeyGenParameterSpec == false) { + throw new InvalidAlgorithmParameterException + ("Params must be instance of RSAKeyGenParameterSpec"); + } + + RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec)params; + int tmpKeySize = rsaSpec.getKeysize(); + BigInteger tmpPublicExponent = rsaSpec.getPublicExponent(); + AlgorithmParameterSpec tmpParams = rsaSpec.getKeyParams(); + + if (tmpPublicExponent == null) { + tmpPublicExponent = RSAKeyGenParameterSpec.F4; + } else { + if (tmpPublicExponent.compareTo(RSAKeyGenParameterSpec.F0) < 0) { + throw new InvalidAlgorithmParameterException + ("Public exponent must be 3 or larger"); + } + if (tmpPublicExponent.bitLength() > tmpKeySize) { + throw new InvalidAlgorithmParameterException + ("Public exponent must be smaller than key size"); + } + } + + // do not allow unreasonably large key sizes, probably user error + try { + RSAKeyFactory.checkKeyLengths(tmpKeySize, tmpPublicExponent, + 512, 64 * 1024); + } catch (InvalidKeyException e) { + throw new InvalidAlgorithmParameterException( + "Invalid key sizes", e); + } + + try { + this.rsaId = RSAUtil.createAlgorithmId(type, tmpParams); + } catch (ProviderException e) { + throw new InvalidAlgorithmParameterException( + "Invalid key parameters", e); + } + + this.keySize = tmpKeySize; + this.publicExponent = tmpPublicExponent; + } + + // generate the keypair. See JCA doc + public KeyPair generateKeyPair() { + + // accommodate odd key sizes in case anybody wants to use them + BigInteger e = publicExponent; + if (!e.equals(RSAKeyGenParameterSpec.F4)) { + throw new AssertionError("Only support F4 now"); + } + BigInteger p, q, n; + + // Pre-calculated p and q for e == RSAKeyGenParameterSpec.F4 + switch (keySize) { + case 2048: + p = new BigInteger("1600840041787354447543653385760927" + + "2642568308955833364523274045522752644800599" + + "8669541532595690224703734511692014533312515" + + "1867029838883431415692353449578487671384896" + + "6611685764860941767986520897595108597563035" + + "4023785639802607792535812062420427283857665" + + "9883578590844700707106157871508280052743363" + + "65749456332400771"); + q = new BigInteger("1303880717101677622201474394769850" + + "7257196073324816341282215626935164930077468" + + "5999131251387556761167658937349436378464220" + + "4831804147777472146628148336776639855791417" + + "3849903041999943901924899580268176393595653" + + "7357080543898614581363167420619163047562600" + + "6155574020606891195960345238780709194499010" + + "43652862954645301"); + break; + case 4096: + p = new BigInteger("2985635754414679487171962796211911" + + "1563710734938215274736352092606404045130913" + + "2477365484439939846705721840432140066578525" + + "0762327458086280430118434094733412377416194" + + "8736124795243564050755767519346747209606612" + + "5835460937739428885308798309679495432910469" + + "0294757621321446003970767164933974474924664" + + "1513767092845098947552598109657871041666676" + + "2945573325433283821164032766425479703026349" + + "9433641551427112483593214628620450175257586" + + "4350119143877183562692754400346175237007314" + + "7121580349193179272551363894896336921717843" + + "3734726842184251708799134654802475890197293" + + "9094908310578403843742664173424031260840446" + + "591633359364559754200663"); + q = new BigInteger("2279248439141087793789384816271625" + + "1304008816573950275844533962181244003563987" + + "6638461665174020058827698592331066726709304" + + "9231319346136709972639455506783245161859951" + + "6191872757335765533547033659834427437142631" + + "3801232751161907082392011429712327250253948" + + "6012497852063361866175243227579880020724881" + + "9393797645220239009219998518884396282407710" + + "7199202450846395844337846503427790307364624" + + "5124871273035872938616425951596065309519651" + + "1519189356431513094684173807318945903212527" + + "7712469749366620048658571121822171067675915" + + "5479178304648399924549334007222294762969503" + + "5341584429803583589276956979963609078497238" + + "760757619468018224491053"); + break; + case 8192: + p = new BigInteger("9821669838446774374944535804569858" + + "0553278885576950130485823829973470553571905" + + "3014418421996241500307589880457361653957913" + + "9176499436767288125182942994089196450118944" + + "8701794862752733776161684616570463744619126" + + "4981622564763630694110472008409561205704867" + + "0221819623405201369630462487520858670679048" + + "5854008441429858453634949980424333056803703" + + "1205609490778445762604050796894221725977551" + + "1428887194691696420765173256600200430067305" + + "4364524177041858044598166859757042904625691" + + "4292728453597609683799189454690202563236931" + + "8171122071288244573793276051041975005528757" + + "0228306442708182141334279133965507583927772" + + "9244311696220253059281524393613278272067808" + + "7017494446447670799055720358621918361716353" + + "5018317015764698318012095108914870478138809" + + "8204738169777192718869484177321870413838036" + + "8149216482968887382371881239714335470844573" + + "1862934371951394070111726593305334971041399" + + "5517260339034138718517336990212463882142363" + + "9154412320743552301967162100734381046548816" + + "3883737645359595416600487444018399886391071" + + "3777667222706059170707223589163679915863781" + + "4662302526078720977228426750718207481384357" + + "7918717041190413457052439016978578217755022" + + "7370720979516554707297685239584071755267452" + + "6021894842754355160100506065457679069228273" + + "95209345267367982516553449135291473361"); + q = new BigInteger("7902448465953646210110784092684896" + + "0265474424590294110174550047938700740921014" + + "1981650823416127449143596912363210790070524" + + "2903784112701128957948996730263815210531364" + + "0489145287401377007608600217628773627723381" + + "1194123533939872283952535576847014977682278" + + "9332064706645169741712060131540562788886577" + + "3762235020990267901959745687867018811088495" + + "3716021011509120447248882358515954471433808" + + "2782236662758287959413069553620728137831579" + + "2321174813204514354999978428741310035945405" + + "0226661395731921098764192439072425262100813" + + "9732949866553839713092238096261034339815187" + + "2832617055364163276140160068136296115910569" + + "9466440903693740716929166334256441926903849" + + "1082968246155177124035336609654226388424434" + + "5775783323612758615407928446164631651292743" + + "8428509642959278732826297890909454571009075" + + "7836191622138731918099379467912681177757761" + + "6141378131042432093843778753846726589215845" + + "7402160146427434508515156204064224022904659" + + "8645441448874409852211668374267341177082462" + + "7341410218867175406105046487057429530801973" + + "0931082058719258230993681115780999537424968" + + "2385515792331573549935317407789344892257264" + + "7464569110078675090194686816764429827739815" + + "0566036514181547634372488184242167294602000" + + "8232780963578241583529875079397308150506597" + + "37190564909892937290776929541076192569"); + break; + default: + throw new AssertionError("Unknown keySize " + keySize); + } + + n = p.multiply(q); + + // phi = (p - 1) * (q - 1) must be relative prime to e + // otherwise RSA just won't work ;-) + BigInteger p1 = p.subtract(BigInteger.ONE); + BigInteger q1 = q.subtract(BigInteger.ONE); + BigInteger phi = p1.multiply(q1); + // generate new p and q until they work. typically + // the first try will succeed when using F4 + if (e.gcd(phi).equals(BigInteger.ONE) == false) { + throw new AssertionError("Should not happen"); + } + + // private exponent d is the inverse of e mod phi + BigInteger d = e.modInverse(phi); + + // 1st prime exponent pe = d mod (p - 1) + BigInteger pe = d.mod(p1); + // 2nd prime exponent qe = d mod (q - 1) + BigInteger qe = d.mod(q1); + + // crt coefficient coeff is the inverse of q mod p + BigInteger coeff = q.modInverse(p); + + try { + PublicKey publicKey = new RSAPublicKeyImpl(rsaId, n, e); + PrivateKey privateKey = new RSAPrivateCrtKeyImpl( + rsaId, n, e, d, p, q, pe, qe, coeff); + return new KeyPair(publicKey, privateKey); + } catch (InvalidKeyException exc) { + // invalid key exception only thrown for keys < 512 bit, + // will not happen here + throw new RuntimeException(exc); + } + } +} diff --git a/src/test/jdk/sun/security/util/FilePermCompat/Flag.java b/src/test/jdk/sun/security/util/FilePermCompat/Flag.java index dab4cff5b14..00c7fbc2677 100644 --- a/src/test/jdk/sun/security/util/FilePermCompat/Flag.java +++ b/src/test/jdk/sun/security/util/FilePermCompat/Flag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,22 +23,84 @@ /* * @test - * @bug 8164705 + * @bug 8164705 8209901 + * @library /test/jdk/java/security/testlibrary + * @modules java.base/jdk.internal.misc * @summary check jdk.filepermission.canonicalize - * @run main/othervm/policy=flag.policy - * -Djdk.io.permissionsUseCanonicalPath=true Flag true true - * @run main/othervm/policy=flag.policy - * -Djdk.io.permissionsUseCanonicalPath=false Flag false true - * @run main/othervm/policy=flag.policy Flag false true */ import java.io.File; import java.io.FilePermission; import java.lang.*; +import java.nio.file.Path; public class Flag { public static void main(String[] args) throws Exception { + if (args.length == 0) { + String policy = Path.of( + System.getProperty("test.src"), "flag.policy").toString(); + + // effectively true + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .prop("jdk.io.permissionsUseCanonicalPath", "true") + .args("run", "true", "true") + .start() + .waitFor(0); + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .secprop("jdk.io.permissionsUseCanonicalPath", "true") + .args("run", "true", "true") + .start() + .waitFor(0); + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .secprop("jdk.io.permissionsUseCanonicalPath", "false") + .prop("jdk.io.permissionsUseCanonicalPath", "true") + .args("run", "true", "true") + .start() + .waitFor(0); + + // effectively false + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .prop("jdk.io.permissionsUseCanonicalPath", "false") + .args("run", "false", "true") + .start() + .waitFor(0); + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .secprop("jdk.io.permissionsUseCanonicalPath", "false") + .args("run", "false", "true") + .start() + .waitFor(0); + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .secprop("jdk.io.permissionsUseCanonicalPath", "true") + .prop("jdk.io.permissionsUseCanonicalPath", "false") + .args("run", "false", "true") + .start() + .waitFor(0); + Proc.create("Flag") + .prop("java.security.manager", "") + .prop("java.security.policy", policy) + .args("run", "false", "true") + .start() + .waitFor(0); + } else { + run(args); + } + } + + static void run(String[] args) throws Exception { + boolean test1; boolean test2; @@ -55,8 +117,8 @@ public static void main(String[] args) throws Exception { test2 = false; } - if (test1 != Boolean.parseBoolean(args[0]) || - test2 != Boolean.parseBoolean(args[1])) { + if (test1 != Boolean.parseBoolean(args[1]) || + test2 != Boolean.parseBoolean(args[2])) { throw new Exception("Test failed: " + test1 + " " + test2); } } diff --git a/src/test/jdk/sun/security/util/RegisteredDomain/Versions.java b/src/test/jdk/sun/security/util/RegisteredDomain/Versions.java new file mode 100644 index 00000000000..8bf39468770 --- /dev/null +++ b/src/test/jdk/sun/security/util/RegisteredDomain/Versions.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8221801 + * @library /test/lib + * @summary Update src/java.base/share/legal/public_suffix.md + */ + +import jdk.test.lib.Asserts; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Versions { + + public static void main(String[] args) throws Exception { + + Path root = Path.of(System.getProperty("test.root")); + Path jdk = Path.of(System.getProperty("test.jdk")); + + Path version = root.resolve("../../make/data/publicsuffixlist/VERSION"); + Path mdSrc = root.resolve("../../src/java.base/share/legal/public_suffix.md"); + Path mdImage = jdk.resolve("legal/java.base/public_suffix.md"); + + // Files in src should either both exist or not + if (!Files.exists(version) && !Files.exists(mdSrc)) { + System.out.println("Source not available. Cannot proceed."); + return; + } + + String s1 = findURL(version); + String s2 = findURL(mdSrc); + + Asserts.assertEQ(s1, s2); + + String s3 = findURL(mdImage); + Asserts.assertEQ(s2, s3); + } + + static Pattern URL_PATTERN = Pattern.compile( + "(https://raw.githubusercontent.com.*?public_suffix_list.dat)"); + + static String findURL(Path p) throws IOException { + return Files.lines(p) + .map(Versions::matchURL) + .filter(Objects::nonNull) + .findFirst() + .orElseThrow(); + } + + static String matchURL(String input) { + Matcher m = URL_PATTERN.matcher(input); + return m.find() ? m.group(1) : null; + } +} diff --git a/src/test/jdk/sun/security/util/misc/SetNullSigParams.java b/src/test/jdk/sun/security/util/misc/SetNullSigParams.java new file mode 100644 index 00000000000..df95aa28a8c --- /dev/null +++ b/src/test/jdk/sun/security/util/misc/SetNullSigParams.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8214096 8216039 + * @summary Make sure SignatureUtil works with null algorithm parameters + * @modules java.base/sun.security.util + */ +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; +import sun.security.util.SignatureUtil; + +public class SetNullSigParams { + + public static void main(String[] args) throws Exception { + Signature sig = new SpecialSigImpl(); + SignatureUtil.initVerifyWithParam(sig, (PublicKey) null, null); + SignatureUtil.initSignWithParam(sig, null, null, null); + } + + // Sample Signature impl class which simulates 3rd party provider behavior + // and throws NPE when given null algorithm parameters + // For max backward-compatibility, sun.security.util.SignatureUtil class + // now calls setParameter() only when algorithm parameters is non-null + private static class SpecialSigImpl extends Signature { + SpecialSigImpl() { + super("ANY"); + } + @Override + protected void engineInitVerify(PublicKey publicKey) + throws InvalidKeyException {} + @Override + protected void engineInitSign(PrivateKey privateKey) + throws InvalidKeyException {} + @Override + protected void engineUpdate(byte b) throws SignatureException {} + @Override + protected void engineUpdate(byte[] b, int off, int len) + throws SignatureException {} + @Override + protected byte[] engineSign() throws SignatureException { return null; } + @Override + protected boolean engineVerify(byte[] sigBytes) + throws SignatureException { return false; } + @Override + protected void engineSetParameter(String param, Object value) + throws InvalidParameterException {} + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params == null) throw new NullPointerException("Test Failed"); + } + @Override + protected Object engineGetParameter(String param) + throws InvalidParameterException { return null; } + } +} diff --git a/src/test/jdk/sun/text/resources/LocaleData b/src/test/jdk/sun/text/resources/LocaleData index 925bc11dd71..b71bc3ac9ef 100644 --- a/src/test/jdk/sun/text/resources/LocaleData +++ b/src/test/jdk/sun/text/resources/LocaleData @@ -614,8 +614,6 @@ FormatData/es_PE/DatePatterns/1=d' de 'MMMM' de 'yyyy FormatData/es_PE/DatePatterns/2=dd/MM/yyyy FormatData/es_PE/DatePatterns/3=dd/MM/yy FormatData/es_PE/DateTimePatterns/0={1} {0} -FormatData/es_PE/NumberElements/0=, -FormatData/es_PE/NumberElements/1=. FormatData/es_PE/NumberElements/2=; FormatData/es_PR/NumberPatterns/0=#,##0.###;-#,##0.### # FormatData/es_PR/NumberPatterns/1=$#,##0.00;($#,##0.00) # Changed; see bug 4122840 @@ -8323,3 +8321,8 @@ CurrencyNames//mru=Mauritanian Ouguiya # bug #8208746 CurrencyNames//ves=Venezuelan Bol\u00edvar Soberano + +# bug# 8206879 +# For Peru decimal separator is changed to dot(.) and grouping separator is changed to comma(,) +FormatData/es_PE/NumberElements/0=. +FormatData/es_PE/NumberElements/1=, diff --git a/src/test/jdk/sun/tools/jcmd/TestProcess.java b/src/test/jdk/sun/tools/jcmd/TestProcess.java new file mode 100644 index 00000000000..873fdde8ab1 --- /dev/null +++ b/src/test/jdk/sun/tools/jcmd/TestProcess.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test; + +public class TestProcess { + + public static void main(String[] args) throws Exception { + System.out.print("The process started, pid:" + ProcessHandle.current().pid()); + while(true) { + Thread.sleep(100); + } + } +} diff --git a/src/test/jdk/sun/tools/jcmd/TestProcessHelper.java b/src/test/jdk/sun/tools/jcmd/TestProcessHelper.java new file mode 100644 index 00000000000..debaffaf234 --- /dev/null +++ b/src/test/jdk/sun/tools/jcmd/TestProcessHelper.java @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.util.JarUtils; +import sun.tools.common.ProcessHelper; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.module.ModuleDescriptor; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/* + * @test + * @bug 8205654 + * @summary Unit test for sun.tools.ProcessHelper class. The test launches Java processes with different Java options + * and checks that sun.tools.ProcessHelper.getMainClass(pid) method returns a correct main class. return a . + * + * @requires os.family == "linux" + * @library /test/lib + * @modules jdk.jcmd/sun.tools.common + * java.base/jdk.internal.module + * @build test.TestProcess + * @run main/othervm TestProcessHelper + */ +public class TestProcessHelper { + + private ProcessHelper PROCESS_HELPER = ProcessHelper.platformProcessHelper(); + + private static final String TEST_PROCESS_MAIN_CLASS_NAME = "TestProcess"; + private static final String TEST_PROCESS_MAIN_CLASS_PACKAGE = "test"; + private static final String TEST_PROCESS_MAIN_CLASS = TEST_PROCESS_MAIN_CLASS_PACKAGE + "." + + TEST_PROCESS_MAIN_CLASS_NAME; + private static final Path TEST_CLASSES = FileSystems.getDefault().getPath(System.getProperty("test.classes")); + private static final Path USER_DIR = FileSystems.getDefault().getPath(System.getProperty("user.dir", ".")); + private static final Path TEST_MODULES = USER_DIR.resolve("testmodules"); + private static final String JAVA_PATH = JDKToolFinder.getJDKTool("java"); + private static final Path TEST_CLASS = TEST_CLASSES.resolve(TEST_PROCESS_MAIN_CLASS_PACKAGE) + .resolve(TEST_PROCESS_MAIN_CLASS_NAME + ".class"); + + private static final String[] CP_OPTIONS = {"-cp", "-classpath", "--class-path"}; + private static final String[][] VM_ARGS = {{}, {"-Dtest1=aaa"}, {"-Dtest1=aaa", "-Dtest2=bbb ccc"}}; + private static final String[][] ARGS = {{}, {"param1"}, {"param1", "param2"}}; + private static final String[] MP_OPTIONS = {"-p", "--module-path"}; + private static final String[] MODULE_OPTIONS = {"-m", "--module", "--module="}; + private static final String JAR_OPTION = "-jar"; + private static final String MODULE_NAME = "module1"; + private static final String[][] EXTRA_MODULAR_OPTIONS = {null, + {"--add-opens", "java.base/java.net=ALL-UNNAMED"}, + {"--add-exports", "java.base/java.net=ALL-UNNAMED"}, + {"--add-reads", "java.base/java.net=ALL-UNNAMED"}, + {"--add-modules", "java.management"}, + {"--limit-modules", "java.management"}, + {"--upgrade-module-path", "test"}}; + + private static final String[] PATCH_MODULE_OPTIONS = {"--patch-module", null}; + + public static void main(String[] args) throws Exception { + new TestProcessHelper().runTests(); + } + + public void runTests() throws Exception { + testClassPath(); + testJar(); + testModule(); + } + + // Test Java processes that are started with -classpath, -cp, or --class-path options + // and with different combinations of VM and program args. + private void testClassPath() throws Exception { + for (String cp : CP_OPTIONS) { + for (String[] vma : VM_ARGS) { + for (String[] arg : ARGS) { + for (String[] modularOptions : EXTRA_MODULAR_OPTIONS) { + List<String> cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + cmd.add(cp); + cmd.add(TEST_CLASSES.toAbsolutePath().toString()); + for (String v : vma) { + cmd.add(v); + } + if (modularOptions != null) { + cmd.add(modularOptions[0]); + cmd.add(modularOptions[1]); + } + cmd.add(TEST_PROCESS_MAIN_CLASS); + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd, TEST_PROCESS_MAIN_CLASS); + } + } + } + } + } + + // Test Java processes that are started with -jar option + // and with different combinations of VM and program args. + private void testJar() throws Exception { + File jarFile = prepareJar(); + for (String[] vma : VM_ARGS) { + for (String[] arg : ARGS) { + List<String> cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + for (String v : vma) { + cmd.add(v); + } + cmd.add(JAR_OPTION); + cmd.add(jarFile.getAbsolutePath()); + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd, jarFile.getAbsolutePath()); + } + } + + } + + // Test Java processes that are started with -m or --module options + // and with different combination of VM and program args. + private void testModule() throws Exception { + prepareModule(); + for (String mp : MP_OPTIONS) { + for (String m : MODULE_OPTIONS) { + for (String[] vma : VM_ARGS) { + for (String[] arg : ARGS) { + for(String patchModuleOption : PATCH_MODULE_OPTIONS) { + List<String> cmd = new LinkedList<>(); + cmd.add(JAVA_PATH); + cmd.add(mp); + cmd.add(TEST_MODULES.toAbsolutePath().toString()); + if (patchModuleOption != null) { + cmd.add(patchModuleOption); + cmd.add(MODULE_NAME + "=" + TEST_MODULES.toAbsolutePath().toString()); + } + for (String v : vma) { + cmd.add(v); + } + if (m.endsWith("=")) { + cmd.add(m + MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); + } else { + cmd.add(m); + cmd.add(MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); + } + for (String a : arg) { + cmd.add(a); + } + testProcessHelper(cmd, MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS); + } + } + } + } + } + } + + private void checkMainClass(Process p, String expectedMainClass) { + String mainClass = PROCESS_HELPER.getMainClass(Long.toString(p.pid())); + // getMainClass() may return null, e.g. due to timing issues. + // Attempt some limited retries. + if (mainClass == null) { + System.err.println("Main class returned by ProcessHelper was null."); + // sleep time doubles each round, altogether, wait no longer than 1 sec + final int MAX_RETRIES = 10; + int retrycount = 0; + long sleepms = 1; + while (retrycount < MAX_RETRIES && mainClass == null) { + System.err.println("Retry " + retrycount + ", sleeping for " + sleepms + "ms."); + try { + Thread.sleep(sleepms); + } catch (InterruptedException e) { + // ignore + } + mainClass = PROCESS_HELPER.getMainClass(Long.toString(p.pid())); + retrycount++; + sleepms *= 2; + } + } + p.destroyForcibly(); + if (!expectedMainClass.equals(mainClass)) { + throw new RuntimeException("Main class is wrong: " + mainClass); + } + } + + private void testProcessHelper(List<String> args, String expectedValue) throws Exception { + ProcessBuilder pb = new ProcessBuilder(args); + String cmd = pb.command().stream().collect(Collectors.joining(" ")); + System.out.println("Starting the process:" + cmd); + Process p = ProcessTools.startProcess("test", pb); + if (!p.isAlive()) { + throw new RuntimeException("Cannot start the process: " + cmd); + } + checkMainClass(p, expectedValue); + } + + private File prepareJar() throws Exception { + Path jarFile = USER_DIR.resolve("testprocess.jar"); + Manifest manifest = createManifest(); + JarUtils.createJarFile(jarFile, manifest, TEST_CLASSES, TEST_CLASS); + return jarFile.toFile(); + } + + private void prepareModule() throws Exception { + TEST_MODULES.toFile().mkdirs(); + Path moduleJar = TEST_MODULES.resolve("mod1.jar"); + ModuleDescriptor md = createModuleDescriptor(); + createModuleJarFile(moduleJar, md, TEST_CLASSES, TEST_CLASS); + } + + private Manifest createManifest() { + Manifest manifest = new Manifest(); + manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, TEST_PROCESS_MAIN_CLASS); + return manifest; + } + + private ModuleDescriptor createModuleDescriptor() { + ModuleDescriptor.Builder builder + = ModuleDescriptor.newModule(MODULE_NAME).requires("java.base"); + return builder.build(); + } + + private static void createModuleJarFile(Path jarfile, ModuleDescriptor md, Path dir, Path... files) + throws IOException { + + Path parent = jarfile.getParent(); + if (parent != null) { + Files.createDirectories(parent); + } + + List<Path> entries = findAllRegularFiles(dir, files); + + try (OutputStream out = Files.newOutputStream(jarfile); + JarOutputStream jos = new JarOutputStream(out)) { + if (md != null) { + JarEntry je = new JarEntry("module-info.class"); + jos.putNextEntry(je); + ModuleInfoWriter.write(md, jos); + jos.closeEntry(); + } + + for (Path entry : entries) { + String name = toJarEntryName(entry); + jos.putNextEntry(new JarEntry(name)); + Files.copy(dir.resolve(entry), jos); + jos.closeEntry(); + } + } + } + + private static String toJarEntryName(Path file) { + Path normalized = file.normalize(); + return normalized.subpath(0, normalized.getNameCount()) + .toString() + .replace(File.separatorChar, '/'); + } + + private static List<Path> findAllRegularFiles(Path dir, Path[] files) throws IOException { + List<Path> entries = new ArrayList<>(); + for (Path file : files) { + try (Stream<Path> stream = Files.find(dir.resolve(file), Integer.MAX_VALUE, + (p, attrs) -> attrs.isRegularFile())) { + stream.map(dir::relativize) + .forEach(entries::add); + } + } + return entries; + } + +} diff --git a/src/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java b/src/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java new file mode 100644 index 00000000000..a6208c6dc2d --- /dev/null +++ b/src/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8225715 + * @requires vm.hasSAandCanAttach + * @library /test/lib + * @compile JShellHeapDumpTest.java + * @run main/timeout=240 JShellHeapDumpTest + */ + +import static jdk.test.lib.Asserts.assertTrue; + +import java.io.IOException; +import java.io.File; +import java.util.List; +import java.util.Arrays; +import java.util.Map; + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.hprof.parser.HprofReader; + +import jdk.jshell.JShell; + +public class JShellHeapDumpTest { + + protected static Process process; + + private static long pid; + + public static void launch(String expectedMessage, List<String> toolArgs) + throws IOException { + + try { + launchJshell(); + + System.out.println("Starting " + toolArgs.get(0) + " against " + pid); + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); + + for (String cmd : toolArgs) { + launcher.addToolArg(cmd); + } + + launcher.addToolArg("--pid=" + Long.toString(pid)); + + ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); + processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println("stdout:"); + System.out.println(output.getStdout()); + System.out.println("stderr:"); + System.out.println(output.getStderr()); + output.shouldNotContain("null"); + output.shouldHaveExitValue(0); + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } finally { + if (process.isAlive()) { + process.destroy(); + } + } + } + + public static void launch(String expectedMessage, String... toolArgs) + throws IOException { + + launch(expectedMessage, Arrays.asList(toolArgs)); + } + + public static void printStackTraces(String file) throws IOException { + try { + String output = HprofReader.getStack(file, 0); + if (!output.contains("JShellToolProvider")) { + throw new RuntimeException("'JShellToolProvider' missing from stdout/stderr"); + } + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } + } + + public static void testHeapDump() throws IOException { + File dump = new File("jhsdb.jmap.heap." + + System.currentTimeMillis() + ".hprof"); + if (dump.exists()) { + dump.delete(); + } + + launch("heap written to", "jmap", + "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); + + assertTrue(dump.exists() && dump.isFile(), + "Could not create dump file " + dump.getAbsolutePath()); + + printStackTraces(dump.getAbsolutePath()); + + dump.delete(); + } + + public static void launchJshell() throws IOException { + System.out.println("Starting Jshell"); + String jdkPath = System.getProperty("test.jdk"); + if (jdkPath == null) { + // we are not under jtreg, try env + Map<String, String> env = System.getenv(); + jdkPath = env.get("TESTJAVA"); + } + if (jdkPath == null) { + throw new RuntimeException("Can't determine jdk path neither test.jdk property no TESTJAVA env are set"); + } + String osname = System.getProperty("os.name"); + String jshell = jdkPath + ((osname.startsWith("window")) ? "/bin/jshell.exe" : "/bin/jshell"); + process = Runtime.getRuntime().exec(jshell); + pid = process.pid(); + } + + public static void main(String[] args) throws Exception { + + testHeapDump(); + + // The test throws RuntimeException on error. + // IOException is thrown if Jshell can't start because of some bad + // environment condition + System.out.println("Test PASSED"); + } +} diff --git a/src/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java b/src/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java index 14cbfe8c77d..41541892c81 100644 --- a/src/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java +++ b/src/test/jdk/sun/util/calendar/zi/TestZoneInfo310.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8007572 8008161 8157792 + * @bug 8007572 8008161 8157792 8212970 8224560 * @summary Test whether the TimeZone generated from JSR310 tzdb is the same * as the one from the tz data from javazic * @modules java.base/sun.util.calendar:+open @@ -46,18 +46,18 @@ public class TestZoneInfo310 { public static void main(String[] args) throws Throwable { String TESTDIR = System.getProperty("test.dir", "."); - String SRCDIR = System.getProperty("test.src", "."); - String tzdir = SRCDIR + File.separator + "tzdata"; - String tzfiles = "africa antarctica asia australasia europe northamerica pacificnew southamerica backward etcetera systemv"; - String jdk_tzdir = SRCDIR + File.separator + "tzdata_jdk"; - String jdk_tzfiles = "gmt jdk11_backward"; + Path tzdir = Paths.get(System.getProperty("test.root"), + "..", "..", "make", "data", "tzdata"); + String tzfiles = "africa antarctica asia australasia europe northamerica pacificnew southamerica backward etcetera systemv gmt"; + Path jdk_tzdir = Paths.get(System.getProperty("test.src"), "tzdata_jdk"); + String jdk_tzfiles = "jdk11_backward"; String zidir = TESTDIR + File.separator + "zi"; File fZidir = new File(zidir); if (!fZidir.exists()) { fZidir.mkdirs(); } Matcher m = Pattern.compile("tzdata(?<ver>[0-9]{4}[A-z])") - .matcher(new String(Files.readAllBytes(Paths.get(tzdir, "VERSION")), "ascii")); + .matcher(new String(Files.readAllBytes(tzdir.resolve("VERSION")), "ascii")); String ver = m.find() ? m.group("ver") : "NULL"; ArrayList<String> alist = new ArrayList<>(); @@ -66,10 +66,10 @@ public static void main(String[] args) throws Throwable { alist.add("-d"); alist.add(zidir); for (String f : tzfiles.split(" ")) { - alist.add(tzdir + File.separator + f); + alist.add(tzdir.resolve(f).toString()); } for (String f : jdk_tzfiles.split(" ")) { - alist.add(jdk_tzdir + File.separator + f); + alist.add(jdk_tzdir.resolve(f).toString()); } System.out.println("Compiling tz files!"); Main.main(alist.toArray(new String[alist.size()])); @@ -170,6 +170,35 @@ public static void main(String[] args) throws Throwable { for (String zid : zids_new) { ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); + /* + * Temporary ignoring the failing TimeZones which are having zone + * rules defined till year 2037 and/or above and have negative DST + * save time in IANA tzdata. This bug is tracked via JDK-8223388. + * + * These are the zones/rules that employ negative DST in vanguard + * format (as of 2019a): + * + * - Rule "Eire" + * - Rule "Morocco" + * - Rule "Namibia" + * - Zone "Europe/Prague" + * + * Tehran/Iran rule has rules beyond 2037, in which javazic assumes + * to be the last year. Thus javazic's rule is based on year 2037 + * (Mar 20th/Sep 20th are the cutover dates), while the real rule + * has year 2087 where Mar 21st/Sep 21st are the cutover dates. + */ + if (zid.equals("Africa/Casablanca") || // uses "Morocco" rule + zid.equals("Africa/El_Aaiun") || // uses "Morocco" rule + zid.equals("Africa/Windhoek") || // uses "Namibia" rule + zid.equals("Eire") || + zid.equals("Europe/Bratislava") || // link to "Europe/Prague" + zid.equals("Europe/Dublin") || // uses "Eire" rule + zid.equals("Europe/Prague") || + zid.equals("Asia/Tehran") || // last rule mismatch + zid.equals("Iran")) { // last rule mismatch + continue; + } if (! zi.equalsTo(ziOLD)) { System.out.println(zi.diffsTo(ziOLD)); throw new RuntimeException(" FAILED: " + zid); diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/africa b/src/test/jdk/sun/util/calendar/zi/tzdata/africa deleted file mode 100644 index e2ffac25ec1..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/africa +++ /dev/null @@ -1,1287 +0,0 @@ -# -# 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. -# -# tzdb data for Africa and environs - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# This file is by no means authoritative; if you think you know better, -# go ahead and edit the file (and please send any changes to -# tz@iana.org for general use in the future). For more, please see -# the file CONTRIBUTING in the tz distribution. - -# From Paul Eggert (2018-05-27): -# -# Unless otherwise specified, the source for data through 1990 is: -# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), -# San Diego: ACS Publications, Inc. (2003). -# Unfortunately this book contains many errors and cites no sources. -# -# Many years ago Gwillim Law wrote that a good source -# for time zone data was the International Air Transport -# Association's Standard Schedules Information Manual (IATA SSIM), -# published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. Except where otherwise noted, -# IATA SSIM is the source for entries after 1990. -# -# Another source occasionally used is Edward W. Whitman, World Time Differences, -# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which -# I found in the UCLA library. -# -# For data circa 1899, a common source is: -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# https://www.jstor.org/stable/1774359 -# -# A reliable and entertaining source about time zones is -# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). -# -# European-style abbreviations are commonly used along the Mediterranean. -# For sub-Saharan Africa abbreviations were less standardized. -# Previous editions of this database used WAT, CAT, SAT, and EAT -# for UT +00 through +03, respectively, -# but in 1997 Mark R V Murray reported that -# 'SAST' is the official abbreviation for +02 in the country of South Africa, -# 'CAT' is commonly used for +02 in countries north of South Africa, and -# 'WAT' is probably the best name for +01, as the common phrase for -# the area that includes Nigeria is "West Africa". -# -# To summarize, the following abbreviations seemed to have some currency: -# +00 GMT Greenwich Mean Time -# +02 CAT Central Africa Time -# +02 SAST South Africa Standard Time -# and Murray suggested the following abbreviation: -# +01 WAT West Africa Time -# Murray's suggestion seems to have caught on in news reports and the like. -# I vaguely recall 'WAT' also being used for -01 in the past but -# cannot now come up with solid citations. -# -# I invented the following abbreviations in the 1990s: -# +02 WAST West Africa Summer Time -# +03 CAST Central Africa Summer Time -# +03 SAST South Africa Summer Time -# +03 EAT East Africa Time -# 'EAT' seems to have caught on and is in current timestamps, and though -# the other abbreviations are rarer and are only in past timestamps, -# they are paired with better-attested non-DST abbreviations. -# Corrections are welcome. - -# Algeria -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Algeria 1916 only - Jun 14 23:00s 1:00 S -Rule Algeria 1916 1919 - Oct Sun>=1 23:00s 0 - -Rule Algeria 1917 only - Mar 24 23:00s 1:00 S -Rule Algeria 1918 only - Mar 9 23:00s 1:00 S -Rule Algeria 1919 only - Mar 1 23:00s 1:00 S -Rule Algeria 1920 only - Feb 14 23:00s 1:00 S -Rule Algeria 1920 only - Oct 23 23:00s 0 - -Rule Algeria 1921 only - Mar 14 23:00s 1:00 S -Rule Algeria 1921 only - Jun 21 23:00s 0 - -Rule Algeria 1939 only - Sep 11 23:00s 1:00 S -Rule Algeria 1939 only - Nov 19 1:00 0 - -Rule Algeria 1944 1945 - Apr Mon>=1 2:00 1:00 S -Rule Algeria 1944 only - Oct 8 2:00 0 - -Rule Algeria 1945 only - Sep 16 1:00 0 - -Rule Algeria 1971 only - Apr 25 23:00s 1:00 S -Rule Algeria 1971 only - Sep 26 23:00s 0 - -Rule Algeria 1977 only - May 6 0:00 1:00 S -Rule Algeria 1977 only - Oct 21 0:00 0 - -Rule Algeria 1978 only - Mar 24 1:00 1:00 S -Rule Algeria 1978 only - Sep 22 3:00 0 - -Rule Algeria 1980 only - Apr 25 0:00 1:00 S -Rule Algeria 1980 only - Oct 31 2:00 0 - -# Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's -# more precise 0:09:21. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Algiers 0:12:12 - LMT 1891 Mar 15 0:01 - 0:09:21 - PMT 1911 Mar 11 # Paris Mean Time - 0:00 Algeria WE%sT 1940 Feb 25 2:00 - 1:00 Algeria CE%sT 1946 Oct 7 - 0:00 - WET 1956 Jan 29 - 1:00 - CET 1963 Apr 14 - 0:00 Algeria WE%sT 1977 Oct 21 - 1:00 Algeria CE%sT 1979 Oct 26 - 0:00 Algeria WE%sT 1981 May - 1:00 - CET - -# Angola -# Benin -# See Africa/Lagos. - -# Botswana -# See Africa/Maputo. - -# Burkina Faso -# See Africa/Abidjan. - -# Burundi -# See Africa/Maputo. - -# Cameroon -# See Africa/Lagos. - -# Cape Verde / Cabo Verde -# -# From Paul Eggert (2018-02-16): -# Shanks gives 1907 for the transition to +02. -# For now, ignore that and follow the 1911-05-26 Portuguese decree -# (see Europe/Lisbon). -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Cape_Verde -1:34:04 - LMT 1912 Jan 01 2:00u # Praia - -2:00 - -02 1942 Sep - -2:00 1:00 -01 1945 Oct 15 - -2:00 - -02 1975 Nov 25 2:00 - -1:00 - -01 - -# Central African Republic -# See Africa/Lagos. - -# Chad -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Ndjamena 1:00:12 - LMT 1912 # N'Djamena - 1:00 - WAT 1979 Oct 14 - 1:00 1:00 WAST 1980 Mar 8 - 1:00 - WAT - -# Comoros -# See Africa/Nairobi. - -# Democratic Republic of the Congo -# See Africa/Lagos for the western part and Africa/Maputo for the eastern. - -# Republic of the Congo -# See Africa/Lagos. - -# Côte d'Ivoire / Ivory Coast -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Abidjan -0:16:08 - LMT 1912 - 0:00 - GMT -Link Africa/Abidjan Africa/Bamako # Mali -Link Africa/Abidjan Africa/Banjul # Gambia -Link Africa/Abidjan Africa/Conakry # Guinea -Link Africa/Abidjan Africa/Dakar # Senegal -Link Africa/Abidjan Africa/Freetown # Sierra Leone -Link Africa/Abidjan Africa/Lome # Togo -Link Africa/Abidjan Africa/Nouakchott # Mauritania -Link Africa/Abidjan Africa/Ouagadougou # Burkina Faso -Link Africa/Abidjan Atlantic/St_Helena # St Helena - -# Djibouti -# See Africa/Nairobi. - -############################################################################### - -# Egypt - -# Milne says Cairo used 2:05:08.9, the local mean time of the Abbasizeh -# observatory; round to nearest. Milne also says that the official time for -# Egypt was mean noon at the Great Pyramid, 2:04:30.5, but apparently this -# did not apply to Cairo, Alexandria, or Port Said. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Egypt 1940 only - Jul 15 0:00 1:00 S -Rule Egypt 1940 only - Oct 1 0:00 0 - -Rule Egypt 1941 only - Apr 15 0:00 1:00 S -Rule Egypt 1941 only - Sep 16 0:00 0 - -Rule Egypt 1942 1944 - Apr 1 0:00 1:00 S -Rule Egypt 1942 only - Oct 27 0:00 0 - -Rule Egypt 1943 1945 - Nov 1 0:00 0 - -Rule Egypt 1945 only - Apr 16 0:00 1:00 S -Rule Egypt 1957 only - May 10 0:00 1:00 S -Rule Egypt 1957 1958 - Oct 1 0:00 0 - -Rule Egypt 1958 only - May 1 0:00 1:00 S -Rule Egypt 1959 1981 - May 1 1:00 1:00 S -Rule Egypt 1959 1965 - Sep 30 3:00 0 - -Rule Egypt 1966 1994 - Oct 1 3:00 0 - -Rule Egypt 1982 only - Jul 25 1:00 1:00 S -Rule Egypt 1983 only - Jul 12 1:00 1:00 S -Rule Egypt 1984 1988 - May 1 1:00 1:00 S -Rule Egypt 1989 only - May 6 1:00 1:00 S -Rule Egypt 1990 1994 - May 1 1:00 1:00 S -# IATA (after 1990) says transitions are at 0:00. -# Go with IATA starting in 1995, except correct 1995 entry from 09-30 to 09-29. - -# From Alexander Krivenyshev (2011-04-20): -# "...Egypt's interim cabinet decided on Wednesday to cancel daylight -# saving time after a poll posted on its website showed the majority of -# Egyptians would approve the cancellation." -# -# Egypt to cancel daylight saving time -# http://www.almasryalyoum.com/en/node/407168 -# or -# http://www.worldtimezone.com/dst_news/dst_news_egypt04.html -Rule Egypt 1995 2010 - Apr lastFri 0:00s 1:00 S -Rule Egypt 1995 2005 - Sep lastThu 24:00 0 - -# From Steffen Thorsen (2006-09-19): -# The Egyptian Gazette, issue 41,090 (2006-09-18), page 1, reports: -# Egypt will turn back clocks by one hour at the midnight of Thursday -# after observing the daylight saving time since May. -# http://news.gom.com.eg/gazette/pdf/2006/09/18/01.pdf -Rule Egypt 2006 only - Sep 21 24:00 0 - -# From Dirk Losch (2007-08-14): -# I received a mail from an airline which says that the daylight -# saving time in Egypt will end in the night of 2007-09-06 to 2007-09-07. -# From Jesper Nørgaard Welen (2007-08-15): [The following agree:] -# http://www.nentjes.info/Bill/bill5.htm -# https://www.timeanddate.com/worldclock/city.html?n=53 -# From Steffen Thorsen (2007-09-04): The official information...: -# http://www.sis.gov.eg/En/EgyptOnline/Miscellaneous/000002/0207000000000000001580.htm -Rule Egypt 2007 only - Sep Thu>=1 24:00 0 - -# From Abdelrahman Hassan (2007-09-06): -# Due to the Hijri (lunar Islamic calendar) year being 11 days shorter -# than the year of the Gregorian calendar, Ramadan shifts earlier each -# year. This year it will be observed September 13 (September is quite -# hot in Egypt), and the idea is to make fasting easier for workers by -# shifting business hours one hour out of daytime heat. Consequently, -# unless discontinued, next DST may end Thursday 28 August 2008. -# From Paul Eggert (2007-08-17): -# For lack of better info, assume the new rule is last Thursday in August. - -# From Petr Machata (2009-04-06): -# The following appeared in Red Hat bugzilla[1] (edited): -# -# > $ zdump -v /usr/share/zoneinfo/Africa/Cairo | grep 2009 -# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 21:59:59 2009 UTC = Thu = -# Apr 23 -# > 23:59:59 2009 EET isdst=0 gmtoff=7200 -# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 22:00:00 2009 UTC = Fri = -# Apr 24 -# > 01:00:00 2009 EEST isdst=1 gmtoff=10800 -# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 20:59:59 2009 UTC = Thu = -# Aug 27 -# > 23:59:59 2009 EEST isdst=1 gmtoff=10800 -# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 21:00:00 2009 UTC = Thu = -# Aug 27 -# > 23:00:00 2009 EET isdst=0 gmtoff=7200 -# -# > end date should be Thu Sep 24 2009 (Last Thursday in September at 23:59= -# :59) -# > http://support.microsoft.com/kb/958729/ -# -# timeanddate[2] and another site I've found[3] also support that. -# -# [1] https://bugzilla.redhat.com/show_bug.cgi?id=492263 -# [2] https://www.timeanddate.com/worldclock/clockchange.html?n=53 -# [3] https://wwp.greenwichmeantime.com/time-zone/africa/egypt/ - -# From Arthur David Olson (2009-04-20): -# In 2009 (and for the next several years), Ramadan ends before the fourth -# Thursday in September; Egypt is expected to revert to the last Thursday -# in September. - -# From Steffen Thorsen (2009-08-11): -# We have been able to confirm the August change with the Egyptian Cabinet -# Information and Decision Support Center: -# https://www.timeanddate.com/news/time/egypt-dst-ends-2009.html -# -# The Middle East News Agency -# https://www.mena.org.eg/index.aspx -# also reports "Egypt starts winter time on August 21" -# today in article numbered "71, 11/08/2009 12:25 GMT." -# Only the title above is available without a subscription to their service, -# and can be found by searching for "winter" in their search engine -# (at least today). - -# From Alexander Krivenyshev (2010-07-20): -# According to News from Egypt - Al-Masry Al-Youm Egypt's cabinet has -# decided that Daylight Saving Time will not be used in Egypt during -# Ramadan. -# -# Arabic translation: -# "Clocks to go back during Ramadan - and then forward again" -# http://www.almasryalyoum.com/en/news/clocks-go-back-during-ramadan-and-then-forward-again -# http://www.worldtimezone.com/dst_news/dst_news_egypt02.html - -# From Ahmad El-Dardiry (2014-05-07): -# Egypt is to change back to Daylight system on May 15 -# http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx - -# From Gunther Vermier (2014-05-13): -# our Egypt office confirms that the change will be at 15 May "midnight" (24:00) - -# From Imed Chihi (2014-06-04): -# We have finally "located" a precise official reference about the DST changes -# in Egypt. The Ministers Cabinet decision is explained at -# http://www.cabinet.gov.eg/Media/CabinetMeetingsDetails.aspx?id=347 ... -# [T]his (Arabic) site is not accessible outside Egypt, but the page ... -# translates into: "With regard to daylight saving time, it is scheduled to -# take effect at exactly twelve o'clock this evening, Thursday, 15 MAY 2014, -# to be suspended by twelve o'clock on the evening of Thursday, 26 JUN 2014, -# and re-established again at the end of the month of Ramadan, at twelve -# o'clock on the evening of Thursday, 31 JUL 2014." This statement has been -# reproduced by other (more accessible) sites[, e.g.,]... -# http://elgornal.net/news/news.aspx?id=4699258 - -# From Paul Eggert (2014-06-04): -# Sarah El Deeb and Lee Keath of AP report that the Egyptian government says -# the change is because of blackouts in Cairo, even though Ahram Online (cited -# above) says DST had no affect on electricity consumption. There is -# no information about when DST will end this fall. See: -# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833 - -# From Steffen Thorsen (2015-04-08): -# Egypt will start DST on midnight after Thursday, April 30, 2015. -# This is based on a law (no 35) from May 15, 2014 saying it starts the last -# Thursday of April.... Clocks will still be turned back for Ramadan, but -# dates not yet announced.... -# http://almogaz.com/news/weird-news/2015/04/05/1947105 ... -# https://www.timeanddate.com/news/time/egypt-starts-dst-2015.html - -# From Ahmed Nazmy (2015-04-20): -# Egypt's ministers cabinet just announced ... that it will cancel DST at -# least for 2015. -# -# From Tim Parenti (2015-04-20): -# http://english.ahram.org.eg/WriterArticles/NewsContentP/1/128195/Egypt/No-daylight-saving-this-summer-Egypts-prime-minist.aspx -# "Egypt's cabinet agreed on Monday not to switch clocks for daylight saving -# time this summer, and carry out studies on the possibility of canceling the -# practice altogether in future years." -# -# From Paul Eggert (2015-04-24): -# Yesterday the office of Egyptian President El-Sisi announced his -# decision to abandon DST permanently. See Ahram Online 2015-04-24. -# http://english.ahram.org.eg/NewsContent/1/64/128509/Egypt/Politics-/Sisi-cancels-daylight-saving-time-in-Egypt.aspx - -# From Steffen Thorsen (2016-04-29): -# Egypt will have DST from July 7 until the end of October.... -# http://english.ahram.org.eg/NewsContentP/1/204655/Egypt/Daylight-savings-time-returning-to-Egypt-on--July.aspx -# From Mina Samuel (2016-07-04): -# Egyptian government took the decision to cancel the DST, - -Rule Egypt 2008 only - Aug lastThu 24:00 0 - -Rule Egypt 2009 only - Aug 20 24:00 0 - -Rule Egypt 2010 only - Aug 10 24:00 0 - -Rule Egypt 2010 only - Sep 9 24:00 1:00 S -Rule Egypt 2010 only - Sep lastThu 24:00 0 - -Rule Egypt 2014 only - May 15 24:00 1:00 S -Rule Egypt 2014 only - Jun 26 24:00 0 - -Rule Egypt 2014 only - Jul 31 24:00 1:00 S -Rule Egypt 2014 only - Sep lastThu 24:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Cairo 2:05:09 - LMT 1900 Oct - 2:00 Egypt EE%sT - -# Equatorial Guinea -# See Africa/Lagos. - -# Eritrea -# Ethiopia -# See Africa/Nairobi. -# -# Unfortunately tzdb records only Western clock time in use in Ethiopia, -# as the tzdb format is not up to properly recording a common Ethiopian -# timekeeping practice that is based on solar time. See: -# Mortada D. If you have a meeting in Ethiopia, you'd better double -# check the time. PRI's The World. 2015-01-30 15:15 -05. -# https://www.pri.org/stories/2015-01-30/if-you-have-meeting-ethiopia-you-better-double-check-time - -# Gabon -# See Africa/Lagos. - -# Gambia -# See Africa/Abidjan. - -# Ghana - -# From Paul Eggert (2018-01-30): -# Whitman says DST was observed from 1931 to "the present"; -# Shanks & Pottenger say 1936 to 1942 with 20 minutes of DST, -# with transitions on 09-01 and 12-31 at 00:00. -# Page 33 of Parish GCB, Colonial Reports - Annual. No. 1066. Gold -# Coast. Report for 1919. (March 1921), OCLC 784024077 -# http://libsysdigi.library.illinois.edu/ilharvest/africana/books2011-05/5530214/5530214_1919/5530214_1919_opt.pdf -# lists the Determination of the Time Ordinance, 1919, No. 18, -# "to advance the time observed locally by the space of twenty minutes -# during the last four months of each year; the object in view being -# to extend during those months the period of daylight-time available -# for evening recreation after office hours." -# Vanessa Ogle, The Global Transformation of Time, 1870-1950 (2015), p 33, -# writes "In 1919, the Gold Coast (Ghana as of 1957) made Greenwich -# time its legal time and simultaneously legalized a summer time of -# UTC - 00:20 minutes from March to October."; a footnote lists -# the ordinance as being dated 1919-11-24. -# The Crown Colonist, Volume 12 (1942), p 176, says "the Government -# intend advancing Gold Coast time half an hour ahead of G.M.T. -# The actual date of the alteration has not yet been announced." -# These sources are incomplete and contradictory. Possibly what is -# now Ghana observed different DST regimes in different years. For -# lack of better info, use Shanks except treat the minus sign as a -# typo, and assume DST started in 1920 not 1936. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Ghana 1920 1942 - Sep 1 0:00 0:20 - -Rule Ghana 1920 1942 - Dec 31 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Accra -0:00:52 - LMT 1918 - 0:00 Ghana GMT/+0020 - -# Guinea -# See Africa/Abidjan. - -# Guinea-Bissau -# -# From Paul Eggert (2018-02-16): -# Shanks gives 1911-05-26 for the transition to WAT, -# evidently confusing the date of the Portuguese decree -# (see Europe/Lisbon) with the date that it took effect. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Bissau -1:02:20 - LMT 1912 Jan 1 1:00u - -1:00 - -01 1975 - 0:00 - GMT - -# Kenya -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Nairobi 2:27:16 - LMT 1928 Jul - 3:00 - EAT 1930 - 2:30 - +0230 1940 - 2:45 - +0245 1960 - 3:00 - EAT -Link Africa/Nairobi Africa/Addis_Ababa # Ethiopia -Link Africa/Nairobi Africa/Asmara # Eritrea -Link Africa/Nairobi Africa/Dar_es_Salaam # Tanzania -Link Africa/Nairobi Africa/Djibouti -Link Africa/Nairobi Africa/Kampala # Uganda -Link Africa/Nairobi Africa/Mogadishu # Somalia -Link Africa/Nairobi Indian/Antananarivo # Madagascar -Link Africa/Nairobi Indian/Comoro -Link Africa/Nairobi Indian/Mayotte - -# Lesotho -# See Africa/Johannesburg. - -# Liberia -# -# From Paul Eggert (2017-03-02): -# -# The Nautical Almanac for the Year 1970, p 264, is the source for -0:44:30. -# -# In 1972 Liberia was the last country to switch from a UT offset -# that was not a multiple of 15 or 20 minutes. The 1972 change was on -# 1972-01-07, according to an entry dated 1972-01-04 on p 330 of: -# Presidential Papers: First year of the administration of -# President William R. Tolbert, Jr., July 23, 1971-July 31, 1972. -# Monrovia: Executive Mansion. -# -# Use the abbreviation "MMT" before 1972, as the more-accurate numeric -# abbreviation "-004430" would be one byte over the POSIX limit. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Monrovia -0:43:08 - LMT 1882 - -0:43:08 - MMT 1919 Mar # Monrovia Mean Time - -0:44:30 - MMT 1972 Jan 7 # approximately MMT - 0:00 - GMT - -############################################################################### - -# Libya - -# From Even Scharning (2012-11-10): -# Libya set their time one hour back at 02:00 on Saturday November 10. -# https://www.libyaherald.com/2012/11/04/clocks-to-go-back-an-hour-on-saturday/ -# Here is an official source [in Arabic]: http://ls.ly/fb6Yc -# -# Steffen Thorsen forwarded a translation (2012-11-10) in -# https://mm.icann.org/pipermail/tz/2012-November/018451.html -# -# From Tim Parenti (2012-11-11): -# Treat the 2012-11-10 change as a zone change from UTC+2 to UTC+1. -# The DST rules planned for 2013 and onward roughly mirror those of Europe -# (either two days before them or five days after them, so as to fall on -# lastFri instead of lastSun). - -# From Even Scharning (2013-10-25): -# The scheduled end of DST in Libya on Friday, October 25, 2013 was -# cancelled yesterday.... -# https://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ -# -# From Paul Eggert (2013-10-25): -# For now, assume they're reverting to the pre-2012 rules of permanent UT +02. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Libya 1951 only - Oct 14 2:00 1:00 S -Rule Libya 1952 only - Jan 1 0:00 0 - -Rule Libya 1953 only - Oct 9 2:00 1:00 S -Rule Libya 1954 only - Jan 1 0:00 0 - -Rule Libya 1955 only - Sep 30 0:00 1:00 S -Rule Libya 1956 only - Jan 1 0:00 0 - -Rule Libya 1982 1984 - Apr 1 0:00 1:00 S -Rule Libya 1982 1985 - Oct 1 0:00 0 - -Rule Libya 1985 only - Apr 6 0:00 1:00 S -Rule Libya 1986 only - Apr 4 0:00 1:00 S -Rule Libya 1986 only - Oct 3 0:00 0 - -Rule Libya 1987 1989 - Apr 1 0:00 1:00 S -Rule Libya 1987 1989 - Oct 1 0:00 0 - -Rule Libya 1997 only - Apr 4 0:00 1:00 S -Rule Libya 1997 only - Oct 4 0:00 0 - -Rule Libya 2013 only - Mar lastFri 1:00 1:00 S -Rule Libya 2013 only - Oct lastFri 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Tripoli 0:52:44 - LMT 1920 - 1:00 Libya CE%sT 1959 - 2:00 - EET 1982 - 1:00 Libya CE%sT 1990 May 4 -# The 1996 and 1997 entries are from Shanks & Pottenger; -# the IATA SSIM data entries contain some obvious errors. - 2:00 - EET 1996 Sep 30 - 1:00 Libya CE%sT 1997 Oct 4 - 2:00 - EET 2012 Nov 10 2:00 - 1:00 Libya CE%sT 2013 Oct 25 2:00 - 2:00 - EET - -# Madagascar -# See Africa/Nairobi. - -# Malawi -# See Africa/Maputo. - -# Mali -# Mauritania -# See Africa/Abidjan. - -# Mauritius - -# From Steffen Thorsen (2008-06-25): -# Mauritius plans to observe DST from 2008-11-01 to 2009-03-31 on a trial -# basis.... -# It seems that Mauritius observed daylight saving time from 1982-10-10 to -# 1983-03-20 as well, but that was not successful.... -# https://www.timeanddate.com/news/time/mauritius-daylight-saving-time.html - -# From Alex Krivenyshev (2008-06-25): -# http://economicdevelopment.gov.mu/portal/site/Mainhomepage/menuitem.a42b24128104d9845dabddd154508a0c/?content_id=0a7cee8b5d69a110VgnVCM1000000a04a8c0RCRD - -# From Arthur David Olson (2008-06-30): -# The www.timeanddate.com article cited by Steffen Thorsen notes that "A -# final decision has yet to be made on the times that daylight saving -# would begin and end on these dates." As a place holder, use midnight. - -# From Paul Eggert (2008-06-30): -# Follow Thorsen on DST in 1982/1983, instead of Shanks & Pottenger. - -# From Steffen Thorsen (2008-07-10): -# According to -# http://www.lexpress.mu/display_article.php?news_id=111216 -# (in French), Mauritius will start and end their DST a few days earlier -# than previously announced (2008-11-01 to 2009-03-31). The new start -# date is 2008-10-26 at 02:00 and the new end date is 2009-03-27 (no time -# given, but it is probably at either 2 or 3 wall clock time). -# -# A little strange though, since the article says that they moved the date -# to align itself with Europe and USA which also change time on that date, -# but that means they have not paid attention to what happened in -# USA/Canada last year (DST ends first Sunday in November). I also wonder -# why that they end on a Friday, instead of aligning with Europe which -# changes two days later. - -# From Alex Krivenyshev (2008-07-11): -# Seems that English language article "The revival of daylight saving -# time: Energy conservation?"- No. 16578 (07/11/2008) was originally -# published on Monday, June 30, 2008... -# -# I guess that article in French "Le gouvernement avance l'introduction -# de l'heure d'été" stating that DST in Mauritius starting on October 26 -# and ending on March 27, 2009 is the most recent one.... -# http://www.worldtimezone.com/dst_news/dst_news_mauritius02.html - -# From Riad M. Hossen Ally (2008-08-03): -# The Government of Mauritius weblink -# http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD -# Cabinet Decision of July 18th, 2008 states as follows: -# -# 4. ...Cabinet has agreed to the introduction into the National Assembly -# of the Time Bill which provides for the introduction of summer time in -# Mauritius. The summer time period which will be of one hour ahead of -# the standard time, will be aligned with that in Europe and the United -# States of America. It will start at two o'clock in the morning on the -# last Sunday of October and will end at two o'clock in the morning on -# the last Sunday of March the following year. The summer time for the -# year 2008-2009 will, therefore, be effective as from 26 October 2008 -# and end on 29 March 2009. - -# From Ed Maste (2008-10-07): -# THE TIME BILL (No. XXVII of 2008) Explanatory Memorandum states the -# beginning / ending of summer time is 2 o'clock standard time in the -# morning of the last Sunday of October / last Sunday of March. -# http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf - -# From Steffen Thorsen (2009-06-05): -# According to several sources, Mauritius will not continue to observe -# DST the coming summer... -# -# Some sources, in French: -# http://www.defimedia.info/news/946/Rashid-Beebeejaun-:-%C2%AB-L%E2%80%99heure-d%E2%80%99%C3%A9t%C3%A9-ne-sera-pas-appliqu%C3%A9e-cette-ann%C3%A9e-%C2%BB -# http://lexpress.mu/Story/3398~Beebeejaun---Les-objectifs-d-%C3%A9conomie-d-%C3%A9nergie-de-l-heure-d-%C3%A9t%C3%A9-ont-%C3%A9t%C3%A9-atteints- -# -# Our wrap-up: -# https://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html - -# From Arthur David Olson (2009-07-11): -# The "mauritius-dst-will-not-repeat" wrapup includes this: -# "The trial ended on March 29, 2009, when the clocks moved back by one hour -# at 2am (or 02:00) local time..." - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Mauritius 1982 only - Oct 10 0:00 1:00 - -Rule Mauritius 1983 only - Mar 21 0:00 0 - -Rule Mauritius 2008 only - Oct lastSun 2:00 1:00 - -Rule Mauritius 2009 only - Mar lastSun 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis - 4:00 Mauritius +04/+05 -# Agalega Is, Rodriguez -# no information; probably like Indian/Mauritius - -# Mayotte -# See Africa/Nairobi. - -# Morocco -# See the 'europe' file for Spanish Morocco (Africa/Ceuta). - -# From Alex Krivenyshev (2008-05-09): -# Here is an article that Morocco plan to introduce Daylight Saving Time between -# 1 June, 2008 and 27 September, 2008. -# -# "... Morocco is to save energy by adjusting its clock during summer so it will -# be one hour ahead of GMT between 1 June and 27 September, according to -# Communication Minister and Government Spokesman, Khalid Naciri...." -# -# http://www.worldtimezone.com/dst_news/dst_news_morocco01.html -# http://en.afrik.com/news11892.html - -# From Alex Krivenyshev (2008-05-09): -# The Morocco time change can be confirmed on Morocco web site Maghreb Arabe -# Presse: -# http://www.map.ma/eng/sections/box3/morocco_shifts_to_da/view -# -# Morocco shifts to daylight time on June 1st through September 27, Govt. -# spokesman. - -# From Patrice Scattolin (2008-05-09): -# According to this article: -# https://www.avmaroc.com/actualite/heure-dete-comment-a127896.html -# (and republished here: <http://www.actu.ma/heure-dete-comment_i127896_0.html>) -# the changes occur at midnight: -# -# Saturday night May 31st at midnight (which in French is to be -# interpreted as the night between Saturday and Sunday) -# Sunday night the 28th at midnight -# -# Seeing that the 28th is Monday, I am guessing that she intends to say -# the midnight of the 28th which is the midnight between Sunday and -# Monday, which jives with other sources that say that it's inclusive -# June 1st to Sept 27th. -# -# The decision was taken by decree *2-08-224 *but I can't find the decree -# published on the web. -# -# It's also confirmed here: -# http://www.maroc.ma/NR/exeres/FACF141F-D910-44B0-B7FA-6E03733425D1.htm -# on a government portal as being between June 1st and Sept 27th (not yet -# posted in English). -# -# The following Google query will generate many relevant hits: -# https://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search - -# From Steffen Thorsen (2008-08-27): -# Morocco will change the clocks back on the midnight between August 31 -# and September 1. They originally planned to observe DST to near the end -# of September: -# -# One article about it (in French): -# http://www.menara.ma/fr/Actualites/Maroc/Societe/ci.retour_a_l_heure_gmt_a_partir_du_dimanche_31_aout_a_minuit_officiel_.default -# -# We have some further details posted here: -# https://www.timeanddate.com/news/time/morocco-ends-dst-early-2008.html - -# From Steffen Thorsen (2009-03-17): -# Morocco will observe DST from 2009-06-01 00:00 to 2009-08-21 00:00 according -# to many sources, such as -# http://news.marweb.com/morocco/entertainment/morocco-daylight-saving.html -# http://www.medi1sat.ma/fr/depeche.aspx?idp=2312 -# (French) -# -# Our summary: -# https://www.timeanddate.com/news/time/morocco-starts-dst-2009.html - -# From Alexander Krivenyshev (2009-03-17): -# Here is a link to official document from Royaume du Maroc Premier Ministre, -# Ministère de la Modernisation des Secteurs Publics -# -# Under Article 1 of Royal Decree No. 455-67 of Act 23 safar 1387 (2 June 1967) -# concerning the amendment of the legal time, the Ministry of Modernization of -# Public Sectors announced that the official time in the Kingdom will be -# advanced 60 minutes from Sunday 31 May 2009 at midnight. -# -# http://www.mmsp.gov.ma/francais/Actualites_fr/PDF_Actualites_Fr/HeureEte_FR.pdf -# http://www.worldtimezone.com/dst_news/dst_news_morocco03.html - -# From Steffen Thorsen (2010-04-13): -# Several news media in Morocco report that the Ministry of Modernization -# of Public Sectors has announced that Morocco will have DST from -# 2010-05-02 to 2010-08-08. -# -# Example: -# http://www.lavieeco.com/actualites/4099-le-maroc-passera-a-l-heure-d-ete-gmt1-le-2-mai.html -# (French) -# Our page: -# https://www.timeanddate.com/news/time/morocco-starts-dst-2010.html - -# From Dan Abitol (2011-03-30): -# ...Rules for Africa/Casablanca are the following (24h format) -# The 3rd April 2011 at 00:00:00, [it] will be 3rd April 01:00:00 -# The 31st July 2011 at 00:59:59, [it] will be 31st July 00:00:00 -# ...Official links of change in morocco -# The change was broadcast on the FM Radio -# I ve called ANRT (telecom regulations in Morocco) at -# +212.537.71.84.00 -# http://www.anrt.net.ma/fr/ -# They said that -# http://www.map.ma/fr/sections/accueil/l_heure_legale_au_ma/view -# is the official publication to look at. -# They said that the decision was already taken. -# -# More articles in the press -# https://www.yabiladi.com/articles/details/5058/secret-l-heure-d-ete-maroc-leve.html -# http://www.lematin.ma/Actualite/Express/Article.asp?id=148923 -# http://www.lavieeco.com/actualite/Le-Maroc-passe-sur-GMT%2B1-a-partir-de-dim - -# From Petr Machata (2011-03-30): -# They have it written in English here: -# http://www.map.ma/eng/sections/home/morocco_to_spring_fo/view -# -# It says there that "Morocco will resume its standard time on July 31, -# 2011 at midnight." Now they don't say whether they mean midnight of -# wall clock time (i.e. 11pm UTC), but that's what I would assume. It has -# also been like that in the past. - -# From Alexander Krivenyshev (2012-03-09): -# According to Infomédiaire web site from Morocco (infomediaire.ma), -# on March 9, 2012, (in French) Heure légale: -# Le Maroc adopte officiellement l'heure d'été -# http://www.infomediaire.ma/news/maroc/heure-l%C3%A9gale-le-maroc-adopte-officiellement-lheure-d%C3%A9t%C3%A9 -# Governing Council adopted draft decree, that Morocco DST starts on -# the last Sunday of March (March 25, 2012) and ends on -# last Sunday of September (September 30, 2012) -# except the month of Ramadan. -# or (brief) -# http://www.worldtimezone.com/dst_news/dst_news_morocco06.html - -# From Arthur David Olson (2012-03-10): -# The infomediaire.ma source indicates that the system is to be in -# effect every year. It gives 03H00 as the "fall back" time of day; -# it lacks a "spring forward" time of day; assume 2:00 XXX. -# Wait on specifying the Ramadan exception for details about -# start date, start time of day, end date, and end time of day XXX. - -# From Christophe Tropamer (2012-03-16): -# Seen Morocco change again: -# http://www.le2uminutes.com/actualite.php -# "...à partir du dernier dimanche d'avril et non fins mars, -# comme annoncé précédemment." - -# From Milamber Space Network (2012-07-17): -# The official return to GMT is announced by the Moroccan government: -# http://www.mmsp.gov.ma/fr/actualites.aspx?id=288 [in French] -# -# Google translation, lightly edited: -# Back to the standard time of the Kingdom (GMT) -# Pursuant to Decree No. 2-12-126 issued on 26 Jumada (I) 1433 (April 18, -# 2012) and in accordance with the order of Mr. President of the -# Government No. 3-47-12 issued on 24 Sha'ban (11 July 2012), the Ministry -# of Public Service and Administration Modernization announces the return -# of the legal time of the Kingdom (GMT) from Friday, July 20, 2012 until -# Monday, August 20, 2012. So the time will be delayed by 60 minutes from -# 3:00 am Friday, July 20, 2012 and will again be advanced by 60 minutes -# August 20, 2012 from 2:00 am. - -# From Paul Eggert (2013-03-06): -# Morocco's daylight-saving transitions due to Ramadan seem to be -# announced a bit in advance. On 2012-07-11 the Moroccan government -# announced that year's Ramadan daylight-saving transitions would be -# 2012-07-20 and 2012-08-20; see -# http://www.mmsp.gov.ma/fr/actualites.aspx?id=288 - -# From Andrew Paprocki (2013-07-02): -# Morocco announced that the year's Ramadan daylight-savings -# transitions would be 2013-07-07 and 2013-08-10; see: -# http://www.maroc.ma/en/news/morocco-suspends-daylight-saving-time-july-7-aug10 - -# From Steffen Thorsen (2013-09-28): -# Morocco extends DST by one month, on very short notice, just 1 day -# before it was going to end. There is a new decree (2.13.781) for -# this, where DST from now on goes from last Sunday of March at 02:00 -# to last Sunday of October at 03:00, similar to EU rules. Official -# source (French): -# http://www.maroc.gov.ma/fr/actualites/lhoraire-dete-gmt1-maintenu-jusquau-27-octobre-2013 -# Another source (specifying the time for start and end in the decree): -# http://www.lemag.ma/Heure-d-ete-au-Maroc-jusqu-au-27-octobre_a75620.html - -# From Sebastien Willemijns (2014-03-18): -# http://www.afriquinfos.com/articles/2014/3/18/maroc-heure-dete-avancez-tous-horloges-247891.asp - -# From Milamber Space Network (2014-06-05): -# The Moroccan government has recently announced that the country will return -# to standard time at 03:00 on Saturday, June 28, 2014 local time.... DST -# will resume again at 02:00 on Saturday, August 2, 2014.... -# http://www.mmsp.gov.ma/fr/actualites.aspx?id=586 - -# From Milamber (2015-06-08): -# (Google Translation) The hour will thus be delayed 60 minutes -# Sunday, June 14 at 3:00, the ministry said in a statement, adding -# that the time will be advanced again 60 minutes Sunday, July 19, -# 2015 at 2:00. The move comes under 2.12.126 Decree of 26 Jumada I -# 1433 (18 April 2012) and the decision of the Head of Government of -# 16 N. 3-29-15 Chaaban 1435 (4 June 2015). -# Source (french): -# https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/ -# -# From Milamber (2015-06-09): -# http://www.mmsp.gov.ma/fr/actualites.aspx?id=863 -# -# From Michael Deckers (2015-06-09): -# [The gov.ma announcement] would (probably) make the switch on 2015-07-19 go -# from 03:00 to 04:00 rather than from 02:00 to 03:00, as in the patch.... -# I think the patch is correct and the quoted text is wrong; the text in -# <https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/> agrees -# with the patch. - -# From Mohamed Essedik Najd (2018-10-26): -# Today, a Moroccan government council approved the perpetual addition -# of 60 minutes to the regular Moroccan timezone. -# From Brian Inglis (2018-10-26): -# http://www.maroc.ma/fr/actualites/le-conseil-de-gouvernement-adopte-un-projet-de-decret-relatif-lheure-legale-stipulant-le - -# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Morocco 1939 only - Sep 12 0:00 1:00 - -Rule Morocco 1939 only - Nov 19 0:00 0 - -Rule Morocco 1940 only - Feb 25 0:00 1:00 - -Rule Morocco 1945 only - Nov 18 0:00 0 - -Rule Morocco 1950 only - Jun 11 0:00 1:00 - -Rule Morocco 1950 only - Oct 29 0:00 0 - -Rule Morocco 1967 only - Jun 3 12:00 1:00 - -Rule Morocco 1967 only - Oct 1 0:00 0 - -Rule Morocco 1974 only - Jun 24 0:00 1:00 - -Rule Morocco 1974 only - Sep 1 0:00 0 - -Rule Morocco 1976 1977 - May 1 0:00 1:00 - -Rule Morocco 1976 only - Aug 1 0:00 0 - -Rule Morocco 1977 only - Sep 28 0:00 0 - -Rule Morocco 1978 only - Jun 1 0:00 1:00 - -Rule Morocco 1978 only - Aug 4 0:00 0 - -Rule Morocco 2008 only - Jun 1 0:00 1:00 - -Rule Morocco 2008 only - Sep 1 0:00 0 - -Rule Morocco 2009 only - Jun 1 0:00 1:00 - -Rule Morocco 2009 only - Aug 21 0:00 0 - -Rule Morocco 2010 only - May 2 0:00 1:00 - -Rule Morocco 2010 only - Aug 8 0:00 0 - -Rule Morocco 2011 only - Apr 3 0:00 1:00 - -Rule Morocco 2011 only - Jul 31 0:00 0 - -Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 - -Rule Morocco 2012 only - Jul 20 3:00 0 - -Rule Morocco 2012 only - Aug 20 2:00 1:00 - -Rule Morocco 2012 only - Sep 30 3:00 0 - -Rule Morocco 2013 only - Jul 7 3:00 0 - -Rule Morocco 2013 only - Aug 10 2:00 1:00 - -Rule Morocco 2013 2018 - Oct lastSun 3:00 0 - -Rule Morocco 2014 2018 - Mar lastSun 2:00 1:00 - -Rule Morocco 2014 only - Jun 28 3:00 0 - -Rule Morocco 2014 only - Aug 2 2:00 1:00 - -Rule Morocco 2015 only - Jun 14 3:00 0 - -Rule Morocco 2015 only - Jul 19 2:00 1:00 - -Rule Morocco 2016 only - Jun 5 3:00 0 - -Rule Morocco 2016 only - Jul 10 2:00 1:00 - -Rule Morocco 2017 only - May 21 3:00 0 - -Rule Morocco 2017 only - Jul 2 2:00 1:00 - -Rule Morocco 2018 only - May 13 3:00 0 - -Rule Morocco 2018 only - Jun 17 2:00 1:00 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26 - 0:00 Morocco +00/+01 1984 Mar 16 - 1:00 - +01 1986 - 0:00 Morocco +00/+01 2018 Oct 27 - 1:00 - +01 - -# Western Sahara -# -# From Gwillim Law (2013-10-22): -# A correspondent who is usually well informed about time zone matters -# ... says that Western Sahara observes daylight saving time, just as -# Morocco does. -# -# From Paul Eggert (2013-10-23): -# Assume that this has been true since Western Sahara switched to GMT, -# since most of it was then controlled by Morocco. - -Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan # El Aaiún - -1:00 - -01 1976 Apr 14 - 0:00 Morocco +00/+01 2018 Oct 27 - 1:00 - +01 - -# Mozambique -# -# Shanks gives 1903-03-01 for the transition to CAT. -# Perhaps the 1911-05-26 Portuguese decree -# https://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf -# merely made it official? -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Maputo 2:10:20 - LMT 1903 Mar - 2:00 - CAT -Link Africa/Maputo Africa/Blantyre # Malawi -Link Africa/Maputo Africa/Bujumbura # Burundi -Link Africa/Maputo Africa/Gaborone # Botswana -Link Africa/Maputo Africa/Harare # Zimbabwe -Link Africa/Maputo Africa/Kigali # Rwanda -Link Africa/Maputo Africa/Lubumbashi # E Dem. Rep. of Congo -Link Africa/Maputo Africa/Lusaka # Zambia - - -# Namibia - -# From Arthur David Olson (2017-08-09): -# The text of the "Namibia Time Act, 1994" is available online at -# www.lac.org.na/laws/1994/811.pdf -# and includes this nugget: -# Notwithstanding the provisions of subsection (2) of section 1, the -# first winter period after the commencement of this Act shall -# commence at OOhOO on Monday 21 March 1994 and shall end at 02h00 on -# Sunday 4 September 1994. - -# From Michael Deckers (2017-04-06): -# ... both summer and winter time are called "standard" -# (which differs from the use in Ireland) ... - -# From Petronella Sibeene (2007-03-30): -# http://allafrica.com/stories/200703300178.html -# While the entire country changes its time, Katima Mulilo and other -# settlements in Caprivi unofficially will not because the sun there -# rises and sets earlier compared to other regions. Chief of -# Forecasting Riaan van Zyl explained that the far eastern parts of -# the country are close to 40 minutes earlier in sunrise than the rest -# of the country. -# -# From Paul Eggert (2017-02-22): -# Although the Zambezi Region (formerly known as Caprivi) informally -# observes Botswana time, we have no details about historical practice. -# In the meantime people there can use Africa/Gaborone. -# See: Immanuel S. The Namibian. 2017-02-23. -# https://www.namibian.com.na/51480/read/Time-change-divides-lawmakers - -# From Steffen Thorsen (2017-08-09): -# Namibia is going to change their time zone to what is now their DST: -# https://www.newera.com.na/2017/02/23/namibias-winter-time-might-be-repealed/ -# This video is from the government decision: -# https://www.nbc.na/news/na-passes-namibia-time-bill-repealing-1994-namibia-time-act.8665 -# We have made the assumption so far that they will change their time zone at -# the same time they would normally start DST, the first Sunday in September: -# https://www.timeanddate.com/news/time/namibia-new-time-zone.html - -# From Paul Eggert (2017-04-09): -# Before the change, summer and winter time were both standard time legally. -# However in common parlance, winter time was considered to be DST. See, e.g.: -# http://www.nbc.na/news/namibias-winter-time-could-be-scrapped.2706 -# https://zone.my.na/news/times-are-changing-in-namibia -# https://www.newera.com.na/2017/02/23/namibias-winter-time-might-be-repealed/ -# Use plain "WAT" and "CAT" for the time zone abbreviations, to be compatible -# with Namibia's neighbors. - -# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# Vanguard section, for zic and other parsers that support negative DST. -#Rule Namibia 1994 only - Mar 21 0:00 -1:00 WAT -#Rule Namibia 1994 2017 - Sep Sun>=1 2:00 0 CAT -#Rule Namibia 1995 2017 - Apr Sun>=1 2:00 -1:00 WAT -# Rearguard section, for parsers that do not support negative DST. -Rule Namibia 1994 only - Mar 21 0:00 0 WAT -Rule Namibia 1994 2017 - Sep Sun>=1 2:00 1:00 CAT -Rule Namibia 1995 2017 - Apr Sun>=1 2:00 0 WAT -# End of rearguard section. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Windhoek 1:08:24 - LMT 1892 Feb 8 - 1:30 - +0130 1903 Mar - 2:00 - SAST 1942 Sep 20 2:00 - 2:00 1:00 SAST 1943 Mar 21 2:00 - 2:00 - SAST 1990 Mar 21 # independence -# Vanguard section, for zic and other parsers that support negative DST. -# 2:00 Namibia %s -# Rearguard section, for parsers that do not support negative DST. - 2:00 - CAT 1994 Mar 21 0:00 -# From Paul Eggert (2017-04-07): -# The official date of the 2017 rule change was 2017-10-24. See: -# http://www.lac.org.na/laws/annoSTAT/Namibian%20Time%20Act%209%20of%202017.pdf - 1:00 Namibia %s 2017 Oct 24 - 2:00 - CAT -# End of rearguard section. - -# Niger -# See Africa/Lagos. - -# Nigeria -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Lagos 0:13:36 - LMT 1919 Sep - 1:00 - WAT -Link Africa/Lagos Africa/Bangui # Central African Republic -Link Africa/Lagos Africa/Brazzaville # Rep. of the Congo -Link Africa/Lagos Africa/Douala # Cameroon -Link Africa/Lagos Africa/Kinshasa # Dem. Rep. of the Congo (west) -Link Africa/Lagos Africa/Libreville # Gabon -Link Africa/Lagos Africa/Luanda # Angola -Link Africa/Lagos Africa/Malabo # Equatorial Guinea -Link Africa/Lagos Africa/Niamey # Niger -Link Africa/Lagos Africa/Porto-Novo # Benin - -# Réunion -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Reunion 3:41:52 - LMT 1911 Jun # Saint-Denis - 4:00 - +04 -# -# Crozet Islands also observes Réunion time; see the 'antarctica' file. -# -# Scattered Islands (Îles Éparses) administered from Réunion are as follows. -# The following information about them is taken from -# Îles Éparses (<http://www.outre-mer.gouv.fr/domtom/ile.htm>, 1997-07-22, -# in French; no longer available as of 1999-08-17). -# We have no info about their time zone histories. -# -# Bassas da India - uninhabited -# Europa Island - inhabited from 1905 to 1910 by two families -# Glorioso Is - inhabited until at least 1958 -# Juan de Nova - uninhabited -# Tromelin - inhabited until at least 1958 - -# Rwanda -# See Africa/Maputo. - -# St Helena -# See Africa/Abidjan. -# The other parts of the St Helena territory are similar: -# Tristan da Cunha: on GMT, say Whitman and the CIA -# Ascension: on GMT, say the USNO (1995-12-21) and the CIA -# Gough (scientific station since 1955; sealers wintered previously): -# on GMT, says the CIA -# Inaccessible, Nightingale: uninhabited - -# São Tomé and Príncipe - -# See Europe/Lisbon for info about the 1912 transition. - -# From Steffen Thorsen (2018-01-08): -# Multiple sources tell that São Tomé changed from UTC to UTC+1 as -# they entered the year 2018. -# From Michael Deckers (2018-01-08): -# the switch is from 01:00 to 02:00 ... [Decree No. 25/2017] -# http://www.mnec.gov.st/index.php/publicacoes/documentos/file/90-decreto-lei-n-25-2017 - -Zone Africa/Sao_Tome 0:26:56 - LMT 1884 - -0:36:45 - LMT 1912 Jan 1 00:00u # Lisbon MT - 0:00 - GMT 2018 Jan 1 01:00 - 1:00 - WAT - -# Senegal -# See Africa/Abidjan. - -# Seychelles -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Mahe 3:41:48 - LMT 1906 Jun # Victoria - 4:00 - +04 -# From Paul Eggert (2001-05-30): -# Aldabra, Farquhar, and Desroches, originally dependencies of the -# Seychelles, were transferred to the British Indian Ocean Territory -# in 1965 and returned to Seychelles control in 1976. We don't know -# whether this affected their time zone, so omit this for now. -# Possibly the islands were uninhabited. - -# Sierra Leone -# See Africa/Abidjan. - -# Somalia -# See Africa/Nairobi. - -# South Africa -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule SA 1942 1943 - Sep Sun>=15 2:00 1:00 - -Rule SA 1943 1944 - Mar Sun>=15 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Johannesburg 1:52:00 - LMT 1892 Feb 8 - 1:30 - SAST 1903 Mar - 2:00 SA SAST -Link Africa/Johannesburg Africa/Maseru # Lesotho -Link Africa/Johannesburg Africa/Mbabane # Swaziland -# -# Marion and Prince Edward Is -# scientific station since 1947 -# no information - -# Sudan - -# From <http://www.sunanews.net/sn13jane.html> -# Sudan News Agency (2000-01-13), -# also reported by Michaël De Beukelaer-Dossche via Steffen Thorsen: -# Clocks will be moved ahead for 60 minutes all over the Sudan as of noon -# Saturday.... This was announced Thursday by Caretaker State Minister for -# Manpower Abdul-Rahman Nur-Eddin. - -# From Ahmed Atyya, National Telecommunications Corp. (NTC), Sudan (2017-10-17): -# ... the Republic of Sudan is going to change the time zone from (GMT+3:00) -# to (GMT+ 2:00) starting from Wednesday 1 November 2017. -# -# From Paul Eggert (2017-10-18): -# A scanned copy (in Arabic) of Cabinet Resolution No. 352 for the -# year 2017 can be found as an attachment in email today from Yahia -# Abdalla of NTC, archived at: -# https://mm.icann.org/pipermail/tz/2017-October/025333.html - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Sudan 1970 only - May 1 0:00 1:00 S -Rule Sudan 1970 1985 - Oct 15 0:00 0 - -Rule Sudan 1971 only - Apr 30 0:00 1:00 S -Rule Sudan 1972 1985 - Apr lastSun 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Khartoum 2:10:08 - LMT 1931 - 2:00 Sudan CA%sT 2000 Jan 15 12:00 - 3:00 - EAT 2017 Nov 1 - 2:00 - CAT - -# South Sudan -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Juba 2:06:28 - LMT 1931 - 2:00 Sudan CA%sT 2000 Jan 15 12:00 - 3:00 - EAT - -# Swaziland -# See Africa/Johannesburg. - -# Tanzania -# See Africa/Nairobi. - -# Togo -# See Africa/Abidjan. - -# Tunisia - -# From Gwillim Law (2005-04-30): -# My correspondent, Risto Nykänen, has alerted me to another adoption of DST, -# this time in Tunisia. According to Yahoo France News -# <http://fr.news.yahoo.com/050426/5/4dumk.html>, in a story attributed to AP -# and dated 2005-04-26, "Tunisia has decided to advance its official time by -# one hour, starting on Sunday, May 1. Henceforth, Tunisian time will be -# UTC+2 instead of UTC+1. The change will take place at 23:00 UTC next -# Saturday." (My translation) -# -# From Oscar van Vlijmen (2005-05-02): -# La Presse, the first national daily newspaper ... -# http://www.lapresse.tn/archives/archives280405/actualites/lheure.html -# ... DST for 2005: on: Sun May 1 0h standard time, off: Fri Sept. 30, -# 1h standard time. -# -# From Atef Loukil (2006-03-28): -# The daylight saving time will be the same each year: -# Beginning : the last Sunday of March at 02:00 -# Ending : the last Sunday of October at 03:00 ... -# http://www.tap.info.tn/en/index.php?option=com_content&task=view&id=1188&Itemid=50 - -# From Steffen Thorsen (2009-03-16): -# According to several news sources, Tunisia will not observe DST this year. -# (Arabic) -# http://www.elbashayer.com/?page=viewn&nid=42546 -# https://www.babnet.net/kiwidetail-15295.asp -# -# We have also confirmed this with the US embassy in Tunisia. -# We have a wrap-up about this on the following page: -# https://www.timeanddate.com/news/time/tunisia-cancels-dst-2009.html - -# From Alexander Krivenyshev (2009-03-17): -# Here is a link to Tunis Afrique Presse News Agency -# -# Standard time to be kept the whole year long (tap.info.tn): -# -# (in English) -# http://www.tap.info.tn/en/index.php?option=com_content&task=view&id=26813&Itemid=157 -# -# (in Arabic) -# http://www.tap.info.tn/ar/index.php?option=com_content&task=view&id=61240&Itemid=1 - -# From Arthur David Olson (2009-03-18): -# The Tunis Afrique Presse News Agency notice contains this: "This measure is -# due to the fact that the fasting month of Ramadan coincides with the period -# concerned by summer time. Therefore, the standard time will be kept -# unchanged the whole year long." So foregoing DST seems to be an exception -# (albeit one that may be repeated in the future). - -# From Alexander Krivenyshev (2010-03-27): -# According to some news reports Tunis confirmed not to use DST in 2010 -# -# (translation): -# "The Tunisian government has decided to abandon DST, which was scheduled on -# Sunday... -# Tunisian authorities had suspended the DST for the first time last year also -# coincided with the month of Ramadan..." -# -# (in Arabic) -# http://www.moheet.com/show_news.aspx?nid=358861&pg=1 -# http://www.almadenahnews.com/newss/news.php?c=118&id=38036 -# http://www.worldtimezone.com/dst_news/dst_news_tunis02.html - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Tunisia 1939 only - Apr 15 23:00s 1:00 S -Rule Tunisia 1939 only - Nov 18 23:00s 0 - -Rule Tunisia 1940 only - Feb 25 23:00s 1:00 S -Rule Tunisia 1941 only - Oct 6 0:00 0 - -Rule Tunisia 1942 only - Mar 9 0:00 1:00 S -Rule Tunisia 1942 only - Nov 2 3:00 0 - -Rule Tunisia 1943 only - Mar 29 2:00 1:00 S -Rule Tunisia 1943 only - Apr 17 2:00 0 - -Rule Tunisia 1943 only - Apr 25 2:00 1:00 S -Rule Tunisia 1943 only - Oct 4 2:00 0 - -Rule Tunisia 1944 1945 - Apr Mon>=1 2:00 1:00 S -Rule Tunisia 1944 only - Oct 8 0:00 0 - -Rule Tunisia 1945 only - Sep 16 0:00 0 - -Rule Tunisia 1977 only - Apr 30 0:00s 1:00 S -Rule Tunisia 1977 only - Sep 24 0:00s 0 - -Rule Tunisia 1978 only - May 1 0:00s 1:00 S -Rule Tunisia 1978 only - Oct 1 0:00s 0 - -Rule Tunisia 1988 only - Jun 1 0:00s 1:00 S -Rule Tunisia 1988 1990 - Sep lastSun 0:00s 0 - -Rule Tunisia 1989 only - Mar 26 0:00s 1:00 S -Rule Tunisia 1990 only - May 1 0:00s 1:00 S -Rule Tunisia 2005 only - May 1 0:00s 1:00 S -Rule Tunisia 2005 only - Sep 30 1:00s 0 - -Rule Tunisia 2006 2008 - Mar lastSun 2:00s 1:00 S -Rule Tunisia 2006 2008 - Oct lastSun 2:00s 0 - - -# Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's -# more precise 0:09:21. -# Shanks & Pottenger say the 1911 switch was on Mar 9; go with Howse's Mar 11. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Tunis 0:40:44 - LMT 1881 May 12 - 0:09:21 - PMT 1911 Mar 11 # Paris Mean Time - 1:00 Tunisia CE%sT - -# Uganda -# See Africa/Nairobi. - -# Zambia -# Zimbabwe -# See Africa/Maputo. diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/antarctica b/src/test/jdk/sun/util/calendar/zi/tzdata/antarctica deleted file mode 100644 index d98afed9b85..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/antarctica +++ /dev/null @@ -1,366 +0,0 @@ -# -# 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. -# -# tzdb data for Antarctica and environs - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# From Paul Eggert (1999-11-15): -# To keep things manageable, we list only locations occupied year-round; see -# COMNAP - Stations and Bases -# http://www.comnap.aq/comnap/comnap.nsf/P/Stations/ -# and -# Summary of the Peri-Antarctic Islands (1998-07-23) -# http://www.spri.cam.ac.uk/bob/periant.htm -# for information. -# Unless otherwise specified, we have no time zone information. - -# FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited. - -# Argentina - year-round bases -# Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 -# Carlini, Potter Cove, King George Island, -6414-0602320, since 1982-01 -# Esperanza, Hope Bay, -6323-05659, since 1952-12-17 -# Marambio, -6414-05637, since 1969-10-29 -# Orcadas, Laurie I, -6016-04444, since 1904-02-22 -# San Martín, Barry I, -6808-06706, since 1951-03-21 -# (except 1960-03 / 1976-03-21) - -# Australia - territories -# Heard Island, McDonald Islands (uninhabited) -# previously sealers and scientific personnel wintered -# Margaret Turner reports -# https://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html -# (1999-09-30) that they're UT +05, with no DST; -# presumably this is when they have visitors. -# -# year-round bases -# Casey, Bailey Peninsula, -6617+11032, since 1969 -# Davis, Vestfold Hills, -6835+07759, since 1957-01-13 -# (except 1964-11 - 1969-02) -# Mawson, Holme Bay, -6736+06253, since 1954-02-13 - -# From Steffen Thorsen (2009-03-11): -# Three Australian stations in Antarctica have changed their time zone: -# Casey moved from UTC+8 to UTC+11 -# Davis moved from UTC+7 to UTC+5 -# Mawson moved from UTC+6 to UTC+5 -# The changes occurred on 2009-10-18 at 02:00 (local times). -# -# Government source: (Australian Antarctic Division) -# http://www.aad.gov.au/default.asp?casid=37079 -# -# We have more background information here: -# https://www.timeanddate.com/news/time/antarctica-new-times.html - -# From Steffen Thorsen (2010-03-10): -# We got these changes from the Australian Antarctic Division: ... -# -# - Casey station reverted to its normal time of UTC+8 on 5 March 2010. -# The change to UTC+11 is being considered as a regular summer thing but -# has not been decided yet. -# -# - Davis station will revert to its normal time of UTC+7 at 10 March 2010 -# 20:00 UTC. -# -# - Mawson station stays on UTC+5. -# -# Background: -# https://www.timeanddate.com/news/time/antartica-time-changes-2010.html - -# From Steffen Thorsen (2016-10-28): -# Australian Antarctica Division informed us that Casey changed time -# zone to UTC+11 in "the morning of 22nd October 2016". - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Casey 0 - -00 1969 - 8:00 - +08 2009 Oct 18 2:00 - 11:00 - +11 2010 Mar 5 2:00 - 8:00 - +08 2011 Oct 28 2:00 - 11:00 - +11 2012 Feb 21 17:00u - 8:00 - +08 2016 Oct 22 - 11:00 - +11 2018 Mar 11 4:00 - 8:00 - +08 -Zone Antarctica/Davis 0 - -00 1957 Jan 13 - 7:00 - +07 1964 Nov - 0 - -00 1969 Feb - 7:00 - +07 2009 Oct 18 2:00 - 5:00 - +05 2010 Mar 10 20:00u - 7:00 - +07 2011 Oct 28 2:00 - 5:00 - +05 2012 Feb 21 20:00u - 7:00 - +07 -Zone Antarctica/Mawson 0 - -00 1954 Feb 13 - 6:00 - +06 2009 Oct 18 2:00 - 5:00 - +05 -# References: -# Casey Weather (1998-02-26) -# http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html -# Davis Station, Antarctica (1998-02-26) -# http://www.antdiv.gov.au/aad/exop/sfo/davis/video.html -# Mawson Station, Antarctica (1998-02-25) -# http://www.antdiv.gov.au/aad/exop/sfo/mawson/video.html - -# Belgium - year-round base -# Princess Elisabeth, Queen Maud Land, -713412+0231200, since 2007 - -# Brazil - year-round base -# Ferraz, King George Island, -6205+05824, since 1983/4 - -# Bulgaria - year-round base -# St. Kliment Ohridski, Livingston Island, -623829-0602153, since 1988 - -# Chile - year-round bases and towns -# Escudero, South Shetland Is, -621157-0585735, since 1994 -# Frei Montalva, King George Island, -6214-05848, since 1969-03-07 -# O'Higgins, Antarctic Peninsula, -6319-05704, since 1948-02 -# Prat, -6230-05941 -# Villa Las Estrellas (a town), around the Frei base, since 1984-04-09 -# These locations employ Region of Magallanes time; use -# TZ='America/Punta_Arenas'. - -# China - year-round bases -# Great Wall, King George Island, -6213-05858, since 1985-02-20 -# Zhongshan, Larsemann Hills, Prydz Bay, -6922+07623, since 1989-02-26 - -# France - year-round bases (also see "France & Italy") -# -# From Antoine Leca (1997-01-20): -# Time data entries are from Nicole Pailleau at the IFRTP -# (French Institute for Polar Research and Technology). -# She confirms that French Southern Territories and Terre Adélie bases -# don't observe daylight saving time, even if Terre Adélie supplies came -# from Tasmania. -# -# French Southern Territories with year-round inhabitants -# -# Alfred Faure, Possession Island, Crozet Islands, -462551+0515152, since 1964; -# sealing & whaling stations operated variously 1802/1911+; -# see Indian/Reunion. -# -# Martin-de-Viviès, Amsterdam Island, -374105+0773155, since 1950 -# Port-aux-Français, Kerguelen Islands, -492110+0701303, since 1951; -# whaling & sealing station operated 1908/1914, 1920/1929, and 1951/1956 -# -# St Paul Island - near Amsterdam, uninhabited -# fishing stations operated variously 1819/1931 -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français - 5:00 - +05 -# -# year-round base in the main continent -# Dumont d'Urville, Île des Pétrels, -6640+14001, since 1956-11 -# <https://en.wikipedia.org/wiki/Dumont_d'Urville_Station> (2005-12-05) -# -# Another base at Port-Martin, 50km east, began operation in 1947. -# It was destroyed by fire on 1952-01-14. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/DumontDUrville 0 - -00 1947 - 10:00 - +10 1952 Jan 14 - 0 - -00 1956 Nov - 10:00 - +10 - -# France & Italy - year-round base -# Concordia, -750600+1232000, since 2005 - -# Germany - year-round base -# Neumayer III, -704080-0081602, since 2009 - -# India - year-round bases -# Bharati, -692428+0761114, since 2012 -# Maitri, -704558+0114356, since 1989 - -# Italy - year-round base (also see "France & Italy") -# Zuchelli, Terra Nova Bay, -744140+1640647, since 1986 - -# Japan - year-round bases -# Syowa (also known as Showa), -690022+0393524, since 1957 -# -# From Hideyuki Suzuki (1999-02-06): -# In all Japanese stations, +0300 is used as the standard time. -# -# Syowa station, which is the first antarctic station of Japan, -# was established on 1957-01-29. Since Syowa station is still the main -# station of Japan, it's appropriate for the principal location. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Syowa 0 - -00 1957 Jan 29 - 3:00 - +03 -# See: -# NIPR Antarctic Research Activities (1999-08-17) -# http://www.nipr.ac.jp/english/ara01.html - -# S Korea - year-round base -# Jang Bogo, Terra Nova Bay, -743700+1641205 since 2014 -# King Sejong, King George Island, -6213-05847, since 1988 - -# New Zealand - claims -# Balleny Islands (never inhabited) -# Scott Island (never inhabited) -# -# year-round base -# Scott Base, Ross Island, since 1957-01. -# See Pacific/Auckland. - -# Norway - territories -# Bouvet (never inhabited) -# -# claims -# Peter I Island (never inhabited) -# -# year-round base -# Troll, Queen Maud Land, -720041+0023206, since 2005-02-12 -# -# From Paul-Inge Flakstad (2014-03-10): -# I recently had a long dialog about this with the developer of timegenie.com. -# In the absence of specific dates, he decided to choose some likely ones: -# GMT +1 - From March 1 to the last Sunday in March -# GMT +2 - From the last Sunday in March until the last Sunday in October -# GMT +1 - From the last Sunday in October until November 7 -# GMT +0 - From November 7 until March 1 -# The dates for switching to and from UTC+0 will probably not be absolutely -# correct, but they should be quite close to the actual dates. -# -# From Paul Eggert (2014-03-21): -# The CET-switching Troll rules require zic from tz 2014b or later, so as -# suggested by Bengt-Inge Larsson comment them out for now, and approximate -# with only UTC and CEST. Uncomment them when 2014b is more prevalent. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Troll 2005 max - Mar 1 1:00u 1:00 +01 -Rule Troll 2005 max - Mar lastSun 1:00u 2:00 +02 -#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 +01 -#Rule Troll 2004 max - Nov 7 1:00u 0:00 +00 -# Remove the following line when uncommenting the above '#Rule' lines. -Rule Troll 2004 max - Oct lastSun 1:00u 0:00 +00 -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Troll 0 - -00 2005 Feb 12 - 0:00 Troll %s - -# Poland - year-round base -# Arctowski, King George Island, -620945-0582745, since 1977 - -# Romania - year-bound base -# Law-Racoviță, Larsemann Hills, -692319+0762251, since 1986 - -# Russia - year-round bases -# Bellingshausen, King George Island, -621159-0585337, since 1968-02-22 -# Mirny, Davis coast, -6633+09301, since 1956-02 -# Molodezhnaya, Alasheyev Bay, -6740+04551, -# year-round from 1962-02 to 1999-07-01 -# Novolazarevskaya, Queen Maud Land, -7046+01150, -# year-round from 1960/61 to 1992 - -# Vostok, since 1957-12-16, temporarily closed 1994-02/1994-11 -# From Craig Mundell (1994-12-15): -# http://quest.arc.nasa.gov/antarctica/QA/computers/Directions,Time,ZIP -# Vostok, which is one of the Russian stations, is set on the same -# time as Moscow, Russia. -# -# From Lee Hotz (2001-03-08): -# I queried the folks at Columbia who spent the summer at Vostok and this is -# what they had to say about time there: -# "in the US Camp (East Camp) we have been on New Zealand (McMurdo) -# time, which is 12 hours ahead of GMT. The Russian Station Vostok was -# 6 hours behind that (although only 2 miles away, i.e. 6 hours ahead -# of GMT). This is a time zone I think two hours east of Moscow. The -# natural time zone is in between the two: 8 hours ahead of GMT." -# -# From Paul Eggert (2001-05-04): -# This seems to be hopelessly confusing, so I asked Lee Hotz about it -# in person. He said that some Antarctic locations set their local -# time so that noon is the warmest part of the day, and that this -# changes during the year and does not necessarily correspond to mean -# solar noon. So the Vostok time might have been whatever the clocks -# happened to be during their visit. So we still don't really know what time -# it is at Vostok. But we'll guess +06. -# -Zone Antarctica/Vostok 0 - -00 1957 Dec 16 - 6:00 - +06 - -# S Africa - year-round bases -# Marion Island, -4653+03752 -# SANAE IV, Vesleskarvet, Queen Maud Land, -714022-0025026, since 1997 - -# Ukraine - year-round base -# Vernadsky (formerly Faraday), Galindez Island, -651445-0641526, since 1954 - -# United Kingdom -# -# British Antarctic Territories (BAT) claims -# South Orkney Islands -# scientific station from 1903 -# whaling station at Signy I 1920/1926 -# South Shetland Islands -# -# year-round bases -# Bird Island, South Georgia, -5400-03803, since 1983 -# Deception Island, -6259-06034, whaling station 1912/1931, -# scientific station 1943/1967, -# previously sealers and a scientific expedition wintered by accident, -# and a garrison was deployed briefly -# Halley, Coates Land, -7535-02604, since 1956-01-06 -# Halley is on a moving ice shelf and is periodically relocated -# so that it is never more than 10km from its nominal location. -# Rothera, Adelaide Island, -6734-6808, since 1976-12-01 -# -# From Paul Eggert (2002-10-22) -# <http://webexhibits.org/daylightsaving/g.html> says Rothera is -03 all year. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Rothera 0 - -00 1976 Dec 1 - -3:00 - -03 - -# Uruguay - year round base -# Artigas, King George Island, -621104-0585107 - -# USA - year-round bases -# -# Palmer, Anvers Island, since 1965 (moved 2 miles in 1968) -# See 'southamerica' for Antarctica/Palmer, since it uses South American DST. -# -# McMurdo Station, Ross Island, since 1955-12 -# Amundsen-Scott South Pole Station, continuously occupied since 1956-11-20 -# -# From Chris Carrier (1996-06-27): -# Siple, the first commander of the South Pole station, -# stated that he would have liked to have kept GMT at the station, -# but that he found it more convenient to keep GMT+12 -# as supplies for the station were coming from McMurdo Sound, -# which was on GMT+12 because New Zealand was on GMT+12 all year -# at that time (1957). (Source: Siple's book 90 Degrees South.) -# -# From Susan Smith -# http://www.cybertours.com/whs/pole10.html -# (1995-11-13 16:24:56 +1300, no longer available): -# We use the same time as McMurdo does. -# And they use the same time as Christchurch, NZ does.... -# One last quirk about South Pole time. -# All the electric clocks are usually wrong. -# Something about the generators running at 60.1hertz or something -# makes all of the clocks run fast. So every couple of days, -# we have to go around and set them back 5 minutes or so. -# Maybe if we let them run fast all of the time, we'd get to leave here sooner!! -# -# See 'australasia' for Antarctica/McMurdo. diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/asia b/src/test/jdk/sun/util/calendar/zi/tzdata/asia deleted file mode 100644 index 57255f2b6b8..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/asia +++ /dev/null @@ -1,3406 +0,0 @@ -# -# 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. -# -# tzdb data for Asia and environs - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# This file is by no means authoritative; if you think you know better, -# go ahead and edit the file (and please send any changes to -# tz@iana.org for general use in the future). For more, please see -# the file CONTRIBUTING in the tz distribution. - -# From Paul Eggert (2018-06-19): -# -# Unless otherwise specified, the source for data through 1990 is: -# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), -# San Diego: ACS Publications, Inc. (2003). -# Unfortunately this book contains many errors and cites no sources. -# -# Many years ago Gwillim Law wrote that a good source -# for time zone data was the International Air Transport -# Association's Standard Schedules Information Manual (IATA SSIM), -# published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. Except where otherwise noted, -# IATA SSIM is the source for entries after 1990. -# -# Another source occasionally used is Edward W. Whitman, World Time Differences, -# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which -# I found in the UCLA library. -# -# For data circa 1899, a common source is: -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# https://www.jstor.org/stable/1774359 -# -# For Russian data circa 1919, a source is: -# Byalokoz EL. New Counting of Time in Russia since July 1, 1919. -# (See the 'europe' file for a fuller citation.) -# -# A reliable and entertaining source about time zones is -# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). -# -# The following alphabetic abbreviations appear in these tables -# (corrections are welcome): -# std dst -# LMT Local Mean Time -# 2:00 EET EEST Eastern European Time -# 2:00 IST IDT Israel -# 5:30 IST India -# 7:00 WIB west Indonesia (Waktu Indonesia Barat) -# 8:00 WITA central Indonesia (Waktu Indonesia Tengah) -# 8:00 CST China -# 8:00 PST PDT* Philippine Standard Time -# 8:30 KST KDT Korea when at +0830 -# 9:00 WIT east Indonesia (Waktu Indonesia Timur) -# 9:00 JST JDT Japan -# 9:00 KST KDT Korea when at +09 -# 9:30 ACST Australian Central Standard Time -# *I invented the abbreviation PDT; see "Philippines" below. -# Otherwise, these tables typically use numeric abbreviations like +03 -# and +0330 for integer hour and minute UT offsets. Although earlier -# editions invented alphabetic time zone abbreviations for every -# offset, this did not reflect common practice. -# -# See the 'europe' file for Russia and Turkey in Asia. - -# From Guy Harris: -# Incorporates data for Singapore from Robert Elz' asia 1.1, as well as -# additional information from Tom Yap, Sun Microsystems Intercontinental -# Technical Support (including a page from the Official Airline Guide - -# Worldwide Edition). - -############################################################################### - -# These rules are stolen from the 'europe' file. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule EUAsia 1981 max - Mar lastSun 1:00u 1:00 S -Rule EUAsia 1979 1995 - Sep lastSun 1:00u 0 - -Rule EUAsia 1996 max - Oct lastSun 1:00u 0 - -Rule E-EurAsia 1981 max - Mar lastSun 0:00 1:00 - -Rule E-EurAsia 1979 1995 - Sep lastSun 0:00 0 - -Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - -Rule RussiaAsia 1981 1984 - Apr 1 0:00 1:00 - -Rule RussiaAsia 1981 1983 - Oct 1 0:00 0 - -Rule RussiaAsia 1984 1995 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1985 2010 - Mar lastSun 2:00s 1:00 - -Rule RussiaAsia 1996 2010 - Oct lastSun 2:00s 0 - - -# Afghanistan -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kabul 4:36:48 - LMT 1890 - 4:00 - +04 1945 - 4:30 - +0430 - -# Armenia -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger have Yerevan switching to 3:00 (with Russian DST) -# in spring 1991, then to 4:00 with no DST in fall 1995, then -# readopting Russian DST in 1997. Go with Shanks & Pottenger, even -# when they disagree with others. Edgar Der-Danieliantz -# reported (1996-05-04) that Yerevan probably wouldn't use DST -# in 1996, though it did use DST in 1995. IATA SSIM (1991/1998) reports that -# Armenia switched from 3:00 to 4:00 in 1998 and observed DST after 1991, -# but started switching at 3:00s in 1998. - -# From Arthur David Olson (2011-06-15): -# While Russia abandoned DST in 2011, Armenia may choose to -# follow Russia's "old" rules. - -# From Alexander Krivenyshev (2012-02-10): -# According to News Armenia, on Feb 9, 2012, -# http://newsarmenia.ru/society/20120209/42609695.html -# -# The Armenia National Assembly adopted final reading of Amendments to the -# Law "On procedure of calculation time on the territory of the Republic of -# Armenia" according to which Armenia [is] abolishing Daylight Saving Time. -# or -# (brief) -# http://www.worldtimezone.com/dst_news/dst_news_armenia03.html -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Armenia 2011 only - Mar lastSun 2:00s 1:00 - -Rule Armenia 2011 only - Oct lastSun 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 - 3:00 - +03 1957 Mar - 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s - 3:00 RussiaAsia +03/+04 1995 Sep 24 2:00s - 4:00 - +04 1997 - 4:00 RussiaAsia +04/+05 2011 - 4:00 Armenia +04/+05 - -# Azerbaijan - -# From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23): -# According to the resolution of Cabinet of Ministers, 1997 -# From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17). -# http://code.az/files/daylight_res.pdf - -# From Steffen Thorsen (2016-03-17): -# ... the Azerbaijani Cabinet of Ministers has cancelled switching to -# daylight saving time.... -# https://www.azernews.az/azerbaijan/94137.html -# http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html -# http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Azer 1997 2015 - Mar lastSun 4:00 1:00 - -Rule Azer 1997 2015 - Oct lastSun 5:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Baku 3:19:24 - LMT 1924 May 2 - 3:00 - +03 1957 Mar - 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s - 3:00 RussiaAsia +03/+04 1992 Sep lastSun 2:00s - 4:00 - +04 1996 - 4:00 EUAsia +04/+05 1997 - 4:00 Azer +04/+05 - -# Bahrain -# See Asia/Qatar. - -# Bangladesh -# From Alexander Krivenyshev (2009-05-13): -# According to newspaper Asian Tribune (May 6, 2009) Bangladesh may introduce -# Daylight Saving Time from June 16 to Sept 30 -# -# Bangladesh to introduce daylight saving time likely from June 16 -# http://www.asiantribune.com/?q=node/17288 -# http://www.worldtimezone.com/dst_news/dst_news_bangladesh02.html -# -# "... Bangladesh government has decided to switch daylight saving time from -# June -# 16 till September 30 in a bid to ensure maximum use of daylight to cope with -# crippling power crisis. " -# -# The switch will remain in effect from June 16 to Sept 30 (2009) but if -# implemented the next year, it will come in force from April 1, 2010 - -# From Steffen Thorsen (2009-06-02): -# They have finally decided now, but changed the start date to midnight between -# the 19th and 20th, and they have not set the end date yet. -# -# Some sources: -# https://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601 -# http://bdnews24.com/details.php?id=85889&cid=2 -# -# Our wrap-up: -# https://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html - -# From A. N. M. Kamrus Saadat (2009-06-15): -# Finally we've got the official mail regarding DST start time where DST start -# time is mentioned as Jun 19 2009, 23:00 from BTRC (Bangladesh -# Telecommunication Regulatory Commission). -# -# No DST end date has been announced yet. - -# From Alexander Krivenyshev (2009-09-25): -# Bangladesh won't go back to Standard Time from October 1, 2009, -# instead it will continue DST measure till the cabinet makes a fresh decision. -# -# Following report by same newspaper-"The Daily Star Friday": -# "DST change awaits cabinet decision-Clock won't go back by 1-hr from Oct 1" -# http://www.thedailystar.net/newDesign/news-details.php?nid=107021 -# http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html - -# From Steffen Thorsen (2009-10-13): -# IANS (Indo-Asian News Service) now reports: -# Bangladesh has decided that the clock advanced by an hour to make -# maximum use of daylight hours as an energy saving measure would -# "continue for an indefinite period." -# -# One of many places where it is published: -# http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html - -# From Alexander Krivenyshev (2009-12-24): -# According to Bangladesh newspaper "The Daily Star," -# Bangladesh will change its clock back to Standard Time on Dec 31, 2009. -# -# Clock goes back 1-hr on Dec 31 night. -# http://www.thedailystar.net/newDesign/news-details.php?nid=119228 -# http://www.worldtimezone.com/dst_news/dst_news_bangladesh05.html -# -# "...The government yesterday decided to put the clock back by one hour -# on December 31 midnight and the new time will continue until March 31, -# 2010 midnight. The decision came at a cabinet meeting at the Prime -# Minister's Office last night..." - -# From Alexander Krivenyshev (2010-03-22): -# According to Bangladesh newspaper "The Daily Star," -# Cabinet cancels Daylight Saving Time -# http://www.thedailystar.net/newDesign/latest_news.php?nid=22817 -# http://www.worldtimezone.com/dst_news/dst_news_bangladesh06.html - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Dhaka 2009 only - Jun 19 23:00 1:00 - -Rule Dhaka 2009 only - Dec 31 24:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Dhaka 6:01:40 - LMT 1890 - 5:53:20 - HMT 1941 Oct # Howrah Mean Time? - 6:30 - +0630 1942 May 15 - 5:30 - +0530 1942 Sep - 6:30 - +0630 1951 Sep 30 - 6:00 - +06 2009 - 6:00 Dhaka +06/+07 - -# Bhutan -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Thimphu 5:58:36 - LMT 1947 Aug 15 # or Thimbu - 5:30 - +0530 1987 Oct - 6:00 - +06 - -# British Indian Ocean Territory -# Whitman and the 1995 CIA time zone map say 5:00, but the -# 1997 and later maps say 6:00. Assume the switch occurred in 1996. -# We have no information as to when standard time was introduced; -# assume it occurred in 1907, the same year as Mauritius (which -# then contained the Chagos Archipelago). -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Chagos 4:49:40 - LMT 1907 - 5:00 - +05 1996 - 6:00 - +06 - -# Brunei -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Bandar Seri Begawan - 7:30 - +0730 1933 - 8:00 - +08 - -# Burma / Myanmar - -# Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon. - -# From Paul Eggert (2017-04-20): -# Page 27 of Reed & Low (cited for Asia/Kolkata) says "Rangoon local time is -# used upon the railways and telegraphs of Burma, and is 6h. 24m. 47s. ahead -# of Greenwich." This refers to the period before Burma's transition to +0630, -# a transition for which Shanks is the only source. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Yangon 6:24:47 - LMT 1880 # or Rangoon - 6:24:47 - RMT 1920 # Rangoon local time - 6:30 - +0630 1942 May - 9:00 - +09 1945 May 3 - 6:30 - +0630 - -# Cambodia -# See Asia/Bangkok. - - -# China - -# From Paul Eggert (2018-10-02): -# The following comes from Table 1 of: -# Li Yu. Research on the daylight saving movement in 1940s Shanghai. -# Nanjing Journal of Social Sciences. 2014;(2):144-50. -# http://oversea.cnki.net/kns55/detail.aspx?dbname=CJFD2014&filename=NJSH201402020 -# The table lists dates only; I am guessing 00:00 and 24:00 transition times. -# Also, the table lists the planned end of DST in 1949, but the corresponding -# zone line cuts this off on May 28, when the Communists took power. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Shang 1940 only - Jun 1 0:00 1:00 D -Rule Shang 1940 only - Oct 12 24:00 0 S -Rule Shang 1941 only - Mar 15 0:00 1:00 D -Rule Shang 1941 only - Nov 1 24:00 0 S -Rule Shang 1942 only - Jan 31 0:00 1:00 D -Rule Shang 1945 only - Sep 1 24:00 0 S -Rule Shang 1946 only - May 15 0:00 1:00 D -Rule Shang 1946 only - Sep 30 24:00 0 S -Rule Shang 1947 only - Apr 15 0:00 1:00 D -Rule Shang 1947 only - Oct 31 24:00 0 S -Rule Shang 1948 1949 - May 1 0:00 1:00 D -Rule Shang 1948 1949 - Sep 30 24:00 0 S #plan - -# From Guy Harris: -# People's Republic of China. Yes, they really have only one time zone. - -# From Bob Devine (1988-01-28): -# No they don't. See TIME mag, 1986-02-17 p.52. Even though -# China is across 4 physical time zones, before Feb 1, 1986 only the -# Peking (Beijing) time zone was recognized. Since that date, China -# has two of 'em - Peking's and Ürümqi (named after the capital of -# the Xinjiang Uyghur Autonomous Region). I don't know about DST for it. -# -# . . .I just deleted the DST table and this editor makes it too -# painful to suck in another copy. So, here is what I have for -# DST start/end dates for Peking's time zone (info from AP): -# -# 1986 May 4 - Sept 14 -# 1987 mid-April - ?? - -# From U. S. Naval Observatory (1989-01-19): -# CHINA 8 H AHEAD OF UTC ALL OF CHINA, INCL TAIWAN -# CHINA 9 H AHEAD OF UTC APR 17 - SEP 10 - -# From Paul Eggert (2008-02-11): -# Jim Mann, "A clumsy embrace for another western custom: China on daylight -# time - sort of", Los Angeles Times, 1986-05-05 ... [says] that China began -# observing daylight saving time in 1986. - -# From P Chan (2018-05-07): -# The start and end time of DST in China [from 1986 on] should be 2:00 -# (i.e. 2:00 to 3:00 at the start and 2:00 to 1:00 at the end).... -# Government notices about summer time: -# -# 1986-04-12 http://www.zj.gov.cn/attach/zfgb/198608.pdf p.21-22 -# (To establish summer time from 1986. On 4 May, set the clocks ahead one hour -# at 2 am. On 14 September, set the clocks backward one hour at 2 am.) -# -# 1987-02-15 http://www.gov.cn/gongbao/shuju/1987/gwyb198703.pdf p.114 -# (Summer time in 1987 to start from 12 April until 13 September) -# -# 1987-09-09 http://www.gov.cn/gongbao/shuju/1987/gwyb198721.pdf p.709 -# (From 1988, summer time to start from 2 am of the first Sunday of mid-April -# until 2 am of the first Sunday of mid-September) -# -# 1992-03-03 http://www.gov.cn/gongbao/shuju/1992/gwyb199205.pdf p.152 -# (To suspend summer time from 1992) -# -# The first page of People's Daily on 12 April 1988 stating that summer time -# to begin on 17 April. -# http://data.people.com.cn/pic/101p/1988/04/1988041201.jpg - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule PRC 1986 only - May 4 2:00 1:00 D -Rule PRC 1986 1991 - Sep Sun>=11 2:00 0 S -Rule PRC 1987 1991 - Apr Sun>=11 2:00 1:00 D - -# From Anthony Fok (2001-12-20): -# BTW, I did some research on-line and found some info regarding these five -# historic timezones from some Taiwan websites. And yes, there are official -# Chinese names for these locales (before 1949). -# -# From Jesper Nørgaard Welen (2006-07-14): -# I have investigated the timezones around 1970 on the -# https://www.astro.com/atlas site [with provinces and county -# boundaries summarized below].... A few other exceptions were two -# counties on the Sichuan side of the Xizang-Sichuan border, -# counties Dege and Baiyu which lies on the Sichuan side and are -# therefore supposed to be GMT+7, Xizang region being GMT+6, but Dege -# county is GMT+8 according to astro.com while Baiyu county is GMT+6 -# (could be true), for the moment I am assuming that those two -# counties are mistakes in the astro.com data. - -# From Paul Eggert (2017-01-05): -# Alois Treindl kindly sent me translations of the following two sources: -# -# (1) -# Guo Qing-sheng (National Time-Service Center, CAS, Xi'an 710600, China) -# Beijing Time at the Beginning of the PRC -# China Historical Materials of Science and Technology -# (Zhongguo ke ji shi liao, 中国科技史料). 2003;24(1):5-9. -# http://oversea.cnki.net/kcms/detail/detail.aspx?filename=ZGKS200301000&dbname=CJFD2003 -# It gives evidence that at the beginning of the PRC, Beijing time was -# officially apparent solar time! However, Guo also says that the -# evidence is dubious, as the relevant institute of astronomy had not -# been taken over by the PRC yet. It's plausible that apparent solar -# time was announced but never implemented, and that people continued -# to use UT+8. As the Shanghai radio station (and I presume the -# observatory) was still under control of French missionaries, it -# could well have ignored any such mandate. -# -# (2) -# Guo Qing-sheng (Shaanxi Astronomical Observatory, CAS, Xi'an 710600, China) -# A Study on the Standard Time Changes for the Past 100 Years in China -# [undated and unknown publication location] -# It says several things: -# * The Qing dynasty used local apparent solar time throughout China. -# * The Republic of China instituted Beijing mean solar time effective -# the official calendar book of 1914. -# * The French Concession in Shanghai set up signal stations in -# French docks in the 1890s, controlled by Xujiahui (Zikawei) -# Observatory and set to local mean time. -# * "From the end of the 19th century" it changed to UT+8. -# * Chinese Customs (by then reduced to a tool of foreign powers) -# eventually standardized on this time for all ports, and it -# became used by railways as well. -# * In 1918 the Central Observatory proposed dividing China into -# five time zones (see below for details). This caught on -# at first only in coastal areas observing UT+8. -# * During WWII all of China was in theory was at UT+7. In practice -# this was ignored in the west, and I presume was ignored in -# Japanese-occupied territory. -# * Japanese-occupied Manchuria was at UT+9, i.e., Japan time. -# * The five-zone plan was resurrected after WWII and officially put into -# place (with some modifications) in March 1948. It's not clear -# how well it was observed in areas under Nationalist control. -# * The People's Liberation Army used UT+8 during the civil war. -# -# An AP article "Shanghai Internat'l Area Little Changed" in the -# Lewiston (ME) Daily Sun (1939-05-29), p 17, said "Even the time is -# different - the occupied districts going by Tokyo time, an hour -# ahead of that prevailing in the rest of Shanghai." Guess that the -# Xujiahui Observatory was under French control and stuck with UT +08. -# -# In earlier versions of this file, China had many separate Zone entries, but -# this was based on what were apparently incorrect data in Shanks & Pottenger. -# This has now been simplified to the two entries Asia/Shanghai and -# Asia/Urumqi, with the others being links for backward compatibility. -# Proposed in 1918 and theoretically in effect until 1949 (although in practice -# mainly observed in coastal areas), the five zones were: -# -# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30 -# Now part of Asia/Shanghai; its pre-1970 times are not recorded here. -# Heilongjiang (except Mohe county), Jilin -# -# Zhongyuan Time ("Central plain Time") UT +08 -# Now part of Asia/Shanghai. -# most of China -# Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest. -# Guo says Shanghai switched to UT +08 "from the end of the 19th century". -# -# Long-shu Time (probably as Long and Shu were two names of the area) UT +07 -# Now part of Asia/Shanghai; its pre-1970 times are not recorded here. -# Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan; -# most of Gansu; west Inner Mongolia; east Qinghai; and the Guangdong -# counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing, -# Yangchun, Yangjiang, Yu'nan, and Yunfu. -# -# Xin-zang Time ("Xinjiang-Tibet Time") UT +06 -# This region is now part of either Asia/Urumqi or Asia/Shanghai with -# current boundaries uncertain; times before 1970 for areas that -# disagree with Ürümqi or Shanghai are not recorded here. -# The Gansu counties Aksay, Anxi, Dunhuang, Subei; west Qinghai; -# the Guangdong counties Xuwen, Haikang, Suixi, Lianjiang, -# Zhanjiang, Wuchuan, Huazhou, Gaozhou, Maoming, Dianbai, and Xinyi; -# east Tibet, including Lhasa, Chamdo, Shigaise, Jimsar, Shawan and Hutubi; -# east Xinjiang, including Ürümqi, Turpan, Karamay, Korla, Minfeng, Jinghe, -# Wusu, Qiemo, Xinyan, Wulanwusu, Jinghe, Yumin, Tacheng, Tuoli, Emin, -# Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami, -# Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan. -# -# Kunlun Time UT +05:30 -# This region is now in the same status as Xin-zang Time (see above). -# West Tibet, including Pulan, Aheqi, Shufu, Shule; -# West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke, -# Zhaosu, Tekesi, Gongliu, Chabuchaer, Huocheng, Bole, Pishan, Suiding, -# and Yarkand. - -# From Luther Ma (2009-10-17): -# Almost all (>99.9%) ethnic Chinese (properly ethnic Han) living in -# Xinjiang use Chinese Standard Time. Some are aware of Xinjiang time, -# but have no need of it. All planes, trains, and schools function on -# what is called "Beijing time." When Han make an appointment in Chinese -# they implicitly use Beijing time. -# -# On the other hand, ethnic Uyghurs, who make up about half the -# population of Xinjiang, typically use "Xinjiang time" which is two -# hours behind Beijing time, or UT +06. The government of the Xinjiang -# Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as -# local governments such as the Ürümqi city government use both times in -# publications, referring to what is popularly called Xinjiang time as -# "Ürümqi time." When Uyghurs make an appointment in the Uyghur language -# they almost invariably use Xinjiang time. -# -# (Their ethnic Han compatriots would typically have no clue of its -# widespread use, however, because so extremely few of them are fluent in -# Uyghur, comparable to the number of Anglo-Americans fluent in Navajo.) -# -# (...As with the rest of China there was a brief interval ending in 1990 -# or 1991 when summer time was in use. The confusion was severe, with -# the province not having dual times but four times in use at the same -# time. Some areas remained on standard Xinjiang time or Beijing time and -# others moving their clocks ahead.) - -# From Luther Ma (2009-11-19): -# With the risk of being redundant to previous answers these are the most common -# English "transliterations" (w/o using non-English symbols): -# -# 1. Wulumuqi... -# 2. Kashi... -# 3. Urumqi... -# 4. Kashgar... -# ... -# 5. It seems that Uyghurs in Ürümqi has been using Xinjiang since at least the -# 1960's. I know of one Han, now over 50, who grew up in the surrounding -# countryside and used Xinjiang time as a child. -# -# 6. Likewise for Kashgar and the rest of south Xinjiang I don't know of any -# start date for Xinjiang time. -# -# Without having access to local historical records, nor the ability to legally -# publish them, I would go with October 1, 1949, when Xinjiang became the Uyghur -# Autonomous Region under the PRC. (Before that Uyghurs, of course, would also -# not be using Beijing time, but some local time.) - -# From David Cochrane (2014-03-26): -# Just a confirmation that Ürümqi time was implemented in Ürümqi on 1 Feb 1986: -# https://content.time.com/time/magazine/article/0,9171,960684,00.html - -# From Luther Ma (2014-04-22): -# I have interviewed numerous people of various nationalities and from -# different localities in Xinjiang and can confirm the information in Guo's -# report regarding Xinjiang, as well as the Time article reference by David -# Cochrane. Whether officially recognized or not (and both are officially -# recognized), two separate times have been in use in Xinjiang since at least -# the Cultural Revolution: Xinjiang Time (XJT), aka Ürümqi Time or local time; -# and Beijing Time. There is no confusion in Xinjiang as to which name refers -# to which time. Both are widely used in the province, although in some -# population groups might be use one to the exclusion of the other. The only -# problem is that computers and smart phones list Ürümqi (or Kashgar) as -# having the same time as Beijing. - -# From Paul Eggert (2014-06-30): -# In the early days of the PRC, Tibet was given its own time zone (UT +06) -# but this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, -# Memories of life in Lhasa under Chinese Rule, Columbia U Press, ISBN -# 978-0231142861 (2008), translator's introduction by Matthew Akester, p x. -# As this is before our 1970 cutoff, Tibet doesn't need a separate zone. -# -# Xinjiang Time is well-documented as being officially recognized. E.g., see -# "The Working-Calendar for The Xinjiang Uygur Autonomous Region Government" -# <http://www.sinkiang.gov.cn/service/ourworking/> (2014-04-22). -# Unfortunately, we have no good records of time in Xinjiang before 1986. -# During the 20th century parts of Xinjiang were ruled by the Qing dynasty, -# the Republic of China, various warlords, the First and Second East Turkestan -# Republics, the Soviet Union, the Kuomintang, and the People's Republic of -# China, and tracking down all these organizations' timekeeping rules would be -# quite a trick. Approximate this lost history by a transition from LMT to -# UT +06 at the start of 1928, the year of accession of the warlord Jin Shuren, -# which happens to be the date given by Shanks & Pottenger (no doubt as a -# guess) as the transition from LMT. Ignore the usage of +08 before -# 1986-02-01 under the theory that the transition date to +08 is unknown and -# that the sort of users who prefer Asia/Urumqi now typically ignored the -# +08 mandate back then. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# Beijing time, used throughout China; represented by Shanghai. -Zone Asia/Shanghai 8:05:43 - LMT 1901 - 8:00 Shang C%sT 1949 May 28 - 8:00 PRC C%sT -# Xinjiang time, used by many in western China; represented by Ürümqi / Ürümchi -# / Wulumuqi. (Please use Asia/Shanghai if you prefer Beijing time.) -Zone Asia/Urumqi 5:50:20 - LMT 1928 - 6:00 - +06 - - -# Hong Kong (Xianggang) - -# Milne gives 7:36:41.7; round this. - -# From Lee Yiu Chung (2009-10-24): -# I found there are some mistakes for the...DST rule for Hong -# Kong. [According] to the DST record from Hong Kong Observatory (actually, -# it is not [an] observatory, but the official meteorological agency of HK, -# and also serves as the official timing agency), there are some missing -# and incorrect rules. Although the exact switch over time is missing, I -# think 3:30 is correct. The official DST record for Hong Kong can be -# obtained from -# http://www.hko.gov.hk/gts/time/Summertime.htm - -# From Arthur David Olson (2009-10-28): -# Here are the dates given at -# http://www.hko.gov.hk/gts/time/Summertime.htm -# as of 2009-10-28: -# Year Period -# 1941 1 Apr to 30 Sep -# 1942 Whole year -# 1943 Whole year -# 1944 Whole year -# 1945 Whole year -# 1946 20 Apr to 1 Dec -# 1947 13 Apr to 30 Dec -# 1948 2 May to 31 Oct -# 1949 3 Apr to 30 Oct -# 1950 2 Apr to 29 Oct -# 1951 1 Apr to 28 Oct -# 1952 6 Apr to 25 Oct -# 1953 5 Apr to 1 Nov -# 1954 21 Mar to 31 Oct -# 1955 20 Mar to 6 Nov -# 1956 18 Mar to 4 Nov -# 1957 24 Mar to 3 Nov -# 1958 23 Mar to 2 Nov -# 1959 22 Mar to 1 Nov -# 1960 20 Mar to 6 Nov -# 1961 19 Mar to 5 Nov -# 1962 18 Mar to 4 Nov -# 1963 24 Mar to 3 Nov -# 1964 22 Mar to 1 Nov -# 1965 18 Apr to 17 Oct -# 1966 17 Apr to 16 Oct -# 1967 16 Apr to 22 Oct -# 1968 21 Apr to 20 Oct -# 1969 20 Apr to 19 Oct -# 1970 19 Apr to 18 Oct -# 1971 18 Apr to 17 Oct -# 1972 16 Apr to 22 Oct -# 1973 22 Apr to 21 Oct -# 1973/74 30 Dec 73 to 20 Oct 74 -# 1975 20 Apr to 19 Oct -# 1976 18 Apr to 17 Oct -# 1977 Nil -# 1978 Nil -# 1979 13 May to 21 Oct -# 1980 to Now Nil -# The page does not give start or end times of day. -# The page does not give a start date for 1942. -# The page does not givw an end date for 1945. -# The Japanese occupation of Hong Kong began on 1941-12-25. -# The Japanese surrender of Hong Kong was signed 1945-09-15. -# For lack of anything better, use start of those days as the transition times. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule HK 1941 only - Apr 1 3:30 1:00 S -Rule HK 1941 only - Sep 30 3:30 0 - -Rule HK 1946 only - Apr 20 3:30 1:00 S -Rule HK 1946 only - Dec 1 3:30 0 - -Rule HK 1947 only - Apr 13 3:30 1:00 S -Rule HK 1947 only - Dec 30 3:30 0 - -Rule HK 1948 only - May 2 3:30 1:00 S -Rule HK 1948 1951 - Oct lastSun 3:30 0 - -Rule HK 1952 only - Oct 25 3:30 0 - -Rule HK 1949 1953 - Apr Sun>=1 3:30 1:00 S -Rule HK 1953 only - Nov 1 3:30 0 - -Rule HK 1954 1964 - Mar Sun>=18 3:30 1:00 S -Rule HK 1954 only - Oct 31 3:30 0 - -Rule HK 1955 1964 - Nov Sun>=1 3:30 0 - -Rule HK 1965 1976 - Apr Sun>=16 3:30 1:00 S -Rule HK 1965 1976 - Oct Sun>=16 3:30 0 - -Rule HK 1973 only - Dec 30 3:30 1:00 S -Rule HK 1979 only - May Sun>=8 3:30 1:00 S -Rule HK 1979 only - Oct Sun>=16 3:30 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30 - 8:00 HK HK%sT 1941 Dec 25 - 9:00 - JST 1945 Sep 15 - 8:00 HK HK%sT - -############################################################################### - -# Taiwan - -# From smallufo (2010-04-03): -# According to Taiwan's CWB [Central Weather Bureau], -# http://www.cwb.gov.tw/V6/astronomy/cdata/summert.htm -# Taipei has DST in 1979 between July 1st and Sep 30. - -# From Yu-Cheng Chuang (2013-07-12): -# On Dec 28, 1895, the Meiji Emperor announced Ordinance No. 167 of -# Meiji Year 28 "The clause about standard time", mentioned that -# Taiwan and Penghu Islands, as well as Yaeyama and Miyako Islands -# (both in Okinawa) adopt the Western Standard Time which is based on -# 120E. The adoption began from Jan 1, 1896. The original text can be -# found on Wikisource: -# https://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時) -# ... This could be the first adoption of time zone in Taiwan, because -# during the Qing Dynasty, it seems that there was no time zone -# declared officially. -# -# Later, in the beginning of World War II, on Sep 25, 1937, the Showa -# Emperor announced Ordinance No. 529 of Showa Year 12 "The clause of -# revision in the ordinance No. 167 of Meiji year 28 about standard -# time", in which abolished the adoption of Western Standard Time in -# western islands (listed above), which means the whole Japan -# territory, including later occupations, adopt Japan Central Time -# (UT+9). The adoption began on Oct 1, 1937. The original text can -# be found on Wikisource: -# https://ja.wikisource.org/wiki/明治二十八年勅令第百六十七號標準時ニ關スル件中改正ノ件 -# -# That is, the time zone of Taipei switched to UT+9 on Oct 1, 1937. - -# From Yu-Cheng Chuang (2014-07-02): -# I've found more evidence about when the time zone was switched from UT+9 -# back to UT+8 after WW2. I believe it was on Sep 21, 1945. In a document -# during Japanese era [1] in which the officer told the staff to change time -# zone back to Western Standard Time (UT+8) on Sep 21. And in another -# history page of National Cheng Kung University [2], on Sep 21 there is a -# note "from today, switch back to Western Standard Time". From these two -# materials, I believe that the time zone change happened on Sep 21. And -# today I have found another monthly journal called "The Astronomical Herald" -# from The Astronomical Society of Japan [3] in which it mentioned the fact -# that: -# -# 1. Standard Time of the Country (Japan) was adopted on Jan 1, 1888, using -# the time at 135E (GMT+9) -# -# 2. Standard Time of the Country was renamed to Central Standard Time, on Jan -# 1, 1898, and on the same day, the new territories Taiwan and Penghu islands, -# as well as Yaeyama and Miyako islands, adopted a new time zone called -# Western Standard Time, which is in GMT+8. -# -# 3. Western Standard Time was deprecated on Sep 30, 1937. From then all the -# territories of Japan adopted the same time zone, which is Central Standard -# Time. -# -# [1] Academica Historica, Taiwan: -# http://163.29.208.22:8080/govsaleShowImage/connect_img.php?s=00101738900090036&e=00101738900090037 -# [2] Nat'l Cheng Kung University 70th Anniversary Special Site: -# http://www.ncku.edu.tw/~ncku70/menu/001/01_01.htm -# [3] Yukio Niimi, The Standard Time in Japan (1997), p.475: -# http://www.asj.or.jp/geppou/archive_open/1997/pdf/19971001c.pdf - -# Yu-Cheng Chuang (2014-07-03): -# I finally have found the real official gazette about changing back to -# Western Standard Time on Sep 21 in Taiwan. It's Taiwan Governor-General -# Bulletin No. 386 in Showa 20 years (1945), published on Sep 19, 1945. [1] ... -# [It] abolishes Bulletin No. 207 in Showa 12 years (1937), which is a local -# bulletin in Taiwan for that Ordinance No. 529. It also mentioned that 1am on -# Sep 21, 1945 will be 12am on Sep 21. I think this bulletin is much more -# official than the one I mentioned in my first mail, because it's from the -# top-level government in Taiwan. If you're going to quote any resource, this -# would be a good one. -# [1] Taiwan Governor-General Gazette, No. 1018, Sep 19, 1945: -# http://db2.th.gov.tw/db2/view/viewImg.php?imgcode=0072031018a&num=19&bgn=019&end=019&otherImg=&type=gener - -# From Yu-Cheng Chuang (2014-07-02): -# In 1946, DST in Taiwan was from May 15 and ended on Sep 30. The info from -# Central Weather Bureau website was not correct. -# -# Original Bulletin: -# http://subtpg.tpg.gov.tw/og/image2.asp?f=03502F0AKM1AF -# http://subtpg.tpg.gov.tw/og/image2.asp?f=0350300AKM1B0 (cont.) -# -# In 1947, DST in Taiwan was expanded to Oct 31. There is a backup of that -# telegram announcement from Taiwan Province Government: -# -# http://subtpg.tpg.gov.tw/og/image2.asp?f=0360310AKZ431 -# -# Here is a brief translation: -# -# The Summer Time this year is adopted from midnight Apr 15 until Sep 20 -# midnight. To save (energy?) consumption, we're expanding Summer Time -# adoption till Oct 31 midnight. -# -# The Central Weather Bureau website didn't mention that, however it can -# be found from historical government announcement database. - -# From Paul Eggert (2014-07-03): -# As per Yu-Cheng Chuang, say that Taiwan was at UT +09 from 1937-10-01 -# until 1945-09-21 at 01:00, overriding Shanks & Pottenger. -# Likewise, use Yu-Cheng Chuang's data for DST in Taiwan. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Taiwan 1946 only - May 15 0:00 1:00 D -Rule Taiwan 1946 only - Oct 1 0:00 0 S -Rule Taiwan 1947 only - Apr 15 0:00 1:00 D -Rule Taiwan 1947 only - Nov 1 0:00 0 S -Rule Taiwan 1948 1951 - May 1 0:00 1:00 D -Rule Taiwan 1948 1951 - Oct 1 0:00 0 S -Rule Taiwan 1952 only - Mar 1 0:00 1:00 D -Rule Taiwan 1952 1954 - Nov 1 0:00 0 S -Rule Taiwan 1953 1959 - Apr 1 0:00 1:00 D -Rule Taiwan 1955 1961 - Oct 1 0:00 0 S -Rule Taiwan 1960 1961 - Jun 1 0:00 1:00 D -Rule Taiwan 1974 1975 - Apr 1 0:00 1:00 D -Rule Taiwan 1974 1975 - Oct 1 0:00 0 S -Rule Taiwan 1979 only - Jul 1 0:00 1:00 D -Rule Taiwan 1979 only - Oct 1 0:00 0 S - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# Taipei or Taibei or T'ai-pei -Zone Asia/Taipei 8:06:00 - LMT 1896 Jan 1 - 8:00 - CST 1937 Oct 1 - 9:00 - JST 1945 Sep 21 1:00 - 8:00 Taiwan C%sT - -# Macau (Macao, Aomen) -# -# From P Chan (2018-05-10): -# * LegisMac -# http://legismac.safp.gov.mo/legismac/descqry/Descqry.jsf?lang=pt -# A database for searching titles of legal documents of Macau in -# Chinese and Portuguese. The term "HORÁRIO DE VERÃO" can be used for -# searching decrees about summer time. -# * Archives of Macao -# http://www.archives.gov.mo/en/bo/ -# It contains images of old official gazettes. -# * The Macao Meteorological and Geophysical Bureau have a page listing the -# summer time history. But it is not complete and has some mistakes. -# http://www.smg.gov.mo/smg/geophysics/e_t_Summer%20Time.htm -# Macau adopted GMT+8 on 30 Oct 1904 to follow Hong Kong. Clocks were -# advanced by 25 minutes and 50 seconds. Which means the LMT used was -# +7:34:10. As stated in the "Portaria No. 204" dated 21 October 1904 -# and published in the Official Gazette on 29 October 1904. -# http://igallery.icm.gov.mo/Images/Archives/BO/MO_AH_PUB_BO_1904_10/MO_AH_PUB_BO_1904_10_00025_Grey.JPG -# -# Therefore the 1911 decree of Portugal did not change time in Macau. -# -# From LegisMac, here is a list of decrees that changed the time ... -# [Decree Gazette-no. date; titles omitted in this quotation] -# DIL 732 BOCM 51 1941.12.20 -# DIL 764 BOCM 9S 1942.04.30 -# DIL 781 BOCM 21 1942.10.10 -# PT 3434 BOCM 8S 1943.04.17 -# PT 3504 BOCM 20 1943.09.25 -# PT 3843 BOCM 39 1945.09.29 -# PT 3961 BOCM 17 1946.04.27 -# PT 4026 BOCM 39 1946.09.28 -# PT 4153 BOCM 16 1947.04.10 -# PT 4271 BOCM 48 1947.11.29 -# PT 4374 BOCM 18 1948.05.01 -# PT 4465 BOCM 44 1948.10.30 -# PT 4590 BOCM 14 1949.04.02 -# PT 4666 BOCM 44 1949.10.29 -# PT 4771 BOCM 12 1950.03.25 -# PT 4838 BOCM 43 1950.10.28 -# PT 4946 BOCM 12 1951.03.24 -# PT 5025 BO 43 1951.10.27 -# PT 5149 BO 14 1952.04.05 -# PT 5251 BO 43 1952.10.25 -# PT 5366 BO 13 1953.03.28 -# PT 5444 BO 44 1953.10.31 -# PT 5540 BO 12 1954.03.20 -# PT 5589 BO 44 1954.10.30 -# PT 5676 BO 12 1955.03.19 -# PT 5739 BO 45 1955.11.05 -# PT 5823 BO 11 1956.03.17 -# PT 5891 BO 44 1956.11.03 -# PT 5981 BO 12 1957.03.23 -# PT 6064 BO 43 1957.10.26 -# PT 6172 BO 12 1958.03.22 -# PT 6243 BO 43 1958.10.25 -# PT 6341 BO 12 1959.03.21 -# PT 6411 BO 43 1959.10.24 -# PT 6514 BO 11 1960.03.12 -# PT 6584 BO 44 1960.10.29 -# PT 6721 BO 10 1961.03.11 -# PT 6815 BO 43 1961.10.28 -# PT 6947 BO 10 1962.03.10 -# PT 7080 BO 43 1962.10.27 -# PT 7218 BO 12 1963.03.23 -# PT 7340 BO 43 1963.10.26 -# PT 7491 BO 11 1964.03.14 -# PT 7664 BO 43 1964.10.24 -# PT 7846 BO 15 1965.04.10 -# PT 7979 BO 42 1965.10.16 -# PT 8146 BO 15 1966.04.09 -# PT 8252 BO 41 1966.10.08 -# PT 8429 BO 15 1967.04.15 -# PT 8540 BO 41 1967.10.14 -# PT 8735 BO 15 1968.04.13 -# PT 8860 BO 41 1968.10.12 -# PT 9035 BO 16 1969.04.19 -# PT 9156 BO 42 1969.10.18 -# PT 9328 BO 15 1970.04.11 -# PT 9418 BO 41 1970.10.10 -# PT 9587 BO 14 1971.04.03 -# PT 9702 BO 41 1971.10.09 -# PT 38-A/72 BO 14 1972.04.01 -# PT 126-A/72 BO 41 1972.10.07 -# PT 61/73 BO 14 1973.04.07 -# PT 182/73 BO 40 1973.10.06 -# PT 282/73 BO 51 1973.12.22 -# PT 177/74 BO 41 1974.10.12 -# PT 51/75 BO 15 1975.04.12 -# PT 173/75 BO 41 1975.10.11 -# PT 67/76/M BO 14 1976.04.03 -# PT 169/76/M BO 41 1976.10.09 -# PT 78/79/M BO 19 1979.05.12 -# PT 166/79/M BO 42 1979.10.20 -# Note that DIL 732 does not belong to "HORÁRIO DE VERÃO" according to -# LegisMac.... Note that between 1942 and 1945, the time switched -# between GMT+9 and GMT+10. Also in 1965 and 1965 the DST ended at 2:30am. - -# From Paul Eggert (2018-05-10): -# The 1904 decree says that Macau changed from the meridian of -# Fortaleza do Monte, presumably the basis for the 7:34:10 for LMT. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Macau 1942 1943 - Apr 30 23:00 1:00 - -Rule Macau 1942 only - Nov 17 23:00 0 - -Rule Macau 1943 only - Sep 30 23:00 0 S -Rule Macau 1946 only - Apr 30 23:00s 1:00 D -Rule Macau 1946 only - Sep 30 23:00s 0 S -Rule Macau 1947 only - Apr 19 23:00s 1:00 D -Rule Macau 1947 only - Nov 30 23:00s 0 S -Rule Macau 1948 only - May 2 23:00s 1:00 D -Rule Macau 1948 only - Oct 31 23:00s 0 S -Rule Macau 1949 1950 - Apr Sat>=1 23:00s 1:00 D -Rule Macau 1949 1950 - Oct lastSat 23:00s 0 S -Rule Macau 1951 only - Mar 31 23:00s 1:00 D -Rule Macau 1951 only - Oct 28 23:00s 0 S -Rule Macau 1952 1953 - Apr Sat>=1 23:00s 1:00 D -Rule Macau 1952 only - Nov 1 23:00s 0 S -Rule Macau 1953 1954 - Oct lastSat 23:00s 0 S -Rule Macau 1954 1956 - Mar Sat>=17 23:00s 1:00 D -Rule Macau 1955 only - Nov 5 23:00s 0 S -Rule Macau 1956 1964 - Nov Sun>=1 03:30 0 S -Rule Macau 1957 1964 - Mar Sun>=18 03:30 1:00 D -Rule Macau 1965 1973 - Apr Sun>=16 03:30 1:00 D -Rule Macau 1965 1966 - Oct Sun>=16 02:30 0 S -Rule Macau 1967 1976 - Oct Sun>=16 03:30 0 S -Rule Macau 1973 only - Dec 30 03:30 1:00 D -Rule Macau 1975 1976 - Apr Sun>=16 03:30 1:00 D -Rule Macau 1979 only - May 13 03:30 1:00 D -Rule Macau 1979 only - Oct Sun>=16 03:30 0 S - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Macau 7:34:10 - LMT 1904 Oct 30 - 8:00 - CST 1941 Dec 21 23:00 - 9:00 Macau +09/+10 1945 Sep 30 24:00 - 8:00 Macau C%sT - - -############################################################################### - -# Cyprus - -# Milne says the Eastern Telegraph Company used 2:14:00. Stick with LMT. -# IATA SSIM (1998-09) has Cyprus using EU rules for the first time. - -# From Paul Eggert (2016-09-09): -# Yesterday's Cyprus Mail reports that Northern Cyprus followed Turkey's -# lead and switched from +02/+03 to +03 year-round. -# http://cyprus-mail.com/2016/09/08/two-time-zones-cyprus-turkey-will-not-turn-clocks-back-next-month/ -# -# From Even Scharning (2016-10-31): -# Looks like the time zone split in Cyprus went through last night. -# http://cyprus-mail.com/2016/10/30/cyprus-new-division-two-time-zones-now-reality/ - -# From Paul Eggert (2017-10-18): -# Northern Cyprus will reinstate winter time on October 29, thus -# staying in sync with the rest of Cyprus. See: Anastasiou A. -# Cyprus to remain united in time. Cyprus Mail 2017-10-17. -# https://cyprus-mail.com/2017/10/17/cyprus-remain-united-time/ - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Cyprus 1975 only - Apr 13 0:00 1:00 S -Rule Cyprus 1975 only - Oct 12 0:00 0 - -Rule Cyprus 1976 only - May 15 0:00 1:00 S -Rule Cyprus 1976 only - Oct 11 0:00 0 - -Rule Cyprus 1977 1980 - Apr Sun>=1 0:00 1:00 S -Rule Cyprus 1977 only - Sep 25 0:00 0 - -Rule Cyprus 1978 only - Oct 2 0:00 0 - -Rule Cyprus 1979 1997 - Sep lastSun 0:00 0 - -Rule Cyprus 1981 1998 - Mar lastSun 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Nicosia 2:13:28 - LMT 1921 Nov 14 - 2:00 Cyprus EE%sT 1998 Sep - 2:00 EUAsia EE%sT -Zone Asia/Famagusta 2:15:48 - LMT 1921 Nov 14 - 2:00 Cyprus EE%sT 1998 Sep - 2:00 EUAsia EE%sT 2016 Sep 8 - 3:00 - +03 2017 Oct 29 1:00u - 2:00 EUAsia EE%sT - -# Classically, Cyprus belongs to Asia; e.g. see Herodotus, Histories, I.72. -# However, for various reasons many users expect to find it under Europe. -Link Asia/Nicosia Europe/Nicosia - -# Georgia -# From Paul Eggert (1994-11-19): -# Today's _Economist_ (p 60) reports that Georgia moved its clocks forward -# an hour recently, due to a law proposed by Zurab Murvanidze, -# an MP who went on a hunger strike for 11 days to force discussion about it! -# We have no details, but we'll guess they didn't move the clocks back in fall. -# -# From Mathew Englander, quoting AP (1996-10-23 13:05-04): -# Instead of putting back clocks at the end of October, Georgia -# will stay on daylight savings time this winter to save energy, -# President Eduard Shevardnadze decreed Wednesday. -# -# From the BBC via Joseph S. Myers (2004-06-27): -# -# Georgia moved closer to Western Europe on Sunday... The former Soviet -# republic has changed its time zone back to that of Moscow. As a result it -# is now just four hours ahead of Greenwich Mean Time, rather than five hours -# ahead. The switch was decreed by the pro-Western president of Georgia, -# Mikheil Saakashvili, who said the change was partly prompted by the process -# of integration into Europe. - -# From Teimuraz Abashidze (2005-11-07): -# Government of Georgia ... decided to NOT CHANGE daylight savings time on -# [Oct.] 30, as it was done before during last more than 10 years. -# Currently, we are in fact GMT +4:00, as before 30 October it was GMT -# +3:00.... The problem is, there is NO FORMAL LAW or governmental document -# about it. As far as I can find, I was told, that there is no document, -# because we just DIDN'T ISSUE document about switching to winter time.... -# I don't know what can be done, especially knowing that some years ago our -# DST rules where changed THREE TIMES during one month. - -# Milne 1899 says Tbilisi (Tiflis) time was 2:59:05.7. -# Byalokoz 1919 says Georgia was 2:59:11. -# Go with Byalokoz. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Tbilisi 2:59:11 - LMT 1880 - 2:59:11 - TBMT 1924 May 2 # Tbilisi Mean Time - 3:00 - +03 1957 Mar - 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s - 3:00 RussiaAsia +03/+04 1992 - 3:00 E-EurAsia +03/+04 1994 Sep lastSun - 4:00 E-EurAsia +04/+05 1996 Oct lastSun - 4:00 1:00 +05 1997 Mar lastSun - 4:00 E-EurAsia +04/+05 2004 Jun 27 - 3:00 RussiaAsia +03/+04 2005 Mar lastSun 2:00 - 4:00 - +04 - -# East Timor - -# See Indonesia for the 1945 transition. - -# From João Carrascalão, brother of the former governor of East Timor, in -# East Timor may be late for its millennium -# <https://etan.org/et99c/december/26-31/30ETMAY.htm> (1999-12-26/31): -# Portugal tried to change the time forward in 1974 because the sun -# rises too early but the suggestion raised a lot of problems with the -# Timorese and I still don't think it would work today because it -# conflicts with their way of life. - -# From Paul Eggert (2000-12-04): -# We don't have any record of the above attempt. -# Most likely our records are incomplete, but we have no better data. - -# From Manoel de Almeida e Silva, Deputy Spokesman for the UN Secretary-General -# http://www.hri.org/news/world/undh/2000/00-08-16.undh.html -# (2000-08-16): -# The Cabinet of the East Timor Transition Administration decided -# today to advance East Timor's time by one hour. The time change, -# which will be permanent, with no seasonal adjustment, will happen at -# midnight on Saturday, September 16. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 - 8:00 - +08 1942 Feb 21 23:00 - 9:00 - +09 1976 May 3 - 8:00 - +08 2000 Sep 17 0:00 - 9:00 - +09 - -# India - -# From Ian P. Beacock, in "A brief history of (modern) time", The Atlantic -# https://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ -# (2015-12-22): -# In January 1906, several thousand cotton-mill workers rioted on the -# outskirts of Bombay.... They were protesting the proposed abolition of -# local time in favor of Indian Standard Time.... Journalists called this -# dispute the "Battle of the Clocks." It lasted nearly half a century. - -# From Paul Eggert (2017-04-20): -# Good luck trying to nail down old timekeeping records in India. -# "... in the nineteenth century ... Madras Observatory took its magnetic -# measurements on Göttingen time, its meteorological measurements on Madras -# (local) time, dropped its time ball on Greenwich (ocean navigator's) time, -# and distributed civil (local time)." -- Bartky IR. Selling the true time: -# 19th-century timekeeping in america. Stanford U Press (2000), 247 note 19. -# "A more potent cause of resistance to the general adoption of the present -# standard time lies in the fact that it is Madras time. The citizen of -# Bombay, proud of being 'primus in Indis' and of Calcutta, equally proud of -# his city being the Capital of India, and - for a part of the year - the Seat -# of the Supreme Government, alike look down on Madras, and refuse to change -# the time they are using, for that of what they regard as a benighted -# Presidency; while Madras, having for long given the standard time to the -# rest of India, would resist the adoption of any other Indian standard in its -# place." -- Oldham RD. On Time in India: a suggestion for its improvement. -# Proceedings of the Asiatic Society of Bengal (April 1899), 49-55. -# -# "In 1870 ... Madras time - 'now used by the telegraph and regulated from the -# only government observatory' - was suggested as a standard railway time, -# first to be adopted on the Great Indian Peninsular Railway (GIPR).... -# Calcutta, Bombay, and Karachi, were to be allowed to continue with their -# local time for civil purposes." - Prasad R. Tracks of Change: Railways and -# Everyday Life in Colonial India. Cambridge University Press (2016), 145. -# -# Reed S, Low F. The Indian Year Book 1936-37. Bennett, Coleman, pp 27-8. -# https://archive.org/details/in.ernet.dli.2015.282212 -# This lists +052110 as Madras local time used in railways, and says that on -# 1906-01-01 railways and telegraphs in India switched to +0530. Some -# municipalities retained their former time, and the time in Calcutta -# continued to depend on whether you were at the railway station or at -# government offices. Government time was at +055320 (according to Shanks) or -# at +0554 (according to the Indian Year Book). Railway time is more -# appropriate for our purposes, as it was better documented, it is what we do -# elsewhere (e.g., Europe/London before 1880), and after 1906 it was -# consistent in the region now identified by Asia/Kolkata. So, use railway -# time for 1870-1941. Shanks is our only (and dubious) source for the -# 1941-1945 data. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kolkata 5:53:28 - LMT 1854 Jun 28 # Kolkata - 5:53:20 - HMT 1870 # Howrah Mean Time? - 5:21:10 - MMT 1906 Jan 1 # Madras local time - 5:30 - IST 1941 Oct - 5:30 1:00 +0630 1942 May 15 - 5:30 - IST 1942 Sep - 5:30 1:00 +0630 1945 Oct 15 - 5:30 - IST -# Since 1970 the following are like Asia/Kolkata: -# Andaman Is -# Lakshadweep (Laccadive, Minicoy and Amindivi Is) -# Nicobar Is - -# Indonesia -# -# From Paul Eggert (2014-09-06): -# The 1876 Report of the Secretary of the [US] Navy, p 306 says that Batavia -# civil time was 7:07:12.5; round to even for Jakarta. -# -# From Gwillim Law (2001-05-28), overriding Shanks & Pottenger: -# http://www.sumatera-inc.com/go_to_invest/about_indonesia.asp#standtime -# says that Indonesia's time zones changed on 1988-01-01. Looking at some -# time zone maps, I think that must refer to Western Borneo (Kalimantan Barat -# and Kalimantan Tengah) switching from UTC+8 to UTC+7. -# -# From Paul Eggert (2007-03-10): -# Here is another correction to Shanks & Pottenger. -# JohnTWB writes that Japanese forces did not surrender control in -# Indonesia until 1945-09-01 00:00 at the earliest (in Jakarta) and -# other formal surrender ceremonies were September 9, 11, and 13, plus -# September 12 for the regional surrender to Mountbatten in Singapore. -# These would be the earliest possible times for a change. -# Régimes horaires pour le monde entier, by Henri Le Corre, (Éditions -# Traditionnelles, 1987, Paris) says that Java and Madura switched -# from UT +09 to +07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura -# (Hollandia). For now, assume all Indonesian locations other than Jayapura -# switched on 1945-09-23. -# -# From Paul Eggert (2013-08-11): -# Normally the tz database uses English-language abbreviations, but in -# Indonesia it's typical to use Indonesian-language abbreviations even -# when writing in English. For example, see the English-language -# summary published by the Time and Frequency Laboratory of the -# Research Center for Calibration, Instrumentation and Metrology, -# Indonesia, <http://time.kim.lipi.go.id/time-eng.php> (2006-09-29). -# The time zone abbreviations and UT offsets are: -# -# WIB - +07 - Waktu Indonesia Barat (Indonesia western time) -# WITA - +08 - Waktu Indonesia Tengah (Indonesia central time) -# WIT - +09 - Waktu Indonesia Timur (Indonesia eastern time) -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# Java, Sumatra -Zone Asia/Jakarta 7:07:12 - LMT 1867 Aug 10 -# Shanks & Pottenger say the next transition was at 1924 Jan 1 0:13, -# but this must be a typo. - 7:07:12 - BMT 1923 Dec 31 23:47:12 # Batavia - 7:20 - +0720 1932 Nov - 7:30 - +0730 1942 Mar 23 - 9:00 - +09 1945 Sep 23 - 7:30 - +0730 1948 May - 8:00 - +08 1950 May - 7:30 - +0730 1964 - 7:00 - WIB -# west and central Borneo -Zone Asia/Pontianak 7:17:20 - LMT 1908 May - 7:17:20 - PMT 1932 Nov # Pontianak MT - 7:30 - +0730 1942 Jan 29 - 9:00 - +09 1945 Sep 23 - 7:30 - +0730 1948 May - 8:00 - +08 1950 May - 7:30 - +0730 1964 - 8:00 - WITA 1988 Jan 1 - 7:00 - WIB -# Sulawesi, Lesser Sundas, east and south Borneo -Zone Asia/Makassar 7:57:36 - LMT 1920 - 7:57:36 - MMT 1932 Nov # Macassar MT - 8:00 - +08 1942 Feb 9 - 9:00 - +09 1945 Sep 23 - 8:00 - WITA -# Maluku Islands, West Papua, Papua -Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov - 9:00 - +09 1944 Sep 1 - 9:30 - +0930 1964 - 9:00 - WIT - -# Iran - -# From Roozbeh Pournader (2003-03-15): -# This is an English translation of what I just found (originally in Persian). -# The Gregorian dates in brackets are mine: -# -# Official Newspaper No. 13548-1370/6/25 [1991-09-16] -# No. 16760/T233 H 1370/6/10 [1991-09-01] -# -# The Rule About Change of the Official Time of the Country -# -# The Board of Ministers, in the meeting dated 1370/5/23 [1991-08-14], -# based on the suggestion number 2221/D dated 1370/4/22 [1991-07-13] -# of the Country's Organization for Official and Employment Affairs, -# and referring to the law for equating the working hours of workers -# and officers in the whole country dated 1359/4/23 [1980-07-14], and -# for synchronizing the official times of the country, agreed that: -# -# The official time of the country will should move forward one hour -# at the 24[:00] hours of the first day of Farvardin and should return -# to its previous state at the 24[:00] hours of the 30th day of -# Shahrivar. -# -# First Deputy to the President - Hassan Habibi -# -# From personal experience, that agrees with what has been followed -# for at least the last 5 years. Before that, for a few years, the -# date used was the first Thursday night of Farvardin and the last -# Thursday night of Shahrivar, but I can't give exact dates.... -# -# From Roozbeh Pournader (2005-04-05): -# The text of the Iranian law, in effect since 1925, clearly mentions -# that the true solar year is the measure, and there is no arithmetic -# leap year calculation involved. There has never been any serious -# plan to change that law.... -# -# From Paul Eggert (2006-03-22): -# Go with Shanks & Pottenger before Sept. 1991, and with Pournader thereafter. -# I used Ed Reingold's cal-persia in GNU Emacs 21.2 to check Persian dates, -# stopping after 2037 when 32-bit time_t's overflow. -# That cal-persia used Birashk's approximation, which disagrees with the solar -# calendar predictions for the year 2025, so I corrected those dates by hand. -# -# From Oscar van Vlijmen (2005-03-30), writing about future -# discrepancies between cal-persia and the Iranian calendar: -# For 2091 solar-longitude-after yields 2091-03-20 08:40:07.7 UT for -# the vernal equinox and that gets so close to 12:00 some local -# Iranian time that the definition of the correct location needs to be -# known exactly, amongst other factors. 2157 is even closer: -# 2157-03-20 08:37:15.5 UT. But the Gregorian year 2025 should give -# no interpretation problem whatsoever. By the way, another instant -# in the near future where there will be a discrepancy between -# arithmetical and astronomical Iranian calendars will be in 2058: -# vernal equinox on 2058-03-20 09:03:05.9 UT. The Java version of -# Reingold's/Dershowitz' calculator gives correctly the Gregorian date -# 2058-03-21 for 1 Farvardin 1437 (astronomical). -# -# From Steffen Thorsen (2006-03-22): -# Several of my users have reported that Iran will not observe DST anymore: -# http://www.irna.ir/en/news/view/line-17/0603193812164948.htm -# -# From Reuters (2007-09-16), with a heads-up from Jesper Nørgaard Welen: -# ... the Guardian Council ... approved a law on Sunday to re-introduce -# daylight saving time ... -# https://uk.reuters.com/article/oilRpt/idUKBLA65048420070916 -# -# From Roozbeh Pournader (2007-11-05): -# This is quoted from Official Gazette of the Islamic Republic of -# Iran, Volume 63, No. 18242, dated Tuesday 1386/6/24 -# [2007-10-16]. I am doing the best translation I can:... -# The official time of the country will be moved forward for one hour -# on the 24 hours of the first day of the month of Farvardin and will -# be changed back to its previous state on the 24 hours of the -# thirtieth day of Shahrivar. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iran 1978 1980 - Mar 21 0:00 1:00 - -Rule Iran 1978 only - Oct 21 0:00 0 - -Rule Iran 1979 only - Sep 19 0:00 0 - -Rule Iran 1980 only - Sep 23 0:00 0 - -Rule Iran 1991 only - May 3 0:00 1:00 - -Rule Iran 1992 1995 - Mar 22 0:00 1:00 - -Rule Iran 1991 1995 - Sep 22 0:00 0 - -Rule Iran 1996 only - Mar 21 0:00 1:00 - -Rule Iran 1996 only - Sep 21 0:00 0 - -Rule Iran 1997 1999 - Mar 22 0:00 1:00 - -Rule Iran 1997 1999 - Sep 22 0:00 0 - -Rule Iran 2000 only - Mar 21 0:00 1:00 - -Rule Iran 2000 only - Sep 21 0:00 0 - -Rule Iran 2001 2003 - Mar 22 0:00 1:00 - -Rule Iran 2001 2003 - Sep 22 0:00 0 - -Rule Iran 2004 only - Mar 21 0:00 1:00 - -Rule Iran 2004 only - Sep 21 0:00 0 - -Rule Iran 2005 only - Mar 22 0:00 1:00 - -Rule Iran 2005 only - Sep 22 0:00 0 - -Rule Iran 2008 only - Mar 21 0:00 1:00 - -Rule Iran 2008 only - Sep 21 0:00 0 - -Rule Iran 2009 2011 - Mar 22 0:00 1:00 - -Rule Iran 2009 2011 - Sep 22 0:00 0 - -Rule Iran 2012 only - Mar 21 0:00 1:00 - -Rule Iran 2012 only - Sep 21 0:00 0 - -Rule Iran 2013 2015 - Mar 22 0:00 1:00 - -Rule Iran 2013 2015 - Sep 22 0:00 0 - -Rule Iran 2016 only - Mar 21 0:00 1:00 - -Rule Iran 2016 only - Sep 21 0:00 0 - -Rule Iran 2017 2019 - Mar 22 0:00 1:00 - -Rule Iran 2017 2019 - Sep 22 0:00 0 - -Rule Iran 2020 only - Mar 21 0:00 1:00 - -Rule Iran 2020 only - Sep 21 0:00 0 - -Rule Iran 2021 2023 - Mar 22 0:00 1:00 - -Rule Iran 2021 2023 - Sep 22 0:00 0 - -Rule Iran 2024 only - Mar 21 0:00 1:00 - -Rule Iran 2024 only - Sep 21 0:00 0 - -Rule Iran 2025 2027 - Mar 22 0:00 1:00 - -Rule Iran 2025 2027 - Sep 22 0:00 0 - -Rule Iran 2028 2029 - Mar 21 0:00 1:00 - -Rule Iran 2028 2029 - Sep 21 0:00 0 - -Rule Iran 2030 2031 - Mar 22 0:00 1:00 - -Rule Iran 2030 2031 - Sep 22 0:00 0 - -Rule Iran 2032 2033 - Mar 21 0:00 1:00 - -Rule Iran 2032 2033 - Sep 21 0:00 0 - -Rule Iran 2034 2035 - Mar 22 0:00 1:00 - -Rule Iran 2034 2035 - Sep 22 0:00 0 - -# -# The following rules are approximations starting in the year 2038. -# These are the best post-2037 approximations available, given the -# restrictions of a single rule using a Gregorian-based data format. -# At some point this table will need to be extended, though quite -# possibly Iran will change the rules first. -Rule Iran 2036 max - Mar 21 0:00 1:00 - -Rule Iran 2036 max - Sep 21 0:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Tehran 3:25:44 - LMT 1916 - 3:25:44 - TMT 1946 # Tehran Mean Time - 3:30 - +0330 1977 Nov - 4:00 Iran +04/+05 1979 - 3:30 Iran +0330/+0430 - - -# Iraq -# -# From Jonathan Lennox (2000-06-12): -# An article in this week's Economist ("Inside the Saddam-free zone", p. 50 in -# the U.S. edition) on the Iraqi Kurds contains a paragraph: -# "The three northern provinces ... switched their clocks this spring and -# are an hour ahead of Baghdad." -# -# But Rives McDow (2000-06-18) quotes a contact in Iraqi-Kurdistan as follows: -# In the past, some Kurdish nationalists, as a protest to the Iraqi -# Government, did not adhere to daylight saving time. They referred -# to daylight saving as Saddam time. But, as of today, the time zone -# in Iraqi-Kurdistan is on standard time with Baghdad, Iraq. -# -# So we'll ignore the Economist's claim. - -# From Steffen Thorsen (2008-03-10): -# The cabinet in Iraq abolished DST last week, according to the following -# news sources (in Arabic): -# http://www.aljeeran.net/wesima_articles/news-20080305-98602.html -# http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10 -# -# We have published a short article in English about the change: -# https://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iraq 1982 only - May 1 0:00 1:00 - -Rule Iraq 1982 1984 - Oct 1 0:00 0 - -Rule Iraq 1983 only - Mar 31 0:00 1:00 - -Rule Iraq 1984 1985 - Apr 1 0:00 1:00 - -Rule Iraq 1985 1990 - Sep lastSun 1:00s 0 - -Rule Iraq 1986 1990 - Mar lastSun 1:00s 1:00 - -# IATA SSIM (1991/1996) says Apr 1 12:01am UTC; guess the ':01' is a typo. -# Shanks & Pottenger say Iraq did not observe DST 1992/1997; ignore this. -# -Rule Iraq 1991 2007 - Apr 1 3:00s 1:00 - -Rule Iraq 1991 2007 - Oct 1 3:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Baghdad 2:57:40 - LMT 1890 - 2:57:36 - BMT 1918 # Baghdad Mean Time? - 3:00 - +03 1982 May - 3:00 Iraq +03/+04 - - -############################################################################### - -# Israel - -# From Ephraim Silverberg (2001-01-11): -# -# I coined "IST/IDT" circa 1988. Until then there were three -# different abbreviations in use: -# -# JST Jerusalem Standard Time [Danny Braniss, Hebrew University] -# IZT Israel Zonal (sic) Time [Prof. Haim Papo, Technion] -# EEST Eastern Europe Standard Time [used by almost everyone else] -# -# Since timezones should be called by country and not capital cities, -# I ruled out JST. As Israel is in Asia Minor and not Eastern Europe, -# EEST was equally unacceptable. Since "zonal" was not compatible with -# any other timezone abbreviation, I felt that 'IST' was the way to go -# and, indeed, it has received almost universal acceptance in timezone -# settings in Israeli computers. -# -# In any case, I am happy to share timezone abbreviations with India, -# high on my favorite-country list (and not only because my wife's -# family is from India). - -# From Shanks & Pottenger: -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1940 only - Jun 1 0:00 1:00 D -Rule Zion 1942 1944 - Nov 1 0:00 0 S -Rule Zion 1943 only - Apr 1 2:00 1:00 D -Rule Zion 1944 only - Apr 1 0:00 1:00 D -Rule Zion 1945 only - Apr 16 0:00 1:00 D -Rule Zion 1945 only - Nov 1 2:00 0 S -Rule Zion 1946 only - Apr 16 2:00 1:00 D -Rule Zion 1946 only - Nov 1 0:00 0 S -Rule Zion 1948 only - May 23 0:00 2:00 DD -Rule Zion 1948 only - Sep 1 0:00 1:00 D -Rule Zion 1948 1949 - Nov 1 2:00 0 S -Rule Zion 1949 only - May 1 0:00 1:00 D -Rule Zion 1950 only - Apr 16 0:00 1:00 D -Rule Zion 1950 only - Sep 15 3:00 0 S -Rule Zion 1951 only - Apr 1 0:00 1:00 D -Rule Zion 1951 only - Nov 11 3:00 0 S -Rule Zion 1952 only - Apr 20 2:00 1:00 D -Rule Zion 1952 only - Oct 19 3:00 0 S -Rule Zion 1953 only - Apr 12 2:00 1:00 D -Rule Zion 1953 only - Sep 13 3:00 0 S -Rule Zion 1954 only - Jun 13 0:00 1:00 D -Rule Zion 1954 only - Sep 12 0:00 0 S -Rule Zion 1955 only - Jun 11 2:00 1:00 D -Rule Zion 1955 only - Sep 11 0:00 0 S -Rule Zion 1956 only - Jun 3 0:00 1:00 D -Rule Zion 1956 only - Sep 30 3:00 0 S -Rule Zion 1957 only - Apr 29 2:00 1:00 D -Rule Zion 1957 only - Sep 22 0:00 0 S -Rule Zion 1974 only - Jul 7 0:00 1:00 D -Rule Zion 1974 only - Oct 13 0:00 0 S -Rule Zion 1975 only - Apr 20 0:00 1:00 D -Rule Zion 1975 only - Aug 31 0:00 0 S -Rule Zion 1985 only - Apr 14 0:00 1:00 D -Rule Zion 1985 only - Sep 15 0:00 0 S -Rule Zion 1986 only - May 18 0:00 1:00 D -Rule Zion 1986 only - Sep 7 0:00 0 S -Rule Zion 1987 only - Apr 15 0:00 1:00 D -Rule Zion 1987 only - Sep 13 0:00 0 S - -# From Avigdor Finkelstein (2014-03-05): -# I check the Parliament (Knesset) records and there it's stated that the -# [1988] transition should take place on Saturday night, when the Sabbath -# ends and changes to Sunday. -Rule Zion 1988 only - Apr 10 0:00 1:00 D -Rule Zion 1988 only - Sep 4 0:00 0 S - -# From Ephraim Silverberg -# (1997-03-04, 1998-03-16, 1998-12-28, 2000-01-17, 2000-07-25, 2004-12-22, -# and 2005-02-17): - -# According to the Office of the Secretary General of the Ministry of -# Interior, there is NO set rule for Daylight-Savings/Standard time changes. -# One thing is entrenched in law, however: that there must be at least 150 -# days of daylight savings time annually. From 1993-1998, the change to -# daylight savings time was on a Friday morning from midnight IST to -# 1 a.m IDT; up until 1998, the change back to standard time was on a -# Saturday night from midnight daylight savings time to 11 p.m. standard -# time. 1996 is an exception to this rule where the change back to standard -# time took place on Sunday night instead of Saturday night to avoid -# conflicts with the Jewish New Year. In 1999, the change to -# daylight savings time was still on a Friday morning but from -# 2 a.m. IST to 3 a.m. IDT; furthermore, the change back to standard time -# was also on a Friday morning from 2 a.m. IDT to 1 a.m. IST for -# 1999 only. In the year 2000, the change to daylight savings time was -# similar to 1999, but although the change back will be on a Friday, it -# will take place from 1 a.m. IDT to midnight IST. Starting in 2001, all -# changes to/from will take place at 1 a.m. old time, but now there is no -# rule as to what day of the week it will take place in as the start date -# (except in 2003) is the night after the Passover Seder (i.e. the eve -# of the 16th of Nisan in the lunar Hebrew calendar) and the end date -# (except in 2002) is three nights before Yom Kippur [Day of Atonement] -# (the eve of the 7th of Tishrei in the lunar Hebrew calendar). - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1989 only - Apr 30 0:00 1:00 D -Rule Zion 1989 only - Sep 3 0:00 0 S -Rule Zion 1990 only - Mar 25 0:00 1:00 D -Rule Zion 1990 only - Aug 26 0:00 0 S -Rule Zion 1991 only - Mar 24 0:00 1:00 D -Rule Zion 1991 only - Sep 1 0:00 0 S -Rule Zion 1992 only - Mar 29 0:00 1:00 D -Rule Zion 1992 only - Sep 6 0:00 0 S -Rule Zion 1993 only - Apr 2 0:00 1:00 D -Rule Zion 1993 only - Sep 5 0:00 0 S - -# The dates for 1994-1995 were obtained from Office of the Spokeswoman for the -# Ministry of Interior, Jerusalem, Israel. The spokeswoman can be reached by -# calling the office directly at 972-2-6701447 or 972-2-6701448. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1994 only - Apr 1 0:00 1:00 D -Rule Zion 1994 only - Aug 28 0:00 0 S -Rule Zion 1995 only - Mar 31 0:00 1:00 D -Rule Zion 1995 only - Sep 3 0:00 0 S - -# The dates for 1996 were determined by the Minister of Interior of the -# time, Haim Ramon. The official announcement regarding 1996-1998 -# (with the dates for 1997-1998 no longer being relevant) can be viewed at: -# -# ftp://ftp.cs.huji.ac.il/pub/tz/announcements/1996-1998.ramon.ps.gz -# -# The dates for 1997-1998 were altered by his successor, Rabbi Eli Suissa. -# -# The official announcements for the years 1997-1999 can be viewed at: -# -# ftp://ftp.cs.huji.ac.il/pub/tz/announcements/YYYY.ps.gz -# -# where YYYY is the relevant year. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1996 only - Mar 15 0:00 1:00 D -Rule Zion 1996 only - Sep 16 0:00 0 S -Rule Zion 1997 only - Mar 21 0:00 1:00 D -Rule Zion 1997 only - Sep 14 0:00 0 S -Rule Zion 1998 only - Mar 20 0:00 1:00 D -Rule Zion 1998 only - Sep 6 0:00 0 S -Rule Zion 1999 only - Apr 2 2:00 1:00 D -Rule Zion 1999 only - Sep 3 2:00 0 S - -# The Knesset Interior Committee has changed the dates for 2000 for -# the third time in just over a year and have set new dates for the -# years 2001-2004 as well. -# -# The official announcement for the start date of 2000 can be viewed at: -# -# ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2000-start.ps.gz -# -# The official announcement for the end date of 2000 and the dates -# for the years 2001-2004 can be viewed at: -# -# ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2000-2004.ps.gz - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 2000 only - Apr 14 2:00 1:00 D -Rule Zion 2000 only - Oct 6 1:00 0 S -Rule Zion 2001 only - Apr 9 1:00 1:00 D -Rule Zion 2001 only - Sep 24 1:00 0 S -Rule Zion 2002 only - Mar 29 1:00 1:00 D -Rule Zion 2002 only - Oct 7 1:00 0 S -Rule Zion 2003 only - Mar 28 1:00 1:00 D -Rule Zion 2003 only - Oct 3 1:00 0 S -Rule Zion 2004 only - Apr 7 1:00 1:00 D -Rule Zion 2004 only - Sep 22 1:00 0 S - -# The proposed law agreed upon by the Knesset Interior Committee on -# 2005-02-14 is that, for 2005 and beyond, DST starts at 02:00 the -# last Friday before April 2nd (i.e. the last Friday in March or April -# 1st itself if it falls on a Friday) and ends at 02:00 on the Saturday -# night _before_ the fast of Yom Kippur. -# -# Those who can read Hebrew can view the announcement at: -# -# ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2005+beyond.ps - -# From Paul Eggert (2012-10-26): -# I used Ephraim Silverberg's dst-israel.el program -# <ftp://ftp.cs.huji.ac.il/pub/tz/software/dst-israel.el> (2005-02-20) -# along with Ed Reingold's cal-hebrew in GNU Emacs 21.4, -# to generate the transitions from 2005 through 2012. -# (I replaced "lastFri" with "Fri>=26" by hand.) -# The spring transitions all correspond to the following Rule: -# -# Rule Zion 2005 2012 - Mar Fri>=26 2:00 1:00 D -# -# but older zic implementations (e.g., Solaris 8) do not support -# "Fri>=26" to mean April 1 in years like 2005, so for now we list the -# springtime transitions explicitly. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 2005 only - Apr 1 2:00 1:00 D -Rule Zion 2005 only - Oct 9 2:00 0 S -Rule Zion 2006 2010 - Mar Fri>=26 2:00 1:00 D -Rule Zion 2006 only - Oct 1 2:00 0 S -Rule Zion 2007 only - Sep 16 2:00 0 S -Rule Zion 2008 only - Oct 5 2:00 0 S -Rule Zion 2009 only - Sep 27 2:00 0 S -Rule Zion 2010 only - Sep 12 2:00 0 S -Rule Zion 2011 only - Apr 1 2:00 1:00 D -Rule Zion 2011 only - Oct 2 2:00 0 S -Rule Zion 2012 only - Mar Fri>=26 2:00 1:00 D -Rule Zion 2012 only - Sep 23 2:00 0 S - -# From Ephraim Silverberg (2013-06-27): -# On June 23, 2013, the Israeli government approved changes to the -# Time Decree Law. The next day, the changes passed the First Reading -# in the Knesset. The law is expected to pass the Second and Third -# (final) Readings by the beginning of September 2013. -# -# As of 2013, DST starts at 02:00 on the Friday before the last Sunday -# in March. DST ends at 02:00 on the last Sunday of October. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 2013 max - Mar Fri>=23 2:00 1:00 D -Rule Zion 2013 max - Oct lastSun 2:00 0 S - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Jerusalem 2:20:54 - LMT 1880 - 2:20:40 - JMT 1918 # Jerusalem Mean Time? - 2:00 Zion I%sT - - - -############################################################################### - -# Japan - -# '9:00' and 'JST' is from Guy Harris. - -# From Paul Eggert (1995-03-06): -# Today's _Asahi Evening News_ (page 4) reports that Japan had -# daylight saving between 1948 and 1951, but "the system was discontinued -# because the public believed it would lead to longer working hours." - -# From Mayumi Negishi in the 2005-08-10 Japan Times: -# http://www.japantimes.co.jp/cgi-bin/getarticle.pl5?nn20050810f2.htm -# Occupation authorities imposed daylight-saving time on Japan on -# [1948-05-01].... But lack of prior debate and the execution of -# daylight-saving time just three days after the bill was passed generated -# deep hatred of the concept.... The Diet unceremoniously passed a bill to -# dump the unpopular system in October 1951, less than a month after the San -# Francisco Peace Treaty was signed. (A government poll in 1951 showed 53% -# of the Japanese wanted to scrap daylight-saving time, as opposed to 30% who -# wanted to keep it.) - -# From Takayuki Nikai (2018-01-19): -# The source of information is Japanese law. -# http://www.shugiin.go.jp/internet/itdb_housei.nsf/html/houritsu/00219480428029.htm -# http://www.shugiin.go.jp/internet/itdb_housei.nsf/html/houritsu/00719500331039.htm -# ... In summary, it is written as follows. From 24:00 on the first Saturday -# in May, until 0:00 on the day after the second Saturday in September. - -# From Phake Nick (2018-09-27): -# [T]he webpage authored by National Astronomical Observatory of Japan -# https://eco.mtk.nao.ac.jp/koyomi/wiki/BBFEB9EF2FB2C6BBFEB9EF.html -# ... mentioned that using Showa 23 (year 1948) as example, 13pm of September -# 11 in summer time will equal to 0am of September 12 in standard time. -# It cited a document issued by the Liaison Office which briefly existed -# during the postwar period of Japan, where the detail on implementation -# of the summer time is described in the document. -# https://eco.mtk.nao.ac.jp/koyomi/wiki/BBFEB9EF2FB2C6BBFEB9EFB2C6BBFEB9EFA4CEBCC2BBDCA4CBA4C4A4A4A4C6.pdf -# The text in the document do instruct a fall back to occur at -# September 11, 13pm in summer time, while ordinary citizens can -# change the clock before they sleep. -# -# From Paul Eggert (2018-09-27): -# This instruction is equivalent to "Sat>=8 25:00", so use that. zic treats -# it like "Sun>=9 01:00", which is not quite the same but is the best we can -# do in any POSIX or C platform. The "25:00" assumes zic from 2007 or later, -# which should be safe now. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Japan 1948 only - May Sat>=1 24:00 1:00 D -Rule Japan 1948 1951 - Sep Sun>=9 1:00 0 S -Rule Japan 1949 only - Apr Sat>=1 24:00 1:00 D -Rule Japan 1950 1951 - May Sat>=1 24:00 1:00 D - -# From Hideyuki Suzuki (1998-11-09): -# 'Tokyo' usually stands for the former location of Tokyo Astronomical -# Observatory: 139° 44' 40.90" E (9h 18m 58.727s), 35° 39' 16.0" N. -# This data is from 'Rika Nenpyou (Chronological Scientific Tables) 1996' -# edited by National Astronomical Observatory of Japan.... -# JST (Japan Standard Time) has been used since 1888-01-01 00:00 (JST). -# The law is enacted on 1886-07-07. - -# From Hideyuki Suzuki (1998-11-16): -# The ordinance No. 51 (1886) established "standard time" in Japan, -# which stands for the time on 135° E. -# In the ordinance No. 167 (1895), "standard time" was renamed to "central -# standard time". And the same ordinance also established "western standard -# time", which stands for the time on 120° E.... But "western standard -# time" was abolished in the ordinance No. 529 (1937). In the ordinance No. -# 167, there is no mention regarding for what place western standard time is -# standard.... -# -# I wrote "ordinance" above, but I don't know how to translate. -# In Japanese it's "chokurei", which means ordinance from emperor. - -# From Yu-Cheng Chuang (2013-07-12): -# ...the Meiji Emperor announced Ordinance No. 167 of Meiji Year 28 "The clause -# about standard time" ... The adoption began from Jan 1, 1896. -# https://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時) -# -# ...the Showa Emperor announced Ordinance No. 529 of Showa Year 12 ... which -# means the whole Japan territory, including later occupations, adopt Japan -# Central Time (UT+9). The adoption began on Oct 1, 1937. -# https://ja.wikisource.org/wiki/明治二十八年勅令第百六十七號標準時ニ關スル件中改正ノ件 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u - 9:00 Japan J%sT -# Since 1938, all Japanese possessions have been like Asia/Tokyo. - -# Jordan -# -# From <http://star.arabia.com/990701/JO9.html> -# Jordan Week (1999-07-01) via Steffen Thorsen (1999-09-09): -# Clocks in Jordan were forwarded one hour on Wednesday at midnight, -# in accordance with the government's decision to implement summer time -# all year round. -# -# From <http://star.arabia.com/990930/JO9.html> -# Jordan Week (1999-09-30) via Steffen Thorsen (1999-11-09): -# Winter time starts today Thursday, 30 September. Clocks will be turned back -# by one hour. This is the latest government decision and it's final! -# The decision was taken because of the increase in working hours in -# government's departments from six to seven hours. -# -# From Paul Eggert (2005-11-22): -# Starting 2003 transitions are from Steffen Thorsen's web site timeanddate.com. -# -# From Steffen Thorsen (2005-11-23): -# For Jordan I have received multiple independent user reports every year -# about DST end dates, as the end-rule is different every year. -# -# From Steffen Thorsen (2006-10-01), after a heads-up from Hilal Malawi: -# http://www.petranews.gov.jo/nepras/2006/Sep/05/4000.htm -# "Jordan will switch to winter time on Friday, October 27". -# - -# From Steffen Thorsen (2009-04-02): -# This single one might be good enough, (2009-03-24, Arabic): -# http://petra.gov.jo/Artical.aspx?Lng=2&Section=8&Artical=95279 -# -# Google's translation: -# -# > The Council of Ministers decided in 2002 to adopt the principle of timely -# > submission of the summer at 60 minutes as of midnight on the last Thursday -# > of the month of March of each year. -# -# So - this means the midnight between Thursday and Friday since 2002. - -# From Arthur David Olson (2009-04-06): -# We still have Jordan switching to DST on Thursdays in 2000 and 2001. - -# From Steffen Thorsen (2012-10-25): -# Yesterday the government in Jordan announced that they will not -# switch back to standard time this winter, so the will stay on DST -# until about the same time next year (at least). -# http://www.petra.gov.jo/Public_News/Nws_NewsDetails.aspx?NewsID=88950 - -# From Steffen Thorsen (2013-12-11): -# Jordan Times and other sources say that Jordan is going back to -# UTC+2 on 2013-12-19 at midnight: -# http://jordantimes.com/govt-decides-to-switch-back-to-wintertime -# Official, in Arabic: -# http://www.petra.gov.jo/public_news/Nws_NewsDetails.aspx?Menu_ID=&Site_Id=2&lang=1&NewsID=133230&CatID=14 -# ... Our background/permalink about it -# https://www.timeanddate.com/news/time/jordan-reverses-dst-decision.html -# ... -# http://www.petra.gov.jo/Public_News/Nws_NewsDetails.aspx?lang=2&site_id=1&NewsID=133313&Type=P -# ... says midnight for the coming one and 1:00 for the ones in the future -# (and they will use DST again next year, using the normal schedule). - -# From Paul Eggert (2013-12-11): -# As Steffen suggested, consider the past 21-month experiment to be DST. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Jordan 1973 only - Jun 6 0:00 1:00 S -Rule Jordan 1973 1975 - Oct 1 0:00 0 - -Rule Jordan 1974 1977 - May 1 0:00 1:00 S -Rule Jordan 1976 only - Nov 1 0:00 0 - -Rule Jordan 1977 only - Oct 1 0:00 0 - -Rule Jordan 1978 only - Apr 30 0:00 1:00 S -Rule Jordan 1978 only - Sep 30 0:00 0 - -Rule Jordan 1985 only - Apr 1 0:00 1:00 S -Rule Jordan 1985 only - Oct 1 0:00 0 - -Rule Jordan 1986 1988 - Apr Fri>=1 0:00 1:00 S -Rule Jordan 1986 1990 - Oct Fri>=1 0:00 0 - -Rule Jordan 1989 only - May 8 0:00 1:00 S -Rule Jordan 1990 only - Apr 27 0:00 1:00 S -Rule Jordan 1991 only - Apr 17 0:00 1:00 S -Rule Jordan 1991 only - Sep 27 0:00 0 - -Rule Jordan 1992 only - Apr 10 0:00 1:00 S -Rule Jordan 1992 1993 - Oct Fri>=1 0:00 0 - -Rule Jordan 1993 1998 - Apr Fri>=1 0:00 1:00 S -Rule Jordan 1994 only - Sep Fri>=15 0:00 0 - -Rule Jordan 1995 1998 - Sep Fri>=15 0:00s 0 - -Rule Jordan 1999 only - Jul 1 0:00s 1:00 S -Rule Jordan 1999 2002 - Sep lastFri 0:00s 0 - -Rule Jordan 2000 2001 - Mar lastThu 0:00s 1:00 S -Rule Jordan 2002 2012 - Mar lastThu 24:00 1:00 S -Rule Jordan 2003 only - Oct 24 0:00s 0 - -Rule Jordan 2004 only - Oct 15 0:00s 0 - -Rule Jordan 2005 only - Sep lastFri 0:00s 0 - -Rule Jordan 2006 2011 - Oct lastFri 0:00s 0 - -Rule Jordan 2013 only - Dec 20 0:00 0 - -Rule Jordan 2014 max - Mar lastThu 24:00 1:00 S -Rule Jordan 2014 max - Oct lastFri 0:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Amman 2:23:44 - LMT 1931 - 2:00 Jordan EE%sT - - -# Kazakhstan - -# From Kazakhstan Embassy's News Bulletin No. 11 -# <http://www.kazsociety.org.uk/news/2005/03/30.htm> (2005-03-21): -# The Government of Kazakhstan passed a resolution March 15 abolishing -# daylight saving time citing lack of economic benefits and health -# complications coupled with a decrease in productivity. -# -# From Branislav Kojic (in Astana) via Gwillim Law (2005-06-28): -# ... what happened was that the former Kazakhstan Eastern time zone -# was "blended" with the Central zone. Therefore, Kazakhstan now has -# two time zones, and difference between them is one hour. The zone -# closer to UTC is the former Western zone (probably still called the -# same), encompassing four provinces in the west: Aqtöbe, Atyraū, -# Mangghystaū, and West Kazakhstan. The other zone encompasses -# everything else.... I guess that would make Kazakhstan time zones -# de jure UTC+5 and UTC+6 respectively. - -# From Stepan Golosunov (2016-03-27): -# Review of the linked documents from http://adilet.zan.kz/ -# produced the following data for post-1991 Kazakhstan: -# -# 0. Act of the Cabinet of Ministers of the USSR -# from 1991-02-04 No. 20 -# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102010545 -# removed the extra hour ("decree time") on the territory of the USSR -# starting with the last Sunday of March 1991. -# It also allowed (but not mandated) Kazakh SSR, Kirghiz SSR, Tajik SSR, -# Turkmen SSR and Uzbek SSR to not have "summer" time. -# -# The 1992-01-13 act also refers to the act of the Cabinet of Ministers -# of the Kazakh SSR from 1991-03-20 No. 170 "About the act of the Cabinet -# of Ministers of the USSR from 1991-02-04 No. 20" but I didn't found its -# text. -# -# According to Izvestia newspaper No. 68 (23334) from 1991-03-20 -# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via -# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during -# transition to "summer" time: -# Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova, -# Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug -# were to move clocks 1 hour forward. -# Kazakh SSR (excluding Uralsk oblast); Republic of Kyrgyzstan, Tajik -# SSR; Andijan, Jizzakh, Namangan, Sirdarya, Tashkent, Fergana oblasts -# of the Uzbek SSR were to move clocks 1 hour backwards. -# Other territories were to not move clocks. -# When the "summer" time would end on 1991-09-29, clocks were to be -# moved 1 hour backwards on the territory of the USSR excluding -# Kazakhstan, Kirghizia, Uzbekistan, Turkmenia, Tajikistan. -# -# Apparently there were last minute changes. Apparently Kazakh act No. 170 -# was one of such changes. -# -# https://ru.wikipedia.org/wiki/Декретное время -# claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that -# Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast) -# were to not move clocks and Uralsk oblast was to move clocks -# forward; on 1991-09-29 Kazakhstan was to move clocks backwards. -# (Probably there were changes even after that publication. There is an -# article claiming that Kaliningrad oblast decided on 1991-03-29 to not -# move clocks.) -# -# This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while -# the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06 -# to +04/+05. It's unclear how Qyzylorda oblast moved into the fifth -# time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ... -# -# 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan -# from 1992-01-13 No. 28 -# http://adilet.zan.kz/rus/docs/P920000028_ -# (text includes modification from the 1996 act) -# introduced new rules for calculation of time, mirroring Russian -# 1992-01-08 act. It specified that time would be calculated -# according to time belts plus extra hour ("decree time"), moved clocks -# on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at -# 2:00, specified DST rules. It acknowledged that Kazakhstan was -# located in the fourth and the fifth time belts and specified the -# border between them to be located east of Qostanay and Aktyubinsk -# oblasts (notably including Turgai and Qyzylorda oblasts into the fifth -# time belt). -# -# This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for -# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyraū and Qostanay oblasts; from -# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk).... -# -# 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan -# from 1992-03-27 No. 284 -# http://adilet.zan.kz/rus/docs/P920000284_ -# cancels extra hour ("decree time") for Uralsk and Qyzylorda oblasts -# since the last Sunday of March 1992, while keeping them in the fourth -# and the fifth time belts respectively. -# -# 3. Order of the Prime Minister of the Republic of Kazakhstan -# from 1994-09-23 No. 384 -# http://adilet.zan.kz/rus/docs/R940000384_ -# cancels the extra hour ("decree time") on the territory of Mangghystaū -# oblast since the last Sunday of September 1994 (saying that time on -# the territory would correspond to the third time belt as a -# result).... -# -# 4. Act of the Government of the Republic of Kazakhstan -# from 1996-05-08 No. 575 -# http://adilet.zan.kz/rus/docs/P960000575_ -# amends the 1992-01-13 act to end summer time in October instead -# of September, mirroring identical Russian change from 1996-04-23 act. -# -# 5. Act of the Government of the Republic of Kazakhstan -# from 1999-03-26 No. 305 -# http://adilet.zan.kz/rus/docs/P990000305_ -# cancels the extra hour ("decree time") for Atyraū oblast since the -# last Sunday of March 1999 while retaining the oblast in the fourth -# time belt. -# -# This means change from +05/+06 to +04/+05.... -# -# 6. Act of the Government of the Republic of Kazakhstan -# from 2000-11-23 No. 1749 -# http://adilet.zan.kz/rus/archive/docs/P000001749_/23.11.2000 -# replaces the previous five documents. -# -# The only changes I noticed are in definition of the border between the -# fourth and the fifth time belts. They account for changes in spelling -# and administrative division (splitting of Turgai oblast in 1997 -# probably changed time in territories incorporated into Qostanay oblast -# (including Arkalyk) from +06/+07 to +05/+06) and move Qyzylorda oblast -# from being in the fifth time belt and not using decree time into the -# fourth time belt (no change in practice). -# -# 7. Act of the Government of the Republic of Kazakhstan -# from 2003-12-29 No. 1342 -# http://adilet.zan.kz/rus/docs/P030001342_ -# modified the 2000-11-23 act. No relevant changes, apparently. -# -# 8. Act of the Government of the Republic of Kazakhstan -# from 2004-07-20 No. 775 -# http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004 -# modified the 2000-11-23 act to move Qostanay and Qyzylorda oblasts into -# the fifth time belt and add Aktobe oblast to the list of regions not -# using extra hour ("decree time"), leaving Kazakhstan with only 2 time -# zones (+04/+05 and +06/+07). The changes were to be implemented -# during DST transitions in 2004 and 2005 but the acts got radically -# amended before implementation happened. -# -# 9. Act of the Government of the Republic of Kazakhstan -# from 2004-09-15 No. 1059 -# http://adilet.zan.kz/rus/docs/P040001059_ -# modified the 2000-11-23 act to remove exceptions from the "decree time" -# (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the -# 2004-07-20 act to implement changes for Atyraū, West Kazakhstan, -# Qostanay, Qyzylorda and Mangghystaū oblasts by not moving clocks -# during the 2004 transition to "winter" time. -# -# This means transition from +04/+05 to +05/+06 for Atyraū oblast (no -# zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to -# +06/+07 for Qostanay oblast (Qostanay and Arkalyk, no zones currently) -# and Asia/Qyzylorda on 2004-10-31 at 3:00.... -# -# 10. Act of the Government of the Republic of Kazakhstan -# from 2005-03-15 No. 231 -# http://adilet.zan.kz/rus/docs/P050000231_ -# removes DST provisions from the 2000-11-23 act, removes most of the -# (already implemented) provisions from the 2004-07-20 and 2004-09-15 -# acts, comes into effect 10 days after official publication. -# The only practical effect seems to be the abolition of the summer -# time. -# -# Unamended version of the act of the Government of the Russian Federation -# No. 23 from 1992-01-08 [See 'europe' file for details]. -# Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27 -# act was to be enacted on the last Sunday of March 1992. - -# From Stepan Golosunov (2016-11-08): -# Turgai reorganization should affect only southern part of Qostanay -# oblast. Which should probably be separated into Asia/Arkalyk zone. -# (There were also 1970, 1988 and 1990 Turgai oblast reorganizations -# according to wikipedia.) -# -# [For Qostanay] http://www.ng.kz/gazeta/195/hranit/ -# suggests that clocks were to be moved 40 minutes backwards on -# 1920-01-01 to the fourth time belt. But I do not understand -# how that could happen.... -# -# [For Atyrau and Oral] 1919 decree -# (http://www.worldtimezone.com/dst_news/dst_news_russia-1919-02-08.html -# and in Byalokoz) lists Ural river (plus 10 versts on its left bank) in -# the third time belt (before 1930 this means +03). - -# From Paul Eggert (2016-12-06): -# The tables below reflect Golosunov's remarks, with exceptions as noted. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# -# Almaty (formerly Alma-Ata), representing most locations in Kazakhstan -# This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA, -# KZ-KAR, KZ-SEV, KZ-PAV, and KZ-YUZ. -Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 # or Alma-Ata - 5:00 - +05 1930 Jun 21 - 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s - 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s - 6:00 RussiaAsia +06/+07 2004 Oct 31 2:00s - 6:00 - +06 -# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY) -# This currently includes Qostanay (aka Kostanay, Kustanay) (KZ-KUS); -# see comments below. -Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 - 4:00 - +04 1930 Jun 21 - 5:00 - +05 1981 Apr 1 - 5:00 1:00 +06 1981 Oct 1 - 6:00 - +06 1982 Apr 1 - 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s - 4:00 RussiaAsia +04/+05 1991 Sep 29 2:00s - 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s - 6:00 RussiaAsia +06/+07 1992 Mar 29 2:00s - 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s - 6:00 - +06 -# The following zone is like Asia/Qyzylorda except for being one -# hour earlier from 1991-09-29 to 1992-03-29. The 1991/2 rules for -# Qostanay are unclear partly because of the 1997 Turgai -# reorganization, so this zone is commented out for now. -#Zone Asia/Qostanay 4:14:20 - LMT 1924 May 2 -# 4:00 - +04 1930 Jun 21 -# 5:00 - +05 1981 Apr 1 -# 5:00 1:00 +06 1981 Oct 1 -# 6:00 - +06 1982 Apr 1 -# 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s -# 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s -# 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s -# 6:00 - +06 -# -# Aqtöbe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT) -Zone Asia/Aqtobe 3:48:40 - LMT 1924 May 2 - 4:00 - +04 1930 Jun 21 - 5:00 - +05 1981 Apr 1 - 5:00 1:00 +06 1981 Oct 1 - 6:00 - +06 1982 Apr 1 - 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s - 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s - 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s - 5:00 - +05 -# Mangghystaū (KZ-MAN) -# Aqtau was not founded until 1963, but it represents an inhabited region, -# so include timestamps before 1963. -Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 - 4:00 - +04 1930 Jun 21 - 5:00 - +05 1981 Oct 1 - 6:00 - +06 1982 Apr 1 - 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s - 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s - 5:00 RussiaAsia +05/+06 1994 Sep 25 2:00s - 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s - 5:00 - +05 -# Atyraū (KZ-ATY) is like Mangghystaū except it switched from -# +04/+05 to +05/+06 in spring 1999, not fall 1994. -Zone Asia/Atyrau 3:27:44 - LMT 1924 May 2 - 3:00 - +03 1930 Jun 21 - 5:00 - +05 1981 Oct 1 - 6:00 - +06 1982 Apr 1 - 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s - 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s - 5:00 RussiaAsia +05/+06 1999 Mar 28 2:00s - 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s - 5:00 - +05 -# West Kazakhstan (KZ-ZAP) -# From Paul Eggert (2016-03-18): -# The 1989 transition is from USSR act No. 227 (1989-03-14). -Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk - 3:00 - +03 1930 Jun 21 - 5:00 - +05 1981 Apr 1 - 5:00 1:00 +06 1981 Oct 1 - 6:00 - +06 1982 Apr 1 - 5:00 RussiaAsia +05/+06 1989 Mar 26 2:00s - 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s - 5:00 RussiaAsia +05/+06 1992 Mar 29 2:00s - 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s - 5:00 - +05 - -# Kyrgyzstan (Kirgizstan) -# Transitions through 1991 are from Shanks & Pottenger. - -# From Paul Eggert (2005-08-15): -# According to an article dated today in the Kyrgyzstan Development Gateway -# http://eng.gateway.kg/cgi-bin/page.pl?id=1&story_name=doc9979.shtml -# Kyrgyzstan is canceling the daylight saving time system. I take the article -# to mean that they will leave their clocks at 6 hours ahead of UTC. -# From Malik Abdugaliev (2005-09-21): -# Our government cancels daylight saving time 6th of August 2005. -# From 2005-08-12 our GMT-offset is +6, w/o any daylight saving. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Kyrgyz 1992 1996 - Apr Sun>=7 0:00s 1:00 - -Rule Kyrgyz 1992 1996 - Sep lastSun 0:00 0 - -Rule Kyrgyz 1997 2005 - Mar lastSun 2:30 1:00 - -Rule Kyrgyz 1997 2004 - Oct lastSun 2:30 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 - 5:00 - +05 1930 Jun 21 - 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s - 5:00 RussiaAsia +05/+06 1991 Aug 31 2:00 - 5:00 Kyrgyz +05/+06 2005 Aug 12 - 6:00 - +06 - -############################################################################### - -# Korea (North and South) - -# From Annie I. Bang (2006-07-10): -# http://www.koreaherald.com/view.php?ud=200607100012 -# Korea ran a daylight saving program from 1949-61 but stopped it -# during the 1950-53 Korean War. The system was temporarily enforced -# between 1987 and 1988 ... - -# From Sanghyuk Jung (2014-10-29): -# https://mm.icann.org/pipermail/tz/2014-October/021830.html -# According to the Korean Wikipedia -# https://ko.wikipedia.org/wiki/한국_표준시 -# [oldid=12896437 2014-09-04 08:03 UTC] -# DST in Republic of Korea was as follows.... And I checked old -# newspapers in Korean, all articles correspond with data in Wikipedia. -# For example, the article in 1948 (Korean Language) proved that DST -# started at June 1 in that year. For another example, the article in -# 1988 said that DST started at 2:00 AM in that year. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule ROK 1948 only - Jun 1 0:00 1:00 D -Rule ROK 1948 only - Sep 13 0:00 0 S -Rule ROK 1949 only - Apr 3 0:00 1:00 D -Rule ROK 1949 1951 - Sep Sun>=8 0:00 0 S -Rule ROK 1950 only - Apr 1 0:00 1:00 D -Rule ROK 1951 only - May 6 0:00 1:00 D -Rule ROK 1955 only - May 5 0:00 1:00 D -Rule ROK 1955 only - Sep 9 0:00 0 S -Rule ROK 1956 only - May 20 0:00 1:00 D -Rule ROK 1956 only - Sep 30 0:00 0 S -Rule ROK 1957 1960 - May Sun>=1 0:00 1:00 D -Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 S -Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D -Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S - -# From Paul Eggert (2016-08-23): -# The Korean Wikipedia entry gives the following sources for UT offsets: -# -# 1908: Official Journal Article No. 3994 (decree No. 5) -# 1912: Governor-General of Korea Official Gazette Issue No. 367 -# (Announcement No. 338) -# 1954: Presidential Decree No. 876 (1954-03-17) -# 1961: Law No. 676 (1961-08-07) -# -# (Another source "1987: Law No. 3919 (1986-12-31)" was in the 2014-10-30 -# edition of the Korean Wikipedia entry.) -# -# I guessed that time zone abbreviations through 1945 followed the same -# rules as discussed under Taiwan, with nominal switches from JST to KST -# when the respective cities were taken over by the Allies after WWII. -# -# For Pyongyang, guess no changes from World War II until 2015, as we -# have no information otherwise. - -# From Steffen Thorsen (2015-08-07): -# According to many news sources, North Korea is going to change to -# the 8:30 time zone on August 15, one example: -# http://www.bbc.com/news/world-asia-33815049 -# -# From Paul Eggert (2015-08-15): -# Bells rang out midnight (00:00) Friday as part of the celebrations. See: -# Talmadge E. North Korea celebrates new time zone, 'Pyongyang Time' -# http://news.yahoo.com/north-korea-celebrates-time-zone-pyongyang-time-164038128.html -# There is no common English-language abbreviation for this time zone. -# Use KST, as that's what we already use for 1954-1961 in ROK. - -# From Kang Seonghoon (2018-04-29): -# North Korea will revert its time zone from UTC+8:30 (PYT; Pyongyang -# Time) back to UTC+9 (KST; Korea Standard Time). -# -# From Seo Sanghyeon (2018-04-30): -# Rodong Sinmun 2018-04-30 announced Pyongyang Time transition plan. -# https://www.nknews.org/kcna/wp-content/uploads/sites/5/2018/04/rodong-2018-04-30.pdf -# ... the transition date is 2018-05-05 ... Citation should be Decree -# No. 2232 of April 30, 2018, of the Presidium of the Supreme People's -# Assembly, as published in Rodong Sinmun. -# From Tim Parenti (2018-04-29): -# It appears to be the front page story at the top in the right-most column. -# -# From Paul Eggert (2018-05-04): -# The BBC reported that the transition was from 23:30 to 24:00 today. -# https://www.bbc.com/news/world-asia-44010705 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1 - 8:30 - KST 1912 Jan 1 - 9:00 - JST 1945 Sep 8 - 9:00 - KST 1954 Mar 21 - 8:30 ROK K%sT 1961 Aug 10 - 9:00 ROK K%sT -Zone Asia/Pyongyang 8:23:00 - LMT 1908 Apr 1 - 8:30 - KST 1912 Jan 1 - 9:00 - JST 1945 Aug 24 - 9:00 - KST 2015 Aug 15 00:00 - 8:30 - KST 2018 May 4 23:30 - 9:00 - KST - -############################################################################### - -# Kuwait -# See Asia/Riyadh. - -# Laos -# See Asia/Bangkok. - - -# Lebanon -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Lebanon 1920 only - Mar 28 0:00 1:00 S -Rule Lebanon 1920 only - Oct 25 0:00 0 - -Rule Lebanon 1921 only - Apr 3 0:00 1:00 S -Rule Lebanon 1921 only - Oct 3 0:00 0 - -Rule Lebanon 1922 only - Mar 26 0:00 1:00 S -Rule Lebanon 1922 only - Oct 8 0:00 0 - -Rule Lebanon 1923 only - Apr 22 0:00 1:00 S -Rule Lebanon 1923 only - Sep 16 0:00 0 - -Rule Lebanon 1957 1961 - May 1 0:00 1:00 S -Rule Lebanon 1957 1961 - Oct 1 0:00 0 - -Rule Lebanon 1972 only - Jun 22 0:00 1:00 S -Rule Lebanon 1972 1977 - Oct 1 0:00 0 - -Rule Lebanon 1973 1977 - May 1 0:00 1:00 S -Rule Lebanon 1978 only - Apr 30 0:00 1:00 S -Rule Lebanon 1978 only - Sep 30 0:00 0 - -Rule Lebanon 1984 1987 - May 1 0:00 1:00 S -Rule Lebanon 1984 1991 - Oct 16 0:00 0 - -Rule Lebanon 1988 only - Jun 1 0:00 1:00 S -Rule Lebanon 1989 only - May 10 0:00 1:00 S -Rule Lebanon 1990 1992 - May 1 0:00 1:00 S -Rule Lebanon 1992 only - Oct 4 0:00 0 - -Rule Lebanon 1993 max - Mar lastSun 0:00 1:00 S -Rule Lebanon 1993 1998 - Sep lastSun 0:00 0 - -Rule Lebanon 1999 max - Oct lastSun 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Beirut 2:22:00 - LMT 1880 - 2:00 Lebanon EE%sT - -# Malaysia -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NBorneo 1935 1941 - Sep 14 0:00 0:20 - -Rule NBorneo 1935 1941 - Dec 14 0:00 0 - -# -# peninsular Malaysia -# taken from Mok Ly Yng (2003-10-30) -# http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kuala_Lumpur 6:46:46 - LMT 1901 Jan 1 - 6:55:25 - SMT 1905 Jun 1 # Singapore M.T. - 7:00 - +07 1933 Jan 1 - 7:00 0:20 +0720 1936 Jan 1 - 7:20 - +0720 1941 Sep 1 - 7:30 - +0730 1942 Feb 16 - 9:00 - +09 1945 Sep 12 - 7:30 - +0730 1982 Jan 1 - 8:00 - +08 -# Sabah & Sarawak -# From Paul Eggert (2014-08-12): -# The data entries here are mostly from Shanks & Pottenger, but the 1942, 1945 -# and 1982 transition dates are from Mok Ly Yng. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kuching 7:21:20 - LMT 1926 Mar - 7:30 - +0730 1933 - 8:00 NBorneo +08/+0820 1942 Feb 16 - 9:00 - +09 1945 Sep 12 - 8:00 - +08 - -# Maldives -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Maldives 4:54:00 - LMT 1880 # Malé - 4:54:00 - MMT 1960 # Malé Mean Time - 5:00 - +05 - -# Mongolia - -# Shanks & Pottenger say that Mongolia has three time zones, but -# The USNO (1995-12-21) and the CIA map Standard Time Zones of the World -# (2005-03) both say that it has just one. - -# From Oscar van Vlijmen (1999-12-11): -# General Information Mongolia -# <http://www.mongoliatourism.gov.mn/general.htm> (1999-09) -# "Time: Mongolia has two time zones. Three westernmost provinces of -# Bayan-Ölgii, Uvs, and Hovd are one hour earlier than the capital city, and -# the rest of the country follows the Ulaanbaatar time, which is UTC/GMT plus -# eight hours." - -# From Rives McDow (1999-12-13): -# Mongolia discontinued the use of daylight savings time in 1999; 1998 -# being the last year it was implemented. The dates of implementation I am -# unsure of, but most probably it was similar to Russia, except for the time -# of implementation may have been different.... -# Some maps in the past have indicated that there was an additional time -# zone in the eastern part of Mongolia, including the provinces of Dornod, -# Sükhbaatar, and possibly Khentii. - -# From Paul Eggert (1999-12-15): -# Naming and spelling is tricky in Mongolia. -# We'll use Hovd (also spelled Chovd and Khovd) to represent the west zone; -# the capital of the Hovd province is sometimes called Hovd, sometimes Dund-Us, -# and sometimes Jirgalanta (with variant spellings), but the name Hovd -# is good enough for our purposes. - -# From Rives McDow (2001-05-13): -# In addition to Mongolia starting daylight savings as reported earlier -# (adopted DST on 2001-04-27 02:00 local time, ending 2001-09-28), -# there are three time zones. -# -# Provinces [at 7:00]: Bayan-Ölgii, Uvs, Khovd, Zavkhan, Govi-Altai -# Provinces [at 8:00]: Khövsgöl, Bulgan, Arkhangai, Khentii, Töv, -# Bayankhongor, Övörkhangai, Dundgovi, Dornogovi, Ömnögovi -# Provinces [at 9:00]: Dornod, Sükhbaatar -# -# [The province of Selenge is omitted from the above lists.] - -# From Ganbold Ts., Ulaanbaatar (2004-04-17): -# Daylight saving occurs at 02:00 local time last Saturday of March. -# It will change back to normal at 02:00 local time last Saturday of -# September.... As I remember this rule was changed in 2001. -# -# From Paul Eggert (2004-04-17): -# For now, assume Rives McDow's informant got confused about Friday vs -# Saturday, and that his 2001 dates should have 1 added to them. - -# From Paul Eggert (2005-07-26): -# We have wildly conflicting information about Mongolia's time zones. -# Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says -# there is only one time zone and that DST is observed, citing Microsoft -# Windows XP as the source. Risto Nykänen (2005-05-16) reports that -# travelmongolia.org says there are two time zones (UT +07, +08) with no DST. -# Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in -# Washington, DC says there are two time zones, with DST observed. -# He also found -# http://ubpost.mongolnews.mn/index.php?subaction=showcomments&id=1111634894&archive=&start_from=&ucat=1& -# which also says that there is DST, and which has a comment by "Toddius" -# (2005-03-31 06:05 +0700) saying "Mongolia actually has 3.5 time zones. -# The West (OLGII) is +7 GMT, most of the country is ULAT is +8 GMT -# and some Eastern provinces are +9 GMT but Sükhbaatar Aimag is SUHK +8.5 GMT. -# The SUKH timezone is new this year, it is one of the few things the -# parliament passed during the tumultuous winter session." -# For now, let's ignore this information, until we have more confirmation. - -# From Ganbold Ts. (2007-02-26): -# Parliament of Mongolia has just changed the daylight-saving rule in February. -# They decided not to adopt daylight-saving time.... -# http://www.mongolnews.mn/index.php?module=unuudur&sec=view&id=15742 - -# From Deborah Goldsmith (2008-03-30): -# We received a bug report claiming that the tz database UTC offset for -# Asia/Choibalsan (GMT+09:00) is incorrect, and that it should be GMT -# +08:00 instead. Different sources appear to disagree with the tz -# database on this, e.g.: -# -# https://www.timeanddate.com/worldclock/city.html?n=1026 -# http://www.worldtimeserver.com/current_time_in_MN.aspx -# -# both say GMT+08:00. - -# From Steffen Thorsen (2008-03-31): -# eznis airways, which operates several domestic flights, has a flight -# schedule here: -# http://www.eznis.com/Container.jsp?id=112 -# (click the English flag for English) -# -# There it appears that flights between Choibalsan and Ulaanbaatar arrive -# about 1:35 - 1:50 hours later in local clock time, no matter the -# direction, while Ulaanbaatar-Khovd takes 2 hours in the Eastern -# direction and 3:35 back, which indicates that Ulaanbaatar and Khovd are -# in different time zones (like we know about), while Choibalsan and -# Ulaanbaatar are in the same time zone (correction needed). - -# From Arthur David Olson (2008-05-19): -# Assume that Choibalsan is indeed offset by 8:00. -# XXX--in the absence of better information, assume that transition -# was at the start of 2008-03-31 (the day of Steffen Thorsen's report); -# this is almost surely wrong. - -# From Ganbold Tsagaankhuu (2015-03-10): -# It seems like yesterday Mongolian Government meeting has concluded to use -# daylight saving time in Mongolia.... Starting at 2:00AM of last Saturday of -# March 2015, daylight saving time starts. And 00:00AM of last Saturday of -# September daylight saving time ends. Source: -# http://zasag.mn/news/view/8969 - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Mongol 1983 1984 - Apr 1 0:00 1:00 - -Rule Mongol 1983 only - Oct 1 0:00 0 - -# Shanks & Pottenger and IATA SSIM say 1990s switches occurred at 00:00, -# but McDow says the 2001 switches occurred at 02:00. Also, IATA SSIM -# (1996-09) says 1996-10-25. Go with Shanks & Pottenger through 1998. -# -# Shanks & Pottenger say that the Sept. 1984 through Sept. 1990 switches -# in Choibalsan (more precisely, in Dornod and Sükhbaatar) took place -# at 02:00 standard time, not at 00:00 local time as in the rest of -# the country. That would be odd, and possibly is a result of their -# correction of 02:00 (in the previous edition) not being done correctly -# in the latest edition; so ignore it for now. - -# From Ganbold Tsagaankhuu (2017-02-09): -# Mongolian Government meeting has concluded today to cancel daylight -# saving time adoption in Mongolia. Source: http://zasag.mn/news/view/16192 - -Rule Mongol 1985 1998 - Mar lastSun 0:00 1:00 - -Rule Mongol 1984 1998 - Sep lastSun 0:00 0 - -# IATA SSIM (1999-09) says Mongolia no longer observes DST. -Rule Mongol 2001 only - Apr lastSat 2:00 1:00 - -Rule Mongol 2001 2006 - Sep lastSat 2:00 0 - -Rule Mongol 2002 2006 - Mar lastSat 2:00 1:00 - -Rule Mongol 2015 2016 - Mar lastSat 2:00 1:00 - -Rule Mongol 2015 2016 - Sep lastSat 0:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta -Zone Asia/Hovd 6:06:36 - LMT 1905 Aug - 6:00 - +06 1978 - 7:00 Mongol +07/+08 -# Ulaanbaatar, a.k.a. Ulan Bataar, Ulan Bator, Urga -Zone Asia/Ulaanbaatar 7:07:32 - LMT 1905 Aug - 7:00 - +07 1978 - 8:00 Mongol +08/+09 -# Choibalsan, a.k.a. Bajan Tümen, Bajan Tumen, Chojbalsan, -# Choybalsan, Sanbejse, Tchoibalsan -Zone Asia/Choibalsan 7:38:00 - LMT 1905 Aug - 7:00 - +07 1978 - 8:00 - +08 1983 Apr - 9:00 Mongol +09/+10 2008 Mar 31 - 8:00 Mongol +08/+09 - -# Nepal -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kathmandu 5:41:16 - LMT 1920 - 5:30 - +0530 1986 - 5:45 - +0545 - -# Oman -# See Asia/Dubai. - -# Pakistan - -# From Rives McDow (2002-03-13): -# I have been advised that Pakistan has decided to adopt dst on a -# TRIAL basis for one year, starting 00:01 local time on April 7, 2002 -# and ending at 00:01 local time October 6, 2002. This is what I was -# told, but I believe that the actual time of change may be 00:00; the -# 00:01 was to make it clear which day it was on. - -# From Paul Eggert (2002-03-15): -# Jesper Nørgaard found this URL: -# http://www.pak.gov.pk/public/news/app/app06_dec.htm -# (dated 2001-12-06) which says that the Cabinet adopted a scheme "to -# advance the clocks by one hour on the night between the first -# Saturday and Sunday of April and revert to the original position on -# 15th October each year". This agrees with McDow's 04-07 at 00:00, -# but disagrees about the October transition, and makes it sound like -# it's not on a trial basis. Also, the "between the first Saturday -# and Sunday of April" phrase, if taken literally, means that the -# transition takes place at 00:00 on the first Sunday on or after 04-02. - -# From Paul Eggert (2003-02-09): -# DAWN <http://www.dawn.com/2002/10/06/top13.htm> reported on 2002-10-05 -# that 2002 DST ended that day at midnight. Go with McDow for now. - -# From Steffen Thorsen (2003-03-14): -# According to http://www.dawn.com/2003/03/07/top15.htm -# there will be no DST in Pakistan this year: -# -# ISLAMABAD, March 6: Information and Media Development Minister Sheikh -# Rashid Ahmed on Thursday said the cabinet had reversed a previous -# decision to advance clocks by one hour in summer and put them back by -# one hour in winter with the aim of saving light hours and energy. -# -# The minister told a news conference that the experiment had rather -# shown 8 per cent higher consumption of electricity. - -# From Alex Krivenyshev (2008-05-15): -# -# Here is an article that Pakistan plan to introduce Daylight Saving Time -# on June 1, 2008 for 3 months. -# -# "... The federal cabinet on Wednesday announced a new conservation plan to -# help reduce load shedding by approving the closure of commercial centres at -# 9pm and moving clocks forward by one hour for the next three months. ...." -# -# http://www.worldtimezone.com/dst_news/dst_news_pakistan01.html -# http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4 - -# From Arthur David Olson (2008-05-19): -# XXX--midnight transitions is a guess; 2008 only is a guess. - -# From Alexander Krivenyshev (2008-08-28): -# Pakistan government has decided to keep the watches one-hour advanced -# for another 2 months - plan to return to Standard Time on October 31 -# instead of August 31. -# -# http://www.worldtimezone.com/dst_news/dst_news_pakistan02.html -# http://dailymailnews.com/200808/28/news/dmbrn03.html - -# From Alexander Krivenyshev (2009-04-08): -# Based on previous media reports that "... proposed plan to -# advance clocks by one hour from May 1 will cause disturbance -# to the working schedules rather than bringing discipline in -# official working." -# http://www.thenews.com.pk/daily_detail.asp?id=171280 -# -# recent news that instead of May 2009 - Pakistan plan to -# introduce DST from April 15, 2009 -# -# FYI: Associated Press Of Pakistan -# April 08, 2009 -# Cabinet okays proposal to advance clocks by one hour from April 15 -# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=73043&Itemid=1 -# http://www.worldtimezone.com/dst_news/dst_news_pakistan05.html -# -# .... -# The Federal Cabinet on Wednesday approved the proposal to -# advance clocks in the country by one hour from April 15 to -# conserve energy" - -# From Steffen Thorsen (2009-09-17): -# "The News International," Pakistan reports that: "The Federal -# Government has decided to restore the previous time by moving the -# clocks backward by one hour from October 1. A formal announcement to -# this effect will be made after the Prime Minister grants approval in -# this regard." -# http://www.thenews.com.pk/updates.asp?id=87168 - -# From Alexander Krivenyshev (2009-09-28): -# According to Associated Press Of Pakistan, it is confirmed that -# Pakistan clocks across the country would be turned back by an hour from -# October 1, 2009. -# -# "Clocks to go back one hour from 1 Oct" -# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2 -# http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm -# -# From Steffen Thorsen (2009-09-29): -# Now they seem to have changed their mind, November 1 is the new date: -# http://www.thenews.com.pk/top_story_detail.asp?Id=24742 -# "The country's clocks will be reversed by one hour on November 1. -# Officials of Federal Ministry for Interior told this to Geo News on -# Monday." -# -# And more importantly, it seems that these dates will be kept every year: -# "It has now been decided that clocks will be wound forward by one hour -# on April 15 and reversed by an hour on November 1 every year without -# obtaining prior approval, the officials added." -# -# We have confirmed this year's end date with both with the Ministry of -# Water and Power and the Pakistan Electric Power Company: -# https://www.timeanddate.com/news/time/pakistan-ends-dst09.html - -# From Christoph Göhre (2009-10-01): -# [T]he German Consulate General in Karachi reported me today that Pakistan -# will go back to standard time on 1st of November. - -# From Steffen Thorsen (2010-03-26): -# Steffen Thorsen wrote: -# > On Thursday (2010-03-25) it was announced that DST would start in -# > Pakistan on 2010-04-01. -# > -# > Then today, the president said that they might have to revert the -# > decision if it is not supported by the parliament. So at the time -# > being, it seems unclear if DST will be actually observed or not - but -# > April 1 could be a more likely date than April 15. -# Now, it seems that the decision to not observe DST in final: -# -# "Govt Withdraws Plan To Advance Clocks" -# http://www.apakistannews.com/govt-withdraws-plan-to-advance-clocks-172041 -# -# "People laud PM's announcement to end DST" -# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=99374&Itemid=2 - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Pakistan 2002 only - Apr Sun>=2 0:00 1:00 S -Rule Pakistan 2002 only - Oct Sun>=2 0:00 0 - -Rule Pakistan 2008 only - Jun 1 0:00 1:00 S -Rule Pakistan 2008 2009 - Nov 1 0:00 0 - -Rule Pakistan 2009 only - Apr 15 0:00 1:00 S - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Karachi 4:28:12 - LMT 1907 - 5:30 - +0530 1942 Sep - 5:30 1:00 +0630 1945 Oct 15 - 5:30 - +0530 1951 Sep 30 - 5:00 - +05 1971 Mar 26 - 5:00 Pakistan PK%sT # Pakistan Time - -# Palestine - -# From Amos Shapir (1998-02-15): -# -# From 1917 until 1948-05-15, all of Palestine, including the parts now -# known as the Gaza Strip and the West Bank, was under British rule. -# Therefore the rules given for Israel for that period, apply there too... -# -# The Gaza Strip was under Egyptian rule between 1948-05-15 until 1967-06-05 -# (except a short occupation by Israel from 1956-11 till 1957-03, but no -# time zone was affected then). It was never formally annexed to Egypt, -# though. -# -# The rest of Palestine was under Jordanian rule at that time, formally -# annexed in 1950 as the West Bank (and the word "Trans" was dropped from -# the country's previous name of "the Hashemite Kingdom of the -# Trans-Jordan"). So the rules for Jordan for that time apply. Major -# towns in that area are Nablus (Shchem), El-Halil (Hebron), Ramallah, and -# East Jerusalem. -# -# Both areas were occupied by Israel in June 1967, but not annexed (except -# for East Jerusalem). They were on Israel time since then; there might -# have been a Military Governor's order about time zones, but I'm not aware -# of any (such orders may have been issued semi-annually whenever summer -# time was in effect, but maybe the legal aspect of time was just neglected). -# -# The Palestinian Authority was established in 1993, and got hold of most -# towns in the West Bank and Gaza by 1995. I know that in order to -# demonstrate...independence, they have been switching to -# summer time and back on a different schedule than Israel's, but I don't -# know when this was started, or what algorithm is used (most likely the -# Jordanian one). -# -# To summarize, the table should probably look something like that: -# -# Area \ when | 1918-1947 | 1948-1967 | 1967-1995 | 1996- -# ------------+-----------+-----------+-----------+----------- -# Israel | Zion | Zion | Zion | Zion -# West bank | Zion | Jordan | Zion | Jordan -# Gaza | Zion | Egypt | Zion | Jordan -# -# I guess more info may be available from the PA's web page (if/when they -# have one). - -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger write that Gaza did not observe DST until 1957, but go -# with Shapir and assume that it observed DST from 1940 through 1947, -# and that it used Jordanian rules starting in 1996. -# We don't yet need a separate entry for the West Bank, since -# the only differences between it and Gaza that we know about -# occurred before our cutoff date of 1970. -# However, as we get more information, we may need to add entries -# for parts of the West Bank as they transitioned from Israel's rules -# to Palestine's rules. - -# From IINS News Service - Israel - 1998-03-23 10:38:07 Israel time, -# forwarded by Ephraim Silverberg: -# -# Despite the fact that Israel changed over to daylight savings time -# last week, the PLO Authority (PA) has decided not to turn its clocks -# one-hour forward at this time. As a sign of independence from Israeli rule, -# the PA has decided to implement DST in April. - -# From Paul Eggert (1999-09-20): -# Daoud Kuttab writes in Holiday havoc -# http://www.jpost.com/com/Archive/22.Apr.1999/Opinion/Article-2.html -# (Jerusalem Post, 1999-04-22) that -# the Palestinian National Authority changed to DST on 1999-04-15. -# I vaguely recall that they switch back in October (sorry, forgot the source). -# For now, let's assume that the spring switch was at 24:00, -# and that they switch at 0:00 on the 3rd Fridays of April and October. - -# From Paul Eggert (2005-11-22): -# Starting 2004 transitions are from Steffen Thorsen's web site timeanddate.com. - -# From Steffen Thorsen (2005-11-23): -# A user from Gaza reported that Gaza made the change early because of -# the Ramadan. Next year Ramadan will be even earlier, so I think -# there is a good chance next year's end date will be around two weeks -# earlier - the same goes for Jordan. - -# From Steffen Thorsen (2006-08-17): -# I was informed by a user in Bethlehem that in Bethlehem it started the -# same day as Israel, and after checking with other users in the area, I -# was informed that they started DST one day after Israel. I was not -# able to find any authoritative sources at the time, nor details if -# Gaza changed as well, but presumed Gaza to follow the same rules as -# the West Bank. - -# From Steffen Thorsen (2006-09-26): -# according to the Palestine News Network (2006-09-19): -# http://english.pnn.ps/index.php?option=com_content&task=view&id=596&Itemid=5 -# > The Council of Ministers announced that this year its winter schedule -# > will begin early, as of midnight Thursday. It is also time to turn -# > back the clocks for winter. Friday will begin an hour late this week. -# I guess it is likely that next year's date will be moved as well, -# because of the Ramadan. - -# From Jesper Nørgaard Welen (2007-09-18): -# According to Steffen Thorsen's web site the Gaza Strip and the rest of the -# Palestinian territories left DST early on 13.th. of September at 2:00. - -# From Paul Eggert (2007-09-20): -# My understanding is that Gaza and the West Bank disagree even over when -# the weekend is (Thursday+Friday versus Friday+Saturday), so I'd be a bit -# surprised if they agreed about DST. But for now, assume they agree. -# For lack of better information, predict that future changes will be -# the 2nd Thursday of September at 02:00. - -# From Alexander Krivenyshev (2008-08-28): -# Here is an article, that Mideast running on different clocks at Ramadan. -# -# Gaza Strip (as Egypt) ended DST at midnight Thursday (Aug 28, 2008), while -# the West Bank will end Daylight Saving Time at midnight Sunday (Aug 31, 2008). -# -# http://www.guardian.co.uk/world/feedarticle/7759001 -# http://www.abcnews.go.com/International/wireStory?id=5676087 -# http://www.worldtimezone.com/dst_news/dst_news_gazastrip01.html - -# From Alexander Krivenyshev (2009-03-26): -# According to the Palestine News Network (arabic.pnn.ps), Palestinian -# government decided to start Daylight Time on Thursday night March -# 26 and continue until the night of 27 September 2009. -# -# (in Arabic) -# http://arabic.pnn.ps/index.php?option=com_content&task=view&id=50850 -# -# (English translation) -# http://www.worldtimezone.com/dst_news/dst_news_westbank01.html - -# From Steffen Thorsen (2009-08-31): -# Palestine's Council of Ministers announced that they will revert back to -# winter time on Friday, 2009-09-04. -# -# One news source: -# http://www.safa.ps/ara/?action=showdetail&seid=4158 -# (Palestinian press agency, Arabic), -# Google translate: "Decided that the Palestinian government in Ramallah -# headed by Salam Fayyad, the start of work in time for the winter of -# 2009, starting on Friday approved the fourth delay Sept. clock sixty -# minutes per hour as of Friday morning." -# -# We are not sure if Gaza will do the same, last year they had a different -# end date, we will keep this page updated: -# https://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html - -# From Alexander Krivenyshev (2009-09-02): -# Seems that Gaza Strip will go back to Winter Time same date as West Bank. -# -# According to Palestinian Ministry Of Interior, West Bank and Gaza Strip plan -# to change time back to Standard time on September 4, 2009. -# -# "Winter time unite the West Bank and Gaza" -# (from Palestinian National Authority): -# http://www.moi.gov.ps/en/?page=633167343250594025&nid=11505 -# http://www.worldtimezone.com/dst_news/dst_news_gazastrip02.html - -# From Alexander Krivenyshev (2010-03-19): -# According to Voice of Palestine DST will last for 191 days, from March -# 26, 2010 till "the last Sunday before the tenth day of Tishri -# (October), each year" (October 03, 2010?) -# -# http://palvoice.org/forums/showthread.php?t=245697 -# (in Arabic) -# http://www.worldtimezone.com/dst_news/dst_news_westbank03.html - -# From Steffen Thorsen (2010-03-24): -# ...Ma'an News Agency reports that Hamas cabinet has decided it will -# start one day later, at 12:01am. Not sure if they really mean 12:01am or -# noon though: -# -# http://www.maannews.net/eng/ViewDetails.aspx?ID=271178 -# (Ma'an News Agency) -# "At 12:01am Friday, clocks in Israel and the West Bank will change to -# 1:01am, while Gaza clocks will change at 12:01am Saturday morning." - -# From Steffen Thorsen (2010-08-11): -# According to several sources, including -# http://www.maannews.net/eng/ViewDetails.aspx?ID=306795 -# the clocks were set back one hour at 2010-08-11 00:00:00 local time in -# Gaza and the West Bank. -# Some more background info: -# https://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html - -# From Steffen Thorsen (2011-08-26): -# Gaza and the West Bank did go back to standard time in the beginning of -# August, and will now enter daylight saving time again on 2011-08-30 -# 00:00 (so two periods of DST in 2011). The pause was because of -# Ramadan. -# -# http://www.maannews.net/eng/ViewDetails.aspx?ID=416217 -# Additional info: -# https://www.timeanddate.com/news/time/palestine-dst-2011.html - -# From Alexander Krivenyshev (2011-08-27): -# According to the article in The Jerusalem Post: -# "...Earlier this month, the Palestinian government in the West Bank decided to -# move to standard time for 30 days, during Ramadan. The Palestinians in the -# Gaza Strip accepted the change and also moved their clocks one hour back. -# The Hamas government said on Saturday that it won't observe summertime after -# the Muslim feast of Id al-Fitr, which begins on Tuesday..." -# ... -# https://www.jpost.com/MiddleEast/Article.aspx?id=235650 -# http://www.worldtimezone.com/dst_news/dst_news_gazastrip05.html -# The rules for Egypt are stolen from the 'africa' file. - -# From Steffen Thorsen (2011-09-30): -# West Bank did end Daylight Saving Time this morning/midnight (2011-09-30 -# 00:00). -# So West Bank and Gaza now have the same time again. -# -# Many sources, including: -# http://www.maannews.net/eng/ViewDetails.aspx?ID=424808 - -# From Steffen Thorsen (2012-03-26): -# Palestinian news sources tell that both Gaza and West Bank will start DST -# on Friday (Thursday midnight, 2012-03-29 24:00). -# Some of many sources in Arabic: -# http://www.samanews.com/index.php?act=Show&id=122638 -# -# http://safa.ps/details/news/74352/%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-%D8%A8%D8%A7%D9%84%D8%B6%D9%81%D8%A9-%D9%88%D8%BA%D8%B2%D8%A9-%D9%84%D9%8A%D9%84%D8%A9-%D8%A7%D9%84%D8%AC%D9%85%D8%B9%D8%A9.html -# -# Our brief summary: -# https://www.timeanddate.com/news/time/gaza-west-bank-dst-2012.html - -# From Steffen Thorsen (2013-03-26): -# The following news sources tells that Palestine will "start daylight saving -# time from midnight on Friday, March 29, 2013" (translated). -# [These are in Arabic and are for Gaza and for Ramallah, respectively.] -# http://www.samanews.com/index.php?act=Show&id=154120 -# http://safa.ps/details/news/99844/%D8%B1%D8%A7%D9%85-%D8%A7%D9%84%D9%84%D9%87-%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-29-%D8%A7%D9%84%D8%AC%D8%A7%D8%B1%D9%8A.html - -# From Steffen Thorsen (2013-09-24): -# The Gaza and West Bank are ending DST Thursday at midnight -# (2013-09-27 00:00:00) (one hour earlier than last year...). -# This source in English, says "that winter time will go into effect -# at midnight on Thursday in the West Bank and Gaza Strip": -# http://english.wafa.ps/index.php?action=detail&id=23246 -# official source...: -# http://www.palestinecabinet.gov.ps/ar/Views/ViewDetails.aspx?pid=1252 - -# From Steffen Thorsen (2015-03-03): -# Sources such as http://www.alquds.com/news/article/view/id/548257 -# and https://www.raya.ps/ar/news/890705.html say Palestine areas will -# start DST on 2015-03-28 00:00 which is one day later than expected. -# -# From Paul Eggert (2015-03-03): -# https://www.timeanddate.com/time/change/west-bank/ramallah?year=2014 -# says that the fall 2014 transition was Oct 23 at 24:00. - -# From Hannah Kreitem (2016-03-09): -# http://www.palestinecabinet.gov.ps/WebSite/ar/ViewDetails?ID=31728 -# [Google translation]: "The Council also decided to start daylight -# saving in Palestine as of one o'clock on Saturday morning, -# 2016-03-26, to provide the clock 60 minutes ahead." - -# From Sharef Mustafa (2016-10-19): -# [T]he Palestinian cabinet decision (Mar 8th 2016) published on -# http://www.palestinecabinet.gov.ps/WebSite/Upload/Decree/GOV_17/16032016134830.pdf -# states that summer time will end on Oct 29th at 01:00. -# -# From Tim Parenti (2016-10-19): -# Predict fall transitions on October's last Saturday at 01:00 from now on. -# This is consistent with the 2016 transition as well as our spring -# predictions. -# -# From Paul Eggert (2016-10-19): -# It's also consistent with predictions in the following URLs today: -# https://www.timeanddate.com/time/change/gaza-strip/gaza -# https://www.timeanddate.com/time/change/west-bank/hebron - -# From Sharef Mustafa (2018-03-16): -# Palestine summer time will start on Mar 24th 2018 by advancing the -# clock by 60 minutes as per Palestinian cabinet decision published on -# the official website, though the decree did not specify the exact -# time of the time shift. -# http://www.palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e7a42ab7-ee23-435a-b9c8-a4f7e81f3817 -# -# From Paul Eggert (2018-03-16): -# For 2016 on, predict spring transitions on March's fourth Saturday at 01:00. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule EgyptAsia 1957 only - May 10 0:00 1:00 S -Rule EgyptAsia 1957 1958 - Oct 1 0:00 0 - -Rule EgyptAsia 1958 only - May 1 0:00 1:00 S -Rule EgyptAsia 1959 1967 - May 1 1:00 1:00 S -Rule EgyptAsia 1959 1965 - Sep 30 3:00 0 - -Rule EgyptAsia 1966 only - Oct 1 3:00 0 - - -Rule Palestine 1999 2005 - Apr Fri>=15 0:00 1:00 S -Rule Palestine 1999 2003 - Oct Fri>=15 0:00 0 - -Rule Palestine 2004 only - Oct 1 1:00 0 - -Rule Palestine 2005 only - Oct 4 2:00 0 - -Rule Palestine 2006 2007 - Apr 1 0:00 1:00 S -Rule Palestine 2006 only - Sep 22 0:00 0 - -Rule Palestine 2007 only - Sep Thu>=8 2:00 0 - -Rule Palestine 2008 2009 - Mar lastFri 0:00 1:00 S -Rule Palestine 2008 only - Sep 1 0:00 0 - -Rule Palestine 2009 only - Sep Fri>=1 1:00 0 - -Rule Palestine 2010 only - Mar 26 0:00 1:00 S -Rule Palestine 2010 only - Aug 11 0:00 0 - -Rule Palestine 2011 only - Apr 1 0:01 1:00 S -Rule Palestine 2011 only - Aug 1 0:00 0 - -Rule Palestine 2011 only - Aug 30 0:00 1:00 S -Rule Palestine 2011 only - Sep 30 0:00 0 - -Rule Palestine 2012 2014 - Mar lastThu 24:00 1:00 S -Rule Palestine 2012 only - Sep 21 1:00 0 - -Rule Palestine 2013 only - Sep Fri>=21 0:00 0 - -Rule Palestine 2014 2015 - Oct Fri>=21 0:00 0 - -Rule Palestine 2015 only - Mar lastFri 24:00 1:00 S -Rule Palestine 2016 max - Mar Sat>=22 1:00 1:00 S -Rule Palestine 2016 max - Oct lastSat 1:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Gaza 2:17:52 - LMT 1900 Oct - 2:00 Zion EET/EEST 1948 May 15 - 2:00 EgyptAsia EE%sT 1967 Jun 5 - 2:00 Zion I%sT 1996 - 2:00 Jordan EE%sT 1999 - 2:00 Palestine EE%sT 2008 Aug 29 0:00 - 2:00 - EET 2008 Sep - 2:00 Palestine EE%sT 2010 - 2:00 - EET 2010 Mar 27 0:01 - 2:00 Palestine EE%sT 2011 Aug 1 - 2:00 - EET 2012 - 2:00 Palestine EE%sT - -Zone Asia/Hebron 2:20:23 - LMT 1900 Oct - 2:00 Zion EET/EEST 1948 May 15 - 2:00 EgyptAsia EE%sT 1967 Jun 5 - 2:00 Zion I%sT 1996 - 2:00 Jordan EE%sT 1999 - 2:00 Palestine EE%sT - -# Paracel Is -# no information - -# Philippines -# On 1844-08-16, Narciso Clavería, governor-general of the -# Philippines, issued a proclamation announcing that 1844-12-30 was to -# be immediately followed by 1845-01-01; see R.H. van Gent's -# History of the International Date Line -# https://www.staff.science.uu.nl/~gent0113/idl/idl_philippines.htm -# The rest of the data entries are from Shanks & Pottenger. - -# From Jesper Nørgaard Welen (2006-04-26): -# ... claims that Philippines had DST last time in 1990: -# http://story.philippinetimes.com/p.x/ct/9/id/145be20cc6b121c0/cid/3e5bbccc730d258c/ -# [a story dated 2006-04-25 by Cris Larano of Dow Jones Newswires, -# but no details] - -# From Paul Eggert (2014-08-14): -# The following source says DST may be instituted November-January and again -# March-June, but this is not definite. It also says DST was last proclaimed -# during the Ramos administration (1992-1998); but again, no details. -# Carcamo D. PNoy urged to declare use of daylight saving time. -# Philippine Star 2014-08-05 -# http://www.philstar.com/headlines/2014/08/05/1354152/pnoy-urged-declare-use-daylight-saving-time - -# From Paul Goyette (2018-06-15): -# In the Philippines, there is a national law, Republic Act No. 10535 -# which declares the official time here as "Philippine Standard Time". -# The act [1] even specifies use of PST as the abbreviation, although -# the FAQ provided by PAGASA [2] uses the "acronym PhST to distinguish -# it from the Pacific Standard Time (PST)." -# [1] http://www.officialgazette.gov.ph/2013/05/15/republic-act-no-10535/ -# [2] https://www1.pagasa.dost.gov.ph/index.php/astronomy/philippine-standard-time#republic-act-10535 -# -# From Paul Eggert (2018-06-19): -# I surveyed recent news reports, and my impression is that "PST" is -# more popular among reliable English-language news sources. This is -# not just a measure of Google hit counts: it's also the sizes and -# influence of the sources. There is no current abbreviation for DST, -# so use "PDT", the usual American style. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Phil 1936 only - Nov 1 0:00 1:00 D -Rule Phil 1937 only - Feb 1 0:00 0 S -Rule Phil 1954 only - Apr 12 0:00 1:00 D -Rule Phil 1954 only - Jul 1 0:00 0 S -Rule Phil 1978 only - Mar 22 0:00 1:00 D -Rule Phil 1978 only - Sep 21 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Manila -15:56:00 - LMT 1844 Dec 31 - 8:04:00 - LMT 1899 May 11 - 8:00 Phil P%sT 1942 May - 9:00 - JST 1944 Nov - 8:00 Phil P%sT - -# Qatar -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha - 4:00 - +04 1972 Jun - 3:00 - +03 -Link Asia/Qatar Asia/Bahrain - -# Saudi Arabia -# -# From Paul Eggert (2018-08-29): -# Time in Saudi Arabia and other countries in the Arabian peninsula was not -# standardized until 1968 or so; we don't know exactly when, and possibly it -# has never been made official. Richard P Hunt, in "Islam city yielding to -# modern times", New York Times (1961-04-09), p 20, wrote that only airlines -# observed standard time, and that people in Jeddah mostly observed quasi-solar -# time, doing so by setting their watches at sunrise to 6 o'clock (or to 12 -# o'clock for "Arab" time). -# -# Timekeeping differed depending on who you were and which part of Saudi -# Arabia you were in. In 1969, Elias Antar wrote that although a common -# practice had been to set one's watch to 12:00 (i.e., midnight) at sunset - -# which meant that the time on one side of a mountain could differ greatly from -# the time on the other side - many foreigners set their watches to 6pm -# instead, while airlines instead used UTC +03 (except in Dhahran, where they -# used UTC +04), Aramco used UTC +03 with DST, and the Trans-Arabian Pipe Line -# Company used Aramco time in eastern Saudi Arabia and airline time in western. -# (The American Military Aid Advisory Group used plain UTC.) Antar writes, -# "A man named Higgins, so the story goes, used to run a local power -# station. One day, the whole thing became too much for Higgins and he -# assembled his staff and laid down the law. 'I've had enough of this,' he -# shrieked. 'It is now 12 o'clock Higgins Time, and from now on this station is -# going to run on Higgins Time.' And so, until last year, it did." See: -# Antar E. Dinner at When? Saudi Aramco World, 1969 March/April. 2-3. -# http://archive.aramcoworld.com/issue/196902/dinner.at.when.htm -# newspapers.com says a similar story about Higgins was published in the Port -# Angeles (WA) Evening News, 1965-03-10, page 5, but I lack access to the text. -# -# The TZ database cannot represent quasi-solar time; airline time is the best -# we can do. The 1946 foreign air news digest of the U.S. Civil Aeronautics -# Board (OCLC 42299995) reported that the "... Arabian Government, inaugurated -# a weekly Dhahran-Cairo service, via the Saudi Arabian cities of Riyadh and -# Jidda, on March 14, 1947". Shanks & Pottenger guessed 1950; go with the -# earlier date. -# -# Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two -# time zones; the other zone, at UT +04, was in the far eastern part of -# the country. Presumably this is documenting airline time. Ignore this, -# as it's before our 1970 cutoff. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14 - 3:00 - +03 -Link Asia/Riyadh Asia/Aden # Yemen -Link Asia/Riyadh Asia/Kuwait - -# Singapore -# taken from Mok Ly Yng (2003-10-30) -# http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Singapore 6:55:25 - LMT 1901 Jan 1 - 6:55:25 - SMT 1905 Jun 1 # Singapore M.T. - 7:00 - +07 1933 Jan 1 - 7:00 0:20 +0720 1936 Jan 1 - 7:20 - +0720 1941 Sep 1 - 7:30 - +0730 1942 Feb 16 - 9:00 - +09 1945 Sep 12 - 7:30 - +0730 1982 Jan 1 - 8:00 - +08 - -# Spratly Is -# no information - -# Sri Lanka - -# From Paul Eggert (2013-02-21): -# Milne says "Madras mean time use from May 1, 1898. Prior to this Colombo -# mean time, 5h. 4m. 21.9s. F., was used." But 5:04:21.9 differs considerably -# from Colombo's meridian 5:19:24, so for now ignore Milne and stick with -# Shanks and Pottenger. - -# From Paul Eggert (1996-09-03): -# "Sri Lanka advances clock by an hour to avoid blackout" -# (<http://www.virtual-pc.com/lankaweb/news/items/240596-2.html>, 1996-05-24, -# no longer available as of 1999-08-17) -# reported "the country's standard time will be put forward by one hour at -# midnight Friday (1830 GMT) 'in the light of the present power crisis'." -# -# From Dharmasiri Senanayake, Sri Lanka Media Minister (1996-10-24), as quoted -# by Shamindra in Daily News - Hot News Section -# <news:54rka5$m5h@mtinsc01-mgt.ops.worldnet.att.net> (1996-10-26): -# With effect from 12.30 a.m. on 26th October 1996 -# Sri Lanka will be six (06) hours ahead of GMT. - -# From Jesper Nørgaard Welen (2006-04-14), quoting Sri Lanka News Online -# <http://news.sinhalaya.com/wmview.php?ArtID=11002> (2006-04-13): -# 0030 hrs on April 15, 2006 (midnight of April 14, 2006 +30 minutes) -# at present, become 2400 hours of April 14, 2006 (midnight of April 14, 2006). - -# From Peter Apps and Ranga Sirila of Reuters (2006-04-12) in: -# http://today.reuters.co.uk/news/newsArticle.aspx?type=scienceNews&storyID=2006-04-12T172228Z_01_COL295762_RTRIDST_0_SCIENCE-SRILANKA-TIME-DC.XML -# [The Tamil Tigers] never accepted the original 1996 time change and simply -# kept their clocks set five and a half hours ahead of Greenwich Mean -# Time (GMT), in line with neighbor India. -# From Paul Eggert (2006-04-18): -# People who live in regions under Tamil control can use [TZ='Asia/Kolkata'], -# as that zone has agreed with the Tamil areas since our cutoff date of 1970. - -# From Sadika Sumanapala (2016-10-19): -# According to http://www.sltime.org (maintained by Measurement Units, -# Standards & Services Department, Sri Lanka) abbreviation for Sri Lanka -# standard time is SLST. -# -# From Paul Eggert (2016-10-18): -# "SLST" seems to be reasonably recent and rarely-used outside time -# zone nerd sources. I searched Google News and found three uses of -# it in the International Business Times of India in February and -# March of this year when discussing cricket match times, but nothing -# since then (though there has been a lot of cricket) and nothing in -# other English-language news sources. Our old abbreviation "LKT" is -# even worse. For now, let's use a numeric abbreviation; we can -# switch to "SLST" if it catches on. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Colombo 5:19:24 - LMT 1880 - 5:19:32 - MMT 1906 # Moratuwa Mean Time - 5:30 - +0530 1942 Jan 5 - 5:30 0:30 +06 1942 Sep - 5:30 1:00 +0630 1945 Oct 16 2:00 - 5:30 - +0530 1996 May 25 0:00 - 6:30 - +0630 1996 Oct 26 0:30 - 6:00 - +06 2006 Apr 15 0:30 - 5:30 - +0530 - -# Syria -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Syria 1920 1923 - Apr Sun>=15 2:00 1:00 S -Rule Syria 1920 1923 - Oct Sun>=1 2:00 0 - -Rule Syria 1962 only - Apr 29 2:00 1:00 S -Rule Syria 1962 only - Oct 1 2:00 0 - -Rule Syria 1963 1965 - May 1 2:00 1:00 S -Rule Syria 1963 only - Sep 30 2:00 0 - -Rule Syria 1964 only - Oct 1 2:00 0 - -Rule Syria 1965 only - Sep 30 2:00 0 - -Rule Syria 1966 only - Apr 24 2:00 1:00 S -Rule Syria 1966 1976 - Oct 1 2:00 0 - -Rule Syria 1967 1978 - May 1 2:00 1:00 S -Rule Syria 1977 1978 - Sep 1 2:00 0 - -Rule Syria 1983 1984 - Apr 9 2:00 1:00 S -Rule Syria 1983 1984 - Oct 1 2:00 0 - -Rule Syria 1986 only - Feb 16 2:00 1:00 S -Rule Syria 1986 only - Oct 9 2:00 0 - -Rule Syria 1987 only - Mar 1 2:00 1:00 S -Rule Syria 1987 1988 - Oct 31 2:00 0 - -Rule Syria 1988 only - Mar 15 2:00 1:00 S -Rule Syria 1989 only - Mar 31 2:00 1:00 S -Rule Syria 1989 only - Oct 1 2:00 0 - -Rule Syria 1990 only - Apr 1 2:00 1:00 S -Rule Syria 1990 only - Sep 30 2:00 0 - -Rule Syria 1991 only - Apr 1 0:00 1:00 S -Rule Syria 1991 1992 - Oct 1 0:00 0 - -Rule Syria 1992 only - Apr 8 0:00 1:00 S -Rule Syria 1993 only - Mar 26 0:00 1:00 S -Rule Syria 1993 only - Sep 25 0:00 0 - -# IATA SSIM (1998-02) says 1998-04-02; -# (1998-09) says 1999-03-29 and 1999-09-29; (1999-02) says 1999-04-02, -# 2000-04-02, and 2001-04-02; (1999-09) says 2000-03-31 and 2001-03-31; -# (2006) says 2006-03-31 and 2006-09-22; -# for now ignore all these claims and go with Shanks & Pottenger, -# except for the 2006-09-22 claim (which seems right for Ramadan). -Rule Syria 1994 1996 - Apr 1 0:00 1:00 S -Rule Syria 1994 2005 - Oct 1 0:00 0 - -Rule Syria 1997 1998 - Mar lastMon 0:00 1:00 S -Rule Syria 1999 2006 - Apr 1 0:00 1:00 S -# From Stephen Colebourne (2006-09-18): -# According to IATA data, Syria will change DST on 21st September [21:00 UTC] -# this year [only].... This is probably related to Ramadan, like Egypt. -Rule Syria 2006 only - Sep 22 0:00 0 - -# From Paul Eggert (2007-03-29): -# Today the AP reported "Syria will switch to summertime at midnight Thursday." -# http://www.iht.com/articles/ap/2007/03/29/africa/ME-GEN-Syria-Time-Change.php -Rule Syria 2007 only - Mar lastFri 0:00 1:00 S -# From Jesper Nørgaard (2007-10-27): -# The sister center ICARDA of my work CIMMYT is confirming that Syria DST will -# not take place 1st November at 0:00 o'clock but 1st November at 24:00 or -# rather Midnight between Thursday and Friday. This does make more sense than -# having it between Wednesday and Thursday (two workdays in Syria) since the -# weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now -# it is implemented at midnight of the last workday before weekend... -# -# From Steffen Thorsen (2007-10-27): -# Jesper Nørgaard Welen wrote: -# -# > "Winter local time in Syria will be observed at midnight of Thursday 1 -# > November 2007, and the clock will be put back 1 hour." -# -# I found confirmation on this in this gov.sy-article (Arabic): -# http://wehda.alwehda.gov.sy/_print_veiw.asp?FileName=12521710520070926111247 -# -# which using Google's translate tools says: -# Council of Ministers also approved the commencement of work on -# identifying the winter time as of Friday, 2/11/2007 where the 60th -# minute delay at midnight Thursday 1/11/2007. -Rule Syria 2007 only - Nov Fri>=1 0:00 0 - - -# From Stephen Colebourne (2008-03-17): -# For everyone's info, I saw an IATA time zone change for [Syria] for -# this month (March 2008) in the last day or so.... -# Country Time Standard --- DST Start --- --- DST End --- DST -# Name Zone Variation Time Date Time Date -# Variation -# Syrian Arab -# Republic SY +0200 2200 03APR08 2100 30SEP08 +0300 -# 2200 02APR09 2100 30SEP09 +0300 -# 2200 01APR10 2100 30SEP10 +0300 - -# From Arthur David Olson (2008-03-17): -# Here's a link to English-language coverage by the Syrian Arab News -# Agency (SANA)... -# http://www.sana.sy/eng/21/2008/03/11/165173.htm -# ...which reads (in part) "The Cabinet approved the suggestion of the -# Ministry of Electricity to begin daylight savings time on Friday April -# 4th, advancing clocks one hour ahead on midnight of Thursday April 3rd." -# Since Syria is two hours east of UTC, the 2200 and 2100 transition times -# shown above match up with midnight in Syria. - -# From Arthur David Olson (2008-03-18): -# My best guess at a Syrian rule is "the Friday nearest April 1"; -# coding that involves either using a "Mar Fri>=29" construct that old time zone -# compilers can't handle or having multiple Rules (a la Israel). -# For now, use "Apr Fri>=1", and go with IATA on a uniform Sep 30 end. - -# From Steffen Thorsen (2008-10-07): -# Syria has now officially decided to end DST on 2008-11-01 this year, -# according to the following article in the Syrian Arab News Agency (SANA). -# -# The article is in Arabic, and seems to tell that they will go back to -# winter time on 2008-11-01 at 00:00 local daylight time (delaying/setting -# clocks back 60 minutes). -# -# http://sana.sy/ara/2/2008/10/07/195459.htm - -# From Steffen Thorsen (2009-03-19): -# Syria will start DST on 2009-03-27 00:00 this year according to many sources, -# two examples: -# -# http://www.sana.sy/eng/21/2009/03/17/217563.htm -# (English, Syrian Arab News # Agency) -# http://thawra.alwehda.gov.sy/_View_news2.asp?FileName=94459258720090318012209 -# (Arabic, gov-site) -# -# We have not found any sources saying anything about when DST ends this year. -# -# Our summary -# https://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html - -# From Steffen Thorsen (2009-10-27): -# The Syrian Arab News Network on 2009-09-29 reported that Syria will -# revert back to winter (standard) time on midnight between Thursday -# 2009-10-29 and Friday 2009-10-30: -# http://www.sana.sy/ara/2/2009/09/29/247012.htm (Arabic) - -# From Arthur David Olson (2009-10-28): -# We'll see if future DST switching times turn out to be end of the last -# Thursday of the month or the start of the last Friday of the month or -# something else. For now, use the start of the last Friday. - -# From Steffen Thorsen (2010-03-17): -# The "Syrian News Station" reported on 2010-03-16 that the Council of -# Ministers has decided that Syria will start DST on midnight Thursday -# 2010-04-01: (midnight between Thursday and Friday): -# http://sns.sy/sns/?path=news/read/11421 (Arabic) - -# From Steffen Thorsen (2012-03-26): -# Today, Syria's government announced that they will start DST early on Friday -# (00:00). This is a bit earlier than the past two years. -# -# From Syrian Arab News Agency, in Arabic: -# http://www.sana.sy/ara/2/2012/03/26/408215.htm -# -# Our brief summary: -# https://www.timeanddate.com/news/time/syria-dst-2012.html - -# From Arthur David Olson (2012-03-27): -# Assume last Friday in March going forward XXX. - -Rule Syria 2008 only - Apr Fri>=1 0:00 1:00 S -Rule Syria 2008 only - Nov 1 0:00 0 - -Rule Syria 2009 only - Mar lastFri 0:00 1:00 S -Rule Syria 2010 2011 - Apr Fri>=1 0:00 1:00 S -Rule Syria 2012 max - Mar lastFri 0:00 1:00 S -Rule Syria 2009 max - Oct lastFri 0:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Damascus 2:25:12 - LMT 1920 # Dimashq - 2:00 Syria EE%sT - -# Tajikistan -# From Shanks & Pottenger. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 - 5:00 - +05 1930 Jun 21 - 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s - 5:00 1:00 +05/+06 1991 Sep 9 2:00s - 5:00 - +05 - -# Thailand -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Bangkok 6:42:04 - LMT 1880 - 6:42:04 - BMT 1920 Apr # Bangkok Mean Time - 7:00 - +07 -Link Asia/Bangkok Asia/Phnom_Penh # Cambodia -Link Asia/Bangkok Asia/Vientiane # Laos - -# Turkmenistan -# From Shanks & Pottenger. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad - 4:00 - +04 1930 Jun 21 - 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00 - 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00 - 5:00 - +05 - -# United Arab Emirates -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Dubai 3:41:12 - LMT 1920 - 4:00 - +04 -Link Asia/Dubai Asia/Muscat # Oman - -# Uzbekistan -# Byalokoz 1919 says Uzbekistan was 4:27:53. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Samarkand 4:27:53 - LMT 1924 May 2 - 4:00 - +04 1930 Jun 21 - 5:00 - +05 1981 Apr 1 - 5:00 1:00 +06 1981 Oct 1 - 6:00 - +06 1982 Apr 1 - 5:00 RussiaAsia +05/+06 1992 - 5:00 - +05 -# Milne says Tashkent was 4:37:10.8; round to nearest. -Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 - 5:00 - +05 1930 Jun 21 - 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00 - 5:00 RussiaAsia +05/+06 1992 - 5:00 - +05 - -# Vietnam - -# From Paul Eggert (2014-10-04): -# Milne gives 7:16:56 for the meridian of Saigon in 1899, as being -# used in Lower Laos, Cambodia, and Annam. But this is quite a ways -# from Saigon's location. For now, ignore this and stick with Shanks -# and Pottenger for LMT before 1906. - -# From Arthur David Olson (2008-03-18): -# The English-language name of Vietnam's most populous city is "Ho Chi Minh -# City"; use Ho_Chi_Minh below to avoid a name of more than 14 characters. - -# From Paul Eggert (2014-10-21) after a heads-up from Trần Ngọc Quân: -# Trần Tiến Bình's authoritative book "Lịch Việt Nam: thế kỷ XX-XXI (1901-2100)" -# (Nhà xuất bản Văn Hoá - Thông Tin, Hanoi, 2005), pp 49-50, -# is quoted verbatim in: -# http://www.thoigian.com.vn/?mPage=P80D01 -# is translated by Brian Inglis in: -# https://mm.icann.org/pipermail/tz/2014-October/021654.html -# and is the basis for the information below. -# -# The 1906 transition was effective July 1 and standardized Indochina to -# Phù Liễn Observatory, legally 104° 17' 17" east of Paris. -# It's unclear whether this meant legal Paris Mean Time (00:09:21) or -# the Paris Meridian (2° 20' 14.03" E); the former yields 07:06:30.1333... -# and the latter 07:06:29.333... so either way it rounds to 07:06:30, -# which is used below even though the modern-day Phù Liễn Observatory -# is closer to 07:06:31. Abbreviate Phù Liễn Mean Time as PLMT. -# -# The following transitions occurred in Indochina in general (before 1954) -# and in South Vietnam in particular (after 1954): -# To 07:00 on 1911-05-01. -# To 08:00 on 1942-12-31 at 23:00. -# To 09:00 in 1945-03-14 at 23:00. -# To 07:00 on 1945-09-02 in Vietnam. -# To 08:00 on 1947-04-01 in French-controlled Indochina. -# To 07:00 on 1955-07-01 in South Vietnam. -# To 08:00 on 1959-12-31 at 23:00 in South Vietnam. -# To 07:00 on 1975-06-13 in South Vietnam. -# -# Trần cites the following sources; it's unclear which supplied the info above. -# -# Hoàng Xuân Hãn: "Lịch và lịch Việt Nam". Tập san Khoa học Xã hội, -# No. 9, Paris, February 1982. -# -# Lê Thành Lân: "Lịch và niên biểu lịch sử hai mươi thế kỷ (0001-2010)", -# NXB Thống kê, Hanoi, 2000. -# -# Lê Thành Lân: "Lịch hai thế kỷ (1802-2010) và các lịch vĩnh cửu", -# NXB Thuận Hoá, Huế, 1995. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 - 7:06:30 - PLMT 1911 May 1 # Phù Liễn MT - 7:00 - +07 1942 Dec 31 23:00 - 8:00 - +08 1945 Mar 14 23:00 - 9:00 - +09 1945 Sep 2 - 7:00 - +07 1947 Apr 1 - 8:00 - +08 1955 Jul 1 - 7:00 - +07 1959 Dec 31 23:00 - 8:00 - +08 1975 Jun 13 - 7:00 - +07 - -# Yemen -# See Asia/Riyadh. diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/australasia b/src/test/jdk/sun/util/calendar/zi/tzdata/australasia deleted file mode 100644 index 82e88c51e91..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/australasia +++ /dev/null @@ -1,1848 +0,0 @@ -# -# 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. -# -# tzdb data for Australasia and environs, and for much of the Pacific - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# This file also includes Pacific islands. - -# Notes are at the end of this file - -############################################################################### - -# Australia - -# Please see the notes below for the controversy about "EST" versus "AEST" etc. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Aus 1917 only - Jan 1 0:01 1:00 D -Rule Aus 1917 only - Mar 25 2:00 0 S -Rule Aus 1942 only - Jan 1 2:00 1:00 D -Rule Aus 1942 only - Mar 29 2:00 0 S -Rule Aus 1942 only - Sep 27 2:00 1:00 D -Rule Aus 1943 1944 - Mar lastSun 2:00 0 S -Rule Aus 1943 only - Oct 3 2:00 1:00 D -# Go with Whitman and the Australian National Standards Commission, which -# says W Australia didn't use DST in 1943/1944. Ignore Whitman's claim that -# 1944/1945 was just like 1943/1944. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# Northern Territory -Zone Australia/Darwin 8:43:20 - LMT 1895 Feb - 9:00 - ACST 1899 May - 9:30 Aus AC%sT -# Western Australia -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule AW 1974 only - Oct lastSun 2:00s 1:00 D -Rule AW 1975 only - Mar Sun>=1 2:00s 0 S -Rule AW 1983 only - Oct lastSun 2:00s 1:00 D -Rule AW 1984 only - Mar Sun>=1 2:00s 0 S -Rule AW 1991 only - Nov 17 2:00s 1:00 D -Rule AW 1992 only - Mar Sun>=1 2:00s 0 S -Rule AW 2006 only - Dec 3 2:00s 1:00 D -Rule AW 2007 2009 - Mar lastSun 2:00s 0 S -Rule AW 2007 2008 - Oct lastSun 2:00s 1:00 D -Zone Australia/Perth 7:43:24 - LMT 1895 Dec - 8:00 Aus AW%sT 1943 Jul - 8:00 AW AW%sT -Zone Australia/Eucla 8:35:28 - LMT 1895 Dec - 8:45 Aus +0845/+0945 1943 Jul - 8:45 AW +0845/+0945 - -# Queensland -# -# From Alex Livingston (1996-11-01): -# I have heard or read more than once that some resort islands off the coast -# of Queensland chose to keep observing daylight-saving time even after -# Queensland ceased to. -# -# From Paul Eggert (1996-11-22): -# IATA SSIM (1993-02/1994-09) say that the Holiday Islands (Hayman, Lindeman, -# Hamilton) observed DST for two years after the rest of Queensland stopped. -# Hamilton is the largest, but there is also a Hamilton in Victoria, -# so use Lindeman. -# -# From J William Piggott (2016-02-20): -# There is no location named Holiday Islands in Queensland Australia; holiday -# islands is a colloquial term used globally. Hayman and Lindeman are at the -# north and south extremes of the Whitsunday Islands archipelago, and -# Hamilton is in between; it is reasonable to believe that this time zone -# applies to all of the Whitsundays. -# http://www.australia.gov.au/about-australia/australian-story/austn-islands -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule AQ 1971 only - Oct lastSun 2:00s 1:00 D -Rule AQ 1972 only - Feb lastSun 2:00s 0 S -Rule AQ 1989 1991 - Oct lastSun 2:00s 1:00 D -Rule AQ 1990 1992 - Mar Sun>=1 2:00s 0 S -Rule Holiday 1992 1993 - Oct lastSun 2:00s 1:00 D -Rule Holiday 1993 1994 - Mar Sun>=1 2:00s 0 S -Zone Australia/Brisbane 10:12:08 - LMT 1895 - 10:00 Aus AE%sT 1971 - 10:00 AQ AE%sT -Zone Australia/Lindeman 9:55:56 - LMT 1895 - 10:00 Aus AE%sT 1971 - 10:00 AQ AE%sT 1992 Jul - 10:00 Holiday AE%sT - -# South Australia -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule AS 1971 1985 - Oct lastSun 2:00s 1:00 D -Rule AS 1986 only - Oct 19 2:00s 1:00 D -Rule AS 1987 2007 - Oct lastSun 2:00s 1:00 D -Rule AS 1972 only - Feb 27 2:00s 0 S -Rule AS 1973 1985 - Mar Sun>=1 2:00s 0 S -Rule AS 1986 1990 - Mar Sun>=15 2:00s 0 S -Rule AS 1991 only - Mar 3 2:00s 0 S -Rule AS 1992 only - Mar 22 2:00s 0 S -Rule AS 1993 only - Mar 7 2:00s 0 S -Rule AS 1994 only - Mar 20 2:00s 0 S -Rule AS 1995 2005 - Mar lastSun 2:00s 0 S -Rule AS 2006 only - Apr 2 2:00s 0 S -Rule AS 2007 only - Mar lastSun 2:00s 0 S -Rule AS 2008 max - Apr Sun>=1 2:00s 0 S -Rule AS 2008 max - Oct Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Australia/Adelaide 9:14:20 - LMT 1895 Feb - 9:00 - ACST 1899 May - 9:30 Aus AC%sT 1971 - 9:30 AS AC%sT - -# Tasmania -# -# From Paul Eggert (2005-08-16): -# http://www.bom.gov.au/climate/averages/tables/dst_times.shtml -# says King Island didn't observe DST from WWII until late 1971. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule AT 1967 only - Oct Sun>=1 2:00s 1:00 D -Rule AT 1968 only - Mar lastSun 2:00s 0 S -Rule AT 1968 1985 - Oct lastSun 2:00s 1:00 D -Rule AT 1969 1971 - Mar Sun>=8 2:00s 0 S -Rule AT 1972 only - Feb lastSun 2:00s 0 S -Rule AT 1973 1981 - Mar Sun>=1 2:00s 0 S -Rule AT 1982 1983 - Mar lastSun 2:00s 0 S -Rule AT 1984 1986 - Mar Sun>=1 2:00s 0 S -Rule AT 1986 only - Oct Sun>=15 2:00s 1:00 D -Rule AT 1987 1990 - Mar Sun>=15 2:00s 0 S -Rule AT 1987 only - Oct Sun>=22 2:00s 1:00 D -Rule AT 1988 1990 - Oct lastSun 2:00s 1:00 D -Rule AT 1991 1999 - Oct Sun>=1 2:00s 1:00 D -Rule AT 1991 2005 - Mar lastSun 2:00s 0 S -Rule AT 2000 only - Aug lastSun 2:00s 1:00 D -Rule AT 2001 max - Oct Sun>=1 2:00s 1:00 D -Rule AT 2006 only - Apr Sun>=1 2:00s 0 S -Rule AT 2007 only - Mar lastSun 2:00s 0 S -Rule AT 2008 max - Apr Sun>=1 2:00s 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Australia/Hobart 9:49:16 - LMT 1895 Sep - 10:00 - AEST 1916 Oct 1 2:00 - 10:00 1:00 AEDT 1917 Feb - 10:00 Aus AE%sT 1967 - 10:00 AT AE%sT -Zone Australia/Currie 9:35:28 - LMT 1895 Sep - 10:00 - AEST 1916 Oct 1 2:00 - 10:00 1:00 AEDT 1917 Feb - 10:00 Aus AE%sT 1971 Jul - 10:00 AT AE%sT - -# Victoria -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule AV 1971 1985 - Oct lastSun 2:00s 1:00 D -Rule AV 1972 only - Feb lastSun 2:00s 0 S -Rule AV 1973 1985 - Mar Sun>=1 2:00s 0 S -Rule AV 1986 1990 - Mar Sun>=15 2:00s 0 S -Rule AV 1986 1987 - Oct Sun>=15 2:00s 1:00 D -Rule AV 1988 1999 - Oct lastSun 2:00s 1:00 D -Rule AV 1991 1994 - Mar Sun>=1 2:00s 0 S -Rule AV 1995 2005 - Mar lastSun 2:00s 0 S -Rule AV 2000 only - Aug lastSun 2:00s 1:00 D -Rule AV 2001 2007 - Oct lastSun 2:00s 1:00 D -Rule AV 2006 only - Apr Sun>=1 2:00s 0 S -Rule AV 2007 only - Mar lastSun 2:00s 0 S -Rule AV 2008 max - Apr Sun>=1 2:00s 0 S -Rule AV 2008 max - Oct Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Australia/Melbourne 9:39:52 - LMT 1895 Feb - 10:00 Aus AE%sT 1971 - 10:00 AV AE%sT - -# New South Wales -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule AN 1971 1985 - Oct lastSun 2:00s 1:00 D -Rule AN 1972 only - Feb 27 2:00s 0 S -Rule AN 1973 1981 - Mar Sun>=1 2:00s 0 S -Rule AN 1982 only - Apr Sun>=1 2:00s 0 S -Rule AN 1983 1985 - Mar Sun>=1 2:00s 0 S -Rule AN 1986 1989 - Mar Sun>=15 2:00s 0 S -Rule AN 1986 only - Oct 19 2:00s 1:00 D -Rule AN 1987 1999 - Oct lastSun 2:00s 1:00 D -Rule AN 1990 1995 - Mar Sun>=1 2:00s 0 S -Rule AN 1996 2005 - Mar lastSun 2:00s 0 S -Rule AN 2000 only - Aug lastSun 2:00s 1:00 D -Rule AN 2001 2007 - Oct lastSun 2:00s 1:00 D -Rule AN 2006 only - Apr Sun>=1 2:00s 0 S -Rule AN 2007 only - Mar lastSun 2:00s 0 S -Rule AN 2008 max - Apr Sun>=1 2:00s 0 S -Rule AN 2008 max - Oct Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Australia/Sydney 10:04:52 - LMT 1895 Feb - 10:00 Aus AE%sT 1971 - 10:00 AN AE%sT -Zone Australia/Broken_Hill 9:25:48 - LMT 1895 Feb - 10:00 - AEST 1896 Aug 23 - 9:00 - ACST 1899 May - 9:30 Aus AC%sT 1971 - 9:30 AN AC%sT 2000 - 9:30 AS AC%sT - -# Lord Howe Island -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule LH 1981 1984 - Oct lastSun 2:00 1:00 - -Rule LH 1982 1985 - Mar Sun>=1 2:00 0 - -Rule LH 1985 only - Oct lastSun 2:00 0:30 - -Rule LH 1986 1989 - Mar Sun>=15 2:00 0 - -Rule LH 1986 only - Oct 19 2:00 0:30 - -Rule LH 1987 1999 - Oct lastSun 2:00 0:30 - -Rule LH 1990 1995 - Mar Sun>=1 2:00 0 - -Rule LH 1996 2005 - Mar lastSun 2:00 0 - -Rule LH 2000 only - Aug lastSun 2:00 0:30 - -Rule LH 2001 2007 - Oct lastSun 2:00 0:30 - -Rule LH 2006 only - Apr Sun>=1 2:00 0 - -Rule LH 2007 only - Mar lastSun 2:00 0 - -Rule LH 2008 max - Apr Sun>=1 2:00 0 - -Rule LH 2008 max - Oct Sun>=1 2:00 0:30 - -Zone Australia/Lord_Howe 10:36:20 - LMT 1895 Feb - 10:00 - AEST 1981 Mar - 10:30 LH +1030/+1130 1985 Jul - 10:30 LH +1030/+11 - -# Australian miscellany -# -# Ashmore Is, Cartier -# no indigenous inhabitants; only seasonal caretakers -# no times are set -# -# Coral Sea Is -# no indigenous inhabitants; only meteorologists -# no times are set -# -# Macquarie -# Permanent occupation (scientific station) 1911-1915 and since 25 March 1948; -# sealing and penguin oil station operated Nov 1899 to Apr 1919. See the -# Tasmania Parks & Wildlife Service history of sealing at Macquarie Island -# http://www.parks.tas.gov.au/index.aspx?base=1828 -# http://www.parks.tas.gov.au/index.aspx?base=1831 -# Guess that it was like Australia/Hobart while inhabited before 2010. -# -# From Steffen Thorsen (2010-03-10): -# We got these changes from the Australian Antarctic Division: -# - Macquarie Island will stay on UTC+11 for winter and therefore not -# switch back from daylight savings time when other parts of Australia do -# on 4 April. -# -# From Arthur David Olson (2013-05-23): -# The 1919 transition is overspecified below so pre-2013 zics -# will produce a binary file with an [A]EST-type as the first 32-bit type; -# this is required for correct handling of times before 1916 by -# pre-2013 versions of localtime. -Zone Antarctica/Macquarie 0 - -00 1899 Nov - 10:00 - AEST 1916 Oct 1 2:00 - 10:00 1:00 AEDT 1917 Feb - 10:00 Aus AE%sT 1919 Apr 1 0:00s - 0 - -00 1948 Mar 25 - 10:00 Aus AE%sT 1967 - 10:00 AT AE%sT 2010 Apr 4 3:00 - 11:00 - +11 - -# Christmas -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Christmas 7:02:52 - LMT 1895 Feb - 7:00 - +07 - -# Cocos (Keeling) Is -# These islands were ruled by the Ross family from about 1830 to 1978. -# We don't know when standard time was introduced; for now, we guess 1900. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Cocos 6:27:40 - LMT 1900 - 6:30 - +0630 - - -# Fiji - -# Milne gives 11:55:44 for Suva. - -# From Alexander Krivenyshev (2009-11-10): -# According to Fiji Broadcasting Corporation, Fiji plans to re-introduce DST -# from November 29th 2009 to April 25th 2010. -# -# "Daylight savings to commence this month" -# http://www.radiofiji.com.fj/fullstory.php?id=23719 -# http://www.worldtimezone.com/dst_news/dst_news_fiji01.html - -# From Steffen Thorsen (2009-11-10): -# The Fiji Government has posted some more details about the approved -# amendments: -# http://www.fiji.gov.fj/publish/page_16198.shtml - -# From Steffen Thorsen (2010-03-03): -# The Cabinet in Fiji has decided to end DST about a month early, on -# 2010-03-28 at 03:00. -# The plan is to observe DST again, from 2010-10-24 to sometime in March -# 2011 (last Sunday a good guess?). -# -# Official source: -# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=1096:3310-cabinet-approves-change-in-daylight-savings-dates&catid=49:cabinet-releases&Itemid=166 -# -# A bit more background info here: -# https://www.timeanddate.com/news/time/fiji-dst-ends-march-2010.html - -# From Alexander Krivenyshev (2010-10-24): -# According to Radio Fiji and Fiji Times online, Fiji will end DST 3 -# weeks earlier than expected - on March 6, 2011, not March 27, 2011... -# Here is confirmation from Government of the Republic of the Fiji Islands, -# Ministry of Information (fiji.gov.fj) web site: -# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=2608:daylight-savings&catid=71:press-releases&Itemid=155 -# http://www.worldtimezone.com/dst_news/dst_news_fiji04.html - -# From Steffen Thorsen (2011-10-03): -# Now the dates have been confirmed, and at least our start date -# assumption was correct (end date was one week wrong). -# -# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=4966:daylight-saving-starts-in-fiji&catid=71:press-releases&Itemid=155 -# which says -# Members of the public are reminded to change their time to one hour in -# advance at 2am to 3am on October 23, 2011 and one hour back at 3am to -# 2am on February 26 next year. - -# From Ken Rylander (2011-10-24) -# Another change to the Fiji DST end date. In the TZ database the end date for -# Fiji DST 2012, is currently Feb 26. This has been changed to Jan 22. -# -# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=5017:amendments-to-daylight-savings&catid=71:press-releases&Itemid=155 -# states: -# -# The end of daylight saving scheduled initially for the 26th of February 2012 -# has been brought forward to the 22nd of January 2012. -# The commencement of daylight saving will remain unchanged and start -# on the 23rd of October, 2011. - -# From the Fiji Government Online Portal (2012-08-21) via Steffen Thorsen: -# The Minister for Labour, Industrial Relations and Employment Mr Jone Usamate -# today confirmed that Fiji will start daylight savings at 2 am on Sunday 21st -# October 2012 and end at 3 am on Sunday 20th January 2013. -# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=6702&catid=71&Itemid=155 - -# From the Fijian Government Media Center (2013-08-30) via David Wheeler: -# Fiji will start daylight savings on Sunday 27th October, 2013 ... -# move clocks forward by one hour from 2am -# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-27th-OCTOBER-201.aspx - -# From Steffen Thorsen (2013-01-10): -# Fiji will end DST on 2014-01-19 02:00: -# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVINGS-TO-END-THIS-MONTH-%281%29.aspx - -# From Ken Rylander (2014-10-20): -# DST will start Nov. 2 this year. -# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx - -# From a government order dated 2015-08-26 and published as Legal Notice No. 77 -# in the Government of Fiji Gazette Supplement No. 24 (2015-08-28), -# via Ken Rylander (2015-09-02): -# the daylight saving period is 1 hour in advance of the standard time -# commencing at 2.00 am on Sunday 1st November, 2015 and ending at -# 3.00 am on Sunday 17th January, 2016. - -# From Raymond Kumar (2016-10-04): -# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-6th-NOVEMBER,-2016.aspx -# "Fiji's daylight savings will begin on Sunday, 6 November 2016, when -# clocks go forward an hour at 2am to 3am.... Daylight Saving will -# end at 3.00am on Sunday 15th January 2017." - -# From Paul Eggert (2017-08-21): -# Dominic Fok writes (2017-08-20) that DST ends 2018-01-14, citing -# Extraordinary Government of Fiji Gazette Supplement No. 21 (2017-08-27), -# [Legal Notice No. 41] of an order of the previous day by J Usamate. - -# From Raymond Kumar (2018-07-13): -# http://www.fijitimes.com/government-approves-2018-daylight-saving/ -# ... The daylight saving period will end at 3am on Sunday January 13, 2019. -# -# From Paul Eggert (2018-07-15): -# For now, guess DST from 02:00 the first Sunday in November to 03:00 -# the first Sunday on or after January 13. January transitions reportedly -# depend on when school terms start. Although the guess is ad hoc, it matches -# transitions since late 2014 and seems more likely to match future -# practice than guessing no DST. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 - -Rule Fiji 1999 2000 - Feb lastSun 3:00 0 - -Rule Fiji 2009 only - Nov 29 2:00 1:00 - -Rule Fiji 2010 only - Mar lastSun 3:00 0 - -Rule Fiji 2010 2013 - Oct Sun>=21 2:00 1:00 - -Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - -Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - -Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - -Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 - -Rule Fiji 2015 max - Jan Sun>=13 3:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva - 12:00 Fiji +12/+13 - -# French Polynesia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Gambier -8:59:48 - LMT 1912 Oct # Rikitea - -9:00 - -09 -Zone Pacific/Marquesas -9:18:00 - LMT 1912 Oct - -9:30 - -0930 -Zone Pacific/Tahiti -9:58:16 - LMT 1912 Oct # Papeete - -10:00 - -10 -# Clipperton (near North America) is administered from French Polynesia; -# it is uninhabited. - -# Guam -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Guam -14:21:00 - LMT 1844 Dec 31 - 9:39:00 - LMT 1901 # Agana - 10:00 - GST 2000 Dec 23 # Guam - 10:00 - ChST # Chamorro Standard Time -Link Pacific/Guam Pacific/Saipan # N Mariana Is - -# Kiribati -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Tarawa 11:32:04 - LMT 1901 # Bairiki - 12:00 - +12 -Zone Pacific/Enderbury -11:24:20 - LMT 1901 - -12:00 - -12 1979 Oct - -11:00 - -11 1994 Dec 31 - 13:00 - +13 -Zone Pacific/Kiritimati -10:29:20 - LMT 1901 - -10:40 - -1040 1979 Oct - -10:00 - -10 1994 Dec 31 - 14:00 - +14 - -# N Mariana Is -# See Pacific/Guam. - -# Marshall Is -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Majuro 11:24:48 - LMT 1901 - 11:00 - +11 1969 Oct - 12:00 - +12 -Zone Pacific/Kwajalein 11:09:20 - LMT 1901 - 11:00 - +11 1969 Oct - -12:00 - -12 1993 Aug 20 - 12:00 - +12 - -# Micronesia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Chuuk 10:07:08 - LMT 1901 - 10:00 - +10 -Zone Pacific/Pohnpei 10:32:52 - LMT 1901 # Kolonia - 11:00 - +11 -Zone Pacific/Kosrae 10:51:56 - LMT 1901 - 11:00 - +11 1969 Oct - 12:00 - +12 1999 - 11:00 - +11 - -# Nauru -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Nauru 11:07:40 - LMT 1921 Jan 15 # Uaobe - 11:30 - +1130 1942 Mar 15 - 9:00 - +09 1944 Aug 15 - 11:30 - +1130 1979 May - 12:00 - +12 - -# New Caledonia -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NC 1977 1978 - Dec Sun>=1 0:00 1:00 - -Rule NC 1978 1979 - Feb 27 0:00 0 - -Rule NC 1996 only - Dec 1 2:00s 1:00 - -# Shanks & Pottenger say the following was at 2:00; go with IATA. -Rule NC 1997 only - Mar 2 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Noumea 11:05:48 - LMT 1912 Jan 13 # Nouméa - 11:00 NC +11/+12 - - -############################################################################### - -# New Zealand - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NZ 1927 only - Nov 6 2:00 1:00 S -Rule NZ 1928 only - Mar 4 2:00 0 M -Rule NZ 1928 1933 - Oct Sun>=8 2:00 0:30 S -Rule NZ 1929 1933 - Mar Sun>=15 2:00 0 M -Rule NZ 1934 1940 - Apr lastSun 2:00 0 M -Rule NZ 1934 1940 - Sep lastSun 2:00 0:30 S -Rule NZ 1946 only - Jan 1 0:00 0 S -# Since 1957 Chatham has been 45 minutes ahead of NZ, but until 2018a -# there was no documented single notation for the date and time of this -# transition. Duplicate the Rule lines for now, to give the 2018a change -# time to percolate out. -Rule NZ 1974 only - Nov Sun>=1 2:00s 1:00 D -Rule Chatham 1974 only - Nov Sun>=1 2:45s 1:00 - -Rule NZ 1975 only - Feb lastSun 2:00s 0 S -Rule Chatham 1975 only - Feb lastSun 2:45s 0 - -Rule NZ 1975 1988 - Oct lastSun 2:00s 1:00 D -Rule Chatham 1975 1988 - Oct lastSun 2:45s 1:00 - -Rule NZ 1976 1989 - Mar Sun>=1 2:00s 0 S -Rule Chatham 1976 1989 - Mar Sun>=1 2:45s 0 - -Rule NZ 1989 only - Oct Sun>=8 2:00s 1:00 D -Rule Chatham 1989 only - Oct Sun>=8 2:45s 1:00 - -Rule NZ 1990 2006 - Oct Sun>=1 2:00s 1:00 D -Rule Chatham 1990 2006 - Oct Sun>=1 2:45s 1:00 - -Rule NZ 1990 2007 - Mar Sun>=15 2:00s 0 S -Rule Chatham 1990 2007 - Mar Sun>=15 2:45s 0 - -Rule NZ 2007 max - Sep lastSun 2:00s 1:00 D -Rule Chatham 2007 max - Sep lastSun 2:45s 1:00 - -Rule NZ 2008 max - Apr Sun>=1 2:00s 0 S -Rule Chatham 2008 max - Apr Sun>=1 2:45s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Auckland 11:39:04 - LMT 1868 Nov 2 - 11:30 NZ NZ%sT 1946 Jan 1 - 12:00 NZ NZ%sT -Zone Pacific/Chatham 12:13:48 - LMT 1868 Nov 2 - 12:15 - +1215 1946 Jan 1 - 12:45 Chatham +1245/+1345 - -Link Pacific/Auckland Antarctica/McMurdo - -# Auckland Is -# uninhabited; Māori and Moriori, colonial settlers, pastoralists, sealers, -# and scientific personnel have wintered - -# Campbell I -# minor whaling stations operated 1909/1914 -# scientific station operated 1941/1995; -# previously whalers, sealers, pastoralists, and scientific personnel wintered -# was probably like Pacific/Auckland - -# Cook Is -# From Shanks & Pottenger: -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Cook 1978 only - Nov 12 0:00 0:30 - -Rule Cook 1979 1991 - Mar Sun>=1 0:00 0 - -Rule Cook 1979 1990 - Oct lastSun 0:00 0:30 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Rarotonga -10:39:04 - LMT 1901 # Avarua - -10:30 - -1030 1978 Nov 12 - -10:00 Cook -10/-0930 - -############################################################################### - - -# Niue -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Niue -11:19:40 - LMT 1901 # Alofi - -11:20 - -1120 1951 - -11:30 - -1130 1978 Oct 1 - -11:00 - -11 - -# Norfolk -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Norfolk 11:11:52 - LMT 1901 # Kingston - 11:12 - +1112 1951 - 11:30 - +1130 1974 Oct 27 02:00 - 11:30 1:00 +1230 1975 Mar 2 02:00 - 11:30 - +1130 2015 Oct 4 02:00 - 11:00 - +11 - -# Palau (Belau) -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Palau 8:57:56 - LMT 1901 # Koror - 9:00 - +09 - -# Papua New Guinea -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Port_Moresby 9:48:40 - LMT 1880 - 9:48:32 - PMMT 1895 # Port Moresby Mean Time - 10:00 - +10 -# -# From Paul Eggert (2014-10-13): -# Base the Bougainville entry on the Arawa-Kieta region, which appears to have -# the most people even though it was devastated in the Bougainville Civil War. -# -# Although Shanks gives 1942-03-15 / 1943-11-01 for UT +09, these dates -# are apparently rough guesswork from the starts of military campaigns. -# The World War II entries below are instead based on Arawa-Kieta. -# The Japanese occupied Kieta in July 1942, -# according to the Pacific War Online Encyclopedia -# https://pwencycl.kgbudge.com/B/o/Bougainville.htm -# and seem to have controlled it until their 1945-08-21 surrender. -# -# The Autonomous Region of Bougainville switched from UT +10 to +11 -# on 2014-12-28 at 02:00. They call +11 "Bougainville Standard Time". -# See: -# http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/ -# -Zone Pacific/Bougainville 10:22:16 - LMT 1880 - 9:48:32 - PMMT 1895 - 10:00 - +10 1942 Jul - 9:00 - +09 1945 Aug 21 - 10:00 - +10 2014 Dec 28 2:00 - 11:00 - +11 - -# Pitcairn -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Pitcairn -8:40:20 - LMT 1901 # Adamstown - -8:30 - -0830 1998 Apr 27 0:00 - -8:00 - -08 - -# American Samoa -Zone Pacific/Pago_Pago 12:37:12 - LMT 1892 Jul 5 - -11:22:48 - LMT 1911 - -11:00 - SST # S=Samoa -Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands - -# Samoa (formerly and also known as Western Samoa) - -# From Steffen Thorsen (2009-10-16): -# We have been in contact with the government of Samoa again, and received -# the following info: -# -# "Cabinet has now approved Daylight Saving to be effected next year -# commencing from the last Sunday of September 2010 and conclude first -# Sunday of April 2011." -# -# Background info: -# https://www.timeanddate.com/news/time/samoa-dst-plan-2009.html -# -# Samoa's Daylight Saving Time Act 2009 is available here, but does not -# contain any dates: -# http://www.parliament.gov.ws/documents/acts/Daylight%20Saving%20Act%20%202009%20%28English%29%20-%20Final%207-7-091.pdf - -# From Laupue Raymond Hughes (2010-10-07): -# Please see -# http://www.mcil.gov.ws -# the Ministry of Commerce, Industry and Labour (sideframe) "Last Sunday -# September 2010 (26/09/10) - adjust clocks forward from 12:00 midnight -# to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks -# backwards from 1:00am to 12:00am" - -# From Laupue Raymond Hughes (2011-03-07): -# [http://www.mcil.gov.ws/ftcd/daylight_saving_2011.pdf] -# -# ... when the standard time strikes the hour of four o'clock (4.00am -# or 0400 Hours) on the 2nd April 2011, then all instruments used to -# measure standard time are to be adjusted/changed to three o'clock -# (3:00am or 0300Hrs). - -# From David Zülke (2011-05-09): -# Subject: Samoa to move timezone from east to west of international date line -# -# http://www.morningstar.co.uk/uk/markets/newsfeeditem.aspx?id=138501958347963 - -# From Paul Eggert (2014-06-27): -# The International Date Line Act 2011 -# http://www.parliament.gov.ws/images/ACTS/International_Date_Line_Act__2011_-_Eng.pdf -# changed Samoa from UT -11 to +13, effective "12 o'clock midnight, on -# Thursday 29th December 2011". The International Date Line was adjusted -# accordingly. - -# From Laupue Raymond Hughes (2011-09-02): -# http://www.mcil.gov.ws/mcil_publications.html -# -# here is the official website publication for Samoa DST and dateline change -# -# DST -# Year End Time Start Time -# 2011 - - - - - - 24 September 3:00am to 4:00am -# 2012 01 April 4:00am to 3:00am - - - - - - -# -# Dateline Change skip Friday 30th Dec 2011 -# Thursday 29th December 2011 23:59:59 Hours -# Saturday 31st December 2011 00:00:00 Hours -# -# From Nicholas Pereira (2012-09-10): -# Daylight Saving Time commences on Sunday 30th September 2012 and -# ends on Sunday 7th of April 2013.... -# http://www.mcil.gov.ws/mcil_publications.html -# -# From Paul Eggert (2014-07-08): -# That web page currently lists transitions for 2012/3 and 2013/4. -# Assume the pattern instituted in 2012 will continue indefinitely. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule WS 2010 only - Sep lastSun 0:00 1 - -Rule WS 2011 only - Apr Sat>=1 4:00 0 - -Rule WS 2011 only - Sep lastSat 3:00 1 - -Rule WS 2012 max - Apr Sun>=1 4:00 0 - -Rule WS 2012 max - Sep lastSun 3:00 1 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Apia 12:33:04 - LMT 1892 Jul 5 - -11:26:56 - LMT 1911 - -11:30 - -1130 1950 - -11:00 WS -11/-10 2011 Dec 29 24:00 - 13:00 WS +13/+14 - -# Solomon Is -# excludes Bougainville, for which see Papua New Guinea -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Guadalcanal 10:39:48 - LMT 1912 Oct # Honiara - 11:00 - +11 - -# Tokelau -# -# From Gwillim Law (2011-12-29) -# A correspondent informed me that Tokelau, like Samoa, will be skipping -# December 31 this year ... -# -# From Steffen Thorsen (2012-07-25) -# ... we double checked by calling hotels and offices based in Tokelau asking -# about the time there, and they all told a time that agrees with UTC+13.... -# Shanks says UT-10 from 1901 [but] ... there is a good chance the change -# actually was to UT-11 back then. -# -# From Paul Eggert (2012-07-25) -# A Google Books snippet of Appendix to the Journals of the House of -# Representatives of New Zealand, Session 1948, -# <https://books.google.com/books?id=ZaVCAQAAIAAJ>, page 65, says Tokelau -# was "11 hours slow on G.M.T." Go with Thorsen and assume Shanks & Pottenger -# are off by an hour starting in 1901. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Fakaofo -11:24:56 - LMT 1901 - -11:00 - -11 2011 Dec 30 - 13:00 - +13 - -# Tonga -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Tonga 1999 only - Oct 7 2:00s 1:00 - -Rule Tonga 2000 only - Mar 19 2:00s 0 - -Rule Tonga 2000 2001 - Nov Sun>=1 2:00 1:00 - -Rule Tonga 2001 2002 - Jan lastSun 2:00 0 - -Rule Tonga 2016 only - Nov Sun>=1 2:00 1:00 - -Rule Tonga 2017 only - Jan Sun>=15 3:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Tongatapu 12:19:20 - LMT 1901 - 12:20 - +1220 1941 - 13:00 - +13 1999 - 13:00 Tonga +13/+14 - -# Tuvalu -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Funafuti 11:56:52 - LMT 1901 - 12:00 - +12 - - -# US minor outlying islands - -# Howland, Baker -# Howland was mined for guano by American companies 1857-1878 and British -# 1886-1891; Baker was similar but exact dates are not known. -# Inhabited by civilians 1935-1942; U.S. military bases 1943-1944; -# uninhabited thereafter. -# Howland observed Hawaii Standard Time (UT -10:30) in 1937; -# see page 206 of Elgen M. Long and Marie K. Long, -# Amelia Earhart: the Mystery Solved, Simon & Schuster (2000). -# So most likely Howland and Baker observed Hawaii Time from 1935 -# until they were abandoned after the war. - -# Jarvis -# Mined for guano by American companies 1857-1879 and British 1883?-1891?. -# Inhabited by civilians 1935-1942; IGY scientific base 1957-1958; -# uninhabited thereafter. -# no information; was probably like Pacific/Kiritimati - -# Johnston -# -# From Paul Eggert (2017-02-10): -# Sometimes Johnston kept Hawaii time, and sometimes it was an hour behind. -# Details are uncertain. We have no data for Johnston after 1970, so -# treat it like Hawaii for now. Since Johnston is now uninhabited, -# its link to Pacific/Honolulu is in the 'backward' file. -# -# In his memoirs of June 6th to October 4, 1945 -# <http://www.315bw.org/Herb_Bach.htm> (2005), Herbert C. Bach writes, -# "We started our letdown to Kwajalein Atoll and landed there at 5:00 AM -# Johnston time, 1:30 AM Kwajalein time." This was in June 1945, and -# confirms that Johnston kept the same time as Honolulu in summer 1945. -# -# From Lyle McElhaney (2014-03-11): -# [W]hen JI was being used for that [atomic bomb] testing, the time being used -# was not Hawaiian time but rather the same time being used on the ships, -# which had a GMT offset of -11 hours. This apparently applied to at least the -# time from Operation Newsreel (Hardtack I/Teak shot, 1958-08-01) to the last -# Operation Fishbowl shot (Tightrope, 1962-11-04).... [See] Herman Hoerlin, -# "The United States High-Altitude Test Experience: A Review Emphasizing the -# Impact on the Environment", Los Alamos LA-6405, Oct 1976. -# https://www.fas.org/sgp/othergov/doe/lanl/docs1/00322994.pdf -# See the table on page 4 where he lists GMT and local times for the tests; a -# footnote for the JI tests reads that local time is "JI time = Hawaii Time -# Minus One Hour". - -# Kingman -# uninhabited - -# Midway -# See Pacific/Pago_Pago. - -# Palmyra -# uninhabited since World War II; was probably like Pacific/Kiritimati - -# Wake -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Wake 11:06:28 - LMT 1901 - 12:00 - +12 - - -# Vanuatu -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Vanuatu 1983 only - Sep 25 0:00 1:00 - -Rule Vanuatu 1984 1991 - Mar Sun>=23 0:00 0 - -Rule Vanuatu 1984 only - Oct 23 0:00 1:00 - -Rule Vanuatu 1985 1991 - Sep Sun>=23 0:00 1:00 - -Rule Vanuatu 1992 1993 - Jan Sun>=23 0:00 0 - -Rule Vanuatu 1992 only - Oct Sun>=23 0:00 1:00 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Efate 11:13:16 - LMT 1912 Jan 13 # Vila - 11:00 Vanuatu +11/+12 - -# Wallis and Futuna -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Wallis 12:15:20 - LMT 1901 - 12:00 - +12 - -############################################################################### - -# NOTES - -# This file is by no means authoritative; if you think you know better, -# go ahead and edit the file (and please send any changes to -# tz@iana.org for general use in the future). For more, please see -# the file CONTRIBUTING in the tz distribution. - -# From Paul Eggert (2017-02-10): -# -# Unless otherwise specified, the source for data through 1990 is: -# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), -# San Diego: ACS Publications, Inc. (2003). -# Unfortunately this book contains many errors and cites no sources. -# -# Many years ago Gwillim Law wrote that a good source -# for time zone data was the International Air Transport -# Association's Standard Schedules Information Manual (IATA SSIM), -# published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. Except where otherwise noted, -# IATA SSIM is the source for entries after 1990. -# -# Another source occasionally used is Edward W. Whitman, World Time Differences, -# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which -# I found in the UCLA library. -# -# For data circa 1899, a common source is: -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# https://www.jstor.org/stable/1774359 -# -# A reliable and entertaining source about time zones is -# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). -# -# The following abbreviations are from other sources. -# Corrections are welcome! -# std dst -# LMT Local Mean Time -# 8:00 AWST AWDT Western Australia -# 9:30 ACST ACDT Central Australia -# 10:00 AEST AEDT Eastern Australia -# 10:00 GST Guam through 2000 -# 10:00 ChST Chamorro -# 11:30 NZMT NZST New Zealand through 1945 -# 12:00 NZST NZDT New Zealand 1946-present -# -11:00 SST Samoa -# -10:00 HST Hawaii -# -# See the 'northamerica' file for Hawaii. -# See the 'southamerica' file for Easter I and the Galápagos Is. - -############################################################################### - -# Australia - -# From Paul Eggert (2014-06-30): -# Daylight saving time has long been controversial in Australia, pitting -# region against region, rural against urban, and local against global. -# For example, in her review of Graeme Davison's _The Unforgiving -# Minute: how Australians learned to tell the time_ (1993), Perth native -# Phillipa J Martyr wrote, "The section entitled 'Saving Daylight' was -# very informative, but was (as can, sadly, only be expected from a -# Melbourne-based study) replete with the usual chuckleheaded -# Queenslanders and straw-chewing yokels from the West prattling fables -# about fading curtains and crazed farm animals." -# Electronic Journal of Australian and New Zealand History (1997-03-03) -# http://www.jcu.edu.au/aff/history/reviews/davison.htm - -# From Paul Eggert (2005-12-08): -# Implementation Dates of Daylight Saving Time within Australia -# http://www.bom.gov.au/climate/averages/tables/dst_times.shtml -# summarizes daylight saving issues in Australia. - -# From Arthur David Olson (2005-12-12): -# Lawlink NSW:Daylight Saving in New South Wales -# http://www.lawlink.nsw.gov.au/lawlink/Corporate/ll_agdinfo.nsf/pages/community_relations_daylight_saving -# covers New South Wales in particular. - -# From John Mackin (1991-03-06): -# We in Australia have _never_ referred to DST as 'daylight' time. -# It is called 'summer' time. Now by a happy coincidence, 'summer' -# and 'standard' happen to start with the same letter; hence, the -# abbreviation does _not_ change... -# The legislation does not actually define abbreviations, at least -# in this State, but the abbreviation is just commonly taken to be the -# initials of the phrase, and the legislation here uniformly uses -# the phrase 'summer time' and does not use the phrase 'daylight -# time'. -# Announcers on the Commonwealth radio network, the ABC (for Australian -# Broadcasting Commission), use the phrases 'Eastern Standard Time' -# or 'Eastern Summer Time'. (Note, though, that as I say in the -# current australasia file, there is really no such thing.) Announcers -# on its overseas service, Radio Australia, use the same phrases -# prefixed by the word 'Australian' when referring to local times; -# time announcements on that service, naturally enough, are made in UTC. - -# From Paul Eggert (2014-06-30): -# -# Inspired by Mackin's remarks quoted above, earlier versions of this -# file used "EST" for both Eastern Standard Time and Eastern Summer -# Time in Australia, and similarly for "CST", "CWST", and "WST". -# However, these abbreviations were confusing and were not common -# practice among Australians, and there were justifiable complaints -# about them, so I attempted to survey current Australian usage. -# For the tz database, the full English phrase is not that important; -# what matters is the abbreviation. It's difficult to survey the web -# directly for abbreviation usage, as there are so many false hits for -# strings like "EST" and "EDT", so I looked for pages that defined an -# abbreviation for eastern or central DST in Australia, and got the -# following numbers of unique hits for the listed Google queries: -# -# 10 "Eastern Daylight Time AEST" site:au [some are false hits] -# 10 "Eastern Summer Time AEST" site:au -# 10 "Summer Time AEDT" site:au -# 13 "EDST Eastern Daylight Saving Time" site:au -# 18 "Summer Time ESST" site:au -# 28 "Eastern Daylight Saving Time EDST" site:au -# 39 "EDT Eastern Daylight Time" site:au [some are false hits] -# 53 "Eastern Daylight Time EDT" site:au [some are false hits] -# 54 "AEDT Australian Eastern Daylight Time" site:au -# 182 "Eastern Daylight Time AEDT" site:au -# -# 17 "Central Daylight Time CDT" site:au [some are false hits] -# 46 "Central Daylight Time ACDT" site:au -# -# I tried several other variants (e.g., "Eastern Summer Time EST") but -# they all returned fewer than 10 unique hits. I also looked for pages -# mentioning both "western standard time" and an abbreviation, since -# there is no WST in the US to generate false hits, and found: -# -# 156 "western standard time" AWST site:au -# 226 "western standard time" WST site:au -# -# I then surveyed the top ten newspapers in Australia by circulation as -# listed in Wikipedia, using Google queries like "AEDT site:heraldsun.com.au" -# and obtaining estimated counts from the initial page of search results. -# All ten papers greatly preferred "AEDT" to "EDT". The papers -# surveyed were the Herald Sun, The Daily Telegraph, The Courier-Mail, -# The Sydney Morning Herald, The West Australian, The Age, The Advertiser, -# The Australian, The Financial Review, and The Herald (Newcastle). -# -# I also searched for historical usage, to see whether abbreviations -# like "AEDT" are new. A Trove search <http://trove.nla.gov.au/> -# found only one newspaper (The Canberra Times) with a house style -# dating back to the 1970s, I expect because other newspapers weren't -# fully indexed. The Canberra Times strongly preferred abbreviations -# like "AEDT". The first occurrence of "AEDT" was a World Weather -# column (1971-11-17, page 24), and of "ACDT" was a Scoreboard column -# (1993-01-24, p 16). The style was the typical usage but was not -# strictly enforced; for example, "Welcome to the twilight zones ..." -# (1994-10-29, p 1) uses the abbreviations AEST/AEDT, CST/CDT, and -# WST, and goes on to say, "The confusion and frustration some feel -# about the lack of uniformity among Australia's six states and two -# territories has prompted one group to form its very own political -# party -- the Sydney-based Daylight Saving Extension Party." -# -# I also surveyed federal government sources. They did not agree: -# -# The Australian Government (2014-03-26) -# http://australia.gov.au/about-australia/our-country/time -# (This document was produced by the Department of Finance.) -# AEST ACST AWST AEDT ACDT -# -# Bureau of Meteorology (2012-11-08) -# http://www.bom.gov.au/climate/averages/tables/daysavtm.shtml -# EST CST WST EDT CDT -# -# Civil Aviation Safety Authority (undated) -# http://services.casa.gov.au/outnback/inc/pages/episode3/episode-3_time_zones.shtml -# EST CST WST (no abbreviations given for DST) -# -# Geoscience Australia (2011-11-24) -# http://www.ga.gov.au/geodesy/astro/sunrise.jsp -# AEST ACST AWST AEDT ACDT -# -# Parliamentary Library (2008-11-10) -# https://www.aph.gov.au/binaries/library/pubs/rp/2008-09/09rp14.pdf -# EST CST WST preferred for standard time; AEST AEDT ACST ACDT also used -# -# The Transport Safety Bureau has an extensive series of accident reports, -# and investigators seem to use whatever abbreviation they like. -# Googling site:atsb.gov.au found the following number of unique hits: -# 311 "ESuT", 195 "EDT", 26 "AEDT", 83 "CSuT", 46 "CDT". -# "_SuT" tended to appear in older reports, and "A_DT" tended to -# appear in reports of events with international implications. -# -# From the above it appears that there is a working consensus in -# Australia to use trailing "DT" for daylight saving time; although -# some sources use trailing "SST" or "ST" or "SuT" they are by far in -# the minority. The case for leading "A" is weaker, but since it -# seems to be preferred in the overall web and is preferred in all -# the leading newspaper websites and in many government departments, -# it has a stronger case than omitting the leading "A". The current -# version of the database therefore uses abbreviations like "AEST" and -# "AEDT" for Australian time zones. - -# From Paul Eggert (1995-12-19): -# Shanks & Pottenger report 2:00 for all autumn changes in Australia and NZ. -# Mark Prior writes that his newspaper -# reports that NSW's fall 1995 change will occur at 2:00, -# but Robert Elz says it's been 3:00 in Victoria since 1970 -# and perhaps the newspaper's '2:00' is referring to standard time. -# For now we'll continue to assume 2:00s for changes since 1960. - -# From Eric Ulevik (1998-01-05): -# -# Here are some URLs to Australian time legislation. These URLs are stable, -# and should probably be included in the data file. There are probably more -# relevant entries in this database. -# -# NSW (including LHI and Broken Hill): -# Standard Time Act 1987 (updated 1995-04-04) -# https://www.austlii.edu.au/au/legis/nsw/consol_act/sta1987137/index.html -# ACT -# Standard Time and Summer Time Act 1972 -# https://www.austlii.edu.au/au/legis/act/consol_act/stasta1972279/index.html -# SA -# Standard Time Act, 1898 -# https://www.austlii.edu.au/au/legis/sa/consol_act/sta1898137/index.html - -# From David Grosz (2005-06-13): -# It was announced last week that Daylight Saving would be extended by -# one week next year to allow for the 2006 Commonwealth Games. -# Daylight Saving is now to end for next year only on the first Sunday -# in April instead of the last Sunday in March. -# -# From Gwillim Law (2005-06-14): -# I did some Googling and found that all of those states (and territory) plan -# to extend DST together in 2006. -# ACT: http://www.cmd.act.gov.au/mediareleases/fileread.cfm?file=86.txt -# New South Wales: http://www.thecouriermail.news.com.au/common/story_page/0,5936,15538869%255E1702,00.html -# South Australia: http://www.news.com.au/story/0,10117,15555031-1246,00.html -# Tasmania: http://www.media.tas.gov.au/release.php?id=14772 -# Victoria: I wasn't able to find anything separate, but the other articles -# allude to it. -# But not Queensland -# http://www.news.com.au/story/0,10117,15564030-1248,00.html - -# Northern Territory - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# # The NORTHERN TERRITORY.. [ Courtesy N.T. Dept of the Chief Minister ] -# # [ Nov 1990 ] -# # N.T. have never utilised any DST due to sub-tropical/tropical location. -# ... -# Zone Australia/North 9:30 - CST - -# From Bradley White (1991-03-04): -# A recent excerpt from an Australian newspaper... -# the Northern Territory do[es] not have daylight saving. - -# Western Australia - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# # The state of WESTERN AUSTRALIA.. [ Courtesy W.A. dept Premier+Cabinet ] -# # [ Nov 1990 ] -# # W.A. suffers from a great deal of public and political opposition to -# # DST in principle. A bill is brought before parliament in most years, but -# # usually defeated either in the upper house, or in party caucus -# # before reaching parliament. -# ... -# Zone Australia/West 8:00 AW %sST -# ... -# Rule AW 1974 only - Oct lastSun 2:00 1:00 D -# Rule AW 1975 only - Mar Sun>=1 3:00 0 W -# Rule AW 1983 only - Oct lastSun 2:00 1:00 D -# Rule AW 1984 only - Mar Sun>=1 3:00 0 W - -# From Bradley White (1991-03-04): -# A recent excerpt from an Australian newspaper... -# Western Australia...do[es] not have daylight saving. - -# From John D. Newman via Bradley White (1991-11-02): -# Western Australia is still on "winter time". Some DH in Sydney -# rang me at home a few days ago at 6.00am. (He had just arrived at -# work at 9.00am.) -# W.A. is switching to Summer Time on Nov 17th just to confuse -# everybody again. - -# From Arthur David Olson (1992-03-08): -# The 1992 ending date used in the rules is a best guess; -# it matches what was used in the past. - -# The Australian Bureau of Meteorology FAQ -# http://www.bom.gov.au/faq/faqgen.htm -# (1999-09-27) writes that Giles Meteorological Station uses -# South Australian time even though it's located in Western Australia. - -# From Paul Eggert (2018-04-01): -# The Guardian Express of Perth, Australia reported today that the -# government decided to advance the clocks permanently on January 1, -# 2019, from UT +08 to UT +09. The article noted that an exemption -# would be made for people aged 61 and over, who "can apply in writing -# to have the extra hour of sunshine removed from their area." See: -# Daylight saving coming to WA in 2019. Guardian Express. 2018-04-01. -# https://www.communitynews.com.au/guardian-express/news/exclusive-daylight-savings-coming-wa-summer-2018/ - -# Queensland - -# From Paul Eggert (2018-02-26): -# I lack access to the following source for Queensland DST: -# Pearce C. History of daylight saving time in Queensland. -# Queensland Hist J. 2017 Aug;23(6):389-403 -# https://search.informit.com.au/documentSummary;dn=994682348436426;res=IELHSS - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# # The state of QUEENSLAND.. [ Courtesy Qld. Dept Premier Econ&Trade Devel ] -# # [ Dec 1990 ] -# ... -# Zone Australia/Queensland 10:00 AQ %sST -# ... -# Rule AQ 1971 only - Oct lastSun 2:00 1:00 D -# Rule AQ 1972 only - Feb lastSun 3:00 0 E -# Rule AQ 1989 max - Oct lastSun 2:00 1:00 D -# Rule AQ 1990 max - Mar Sun>=1 3:00 0 E - -# From Bradley White (1989-12-24): -# "Australia/Queensland" now observes daylight time (i.e. from -# October 1989). - -# From Bradley White (1991-03-04): -# A recent excerpt from an Australian newspaper... -# ...Queensland...[has] agreed to end daylight saving -# at 3am tomorrow (March 3)... - -# From John Mackin (1991-03-06): -# I can certainly confirm for my part that Daylight Saving in NSW did in fact -# end on Sunday, 3 March. I don't know at what hour, though. (It surprised -# me.) - -# From Bradley White (1992-03-08): -# ...there was recently a referendum in Queensland which resulted -# in the experimental daylight saving system being abandoned. So, ... -# ... -# Rule QLD 1989 1991 - Oct lastSun 2:00 1:00 D -# Rule QLD 1990 1992 - Mar Sun>=1 3:00 0 S -# ... - -# From Arthur David Olson (1992-03-08): -# The chosen rules the union of the 1971/1972 change and the 1989-1992 changes. - -# From Christopher Hunt (2006-11-21), after an advance warning -# from Jesper Nørgaard Welen (2006-11-01): -# WA are trialing DST for three years. -# http://www.parliament.wa.gov.au/parliament/bills.nsf/9A1B183144403DA54825721200088DF1/$File/Bill175-1B.pdf - -# From Rives McDow (2002-04-09): -# The most interesting region I have found consists of three towns on the -# southern coast.... South Australia observes daylight saving time; Western -# Australia does not. The two states are one and a half hours apart. The -# residents decided to forget about this nonsense of changing the clock so -# much and set the local time 20 hours and 45 minutes from the -# international date line, or right in the middle of the time of South -# Australia and Western Australia.... -# -# From Paul Eggert (2002-04-09): -# This is confirmed by the section entitled -# "What's the deal with time zones???" in -# http://www.earthsci.unimelb.edu.au/~awatkins/null.html -# -# From Alex Livingston (2006-12-07): -# ... it was just on four years ago that I drove along the Eyre Highway, -# which passes through eastern Western Australia close to the southern -# coast of the continent. -# -# I paid particular attention to the time kept there. There can be no -# dispute that UTC+08:45 was considered "the time" from the border -# village just inside the border with South Australia to as far west -# as just east of Caiguna. There can also be no dispute that Eucla is -# the largest population centre in this zone.... -# -# Now that Western Australia is observing daylight saving, the -# question arose whether this part of the state would follow suit. I -# just called the border village and confirmed that indeed they have, -# meaning that they are now observing UTC+09:45. -# -# (2006-12-09): -# I personally doubt that either experimentation with daylight saving -# in WA or its introduction in SA had anything to do with the genesis -# of this time zone. My hunch is that it's been around since well -# before 1975. I remember seeing it noted on road maps decades ago. - -# From Paul Eggert (2006-12-15): -# For lack of better info, assume the tradition dates back to the -# introduction of standard time in 1895. - - -# southeast Australia -# -# From Paul Eggert (2007-07-23): -# Starting autumn 2008 Victoria, NSW, South Australia, Tasmania and the ACT -# end DST the first Sunday in April and start DST the first Sunday in October. -# http://www.theage.com.au/news/national/daylight-savings-to-span-six-months/2007/06/27/1182623966703.html - - -# South Australia - -# From Bradley White (1991-03-04): -# A recent excerpt from an Australian newspaper... -# ...South Australia...[has] agreed to end daylight saving -# at 3am tomorrow (March 3)... - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# # The state of SOUTH AUSTRALIA....[ Courtesy of S.A. Dept of Labour ] -# # [ Nov 1990 ] -# ... -# Zone Australia/South 9:30 AS %sST -# ... -# Rule AS 1971 max - Oct lastSun 2:00 1:00 D -# Rule AS 1972 1985 - Mar Sun>=1 3:00 0 C -# Rule AS 1986 1990 - Mar Sun>=15 3:00 0 C -# Rule AS 1991 max - Mar Sun>=1 3:00 0 C - -# From Bradley White (1992-03-11): -# Recent correspondence with a friend in Adelaide -# contained the following exchange: "Due to the Adelaide Festival, -# South Australia delays setting back our clocks for a few weeks." - -# From Robert Elz (1992-03-13): -# I heard that apparently (or at least, it appears that) -# South Aus will have an extra 3 weeks daylight saving every even -# numbered year (from 1990). That's when the Adelaide Festival -# is on... - -# From Robert Elz (1992-03-16, 00:57:07 +1000): -# DST didn't end in Adelaide today (yesterday).... -# But whether it's "4th Sunday" or "2nd last Sunday" I have no idea whatever... -# (it's just as likely to be "the Sunday we pick for this year"...). - -# From Bradley White (1994-04-11): -# If Sun, 15 March, 1992 was at +1030 as kre asserts, but yet Sun, 20 March, -# 1994 was at +0930 as John Connolly's customer seems to assert, then I can -# only conclude that the actual rule is more complicated.... - -# From John Warburton (1994-10-07): -# The new Daylight Savings dates for South Australia ... -# was gazetted in the Government Hansard on Sep 26 1994.... -# start on last Sunday in October and end in last sunday in March. - -# From Paul Eggert (2007-07-23): -# See "southeast Australia" above for 2008 and later. - -# Tasmania - -# The rules for 1967 through 1991 were reported by George Shepherd -# via Simon Woodhead via Robert Elz (1991-03-06): -# # The state of TASMANIA.. [Courtesy Tasmanian Dept of Premier + Cabinet ] -# # [ Nov 1990 ] - -# From Bill Hart via Guy Harris (1991-10-10): -# Oh yes, the new daylight savings rules are uniquely tasmanian, we have -# 6 weeks a year now when we are out of sync with the rest of Australia -# (but nothing new about that). - -# From Alex Livingston (1999-10-04): -# I heard on the ABC (Australian Broadcasting Corporation) radio news on the -# (long) weekend that Tasmania, which usually goes its own way in this regard, -# has decided to join with most of NSW, the ACT, and most of Victoria -# (Australia) and start daylight saving on the last Sunday in August in 2000 -# instead of the first Sunday in October. - -# Sim Alam (2000-07-03) reported a legal citation for the 2000/2001 rules: -# http://www.thelaw.tas.gov.au/fragview/42++1968+GS3A@EN+2000070300 - -# From Paul Eggert (2007-07-23): -# See "southeast Australia" above for 2008 and later. - -# Victoria - -# The rules for 1971 through 1991 were reported by George Shepherd -# via Simon Woodhead via Robert Elz (1991-03-06): -# # The state of VICTORIA.. [ Courtesy of Vic. Dept of Premier + Cabinet ] -# # [ Nov 1990 ] - -# From Scott Harrington (2001-08-29): -# On KQED's "City Arts and Lectures" program last night I heard an -# interesting story about daylight savings time. Dr. John Heilbron was -# discussing his book "The Sun in the Church: Cathedrals as Solar -# Observatories"[1], and in particular the Shrine of Remembrance[2] located -# in Melbourne, Australia. -# -# Apparently the shrine's main purpose is a beam of sunlight which -# illuminates a special spot on the floor at the 11th hour of the 11th day -# of the 11th month (Remembrance Day) every year in memory of Australia's -# fallen WWI soldiers. And if you go there on Nov. 11, at 11am local time, -# you will indeed see the sunbeam illuminate the special spot at the -# expected time. -# -# However, that is only because of some special mirror contraption that had -# to be employed, since due to daylight savings time, the true solar time of -# the remembrance moment occurs one hour later (or earlier?). Perhaps -# someone with more information on this jury-rig can tell us more. -# -# [1] http://www.hup.harvard.edu/catalog/HEISUN.html -# [2] http://www.shrine.org.au - -# From Paul Eggert (2007-07-23): -# See "southeast Australia" above for 2008 and later. - -# New South Wales - -# From Arthur David Olson: -# New South Wales and subjurisdictions have their own ideas of a fun time. -# Based on law library research by John Mackin, -# who notes: -# In Australia, time is not legislated federally, but rather by the -# individual states. Thus, while such terms as "Eastern Standard Time" -# [I mean, of course, Australian EST, not any other kind] are in common -# use, _they have NO REAL MEANING_, as they are not defined in the -# legislation. This is very important to understand. -# I have researched New South Wales time only... - -# From Eric Ulevik (1999-05-26): -# DST will start in NSW on the last Sunday of August, rather than the usual -# October in 2000. See: Matthew Moore, -# Two months more daylight saving, Sydney Morning Herald (1999-05-26). -# http://www.smh.com.au/news/9905/26/pageone/pageone4.html - -# From Paul Eggert (1999-09-27): -# See the following official NSW source: -# Daylight Saving in New South Wales. -# http://dir.gis.nsw.gov.au/cgi-bin/genobject/document/other/daylightsaving/tigGmZ -# -# Narrabri Shire (NSW) council has announced it will ignore the extension of -# daylight saving next year. See: -# Narrabri Council to ignore daylight saving -# http://abc.net.au/news/regionals/neweng/monthly/regeng-22jul1999-1.htm -# (1999-07-22). For now, we'll wait to see if this really happens. -# -# Victoria will follow NSW. See: -# Vic to extend daylight saving (1999-07-28) -# http://abc.net.au/local/news/olympics/1999/07/item19990728112314_1.htm -# -# However, South Australia rejected the DST request. See: -# South Australia rejects Olympics daylight savings request (1999-07-19) -# http://abc.net.au/news/olympics/1999/07/item19990719151754_1.htm -# -# Queensland also will not observe DST for the Olympics. See: -# Qld says no to daylight savings for Olympics -# http://abc.net.au/news/olympics/1999/06/item19990601114608_1.htm -# (1999-06-01), which quotes Queensland Premier Peter Beattie as saying -# "Look you've got to remember in my family when this came up last time -# I voted for it, my wife voted against it and she said to me it's all very -# well for you, you don't have to worry about getting the children out of -# bed, getting them to school, getting them to sleep at night. -# I've been through all this argument domestically...my wife rules." -# -# Broken Hill will stick with South Australian time in 2000. See: -# Broken Hill to be behind the times (1999-07-21) -# http://abc.net.au/news/regionals/brokenh/monthly/regbrok-21jul1999-6.htm - -# IATA SSIM (1998-09) says that the spring 2000 change for Australian -# Capital Territory, New South Wales except Lord Howe Island and Broken -# Hill, and Victoria will be August 27, presumably due to the Sydney Olympics. - -# From Eric Ulevik, referring to Sydney's Sun Herald (2000-08-13), page 29: -# The Queensland Premier Peter Beattie is encouraging northern NSW -# towns to use Queensland time. - -# From Paul Eggert (2007-07-23): -# See "southeast Australia" above for 2008 and later. - -# Yancowinna - -# From John Mackin (1989-01-04): -# 'Broken Hill' means the County of Yancowinna. - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# # YANCOWINNA.. [ Confirmation courtesy of Broken Hill Postmaster ] -# # [ Dec 1990 ] -# ... -# # Yancowinna uses Central Standard Time, despite [its] location on the -# # New South Wales side of the S.A. border. Most business and social dealings -# # are with CST zones, therefore CST is legislated by local government -# # although the switch to Summer Time occurs in line with N.S.W. There have -# # been years when this did not apply, but the historical data is not -# # presently available. -# Zone Australia/Yancowinna 9:30 AY %sST -# ... -# Rule AY 1971 1985 - Oct lastSun 2:00 1:00 D -# Rule AY 1972 only - Feb lastSun 3:00 0 C -# [followed by other Rules] - -# Lord Howe Island - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# LHI... [ Courtesy of Pauline Van Winsen ] -# [ Dec 1990 ] -# Lord Howe Island is located off the New South Wales coast, and is half an -# hour ahead of NSW time. - -# From James Lonergan, Secretary, Lord Howe Island Board (2000-01-27): -# Lord Howe Island summer time in 2000/2001 will commence on the same -# date as the rest of NSW (i.e. 2000-08-27). For your information the -# Lord Howe Island Board (controlling authority for the Island) is -# seeking the community's views on various options for summer time -# arrangements on the Island, e.g. advance clocks by 1 full hour -# instead of only 30 minutes. [Dependent] on the wishes of residents -# the Board may approach the NSW government to change the existing -# arrangements. The starting date for summer time on the Island will -# however always coincide with the rest of NSW. - -# From James Lonergan, Secretary, Lord Howe Island Board (2000-10-25): -# Lord Howe Island advances clocks by 30 minutes during DST in NSW and retards -# clocks by 30 minutes when DST finishes. Since DST was most recently -# introduced in NSW, the "changeover" time on the Island has been 02:00 as -# shown on clocks on LHI. I guess this means that for 30 minutes at the start -# of DST, LHI is actually 1 hour ahead of the rest of NSW. - -# From Paul Eggert (2006-03-22): -# For Lord Howe dates we use Shanks & Pottenger through 1989, and -# Lonergan thereafter. For times we use Lonergan. - -# From Paul Eggert (2007-07-23): -# See "southeast Australia" above for 2008 and later. - -# From Steffen Thorsen (2009-04-28): -# According to the official press release, South Australia's extended daylight -# saving period will continue with the same rules as used during the 2008-2009 -# summer (southern hemisphere). -# -# From -# http://www.safework.sa.gov.au/uploaded_files/DaylightDatesSet.pdf -# The extended daylight saving period that South Australia has been trialling -# for over the last year is now set to be ongoing. -# Daylight saving will continue to start on the first Sunday in October each -# year and finish on the first Sunday in April the following year. -# Industrial Relations Minister, Paul Caica, says this provides South Australia -# with a consistent half hour time difference with NSW, Victoria, Tasmania and -# the ACT for all 52 weeks of the year... -# -# We have a wrap-up here: -# https://www.timeanddate.com/news/time/south-australia-extends-dst.html -############################################################################### - -# New Zealand - -# From Mark Davies (1990-10-03): -# the 1989/90 year was a trial of an extended "daylight saving" period. -# This trial was deemed successful and the extended period adopted for -# subsequent years (with the addition of a further week at the start). -# source - phone call to Ministry of Internal Affairs Head Office. - -# From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06): -# # The Country of New Zealand (Australia's east island -) Gee they hate that! -# # or is Australia the west island of N.Z. -# # [ courtesy of Geoff Tribble.. Auckland N.Z. ] -# # [ Nov 1990 ] -# ... -# Rule NZ 1974 1988 - Oct lastSun 2:00 1:00 D -# Rule NZ 1989 max - Oct Sun>=1 2:00 1:00 D -# Rule NZ 1975 1989 - Mar Sun>=1 3:00 0 S -# Rule NZ 1990 max - Mar lastSun 3:00 0 S -# ... -# Zone NZ 12:00 NZ NZ%sT # New Zealand -# Zone NZ-CHAT 12:45 - NZ-CHAT # Chatham Island - -# From Arthur David Olson (1992-03-08): -# The chosen rules use the Davies October 8 values for the start of DST in 1989 -# rather than the October 1 value. - -# From Paul Eggert (1995-12-19); -# Shank & Pottenger report 2:00 for all autumn changes in Australia and NZ. -# Robert Uzgalis writes that the New Zealand Daylight -# Savings Time Order in Council dated 1990-06-18 specifies 2:00 standard -# time on both the first Sunday in October and the third Sunday in March. -# As with Australia, we'll assume the tradition is 2:00s, not 2:00. -# -# From Paul Eggert (2006-03-22): -# The Department of Internal Affairs (DIA) maintains a brief history, -# as does Carol Squires; see tz-link.html for the full references. -# Use these sources in preference to Shanks & Pottenger. -# -# For Chatham, IATA SSIM (1991/1999) gives the NZ rules but with -# transitions at 2:45 local standard time; this confirms that Chatham -# is always exactly 45 minutes ahead of Auckland. - -# From Colin Sharples (2007-04-30): -# DST will now start on the last Sunday in September, and end on the -# first Sunday in April. The changes take effect this year, meaning -# that DST will begin on 2007-09-30 2008-04-06. -# http://www.dia.govt.nz/diawebsite.nsf/wpg_URL/Services-Daylight-Saving-Daylight-saving-to-be-extended - -# From Paul Eggert (2014-07-14): -# Chatham Island time was formally standardized on 1957-01-01 by -# New Zealand's Standard Time Amendment Act 1956 (1956-10-26). -# https://www.austlii.edu.au/nz/legis/hist_act/staa19561956n100244.pdf -# According to Google Books snippet view, a speaker in the New Zealand -# parliamentary debates in 1956 said "Clause 78 makes provision for standard -# time in the Chatham Islands. The time there is 45 minutes in advance of New -# Zealand time. I understand that is the time they keep locally, anyhow." -# For now, assume this practice goes back to the introduction of standard time -# in New Zealand, as this would make Chatham Islands time almost exactly match -# LMT back when New Zealand was at UT +11:30; also, assume Chatham Islands did -# not observe New Zealand's prewar DST. - -############################################################################### - - -# Fiji - -# Howse writes (p 153) that in 1879 the British governor of Fiji -# enacted an ordinance standardizing the islands on Antipodean Time -# instead of the American system (which was one day behind). - -# From Rives McDow (1998-10-08): -# Fiji will introduce DST effective 0200 local time, 1998-11-01 -# until 0300 local time 1999-02-28. Each year the DST period will -# be from the first Sunday in November until the last Sunday in February. - -# From Paul Eggert (2000-01-08): -# IATA SSIM (1999-09) says DST ends 0100 local time. Go with McDow. - -# From the BBC World Service in -# http://news.bbc.co.uk/2/hi/asia-pacific/205226.stm (1998-10-31 16:03 UTC): -# The Fijian government says the main reasons for the time change is to -# improve productivity and reduce road accidents.... [T]he move is also -# intended to boost Fiji's ability to attract tourists to witness the dawning -# of the new millennium. - -# http://www.fiji.gov.fj/press/2000_09/2000_09_13-05.shtml (2000-09-13) -# reports that Fiji has discontinued DST. - - -# Kiribati - -# From Paul Eggert (1996-01-22): -# Today's _Wall Street Journal_ (page 1) reports that Kiribati -# "declared it the same day [throughout] the country as of Jan. 1, 1995" -# as part of the competition to be first into the 21st century. - -# From Kerry Shetline (2018-02-03): -# December 31 was the day that was skipped, so that the transition -# would be from Friday December 30, 1994 to Sunday January 1, 1995. -# From Paul Eggert (2018-02-04): -# One source for this is page 202 of: Bartky IR. One Time Fits All: -# The Campaigns for Global Uniformity (2007). - -# Kwajalein - -# In comp.risks 14.87 (26 August 1993), Peter Neumann writes: -# I wonder what happened in Kwajalein, where there was NO Friday, -# 1993-08-20. Thursday night at midnight Kwajalein switched sides with -# respect to the International Date Line, to rejoin its fellow islands, -# going from 11:59 p.m. Thursday to 12:00 m. Saturday in a blink. - - -# N Mariana Is, Guam - -# Howse writes (p 153) "The Spaniards, on the other hand, reached the -# Philippines and the Ladrones from America," and implies that the Ladrones -# (now called the Marianas) kept American date for quite some time. -# For now, we assume the Ladrones switched at the same time as the Philippines; -# see Asia/Manila. - -# US Public Law 106-564 (2000-12-23) made UT +10 the official standard time, -# under the name "Chamorro Standard Time". There is no official abbreviation, -# but Congressman Robert A. Underwood, author of the bill that became law, -# wrote in a press release (2000-12-27) that he will seek the use of "ChST". - - -# Micronesia - -# Alan Eugene Davis writes (1996-03-16), -# "I am certain, having lived there for the past decade, that 'Truk' -# (now properly known as Chuuk) ... is in the time zone GMT+10." -# -# Shanks & Pottenger write that Truk switched from UT +10 to +11 -# on 1978-10-01; ignore this for now. - -# From Paul Eggert (1999-10-29): -# The Federated States of Micronesia Visitors Board writes in -# The Federated States of Micronesia - Visitor Information (1999-01-26) -# http://www.fsmgov.org/info/clocks.html -# that Truk and Yap are UT +10, and Ponape and Kosrae are +11. -# We don't know when Kosrae switched from +12; assume January 1 for now. - - -# Midway - -# From Charles T O'Connor, KMTH DJ (1956), -# quoted in the KTMH section of the Radio Heritage Collection -# <http://radiodx.com/spdxr/KMTH.htm> (2002-12-31): -# For the past two months we've been on what is known as Daylight -# Saving Time. This time has put us on air at 5am in the morning, -# your time down there in New Zealand. Starting September 2, 1956 -# we'll again go back to Standard Time. This'll mean that we'll go to -# air at 6am your time. -# -# From Paul Eggert (2003-03-23): -# We don't know the date of that quote, but we'll guess they -# started DST on June 3. Possibly DST was observed other years -# in Midway, but we have no record of it. - -# Norfolk - -# From Alexander Krivenyshev (2015-09-23): -# Norfolk Island will change ... from +1130 to +1100: -# https://www.comlaw.gov.au/Details/F2015L01483/Explanatory%20Statement/Text -# ... at 12.30 am (by legal time in New South Wales) on 4 October 2015. -# http://www.norfolkisland.gov.nf/nia/MediaRelease/Media%20Release%20Norfolk%20Island%20Standard%20Time%20Change.pdf - -# From Paul Eggert (2015-09-23): -# Transitions before 2015 are from timeanddate.com, which consulted -# the Norfolk Island Museum and the Australian Bureau of Meteorology's -# Norfolk Island station, and found no record of Norfolk observing DST -# other than in 1974/5. See: -# https://www.timeanddate.com/time/australia/norfolk-island.html - -# Pitcairn - -# From Rives McDow (1999-11-08): -# A Proclamation was signed by the Governor of Pitcairn on the 27th March 1998 -# with regard to Pitcairn Standard Time. The Proclamation is as follows. -# -# The local time for general purposes in the Islands shall be -# Co-ordinated Universal time minus 8 hours and shall be known -# as Pitcairn Standard Time. -# -# ... I have also seen Pitcairn listed as UTC minus 9 hours in several -# references, and can only assume that this was an error in interpretation -# somehow in light of this proclamation. - -# From Rives McDow (1999-11-09): -# The Proclamation regarding Pitcairn time came into effect on 27 April 1998 -# ... at midnight. - -# From Howie Phelps (1999-11-10), who talked to a Pitcairner via shortwave: -# Betty Christian told me yesterday that their local time is the same as -# Pacific Standard Time. They used to be ½ hour different from us here in -# Sacramento but it was changed a couple of years ago. - - -# (Western) Samoa and American Samoa - -# Howse writes (p 153) that after the 1879 standardization on Antipodean -# time by the British governor of Fiji, the King of Samoa decided to change -# "the date in his kingdom from the Antipodean to the American system, -# ordaining - by a masterpiece of diplomatic flattery - that -# the Fourth of July should be celebrated twice in that year." -# This happened in 1892, according to the Evening News (Sydney) of 1892-07-20. -# https://www.staff.science.uu.nl/~gent0113/idl/idl.htm - -# Although Shanks & Pottenger says they both switched to UT -11:30 -# in 1911, and to -11 in 1950. many earlier sources give -11 -# for American Samoa, e.g., the US National Bureau of Standards -# circular "Standard Time Throughout the World", 1932. -# Assume American Samoa switched to -11 in 1911, not 1950, -# and that after 1950 they agreed until (western) Samoa skipped a -# day in 2011. Assume also that the Samoas follow the US and New -# Zealand's "ST"/"DT" style of daylight-saving abbreviations. - - -# Tonga - -# From Paul Eggert (1996-01-22): -# Today's _Wall Street Journal_ (p 1) reports that "Tonga has been plotting -# to sneak ahead of [New Zealanders] by introducing daylight-saving time." -# Since Kiribati has moved the Date Line it's not clear what Tonga will do. - -# Don Mundell writes in the 1997-02-20 Tonga Chronicle -# How Tonga became 'The Land where Time Begins': -# http://www.tongatapu.net.to/tonga/homeland/timebegins.htm -# -# Until 1941 Tonga maintained a standard time 50 minutes ahead of NZST -# 12 hours and 20 minutes ahead of GMT. When New Zealand adjusted its -# standard time in 1940s, Tonga had the choice of subtracting from its -# local time to come on the same standard time as New Zealand or of -# advancing its time to maintain the differential of 13° -# (approximately 50 minutes ahead of New Zealand time). -# -# Because His Majesty King Tāufaʻāhau Tupou IV, then Crown Prince -# Tungī, preferred to ensure Tonga's title as the land where time -# begins, the Legislative Assembly approved the latter change. -# -# But some of the older, more conservative members from the outer -# islands objected. "If at midnight on Dec. 31, we move ahead 40 -# minutes, as your Royal Highness wishes, what becomes of the 40 -# minutes we have lost?" -# -# The Crown Prince, presented an unanswerable argument: "Remember that -# on the World Day of Prayer, you would be the first people on Earth -# to say your prayers in the morning." - -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger say the transition was on 1968-10-01; go with Mundell. - -# From Eric Ulevik (1999-05-03): -# Tonga's director of tourism, who is also secretary of the National Millennium -# Committee, has a plan to get Tonga back in front. -# He has proposed a one-off move to tropical daylight saving for Tonga from -# October to March, which has won approval in principle from the Tongan -# Government. - -# From Steffen Thorsen (1999-09-09): -# * Tonga will introduce DST in November -# -# I was given this link by John Letts: -# http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm -# -# I have not been able to find exact dates for the transition in November -# yet. By reading this article it seems like Fiji will be 14 hours ahead -# of UTC as well, but as far as I know Fiji will only be 13 hours ahead -# (12 + 1 hour DST). - -# From Arthur David Olson (1999-09-20): -# According to <http://www.tongaonline.com/news/sept1799.html>: -# "Daylight Savings Time will take effect on Oct. 2 through April 15, 2000 -# and annually thereafter from the first Saturday in October through the -# third Saturday of April. Under the system approved by Privy Council on -# Sept. 10, clocks must be turned ahead one hour on the opening day and -# set back an hour on the closing date." -# Alas, no indication of the time of day. - -# From Rives McDow (1999-10-06): -# Tonga started its Daylight Saving on Saturday morning October 2nd at 0200am. -# Daylight Saving ends on April 16 at 0300am which is Sunday morning. - -# From Steffen Thorsen (2000-10-31): -# Back in March I found a notice on the website http://www.tongaonline.com -# that Tonga changed back to standard time one month early, on March 19 -# instead of the original reported date April 16. Unfortunately, the article -# is no longer available on the site, and I did not make a copy of the -# text, and I have forgotten to report it here. -# (Original URL was <http://www.tongaonline.com/news/march162000.htm>) - -# From Rives McDow (2000-12-01): -# Tonga is observing DST as of 2000-11-04 and will stop on 2001-01-27. - -# From Sione Moala-Mafi (2001-09-20) via Rives McDow: -# At 2:00am on the first Sunday of November, the standard time in the Kingdom -# shall be moved forward by one hour to 3:00am. At 2:00am on the last Sunday -# of January the standard time in the Kingdom shall be moved backward by one -# hour to 1:00am. - -# From Pulu ʻAnau (2002-11-05): -# The law was for 3 years, supposedly to get renewed. It wasn't. - -# From Pulu ʻAnau (2016-10-27): -# http://mic.gov.to/news-today/press-releases/6375-daylight-saving-set-to-run-from-6-november-2016-to-15-january-2017 -# Cannot find anyone who knows the rules, has seen the duration or has seen -# the cabinet decision, but it appears we are following Fiji's rule set. -# -# From Tim Parenti (2016-10-26): -# Assume Tonga will observe DST from the first Sunday in November at 02:00 -# through the third Sunday in January at 03:00, like Fiji, for now. - -# From David Wade (2017-10-18): -# In August government was disolved by the King. The current prime minister -# continued in office in care taker mode. It is easy to see that few -# decisions will be made until elections 16th November. -# -# From Paul Eggert (2017-10-18): -# For now, guess that DST is discontinued. That's what the IATA is guessing. - - -# Wake - -# From Vernice Anderson, Personal Secretary to Philip Jessup, -# US Ambassador At Large (oral history interview, 1971-02-02): -# -# Saturday, the 14th [of October, 1950] - ... The time was all the -# more confusing at that point, because we had crossed the -# International Date Line, thus getting two Sundays. Furthermore, we -# discovered that Wake Island had two hours of daylight saving time -# making calculation of time in Washington difficult if not almost -# impossible. -# -# https://www.trumanlibrary.org/oralhist/andrsonv.htm - -# From Paul Eggert (2003-03-23): -# We have no other report of DST in Wake Island, so omit this info for now. - -############################################################################### - -# The International Date Line - -# From Gwillim Law (2000-01-03): -# -# The International Date Line is not defined by any international standard, -# convention, or treaty. Mapmakers are free to draw it as they please. -# Reputable mapmakers will simply ensure that every point of land appears on -# the correct side of the IDL, according to the date legally observed there. -# -# When Kiribati adopted a uniform date in 1995, thereby moving the Phoenix and -# Line Islands to the west side of the IDL (or, if you prefer, moving the IDL -# to the east side of the Phoenix and Line Islands), I suppose that most -# mapmakers redrew the IDL following the boundary of Kiribati. Even that line -# has a rather arbitrary nature. The straight-line boundaries between Pacific -# island nations that are shown on many maps are based on an international -# convention, but are not legally binding national borders.... The date is -# governed by the IDL; therefore, even on the high seas, there may be some -# places as late as fourteen hours later than UTC. And, since the IDL is not -# an international standard, there are some places on the high seas where the -# correct date is ambiguous. - -# From Wikipedia <https://en.wikipedia.org/wiki/Time_zone> (2005-08-31): -# Before 1920, all ships kept local apparent time on the high seas by setting -# their clocks at night or at the morning sight so that, given the ship's -# speed and direction, it would be 12 o'clock when the Sun crossed the ship's -# meridian (12 o'clock = local apparent noon). During 1917, at the -# Anglo-French Conference on Time-keeping at Sea, it was recommended that all -# ships, both military and civilian, should adopt hourly standard time zones -# on the high seas. Whenever a ship was within the territorial waters of any -# nation it would use that nation's standard time. The captain was permitted -# to change his ship's clocks at a time of his choice following his ship's -# entry into another zone time - he often chose midnight. These zones were -# adopted by all major fleets between 1920 and 1925 but not by many -# independent merchant ships until World War II. - -# From Paul Eggert, using references suggested by Oscar van Vlijmen -# (2005-03-20): -# -# The American Practical Navigator (2002) -# http://pollux.nss.nima.mil/pubs/pubs_j_apn_sections.html?rid=187 -# talks only about the 180-degree meridian with respect to ships in -# international waters; it ignores the international date line. diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/backward b/src/test/jdk/sun/util/calendar/zi/tzdata/backward deleted file mode 100644 index f30f30e511b..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/backward +++ /dev/null @@ -1,153 +0,0 @@ -# -# 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. -# -# tzdb links for backward compatibility - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# This file provides links between current names for timezones -# and their old names. Many names changed in late 1993. - -# Link TARGET LINK-NAME -Link Africa/Nairobi Africa/Asmera -Link Africa/Abidjan Africa/Timbuktu -Link America/Argentina/Catamarca America/Argentina/ComodRivadavia -Link America/Adak America/Atka -Link America/Argentina/Buenos_Aires America/Buenos_Aires -Link America/Argentina/Catamarca America/Catamarca -Link America/Atikokan America/Coral_Harbour -Link America/Argentina/Cordoba America/Cordoba -Link America/Tijuana America/Ensenada -Link America/Indiana/Indianapolis America/Fort_Wayne -Link America/Indiana/Indianapolis America/Indianapolis -Link America/Argentina/Jujuy America/Jujuy -Link America/Indiana/Knox America/Knox_IN -Link America/Kentucky/Louisville America/Louisville -Link America/Argentina/Mendoza America/Mendoza -Link America/Toronto America/Montreal -Link America/Rio_Branco America/Porto_Acre -Link America/Argentina/Cordoba America/Rosario -Link America/Tijuana America/Santa_Isabel -Link America/Denver America/Shiprock -Link America/Port_of_Spain America/Virgin -Link Pacific/Auckland Antarctica/South_Pole -Link Asia/Ashgabat Asia/Ashkhabad -Link Asia/Kolkata Asia/Calcutta -Link Asia/Shanghai Asia/Chongqing -Link Asia/Shanghai Asia/Chungking -Link Asia/Dhaka Asia/Dacca -Link Asia/Shanghai Asia/Harbin -Link Asia/Urumqi Asia/Kashgar -Link Asia/Kathmandu Asia/Katmandu -Link Asia/Macau Asia/Macao -Link Asia/Yangon Asia/Rangoon -Link Asia/Ho_Chi_Minh Asia/Saigon -Link Asia/Jerusalem Asia/Tel_Aviv -Link Asia/Thimphu Asia/Thimbu -Link Asia/Makassar Asia/Ujung_Pandang -Link Asia/Ulaanbaatar Asia/Ulan_Bator -Link Atlantic/Faroe Atlantic/Faeroe -Link Europe/Oslo Atlantic/Jan_Mayen -Link Australia/Sydney Australia/ACT -Link Australia/Sydney Australia/Canberra -Link Australia/Lord_Howe Australia/LHI -Link Australia/Sydney Australia/NSW -Link Australia/Darwin Australia/North -Link Australia/Brisbane Australia/Queensland -Link Australia/Adelaide Australia/South -Link Australia/Hobart Australia/Tasmania -Link Australia/Melbourne Australia/Victoria -Link Australia/Perth Australia/West -Link Australia/Broken_Hill Australia/Yancowinna -Link America/Rio_Branco Brazil/Acre -Link America/Noronha Brazil/DeNoronha -Link America/Sao_Paulo Brazil/East -Link America/Manaus Brazil/West -Link America/Halifax Canada/Atlantic -Link America/Winnipeg Canada/Central -# This line is commented out, as the name exceeded the 14-character limit -# and was an unused misnomer. -#Link America/Regina Canada/East-Saskatchewan -Link America/Toronto Canada/Eastern -Link America/Edmonton Canada/Mountain -Link America/St_Johns Canada/Newfoundland -Link America/Vancouver Canada/Pacific -Link America/Regina Canada/Saskatchewan -Link America/Whitehorse Canada/Yukon -Link America/Santiago Chile/Continental -Link Pacific/Easter Chile/EasterIsland -Link America/Havana Cuba -Link Africa/Cairo Egypt -Link Europe/Dublin Eire -Link Europe/London Europe/Belfast -Link Europe/Chisinau Europe/Tiraspol -Link Europe/London GB -Link Europe/London GB-Eire -Link Etc/GMT GMT+0 -Link Etc/GMT GMT-0 -Link Etc/GMT GMT0 -Link Etc/GMT Greenwich -Link Asia/Hong_Kong Hongkong -Link Atlantic/Reykjavik Iceland -Link Asia/Tehran Iran -Link Asia/Jerusalem Israel -Link America/Jamaica Jamaica -Link Asia/Tokyo Japan -Link Pacific/Kwajalein Kwajalein -Link Africa/Tripoli Libya -Link America/Tijuana Mexico/BajaNorte -Link America/Mazatlan Mexico/BajaSur -Link America/Mexico_City Mexico/General -Link Pacific/Auckland NZ -Link Pacific/Chatham NZ-CHAT -Link America/Denver Navajo -Link Asia/Shanghai PRC -Link Pacific/Honolulu Pacific/Johnston -Link Pacific/Pohnpei Pacific/Ponape -Link Pacific/Pago_Pago Pacific/Samoa -Link Pacific/Chuuk Pacific/Truk -Link Pacific/Chuuk Pacific/Yap -Link Europe/Warsaw Poland -Link Europe/Lisbon Portugal -Link Asia/Taipei ROC -Link Asia/Seoul ROK -Link Asia/Singapore Singapore -Link Europe/Istanbul Turkey -Link Etc/UCT UCT -Link America/Anchorage US/Alaska -Link America/Adak US/Aleutian -Link America/Phoenix US/Arizona -Link America/Chicago US/Central -Link America/Indiana/Indianapolis US/East-Indiana -Link America/New_York US/Eastern -Link Pacific/Honolulu US/Hawaii -Link America/Indiana/Knox US/Indiana-Starke -Link America/Detroit US/Michigan -Link America/Denver US/Mountain -Link America/Los_Angeles US/Pacific -Link Pacific/Pago_Pago US/Samoa -Link Etc/UTC UTC -Link Etc/UTC Universal -Link Europe/Moscow W-SU -Link Etc/UTC Zulu diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/etcetera b/src/test/jdk/sun/util/calendar/zi/tzdata/etcetera deleted file mode 100644 index db5937879e0..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/etcetera +++ /dev/null @@ -1,103 +0,0 @@ -# -# 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. -# -# tzdb data for ships at sea and other miscellany - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# These entries are mostly present for historical reasons, so that -# people in areas not otherwise covered by the tz files could "zic -l" -# to a timezone that was right for their area. These days, the -# tz files cover almost all the inhabited world, and the only practical -# need now for the entries that are not on UTC are for ships at sea -# that cannot use POSIX TZ settings. - -# Starting with POSIX 1003.1-2001, the entries below are all -# unnecessary as settings for the TZ environment variable. E.g., -# instead of TZ='Etc/GMT+4' one can use the POSIX setting TZ='<-04>+4'. -# -# Do not use a POSIX TZ setting like TZ='GMT+4', which is four hours -# behind GMT but uses the completely misleading abbreviation "GMT". - -Zone Etc/GMT 0 - GMT -Zone Etc/UTC 0 - UTC -Zone Etc/UCT 0 - UCT - -# The following link uses older naming conventions, -# but it belongs here, not in the file 'backward', -# as functions like gmtime load the "GMT" file to handle leap seconds properly. -# We want this to work even on installations that omit the other older names. -Link Etc/GMT GMT - -Link Etc/UTC Etc/Universal -Link Etc/UTC Etc/Zulu - -Link Etc/GMT Etc/Greenwich -Link Etc/GMT Etc/GMT-0 -Link Etc/GMT Etc/GMT+0 -Link Etc/GMT Etc/GMT0 - -# Be consistent with POSIX TZ settings in the Zone names, -# even though this is the opposite of what many people expect. -# POSIX has positive signs west of Greenwich, but many people expect -# positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses -# the abbreviation "-04" and corresponds to 4 hours behind UT -# (i.e. west of Greenwich) even though many people would expect it to -# mean 4 hours ahead of UT (i.e. east of Greenwich). - -# Earlier incarnations of this package were not POSIX-compliant, -# and had lines such as -# Zone GMT-12 -12 - GMT-1200 -# We did not want things to change quietly if someone accustomed to the old -# way does a -# zic -l GMT-12 -# so we moved the names into the Etc subdirectory. -# Also, the time zone abbreviations are now compatible with %z. - -Zone Etc/GMT-14 14 - +14 -Zone Etc/GMT-13 13 - +13 -Zone Etc/GMT-12 12 - +12 -Zone Etc/GMT-11 11 - +11 -Zone Etc/GMT-10 10 - +10 -Zone Etc/GMT-9 9 - +09 -Zone Etc/GMT-8 8 - +08 -Zone Etc/GMT-7 7 - +07 -Zone Etc/GMT-6 6 - +06 -Zone Etc/GMT-5 5 - +05 -Zone Etc/GMT-4 4 - +04 -Zone Etc/GMT-3 3 - +03 -Zone Etc/GMT-2 2 - +02 -Zone Etc/GMT-1 1 - +01 -Zone Etc/GMT+1 -1 - -01 -Zone Etc/GMT+2 -2 - -02 -Zone Etc/GMT+3 -3 - -03 -Zone Etc/GMT+4 -4 - -04 -Zone Etc/GMT+5 -5 - -05 -Zone Etc/GMT+6 -6 - -06 -Zone Etc/GMT+7 -7 - -07 -Zone Etc/GMT+8 -8 - -08 -Zone Etc/GMT+9 -9 - -09 -Zone Etc/GMT+10 -10 - -10 -Zone Etc/GMT+11 -11 - -11 -Zone Etc/GMT+12 -12 - -12 diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/europe b/src/test/jdk/sun/util/calendar/zi/tzdata/europe deleted file mode 100644 index e434b7e9fc4..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/europe +++ /dev/null @@ -1,4018 +0,0 @@ -# -# 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. -# -# tzdb data for Europe and environs - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# This file is by no means authoritative; if you think you know better, -# go ahead and edit the file (and please send any changes to -# tz@iana.org for general use in the future). For more, please see -# the file CONTRIBUTING in the tz distribution. - -# From Paul Eggert (2017-02-10): -# -# Unless otherwise specified, the source for data through 1990 is: -# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), -# San Diego: ACS Publications, Inc. (2003). -# Unfortunately this book contains many errors and cites no sources. -# -# Many years ago Gwillim Law wrote that a good source -# for time zone data was the International Air Transport -# Association's Standard Schedules Information Manual (IATA SSIM), -# published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. Except where otherwise noted, -# IATA SSIM is the source for entries after 1990. -# -# A reliable and entertaining source about time zones is -# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1991, and IATA SSIM is the source for entries afterwards. -# -# Other sources occasionally used include: -# -# Edward W. Whitman, World Time Differences, -# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), -# which I found in the UCLA library. -# -# William Willett, The Waste of Daylight, 19th edition -# <http://cs.ucla.edu/~eggert/The-Waste-of-Daylight-19th.pdf> -# [PDF] (1914-03) -# -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94 -# <https://www.jstor.org/stable/1774359>. He writes: -# "It is requested that corrections and additions to these tables -# may be sent to Mr. John Milne, Royal Geographical Society, -# Savile Row, London." Nowadays please email them to tz@iana.org. -# -# Byalokoz EL. New Counting of Time in Russia since July 1, 1919. -# This Russian-language source was consulted by Vladimir Karpinsky; see -# https://mm.icann.org/pipermail/tz/2014-August/021320.html -# The full Russian citation is: -# Бялокоз, Евгений Людвигович. Новый счет времени в течении суток -# введенный декретом Совета народных комиссаров для всей России с 1-го -# июля 1919 г. / Изд. 2-е Междуведомственной комиссии. - Петроград: -# Десятая гос. тип., 1919. -# http://resolver.gpntb.ru/purl?docushare/dsweb/Get/Resource-2011/Byalokoz__E.L.__Novyy__schet__vremeni__v__techenie__sutok__izd__2(1).pdf -# -# Brazil's Divisão Serviço da Hora (DSHO), -# History of Summer Time -# <http://pcdsh01.on.br/HISTHV.htm> -# (1998-09-21, in Portuguese) -# -# I invented the abbreviations marked '*' in the following table; -# the rest are variants of the "xMT" pattern for a city's mean time, -# or are from other sources. Corrections are welcome! -# std dst 2dst -# LMT Local Mean Time -# -4:00 AST ADT Atlantic -# 0:00 GMT BST BDST Greenwich, British Summer -# 0:00 GMT IST Greenwich, Irish Summer -# 0:00 WET WEST WEMT Western Europe -# 0:19:32.13 AMT* NST* Amsterdam, Netherlands Summer (1835-1937) -# 1:00 BST British Standard (1968-1971) -# 1:00 IST GMT Irish Standard (1968-) with winter DST -# 1:00 CET CEST CEMT Central Europe -# 1:00:14 SET Swedish (1879-1899) -# 1:36:34 RMT* LST* Riga, Latvian Summer (1880-1926)* -# 2:00 EET EEST Eastern Europe -# 3:00 MSK MSD MDST* Moscow - -# From Peter Ilieve (1994-12-04), re EEC/EC/EU members: -# The original six: Belgium, France, (West) Germany, Italy, -# Luxembourg, the Netherlands. -# Plus, from 1 Jan 73: Denmark, Ireland, United Kingdom. -# Plus, from 1 Jan 81: Greece. -# Plus, from 1 Jan 86: Spain, Portugal. -# Plus, from 1 Jan 95: Austria, Finland, Sweden. (Norway negotiated terms for -# entry but in a referendum on 28 Nov 94 the people voted No by 52.2% to 47.8% -# on a turnout of 88.6%. This was almost the same result as Norway's previous -# referendum in 1972, they are the only country to have said No twice. -# Referendums in the other three countries voted Yes.) -# ... -# Estonia ... uses EU dates but not at 01:00 GMT, they use midnight GMT. -# I don't think they know yet what they will do from 1996 onwards. -# ... -# There shouldn't be any [current members who are not using EU rules]. -# A Directive has the force of law, member states are obliged to enact -# national law to implement it. The only contentious issue was the -# different end date for the UK and Ireland, and this was always allowed -# in the Directive. - - -############################################################################### - -# Britain (United Kingdom) and Ireland (Eire) - -# From Peter Ilieve (1994-07-06): -# -# On 17 Jan 1994 the Independent, a UK quality newspaper, had a piece about -# historical vistas along the Thames in west London. There was a photo -# and a sketch map showing some of the sightlines involved. One paragraph -# of the text said: -# -# 'An old stone obelisk marking a forgotten terrestrial meridian stands -# beside the river at Kew. In the 18th century, before time and longitude -# was standardised by the Royal Observatory in Greenwich, scholars observed -# this stone and the movement of stars from Kew Observatory nearby. They -# made their calculations and set the time for the Horse Guards and Parliament, -# but now the stone is obscured by scrubwood and can only be seen by walking -# along the towpath within a few yards of it.' -# -# I have a one inch to one mile map of London and my estimate of the stone's -# position is 51° 28' 30" N, 0° 18' 45" W. The longitude should -# be within about ±2". The Ordnance Survey grid reference is TQ172761. -# -# [This yields GMTOFF = -0:01:15 for London LMT in the 18th century.] - -# From Paul Eggert (1993-11-18): -# -# Howse writes that Britain was the first country to use standard time. -# The railways cared most about the inconsistencies of local mean time, -# and it was they who forced a uniform time on the country. -# The original idea was credited to Dr. William Hyde Wollaston (1766-1828) -# and was popularized by Abraham Follett Osler (1808-1903). -# The first railway to adopt London time was the Great Western Railway -# in November 1840; other railways followed suit, and by 1847 most -# (though not all) railways used London time. On 1847-09-22 the -# Railway Clearing House, an industry standards body, recommended that GMT be -# adopted at all stations as soon as the General Post Office permitted it. -# The transition occurred on 12-01 for the L&NW, the Caledonian, -# and presumably other railways; the January 1848 Bradshaw's lists many -# railways as using GMT. By 1855 the vast majority of public -# clocks in Britain were set to GMT (though some, like the great clock -# on Tom Tower at Christ Church, Oxford, were fitted with two minute hands, -# one for local time and one for GMT). The last major holdout was the legal -# system, which stubbornly stuck to local time for many years, leading -# to oddities like polls opening at 08:13 and closing at 16:13. -# The legal system finally switched to GMT when the Statutes (Definition -# of Time) Act took effect; it received the Royal Assent on 1880-08-02. -# -# In the tables below, we condense this complicated story into a single -# transition date for London, namely 1847-12-01. We don't know as much -# about Dublin, so we use 1880-08-02, the legal transition time. - -# From Paul Eggert (2014-07-19): -# The ancients had no need for daylight saving, as they kept time -# informally or via hours whose length depended on the time of year. -# Daylight saving time in its modern sense was invented by the -# New Zealand entomologist George Vernon Hudson (1867-1946), -# whose day job as a postal clerk led him to value -# after-hours daylight in which to pursue his research. -# In 1895 he presented a paper to the Wellington Philosophical Society -# that proposed a two-hour daylight-saving shift. See: -# Hudson GV. On seasonal time-adjustment in countries south of lat. 30°. -# Transactions and Proceedings of the New Zealand Institute. 1895;28:734 -# http://rsnz.natlib.govt.nz/volume/rsnz_28/rsnz_28_00_006110.html -# Although some interest was expressed in New Zealand, his proposal -# did not find its way into law and eventually it was almost forgotten. -# -# In England, DST was independently reinvented by William Willett (1857-1915), -# a London builder and member of the Royal Astronomical Society -# who circulated a pamphlet "The Waste of Daylight" (1907) -# that proposed advancing clocks 20 minutes on each of four Sundays in April, -# and retarding them by the same amount on four Sundays in September. -# A bill was drafted in 1909 and introduced in Parliament several times, -# but it met with ridicule and opposition, especially from farming interests. -# Later editions of the pamphlet proposed one-hour summer time, and -# it was eventually adopted as a wartime measure in 1916. -# See: Summer Time Arrives Early, The Times (2000-05-18). -# A monument to Willett was unveiled on 1927-05-21, in an open space in -# a 45-acre wood near Chislehurst, Kent that was purchased by popular -# subscription and open to the public. On the south face of the monolith, -# designed by G. W. Miller, is the William Willett Memorial Sundial, -# which is permanently set to Summer Time. - -# From Winston Churchill (1934-04-28): -# It is one of the paradoxes of history that we should owe the boon of -# summer time, which gives every year to the people of this country -# between 160 and 170 hours more daylight leisure, to a war which -# plunged Europe into darkness for four years, and shook the -# foundations of civilization throughout the world. -# -- "A Silent Toast to William Willett", Pictorial Weekly; -# republished in Finest Hour (Spring 2002) 1(114):26 -# https://www.winstonchurchill.org/publications/finest-hour/finest-hour-114/a-silent-toast-to-william-willett-by-winston-s-churchill - -# From Paul Eggert (2015-08-08): -# The OED Supplement says that the English originally said "Daylight Saving" -# when they were debating the adoption of DST in 1908; but by 1916 this -# term appears only in quotes taken from DST's opponents, whereas the -# proponents (who eventually won the argument) are quoted as using "Summer". -# The term "Summer Time" was introduced by Herbert Samuel, Home Secretary; see: -# Viscount Samuel. Leisure in a Democracy. Cambridge University Press -# ISBN 978-1-107-49471-8 (1949, reissued 2015), p 8. - -# From Arthur David Olson (1989-01-19): -# A source at the British Information Office in New York avers that it's -# known as "British" Summer Time in all parts of the United Kingdom. - -# Date: 4 Jan 89 08:57:25 GMT (Wed) -# From: Jonathan Leffler -# [British Summer Time] is fixed annually by Act of Parliament. -# If you can predict what Parliament will do, you should be in -# politics making a fortune, not computing. - -# From Chris Carrier (1996-06-14): -# I remember reading in various wartime issues of the London Times the -# acronym BDST for British Double Summer Time. Look for the published -# time of sunrise and sunset in The Times, when BDST was in effect, and -# if you find a zone reference it will say, "All times B.D.S.T." - -# From Joseph S. Myers (1999-09-02): -# ... some military cables (WO 219/4100 - this is a copy from the -# main SHAEF archives held in the US National Archives, SHAEF/5252/8/516) -# agree that the usage is BDST (this appears in a message dated 17 Feb 1945). - -# From Joseph S. Myers (2000-10-03): -# On 18th April 1941, Sir Stephen Tallents of the BBC wrote to Sir -# Alexander Maxwell of the Home Office asking whether there was any -# official designation; the reply of the 21st was that there wasn't -# but he couldn't think of anything better than the "Double British -# Summer Time" that the BBC had been using informally. -# https://www.polyomino.org.uk/british-time/bbc-19410418.png -# https://www.polyomino.org.uk/british-time/ho-19410421.png - -# From Sir Alexander Maxwell in the above-mentioned letter (1941-04-21): -# [N]o official designation has as far as I know been adopted for the time -# which is to be introduced in May.... -# I cannot think of anything better than "Double British Summer Time" -# which could not be said to run counter to any official description. - -# From Paul Eggert (2000-10-02): -# Howse writes (p 157) 'DBST' too, but 'BDST' seems to have been common -# and follows the more usual convention of putting the location name first, -# so we use 'BDST'. - -# Peter Ilieve (1998-04-19) described at length -# the history of summer time legislation in the United Kingdom. -# Since 1998 Joseph S. Myers has been updating -# and extending this list, which can be found in -# https://www.polyomino.org.uk/british-time/ - -# From Joseph S. Myers (1998-01-06): -# -# The legal time in the UK outside of summer time is definitely GMT, not UTC; -# see Lord Tanlaw's speech -# https://www.publications.parliament.uk/pa/ld199798/ldhansrd/vo970611/text/70611-10.htm#70611-10_head0 -# (Lords Hansard 11 June 1997 columns 964 to 976). - -# From Paul Eggert (2006-03-22): -# -# For lack of other data, follow Shanks & Pottenger for Eire in 1940-1948. -# -# Given Ilieve and Myers's data, the following claims by Shanks & Pottenger -# are incorrect: -# * Wales did not switch from GMT to daylight saving time until -# 1921 Apr 3, when they began to conform with the rest of Great Britain. -# Actually, Wales was identical after 1880. -# * Eire had two transitions on 1916 Oct 1. -# It actually just had one transition. -# * Northern Ireland used single daylight saving time throughout WW II. -# Actually, it conformed to Britain. -# * GB-Eire changed standard time to 1 hour ahead of GMT on 1968-02-18. -# Actually, that date saw the usual switch to summer time. -# Standard time was not changed until 1968-10-27 (the clocks didn't change). -# -# Here is another incorrect claim by Shanks & Pottenger: -# * Jersey, Guernsey, and the Isle of Man did not switch from GMT -# to daylight saving time until 1921 Apr 3, when they began to -# conform with Great Britain. -# S.R.&O. 1916, No. 382 and HO 45/10811/312364 (quoted above) say otherwise. -# -# The following claim by Shanks & Pottenger is possible though doubtful; -# we'll ignore it for now. -# * Dublin's 1971-10-31 switch was at 02:00, even though London's was 03:00. - -# From Paul Eggert (2017-12-04): -# -# Dunsink Observatory (8 km NW of Dublin's center) was to Dublin as -# Greenwich was to London. For example: -# -# "Timeball on the ballast office is down. Dunsink time." -# -- James Joyce, Ulysses -# -# The abbreviation DMT stood for "Dublin Mean Time" or "Dunsink Mean Time"; -# this being Ireland, opinions differed. -# -# Whitman says Dublin/Dunsink Mean Time was UT-00:25:21, which agrees -# with measurements of recent visitors to the Meridian Room of Dunsink -# Observatory; see Malone D. Dunsink and timekeeping. 2016-01-24. -# <https://www.maths.tcd.ie/~dwmalone/time/dunsink.html>. Malone -# writes that the Nautical Almanac listed UT-00:25:22 until 1896, when -# it moved to UT-00:25:21.1 (I confirmed that the 1893 edition used -# the former and the 1896 edition used the latter). Evidently the -# news of this change propagated slowly, as Milne 1899 still lists -# UT-00:25:22 and cites the International Telegraph Bureau. As it is -# not clear that there was any practical significance to the change -# from UT-00:25:22 to UT-00:25:21.1 in civil timekeeping, omit this -# transition for now and just use the latter value, omitting its -# fraction since our format cannot represent fractions. - -# "Countess Markievicz ... claimed that the [1916] abolition of Dublin Mean Time -# was among various actions undertaken by the 'English' government that -# would 'put the whole country into the SF (Sinn Féin) camp'. She claimed -# Irish 'public feeling (was) outraged by forcing of English time on us'." -# -- Parsons M. Dublin lost its time zone - and 25 minutes - after 1916 Rising. -# Irish Times 2014-10-27. -# https://www.irishtimes.com/news/politics/dublin-lost-its-time-zone-and-25-minutes-after-1916-rising-1.1977411 - -# From Joseph S. Myers (2005-01-26): -# Irish laws are available online at <http://www.irishstatutebook.ie>. -# These include various relating to legal time, for example: -# -# ZZA13Y1923.html ZZA12Y1924.html ZZA8Y1925.html ZZSIV20PG1267.html -# -# ZZSI71Y1947.html ZZSI128Y1948.html ZZSI23Y1949.html ZZSI41Y1950.html -# ZZSI27Y1951.html ZZSI73Y1952.html -# -# ZZSI11Y1961.html ZZSI232Y1961.html ZZSI182Y1962.html -# ZZSI167Y1963.html ZZSI257Y1964.html ZZSI198Y1967.html -# ZZA23Y1968.html ZZA17Y1971.html -# -# ZZSI67Y1981.html ZZSI212Y1982.html ZZSI45Y1986.html -# ZZSI264Y1988.html ZZSI52Y1990.html ZZSI371Y1992.html -# ZZSI395Y1994.html ZZSI484Y1997.html ZZSI506Y2001.html -# -# [These are all relative to the root, e.g., the first is -# <http://www.irishstatutebook.ie/ZZA13Y1923.html>.] -# -# (These are those I found, but there could be more. In any case these -# should allow various updates to the comments in the europe file to cover -# the laws applicable in Ireland.) -# -# (Note that the time in the Republic of Ireland since 1968 has been defined -# in terms of standard time being GMT+1 with a period of winter time when it -# is GMT, rather than standard time being GMT with a period of summer time -# being GMT+1.) - -# From Paul Eggert (1999-03-28): -# Clive Feather (<news:859845706.26043.0@office.demon.net>, 1997-03-31) -# reports that Folkestone (Cheriton) Shuttle Terminal uses Concession Time -# (CT), equivalent to French civil time. -# Julian Hill (<news:36118128.5A14@virgin.net>, 1998-09-30) reports that -# trains between Dollands Moor (the freight facility next door) -# and Frethun run in CT. -# My admittedly uninformed guess is that the terminal has two authorities, -# the French concession operators and the British civil authorities, -# and that the time depends on who you're talking to. -# If, say, the British police were called to the station for some reason, -# I would expect the official police report to use GMT/BST and not CET/CEST. -# This is a borderline case, but for now let's stick to GMT/BST. - -# From an anonymous contributor (1996-06-02): -# The law governing time in Ireland is under Statutory Instrument SI 395/94, -# which gives force to European Union 7th Council Directive No. 94/21/EC. -# Under this directive, the Minister for Justice in Ireland makes appropriate -# regulations. I spoke this morning with the Secretary of the Department of -# Justice (tel +353 1 678 9711) who confirmed to me that the correct name is -# "Irish Summer Time", abbreviated to "IST". -# -# From Paul Eggert (2017-12-07): -# The 1996 anonymous contributor's goal was to determine the correct -# abbreviation for summer time in Dublin and so the contributor -# focused on the "IST", not on the "Irish Summer Time". Though the -# "IST" was correct, the "Irish Summer Time" appears to have been an -# error, as Ireland's Standard Time (Amendment) Act, 1971 states that -# standard time in Ireland remains at UT +01 and is observed in -# summer, and that Greenwich mean time is observed in winter. (Thanks -# to Derick Rethans for pointing out the error.) That is, when -# Ireland amended the 1968 act that established UT +01 as Irish -# Standard Time, it left standard time unchanged and established GMT -# as a negative daylight saving time in winter. So, in this database -# IST stands for Irish Summer Time for timestamps before 1968, and for -# Irish Standard Time after that. See: -# http://www.irishstatutebook.ie/eli/1971/act/17/enacted/en/print - -# Michael Deckers (2017-06-01) gave the following URLs for Ireland's -# Summer Time Act, 1925 and Summer Time Orders, 1926 and 1947: -# http://www.irishstatutebook.ie/eli/1925/act/8/enacted/en/print -# http://www.irishstatutebook.ie/eli/1926/sro/919/made/en/print -# http://www.irishstatutebook.ie/eli/1947/sro/71/made/en/print - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# Summer Time Act, 1916 -Rule GB-Eire 1916 only - May 21 2:00s 1:00 BST -Rule GB-Eire 1916 only - Oct 1 2:00s 0 GMT -# S.R.&O. 1917, No. 358 -Rule GB-Eire 1917 only - Apr 8 2:00s 1:00 BST -Rule GB-Eire 1917 only - Sep 17 2:00s 0 GMT -# S.R.&O. 1918, No. 274 -Rule GB-Eire 1918 only - Mar 24 2:00s 1:00 BST -Rule GB-Eire 1918 only - Sep 30 2:00s 0 GMT -# S.R.&O. 1919, No. 297 -Rule GB-Eire 1919 only - Mar 30 2:00s 1:00 BST -Rule GB-Eire 1919 only - Sep 29 2:00s 0 GMT -# S.R.&O. 1920, No. 458 -Rule GB-Eire 1920 only - Mar 28 2:00s 1:00 BST -# S.R.&O. 1920, No. 1844 -Rule GB-Eire 1920 only - Oct 25 2:00s 0 GMT -# S.R.&O. 1921, No. 363 -Rule GB-Eire 1921 only - Apr 3 2:00s 1:00 BST -Rule GB-Eire 1921 only - Oct 3 2:00s 0 GMT -# S.R.&O. 1922, No. 264 -Rule GB-Eire 1922 only - Mar 26 2:00s 1:00 BST -Rule GB-Eire 1922 only - Oct 8 2:00s 0 GMT -# The Summer Time Act, 1922 -Rule GB-Eire 1923 only - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1923 1924 - Sep Sun>=16 2:00s 0 GMT -Rule GB-Eire 1924 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1925 1926 - Apr Sun>=16 2:00s 1:00 BST -# The Summer Time Act, 1925 -Rule GB-Eire 1925 1938 - Oct Sun>=2 2:00s 0 GMT -Rule GB-Eire 1927 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1928 1929 - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1930 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1931 1932 - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1933 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1934 only - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1935 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1936 1937 - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1938 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1939 only - Apr Sun>=16 2:00s 1:00 BST -# S.R.&O. 1939, No. 1379 -Rule GB-Eire 1939 only - Nov Sun>=16 2:00s 0 GMT -# S.R.&O. 1940, No. 172 and No. 1883 -Rule GB-Eire 1940 only - Feb Sun>=23 2:00s 1:00 BST -# S.R.&O. 1941, No. 476 -Rule GB-Eire 1941 only - May Sun>=2 1:00s 2:00 BDST -Rule GB-Eire 1941 1943 - Aug Sun>=9 1:00s 1:00 BST -# S.R.&O. 1942, No. 506 -Rule GB-Eire 1942 1944 - Apr Sun>=2 1:00s 2:00 BDST -# S.R.&O. 1944, No. 932 -Rule GB-Eire 1944 only - Sep Sun>=16 1:00s 1:00 BST -# S.R.&O. 1945, No. 312 -Rule GB-Eire 1945 only - Apr Mon>=2 1:00s 2:00 BDST -Rule GB-Eire 1945 only - Jul Sun>=9 1:00s 1:00 BST -# S.R.&O. 1945, No. 1208 -Rule GB-Eire 1945 1946 - Oct Sun>=2 2:00s 0 GMT -Rule GB-Eire 1946 only - Apr Sun>=9 2:00s 1:00 BST -# The Summer Time Act, 1947 -Rule GB-Eire 1947 only - Mar 16 2:00s 1:00 BST -Rule GB-Eire 1947 only - Apr 13 1:00s 2:00 BDST -Rule GB-Eire 1947 only - Aug 10 1:00s 1:00 BST -Rule GB-Eire 1947 only - Nov 2 2:00s 0 GMT -# Summer Time Order, 1948 (S.I. 1948/495) -Rule GB-Eire 1948 only - Mar 14 2:00s 1:00 BST -Rule GB-Eire 1948 only - Oct 31 2:00s 0 GMT -# Summer Time Order, 1949 (S.I. 1949/373) -Rule GB-Eire 1949 only - Apr 3 2:00s 1:00 BST -Rule GB-Eire 1949 only - Oct 30 2:00s 0 GMT -# Summer Time Order, 1950 (S.I. 1950/518) -# Summer Time Order, 1951 (S.I. 1951/430) -# Summer Time Order, 1952 (S.I. 1952/451) -Rule GB-Eire 1950 1952 - Apr Sun>=14 2:00s 1:00 BST -Rule GB-Eire 1950 1952 - Oct Sun>=21 2:00s 0 GMT -# revert to the rules of the Summer Time Act, 1925 -Rule GB-Eire 1953 only - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1953 1960 - Oct Sun>=2 2:00s 0 GMT -Rule GB-Eire 1954 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1955 1956 - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1957 only - Apr Sun>=9 2:00s 1:00 BST -Rule GB-Eire 1958 1959 - Apr Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1960 only - Apr Sun>=9 2:00s 1:00 BST -# Summer Time Order, 1961 (S.I. 1961/71) -# Summer Time (1962) Order, 1961 (S.I. 1961/2465) -# Summer Time Order, 1963 (S.I. 1963/81) -Rule GB-Eire 1961 1963 - Mar lastSun 2:00s 1:00 BST -Rule GB-Eire 1961 1968 - Oct Sun>=23 2:00s 0 GMT -# Summer Time (1964) Order, 1963 (S.I. 1963/2101) -# Summer Time Order, 1964 (S.I. 1964/1201) -# Summer Time Order, 1967 (S.I. 1967/1148) -Rule GB-Eire 1964 1967 - Mar Sun>=19 2:00s 1:00 BST -# Summer Time Order, 1968 (S.I. 1968/117) -Rule GB-Eire 1968 only - Feb 18 2:00s 1:00 BST -# The British Standard Time Act, 1968 -# (no summer time) -# The Summer Time Act, 1972 -Rule GB-Eire 1972 1980 - Mar Sun>=16 2:00s 1:00 BST -Rule GB-Eire 1972 1980 - Oct Sun>=23 2:00s 0 GMT -# Summer Time Order, 1980 (S.I. 1980/1089) -# Summer Time Order, 1982 (S.I. 1982/1673) -# Summer Time Order, 1986 (S.I. 1986/223) -# Summer Time Order, 1988 (S.I. 1988/931) -Rule GB-Eire 1981 1995 - Mar lastSun 1:00u 1:00 BST -Rule GB-Eire 1981 1989 - Oct Sun>=23 1:00u 0 GMT -# Summer Time Order, 1989 (S.I. 1989/985) -# Summer Time Order, 1992 (S.I. 1992/1729) -# Summer Time Order 1994 (S.I. 1994/2798) -Rule GB-Eire 1990 1995 - Oct Sun>=22 1:00u 0 GMT -# Summer Time Order 1997 (S.I. 1997/2982) -# See EU for rules starting in 1996. -# -# Use Europe/London for Jersey, Guernsey, and the Isle of Man. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/London -0:01:15 - LMT 1847 Dec 1 0:00s - 0:00 GB-Eire %s 1968 Oct 27 - 1:00 - BST 1971 Oct 31 2:00u - 0:00 GB-Eire %s 1996 - 0:00 EU GMT/BST -Link Europe/London Europe/Jersey -Link Europe/London Europe/Guernsey -Link Europe/London Europe/Isle_of_Man - -# From Paul Eggert (2018-02-15): -# In January 2018 we discovered that the negative SAVE values in the -# Eire rules cause problems with tests for ICU: -# https://mm.icann.org/pipermail/tz/2018-January/025825.html -# and with tests for OpenJDK: -# https://mm.icann.org/pipermail/tz/2018-January/025822.html -# -# To work around this problem, the build procedure can translate the -# following data into two forms, one with negative SAVE values and the -# other form with a traditional approximation for Irish timestamps -# after 1971-10-31 02:00 UTC; although this approximation has tm_isdst -# flags that are reversed, its UTC offsets are correct and this often -# suffices. This source file currently uses only nonnegative SAVE -# values, but this is intended to change and downstream code should -# not rely on it. -# -# The following is like GB-Eire and EU, except with standard time in -# summer and negative daylight saving time in winter. It is for when -# negative SAVE values are used. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Eire 1971 only - Oct 31 2:00u -1:00 - -#Rule Eire 1972 1980 - Mar Sun>=16 2:00u 0 - -#Rule Eire 1972 1980 - Oct Sun>=23 2:00u -1:00 - -#Rule Eire 1981 max - Mar lastSun 1:00u 0 - -#Rule Eire 1981 1989 - Oct Sun>=23 1:00u -1:00 - -#Rule Eire 1990 1995 - Oct Sun>=22 1:00u -1:00 - -#Rule Eire 1996 max - Oct lastSun 1:00u -1:00 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 - -0:25:21 - DMT 1916 May 21 2:00s - -0:25:21 1:00 IST 1916 Oct 1 2:00s - 0:00 GB-Eire %s 1921 Dec 6 # independence - 0:00 GB-Eire GMT/IST 1940 Feb 25 2:00s - 0:00 1:00 IST 1946 Oct 6 2:00s - 0:00 - GMT 1947 Mar 16 2:00s - 0:00 1:00 IST 1947 Nov 2 2:00s - 0:00 - GMT 1948 Apr 18 2:00s - 0:00 GB-Eire GMT/IST 1968 Oct 27 -# The next line is for when negative SAVE values are used. -# 1:00 Eire IST/GMT -# These three lines are for when SAVE values are always nonnegative. - 1:00 - IST 1971 Oct 31 2:00u - 0:00 GB-Eire GMT/IST 1996 - 0:00 EU GMT/IST - - -############################################################################### - -# Europe - -# The following rules are for the European Union and for its -# predecessor organization, the European Communities. -# For brevity they are called "EU rules" elsewhere in this file. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule EU 1977 1980 - Apr Sun>=1 1:00u 1:00 S -Rule EU 1977 only - Sep lastSun 1:00u 0 - -Rule EU 1978 only - Oct 1 1:00u 0 - -Rule EU 1979 1995 - Sep lastSun 1:00u 0 - -Rule EU 1981 max - Mar lastSun 1:00u 1:00 S -Rule EU 1996 max - Oct lastSun 1:00u 0 - -# The most recent directive covers the years starting in 2002. See: -# Directive 2000/84/EC of the European Parliament and of the Council -# of 19 January 2001 on summer-time arrangements. -# http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32000L0084:EN:NOT - -# W-Eur differs from EU only in that W-Eur uses standard time. -Rule W-Eur 1977 1980 - Apr Sun>=1 1:00s 1:00 S -Rule W-Eur 1977 only - Sep lastSun 1:00s 0 - -Rule W-Eur 1978 only - Oct 1 1:00s 0 - -Rule W-Eur 1979 1995 - Sep lastSun 1:00s 0 - -Rule W-Eur 1981 max - Mar lastSun 1:00s 1:00 S -Rule W-Eur 1996 max - Oct lastSun 1:00s 0 - - -# Older C-Eur rules are for convenience in the tables. -# From 1977 on, C-Eur differs from EU only in that C-Eur uses standard time. -Rule C-Eur 1916 only - Apr 30 23:00 1:00 S -Rule C-Eur 1916 only - Oct 1 1:00 0 - -Rule C-Eur 1917 1918 - Apr Mon>=15 2:00s 1:00 S -Rule C-Eur 1917 1918 - Sep Mon>=15 2:00s 0 - -Rule C-Eur 1940 only - Apr 1 2:00s 1:00 S -Rule C-Eur 1942 only - Nov 2 2:00s 0 - -Rule C-Eur 1943 only - Mar 29 2:00s 1:00 S -Rule C-Eur 1943 only - Oct 4 2:00s 0 - -Rule C-Eur 1944 1945 - Apr Mon>=1 2:00s 1:00 S -# Whitman gives 1944 Oct 7; go with Shanks & Pottenger. -Rule C-Eur 1944 only - Oct 2 2:00s 0 - -# From Jesper Nørgaard Welen (2008-07-13): -# -# I found what is probably a typo of 2:00 which should perhaps be 2:00s -# in the C-Eur rule from tz database version 2008d (this part was -# corrected in version 2008d). The circumstantial evidence is simply the -# tz database itself, as seen below: -# -# Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 -# 0:00 France WE%sT 1945 Sep 16 3:00 -# -# Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15 -# 0:00 France WE%sT 1945 Sep 16 3:00 -# -# Zone Europe/Belgrade 1:22:00 - LMT 1884 -# 1:00 1:00 CEST 1945 Sep 16 2:00s -# -# Rule France 1945 only - Sep 16 3:00 0 - -# Rule Belgium 1945 only - Sep 16 2:00s 0 - -# Rule Neth 1945 only - Sep 16 2:00s 0 - -# -# The rule line to be changed is: -# -# Rule C-Eur 1945 only - Sep 16 2:00 0 - -# -# It seems that Paris, Monaco, Rule France, Rule Belgium all agree on -# 2:00 standard time, e.g. 3:00 local time. However there are no -# countries that use C-Eur rules in September 1945, so the only items -# affected are apparently these fictitious zones that translate acronyms -# CET and MET: -# -# Zone CET 1:00 C-Eur CE%sT -# Zone MET 1:00 C-Eur ME%sT -# -# It this is right then the corrected version would look like: -# -# Rule C-Eur 1945 only - Sep 16 2:00s 0 - -# -# A small step for mankind though 8-) -Rule C-Eur 1945 only - Sep 16 2:00s 0 - -Rule C-Eur 1977 1980 - Apr Sun>=1 2:00s 1:00 S -Rule C-Eur 1977 only - Sep lastSun 2:00s 0 - -Rule C-Eur 1978 only - Oct 1 2:00s 0 - -Rule C-Eur 1979 1995 - Sep lastSun 2:00s 0 - -Rule C-Eur 1981 max - Mar lastSun 2:00s 1:00 S -Rule C-Eur 1996 max - Oct lastSun 2:00s 0 - - -# E-Eur differs from EU only in that E-Eur switches at midnight local time. -Rule E-Eur 1977 1980 - Apr Sun>=1 0:00 1:00 S -Rule E-Eur 1977 only - Sep lastSun 0:00 0 - -Rule E-Eur 1978 only - Oct 1 0:00 0 - -Rule E-Eur 1979 1995 - Sep lastSun 0:00 0 - -Rule E-Eur 1981 max - Mar lastSun 0:00 1:00 S -Rule E-Eur 1996 max - Oct lastSun 0:00 0 - - - -# Daylight saving time for Russia and the Soviet Union -# -# The 1917-1921 decree URLs are from Alexander Belopolsky (2016-08-23). - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Russia 1917 only - Jul 1 23:00 1:00 MST # Moscow Summer Time -# -# Decree No. 142 (1917-12-22) http://istmat.info/node/28137 -Rule Russia 1917 only - Dec 28 0:00 0 MMT # Moscow Mean Time -# -# Decree No. 497 (1918-05-30) http://istmat.info/node/30001 -Rule Russia 1918 only - May 31 22:00 2:00 MDST # Moscow Double Summer Time -Rule Russia 1918 only - Sep 16 1:00 1:00 MST -# -# Decree No. 258 (1919-05-29) http://istmat.info/node/37949 -Rule Russia 1919 only - May 31 23:00 2:00 MDST -# -Rule Russia 1919 only - Jul 1 0:00u 1:00 MSD -Rule Russia 1919 only - Aug 16 0:00 0 MSK -# -# Decree No. 63 (1921-02-03) http://istmat.info/node/45840 -Rule Russia 1921 only - Feb 14 23:00 1:00 MSD -# -# Decree No. 121 (1921-03-07) http://istmat.info/node/45949 -Rule Russia 1921 only - Mar 20 23:00 2:00 +05 -# -Rule Russia 1921 only - Sep 1 0:00 1:00 MSD -Rule Russia 1921 only - Oct 1 0:00 0 - -# Act No. 925 of the Council of Ministers of the USSR (1980-10-24): -Rule Russia 1981 1984 - Apr 1 0:00 1:00 S -Rule Russia 1981 1983 - Oct 1 0:00 0 - -# Act No. 967 of the Council of Ministers of the USSR (1984-09-13), repeated in -# Act No. 227 of the Council of Ministers of the USSR (1989-03-14): -Rule Russia 1984 1995 - Sep lastSun 2:00s 0 - -Rule Russia 1985 2010 - Mar lastSun 2:00s 1:00 S -# -Rule Russia 1996 2010 - Oct lastSun 2:00s 0 - -# As described below, Russia's 2014 change affects Zone data, not Rule data. - -# From Stepan Golosunov (2016-03-07): -# Wikipedia and other sources refer to the Act of the Council of -# Ministers of the USSR from 1988-01-04 No. 5 and the Act of the -# Council of Ministers of the USSR from 1989-03-14 No. 227. -# -# I did not find full texts of these acts. For the 1989 one we have -# title at https://base.garant.ru/70754136/ : -# "About change in calculation of time on the territories of -# Lithuanian SSR, Latvian SSR and Estonian SSR, Astrakhan, -# Kaliningrad, Kirov, Kuybyshev, Ulyanovsk and Uralsk oblasts". -# And http://astrozet.net/files/Zones/DOC/RU/1980-925.txt appears to -# contain quotes from both acts: Since last Sunday of March 1988 rules -# of the second time belt are installed in Volgograd and Saratov -# oblasts. Since last Sunday of March 1989: -# a) Lithuanian SSR, Latvian SSR, Estonian SSR, Kaliningrad oblast: -# second time belt rules without extra hour (Moscow-1); -# b) Astrakhan, Kirov, Kuybyshev, Ulyanovsk oblasts: second time belt -# rules (Moscow time) -# c) Uralsk oblast: third time belt rules (Moscow+1). - -# From Stepan Golosunov (2016-03-27): -# Unamended version of the act of the -# Government of the Russian Federation No. 23 from 08.01.1992 -# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102014034&rdk=0 -# says that every year clocks were to be moved forward on last Sunday -# of March at 2 hours and moved backwards on last Sunday of September -# at 3 hours. It was amended in 1996 to replace September with October. - -# From Alexander Krivenyshev (2011-06-14): -# According to Kremlin press service, Russian President Dmitry Medvedev -# signed a federal law "On calculation of time" on June 9, 2011. -# According to the law Russia is abolishing daylight saving time. -# -# Medvedev signed a law "On the Calculation of Time" (in russian): -# http://bmockbe.ru/events/?ID=7583 -# -# Medvedev signed a law on the calculation of the time (in russian): -# https://www.regnum.ru/news/polit/1413906.html - -# From Arthur David Olson (2011-06-15): -# Take "abolishing daylight saving time" to mean that time is now considered -# to be standard. - -# These are for backward compatibility with older versions. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone WET 0:00 EU WE%sT -Zone CET 1:00 C-Eur CE%sT -Zone MET 1:00 C-Eur ME%sT -Zone EET 2:00 EU EE%sT - -# Previous editions of this database used abbreviations like MET DST -# for Central European Summer Time, but this didn't agree with common usage. - -# From Markus Kuhn (1996-07-12): -# The official German names ... are -# -# Mitteleuropäische Zeit (MEZ) = UTC+01:00 -# Mitteleuropäische Sommerzeit (MESZ) = UTC+02:00 -# -# as defined in the German Time Act (Gesetz über die Zeitbestimmung (ZeitG), -# 1978-07-25, Bundesgesetzblatt, Jahrgang 1978, Teil I, S. 1110-1111).... -# I wrote ... to the German Federal Physical-Technical Institution -# -# Physikalisch-Technische Bundesanstalt (PTB) -# Laboratorium 4.41 "Zeiteinheit" -# Postfach 3345 -# D-38023 Braunschweig -# phone: +49 531 592-0 -# -# ... I received today an answer letter from Dr. Peter Hetzel, head of the PTB -# department for time and frequency transmission. He explained that the -# PTB translates MEZ and MESZ into English as -# -# Central European Time (CET) = UTC+01:00 -# Central European Summer Time (CEST) = UTC+02:00 - - -# Albania -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Albania 1940 only - Jun 16 0:00 1:00 S -Rule Albania 1942 only - Nov 2 3:00 0 - -Rule Albania 1943 only - Mar 29 2:00 1:00 S -Rule Albania 1943 only - Apr 10 3:00 0 - -Rule Albania 1974 only - May 4 0:00 1:00 S -Rule Albania 1974 only - Oct 2 0:00 0 - -Rule Albania 1975 only - May 1 0:00 1:00 S -Rule Albania 1975 only - Oct 2 0:00 0 - -Rule Albania 1976 only - May 2 0:00 1:00 S -Rule Albania 1976 only - Oct 3 0:00 0 - -Rule Albania 1977 only - May 8 0:00 1:00 S -Rule Albania 1977 only - Oct 2 0:00 0 - -Rule Albania 1978 only - May 6 0:00 1:00 S -Rule Albania 1978 only - Oct 1 0:00 0 - -Rule Albania 1979 only - May 5 0:00 1:00 S -Rule Albania 1979 only - Sep 30 0:00 0 - -Rule Albania 1980 only - May 3 0:00 1:00 S -Rule Albania 1980 only - Oct 4 0:00 0 - -Rule Albania 1981 only - Apr 26 0:00 1:00 S -Rule Albania 1981 only - Sep 27 0:00 0 - -Rule Albania 1982 only - May 2 0:00 1:00 S -Rule Albania 1982 only - Oct 3 0:00 0 - -Rule Albania 1983 only - Apr 18 0:00 1:00 S -Rule Albania 1983 only - Oct 1 0:00 0 - -Rule Albania 1984 only - Apr 1 0:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Tirane 1:19:20 - LMT 1914 - 1:00 - CET 1940 Jun 16 - 1:00 Albania CE%sT 1984 Jul - 1:00 EU CE%sT - -# Andorra -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Andorra 0:06:04 - LMT 1901 - 0:00 - WET 1946 Sep 30 - 1:00 - CET 1985 Mar 31 2:00 - 1:00 EU CE%sT - -# Austria - -# Milne says Vienna time was 1:05:21. - -# From Paul Eggert (2006-03-22): Shanks & Pottenger give 1918-06-16 and -# 1945-11-18, but the Austrian Federal Office of Metrology and -# Surveying (BEV) gives 1918-09-16 and for Vienna gives the "alleged" -# date of 1945-04-12 with no time. For the 1980-04-06 transition -# Shanks & Pottenger give 02:00, the BEV 00:00. Go with the BEV, -# and guess 02:00 for 1945-04-12. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Austria 1920 only - Apr 5 2:00s 1:00 S -Rule Austria 1920 only - Sep 13 2:00s 0 - -Rule Austria 1946 only - Apr 14 2:00s 1:00 S -Rule Austria 1946 1948 - Oct Sun>=1 2:00s 0 - -Rule Austria 1947 only - Apr 6 2:00s 1:00 S -Rule Austria 1948 only - Apr 18 2:00s 1:00 S -Rule Austria 1980 only - Apr 6 0:00 1:00 S -Rule Austria 1980 only - Sep 28 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Vienna 1:05:21 - LMT 1893 Apr - 1:00 C-Eur CE%sT 1920 - 1:00 Austria CE%sT 1940 Apr 1 2:00s - 1:00 C-Eur CE%sT 1945 Apr 2 2:00s - 1:00 1:00 CEST 1945 Apr 12 2:00s - 1:00 - CET 1946 - 1:00 Austria CE%sT 1981 - 1:00 EU CE%sT - -# Belarus -# -# From Stepan Golosunov (2016-07-02): -# http://www.lawbelarus.com/repub/sub30/texf9611.htm -# (Act of the Cabinet of Ministers of the Republic of Belarus from -# 1992-03-25 No. 157) ... says clocks were to be moved forward at 2:00 -# on last Sunday of March and backward at 3:00 on last Sunday of September -# (the same as previous USSR and contemporary Russian regulations). -# -# From Yauhen Kharuzhy (2011-09-16): -# By latest Belarus government act Europe/Minsk timezone was changed to -# GMT+3 without DST (was GMT+2 with DST). -# -# Sources (Russian language): -# http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html -# http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/ -# https://news.tut.by/society/250578.html -# -# From Alexander Bokovoy (2014-10-09): -# Belarussian government decided against changing to winter time.... -# http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Minsk 1:50:16 - LMT 1880 - 1:50 - MMT 1924 May 2 # Minsk Mean Time - 2:00 - EET 1930 Jun 21 - 3:00 - MSK 1941 Jun 28 - 1:00 C-Eur CE%sT 1944 Jul 3 - 3:00 Russia MSK/MSD 1990 - 3:00 - MSK 1991 Mar 31 2:00s - 2:00 Russia EE%sT 2011 Mar 27 2:00s - 3:00 - +03 - -# Belgium -# -# From Paul Eggert (1997-07-02): -# Entries from 1918 through 1991 are taken from: -# Annuaire de L'Observatoire Royal de Belgique, -# Avenue Circulaire, 3, B-1180 BRUXELLES, CLVIIe année, 1991 -# (Imprimerie HAYEZ, s.p.r.l., Rue Fin, 4, 1080 BRUXELLES, MCMXC), -# pp 8-9. -# LMT before 1892 was 0:17:30, according to the official journal of Belgium: -# Moniteur Belge, Samedi 30 Avril 1892, N.121. -# Thanks to Pascal Delmoitie for these references. -# The 1918 rules are listed for completeness; they apply to unoccupied Belgium. -# Assume Brussels switched to WET in 1918 when the armistice took effect. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Belgium 1918 only - Mar 9 0:00s 1:00 S -Rule Belgium 1918 1919 - Oct Sat>=1 23:00s 0 - -Rule Belgium 1919 only - Mar 1 23:00s 1:00 S -Rule Belgium 1920 only - Feb 14 23:00s 1:00 S -Rule Belgium 1920 only - Oct 23 23:00s 0 - -Rule Belgium 1921 only - Mar 14 23:00s 1:00 S -Rule Belgium 1921 only - Oct 25 23:00s 0 - -Rule Belgium 1922 only - Mar 25 23:00s 1:00 S -Rule Belgium 1922 1927 - Oct Sat>=1 23:00s 0 - -Rule Belgium 1923 only - Apr 21 23:00s 1:00 S -Rule Belgium 1924 only - Mar 29 23:00s 1:00 S -Rule Belgium 1925 only - Apr 4 23:00s 1:00 S -# DSH writes that a royal decree of 1926-02-22 specified the Sun following 3rd -# Sat in Apr (except if it's Easter, in which case it's one Sunday earlier), -# to Sun following 1st Sat in Oct, and that a royal decree of 1928-09-15 -# changed the transition times to 02:00 GMT. -Rule Belgium 1926 only - Apr 17 23:00s 1:00 S -Rule Belgium 1927 only - Apr 9 23:00s 1:00 S -Rule Belgium 1928 only - Apr 14 23:00s 1:00 S -Rule Belgium 1928 1938 - Oct Sun>=2 2:00s 0 - -Rule Belgium 1929 only - Apr 21 2:00s 1:00 S -Rule Belgium 1930 only - Apr 13 2:00s 1:00 S -Rule Belgium 1931 only - Apr 19 2:00s 1:00 S -Rule Belgium 1932 only - Apr 3 2:00s 1:00 S -Rule Belgium 1933 only - Mar 26 2:00s 1:00 S -Rule Belgium 1934 only - Apr 8 2:00s 1:00 S -Rule Belgium 1935 only - Mar 31 2:00s 1:00 S -Rule Belgium 1936 only - Apr 19 2:00s 1:00 S -Rule Belgium 1937 only - Apr 4 2:00s 1:00 S -Rule Belgium 1938 only - Mar 27 2:00s 1:00 S -Rule Belgium 1939 only - Apr 16 2:00s 1:00 S -Rule Belgium 1939 only - Nov 19 2:00s 0 - -Rule Belgium 1940 only - Feb 25 2:00s 1:00 S -Rule Belgium 1944 only - Sep 17 2:00s 0 - -Rule Belgium 1945 only - Apr 2 2:00s 1:00 S -Rule Belgium 1945 only - Sep 16 2:00s 0 - -Rule Belgium 1946 only - May 19 2:00s 1:00 S -Rule Belgium 1946 only - Oct 7 2:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Brussels 0:17:30 - LMT 1880 - 0:17:30 - BMT 1892 May 1 12:00 # Brussels MT - 0:00 - WET 1914 Nov 8 - 1:00 - CET 1916 May 1 0:00 - 1:00 C-Eur CE%sT 1918 Nov 11 11:00u - 0:00 Belgium WE%sT 1940 May 20 2:00s - 1:00 C-Eur CE%sT 1944 Sep 3 - 1:00 Belgium CE%sT 1977 - 1:00 EU CE%sT - -# Bosnia and Herzegovina -# See Europe/Belgrade. - -# Bulgaria -# -# From Plamen Simenov via Steffen Thorsen (1999-09-09): -# A document of Government of Bulgaria (No. 94/1997) says: -# EET -> EETDST is in 03:00 Local time in last Sunday of March ... -# EETDST -> EET is in 04:00 Local time in last Sunday of October -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Bulg 1979 only - Mar 31 23:00 1:00 S -Rule Bulg 1979 only - Oct 1 1:00 0 - -Rule Bulg 1980 1982 - Apr Sat>=1 23:00 1:00 S -Rule Bulg 1980 only - Sep 29 1:00 0 - -Rule Bulg 1981 only - Sep 27 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Sofia 1:33:16 - LMT 1880 - 1:56:56 - IMT 1894 Nov 30 # Istanbul MT? - 2:00 - EET 1942 Nov 2 3:00 - 1:00 C-Eur CE%sT 1945 - 1:00 - CET 1945 Apr 2 3:00 - 2:00 - EET 1979 Mar 31 23:00 - 2:00 Bulg EE%sT 1982 Sep 26 3:00 - 2:00 C-Eur EE%sT 1991 - 2:00 E-Eur EE%sT 1997 - 2:00 EU EE%sT - -# Croatia -# See Europe/Belgrade. - -# Cyprus -# Please see the 'asia' file for Asia/Nicosia. - -# Czech Republic / Czechia -# -# From Paul Eggert (2018-04-15): -# The source for Czech data is: Kdy začíná a končí letní čas. 2018-04-15. -# https://kalendar.beda.cz/kdy-zacina-a-konci-letni-cas -# We know of no English-language name for historical Czech winter time; -# abbreviate it as "GMT", as it happened to be GMT. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Czech 1945 only - Apr Mon>=1 2:00s 1:00 S -Rule Czech 1945 only - Oct 1 2:00s 0 - -Rule Czech 1946 only - May 6 2:00s 1:00 S -Rule Czech 1946 1949 - Oct Sun>=1 2:00s 0 - -Rule Czech 1947 1948 - Apr Sun>=15 2:00s 1:00 S -Rule Czech 1949 only - Apr 9 2:00s 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Prague 0:57:44 - LMT 1850 - 0:57:44 - PMT 1891 Oct # Prague Mean Time - 1:00 C-Eur CE%sT 1945 May 9 - 1:00 Czech CE%sT 1946 Dec 1 3:00 -# Vanguard section, for zic and other parsers that support negative DST. -# 1:00 -1:00 GMT 1947 Feb 23 2:00 -# Rearguard section, for parsers that do not support negative DST. - 0:00 - GMT 1947 Feb 23 2:00 -# End of rearguard section. - 1:00 Czech CE%sT 1979 - 1:00 EU CE%sT -# Use Europe/Prague also for Slovakia. - -# Denmark, Faroe Islands, and Greenland - -# From Jesper Nørgaard Welen (2005-04-26): -# http://www.hum.aau.dk/~poe/tid/tine/DanskTid.htm says that the law -# [introducing standard time] was in effect from 1894-01-01.... -# The page http://www.retsinfo.dk/_GETDOCI_/ACCN/A18930008330-REGL -# confirms this, and states that the law was put forth 1893-03-29. -# -# The EU [actually, EEC and Euratom] treaty with effect from 1973: -# http://www.retsinfo.dk/_GETDOCI_/ACCN/A19722110030-REGL -# -# This provoked a new law from 1974 to make possible summer time changes -# in subsequent decrees with the law -# http://www.retsinfo.dk/_GETDOCI_/ACCN/A19740022330-REGL -# -# It seems however that no decree was set forward until 1980. I have -# not found any decree, but in another related law, the effecting DST -# changes are stated explicitly to be from 1980-04-06 at 02:00 to -# 1980-09-28 at 02:00. If this is true, this differs slightly from -# the EU rule in that DST runs to 02:00, not 03:00. We don't know -# when Denmark began using the EU rule correctly, but we have only -# confirmation of the 1980-time, so I presume it was correct in 1981: -# The law is about the management of the extra hour, concerning -# working hours reported and effect on obligatory-rest rules (which -# was suspended on that night): -# http://www.retsinfo.dk/_GETDOCI_/ACCN/C19801120554-REGL - -# From Jesper Nørgaard Welen (2005-06-11): -# The Herning Folkeblad (1980-09-26) reported that the night between -# Saturday and Sunday the clock is set back from three to two. - -# From Paul Eggert (2005-06-11): -# Hence the "02:00" of the 1980 law refers to standard time, not -# wall-clock time, and so the EU rules were in effect in 1980. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Denmark 1916 only - May 14 23:00 1:00 S -Rule Denmark 1916 only - Sep 30 23:00 0 - -Rule Denmark 1940 only - May 15 0:00 1:00 S -Rule Denmark 1945 only - Apr 2 2:00s 1:00 S -Rule Denmark 1945 only - Aug 15 2:00s 0 - -Rule Denmark 1946 only - May 1 2:00s 1:00 S -Rule Denmark 1946 only - Sep 1 2:00s 0 - -Rule Denmark 1947 only - May 4 2:00s 1:00 S -Rule Denmark 1947 only - Aug 10 2:00s 0 - -Rule Denmark 1948 only - May 9 2:00s 1:00 S -Rule Denmark 1948 only - Aug 8 2:00s 0 - -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Copenhagen 0:50:20 - LMT 1890 - 0:50:20 - CMT 1894 Jan 1 # Copenhagen MT - 1:00 Denmark CE%sT 1942 Nov 2 2:00s - 1:00 C-Eur CE%sT 1945 Apr 2 2:00 - 1:00 Denmark CE%sT 1980 - 1:00 EU CE%sT -Zone Atlantic/Faroe -0:27:04 - LMT 1908 Jan 11 # Tórshavn - 0:00 - WET 1981 - 0:00 EU WE%sT -# -# From Paul Eggert (2004-10-31): -# During World War II, Germany maintained secret manned weather stations in -# East Greenland and Franz Josef Land, but we don't know their time zones. -# My source for this is Wilhelm Dege's book mentioned under Svalbard. -# -# From Paul Eggert (2017-12-10): -# Greenland joined the European Communities as part of Denmark, -# obtained home rule on 1979-05-01, and left the European Communities -# on 1985-02-01. It therefore should have been using EU -# rules at least through 1984. Shanks & Pottenger say Scoresbysund and Godthåb -# used C-Eur rules after 1980, but IATA SSIM (1991/1996) says they use EU -# rules since at least 1991. Assume EU rules since 1980. - -# From Gwillim Law (2001-06-06), citing -# <http://www.statkart.no/efs/efshefter/2001/efs5-2001.pdf> (2001-03-15), -# and with translations corrected by Steffen Thorsen: -# -# Greenland has four local times, and the relation to UTC -# is according to the following time line: -# -# The military zone near Thule UTC-4 -# Standard Greenland time UTC-3 -# Scoresbysund UTC-1 -# Danmarkshavn UTC -# -# In the military area near Thule and in Danmarkshavn DST will not be -# introduced. - -# From Rives McDow (2001-11-01): -# -# I correspond regularly with the Dansk Polarcenter, and wrote them at -# the time to clarify the situation in Thule. Unfortunately, I have -# not heard back from them regarding my recent letter. [But I have -# info from earlier correspondence.] -# -# According to the center, a very small local time zone around Thule -# Air Base keeps the time according to UTC-4, implementing daylight -# savings using North America rules, changing the time at 02:00 local time.... -# -# The east coast of Greenland north of the community of Scoresbysund -# uses UTC in the same way as in Iceland, year round, with no dst. -# There are just a few stations on this coast, including the -# Danmarkshavn ICAO weather station mentioned in your September 29th -# email. The other stations are two sledge patrol stations in -# Mestersvig and Daneborg, the air force base at Station Nord, and the -# DPC research station at Zackenberg. -# -# Scoresbysund and two small villages nearby keep time UTC-1 and use -# the same daylight savings time period as in West Greenland (Godthåb). -# -# The rest of Greenland, including Godthåb (this area, although it -# includes central Greenland, is known as west Greenland), keeps time -# UTC-3, with daylight savings methods according to European rules. -# -# It is common procedure to use UTC 0 in the wilderness of East and -# North Greenland, because it is mainly Icelandic aircraft operators -# maintaining traffic in these areas. However, the official status of -# this area is that it sticks with Godthåb time. This area might be -# considered a dual time zone in some respects because of this. - -# From Rives McDow (2001-11-19): -# I heard back from someone stationed at Thule; the time change took place -# there at 2:00 AM. - -# From Paul Eggert (2006-03-22): -# From 1997 on the CIA map shows Danmarkshavn on GMT; -# the 1995 map as like Godthåb. -# For lack of better info, assume they were like Godthåb before 1996. -# startkart.no says Thule does not observe DST, but this is clearly an error, -# so go with Shanks & Pottenger for Thule transitions until this year. -# For 2007 on assume Thule will stay in sync with US DST rules. - -# From J William Piggott (2016-02-20): -# "Greenland north of the community of Scoresbysund" is officially named -# "National Park" by Executive Order: -# http://naalakkersuisut.gl/~/media/Nanoq/Files/Attached%20Files/Engelske-tekster/Legislation/Executive%20Order%20National%20Park.rtf -# It is their only National Park. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Thule 1991 1992 - Mar lastSun 2:00 1:00 D -Rule Thule 1991 1992 - Sep lastSun 2:00 0 S -Rule Thule 1993 2006 - Apr Sun>=1 2:00 1:00 D -Rule Thule 1993 2006 - Oct lastSun 2:00 0 S -Rule Thule 2007 max - Mar Sun>=8 2:00 1:00 D -Rule Thule 2007 max - Nov Sun>=1 2:00 0 S -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Danmarkshavn -1:14:40 - LMT 1916 Jul 28 - -3:00 - -03 1980 Apr 6 2:00 - -3:00 EU -03/-02 1996 - 0:00 - GMT -Zone America/Scoresbysund -1:27:52 - LMT 1916 Jul 28 # Ittoqqortoormiit - -2:00 - -02 1980 Apr 6 2:00 - -2:00 C-Eur -02/-01 1981 Mar 29 - -1:00 EU -01/+00 -Zone America/Godthab -3:26:56 - LMT 1916 Jul 28 # Nuuk - -3:00 - -03 1980 Apr 6 2:00 - -3:00 EU -03/-02 -Zone America/Thule -4:35:08 - LMT 1916 Jul 28 # Pituffik air base - -4:00 Thule A%sT - -# Estonia -# -# From Paul Eggert (2016-03-18): -# The 1989 transition is from USSR act No. 227 (1989-03-14). -# -# From Peter Ilieve (1994-10-15): -# A relative in Tallinn confirms the accuracy of the data for 1989 onwards -# [through 1994] and gives the legal authority for it, -# a regulation of the Government of Estonia, No. 111 of 1989.... -# -# From Peter Ilieve (1996-10-28): -# [IATA SSIM (1992/1996) claims that the Baltic republics switch at 01:00s, -# but a relative confirms that Estonia still switches at 02:00s, writing:] -# "I do not [know] exactly but there are some little different -# (confusing) rules for International Air and Railway Transport Schedules -# conversion in Sunday connected with end of summer time in Estonia.... -# A discussion is running about the summer time efficiency and effect on -# human physiology. It seems that Estonia maybe will not change to -# summer time next spring." - -# From Peter Ilieve (1998-11-04), heavily edited: -# The 1998-09-22 Estonian time law -# http://trip.rk.ee/cgi-bin/thw?${BASE}=akt&${OOHTML}=rtd&TA=1998&TO=1&AN=1390 -# refers to the Eighth Directive and cites the association agreement between -# the EU and Estonia, ratified by the Estonian law (RT II 1995, 22-27, 120). -# -# I also asked [my relative] whether they use any standard abbreviation -# for their standard and summer times. He says no, they use "suveaeg" -# (summer time) and "talveaeg" (winter time). - -# From The Baltic Times <https://www.baltictimes.com/> (1999-09-09) -# via Steffen Thorsen: -# This year will mark the last time Estonia shifts to summer time, -# a council of the ruling coalition announced Sept. 6.... -# But what this could mean for Estonia's chances of joining the European -# Union are still unclear. In 1994, the EU declared summer time compulsory -# for all member states until 2001. Brussels has yet to decide what to do -# after that. - -# From Mart Oruaas (2000-01-29): -# Regulation No. 301 (1999-10-12) obsoletes previous regulation -# No. 206 (1998-09-22) and thus sticks Estonia to +02:00 GMT for all -# the year round. The regulation is effective 1999-11-01. - -# From Toomas Soome (2002-02-21): -# The Estonian government has changed once again timezone politics. -# Now we are using again EU rules. -# -# From Urmet Jänes (2002-03-28): -# The legislative reference is Government decree No. 84 on 2002-02-21. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Tallinn 1:39:00 - LMT 1880 - 1:39:00 - TMT 1918 Feb # Tallinn Mean Time - 1:00 C-Eur CE%sT 1919 Jul - 1:39:00 - TMT 1921 May - 2:00 - EET 1940 Aug 6 - 3:00 - MSK 1941 Sep 15 - 1:00 C-Eur CE%sT 1944 Sep 22 - 3:00 Russia MSK/MSD 1989 Mar 26 2:00s - 2:00 1:00 EEST 1989 Sep 24 2:00s - 2:00 C-Eur EE%sT 1998 Sep 22 - 2:00 EU EE%sT 1999 Oct 31 4:00 - 2:00 - EET 2002 Feb 21 - 2:00 EU EE%sT - -# Finland - -# From Hannu Strang (1994-09-25 06:03:37 UTC): -# Well, here in Helsinki we're just changing from summer time to regular one, -# and it's supposed to change at 4am... - -# From Janne Snabb (2010-07-15): -# -# I noticed that the Finland data is not accurate for years 1981 and 1982. -# During these two first trial years the DST adjustment was made one hour -# earlier than in forthcoming years. Starting 1983 the adjustment was made -# according to the central European standards. -# -# This is documented in Heikki Oja: Aikakirja 2007, published by The Almanac -# Office of University of Helsinki, ISBN 952-10-3221-9, available online (in -# Finnish) at -# https://almanakka.helsinki.fi/aikakirja/Aikakirja2007kokonaan.pdf -# -# Page 105 (56 in PDF version) has a handy table of all past daylight savings -# transitions. It is easy enough to interpret without Finnish skills. -# -# This is also confirmed by Finnish Broadcasting Company's archive at: -# http://www.yle.fi/elavaarkisto/?s=s&g=1&ag=5&t=&a=3401 -# -# The news clip from 1981 says that "the time between 2 and 3 o'clock does not -# exist tonight." - -# From Konstantin Hyppönen (2014-06-13): -# [Heikki Oja's book Aikakirja 2013] -# https://almanakka.helsinki.fi/images/aikakirja/Aikakirja2013kokonaan.pdf -# pages 104-105, including a scan from a newspaper published on Apr 2 1942 -# say that ... [o]n Apr 2 1942, 24 o'clock (which means Apr 3 1942, -# 00:00), clocks were moved one hour forward. The newspaper -# mentions "on the night from Thursday to Friday".... -# On Oct 4 1942, clocks were moved at 1:00 one hour backwards. -# -# From Paul Eggert (2014-06-14): -# Go with Oja over Shanks. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Finland 1942 only - Apr 2 24:00 1:00 S -Rule Finland 1942 only - Oct 4 1:00 0 - -Rule Finland 1981 1982 - Mar lastSun 2:00 1:00 S -Rule Finland 1981 1982 - Sep lastSun 3:00 0 - - -# Milne says Helsinki (Helsingfors) time was 1:39:49.2 (official document); -# round to nearest. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Helsinki 1:39:49 - LMT 1878 May 31 - 1:39:49 - HMT 1921 May # Helsinki Mean Time - 2:00 Finland EE%sT 1983 - 2:00 EU EE%sT - -# Åland Is -Link Europe/Helsinki Europe/Mariehamn - - -# France - -# From Ciro Discepolo (2000-12-20): -# -# Henri Le Corre, Régimes horaires pour le monde entier, Éditions -# Traditionnelles - Paris 2 books, 1993 -# -# Gabriel, Traité de l'heure dans le monde, Guy Trédaniel, -# Paris, 1991 -# -# Françoise Gauquelin, Problèmes de l'heure résolus en astrologie, -# Guy Trédaniel, Paris 1987 - - -# -# Shank & Pottenger seem to use '24:00' ambiguously; resolve it with Whitman. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule France 1916 only - Jun 14 23:00s 1:00 S -Rule France 1916 1919 - Oct Sun>=1 23:00s 0 - -Rule France 1917 only - Mar 24 23:00s 1:00 S -Rule France 1918 only - Mar 9 23:00s 1:00 S -Rule France 1919 only - Mar 1 23:00s 1:00 S -Rule France 1920 only - Feb 14 23:00s 1:00 S -Rule France 1920 only - Oct 23 23:00s 0 - -Rule France 1921 only - Mar 14 23:00s 1:00 S -Rule France 1921 only - Oct 25 23:00s 0 - -Rule France 1922 only - Mar 25 23:00s 1:00 S -# DSH writes that a law of 1923-05-24 specified 3rd Sat in Apr at 23:00 to 1st -# Sat in Oct at 24:00; and that in 1930, because of Easter, the transitions -# were Apr 12 and Oct 5. Go with Shanks & Pottenger. -Rule France 1922 1938 - Oct Sat>=1 23:00s 0 - -Rule France 1923 only - May 26 23:00s 1:00 S -Rule France 1924 only - Mar 29 23:00s 1:00 S -Rule France 1925 only - Apr 4 23:00s 1:00 S -Rule France 1926 only - Apr 17 23:00s 1:00 S -Rule France 1927 only - Apr 9 23:00s 1:00 S -Rule France 1928 only - Apr 14 23:00s 1:00 S -Rule France 1929 only - Apr 20 23:00s 1:00 S -Rule France 1930 only - Apr 12 23:00s 1:00 S -Rule France 1931 only - Apr 18 23:00s 1:00 S -Rule France 1932 only - Apr 2 23:00s 1:00 S -Rule France 1933 only - Mar 25 23:00s 1:00 S -Rule France 1934 only - Apr 7 23:00s 1:00 S -Rule France 1935 only - Mar 30 23:00s 1:00 S -Rule France 1936 only - Apr 18 23:00s 1:00 S -Rule France 1937 only - Apr 3 23:00s 1:00 S -Rule France 1938 only - Mar 26 23:00s 1:00 S -Rule France 1939 only - Apr 15 23:00s 1:00 S -Rule France 1939 only - Nov 18 23:00s 0 - -Rule France 1940 only - Feb 25 2:00 1:00 S -# The French rules for 1941-1944 were not used in Paris, but Shanks & Pottenger -# write that they were used in Monaco and in many French locations. -# Le Corre writes that the upper limit of the free zone was Arnéguy, Orthez, -# Mont-de-Marsan, Bazas, Langon, Lamothe-Montravel, Marœuil, La -# Rochefoucauld, Champagne-Mouton, La Roche-Posay, La Haye-Descartes, -# Loches, Montrichard, Vierzon, Bourges, Moulins, Digoin, -# Paray-le-Monial, Montceau-les-Mines, Chalon-sur-Saône, Arbois, -# Dole, Morez, St-Claude, and Collonges (Haute-Savoie). -Rule France 1941 only - May 5 0:00 2:00 M # Midsummer -# Shanks & Pottenger say this transition occurred at Oct 6 1:00, -# but go with Denis Excoffier (1997-12-12), -# who quotes the Ephémérides astronomiques for 1998 from Bureau des Longitudes -# as saying 5/10/41 22hUT. -Rule France 1941 only - Oct 6 0:00 1:00 S -Rule France 1942 only - Mar 9 0:00 2:00 M -Rule France 1942 only - Nov 2 3:00 1:00 S -Rule France 1943 only - Mar 29 2:00 2:00 M -Rule France 1943 only - Oct 4 3:00 1:00 S -Rule France 1944 only - Apr 3 2:00 2:00 M -Rule France 1944 only - Oct 8 1:00 1:00 S -Rule France 1945 only - Apr 2 2:00 2:00 M -Rule France 1945 only - Sep 16 3:00 0 - -# Shanks & Pottenger give Mar 28 2:00 and Sep 26 3:00; -# go with Excoffier's 28/3/76 0hUT and 25/9/76 23hUT. -Rule France 1976 only - Mar 28 1:00 1:00 S -Rule France 1976 only - Sep 26 1:00 0 - -# Shanks & Pottenger give 0:09:20 for Paris Mean Time, and Whitman 0:09:05, -# but Howse quotes the actual French legislation as saying 0:09:21. -# Go with Howse. Howse writes that the time in France was officially based -# on PMT-0:09:21 until 1978-08-09, when the time base finally switched to UTC. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 - 0:09:21 - PMT 1911 Mar 11 0:01 # Paris MT -# Shanks & Pottenger give 1940 Jun 14 0:00; go with Excoffier and Le Corre. - 0:00 France WE%sT 1940 Jun 14 23:00 -# Le Corre says Paris stuck with occupied-France time after the liberation; -# go with Shanks & Pottenger. - 1:00 C-Eur CE%sT 1944 Aug 25 - 0:00 France WE%sT 1945 Sep 16 3:00 - 1:00 France CE%sT 1977 - 1:00 EU CE%sT - -# Germany - -# From Markus Kuhn (1998-09-29): -# The German time zone web site by the Physikalisch-Technische -# Bundesanstalt contains DST information back to 1916. -# [See tz-link.html for the URL.] - -# From Jörg Schilling (2002-10-23): -# In 1945, Berlin was switched to Moscow Summer time (GMT+4) by -# https://www.dhm.de/lemo/html/biografien/BersarinNikolai/ -# General [Nikolai] Bersarin. - -# From Paul Eggert (2003-03-08): -# http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf -# says that Bersarin issued an order to use Moscow time on May 20. -# However, Moscow did not observe daylight saving in 1945, so -# this was equivalent to UT +03, not +04. - - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Germany 1946 only - Apr 14 2:00s 1:00 S -Rule Germany 1946 only - Oct 7 2:00s 0 - -Rule Germany 1947 1949 - Oct Sun>=1 2:00s 0 - -# http://www.ptb.de/de/org/4/44/441/salt.htm says the following transition -# occurred at 3:00 MEZ, not the 2:00 MEZ given in Shanks & Pottenger. -# Go with the PTB. -Rule Germany 1947 only - Apr 6 3:00s 1:00 S -Rule Germany 1947 only - May 11 2:00s 2:00 M -Rule Germany 1947 only - Jun 29 3:00 1:00 S -Rule Germany 1948 only - Apr 18 2:00s 1:00 S -Rule Germany 1949 only - Apr 10 2:00s 1:00 S - -Rule SovietZone 1945 only - May 24 2:00 2:00 M # Midsummer -Rule SovietZone 1945 only - Sep 24 3:00 1:00 S -Rule SovietZone 1945 only - Nov 18 2:00s 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Berlin 0:53:28 - LMT 1893 Apr - 1:00 C-Eur CE%sT 1945 May 24 2:00 - 1:00 SovietZone CE%sT 1946 - 1:00 Germany CE%sT 1980 - 1:00 EU CE%sT - -# From Tobias Conradi (2011-09-12): -# Büsingen <http://www.buesingen.de>, surrounded by the Swiss canton -# Schaffhausen, did not start observing DST in 1980 as the rest of DE -# (West Germany at that time) and DD (East Germany at that time) did. -# DD merged into DE, the area is currently covered by code DE in ISO 3166-1, -# which in turn is covered by the zone Europe/Berlin. -# -# Source for the time in Büsingen 1980: -# http://www.srf.ch/player/video?id=c012c029-03b7-4c2b-9164-aa5902cd58d3 - -# From Arthur David Olson (2012-03-03): -# Büsingen and Zurich have shared clocks since 1970. - -Link Europe/Zurich Europe/Busingen - -# Georgia -# Please see the "asia" file for Asia/Tbilisi. -# Herodotus (Histories, IV.45) says Georgia north of the Phasis (now Rioni) -# is in Europe. Our reference location Tbilisi is in the Asian part. - -# Gibraltar -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Gibraltar -0:21:24 - LMT 1880 Aug 2 0:00s - 0:00 GB-Eire %s 1957 Apr 14 2:00 - 1:00 - CET 1982 - 1:00 EU CE%sT - -# Greece -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# Whitman gives 1932 Jul 5 - Nov 1; go with Shanks & Pottenger. -Rule Greece 1932 only - Jul 7 0:00 1:00 S -Rule Greece 1932 only - Sep 1 0:00 0 - -# Whitman gives 1941 Apr 25 - ?; go with Shanks & Pottenger. -Rule Greece 1941 only - Apr 7 0:00 1:00 S -# Whitman gives 1942 Feb 2 - ?; go with Shanks & Pottenger. -Rule Greece 1942 only - Nov 2 3:00 0 - -Rule Greece 1943 only - Mar 30 0:00 1:00 S -Rule Greece 1943 only - Oct 4 0:00 0 - -# Whitman gives 1944 Oct 3 - Oct 31; go with Shanks & Pottenger. -Rule Greece 1952 only - Jul 1 0:00 1:00 S -Rule Greece 1952 only - Nov 2 0:00 0 - -Rule Greece 1975 only - Apr 12 0:00s 1:00 S -Rule Greece 1975 only - Nov 26 0:00s 0 - -Rule Greece 1976 only - Apr 11 2:00s 1:00 S -Rule Greece 1976 only - Oct 10 2:00s 0 - -Rule Greece 1977 1978 - Apr Sun>=1 2:00s 1:00 S -Rule Greece 1977 only - Sep 26 2:00s 0 - -Rule Greece 1978 only - Sep 24 4:00 0 - -Rule Greece 1979 only - Apr 1 9:00 1:00 S -Rule Greece 1979 only - Sep 29 2:00 0 - -Rule Greece 1980 only - Apr 1 0:00 1:00 S -Rule Greece 1980 only - Sep 28 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Athens 1:34:52 - LMT 1895 Sep 14 - 1:34:52 - AMT 1916 Jul 28 0:01 # Athens MT - 2:00 Greece EE%sT 1941 Apr 30 - 1:00 Greece CE%sT 1944 Apr 4 - 2:00 Greece EE%sT 1981 - # Shanks & Pottenger say it switched to C-Eur in 1981; - # go with EU rules instead, since Greece joined Jan 1. - 2:00 EU EE%sT - -# Hungary -# From Paul Eggert (2014-07-15): -# Dates for 1916-1945 are taken from: -# Oross A. Jelen a múlt jövője: a nyári időszámítás Magyarországon 1916-1945. -# National Archives of Hungary (2012-10-29). -# http://mnl.gov.hu/a_het_dokumentuma/a_nyari_idoszamitas_magyarorszagon_19161945.html -# This source does not always give times, which are taken from Shanks -# & Pottenger (which disagree about the dates). -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Hungary 1918 only - Apr 1 3:00 1:00 S -Rule Hungary 1918 only - Sep 16 3:00 0 - -Rule Hungary 1919 only - Apr 15 3:00 1:00 S -Rule Hungary 1919 only - Nov 24 3:00 0 - -Rule Hungary 1945 only - May 1 23:00 1:00 S -Rule Hungary 1945 only - Nov 1 0:00 0 - -Rule Hungary 1946 only - Mar 31 2:00s 1:00 S -Rule Hungary 1946 1949 - Oct Sun>=1 2:00s 0 - -Rule Hungary 1947 1949 - Apr Sun>=4 2:00s 1:00 S -Rule Hungary 1950 only - Apr 17 2:00s 1:00 S -Rule Hungary 1950 only - Oct 23 2:00s 0 - -Rule Hungary 1954 1955 - May 23 0:00 1:00 S -Rule Hungary 1954 1955 - Oct 3 0:00 0 - -Rule Hungary 1956 only - Jun Sun>=1 0:00 1:00 S -Rule Hungary 1956 only - Sep lastSun 0:00 0 - -Rule Hungary 1957 only - Jun Sun>=1 1:00 1:00 S -Rule Hungary 1957 only - Sep lastSun 3:00 0 - -Rule Hungary 1980 only - Apr 6 1:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Budapest 1:16:20 - LMT 1890 Oct - 1:00 C-Eur CE%sT 1918 - 1:00 Hungary CE%sT 1941 Apr 8 - 1:00 C-Eur CE%sT 1945 - 1:00 Hungary CE%sT 1980 Sep 28 2:00s - 1:00 EU CE%sT - -# Iceland -# -# From Adam David (1993-11-06): -# The name of the timezone in Iceland for system / mail / news purposes is GMT. -# -# (1993-12-05): -# This material is paraphrased from the 1988 edition of the University of -# Iceland Almanak. -# -# From January 1st, 1908 the whole of Iceland was standardised at 1 hour -# behind GMT. Previously, local mean solar time was used in different parts -# of Iceland, the almanak had been based on Reykjavik mean solar time which -# was 1 hour and 28 minutes behind GMT. -# -# "first day of winter" referred to [below] means the first day of the 26 weeks -# of winter, according to the old icelandic calendar that dates back to the -# time the norsemen first settled Iceland. The first day of winter is always -# Saturday, but is not dependent on the Julian or Gregorian calendars. -# -# (1993-12-10): -# I have a reference from the Oxford Icelandic-English dictionary for the -# beginning of winter, which ties it to the ecclesiastical calendar (and thus -# to the julian/gregorian calendar) over the period in question. -# the winter begins on the Saturday next before St. Luke's day -# (old style), or on St. Luke's day, if a Saturday. -# St. Luke's day ought to be traceable from ecclesiastical sources. "old style" -# might be a reference to the Julian calendar as opposed to Gregorian, or it -# might mean something else (???). -# -# From Paul Eggert (2014-11-22): -# The information below is taken from the 1988 Almanak; see -# http://www.almanak.hi.is/klukkan.html -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iceland 1917 1919 - Feb 19 23:00 1:00 - -Rule Iceland 1917 only - Oct 21 1:00 0 - -Rule Iceland 1918 1919 - Nov 16 1:00 0 - -Rule Iceland 1921 only - Mar 19 23:00 1:00 - -Rule Iceland 1921 only - Jun 23 1:00 0 - -Rule Iceland 1939 only - Apr 29 23:00 1:00 - -Rule Iceland 1939 only - Oct 29 2:00 0 - -Rule Iceland 1940 only - Feb 25 2:00 1:00 - -Rule Iceland 1940 1941 - Nov Sun>=2 1:00s 0 - -Rule Iceland 1941 1942 - Mar Sun>=2 1:00s 1:00 - -# 1943-1946 - first Sunday in March until first Sunday in winter -Rule Iceland 1943 1946 - Mar Sun>=1 1:00s 1:00 - -Rule Iceland 1942 1948 - Oct Sun>=22 1:00s 0 - -# 1947-1967 - first Sunday in April until first Sunday in winter -Rule Iceland 1947 1967 - Apr Sun>=1 1:00s 1:00 - -# 1949 and 1967 Oct transitions delayed by 1 week -Rule Iceland 1949 only - Oct 30 1:00s 0 - -Rule Iceland 1950 1966 - Oct Sun>=22 1:00s 0 - -Rule Iceland 1967 only - Oct 29 1:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Reykjavik -1:28 - LMT 1908 - -1:00 Iceland -01/+00 1968 Apr 7 1:00s - 0:00 - GMT - -# Italy -# -# From Paul Eggert (2001-03-06): -# Sicily and Sardinia each had their own time zones from 1866 to 1893, -# called Palermo Time (+00:53:28) and Cagliari Time (+00:36:32). -# During World War II, German-controlled Italy used German time. -# But these events all occurred before the 1970 cutoff, -# so record only the time in Rome. -# -# From Michael Deckers (2016-10-24): -# http://www.ac-ilsestante.it/MERIDIANE/ora_legale quotes a law of 1893-08-10 -# ... [translated as] "The preceding dispositions will enter into -# force at the instant at which, according to the time specified in -# the 1st article, the 1st of November 1893 will begin...." -# -# From Pierpaolo Bernardi (2016-10-20): -# The authoritative source for time in Italy is the national metrological -# institute, which has a summary page of historical DST data at -# http://www.inrim.it/res/tf/ora_legale_i.shtml -# (2016-10-24): -# http://www.renzobaldini.it/le-ore-legali-in-italia/ -# has still different data for 1944. It divides Italy in two, as -# there were effectively two governments at the time, north of Gothic -# Line German controlled territory, official government RSI, and south -# of the Gothic Line, controlled by allied armies. -# -# From Brian Inglis (2016-10-23): -# Viceregal LEGISLATIVE DECREE. 14 September 1944, no. 219. -# Restoration of Standard Time. (044U0219) (OJ 62 of 30.9.1944) ... -# Given the R. law decreed on 1944-03-29, no. 92, by which standard time is -# advanced to sixty minutes later starting at hour two on 1944-04-02; ... -# Starting at hour three on the date 1944-09-17 standard time will be resumed. -# -# From Paul Eggert (2016-10-27): -# Go with INRiM for DST rules, except as corrected by Inglis for 1944 -# for the Kingdom of Italy. This is consistent with Renzo Baldini. -# Model Rome's occupation by using C-Eur rules from 1943-09-10 -# to 1944-06-04; although Rome was an open city during this period, it -# was effectively controlled by Germany. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Italy 1916 only - Jun 3 24:00 1:00 S -Rule Italy 1916 1917 - Sep 30 24:00 0 - -Rule Italy 1917 only - Mar 31 24:00 1:00 S -Rule Italy 1918 only - Mar 9 24:00 1:00 S -Rule Italy 1918 only - Oct 6 24:00 0 - -Rule Italy 1919 only - Mar 1 24:00 1:00 S -Rule Italy 1919 only - Oct 4 24:00 0 - -Rule Italy 1920 only - Mar 20 24:00 1:00 S -Rule Italy 1920 only - Sep 18 24:00 0 - -Rule Italy 1940 only - Jun 14 24:00 1:00 S -Rule Italy 1942 only - Nov 2 2:00s 0 - -Rule Italy 1943 only - Mar 29 2:00s 1:00 S -Rule Italy 1943 only - Oct 4 2:00s 0 - -Rule Italy 1944 only - Apr 2 2:00s 1:00 S -Rule Italy 1944 only - Sep 17 2:00s 0 - -Rule Italy 1945 only - Apr 2 2:00 1:00 S -Rule Italy 1945 only - Sep 15 1:00 0 - -Rule Italy 1946 only - Mar 17 2:00s 1:00 S -Rule Italy 1946 only - Oct 6 2:00s 0 - -Rule Italy 1947 only - Mar 16 0:00s 1:00 S -Rule Italy 1947 only - Oct 5 0:00s 0 - -Rule Italy 1948 only - Feb 29 2:00s 1:00 S -Rule Italy 1948 only - Oct 3 2:00s 0 - -Rule Italy 1966 1968 - May Sun>=22 0:00s 1:00 S -Rule Italy 1966 only - Sep 24 24:00 0 - -Rule Italy 1967 1969 - Sep Sun>=22 0:00s 0 - -Rule Italy 1969 only - Jun 1 0:00s 1:00 S -Rule Italy 1970 only - May 31 0:00s 1:00 S -Rule Italy 1970 only - Sep lastSun 0:00s 0 - -Rule Italy 1971 1972 - May Sun>=22 0:00s 1:00 S -Rule Italy 1971 only - Sep lastSun 0:00s 0 - -Rule Italy 1972 only - Oct 1 0:00s 0 - -Rule Italy 1973 only - Jun 3 0:00s 1:00 S -Rule Italy 1973 1974 - Sep lastSun 0:00s 0 - -Rule Italy 1974 only - May 26 0:00s 1:00 S -Rule Italy 1975 only - Jun 1 0:00s 1:00 S -Rule Italy 1975 1977 - Sep lastSun 0:00s 0 - -Rule Italy 1976 only - May 30 0:00s 1:00 S -Rule Italy 1977 1979 - May Sun>=22 0:00s 1:00 S -Rule Italy 1978 only - Oct 1 0:00s 0 - -Rule Italy 1979 only - Sep 30 0:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Rome 0:49:56 - LMT 1866 Sep 22 - 0:49:56 - RMT 1893 Oct 31 23:49:56 # Rome Mean - 1:00 Italy CE%sT 1943 Sep 10 - 1:00 C-Eur CE%sT 1944 Jun 4 - 1:00 Italy CE%sT 1980 - 1:00 EU CE%sT - -Link Europe/Rome Europe/Vatican -Link Europe/Rome Europe/San_Marino - -# Latvia - -# From Liene Kanepe (1998-09-17): - -# I asked about this matter Scientific Secretary of the Institute of Astronomy -# of The University of Latvia Dr. paed Mr. Ilgonis Vilks. I also searched the -# correct data in juridical acts and I found some juridical documents about -# changes in the counting of time in Latvia from 1981.... -# -# Act No. 35 of the Council of Ministers of Latvian SSR of 1981-01-22 ... -# according to the Act No. 925 of the Council of Ministers of USSR of 1980-10-24 -# ...: all year round the time of 2nd time zone + 1 hour, in addition turning -# the hands of the clock 1 hour forward on 1 April at 00:00 (GMT 31 March 21:00) -# and 1 hour backward on the 1 October at 00:00 (GMT 30 September 20:00). -# -# Act No. 592 of the Council of Ministers of Latvian SSR of 1984-09-24 ... -# according to the Act No. 967 of the Council of Ministers of USSR of 1984-09-13 -# ...: all year round the time of 2nd time zone + 1 hour, in addition turning -# the hands of the clock 1 hour forward on the last Sunday of March at 02:00 -# (GMT 23:00 on the previous day) and 1 hour backward on the last Sunday of -# September at 03:00 (GMT 23:00 on the previous day). -# -# Act No. 81 of the Council of Ministers of Latvian SSR of 1989-03-22 ... -# according to the Act No. 227 of the Council of Ministers of USSR of 1989-03-14 -# ...: since the last Sunday of March 1989 in Lithuanian SSR, Latvian SSR, -# Estonian SSR and Kaliningrad region of Russian Federation all year round the -# time of 2nd time zone (Moscow time minus one hour). On the territory of Latvia -# transition to summer time is performed on the last Sunday of March at 02:00 -# (GMT 00:00), turning the hands of the clock 1 hour forward. The end of -# daylight saving time is performed on the last Sunday of September at 03:00 -# (GMT 00:00), turning the hands of the clock 1 hour backward. Exception is -# 1989-03-26, when we must not turn the hands of the clock.... -# -# The Regulations of the Cabinet of Ministers of the Republic of Latvia of -# 1997-01-21 on transition to Summer time ... established the same order of -# daylight savings time settings as in the States of the European Union. - -# From Andrei Ivanov (2000-03-06): -# This year Latvia will not switch to Daylight Savings Time (as specified in -# The Regulations of the Cabinet of Ministers of the Rep. of Latvia of -# 29-Feb-2000 (No. 79) <http://www.lv-laiks.lv/wwwraksti/2000/071072/vd4.htm>, -# in Latvian for subscribers only). - -# From RFE/RL Newsline -# http://www.rferl.org/newsline/2001/01/3-CEE/cee-030101.html -# (2001-01-03), noted after a heads-up by Rives McDow: -# The Latvian government on 2 January decided that the country will -# institute daylight-saving time this spring, LETA reported. -# Last February the three Baltic states decided not to turn back their -# clocks one hour in the spring.... -# Minister of Economy Aigars Kalvītis noted that Latvia had too few -# daylight hours and thus decided to comply with a draft European -# Commission directive that provides for instituting daylight-saving -# time in EU countries between 2002 and 2006. The Latvian government -# urged Lithuania and Estonia to adopt a similar time policy, but it -# appears that they will not do so.... - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Latvia 1989 1996 - Mar lastSun 2:00s 1:00 S -Rule Latvia 1989 1996 - Sep lastSun 2:00s 0 - - -# Milne 1899 says Riga was 1:36:28 (Polytechnique House time). -# Byalokoz 1919 says Latvia was 1:36:34. -# Go with Byalokoz. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Riga 1:36:34 - LMT 1880 - 1:36:34 - RMT 1918 Apr 15 2:00 # Riga MT - 1:36:34 1:00 LST 1918 Sep 16 3:00 # Latvian ST - 1:36:34 - RMT 1919 Apr 1 2:00 - 1:36:34 1:00 LST 1919 May 22 3:00 - 1:36:34 - RMT 1926 May 11 - 2:00 - EET 1940 Aug 5 - 3:00 - MSK 1941 Jul - 1:00 C-Eur CE%sT 1944 Oct 13 - 3:00 Russia MSK/MSD 1989 Mar lastSun 2:00s - 2:00 1:00 EEST 1989 Sep lastSun 2:00s - 2:00 Latvia EE%sT 1997 Jan 21 - 2:00 EU EE%sT 2000 Feb 29 - 2:00 - EET 2001 Jan 2 - 2:00 EU EE%sT - -# Liechtenstein - -# From Paul Eggert (2013-09-09): -# Shanks & Pottenger say Vaduz is like Zurich. - -# From Alois Treindl (2013-09-18): -# http://www.eliechtensteinensia.li/LIJ/1978/1938-1978/1941.pdf -# ... confirms on p. 6 that Liechtenstein followed Switzerland in 1941 and 1942. -# I ... translate only the last two paragraphs: -# ... during second world war, in the years 1941 and 1942, Liechtenstein -# introduced daylight saving time, adapting to Switzerland. From 1943 on -# central European time was in force throughout the year. -# From a report of the duke's government to the high council, -# regarding the introduction of a time law, of 31 May 1977. - -Link Europe/Zurich Europe/Vaduz - - -# Lithuania - -# From Paul Eggert (2016-03-18): -# The 1989 transition is from USSR act No. 227 (1989-03-14). - -# From Paul Eggert (1996-11-22): -# IATA SSIM (1992/1996) says Lithuania uses W-Eur rules, but since it is -# known to be wrong about Estonia and Latvia, assume it's wrong here too. - -# From Marius Gedminas (1998-08-07): -# I would like to inform that in this year Lithuanian time zone -# (Europe/Vilnius) was changed. - -# From ELTA No. 972 (2582) (1999-09-29) <http://www.elta.lt/>, -# via Steffen Thorsen: -# Lithuania has shifted back to the second time zone (GMT plus two hours) -# to be valid here starting from October 31, -# as decided by the national government on Wednesday.... -# The Lithuanian government also announced plans to consider a -# motion to give up shifting to summer time in spring, as it was -# already done by Estonia. - -# From the Fact File, Lithuanian State Department of Tourism -# <http://www.tourism.lt/informa/ff.htm> (2000-03-27): -# Local time is GMT+2 hours ..., no daylight saving. - -# From a user via Klaus Marten (2003-02-07): -# As a candidate for membership of the European Union, Lithuania will -# observe Summer Time in 2003, changing its clocks at the times laid -# down in EU Directive 2000/84 of 19.I.01 (i.e. at the same times as its -# neighbour Latvia). The text of the Lithuanian government Order of -# 7.XI.02 to this effect can be found at -# http://www.lrvk.lt/nut/11/n1749.htm - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Vilnius 1:41:16 - LMT 1880 - 1:24:00 - WMT 1917 # Warsaw Mean Time - 1:35:36 - KMT 1919 Oct 10 # Kaunas Mean Time - 1:00 - CET 1920 Jul 12 - 2:00 - EET 1920 Oct 9 - 1:00 - CET 1940 Aug 3 - 3:00 - MSK 1941 Jun 24 - 1:00 C-Eur CE%sT 1944 Aug - 3:00 Russia MSK/MSD 1989 Mar 26 2:00s - 2:00 Russia EE%sT 1991 Sep 29 2:00s - 2:00 C-Eur EE%sT 1998 - 2:00 - EET 1998 Mar 29 1:00u - 1:00 EU CE%sT 1999 Oct 31 1:00u - 2:00 - EET 2003 Jan 1 - 2:00 EU EE%sT - -# Luxembourg -# Whitman disagrees with most of these dates in minor ways; -# go with Shanks & Pottenger. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Lux 1916 only - May 14 23:00 1:00 S -Rule Lux 1916 only - Oct 1 1:00 0 - -Rule Lux 1917 only - Apr 28 23:00 1:00 S -Rule Lux 1917 only - Sep 17 1:00 0 - -Rule Lux 1918 only - Apr Mon>=15 2:00s 1:00 S -Rule Lux 1918 only - Sep Mon>=15 2:00s 0 - -Rule Lux 1919 only - Mar 1 23:00 1:00 S -Rule Lux 1919 only - Oct 5 3:00 0 - -Rule Lux 1920 only - Feb 14 23:00 1:00 S -Rule Lux 1920 only - Oct 24 2:00 0 - -Rule Lux 1921 only - Mar 14 23:00 1:00 S -Rule Lux 1921 only - Oct 26 2:00 0 - -Rule Lux 1922 only - Mar 25 23:00 1:00 S -Rule Lux 1922 only - Oct Sun>=2 1:00 0 - -Rule Lux 1923 only - Apr 21 23:00 1:00 S -Rule Lux 1923 only - Oct Sun>=2 2:00 0 - -Rule Lux 1924 only - Mar 29 23:00 1:00 S -Rule Lux 1924 1928 - Oct Sun>=2 1:00 0 - -Rule Lux 1925 only - Apr 5 23:00 1:00 S -Rule Lux 1926 only - Apr 17 23:00 1:00 S -Rule Lux 1927 only - Apr 9 23:00 1:00 S -Rule Lux 1928 only - Apr 14 23:00 1:00 S -Rule Lux 1929 only - Apr 20 23:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Luxembourg 0:24:36 - LMT 1904 Jun - 1:00 Lux CE%sT 1918 Nov 25 - 0:00 Lux WE%sT 1929 Oct 6 2:00s - 0:00 Belgium WE%sT 1940 May 14 3:00 - 1:00 C-Eur WE%sT 1944 Sep 18 3:00 - 1:00 Belgium CE%sT 1977 - 1:00 EU CE%sT - -# Macedonia -# See Europe/Belgrade. - -# Malta -# -# From Paul Eggert (2016-10-21): -# Assume 1900-1972 was like Rome, overriding Shanks. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Malta 1973 only - Mar 31 0:00s 1:00 S -Rule Malta 1973 only - Sep 29 0:00s 0 - -Rule Malta 1974 only - Apr 21 0:00s 1:00 S -Rule Malta 1974 only - Sep 16 0:00s 0 - -Rule Malta 1975 1979 - Apr Sun>=15 2:00 1:00 S -Rule Malta 1975 1980 - Sep Sun>=15 2:00 0 - -Rule Malta 1980 only - Mar 31 2:00 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 0:00s # Valletta - 1:00 Italy CE%sT 1973 Mar 31 - 1:00 Malta CE%sT 1981 - 1:00 EU CE%sT - -# Moldova - -# From Stepan Golosunov (2016-03-07): -# the act of the government of the Republic of Moldova Nr. 132 from 1990-05-04 -# http://lex.justice.md/viewdoc.php?action=view&view=doc&id=298782&lang=2 -# ... says that since 1990-05-06 on the territory of the Moldavian SSR -# time would be calculated as the standard time of the second time belt -# plus one hour of the "summer" time. To implement that clocks would be -# adjusted one hour backwards at 1990-05-06 2:00. After that "summer" -# time would be cancelled last Sunday of September at 3:00 and -# reintroduced last Sunday of March at 2:00. - -# From Paul Eggert (2006-03-22): -# A previous version of this database followed Shanks & Pottenger, who write -# that Tiraspol switched to Moscow time on 1992-01-19 at 02:00. -# However, this is most likely an error, as Moldova declared independence -# on 1991-08-27 (the 1992-01-19 date is that of a Russian decree). -# In early 1992 there was large-scale interethnic violence in the area -# and it's possible that some Russophones continued to observe Moscow time. -# But [two people] separately reported via -# Jesper Nørgaard that as of 2001-01-24 Tiraspol was like Chisinau. -# The Tiraspol entry has therefore been removed for now. -# -# From Alexander Krivenyshev (2011-10-17): -# Pridnestrovian Moldavian Republic (PMR, also known as -# "Pridnestrovie") has abolished seasonal clock change (no transition -# to the Winter Time). -# -# News (in Russian): -# http://www.kyivpost.ua/russia/news/pridnestrove-otkazalos-ot-perehoda-na-zimnee-vremya-30954.html -# http://www.allmoldova.com/moldova-news/1249064116.html -# -# The substance of this change (reinstatement of the Tiraspol entry) -# is from a patch from Petr Machata (2011-10-17) -# -# From Tim Parenti (2011-10-19) -# In addition, being situated at +4651+2938 would give Tiraspol -# a pre-1880 LMT offset of 1:58:32. -# -# (which agrees with the earlier entry that had been removed) -# -# From Alexander Krivenyshev (2011-10-26) -# NO need to divide Moldova into two timezones at this point. -# As of today, Transnistria (Pridnestrovie)- Tiraspol reversed its own -# decision to abolish DST this winter. -# Following Moldova and neighboring Ukraine- Transnistria (Pridnestrovie)- -# Tiraspol will go back to winter time on October 30, 2011. -# News from Moldova (in russian): -# https://ru.publika.md/link_317061.html - -# From Roman Tudos (2015-07-02): -# http://lex.justice.md/index.php?action=view&view=doc&lang=1&id=355077 -# From Paul Eggert (2015-07-01): -# The abovementioned official link to IGO1445-868/2014 states that -# 2014-10-26's fallback transition occurred at 03:00 local time. Also, -# https://www.trm.md/en/social/la-30-martie-vom-trece-la-ora-de-vara -# says the 2014-03-30 spring-forward transition was at 02:00 local time. -# Guess that since 1997 Moldova has switched one hour before the EU. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Moldova 1997 max - Mar lastSun 2:00 1:00 S -Rule Moldova 1997 max - Oct lastSun 3:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Chisinau 1:55:20 - LMT 1880 - 1:55 - CMT 1918 Feb 15 # Chisinau MT - 1:44:24 - BMT 1931 Jul 24 # Bucharest MT - 2:00 Romania EE%sT 1940 Aug 15 - 2:00 1:00 EEST 1941 Jul 17 - 1:00 C-Eur CE%sT 1944 Aug 24 - 3:00 Russia MSK/MSD 1990 May 6 2:00 - 2:00 Russia EE%sT 1992 - 2:00 E-Eur EE%sT 1997 -# See Romania commentary for the guessed 1997 transition to EU rules. - 2:00 Moldova EE%sT - -# Monaco -# Shanks & Pottenger give 0:09:20 for Paris Mean Time; go with Howse's -# more precise 0:09:21. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15 - 0:09:21 - PMT 1911 Mar 11 # Paris Mean Time - 0:00 France WE%sT 1945 Sep 16 3:00 - 1:00 France CE%sT 1977 - 1:00 EU CE%sT - -# Montenegro -# See Europe/Belgrade. - -# Netherlands - -# Howse writes that the Netherlands' railways used GMT between 1892 and 1940, -# but for other purposes the Netherlands used Amsterdam mean time. - -# However, Robert H. van Gent writes (2001-04-01): -# Howse's statement is only correct up to 1909. From 1909-05-01 (00:00:00 -# Amsterdam mean time) onwards, the whole of the Netherlands (including -# the Dutch railways) was required by law to observe Amsterdam mean time -# (19 minutes 32.13 seconds ahead of GMT). This had already been the -# common practice (except for the railways) for many decades but it was -# not until 1909 when the Dutch government finally defined this by law. -# On 1937-07-01 this was changed to 20 minutes (exactly) ahead of GMT and -# was generally known as Dutch Time ("Nederlandse Tijd"). -# -# (2001-04-08): -# 1892-05-01 was the date when the Dutch railways were by law required to -# observe GMT while the remainder of the Netherlands adhered to the common -# practice of following Amsterdam mean time. -# -# (2001-04-09): -# In 1835 the authorities of the province of North Holland requested the -# municipal authorities of the towns and cities in the province to observe -# Amsterdam mean time but I do not know in how many cases this request was -# actually followed. -# -# From 1852 onwards the Dutch telegraph offices were by law required to -# observe Amsterdam mean time. As the time signals from the observatory of -# Leiden were also distributed by the telegraph system, I assume that most -# places linked up with the telegraph (and railway) system automatically -# adopted Amsterdam mean time. -# -# Although the early Dutch railway companies initially observed a variety -# of times, most of them had adopted Amsterdam mean time by 1858 but it -# was not until 1866 when they were all required by law to observe -# Amsterdam mean time. - -# The data entries before 1945 are taken from -# https://www.staff.science.uu.nl/~gent0113/wettijd/wettijd.htm - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Neth 1916 only - May 1 0:00 1:00 NST # Netherlands Summer Time -Rule Neth 1916 only - Oct 1 0:00 0 AMT # Amsterdam Mean Time -Rule Neth 1917 only - Apr 16 2:00s 1:00 NST -Rule Neth 1917 only - Sep 17 2:00s 0 AMT -Rule Neth 1918 1921 - Apr Mon>=1 2:00s 1:00 NST -Rule Neth 1918 1921 - Sep lastMon 2:00s 0 AMT -Rule Neth 1922 only - Mar lastSun 2:00s 1:00 NST -Rule Neth 1922 1936 - Oct Sun>=2 2:00s 0 AMT -Rule Neth 1923 only - Jun Fri>=1 2:00s 1:00 NST -Rule Neth 1924 only - Mar lastSun 2:00s 1:00 NST -Rule Neth 1925 only - Jun Fri>=1 2:00s 1:00 NST -# From 1926 through 1939 DST began 05-15, except that it was delayed by a week -# in years when 05-15 fell in the Pentecost weekend. -Rule Neth 1926 1931 - May 15 2:00s 1:00 NST -Rule Neth 1932 only - May 22 2:00s 1:00 NST -Rule Neth 1933 1936 - May 15 2:00s 1:00 NST -Rule Neth 1937 only - May 22 2:00s 1:00 NST -Rule Neth 1937 only - Jul 1 0:00 1:00 S -Rule Neth 1937 1939 - Oct Sun>=2 2:00s 0 - -Rule Neth 1938 1939 - May 15 2:00s 1:00 S -Rule Neth 1945 only - Apr 2 2:00s 1:00 S -Rule Neth 1945 only - Sep 16 2:00s 0 - -# -# Amsterdam Mean Time was +00:19:32.13, but the .13 is omitted -# below because the current format requires GMTOFF to be an integer. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Amsterdam 0:19:32 - LMT 1835 - 0:19:32 Neth %s 1937 Jul 1 - 0:20 Neth +0020/+0120 1940 May 16 0:00 - 1:00 C-Eur CE%sT 1945 Apr 2 2:00 - 1:00 Neth CE%sT 1977 - 1:00 EU CE%sT - -# Norway -# http://met.no/met/met_lex/q_u/sommertid.html (2004-01) agrees with Shanks & -# Pottenger. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Norway 1916 only - May 22 1:00 1:00 S -Rule Norway 1916 only - Sep 30 0:00 0 - -Rule Norway 1945 only - Apr 2 2:00s 1:00 S -Rule Norway 1945 only - Oct 1 2:00s 0 - -Rule Norway 1959 1964 - Mar Sun>=15 2:00s 1:00 S -Rule Norway 1959 1965 - Sep Sun>=15 2:00s 0 - -Rule Norway 1965 only - Apr 25 2:00s 1:00 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 - 1:00 Norway CE%sT 1940 Aug 10 23:00 - 1:00 C-Eur CE%sT 1945 Apr 2 2:00 - 1:00 Norway CE%sT 1980 - 1:00 EU CE%sT - -# Svalbard & Jan Mayen - -# From Steffen Thorsen (2001-05-01): -# Although I could not find it explicitly, it seems that Jan Mayen and -# Svalbard have been using the same time as Norway at least since the -# time they were declared as parts of Norway. Svalbard was declared -# as a part of Norway by law of 1925-07-17 no 11, section 4 and Jan -# Mayen by law of 1930-02-27 no 2, section 2. (From -# <http://www.lovdata.no/all/nl-19250717-011.html> and -# <http://www.lovdata.no/all/nl-19300227-002.html>). The law/regulation -# for normal/standard time in Norway is from 1894-06-29 no 1 (came -# into operation on 1895-01-01) and Svalbard/Jan Mayen seem to be a -# part of this law since 1925/1930. (From -# <http://www.lovdata.no/all/nl-18940629-001.html>) I have not been -# able to find if Jan Mayen used a different time zone (e.g. -0100) -# before 1930. Jan Mayen has only been "inhabited" since 1921 by -# Norwegian meteorologists and maybe used the same time as Norway ever -# since 1921. Svalbard (Arctic/Longyearbyen) has been inhabited since -# before 1895, and therefore probably changed the local time somewhere -# between 1895 and 1925 (inclusive). - -# From Paul Eggert (2013-09-04): -# -# Actually, Jan Mayen was never occupied by Germany during World War II, -# so it must have diverged from Oslo time during the war, as Oslo was -# keeping Berlin time. -# -# <https://www.jan-mayen.no/history.htm> says that the meteorologists -# burned down their station in 1940 and left the island, but returned in -# 1941 with a small Norwegian garrison and continued operations despite -# frequent air attacks from Germans. In 1943 the Americans established a -# radiolocating station on the island, called "Atlantic City". Possibly -# the UT offset changed during the war, but I think it unlikely that -# Jan Mayen used German daylight-saving rules. -# -# Svalbard is more complicated, as it was raided in August 1941 by an -# Allied party that evacuated the civilian population to England (says -# <http://www.bartleby.com/65/sv/Svalbard.html>). The Svalbard FAQ -# <http://www.svalbard.com/SvalbardFAQ.html> says that the Germans were -# expelled on 1942-05-14. However, small parties of Germans did return, -# and according to Wilhelm Dege's book "War North of 80" (1954) -# http://www.ucalgary.ca/UofC/departments/UP/1-55238/1-55238-110-2.html -# the German armed forces at the Svalbard weather station code-named -# Haudegen did not surrender to the Allies until September 1945. -# -# All these events predate our cutoff date of 1970, so use Europe/Oslo -# for these regions. -Link Europe/Oslo Arctic/Longyearbyen - -# Poland - -# The 1919 dates and times can be found in Tygodnik Urzędowy nr 1 (1919-03-20), -# <http://www.wbc.poznan.pl/publication/32156> pp 1-2. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Poland 1918 1919 - Sep 16 2:00s 0 - -Rule Poland 1919 only - Apr 15 2:00s 1:00 S -Rule Poland 1944 only - Apr 3 2:00s 1:00 S -# Whitman gives 1944 Nov 30; go with Shanks & Pottenger. -Rule Poland 1944 only - Oct 4 2:00 0 - -# For 1944-1948 Whitman gives the previous day; go with Shanks & Pottenger. -Rule Poland 1945 only - Apr 29 0:00 1:00 S -Rule Poland 1945 only - Nov 1 0:00 0 - -# For 1946 on the source is Kazimierz Borkowski, -# Toruń Center for Astronomy, Dept. of Radio Astronomy, Nicolaus Copernicus U., -# https://www.astro.uni.torun.pl/~kb/Artykuly/U-PA/Czas2.htm#tth_tAb1 -# Thanks to Przemysław Augustyniak (2005-05-28) for this reference. -# He also gives these further references: -# Mon Pol nr 13, poz 162 (1995) <http://www.abc.com.pl/serwis/mp/1995/0162.htm> -# Druk nr 2180 (2003) <http://www.senat.gov.pl/k5/dok/sejm/053/2180.pdf> -Rule Poland 1946 only - Apr 14 0:00s 1:00 S -Rule Poland 1946 only - Oct 7 2:00s 0 - -Rule Poland 1947 only - May 4 2:00s 1:00 S -Rule Poland 1947 1949 - Oct Sun>=1 2:00s 0 - -Rule Poland 1948 only - Apr 18 2:00s 1:00 S -Rule Poland 1949 only - Apr 10 2:00s 1:00 S -Rule Poland 1957 only - Jun 2 1:00s 1:00 S -Rule Poland 1957 1958 - Sep lastSun 1:00s 0 - -Rule Poland 1958 only - Mar 30 1:00s 1:00 S -Rule Poland 1959 only - May 31 1:00s 1:00 S -Rule Poland 1959 1961 - Oct Sun>=1 1:00s 0 - -Rule Poland 1960 only - Apr 3 1:00s 1:00 S -Rule Poland 1961 1964 - May lastSun 1:00s 1:00 S -Rule Poland 1962 1964 - Sep lastSun 1:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Warsaw 1:24:00 - LMT 1880 - 1:24:00 - WMT 1915 Aug 5 # Warsaw Mean Time - 1:00 C-Eur CE%sT 1918 Sep 16 3:00 - 2:00 Poland EE%sT 1922 Jun - 1:00 Poland CE%sT 1940 Jun 23 2:00 - 1:00 C-Eur CE%sT 1944 Oct - 1:00 Poland CE%sT 1977 - 1:00 W-Eur CE%sT 1988 - 1:00 EU CE%sT - -# Portugal - -# From Paul Eggert (2014-08-11), after a heads-up from Stephen Colebourne: -# According to a Portuguese decree (1911-05-26) -# https://dre.pt/application/dir/pdf1sdip/1911/05/12500/23132313.pdf -# Lisbon was at -0:36:44.68, but switched to GMT on 1912-01-01 at 00:00. -# Round the old offset to -0:36:45. This agrees with Willett.... -# -# From Michael Deckers (2018-02-15): -# article 5 [of the 1911 decree; Deckers's translation] ...: -# These dispositions shall enter into force at the instant at which, -# according to the 2nd article, the civil day January 1, 1912 begins, -# all clocks therefore having to be advanced or set back correspondingly ... - -# From Rui Pedro Salgueiro (1992-11-12): -# Portugal has recently (September, 27) changed timezone -# (from WET to MET or CET) to harmonize with EEC. -# -# Martin Bruckmann (1996-02-29) reports via Peter Ilieve -# that Portugal is reverting to 0:00 by not moving its clocks this spring. -# The new Prime Minister was fed up with getting up in the dark in the winter. -# -# From Paul Eggert (1996-11-12): -# IATA SSIM (1991-09) reports several 1991-09 and 1992-09 transitions -# at 02:00u, not 01:00u. Assume that these are typos. -# IATA SSIM (1991/1992) reports that the Azores were at -1:00. -# IATA SSIM (1993-02) says +0:00; later issues (through 1996-09) say -1:00. -# Guess that the Azores changed to EU rules in 1992 (since that's when Portugal -# harmonized with EU rules), and that they stayed +0:00 that winter. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# DSH writes that despite Decree 1,469 (1915), the change to the clocks was not -# done every year, depending on what Spain did, because of railroad schedules. -# Go with Shanks & Pottenger. -Rule Port 1916 only - Jun 17 23:00 1:00 S -# Whitman gives 1916 Oct 31; go with Shanks & Pottenger. -Rule Port 1916 only - Nov 1 1:00 0 - -Rule Port 1917 only - Feb 28 23:00s 1:00 S -Rule Port 1917 1921 - Oct 14 23:00s 0 - -Rule Port 1918 only - Mar 1 23:00s 1:00 S -Rule Port 1919 only - Feb 28 23:00s 1:00 S -Rule Port 1920 only - Feb 29 23:00s 1:00 S -Rule Port 1921 only - Feb 28 23:00s 1:00 S -Rule Port 1924 only - Apr 16 23:00s 1:00 S -Rule Port 1924 only - Oct 14 23:00s 0 - -Rule Port 1926 only - Apr 17 23:00s 1:00 S -Rule Port 1926 1929 - Oct Sat>=1 23:00s 0 - -Rule Port 1927 only - Apr 9 23:00s 1:00 S -Rule Port 1928 only - Apr 14 23:00s 1:00 S -Rule Port 1929 only - Apr 20 23:00s 1:00 S -Rule Port 1931 only - Apr 18 23:00s 1:00 S -# Whitman gives 1931 Oct 8; go with Shanks & Pottenger. -Rule Port 1931 1932 - Oct Sat>=1 23:00s 0 - -Rule Port 1932 only - Apr 2 23:00s 1:00 S -Rule Port 1934 only - Apr 7 23:00s 1:00 S -# Whitman gives 1934 Oct 5; go with Shanks & Pottenger. -Rule Port 1934 1938 - Oct Sat>=1 23:00s 0 - -# Shanks & Pottenger give 1935 Apr 30; go with Whitman. -Rule Port 1935 only - Mar 30 23:00s 1:00 S -Rule Port 1936 only - Apr 18 23:00s 1:00 S -# Whitman gives 1937 Apr 2; go with Shanks & Pottenger. -Rule Port 1937 only - Apr 3 23:00s 1:00 S -Rule Port 1938 only - Mar 26 23:00s 1:00 S -Rule Port 1939 only - Apr 15 23:00s 1:00 S -# Whitman gives 1939 Oct 7; go with Shanks & Pottenger. -Rule Port 1939 only - Nov 18 23:00s 0 - -Rule Port 1940 only - Feb 24 23:00s 1:00 S -# Shanks & Pottenger give 1940 Oct 7; go with Whitman. -Rule Port 1940 1941 - Oct 5 23:00s 0 - -Rule Port 1941 only - Apr 5 23:00s 1:00 S -Rule Port 1942 1945 - Mar Sat>=8 23:00s 1:00 S -Rule Port 1942 only - Apr 25 22:00s 2:00 M # Midsummer -Rule Port 1942 only - Aug 15 22:00s 1:00 S -Rule Port 1942 1945 - Oct Sat>=24 23:00s 0 - -Rule Port 1943 only - Apr 17 22:00s 2:00 M -Rule Port 1943 1945 - Aug Sat>=25 22:00s 1:00 S -Rule Port 1944 1945 - Apr Sat>=21 22:00s 2:00 M -Rule Port 1946 only - Apr Sat>=1 23:00s 1:00 S -Rule Port 1946 only - Oct Sat>=1 23:00s 0 - -Rule Port 1947 1949 - Apr Sun>=1 2:00s 1:00 S -Rule Port 1947 1949 - Oct Sun>=1 2:00s 0 - -# Shanks & Pottenger say DST was observed in 1950; go with Whitman. -# Whitman gives Oct lastSun for 1952 on; go with Shanks & Pottenger. -Rule Port 1951 1965 - Apr Sun>=1 2:00s 1:00 S -Rule Port 1951 1965 - Oct Sun>=1 2:00s 0 - -Rule Port 1977 only - Mar 27 0:00s 1:00 S -Rule Port 1977 only - Sep 25 0:00s 0 - -Rule Port 1978 1979 - Apr Sun>=1 0:00s 1:00 S -Rule Port 1978 only - Oct 1 0:00s 0 - -Rule Port 1979 1982 - Sep lastSun 1:00s 0 - -Rule Port 1980 only - Mar lastSun 0:00s 1:00 S -Rule Port 1981 1982 - Mar lastSun 1:00s 1:00 S -Rule Port 1983 only - Mar lastSun 2:00s 1:00 S -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Lisbon -0:36:45 - LMT 1884 - -0:36:45 - LMT 1912 Jan 1 0:00u # Lisbon MT - 0:00 Port WE%sT 1966 Apr 3 2:00 - 1:00 - CET 1976 Sep 26 1:00 - 0:00 Port WE%sT 1983 Sep 25 1:00s - 0:00 W-Eur WE%sT 1992 Sep 27 1:00s - 1:00 EU CE%sT 1996 Mar 31 1:00u - 0:00 EU WE%sT -# This Zone can be simplified once we assume zic %z. -Zone Atlantic/Azores -1:42:40 - LMT 1884 # Ponta Delgada - -1:54:32 - HMT 1912 Jan 1 2:00u # Horta MT - -2:00 Port -02/-01 1942 Apr 25 22:00s - -2:00 Port +00 1942 Aug 15 22:00s - -2:00 Port -02/-01 1943 Apr 17 22:00s - -2:00 Port +00 1943 Aug 28 22:00s - -2:00 Port -02/-01 1944 Apr 22 22:00s - -2:00 Port +00 1944 Aug 26 22:00s - -2:00 Port -02/-01 1945 Apr 21 22:00s - -2:00 Port +00 1945 Aug 25 22:00s - -2:00 Port -02/-01 1966 Apr 3 2:00 - -1:00 Port -01/+00 1983 Sep 25 1:00s - -1:00 W-Eur -01/+00 1992 Sep 27 1:00s - 0:00 EU WE%sT 1993 Mar 28 1:00u - -1:00 EU -01/+00 -# This Zone can be simplified once we assume zic %z. -Zone Atlantic/Madeira -1:07:36 - LMT 1884 # Funchal - -1:07:36 - FMT 1912 Jan 1 1:00u # Funchal MT - -1:00 Port -01/+00 1942 Apr 25 22:00s - -1:00 Port +01 1942 Aug 15 22:00s - -1:00 Port -01/+00 1943 Apr 17 22:00s - -1:00 Port +01 1943 Aug 28 22:00s - -1:00 Port -01/+00 1944 Apr 22 22:00s - -1:00 Port +01 1944 Aug 26 22:00s - -1:00 Port -01/+00 1945 Apr 21 22:00s - -1:00 Port +01 1945 Aug 25 22:00s - -1:00 Port -01/+00 1966 Apr 3 2:00 - 0:00 Port WE%sT 1983 Sep 25 1:00s - 0:00 EU WE%sT - -# Romania -# -# From Paul Eggert (1999-10-07): -# Nine O'clock <http://www.nineoclock.ro/POL/1778pol.html> -# (1998-10-23) reports that the switch occurred at -# 04:00 local time in fall 1998. For lack of better info, -# assume that Romania and Moldova switched to EU rules in 1997, -# the same year as Bulgaria. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Romania 1932 only - May 21 0:00s 1:00 S -Rule Romania 1932 1939 - Oct Sun>=1 0:00s 0 - -Rule Romania 1933 1939 - Apr Sun>=2 0:00s 1:00 S -Rule Romania 1979 only - May 27 0:00 1:00 S -Rule Romania 1979 only - Sep lastSun 0:00 0 - -Rule Romania 1980 only - Apr 5 23:00 1:00 S -Rule Romania 1980 only - Sep lastSun 1:00 0 - -Rule Romania 1991 1993 - Mar lastSun 0:00s 1:00 S -Rule Romania 1991 1993 - Sep lastSun 0:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct - 1:44:24 - BMT 1931 Jul 24 # Bucharest MT - 2:00 Romania EE%sT 1981 Mar 29 2:00s - 2:00 C-Eur EE%sT 1991 - 2:00 Romania EE%sT 1994 - 2:00 E-Eur EE%sT 1997 - 2:00 EU EE%sT - - -# Russia - -# From Alexander Krivenyshev (2011-09-15): -# Based on last Russian Government Decree No. 725 on August 31, 2011 -# (Government document -# http://www.government.ru/gov/results/16355/print/ -# in Russian) -# there are few corrections have to be made for some Russian time zones... -# All updated Russian Time Zones were placed in table and translated to English -# by WorldTimeZone.com at the link below: -# http://www.worldtimezone.com/dst_news/dst_news_russia36.htm - -# From Sanjeev Gupta (2011-09-27): -# Scans of [Decree No. 23 of January 8, 1992] are available at: -# http://government.consultant.ru/page.aspx?1223966 -# They are in Cyrillic letters (presumably Russian). - -# From Arthur David Olson (2012-05-09): -# Regarding the instant when clocks in time-zone-shifting parts of Russia -# changed in September 2011: -# -# One source is -# http://government.ru/gov/results/16355/ -# which, according to translate.google.com, begins "Decree of August 31, -# 2011 No. 725" and contains no other dates or "effective date" information. -# -# Another source is -# https://rg.ru/2011/09/06/chas-zona-dok.html -# which, according to translate.google.com, begins "Resolution of the -# Government of the Russian Federation on August 31, 2011 N 725" and also -# contains "Date first official publication: September 6, 2011 Posted on: -# in the 'RG' - Federal Issue No. 5573 September 6, 2011" but which -# does not contain any "effective date" information. -# -# Another source is -# https://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7 -# which, in note 8, contains "Resolution No. 725 of August 31, 2011... -# Effective as of after 7 days following the day of the official publication" -# but which does not contain any reference to September 6, 2011. -# -# The Wikipedia article refers to -# http://base.consultant.ru/cons/cgi/online.cgi?req=doc;base=LAW;n=118896 -# which seems to copy the text of the government.ru page. -# -# Tobias Conradi combines Wikipedia's -# "as of after 7 days following the day of the official publication" -# with www.rg.ru's "Date of first official publication: September 6, 2011" to -# get September 13, 2011 as the cutover date (unusually, a Tuesday, as Tobias -# Conradi notes). -# -# None of the sources indicates a time of day for changing clocks. -# -# Go with 2011-09-13 0:00s. - -# From Alexander Krivenyshev (2014-07-01): -# According to the Russian news (ITAR-TASS News Agency) -# http://en.itar-tass.com/russia/738562 -# the State Duma has approved ... the draft bill on returning to -# winter time standard and return Russia 11 time zones. The new -# regulations will come into effect on October 26, 2014 at 02:00 ... -# http://asozd2.duma.gov.ru/main.nsf/%28Spravka%29?OpenAgent&RN=431985-6&02 -# Here is a link where we put together table (based on approved Bill N -# 431985-6) with proposed 11 Russian time zones and corresponding -# areas/cities/administrative centers in the Russian Federation (in English): -# http://www.worldtimezone.com/dst_news/dst_news_russia65.html -# -# From Alexander Krivenyshev (2014-07-22): -# Putin signed the Federal Law 431985-6 ... (in Russian) -# http://itar-tass.com/obschestvo/1333711 -# http://www.pravo.gov.ru:8080/page.aspx?111660 -# http://www.kremlin.ru/acts/46279 -# From October 26, 2014 the new Russian time zone map will look like this: -# http://www.worldtimezone.com/dst_news/dst_news_russia-map-2014-07.html - -# From Paul Eggert (2006-03-22): -# Moscow time zone abbreviations after 1919-07-01, and Moscow rules after 1991, -# are from Andrey A. Chernov. The rest is from Shanks & Pottenger, -# except we follow Chernov's report that 1992 DST transitions were Sat -# 23:00, not Sun 02:00s. -# -# From Stanislaw A. Kuzikowski (1994-06-29): -# But now it is some months since Novosibirsk is 3 hours ahead of Moscow! -# I do not know why they have decided to make this change; -# as far as I remember it was done exactly during winter->summer switching -# so we (Novosibirsk) simply did not switch. -# -# From Andrey A. Chernov (1996-10-04): -# 'MSK' and 'MSD' were born and used initially on Moscow computers with -# UNIX-like OSes by several developer groups (e.g. Demos group, Kiae group).... -# The next step was the UUCP network, the Relcom predecessor -# (used mainly for mail), and MSK/MSD was actively used there. -# -# From Chris Carrier (1996-10-30): -# According to a friend of mine who rode the Trans-Siberian Railroad from -# Moscow to Irkutsk in 1995, public air and rail transport in Russia ... -# still follows Moscow time, no matter where in Russia it is located. -# -# For Grozny, Chechnya, we have the following story from -# John Daniszewski, "Scavengers in the Rubble", Los Angeles Times (2001-02-07): -# News - often false - is spread by word of mouth. A rumor that it was -# time to move the clocks back put this whole city out of sync with -# the rest of Russia for two weeks - even soldiers stationed here began -# enforcing curfew at the wrong time. -# -# From Gwillim Law (2001-06-05): -# There's considerable evidence that Sakhalin Island used to be in -# UTC+11, and has changed to UTC+10, in this decade. I start with the -# SSIM, which listed Yuzhno-Sakhalinsk in zone RU10 along with Magadan -# until February 1997, and then in RU9 with Khabarovsk and Vladivostok -# since September 1997.... Although the Kuril Islands are -# administratively part of Sakhalin oblast', they appear to have -# remained on UTC+11 along with Magadan. - -# From Marat Nigametzianov (2018-07-16): -# this is link to order from 1956 about timezone in USSR -# http://astro.uni-altai.ru/~orion/blog/2011/11/novyie-granitsyi-chasovyih-poyasov-v-sssr/ -# -# From Paul Eggert (2018-07-16): -# Perhaps someone could translate the above-mentioned link and use it -# to correct our data for the ex-Soviet Union. It cites the following: -# «Поясное время и новые границы часовых поясов» / сост. П.Н. Долгов, -# отв. ред. Г.Д. Бурдун - М: Комитет стандартов, мер и измерительных -# приборов при Совете Министров СССР, Междуведомственная комиссия -# единой службы времени, 1956 г. -# This book looks like it would be a helpful resource for the Soviet -# Union through 1956. Although a copy was in the Scientific Library -# of Tomsk State University, I have not been able to track down a copy nearby. -# -# From Stepan Golosunov (2018-07-21): -# http://astro.uni-altai.ru/~orion/blog/2015/05/center-reforma-ischisleniya-vremeni-br-na-territorii-sssr-v-1957-godu-center/ -# says that the 1956 decision to change time belts' borders was not -# implemented as planned in 1956 and the change happened in 1957. -# There is also the problem that actual time zones were different from -# the official time belts (and from many time belts' maps) as there were -# numerous exceptions to application of time belt rules. For example, -# https://ru.wikipedia.org/wiki/Московское_время#Перемещение_границы_применения_московского_времени_на_восток -# says that by 1962 there were many regions in the 3rd time belt that -# were on Moscow time, referring to a 1962 map. By 1989 number of such -# exceptions grew considerably. - -# From Tim Parenti (2014-07-06): -# The comments detailing the coverage of each Russian zone are meant to assist -# with maintenance only and represent our best guesses as to which regions -# are covered by each zone. They are not meant to be taken as an authoritative -# listing. The region codes listed come from -# https://en.wikipedia.org/w/?title=Federal_subjects_of_Russia&oldid=611810498 -# and are used for convenience only; no guarantees are made regarding their -# future stability. ISO 3166-2:RU codes are also listed for first-level -# divisions where available. - -# From Tim Parenti (2014-07-03): -# Europe/Kaliningrad covers... -# 39 RU-KGD Kaliningrad Oblast - -# From Paul Eggert (2016-03-18): -# The 1989 transition is from USSR act No. 227 (1989-03-14). - -# From Stepan Golosunov (2016-03-07): -# http://www.rgo.ru/ru/kaliningradskoe-oblastnoe-otdelenie/ob-otdelenii/publikacii/kak-nam-zhilos-bez-letnego-vremeni -# confirms that the 1989 change to Moscow-1 was implemented. -# (The article, though, is misattributed to 1990 while saying that -# summer->winter transition would be done on the 24 of September. But -# 1990-09-24 was Monday, while 1989-09-24 was Sunday as expected.) -# ... -# http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091 -# says that Kaliningrad switched to Moscow-1 on 1989-03-26, avoided -# at the last moment switch to Moscow-1 on 1991-03-31, switched to -# Moscow on 1991-11-03, switched to Moscow-1 on 1992-01-19. - -Zone Europe/Kaliningrad 1:22:00 - LMT 1893 Apr - 1:00 C-Eur CE%sT 1945 - 2:00 Poland CE%sT 1946 - 3:00 Russia MSK/MSD 1989 Mar 26 2:00s - 2:00 Russia EE%sT 2011 Mar 27 2:00s - 3:00 - +03 2014 Oct 26 2:00s - 2:00 - EET - - -# From Paul Eggert (2016-02-21), per Tim Parenti (2014-07-03) and -# Oscar van Vlijmen (2001-08-25): -# Europe/Moscow covers... -# 01 RU-AD Adygea, Republic of -# 05 RU-DA Dagestan, Republic of -# 06 RU-IN Ingushetia, Republic of -# 07 RU-KB Kabardino-Balkar Republic -# 08 RU-KL Kalmykia, Republic of -# 09 RU-KC Karachay-Cherkess Republic -# 10 RU-KR Karelia, Republic of -# 11 RU-KO Komi Republic -# 12 RU-ME Mari El Republic -# 13 RU-MO Mordovia, Republic of -# 15 RU-SE North Ossetia-Alania, Republic of -# 16 RU-TA Tatarstan, Republic of -# 20 RU-CE Chechen Republic -# 21 RU-CU Chuvash Republic -# 23 RU-KDA Krasnodar Krai -# 26 RU-STA Stavropol Krai -# 29 RU-ARK Arkhangelsk Oblast -# 31 RU-BEL Belgorod Oblast -# 32 RU-BRY Bryansk Oblast -# 33 RU-VLA Vladimir Oblast -# 35 RU-VLG Vologda Oblast -# 36 RU-VOR Voronezh Oblast -# 37 RU-IVA Ivanovo Oblast -# 40 RU-KLU Kaluga Oblast -# 44 RU-KOS Kostroma Oblast -# 46 RU-KRS Kursk Oblast -# 47 RU-LEN Leningrad Oblast -# 48 RU-LIP Lipetsk Oblast -# 50 RU-MOS Moscow Oblast -# 51 RU-MUR Murmansk Oblast -# 52 RU-NIZ Nizhny Novgorod Oblast -# 53 RU-NGR Novgorod Oblast -# 57 RU-ORL Oryol Oblast -# 58 RU-PNZ Penza Oblast -# 60 RU-PSK Pskov Oblast -# 61 RU-ROS Rostov Oblast -# 62 RU-RYA Ryazan Oblast -# 67 RU-SMO Smolensk Oblast -# 68 RU-TAM Tambov Oblast -# 69 RU-TVE Tver Oblast -# 71 RU-TUL Tula Oblast -# 76 RU-YAR Yaroslavl Oblast -# 77 RU-MOW Moscow -# 78 RU-SPE Saint Petersburg -# 83 RU-NEN Nenets Autonomous Okrug - -# From Paul Eggert (2016-08-23): -# The Soviets switched to UT-based time in 1919. Decree No. 59 -# (1919-02-08) http://istmat.info/node/35567 established UT-based time -# zones, and Decree No. 147 (1919-03-29) http://istmat.info/node/35854 -# specified a transition date of 1919-07-01, apparently at 00:00 UT. -# No doubt only the Soviet-controlled regions switched on that date; -# later transitions to UT-based time in other parts of Russia are -# taken from what appear to be guesses by Shanks. -# (Thanks to Alexander Belopolsky for pointers to the decrees.) - -# From Stepan Golosunov (2016-03-07): -# 11. Regions-violators, 1981-1982. -# Wikipedia refers to -# http://maps.monetonos.ru/maps/raznoe/Old_Maps/Old_Maps/Articles/022/3_1981.html -# http://besp.narod.ru/nauka_1981_3.htm -# -# The second link provides two articles scanned from the Nauka i Zhizn -# magazine No. 3, 1981 and a scan of the short article attributed to -# the Trud newspaper from February 1982. The first link provides the -# same Nauka i Zhizn articles converted to the text form (but misses -# time belt changes map). -# -# The second Nauka i Zhizn article says that in addition to -# introduction of summer time on 1981-04-01 there are some time belt -# border changes on 1981-10-01, mostly affecting Nenets Autonomous -# Okrug, Krasnoyarsk Krai, Yakutia, Magadan Oblast and Chukotka -# according to the provided map (colored one). In addition to that -# "time violators" (regions which were not using rules of the time -# belts in which they were located) would not be moving off the DST on -# 1981-10-01 to restore the decree time usage. (Komi ASSR was -# supposed to repeat that move in October 1982 to account for the 2 -# hour difference.) Map depicting "time violators" before 1981-10-01 -# is also provided. -# -# The article from Trud says that 1981-10-01 changes caused problems -# and some territories would be moved to pre-1981-10-01 time by not -# moving to summer time on 1982-04-01. Namely: Dagestan, -# Kabardino-Balkar, Kalmyk, Komi, Mari, Mordovian, North Ossetian, -# Tatar, Chechen-Ingush and Chuvash ASSR, Krasnodar and Stavropol -# krais, Arkhangelsk, Vladimir, Vologda, Voronezh, Gorky, Ivanovo, -# Kostroma, Lipetsk, Penza, Rostov, Ryazan, Tambov, Tyumen and -# Yaroslavl oblasts, Nenets and Evenk autonomous okrugs, Khatangsky -# district of Taymyr Autonomous Okrug. As a result Evenk Autonomous -# Okrug and Khatangsky district of Taymyr Autonomous Okrug would end -# up on Moscow+4, Tyumen Oblast on Moscow+2 and the rest on Moscow -# time. -# -# http://astrozet.net/files/Zones/DOC/RU/1980-925.txt -# attributes the 1982 changes to the Act of the Council of Ministers -# of the USSR No. 126 from 18.02.1982. 1980-925.txt also adds -# Udmurtia to the list of affected territories and lists Khatangsky -# district separately from Taymyr Autonomous Okrug. Probably erroneously. -# -# The affected territories are currently listed under Europe/Moscow, -# Asia/Yekaterinburg and Asia/Krasnoyarsk. -# -# 12. Udmurtia -# The fact that Udmurtia is depicted as a violator in the Nauka i -# Zhizn article hints at Izhevsk being on different time from -# Kuybyshev before 1981-10-01. Udmurtia is not mentioned in the 1989 act. -# http://astrozet.net/files/Zones/DOC/RU/1980-925.txt -# implies Udmurtia was on Moscow time after 1982-04-01. -# Wikipedia implies Udmurtia being on Moscow+1 until 1991. -# -# ... -# -# All Russian zones are supposed to have by default a -1 change at -# 1991-03-31 2:00 (cancellation of the decree time in the USSR) and a +1 -# change at 1992-01-19 2:00 (restoration of the decree time in Russia). -# -# There were some exceptions, though. -# Wikipedia says newspapers listed Astrakhan, Saratov, Kirov, Volgograd, -# Izhevsk, Grozny, Kazan and Samara as such exceptions for the 1992 -# change. (Different newspapers providing different lists. And some -# lists found in the internet are quite wild.) -# -# And apparently some exceptions were reverted in the last moment. -# http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091 -# says that Kaliningrad decided not to be an exception 2 days before the -# 1991-03-31 switch and one person at -# https://izhevsk.ru/forum_light_message/50/682597-m8369040.html -# says he remembers that Samara opted out of the 1992-01-19 exception -# 2 days before the switch. -# -# -# From Paul Eggert (2016-03-18): -# Given the above, we appear to be missing some Zone entries for the -# chaotic early 1980s in Russia. It's not clear what these entries -# should be. For now, sweep this under the rug and just document the -# time in Moscow. - -# From Vladimir Karpinsky (2014-07-08): -# LMT in Moscow (before Jul 3, 1916) is 2:30:17, that was defined by Moscow -# Observatory (coordinates: 55° 45' 29.70", 37° 34' 05.30").... -# LMT in Moscow since Jul 3, 1916 is 2:31:01 as a result of new standard. -# (The info is from the book by Byalokoz ... p. 18.) -# The time in St. Petersburg as capital of Russia was defined by -# Pulkov observatory, near St. Petersburg. In 1916 LMT Moscow -# was synchronized with LMT St. Petersburg (+30 minutes), (Pulkov observatory -# coordinates: 59° 46' 18.70", 30° 19' 40.70") so 30° 19' 40.70" > -# 2h01m18.7s = 2:01:19. LMT Moscow = LMT St.Petersburg + 30m 2:01:19 + 0:30 = -# 2:31:19 ... -# -# From Paul Eggert (2014-07-08): -# Milne does not list Moscow, but suggests that its time might be listed in -# Résumés mensuels et annuels des observations météorologiques (1895). -# Presumably this is OCLC 85825704, a journal published with parallel text in -# Russian and French. This source has not been located; go with Karpinsky. - -Zone Europe/Moscow 2:30:17 - LMT 1880 - 2:30:17 - MMT 1916 Jul 3 # Moscow Mean Time - 2:31:19 Russia %s 1919 Jul 1 0:00u - 3:00 Russia %s 1921 Oct - 3:00 Russia MSK/MSD 1922 Oct - 2:00 - EET 1930 Jun 21 - 3:00 Russia MSK/MSD 1991 Mar 31 2:00s - 2:00 Russia EE%sT 1992 Jan 19 2:00s - 3:00 Russia MSK/MSD 2011 Mar 27 2:00s - 4:00 - MSK 2014 Oct 26 2:00s - 3:00 - MSK - - -# From Paul Eggert (2016-12-06): -# Europe/Simferopol covers Crimea. - -Zone Europe/Simferopol 2:16:24 - LMT 1880 - 2:16 - SMT 1924 May 2 # Simferopol Mean T - 2:00 - EET 1930 Jun 21 - 3:00 - MSK 1941 Nov - 1:00 C-Eur CE%sT 1944 Apr 13 - 3:00 Russia MSK/MSD 1990 - 3:00 - MSK 1990 Jul 1 2:00 - 2:00 - EET 1992 -# Central Crimea used Moscow time 1994/1997. -# -# From Paul Eggert (2006-03-22): -# The _Economist_ (1994-05-28, p 45) reports that central Crimea switched -# from Kiev to Moscow time sometime after the January 1994 elections. -# Shanks (1999) says "date of change uncertain", but implies that it happened -# sometime between the 1994 DST switches. Shanks & Pottenger simply say -# 1994-09-25 03:00, but that can't be right. For now, guess it -# changed in May. - 2:00 E-Eur EE%sT 1994 May -# From IATA SSIM (1994/1997), which also says that Kerch is still like Kiev. - 3:00 E-Eur MSK/MSD 1996 Mar 31 0:00s - 3:00 1:00 MSD 1996 Oct 27 3:00s -# IATA SSIM (1997-09) says Crimea switched to EET/EEST. -# Assume it happened in March by not changing the clocks. - 3:00 Russia MSK/MSD 1997 - 3:00 - MSK 1997 Mar lastSun 1:00u -# From Alexander Krivenyshev (2014-03-17): -# time change at 2:00 (2am) on March 30, 2014 -# https://vz.ru/news/2014/3/17/677464.html -# From Paul Eggert (2014-03-30): -# Simferopol and Sevastopol reportedly changed their central town clocks -# late the previous day, but this appears to have been ceremonial -# and the discrepancies are small enough to not worry about. - 2:00 EU EE%sT 2014 Mar 30 2:00 - 4:00 - MSK 2014 Oct 26 2:00s - 3:00 - MSK - - -# From Paul Eggert (2016-03-18): -# Europe/Astrakhan covers: -# 30 RU-AST Astrakhan Oblast -# -# The 1989 transition is from USSR act No. 227 (1989-03-14). - -# From Alexander Krivenyshev (2016-01-12): -# On February 10, 2016 Astrakhan Oblast got approval by the Federation -# Council to change its time zone to UTC+4 (from current UTC+3 Moscow time).... -# This Federal Law shall enter into force on 27 March 2016 at 02:00. -# From Matt Johnson (2016-03-09): -# http://publication.pravo.gov.ru/Document/View/0001201602150056 - -Zone Europe/Astrakhan 3:12:12 - LMT 1924 May - 3:00 - +03 1930 Jun 21 - 4:00 Russia +04/+05 1989 Mar 26 2:00s - 3:00 Russia +03/+04 1991 Mar 31 2:00s - 4:00 - +04 1992 Mar 29 2:00s - 3:00 Russia +03/+04 2011 Mar 27 2:00s - 4:00 - +04 2014 Oct 26 2:00s - 3:00 - +03 2016 Mar 27 2:00s - 4:00 - +04 - -# From Paul Eggert (2016-11-11): -# Europe/Volgograd covers: -# 34 RU-VGG Volgograd Oblast -# The 1988 transition is from USSR act No. 5 (1988-01-04). - -# From Alexander Fetisov (2018-09-20): -# Volgograd region in southern Russia (Europe/Volgograd) change -# timezone from UTC+3 to UTC+4 from 28oct2018. -# http://sozd.parliament.gov.ru/bill/452878-7 -# -# From Stepan Golosunov (2018-10-11): -# The law has been published today on -# http://publication.pravo.gov.ru/Document/View/0001201810110037 - -Zone Europe/Volgograd 2:57:40 - LMT 1920 Jan 3 - 3:00 - +03 1930 Jun 21 - 4:00 - +04 1961 Nov 11 - 4:00 Russia +04/+05 1988 Mar 27 2:00s - 3:00 Russia +03/+04 1991 Mar 31 2:00s - 4:00 - +04 1992 Mar 29 2:00s - 3:00 Russia +03/+04 2011 Mar 27 2:00s - 4:00 - +04 2014 Oct 26 2:00s - 3:00 - +03 2018 Oct 28 2:00s - 4:00 - +04 - -# From Paul Eggert (2016-11-11): -# Europe/Saratov covers: -# 64 RU-SAR Saratov Oblast - -# From Yuri Konotopov (2016-11-11): -# Dec 4, 2016 02:00 UTC+3.... Saratov Region's local time will be ... UTC+4. -# From Stepan Golosunov (2016-11-11): -# ... Byalokoz listed Saratov on 03:04:18. -# From Stepan Golosunov (2016-11-22): -# http://publication.pravo.gov.ru/Document/View/0001201611220031 - -Zone Europe/Saratov 3:04:18 - LMT 1919 Jul 1 0:00u - 3:00 - +03 1930 Jun 21 - 4:00 Russia +04/+05 1988 Mar 27 2:00s - 3:00 Russia +03/+04 1991 Mar 31 2:00s - 4:00 - +04 1992 Mar 29 2:00s - 3:00 Russia +03/+04 2011 Mar 27 2:00s - 4:00 - +04 2014 Oct 26 2:00s - 3:00 - +03 2016 Dec 4 2:00s - 4:00 - +04 - -# From Paul Eggert (2016-03-18): -# Europe/Kirov covers: -# 43 RU-KIR Kirov Oblast -# The 1989 transition is from USSR act No. 227 (1989-03-14). -# -Zone Europe/Kirov 3:18:48 - LMT 1919 Jul 1 0:00u - 3:00 - +03 1930 Jun 21 - 4:00 Russia +04/+05 1989 Mar 26 2:00s - 3:00 Russia +03/+04 1991 Mar 31 2:00s - 4:00 - +04 1992 Mar 29 2:00s - 3:00 Russia +03/+04 2011 Mar 27 2:00s - 4:00 - +04 2014 Oct 26 2:00s - 3:00 - +03 - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25): -# Europe/Samara covers... -# 18 RU-UD Udmurt Republic -# 63 RU-SAM Samara Oblast - -# From Paul Eggert (2016-03-18): -# Byalokoz 1919 says Samara was 3:20:20. -# The 1989 transition is from USSR act No. 227 (1989-03-14). - -Zone Europe/Samara 3:20:20 - LMT 1919 Jul 1 0:00u - 3:00 - +03 1930 Jun 21 - 4:00 - +04 1935 Jan 27 - 4:00 Russia +04/+05 1989 Mar 26 2:00s - 3:00 Russia +03/+04 1991 Mar 31 2:00s - 2:00 Russia +02/+03 1991 Sep 29 2:00s - 3:00 - +03 1991 Oct 20 3:00 - 4:00 Russia +04/+05 2010 Mar 28 2:00s - 3:00 Russia +03/+04 2011 Mar 27 2:00s - 4:00 - +04 - -# From Paul Eggert (2016-03-18): -# Europe/Ulyanovsk covers: -# 73 RU-ULY Ulyanovsk Oblast - -# The 1989 transition is from USSR act No. 227 (1989-03-14). - -# From Alexander Krivenyshev (2016-02-17): -# Ulyanovsk ... on their way to change time zones by March 27, 2016 at 2am. -# Ulyanovsk Oblast ... from MSK to MSK+1 (UTC+3 to UTC+4) ... -# 920582-6 ... 02/17/2016 The State Duma passed the bill in the first reading. -# From Matt Johnson (2016-03-09): -# http://publication.pravo.gov.ru/Document/View/0001201603090051 - -Zone Europe/Ulyanovsk 3:13:36 - LMT 1919 Jul 1 0:00u - 3:00 - +03 1930 Jun 21 - 4:00 Russia +04/+05 1989 Mar 26 2:00s - 3:00 Russia +03/+04 1991 Mar 31 2:00s - 2:00 Russia +02/+03 1992 Jan 19 2:00s - 3:00 Russia +03/+04 2011 Mar 27 2:00s - 4:00 - +04 2014 Oct 26 2:00s - 3:00 - +03 2016 Mar 27 2:00s - 4:00 - +04 - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25): -# Asia/Yekaterinburg covers... -# 02 RU-BA Bashkortostan, Republic of -# 90 RU-PER Perm Krai -# 45 RU-KGN Kurgan Oblast -# 56 RU-ORE Orenburg Oblast -# 66 RU-SVE Sverdlovsk Oblast -# 72 RU-TYU Tyumen Oblast -# 74 RU-CHE Chelyabinsk Oblast -# 86 RU-KHM Khanty-Mansi Autonomous Okrug - Yugra -# 89 RU-YAN Yamalo-Nenets Autonomous Okrug -# -# Note: Effective 2005-12-01, (59) Perm Oblast and (81) Komi-Permyak -# Autonomous Okrug merged to form (90, RU-PER) Perm Krai. - -# Milne says Yekaterinburg was 4:02:32.9; round to nearest. -# Byalokoz 1919 says its provincial time was based on Perm, at 3:45:05. -# Assume it switched on 1916-07-03, the time of the new standard. -# The 1919 and 1930 transitions are from Shanks. - -Zone Asia/Yekaterinburg 4:02:33 - LMT 1916 Jul 3 - 3:45:05 - PMT 1919 Jul 15 4:00 - 4:00 - +04 1930 Jun 21 - 5:00 Russia +05/+06 1991 Mar 31 2:00s - 4:00 Russia +04/+05 1992 Jan 19 2:00s - 5:00 Russia +05/+06 2011 Mar 27 2:00s - 6:00 - +06 2014 Oct 26 2:00s - 5:00 - +05 - - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25): -# Asia/Omsk covers... -# 55 RU-OMS Omsk Oblast - -# Byalokoz 1919 says Omsk was 4:53:30. - -Zone Asia/Omsk 4:53:30 - LMT 1919 Nov 14 - 5:00 - +05 1930 Jun 21 - 6:00 Russia +06/+07 1991 Mar 31 2:00s - 5:00 Russia +05/+06 1992 Jan 19 2:00s - 6:00 Russia +06/+07 2011 Mar 27 2:00s - 7:00 - +07 2014 Oct 26 2:00s - 6:00 - +06 - -# From Paul Eggert (2016-02-22): -# Asia/Barnaul covers: -# 04 RU-AL Altai Republic -# 22 RU-ALT Altai Krai - -# Data before 1991 are from Shanks & Pottenger. - -# From Stepan Golosunov (2016-03-07): -# Letter of Bank of Russia from 1995-05-25 -# http://www.bestpravo.ru/rossijskoje/lj-akty/y3a.htm -# suggests that Altai Republic transitioned to Moscow+3 on -# 1995-05-28. -# -# https://regnum.ru/news/society/1957270.html -# has some historical data for Altai Krai: -# before 1957: west part on UT+6, east on UT+7 -# after 1957: UT+7 -# since 1995: UT+6 -# http://barnaul.rusplt.ru/index/pochemu_altajskij_kraj_okazalsja_v_neprivychnom_chasovom_pojase-17648.html -# confirms that and provides more details including 1995-05-28 transition date. - -# From Alexander Krivenyshev (2016-02-17): -# Altai Krai and Altai Republic on their way to change time zones -# by March 27, 2016 at 2am.... -# Altai Republic / Gorno-Altaysk MSK+3 to MSK+4 (UTC+6 to UTC+7) ... -# Altai Krai / Barnaul MSK+3 to MSK+4 (UTC+6 to UTC+7) -# From Matt Johnson (2016-03-09): -# http://publication.pravo.gov.ru/Document/View/0001201603090043 -# http://publication.pravo.gov.ru/Document/View/0001201603090038 - -Zone Asia/Barnaul 5:35:00 - LMT 1919 Dec 10 - 6:00 - +06 1930 Jun 21 - 7:00 Russia +07/+08 1991 Mar 31 2:00s - 6:00 Russia +06/+07 1992 Jan 19 2:00s - 7:00 Russia +07/+08 1995 May 28 - 6:00 Russia +06/+07 2011 Mar 27 2:00s - 7:00 - +07 2014 Oct 26 2:00s - 6:00 - +06 2016 Mar 27 2:00s - 7:00 - +07 - -# From Paul Eggert (2016-03-18): -# Asia/Novosibirsk covers: -# 54 RU-NVS Novosibirsk Oblast - -# From Stepan Golosunov (2016-05-30): -# http://asozd2.duma.gov.ru/main.nsf/(Spravka)?OpenAgent&RN=1085784-6 -# moves Novosibirsk oblast from UTC+6 to UTC+7. -# From Stepan Golosunov (2016-07-04): -# The law was signed yesterday and published today on -# http://publication.pravo.gov.ru/Document/View/0001201607040064 - -Zone Asia/Novosibirsk 5:31:40 - LMT 1919 Dec 14 6:00 - 6:00 - +06 1930 Jun 21 - 7:00 Russia +07/+08 1991 Mar 31 2:00s - 6:00 Russia +06/+07 1992 Jan 19 2:00s - 7:00 Russia +07/+08 1993 May 23 # say Shanks & P. - 6:00 Russia +06/+07 2011 Mar 27 2:00s - 7:00 - +07 2014 Oct 26 2:00s - 6:00 - +06 2016 Jul 24 2:00s - 7:00 - +07 - -# From Paul Eggert (2016-03-18): -# Asia/Tomsk covers: -# 70 RU-TOM Tomsk Oblast - -# From Stepan Golosunov (2016-03-24): -# Byalokoz listed Tomsk at 5:39:51. - -# From Stanislaw A. Kuzikowski (1994-06-29): -# Tomsk is still 4 hours ahead of Moscow. - -# From Stepan Golosunov (2016-03-19): -# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102075743 -# (fifth time belt being UTC+5+1(decree time) -# / UTC+5+1(decree time)+1(summer time)) ... -# Note that time belts (numbered from 2 (Moscow) to 12 according to their -# GMT/UTC offset and having too many exceptions like regions formally -# belonging to one belt but using time from another) were replaced -# with time zones in 2011 with different numbering (there was a -# 2-hour gap between second and third zones in 2011-2014). - -# From Stepan Golosunov (2016-04-12): -# http://asozd2.duma.gov.ru/main.nsf/(SpravkaNew)?OpenAgent&RN=1006865-6 -# This bill was approved in the first reading today. It moves Tomsk oblast -# from UTC+6 to UTC+7 and is supposed to come into effect on 2016-05-29 at -# 2:00. The bill needs to be approved in the second and the third readings by -# the State Duma, approved by the Federation Council, signed by the President -# and published to become a law. Minor changes in the text are to be expected -# before the second reading (references need to be updated to account for the -# recent changes). -# -# Judging by the ultra-short one-day amendments period, recent similar laws, -# the State Duma schedule and the Federation Council schedule -# http://www.duma.gov.ru/legislative/planning/day-shedule/por_vesna_2016/ -# http://council.gov.ru/activity/meetings/schedule/63303 -# I speculate that the final text of the bill will be proposed tomorrow, the -# bill will be approved in the second and the third readings on Friday, -# approved by the Federation Council on 2016-04-20, signed by the President and -# published as a law around 2016-04-26. - -# From Matt Johnson (2016-04-26): -# http://publication.pravo.gov.ru/Document/View/0001201604260048 - -Zone Asia/Tomsk 5:39:51 - LMT 1919 Dec 22 - 6:00 - +06 1930 Jun 21 - 7:00 Russia +07/+08 1991 Mar 31 2:00s - 6:00 Russia +06/+07 1992 Jan 19 2:00s - 7:00 Russia +07/+08 2002 May 1 3:00 - 6:00 Russia +06/+07 2011 Mar 27 2:00s - 7:00 - +07 2014 Oct 26 2:00s - 6:00 - +06 2016 May 29 2:00s - 7:00 - +07 - - -# From Tim Parenti (2014-07-03): -# Asia/Novokuznetsk covers... -# 42 RU-KEM Kemerovo Oblast - -# From Alexander Krivenyshev (2009-10-13): -# Kemerovo oblast' (Kemerovo region) in Russia will change current time zone on -# March 28, 2010: -# from current Russia Zone 6 - Krasnoyarsk Time Zone (KRA) UTC +0700 -# to Russia Zone 5 - Novosibirsk Time Zone (NOV) UTC +0600 -# -# This is according to Government of Russia decree No. 740, on September -# 14, 2009 "Application in the territory of the Kemerovo region the Fifth -# time zone." ("Russia Zone 5" or old "USSR Zone 5" is GMT +0600) -# -# Russian Government web site (Russian language) -# http://www.government.ru/content/governmentactivity/rfgovernmentdecisions/archive/2009/09/14/991633.htm -# or Russian-English translation by WorldTimeZone.com with reference -# map to local region and new Russia Time Zone map after March 28, 2010 -# http://www.worldtimezone.com/dst_news/dst_news_russia03.html -# -# Thus, when Russia will switch to DST on the night of March 28, 2010 -# Kemerovo region (Kemerovo oblast') will not change the clock. - -# From Tim Parenti (2014-07-02), per Alexander Krivenyshev (2014-07-02): -# The Kemerovo region will remain at UTC+7 through the 2014-10-26 change, thus -# realigning itself with KRAT. - -Zone Asia/Novokuznetsk 5:48:48 - LMT 1924 May 1 - 6:00 - +06 1930 Jun 21 - 7:00 Russia +07/+08 1991 Mar 31 2:00s - 6:00 Russia +06/+07 1992 Jan 19 2:00s - 7:00 Russia +07/+08 2010 Mar 28 2:00s - 6:00 Russia +06/+07 2011 Mar 27 2:00s - 7:00 - +07 - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25): -# Asia/Krasnoyarsk covers... -# 17 RU-TY Tuva Republic -# 19 RU-KK Khakassia, Republic of -# 24 RU-KYA Krasnoyarsk Krai -# -# Note: Effective 2007-01-01, (88) Evenk Autonomous Okrug and (84) Taymyr -# Autonomous Okrug were merged into (24, RU-KYA) Krasnoyarsk Krai. - -# Byalokoz 1919 says Krasnoyarsk was 6:11:26. - -Zone Asia/Krasnoyarsk 6:11:26 - LMT 1920 Jan 6 - 6:00 - +06 1930 Jun 21 - 7:00 Russia +07/+08 1991 Mar 31 2:00s - 6:00 Russia +06/+07 1992 Jan 19 2:00s - 7:00 Russia +07/+08 2011 Mar 27 2:00s - 8:00 - +08 2014 Oct 26 2:00s - 7:00 - +07 - - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25): -# Asia/Irkutsk covers... -# 03 RU-BU Buryatia, Republic of -# 38 RU-IRK Irkutsk Oblast -# -# Note: Effective 2008-01-01, (85) Ust-Orda Buryat Autonomous Okrug was -# merged into (38, RU-IRK) Irkutsk Oblast. - -# Milne 1899 says Irkutsk was 6:57:15. -# Byalokoz 1919 says Irkutsk was 6:57:05. -# Go with Byalokoz. - -Zone Asia/Irkutsk 6:57:05 - LMT 1880 - 6:57:05 - IMT 1920 Jan 25 # Irkutsk Mean Time - 7:00 - +07 1930 Jun 21 - 8:00 Russia +08/+09 1991 Mar 31 2:00s - 7:00 Russia +07/+08 1992 Jan 19 2:00s - 8:00 Russia +08/+09 2011 Mar 27 2:00s - 9:00 - +09 2014 Oct 26 2:00s - 8:00 - +08 - - -# From Tim Parenti (2014-07-06): -# Asia/Chita covers... -# 92 RU-ZAB Zabaykalsky Krai -# -# Note: Effective 2008-03-01, (75) Chita Oblast and (80) Agin-Buryat -# Autonomous Okrug merged to form (92, RU-ZAB) Zabaykalsky Krai. - -# From Alexander Krivenyshev (2016-01-02): -# [The] time zone in the Trans-Baikal Territory (Zabaykalsky Krai) - -# Asia/Chita [is changing] from UTC+8 to UTC+9. Effective date will -# be March 27, 2016 at 2:00am.... -# http://publication.pravo.gov.ru/Document/View/0001201512300107 - -Zone Asia/Chita 7:33:52 - LMT 1919 Dec 15 - 8:00 - +08 1930 Jun 21 - 9:00 Russia +09/+10 1991 Mar 31 2:00s - 8:00 Russia +08/+09 1992 Jan 19 2:00s - 9:00 Russia +09/+10 2011 Mar 27 2:00s - 10:00 - +10 2014 Oct 26 2:00s - 8:00 - +08 2016 Mar 27 2:00 - 9:00 - +09 - - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29): -# Asia/Yakutsk covers... -# 28 RU-AMU Amur Oblast -# -# ...and parts of (14, RU-SA) Sakha (Yakutia) Republic: -# 14-02 **** Aldansky District -# 14-04 **** Amginsky District -# 14-05 **** Anabarsky District -# 14-06 **** Bulunsky District -# 14-07 **** Verkhnevilyuysky District -# 14-10 **** Vilyuysky District -# 14-11 **** Gorny District -# 14-12 **** Zhigansky District -# 14-13 **** Kobyaysky District -# 14-14 **** Lensky District -# 14-15 **** Megino-Kangalassky District -# 14-16 **** Mirninsky District -# 14-18 **** Namsky District -# 14-19 **** Neryungrinsky District -# 14-21 **** Nyurbinsky District -# 14-23 **** Olenyoksky District -# 14-24 **** Olyokminsky District -# 14-26 **** Suntarsky District -# 14-27 **** Tattinsky District -# 14-29 **** Ust-Aldansky District -# 14-32 **** Khangalassky District -# 14-33 **** Churapchinsky District -# 14-34 **** Eveno-Bytantaysky National District - -# From Tim Parenti (2014-07-03): -# Our commentary seems to have lost mention of (14-19) Neryungrinsky District. -# Since the surrounding districts of Sakha are all YAKT, assume this is, too. -# Also assume its history has been the same as the rest of Asia/Yakutsk. - -# Byalokoz 1919 says Yakutsk was 8:38:58. - -Zone Asia/Yakutsk 8:38:58 - LMT 1919 Dec 15 - 8:00 - +08 1930 Jun 21 - 9:00 Russia +09/+10 1991 Mar 31 2:00s - 8:00 Russia +08/+09 1992 Jan 19 2:00s - 9:00 Russia +09/+10 2011 Mar 27 2:00s - 10:00 - +10 2014 Oct 26 2:00s - 9:00 - +09 - - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29): -# Asia/Vladivostok covers... -# 25 RU-PRI Primorsky Krai -# 27 RU-KHA Khabarovsk Krai -# 79 RU-YEV Jewish Autonomous Oblast -# -# ...and parts of (14, RU-SA) Sakha (Yakutia) Republic: -# 14-09 **** Verkhoyansky District -# 14-31 **** Ust-Yansky District - -# Milne 1899 says Vladivostok was 8:47:33.5. -# Byalokoz 1919 says Vladivostok was 8:47:31. -# Go with Byalokoz. - -Zone Asia/Vladivostok 8:47:31 - LMT 1922 Nov 15 - 9:00 - +09 1930 Jun 21 - 10:00 Russia +10/+11 1991 Mar 31 2:00s - 9:00 Russia +09/+10 1992 Jan 19 2:00s - 10:00 Russia +10/+11 2011 Mar 27 2:00s - 11:00 - +11 2014 Oct 26 2:00s - 10:00 - +10 - - -# From Tim Parenti (2014-07-03): -# Asia/Khandyga covers parts of (14, RU-SA) Sakha (Yakutia) Republic: -# 14-28 **** Tomponsky District -# 14-30 **** Ust-Maysky District - -# From Arthur David Olson (2012-05-09): -# Tomponskij and Ust'-Majskij switched from Vladivostok time to Yakutsk time -# in 2011. - -# From Paul Eggert (2012-11-25): -# Shanks and Pottenger (2003) has Khandyga on Yakutsk time. -# Make a wild guess that it switched to Vladivostok time in 2004. -# This transition is no doubt wrong, but we have no better info. - -Zone Asia/Khandyga 9:02:13 - LMT 1919 Dec 15 - 8:00 - +08 1930 Jun 21 - 9:00 Russia +09/+10 1991 Mar 31 2:00s - 8:00 Russia +08/+09 1992 Jan 19 2:00s - 9:00 Russia +09/+10 2004 - 10:00 Russia +10/+11 2011 Mar 27 2:00s - 11:00 - +11 2011 Sep 13 0:00s # Decree 725? - 10:00 - +10 2014 Oct 26 2:00s - 9:00 - +09 - - -# From Tim Parenti (2014-07-03): -# Asia/Sakhalin covers... -# 65 RU-SAK Sakhalin Oblast -# ...with the exception of: -# 65-11 **** Severo-Kurilsky District (North Kuril Islands) - -# From Matt Johnson (2016-02-22): -# Asia/Sakhalin is moving (in entirety) from UTC+10 to UTC+11 ... -# (2016-03-09): -# http://publication.pravo.gov.ru/Document/View/0001201603090044 - -# The Zone name should be Asia/Yuzhno-Sakhalinsk, but that's too long. -Zone Asia/Sakhalin 9:30:48 - LMT 1905 Aug 23 - 9:00 - +09 1945 Aug 25 - 11:00 Russia +11/+12 1991 Mar 31 2:00s # Sakhalin T - 10:00 Russia +10/+11 1992 Jan 19 2:00s - 11:00 Russia +11/+12 1997 Mar lastSun 2:00s - 10:00 Russia +10/+11 2011 Mar 27 2:00s - 11:00 - +11 2014 Oct 26 2:00s - 10:00 - +10 2016 Mar 27 2:00s - 11:00 - +11 - - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29): -# Asia/Magadan covers... -# 49 RU-MAG Magadan Oblast - -# From Tim Parenti (2014-07-06), per Alexander Krivenyshev (2014-07-02): -# Magadan Oblast is moving from UTC+12 to UTC+10 on 2014-10-26; however, -# several districts of Sakha Republic as well as Severo-Kurilsky District of -# the Sakhalin Oblast (also known as the North Kuril Islands), represented -# until now by Asia/Magadan, will instead move to UTC+11. These regions will -# need their own zone. - -# From Alexander Krivenyshev (2016-03-27): -# ... draft bill 948300-6 to change its time zone from UTC+10 to UTC+11 ... -# will take ... effect ... on April 24, 2016 at 2 o'clock -# -# From Matt Johnson (2016-04-05): -# ... signed by the President today ... -# http://publication.pravo.gov.ru/Document/View/0001201604050038 - -Zone Asia/Magadan 10:03:12 - LMT 1924 May 2 - 10:00 - +10 1930 Jun 21 # Magadan Time - 11:00 Russia +11/+12 1991 Mar 31 2:00s - 10:00 Russia +10/+11 1992 Jan 19 2:00s - 11:00 Russia +11/+12 2011 Mar 27 2:00s - 12:00 - +12 2014 Oct 26 2:00s - 10:00 - +10 2016 Apr 24 2:00s - 11:00 - +11 - - -# From Tim Parenti (2014-07-06): -# Asia/Srednekolymsk covers parts of (14, RU-SA) Sakha (Yakutia) Republic: -# 14-01 **** Abyysky District -# 14-03 **** Allaikhovsky District -# 14-08 **** Verkhnekolymsky District -# 14-17 **** Momsky District -# 14-20 **** Nizhnekolymsky District -# 14-25 **** Srednekolymsky District -# -# ...and parts of (65, RU-SAK) Sakhalin Oblast: -# 65-11 **** Severo-Kurilsky District (North Kuril Islands) - -# From Tim Parenti (2014-07-02): -# Oymyakonsky District of Sakha Republic (represented by Ust-Nera), along with -# most of Sakhalin Oblast (represented by Sakhalin) will be moving to UTC+10 on -# 2014-10-26 to stay aligned with VLAT/SAKT; however, Severo-Kurilsky District -# of the Sakhalin Oblast (also known as the North Kuril Islands, represented by -# Severo-Kurilsk) will remain on UTC+11. - -# From Tim Parenti (2014-07-06): -# Assume North Kuril Islands have history like Magadan before 2011-03-27. -# There is a decent chance this is wrong, in which case a new zone -# Asia/Severo-Kurilsk would become necessary. -# -# Srednekolymsk and Zyryanka are the most populous places amongst these -# districts, but have very similar populations. In fact, Wikipedia currently -# lists them both as having 3528 people, exactly 1668 males and 1860 females -# each! (Yikes!) -# https://en.wikipedia.org/w/?title=Srednekolymsky_District&oldid=603435276 -# https://en.wikipedia.org/w/?title=Verkhnekolymsky_District&oldid=594378493 -# Assume this is a mistake, albeit an amusing one. -# -# Looking at censuses, the populations of the two municipalities seem to have -# fluctuated recently. Zyryanka was more populous than Srednekolymsk in the -# 1989 and 2002 censuses, but Srednekolymsk was more populous in the most -# recent (2010) census, 3525 to 3170. (See pages 195 and 197 of -# http://www.gks.ru/free_doc/new_site/perepis2010/croc/Documents/Vol1/pub-01-05.pdf -# in Russian.) In addition, Srednekolymsk appears to be a much older -# settlement and the population of Zyryanka seems to be declining. -# Go with Srednekolymsk. - -Zone Asia/Srednekolymsk 10:14:52 - LMT 1924 May 2 - 10:00 - +10 1930 Jun 21 - 11:00 Russia +11/+12 1991 Mar 31 2:00s - 10:00 Russia +10/+11 1992 Jan 19 2:00s - 11:00 Russia +11/+12 2011 Mar 27 2:00s - 12:00 - +12 2014 Oct 26 2:00s - 11:00 - +11 - - -# From Tim Parenti (2014-07-03): -# Asia/Ust-Nera covers parts of (14, RU-SA) Sakha (Yakutia) Republic: -# 14-22 **** Oymyakonsky District - -# From Arthur David Olson (2012-05-09): -# Ojmyakonskij [and the Kuril Islands] switched from -# Magadan time to Vladivostok time in 2011. -# -# From Tim Parenti (2014-07-06), per Alexander Krivenyshev (2014-07-02): -# It's unlikely that any of the Kuril Islands were involved in such a switch, -# as the South and Middle Kurils have been on UTC+11 (SAKT) with the rest of -# Sakhalin Oblast since at least 2011-09, and the North Kurils have been on -# UTC+12 since at least then, too. - -Zone Asia/Ust-Nera 9:32:54 - LMT 1919 Dec 15 - 8:00 - +08 1930 Jun 21 - 9:00 Russia +09/+10 1981 Apr 1 - 11:00 Russia +11/+12 1991 Mar 31 2:00s - 10:00 Russia +10/+11 1992 Jan 19 2:00s - 11:00 Russia +11/+12 2011 Mar 27 2:00s - 12:00 - +12 2011 Sep 13 0:00s # Decree 725? - 11:00 - +11 2014 Oct 26 2:00s - 10:00 - +10 - - -# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25): -# Asia/Kamchatka covers... -# 91 RU-KAM Kamchatka Krai -# -# Note: Effective 2007-07-01, (41) Kamchatka Oblast and (82) Koryak -# Autonomous Okrug merged to form (91, RU-KAM) Kamchatka Krai. - -# The Zone name should be Asia/Petropavlovsk-Kamchatski or perhaps -# Asia/Petropavlovsk-Kamchatsky, but these are too long. -Zone Asia/Kamchatka 10:34:36 - LMT 1922 Nov 10 - 11:00 - +11 1930 Jun 21 - 12:00 Russia +12/+13 1991 Mar 31 2:00s - 11:00 Russia +11/+12 1992 Jan 19 2:00s - 12:00 Russia +12/+13 2010 Mar 28 2:00s - 11:00 Russia +11/+12 2011 Mar 27 2:00s - 12:00 - +12 - - -# From Tim Parenti (2014-07-03): -# Asia/Anadyr covers... -# 87 RU-CHU Chukotka Autonomous Okrug - -Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2 - 12:00 - +12 1930 Jun 21 - 13:00 Russia +13/+14 1982 Apr 1 0:00s - 12:00 Russia +12/+13 1991 Mar 31 2:00s - 11:00 Russia +11/+12 1992 Jan 19 2:00s - 12:00 Russia +12/+13 2010 Mar 28 2:00s - 11:00 Russia +11/+12 2011 Mar 27 2:00s - 12:00 - +12 - - -# San Marino -# See Europe/Rome. - -# Serbia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Belgrade 1:22:00 - LMT 1884 - 1:00 - CET 1941 Apr 18 23:00 - 1:00 C-Eur CE%sT 1945 - 1:00 - CET 1945 May 8 2:00s - 1:00 1:00 CEST 1945 Sep 16 2:00s -# Metod Koželj reports that the legal date of -# transition to EU rules was 1982-11-27, for all of Yugoslavia at the time. -# Shanks & Pottenger don't give as much detail, so go with Koželj. - 1:00 - CET 1982 Nov 27 - 1:00 EU CE%sT -Link Europe/Belgrade Europe/Ljubljana # Slovenia -Link Europe/Belgrade Europe/Podgorica # Montenegro -Link Europe/Belgrade Europe/Sarajevo # Bosnia and Herzegovina -Link Europe/Belgrade Europe/Skopje # Macedonia -Link Europe/Belgrade Europe/Zagreb # Croatia - -# Slovakia -Link Europe/Prague Europe/Bratislava - -# Slovenia -# See Europe/Belgrade. - -# Spain -# -# From Paul Eggert (2016-12-14): -# -# The source for Europe/Madrid before 2013 is: -# Planesas P. La hora oficial en España y sus cambios. -# Anuario del Observatorio Astronómico de Madrid (2013, in Spanish). -# http://astronomia.ign.es/rknowsys-theme/images/webAstro/paginas/documentos/Anuario/lahoraoficialenespana.pdf -# As this source says that historical time in the Canaries is obscure, -# and it does not discuss Ceuta, stick with Shanks for now for that data. -# -# In the 1918 and 1919 fallback transitions in Spain, the clock for -# the hour-longer day officially kept going after midnight, so that -# the repeated instances of that day's 00:00 hour were 24 hours apart, -# with a fallback transition from the second occurrence of 00:59... to -# the next day's 00:00. Our data format cannot represent this -# directly, and instead repeats the first hour of the next day, with a -# fallback transition from the next day's 00:59... to 00:00. - -# From Michael Deckers (2016-12-15): -# The Royal Decree of 1900-06-26 quoted by Planesas, online at -# https://www.boe.es/datos/pdfs/BOE//1900/209/A00383-00384.pdf -# says in its article 5 (my translation): -# These dispositions will enter into force beginning with the -# instant at which, according to the time indicated in article 1, -# the 1st day of January of 1901 will begin. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Spain 1918 only - Apr 15 23:00 1:00 S -Rule Spain 1918 1919 - Oct 6 24:00s 0 - -Rule Spain 1919 only - Apr 6 23:00 1:00 S -Rule Spain 1924 only - Apr 16 23:00 1:00 S -Rule Spain 1924 only - Oct 4 24:00s 0 - -Rule Spain 1926 only - Apr 17 23:00 1:00 S -Rule Spain 1926 1929 - Oct Sat>=1 24:00s 0 - -Rule Spain 1927 only - Apr 9 23:00 1:00 S -Rule Spain 1928 only - Apr 15 0:00 1:00 S -Rule Spain 1929 only - Apr 20 23:00 1:00 S -# Republican Spain during the civil war; it controlled Madrid until 1939-03-28. -Rule Spain 1937 only - Jun 16 23:00 1:00 S -Rule Spain 1937 only - Oct 2 24:00s 0 - -Rule Spain 1938 only - Apr 2 23:00 1:00 S -Rule Spain 1938 only - Apr 30 23:00 2:00 M -Rule Spain 1938 only - Oct 2 24:00 1:00 S -# The following rules are for unified Spain again. -# -# Planesas does not say what happened in Madrid between its fall on -# 1939-03-28 and the Nationalist spring-forward transition on -# 1939-04-15. For lack of better info, assume Madrid's clocks did not -# change during that period. -# -# The first rule is commented out, as it is redundant for Republican Spain. -#Rule Spain 1939 only - Apr 15 23:00 1:00 S -Rule Spain 1939 only - Oct 7 24:00s 0 - -Rule Spain 1942 only - May 2 23:00 1:00 S -Rule Spain 1942 only - Sep 1 1:00 0 - -Rule Spain 1943 1946 - Apr Sat>=13 23:00 1:00 S -Rule Spain 1943 1944 - Oct Sun>=1 1:00 0 - -Rule Spain 1945 1946 - Sep lastSun 1:00 0 - -Rule Spain 1949 only - Apr 30 23:00 1:00 S -Rule Spain 1949 only - Oct 2 1:00 0 - -Rule Spain 1974 1975 - Apr Sat>=12 23:00 1:00 S -Rule Spain 1974 1975 - Oct Sun>=1 1:00 0 - -Rule Spain 1976 only - Mar 27 23:00 1:00 S -Rule Spain 1976 1977 - Sep lastSun 1:00 0 - -Rule Spain 1977 only - Apr 2 23:00 1:00 S -Rule Spain 1978 only - Apr 2 2:00s 1:00 S -Rule Spain 1978 only - Oct 1 2:00s 0 - -# Nationalist Spain during the civil war -#Rule NatSpain 1937 only - May 22 23:00 1:00 S -#Rule NatSpain 1937 1938 - Oct Sat>=1 24:00s 0 - -#Rule NatSpain 1938 only - Mar 26 23:00 1:00 S -# The following rules are copied from Morocco from 1967 through 1978, -# except with "S" letters. -Rule SpainAfrica 1967 only - Jun 3 12:00 1:00 S -Rule SpainAfrica 1967 only - Oct 1 0:00 0 - -Rule SpainAfrica 1974 only - Jun 24 0:00 1:00 S -Rule SpainAfrica 1974 only - Sep 1 0:00 0 - -Rule SpainAfrica 1976 1977 - May 1 0:00 1:00 S -Rule SpainAfrica 1976 only - Aug 1 0:00 0 - -Rule SpainAfrica 1977 only - Sep 28 0:00 0 - -Rule SpainAfrica 1978 only - Jun 1 0:00 1:00 S -Rule SpainAfrica 1978 only - Aug 4 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Madrid -0:14:44 - LMT 1900 Dec 31 23:45:16 - 0:00 Spain WE%sT 1940 Mar 16 23:00 - 1:00 Spain CE%sT 1979 - 1:00 EU CE%sT -Zone Africa/Ceuta -0:21:16 - LMT 1900 Dec 31 23:38:44 - 0:00 - WET 1918 May 6 23:00 - 0:00 1:00 WEST 1918 Oct 7 23:00 - 0:00 - WET 1924 - 0:00 Spain WE%sT 1929 - 0:00 - WET 1967 # Help zishrink.awk. - 0:00 SpainAfrica WE%sT 1984 Mar 16 - 1:00 - CET 1986 - 1:00 EU CE%sT -Zone Atlantic/Canary -1:01:36 - LMT 1922 Mar # Las Palmas de Gran C. - -1:00 - -01 1946 Sep 30 1:00 - 0:00 - WET 1980 Apr 6 0:00s - 0:00 1:00 WEST 1980 Sep 28 1:00u - 0:00 EU WE%sT -# IATA SSIM (1996-09) says the Canaries switch at 2:00u, not 1:00u. -# Ignore this for now, as the Canaries are part of the EU. - -# Sweden - -# From Ivan Nilsson (2001-04-13), superseding Shanks & Pottenger: -# -# The law "Svensk författningssamling 1878, no 14" about standard time in 1879: -# From the beginning of 1879 (that is 01-01 00:00) the time for all -# places in the country is "the mean solar time for the meridian at -# three degrees, or twelve minutes of time, to the west of the -# meridian of the Observatory of Stockholm". The law is dated 1878-05-31. -# -# The observatory at that time had the meridian 18° 03' 30" -# eastern longitude = 01:12:14 in time. Less 12 minutes gives the -# national standard time as 01:00:14 ahead of GMT.... -# -# About the beginning of CET in Sweden. The lawtext ("Svensk -# författningssamling 1899, no 44") states, that "from the beginning -# of 1900... ... the same as the mean solar time for the meridian at -# the distance of one hour of time from the meridian of the English -# observatory at Greenwich, or at 12 minutes 14 seconds to the west -# from the meridian of the Observatory of Stockholm". The law is dated -# 1899-06-16. In short: At 1900-01-01 00:00:00 the new standard time -# in Sweden is 01:00:00 ahead of GMT. -# -# 1916: The lawtext ("Svensk författningssamling 1916, no 124") states -# that "1916-05-15 is considered to begin one hour earlier". It is -# pretty obvious that at 05-14 23:00 the clocks are set to 05-15 00:00.... -# Further the law says, that "1916-09-30 is considered to end one hour later". -# -# The laws regulating [DST] are available on the site of the Swedish -# Parliament beginning with 1985 - the laws regulating 1980/1984 are -# not available on the site (to my knowledge they are only available -# in Swedish): <http://www.riksdagen.se/english/work/sfst.asp> (type -# "sommartid" without the quotes in the field "Fritext" and then click -# the Sök-button). -# -# (2001-05-13): -# -# I have now found a newspaper stating that at 1916-10-01 01:00 -# summertime the church-clocks etc were set back one hour to show -# 1916-10-01 00:00 standard time. The article also reports that some -# people thought the switch to standard time would take place already -# at 1916-10-01 00:00 summer time, but they had to wait for another -# hour before the event took place. -# -# Source: The newspaper "Dagens Nyheter", 1916-10-01, page 7 upper left. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 - 1:00:14 - SET 1900 Jan 1 # Swedish Time - 1:00 - CET 1916 May 14 23:00 - 1:00 1:00 CEST 1916 Oct 1 1:00 - 1:00 - CET 1980 - 1:00 EU CE%sT - -# Switzerland -# From Howse: -# By the end of the 18th century clocks and watches became commonplace -# and their performance improved enormously. Communities began to keep -# mean time in preference to apparent time - Geneva from 1780 .... -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# From Whitman (who writes "Midnight?"): -# Rule Swiss 1940 only - Nov 2 0:00 1:00 S -# Rule Swiss 1940 only - Dec 31 0:00 0 - -# From Shanks & Pottenger: -# Rule Swiss 1941 1942 - May Sun>=1 2:00 1:00 S -# Rule Swiss 1941 1942 - Oct Sun>=1 0:00 0 - - -# From Alois Treindl (2008-12-17): -# I have researched the DST usage in Switzerland during the 1940ies. -# -# As I wrote in an earlier message, I suspected the current tzdata values -# to be wrong. This is now verified. -# -# I have found copies of the original ruling by the Swiss Federal -# government, in 'Eidgenössische Gesetzessammlung 1941 and 1942' (Swiss -# federal law collection)... -# -# DST began on Monday 5 May 1941, 1:00 am by shifting the clocks to 2:00 am -# DST ended on Monday 6 Oct 1941, 2:00 am by shifting the clocks to 1:00 am. -# -# DST began on Monday, 4 May 1942 at 01:00 am -# DST ended on Monday, 5 Oct 1942 at 02:00 am -# -# There was no DST in 1940, I have checked the law collection carefully. -# It is also indicated by the fact that the 1942 entry in the law -# collection points back to 1941 as a reference, but no reference to any -# other years are made. -# -# Newspaper articles I have read in the archives on 6 May 1941 reported -# about the introduction of DST (Sommerzeit in German) during the previous -# night as an absolute novelty, because this was the first time that such -# a thing had happened in Switzerland. -# -# I have also checked 1916, because one book source (Gabriel, Traité de -# l'heure dans le monde) claims that Switzerland had DST in 1916. This is -# false, no official document could be found. Probably Gabriel got misled -# by references to Germany, which introduced DST in 1916 for the first time. -# -# The tzdata rules for Switzerland must be changed to: -# Rule Swiss 1941 1942 - May Mon>=1 1:00 1:00 S -# Rule Swiss 1941 1942 - Oct Mon>=1 2:00 0 - -# -# The 1940 rules must be deleted. -# -# One further detail for Switzerland, which is probably out of scope for -# most users of tzdata: The [Europe/Zurich zone] ... -# describes all of Switzerland correctly, with the exception of -# the Canton de Genève (Geneva, Genf). Between 1848 and 1894 Geneva did not -# follow Bern Mean Time but kept its own local mean time. -# To represent this, an extra zone would be needed. -# -# From Alois Treindl (2013-09-11): -# The Federal regulations say -# https://www.admin.ch/opc/de/classified-compilation/20071096/index.html -# ... the meridian for Bern mean time ... is 7° 26' 22.50". -# Expressed in time, it is 0h29m45.5s. - -# From Pierre-Yves Berger (2013-09-11): -# the "Circulaire du conseil fédéral" (December 11 1893) -# http://www.amtsdruckschriften.bar.admin.ch/viewOrigDoc.do?id=10071353 -# clearly states that the [1894-06-01] change should be done at midnight -# but if no one is present after 11 at night, could be postponed until one -# hour before the beginning of service. - -# From Paul Eggert (2013-09-11): -# Round BMT to the nearest even second, 0:29:46. -# -# We can find no reliable source for Shanks's assertion that all of Switzerland -# except Geneva switched to Bern Mean Time at 00:00 on 1848-09-12. This book: -# -# Jakob Messerli. Gleichmässig, pünktlich, schnell. Zeiteinteilung und -# Zeitgebrauch in der Schweiz im 19. Jahrhundert. Chronos, Zurich 1995, -# ISBN 3-905311-68-2, OCLC 717570797. -# -# suggests that the transition was more gradual, and that the Swiss did not -# agree about civil time during the transition. The timekeeping it gives the -# most detail for is postal and telegraph time: here, federal legislation (the -# "Bundesgesetz über die Erstellung von elektrischen Telegraphen") passed on -# 1851-11-23, and an official implementation notice was published 1853-07-16 -# (Bundesblatt 1853, Bd. II, S. 859). On p 72 Messerli writes that in -# practice since July 1853 Bernese time was used in "all postal and telegraph -# offices in Switzerland from Geneva to St. Gallen and Basel to Chiasso" -# (Google translation). For now, model this transition as occurring on -# 1853-07-16, though it probably occurred at some other date in Zurich, and -# legal civil time probably changed at still some other transition date. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Swiss 1941 1942 - May Mon>=1 1:00 1:00 S -Rule Swiss 1941 1942 - Oct Mon>=1 2:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment. - 0:29:46 - BMT 1894 Jun # Bern Mean Time - 1:00 Swiss CE%sT 1981 - 1:00 EU CE%sT - -# Turkey - -# From Kıvanç Yazan (2016-09-25): -# 1) For 1986-2006, DST started at 01:00 local and ended at 02:00 local, with -# no exceptions. -# 2) 1994's lastSun was overridden with Mar 20 ... -# Here are official papers: -# http://www.resmigazete.gov.tr/arsiv/19032.pdf - page 2 for 1986 -# http://www.resmigazete.gov.tr/arsiv/19400.pdf - page 4 for 1987 -# http://www.resmigazete.gov.tr/arsiv/19752.pdf - page 15 for 1988 -# http://www.resmigazete.gov.tr/arsiv/20102.pdf - page 6 for 1989 -# http://www.resmigazete.gov.tr/arsiv/20464.pdf - page 1 for 1990 - 1992 -# http://www.resmigazete.gov.tr/arsiv/21531.pdf - page 15 for 1993 - 1995 -# http://www.resmigazete.gov.tr/arsiv/21879.pdf - page 1 for overriding 1994 -# http://www.resmigazete.gov.tr/arsiv/22588.pdf - page 1 for 1996, 1997 -# http://www.resmigazete.gov.tr/arsiv/23286.pdf - page 10 for 1998 - 2000 -# http://www.resmigazete.gov.tr/eskiler/2001/03/20010324.htm#2 - for 2001 -# http://www.resmigazete.gov.tr/eskiler/2002/03/20020316.htm#2 - for 2002-2006 -# From Paul Eggert (2016-09-25): -# Prefer the above sources to Shanks & Pottenger for timestamps after 1985. - -# From Steffen Thorsen (2007-03-09): -# Starting 2007 though, it seems that they are adopting EU's 1:00 UTC -# start/end time, according to the following page (2007-03-07): -# http://www.ntvmsnbc.com/news/402029.asp -# The official document is located here - it is in Turkish...: -# http://rega.basbakanlik.gov.tr/eskiler/2007/03/20070307-7.htm -# I was able to locate the following seemingly official document -# (on a non-government server though) describing dates between 2002 and 2006: -# http://www.alomaliye.com/bkk_2002_3769.htm - -# From Gökdeniz Karadağ (2011-03-10): -# According to the articles linked below, Turkey will change into summer -# time zone (GMT+3) on March 28, 2011 at 3:00 a.m. instead of March 27. -# This change is due to a nationwide exam on 27th. -# https://www.worldbulletin.net/?aType=haber&ArticleID=70872 -# Turkish: -# https://www.hurriyet.com.tr/yaz-saati-uygulamasi-bir-gun-ileri-alindi-17230464 - -# From Faruk Pasin (2014-02-14): -# The DST for Turkey has been changed for this year because of the -# Turkish Local election.... -# http://www.sabah.com.tr/Ekonomi/2014/02/12/yaz-saatinde-onemli-degisiklik -# ... so Turkey will move clocks forward one hour on March 31 at 3:00 a.m. -# From Randal L. Schwartz (2014-04-15): -# Having landed on a flight from the states to Istanbul (via AMS) on March 31, -# I can tell you that NOBODY (even the airlines) respected this timezone DST -# change delay. Maybe the word just didn't get out in time. -# From Paul Eggert (2014-06-15): -# The press reported massive confusion, as election officials obeyed the rule -# change but cell phones (and airline baggage systems) did not. See: -# Kostidis M. Eventful elections in Turkey. Balkan News Agency -# http://www.balkaneu.com/eventful-elections-turkey/ 2014-03-30. -# I guess the best we can do is document the official time. - -# From Fatih (2015-09-29): -# It's officially announced now by the Ministry of Energy. -# Turkey delays winter time to 8th of November 04:00 -# http://www.aa.com.tr/tr/turkiye/yaz-saati-uygulamasi-8-kasimda-sona-erecek/362217 -# -# From BBC News (2015-10-25): -# Confused Turks are asking "what's the time?" after automatic clocks defied a -# government decision ... "For the next two weeks #Turkey is on EEST... Erdogan -# Engineered Standard Time," said Twitter user @aysekarahasan. -# http://www.bbc.com/news/world-europe-34631326 - -# From Burak AYDIN (2016-09-08): -# Turkey will stay in Daylight Saving Time even in winter.... -# http://www.resmigazete.gov.tr/eskiler/2016/09/20160908-2.pdf -# -# From Paul Eggert (2016-09-07): -# The change is permanent, so this is the new standard time in Turkey. -# It takes effect today, which is not much notice. - -# From Kıvanç Yazan (2017-10-28): -# Turkey will go back to Daylight Saving Time starting 2018-10. -# http://www.resmigazete.gov.tr/eskiler/2017/10/20171028-5.pdf -# -# From Even Scharning (2017-11-08): -# ... today it was announced that the DST will become "continuous": -# http://www.hurriyet.com.tr/son-dakika-yaz-saati-uygulamasi-surekli-hale-geldi-40637482 -# From Paul Eggert (2017-11-08): -# Although Google Translate misfires on that source, it looks like -# Turkey reversed last month's decision, and so will stay at +03. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Turkey 1916 only - May 1 0:00 1:00 S -Rule Turkey 1916 only - Oct 1 0:00 0 - -Rule Turkey 1920 only - Mar 28 0:00 1:00 S -Rule Turkey 1920 only - Oct 25 0:00 0 - -Rule Turkey 1921 only - Apr 3 0:00 1:00 S -Rule Turkey 1921 only - Oct 3 0:00 0 - -Rule Turkey 1922 only - Mar 26 0:00 1:00 S -Rule Turkey 1922 only - Oct 8 0:00 0 - -# Whitman gives 1923 Apr 28 - Sep 16 and no DST in 1924-1925; -# go with Shanks & Pottenger. -Rule Turkey 1924 only - May 13 0:00 1:00 S -Rule Turkey 1924 1925 - Oct 1 0:00 0 - -Rule Turkey 1925 only - May 1 0:00 1:00 S -Rule Turkey 1940 only - Jun 30 0:00 1:00 S -Rule Turkey 1940 only - Oct 5 0:00 0 - -Rule Turkey 1940 only - Dec 1 0:00 1:00 S -Rule Turkey 1941 only - Sep 21 0:00 0 - -Rule Turkey 1942 only - Apr 1 0:00 1:00 S -# Whitman omits the next two transition and gives 1945 Oct 1; -# go with Shanks & Pottenger. -Rule Turkey 1942 only - Nov 1 0:00 0 - -Rule Turkey 1945 only - Apr 2 0:00 1:00 S -Rule Turkey 1945 only - Oct 8 0:00 0 - -Rule Turkey 1946 only - Jun 1 0:00 1:00 S -Rule Turkey 1946 only - Oct 1 0:00 0 - -Rule Turkey 1947 1948 - Apr Sun>=16 0:00 1:00 S -Rule Turkey 1947 1950 - Oct Sun>=2 0:00 0 - -Rule Turkey 1949 only - Apr 10 0:00 1:00 S -Rule Turkey 1950 only - Apr 19 0:00 1:00 S -Rule Turkey 1951 only - Apr 22 0:00 1:00 S -Rule Turkey 1951 only - Oct 8 0:00 0 - -Rule Turkey 1962 only - Jul 15 0:00 1:00 S -Rule Turkey 1962 only - Oct 8 0:00 0 - -Rule Turkey 1964 only - May 15 0:00 1:00 S -Rule Turkey 1964 only - Oct 1 0:00 0 - -Rule Turkey 1970 1972 - May Sun>=2 0:00 1:00 S -Rule Turkey 1970 1972 - Oct Sun>=2 0:00 0 - -Rule Turkey 1973 only - Jun 3 1:00 1:00 S -Rule Turkey 1973 only - Nov 4 3:00 0 - -Rule Turkey 1974 only - Mar 31 2:00 1:00 S -Rule Turkey 1974 only - Nov 3 5:00 0 - -Rule Turkey 1975 only - Mar 30 0:00 1:00 S -Rule Turkey 1975 1976 - Oct lastSun 0:00 0 - -Rule Turkey 1976 only - Jun 1 0:00 1:00 S -Rule Turkey 1977 1978 - Apr Sun>=1 0:00 1:00 S -Rule Turkey 1977 only - Oct 16 0:00 0 - -Rule Turkey 1979 1980 - Apr Sun>=1 3:00 1:00 S -Rule Turkey 1979 1982 - Oct Mon>=11 0:00 0 - -Rule Turkey 1981 1982 - Mar lastSun 3:00 1:00 S -Rule Turkey 1983 only - Jul 31 0:00 1:00 S -Rule Turkey 1983 only - Oct 2 0:00 0 - -Rule Turkey 1985 only - Apr 20 0:00 1:00 S -Rule Turkey 1985 only - Sep 28 0:00 0 - -Rule Turkey 1986 1993 - Mar lastSun 1:00s 1:00 S -Rule Turkey 1986 1995 - Sep lastSun 1:00s 0 - -Rule Turkey 1994 only - Mar 20 1:00s 1:00 S -Rule Turkey 1995 2006 - Mar lastSun 1:00s 1:00 S -Rule Turkey 1996 2006 - Oct lastSun 1:00s 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Istanbul 1:55:52 - LMT 1880 - 1:56:56 - IMT 1910 Oct # Istanbul Mean Time? - 2:00 Turkey EE%sT 1978 Oct 15 - 3:00 Turkey +03/+04 1985 Apr 20 - 2:00 Turkey EE%sT 2007 - 2:00 EU EE%sT 2011 Mar 27 1:00u - 2:00 - EET 2011 Mar 28 1:00u - 2:00 EU EE%sT 2014 Mar 30 1:00u - 2:00 - EET 2014 Mar 31 1:00u - 2:00 EU EE%sT 2015 Oct 25 1:00u - 2:00 1:00 EEST 2015 Nov 8 1:00u - 2:00 EU EE%sT 2016 Sep 7 - 3:00 - +03 -Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. - -# Ukraine -# -# From Igor Karpov, who works for the Ukrainian Ministry of Justice, -# via Garrett Wollman (2003-01-27): -# BTW, I've found the official document on this matter. It's government -# regulations No. 509, May 13, 1996. In my poor translation it says: -# "Time in Ukraine is set to second timezone (Kiev time). Each last Sunday -# of March at 3am the time is changing to 4am and each last Sunday of -# October the time at 4am is changing to 3am" - -# From Alexander Krivenyshev (2011-09-20): -# On September 20, 2011 the deputies of the Verkhovna Rada agreed to -# abolish the transfer clock to winter time. -# -# Bill No. 8330 of MP from the Party of Regions Oleg Nadoshi got -# approval from 266 deputies. -# -# Ukraine abolishes transfer back to the winter time (in Russian) -# http://news.mail.ru/politics/6861560/ -# -# The Ukrainians will no longer change the clock (in Russian) -# http://www.segodnya.ua/news/14290482.html -# -# Deputies cancelled the winter time (in Russian) -# https://www.pravda.com.ua/rus/news/2011/09/20/6600616/ -# -# From Philip Pizzey (2011-10-18): -# Today my Ukrainian colleagues have informed me that the -# Ukrainian parliament have decided that they will go to winter -# time this year after all. -# -# From Udo Schwedt (2011-10-18): -# As far as I understand, the recent change to the Ukrainian time zone -# (Europe/Kiev) to introduce permanent daylight saving time (similar -# to Russia) was reverted today: -# http://portal.rada.gov.ua/rada/control/en/publish/article/info_left?art_id=287324&cat_id=105995 -# -# Also reported by Alexander Bokovoy (2011-10-18) who also noted: -# The law documents themselves are at -# http://w1.c1.rada.gov.ua/pls/zweb_n/webproc4_1?id=&pf3511=41484 - -# From Vladimir in Moscow via Alois Treindl re Kiev time 1991/2 (2014-02-28): -# First in Ukraine they changed Time zone from UTC+3 to UTC+2 with DST: -# 03 25 1990 02:00 -03.00 1 Time Zone 3 with DST -# 07 01 1990 02:00 -02.00 1 Time Zone 2 with DST -# * Ukrainian Government's Resolution of 18.06.1990, No. 134. -# http://search.ligazakon.ua/l_doc2.nsf/link1/T001500.html -# -# They did not end DST in September, 1990 (according to the law, -# "summer time" was still in action): -# 09 30 1990 03:00 -02.00 1 Time Zone 2 with DST -# * Ukrainian Government's Resolution of 21.09.1990, No. 272. -# http://search.ligazakon.ua/l_doc2.nsf/link1/KP900272.html -# -# Again no change in March, 1991 ("summer time" in action): -# 03 31 1991 02:00 -02.00 1 Time Zone 2 with DST -# -# DST ended in September 1991 ("summer time" ended): -# 09 29 1991 03:00 -02.00 0 Time Zone 2, no DST -# * Ukrainian Government's Resolution of 25.09.1991, No. 225. -# http://www.uazakon.com/documents/date_21/pg_iwgdoc.htm -# This is an answer. -# -# Since 1992 they had normal DST procedure: -# 03 29 1992 02:00 -02.00 1 DST started -# 09 27 1992 03:00 -02.00 0 DST ended -# * Ukrainian Government's Resolution of 20.03.1992, No. 139. -# http://www.uazakon.com/documents/date_8u/pg_grcasa.htm - -# From Paul Eggert (2018-10-03): -# As is usual in tzdb, Ukrainian zones use the most common English spellings. -# For example, tzdb uses Europe/Kiev, as "Kiev" is the most common spelling in -# English for Ukraine's capital, even though it is certainly wrong as a -# transliteration of the Ukrainian "Київ". This is similar to tzdb's use of -# Europe/Prague, which is certainly wrong as a transliteration of the Czech -# "Praha". ("Kiev" came from old Slavic via Russian to English, and "Prague" -# came from old Slavic via French to English, so the two cases have something -# in common.) Admittedly English-language spelling of Ukrainian names is -# controversial, and some day "Kyiv" may become substantially more popular in -# English; in the meantime, stick with the traditional English "Kiev" as that -# means less disruption for our users. -# -# Anyway, none of the common English-language spellings (Kiev, Kyiv, Kieff, -# Kijeff, Kijev, Kiyef, Kiyeff) do justice to the common pronunciation in -# Ukrainian, namely [ˈkɪjiu̯] (IPA). This pronunciation has nothing like an -# English "v" or "f", and instead trails off with what an English-speaker -# would call a demure "oo" sound, and it would would be better anglicized as -# "Kuiyu". Here's a sound file, if you would like to do as the Kuiyuvians do: -# https://commons.wikimedia.org/wiki/File:Uk-Київ.ogg - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# This represents most of Ukraine. See above for the spelling of "Kiev". -Zone Europe/Kiev 2:02:04 - LMT 1880 - 2:02:04 - KMT 1924 May 2 # Kiev Mean Time - 2:00 - EET 1930 Jun 21 - 3:00 - MSK 1941 Sep 20 - 1:00 C-Eur CE%sT 1943 Nov 6 - 3:00 Russia MSK/MSD 1990 Jul 1 2:00 - 2:00 1:00 EEST 1991 Sep 29 3:00 - 2:00 E-Eur EE%sT 1995 - 2:00 EU EE%sT -# Ruthenia used CET 1990/1991. -# "Uzhhorod" is the transliteration of the Rusyn/Ukrainian pronunciation, but -# "Uzhgorod" is more common in English. -Zone Europe/Uzhgorod 1:29:12 - LMT 1890 Oct - 1:00 - CET 1940 - 1:00 C-Eur CE%sT 1944 Oct - 1:00 1:00 CEST 1944 Oct 26 - 1:00 - CET 1945 Jun 29 - 3:00 Russia MSK/MSD 1990 - 3:00 - MSK 1990 Jul 1 2:00 - 1:00 - CET 1991 Mar 31 3:00 - 2:00 - EET 1992 - 2:00 E-Eur EE%sT 1995 - 2:00 EU EE%sT -# Zaporozh'ye and eastern Lugansk oblasts observed DST 1990/1991. -# "Zaporizhia" is the transliteration of the Ukrainian name, but -# "Zaporozh'ye" is more common in English. Use the common English -# spelling, except omit the apostrophe as it is not allowed in -# portable Posix file names. -Zone Europe/Zaporozhye 2:20:40 - LMT 1880 - 2:20 - +0220 1924 May 2 - 2:00 - EET 1930 Jun 21 - 3:00 - MSK 1941 Aug 25 - 1:00 C-Eur CE%sT 1943 Oct 25 - 3:00 Russia MSK/MSD 1991 Mar 31 2:00 - 2:00 E-Eur EE%sT 1995 - 2:00 EU EE%sT - -# Vatican City -# See Europe/Rome. - -############################################################################### - -# One source shows that Bulgaria, Cyprus, Finland, and Greece observe DST from -# the last Sunday in March to the last Sunday in September in 1986. -# The source shows Romania changing a day later than everybody else. -# -# According to Bernard Sieloff's source, Poland is in the MET time zone but -# uses the WE DST rules. The Western USSR uses EET+1 and ME DST rules. -# Bernard Sieloff's source claims Romania switches on the same day, but at -# 00:00 standard time (i.e., 01:00 DST). It also claims that Turkey -# switches on the same day, but switches on at 01:00 standard time -# and off at 00:00 standard time (i.e., 01:00 DST) - -# ... -# Date: Wed, 28 Jan 87 16:56:27 -0100 -# From: Tom Hofmann -# ... -# -# ...the European time rules are...standardized since 1981, when -# most European countries started DST. Before that year, only -# a few countries (UK, France, Italy) had DST, each according -# to own national rules. In 1981, however, DST started on -# 'Apr firstSun', and not on 'Mar lastSun' as in the following -# years... -# But also since 1981 there are some more national exceptions -# than listed in 'europe': Switzerland, for example, joined DST -# one year later, Denmark ended DST on 'Oct 1' instead of 'Sep -# lastSun' in 1981 - I don't know how they handle now. -# -# Finally, DST ist always from 'Apr 1' to 'Oct 1' in the -# Soviet Union (as far as I know). -# -# Tom Hofmann, Scientific Computer Center, CIBA-GEIGY AG, -# 4002 Basle, Switzerland -# ... - -# ... -# Date: Wed, 4 Feb 87 22:35:22 +0100 -# From: Dik T. Winter -# ... -# -# The information from Tom Hofmann is (as far as I know) not entirely correct. -# After a request from chongo at amdahl I tried to retrieve all information -# about DST in Europe. I was able to find all from about 1969. -# -# ...standardization on DST in Europe started in about 1977 with switches on -# first Sunday in April and last Sunday in September... -# In 1981 UK joined Europe insofar that -# the starting day for both shifted to last Sunday in March. And from 1982 -# the whole of Europe used DST, with switch dates April 1 and October 1 in -# the Sov[i]et Union. In 1985 the SU reverted to standard Europe[a]n switch -# dates... -# -# It should also be remembered that time-zones are not constants; e.g. -# Portugal switched in 1976 from MET (or CET) to WET with DST... -# Note also that though there were rules for switch dates not -# all countries abided to these dates, and many individual deviations -# occurred, though not since 1982 I believe. Another note: it is always -# assumed that DST is 1 hour ahead of normal time, this need not be the -# case; at least in the Netherlands there have been times when DST was 2 hours -# in advance of normal time. -# -# ... -# dik t. winter, cwi, amsterdam, nederland -# ... - -# From Bob Devine (1988-01-28): -# ... -# Greece: Last Sunday in April to last Sunday in September (iffy on dates). -# Since 1978. Change at midnight. -# ... -# Monaco: has same DST as France. -# ... diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/gmt b/src/test/jdk/sun/util/calendar/zi/tzdata/gmt deleted file mode 100644 index 7685fda0390..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/gmt +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2000, 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. -# - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone GMT 0:00 - GMT diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/iso3166.tab b/src/test/jdk/sun/util/calendar/zi/tzdata/iso3166.tab deleted file mode 100644 index 38a3a1ed52b..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/iso3166.tab +++ /dev/null @@ -1,297 +0,0 @@ -# -# 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. -# -# ISO 3166 alpha-2 country codes -# -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. -# -# From Paul Eggert (2015-05-02): -# This file contains a table of two-letter country codes. Columns are -# separated by a single tab. Lines beginning with '#' are comments. -# All text uses UTF-8 encoding. The columns of the table are as follows: -# -# 1. ISO 3166-1 alpha-2 country code, current as of -# ISO 3166-1 N905 (2016-11-15). See: Updates on ISO 3166-1 -# http://isotc.iso.org/livelink/livelink/Open/16944257 -# 2. The usual English name for the coded region, -# chosen so that alphabetic sorting of subsets produces helpful lists. -# This is not the same as the English name in the ISO 3166 tables. -# -# The table is sorted by country code. -# -# This table is intended as an aid for users, to help them select time -# zone data appropriate for their practical needs. It is not intended -# to take or endorse any position on legal or territorial claims. -# -#country- -#code name of country, territory, area, or subdivision -AD Andorra -AE United Arab Emirates -AF Afghanistan -AG Antigua & Barbuda -AI Anguilla -AL Albania -AM Armenia -AO Angola -AQ Antarctica -AR Argentina -AS Samoa (American) -AT Austria -AU Australia -AW Aruba -AX Åland Islands -AZ Azerbaijan -BA Bosnia & Herzegovina -BB Barbados -BD Bangladesh -BE Belgium -BF Burkina Faso -BG Bulgaria -BH Bahrain -BI Burundi -BJ Benin -BL St Barthelemy -BM Bermuda -BN Brunei -BO Bolivia -BQ Caribbean NL -BR Brazil -BS Bahamas -BT Bhutan -BV Bouvet Island -BW Botswana -BY Belarus -BZ Belize -CA Canada -CC Cocos (Keeling) Islands -CD Congo (Dem. Rep.) -CF Central African Rep. -CG Congo (Rep.) -CH Switzerland -CI Côte d'Ivoire -CK Cook Islands -CL Chile -CM Cameroon -CN China -CO Colombia -CR Costa Rica -CU Cuba -CV Cape Verde -CW Curaçao -CX Christmas Island -CY Cyprus -CZ Czech Republic -DE Germany -DJ Djibouti -DK Denmark -DM Dominica -DO Dominican Republic -DZ Algeria -EC Ecuador -EE Estonia -EG Egypt -EH Western Sahara -ER Eritrea -ES Spain -ET Ethiopia -FI Finland -FJ Fiji -FK Falkland Islands -FM Micronesia -FO Faroe Islands -FR France -GA Gabon -GB Britain (UK) -GD Grenada -GE Georgia -GF French Guiana -GG Guernsey -GH Ghana -GI Gibraltar -GL Greenland -GM Gambia -GN Guinea -GP Guadeloupe -GQ Equatorial Guinea -GR Greece -GS South Georgia & the South Sandwich Islands -GT Guatemala -GU Guam -GW Guinea-Bissau -GY Guyana -HK Hong Kong -HM Heard Island & McDonald Islands -HN Honduras -HR Croatia -HT Haiti -HU Hungary -ID Indonesia -IE Ireland -IL Israel -IM Isle of Man -IN India -IO British Indian Ocean Territory -IQ Iraq -IR Iran -IS Iceland -IT Italy -JE Jersey -JM Jamaica -JO Jordan -JP Japan -KE Kenya -KG Kyrgyzstan -KH Cambodia -KI Kiribati -KM Comoros -KN St Kitts & Nevis -KP Korea (North) -KR Korea (South) -KW Kuwait -KY Cayman Islands -KZ Kazakhstan -LA Laos -LB Lebanon -LC St Lucia -LI Liechtenstein -LK Sri Lanka -LR Liberia -LS Lesotho -LT Lithuania -LU Luxembourg -LV Latvia -LY Libya -MA Morocco -MC Monaco -MD Moldova -ME Montenegro -MF St Martin (French) -MG Madagascar -MH Marshall Islands -MK Macedonia -ML Mali -MM Myanmar (Burma) -MN Mongolia -MO Macau -MP Northern Mariana Islands -MQ Martinique -MR Mauritania -MS Montserrat -MT Malta -MU Mauritius -MV Maldives -MW Malawi -MX Mexico -MY Malaysia -MZ Mozambique -NA Namibia -NC New Caledonia -NE Niger -NF Norfolk Island -NG Nigeria -NI Nicaragua -NL Netherlands -NO Norway -NP Nepal -NR Nauru -NU Niue -NZ New Zealand -OM Oman -PA Panama -PE Peru -PF French Polynesia -PG Papua New Guinea -PH Philippines -PK Pakistan -PL Poland -PM St Pierre & Miquelon -PN Pitcairn -PR Puerto Rico -PS Palestine -PT Portugal -PW Palau -PY Paraguay -QA Qatar -RE Réunion -RO Romania -RS Serbia -RU Russia -RW Rwanda -SA Saudi Arabia -SB Solomon Islands -SC Seychelles -SD Sudan -SE Sweden -SG Singapore -SH St Helena -SI Slovenia -SJ Svalbard & Jan Mayen -SK Slovakia -SL Sierra Leone -SM San Marino -SN Senegal -SO Somalia -SR Suriname -SS South Sudan -ST Sao Tome & Principe -SV El Salvador -SX St Maarten (Dutch) -SY Syria -SZ Swaziland -TC Turks & Caicos Is -TD Chad -TF French Southern & Antarctic Lands -TG Togo -TH Thailand -TJ Tajikistan -TK Tokelau -TL East Timor -TM Turkmenistan -TN Tunisia -TO Tonga -TR Turkey -TT Trinidad & Tobago -TV Tuvalu -TW Taiwan -TZ Tanzania -UA Ukraine -UG Uganda -UM US minor outlying islands -US United States -UY Uruguay -UZ Uzbekistan -VA Vatican City -VC St Vincent -VE Venezuela -VG Virgin Islands (UK) -VI Virgin Islands (US) -VN Vietnam -VU Vanuatu -WF Wallis & Futuna -WS Samoa (western) -YE Yemen -YT Mayotte -ZA South Africa -ZM Zambia -ZW Zimbabwe diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/jdk11_backward b/src/test/jdk/sun/util/calendar/zi/tzdata/jdk11_backward deleted file mode 100644 index c869b794f8c..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/jdk11_backward +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2000, 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. -# -# JDK 1.1.x compatible time zone IDs -# - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule SystemV min 1973 - Apr lastSun 2:00 1:00 D -Rule SystemV min 1973 - Oct lastSun 2:00 0 S -Rule SystemV 1974 only - Jan 6 2:00 1:00 D -Rule SystemV 1974 only - Nov lastSun 2:00 0 S -Rule SystemV 1975 only - Feb 23 2:00 1:00 D -Rule SystemV 1975 only - Oct lastSun 2:00 0 S -Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D -Rule SystemV 1976 max - Oct lastSun 2:00 0 S - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -Zone SystemV/AST4ADT -4:00 SystemV A%sT -Zone SystemV/EST5EDT -5:00 SystemV E%sT -Zone SystemV/CST6CDT -6:00 SystemV C%sT -Zone SystemV/MST7MDT -7:00 SystemV M%sT -Zone SystemV/PST8PDT -8:00 SystemV P%sT -Zone SystemV/YST9YDT -9:00 SystemV Y%sT -Zone SystemV/AST4 -4:00 - AST -Zone SystemV/EST5 -5:00 - EST -Zone SystemV/CST6 -6:00 - CST -Zone SystemV/MST7 -7:00 - MST -Zone SystemV/PST8 -8:00 - PST -Zone SystemV/YST9 -9:00 - YST -Zone SystemV/HST10 -10:00 - HST diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/leapseconds b/src/test/jdk/sun/util/calendar/zi/tzdata/leapseconds deleted file mode 100644 index 8b539e6ef4b..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/leapseconds +++ /dev/null @@ -1,89 +0,0 @@ -# -# 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. -# -# Allowance for leap seconds added to each time zone file. - -# This file is in the public domain. - -# This file is generated automatically from the data in the public-domain -# leap-seconds.list file, which can be copied from -# <ftp://ftp.nist.gov/pub/time/leap-seconds.list> -# or <ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.list> -# or <ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list>. -# For more about leap-seconds.list, please see -# The NTP Timescale and Leap Seconds -# <https://www.eecis.udel.edu/~mills/leap.html>. - -# The International Earth Rotation and Reference Systems Service -# periodically uses leap seconds to keep UTC to within 0.9 s of UT1 -# (which measures the true angular orientation of the earth in space) -# and publishes leap second data in a copyrighted file -# <https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat>. -# See: Levine J. Coordinated Universal Time and the leap second. -# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995 -# <https://ieeexplore.ieee.org/document/7909995>. -# There were no leap seconds before 1972, because the official mechanism -# accounting for the discrepancy between atomic time and the earth's rotation -# did not exist. - -# The correction (+ or -) is made at the given time, so lines -# will typically look like: -# Leap YEAR MON DAY 23:59:60 + R/S -# or -# Leap YEAR MON DAY 23:59:59 - R/S - -# If the leap second is Rolling (R) the given time is local time (unused here). -Leap 1972 Jun 30 23:59:60 + S -Leap 1972 Dec 31 23:59:60 + S -Leap 1973 Dec 31 23:59:60 + S -Leap 1974 Dec 31 23:59:60 + S -Leap 1975 Dec 31 23:59:60 + S -Leap 1976 Dec 31 23:59:60 + S -Leap 1977 Dec 31 23:59:60 + S -Leap 1978 Dec 31 23:59:60 + S -Leap 1979 Dec 31 23:59:60 + S -Leap 1981 Jun 30 23:59:60 + S -Leap 1982 Jun 30 23:59:60 + S -Leap 1983 Jun 30 23:59:60 + S -Leap 1985 Jun 30 23:59:60 + S -Leap 1987 Dec 31 23:59:60 + S -Leap 1989 Dec 31 23:59:60 + S -Leap 1990 Dec 31 23:59:60 + S -Leap 1992 Jun 30 23:59:60 + S -Leap 1993 Jun 30 23:59:60 + S -Leap 1994 Jun 30 23:59:60 + S -Leap 1995 Dec 31 23:59:60 + S -Leap 1997 Jun 30 23:59:60 + S -Leap 1998 Dec 31 23:59:60 + S -Leap 2005 Dec 31 23:59:60 + S -Leap 2008 Dec 31 23:59:60 + S -Leap 2012 Jun 30 23:59:60 + S -Leap 2015 Jun 30 23:59:60 + S -Leap 2016 Dec 31 23:59:60 + S - -# POSIX timestamps for the data in this file: -#updated 1467936000 -#expires 1561680000 - -# Updated through IERS Bulletin C56 -# File expires on: 28 June 2019 diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/northamerica b/src/test/jdk/sun/util/calendar/zi/tzdata/northamerica deleted file mode 100644 index 297a10a3849..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/northamerica +++ /dev/null @@ -1,3472 +0,0 @@ -# -# 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. -# -# tzdb data for North and Central America and environs - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# also includes Central America and the Caribbean - -# This file is by no means authoritative; if you think you know better, -# go ahead and edit the file (and please send any changes to -# tz@iana.org for general use in the future). For more, please see -# the file CONTRIBUTING in the tz distribution. - -# From Paul Eggert (1999-03-22): -# A reliable and entertaining source about time zones is -# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). - -############################################################################### - -# United States - -# From Paul Eggert (1999-03-31): -# Howse writes (pp 121-125) that time zones were invented by -# Professor Charles Ferdinand Dowd (1825-1904), -# Principal of Temple Grove Ladies' Seminary (Saratoga Springs, NY). -# His pamphlet "A System of National Time for Railroads" (1870) -# was the result of his proposals at the Convention of Railroad Trunk Lines -# in New York City (1869-10). His 1870 proposal was based on Washington, DC, -# but in 1872-05 he moved the proposed origin to Greenwich. - -# From Paul Eggert (2018-03-20): -# Dowd's proposal left many details unresolved, such as where to draw -# lines between time zones. The key individual who made time zones -# work in the US was William Frederick Allen - railway engineer, -# managing editor of the Travelers' Guide, and secretary of the -# General Time Convention, a railway standardization group. Allen -# spent months in dialogs with scientific and railway leaders, -# developed a workable plan to institute time zones, and presented it -# to the General Time Convention on 1883-04-11, saying that his plan -# meant "local time would be practically abolished" - a plus for -# railway scheduling. By the next convention on 1883-10-11 nearly all -# railroads had agreed and it took effect on 1883-11-18. That Sunday -# was called the "day of two noons", as some locations observed noon -# twice. Allen witnessed the transition in New York City, writing: -# -# I heard the bells of St. Paul's strike on the old time. Four -# minutes later, obedient to the electrical signal from the Naval -# Observatory ... the time-ball made its rapid descent, the chimes -# of old Trinity rang twelve measured strokes, and local time was -# abandoned, probably forever. -# -# Most of the US soon followed suit. See: -# Bartky IR. The adoption of standard time. Technol Cult 1989 Jan;30(1):25-56. -# https://dx.doi.org/10.2307/3105430 - -# From Paul Eggert (2005-04-16): -# That 1883 transition occurred at 12:00 new time, not at 12:00 old time. -# See p 46 of David Prerau, Seize the daylight, Thunder's Mouth Press (2005). - -# From Paul Eggert (2006-03-22): -# A good source for time zone historical data in the US is -# Thomas G. Shanks, The American Atlas (5th edition), -# San Diego: ACS Publications, Inc. (1991). -# Make sure you have the errata sheet; the book is somewhat useless without it. -# It is the source for most of the pre-1991 US entries below. - -# From Paul Eggert (2001-03-06): -# Daylight Saving Time was first suggested as a joke by Benjamin Franklin -# in his whimsical essay "An Economical Project for Diminishing the Cost -# of Light" published in the Journal de Paris (1784-04-26). -# Not everyone is happy with the results: -# -# I don't really care how time is reckoned so long as there is some -# agreement about it, but I object to being told that I am saving -# daylight when my reason tells me that I am doing nothing of the kind. -# I even object to the implication that I am wasting something -# valuable if I stay in bed after the sun has risen. As an admirer -# of moonlight I resent the bossy insistence of those who want to -# reduce my time for enjoying it. At the back of the Daylight Saving -# scheme I detect the bony, blue-fingered hand of Puritanism, eager -# to push people into bed earlier, and get them up earlier, to make -# them healthy, wealthy and wise in spite of themselves. -# -# -- Robertson Davies, The diary of Samuel Marchbanks, -# Clarke, Irwin (1947), XIX, Sunday -# -# For more about the first ten years of DST in the United States, see -# Robert Garland, Ten years of daylight saving from the Pittsburgh standpoint -# (Carnegie Library of Pittsburgh, 1927). -# http://www.clpgh.org/exhibit/dst.html -# -# Shanks says that DST was called "War Time" in the US in 1918 and 1919. -# However, DST was imposed by the Standard Time Act of 1918, which -# was the first nationwide legal time standard, and apparently -# time was just called "Standard Time" or "Daylight Saving Time". - -# From Arthur David Olson: -# US Daylight Saving Time ended on the last Sunday of *October* in 1974. -# See, for example, the front page of the Saturday, 1974-10-26 -# and Sunday, 1974-10-27 editions of the Washington Post. - -# From Arthur David Olson: -# Before the Uniform Time Act of 1966 took effect in 1967, observance of -# Daylight Saving Time in the US was by local option, except during wartime. - -# From Arthur David Olson (2000-09-25): -# Last night I heard part of a rebroadcast of a 1945 Arch Oboler radio drama. -# In the introduction, Oboler spoke of "Eastern Peace Time." -# An AltaVista search turned up: -# https://web.archive.org/web/20000926032210/http://rowayton.org/rhs/hstaug45.html -# "When the time is announced over the radio now, it is 'Eastern Peace -# Time' instead of the old familiar 'Eastern War Time.' Peace is wonderful." -# (August 1945) by way of confirmation. -# -# From Paul Eggert (2017-09-23): -# This was the V-J Day issue of the Clamdigger, a Rowayton, CT newsletter. - -# From Joseph Gallant citing -# George H. Douglas, _The Early Days of Radio Broadcasting_ (1987): -# At 7 P.M. (Eastern War Time) [on 1945-08-14], the networks were set -# to switch to London for Attlee's address, but the American people -# never got to hear his speech live. According to one press account, -# CBS' Bob Trout was first to announce the word of Japan's surrender, -# but a few seconds later, NBC, ABC and Mutual also flashed the word -# of surrender, all of whom interrupting the bells of Big Ben in -# London which were to precede Mr. Attlee's speech. - -# From Paul Eggert (2003-02-09): It was Robert St John, not Bob Trout. From -# Myrna Oliver's obituary of St John on page B16 of today's Los Angeles Times: -# -# ... a war-weary U.S. clung to radios, awaiting word of Japan's surrender. -# Any announcement from Asia would reach St. John's New York newsroom on a -# wire service teletype machine, which had prescribed signals for major news. -# Associated Press, for example, would ring five bells before spewing out -# typed copy of an important story, and 10 bells for news "of transcendental -# importance." -# -# On Aug. 14, stalling while talking steadily into the NBC networks' open -# microphone, St. John heard five bells and waited only to hear a sixth bell, -# before announcing confidently: "Ladies and gentlemen, World War II is over. -# The Japanese have agreed to our surrender terms." -# -# He had scored a 20-second scoop on other broadcasters. - -# From Arthur David Olson (2005-08-22): -# Paul has been careful to use the "US" rules only in those locations -# that are part of the United States; this reflects the real scope of -# U.S. government action. So even though the "US" rules have changed -# in the latest release, other countries won't be affected. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule US 1918 1919 - Mar lastSun 2:00 1:00 D -Rule US 1918 1919 - Oct lastSun 2:00 0 S -Rule US 1942 only - Feb 9 2:00 1:00 W # War -Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule US 1945 only - Sep lastSun 2:00 0 S -Rule US 1967 2006 - Oct lastSun 2:00 0 S -Rule US 1967 1973 - Apr lastSun 2:00 1:00 D -Rule US 1974 only - Jan 6 2:00 1:00 D -Rule US 1975 only - Feb 23 2:00 1:00 D -Rule US 1976 1986 - Apr lastSun 2:00 1:00 D -Rule US 1987 2006 - Apr Sun>=1 2:00 1:00 D -Rule US 2007 max - Mar Sun>=8 2:00 1:00 D -Rule US 2007 max - Nov Sun>=1 2:00 0 S - -# From Arthur David Olson, 2005-12-19 -# We generate the files specified below to guard against old files with -# obsolete information being left in the time zone binary directory. -# We limit the list to names that have appeared in previous versions of -# this time zone package. -# We do these as separate Zones rather than as Links to avoid problems if -# a particular place changes whether it observes DST. -# We put these specifications here in the northamerica file both to -# increase the chances that they'll actually get compiled and to -# avoid the need to duplicate the US rules in another file. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone EST -5:00 - EST -Zone MST -7:00 - MST -Zone HST -10:00 - HST -Zone EST5EDT -5:00 US E%sT -Zone CST6CDT -6:00 US C%sT -Zone MST7MDT -7:00 US M%sT -Zone PST8PDT -8:00 US P%sT - -# From U. S. Naval Observatory (1989-01-19): -# USA EASTERN 5 H BEHIND UTC NEW YORK, WASHINGTON -# USA EASTERN 4 H BEHIND UTC APR 3 - OCT 30 -# USA CENTRAL 6 H BEHIND UTC CHICAGO, HOUSTON -# USA CENTRAL 5 H BEHIND UTC APR 3 - OCT 30 -# USA MOUNTAIN 7 H BEHIND UTC DENVER -# USA MOUNTAIN 6 H BEHIND UTC APR 3 - OCT 30 -# USA PACIFIC 8 H BEHIND UTC L.A., SAN FRANCISCO -# USA PACIFIC 7 H BEHIND UTC APR 3 - OCT 30 -# USA ALASKA STD 9 H BEHIND UTC MOST OF ALASKA (AKST) -# USA ALASKA STD 8 H BEHIND UTC APR 3 - OCT 30 (AKDT) -# USA ALEUTIAN 10 H BEHIND UTC ISLANDS WEST OF 170W -# USA " 9 H BEHIND UTC APR 3 - OCT 30 -# USA HAWAII 10 H BEHIND UTC -# USA BERING 11 H BEHIND UTC SAMOA, MIDWAY - -# From Arthur David Olson (1989-01-21): -# The above dates are for 1988. -# Note the "AKST" and "AKDT" abbreviations, the claim that there's -# no DST in Samoa, and the claim that there is DST in Alaska and the -# Aleutians. - -# From Arthur David Olson (1988-02-13): -# Legal standard time zone names, from United States Code (1982 Edition and -# Supplement III), Title 15, Chapter 6, Section 260 and forward. First, names -# up to 1967-04-01 (when most provisions of the Uniform Time Act of 1966 -# took effect), as explained in sections 263 and 261: -# (none) -# United States standard eastern time -# United States standard mountain time -# United States standard central time -# United States standard Pacific time -# (none) -# United States standard Alaska time -# (none) -# Next, names from 1967-04-01 until 1983-11-30 (the date for -# public law 98-181): -# Atlantic standard time -# eastern standard time -# central standard time -# mountain standard time -# Pacific standard time -# Yukon standard time -# Alaska-Hawaii standard time -# Bering standard time -# And after 1983-11-30: -# Atlantic standard time -# eastern standard time -# central standard time -# mountain standard time -# Pacific standard time -# Alaska standard time -# Hawaii-Aleutian standard time -# Samoa standard time -# The law doesn't give abbreviations. -# -# From Paul Eggert (2016-12-19): -# Here are URLs for the 1918 and 1966 legislation: -# http://uscode.house.gov/statviewer.htm?volume=40&page=451 -# http://uscode.house.gov/statviewer.htm?volume=80&page=108 -# Although the 1918 names were officially "United States Standard -# Eastern Time" and similarly for "Central", "Mountain", "Pacific", -# and "Alaska", in practice "Standard" was placed just before "Time", -# as codified in 1966. In practice, Alaska time was abbreviated "AST" -# before 1968. Summarizing the 1967 name changes: -# 1918 names 1967 names -# -08 Standard Pacific Time (PST) Pacific standard time (PST) -# -09 (unofficial) Yukon (YST) Yukon standard time (YST) -# -10 Standard Alaska Time (AST) Alaska-Hawaii standard time (AHST) -# -11 (unofficial) Nome (NST) Bering standard time (BST) -# -# From Paul Eggert (2000-01-08), following a heads-up from Rives McDow: -# Public law 106-564 (2000-12-23) introduced ... "Chamorro Standard Time" -# for time in Guam and the Northern Marianas. See the file "australasia". -# -# From Paul Eggert (2015-04-17): -# HST and HDT are standardized abbreviations for Hawaii-Aleutian -# standard and daylight times. See section 9.47 (p 234) of the -# U.S. Government Printing Office Style Manual (2008) -# https://www.gpo.gov/fdsys/pkg/GPO-STYLEMANUAL-2008/pdf/GPO-STYLEMANUAL-2008.pdf - -# From Arthur David Olson, 2005-08-09 -# The following was signed into law on 2005-08-08. -# -# H.R. 6, Energy Policy Act of 2005, SEC. 110. DAYLIGHT SAVINGS. -# (a) Amendment.--Section 3(a) of the Uniform Time Act of 1966 (15 -# U.S.C. 260a(a)) is amended-- -# (1) by striking "first Sunday of April" and inserting "second -# Sunday of March"; and -# (2) by striking "last Sunday of October" and inserting "first -# Sunday of November'. -# (b) Effective Date.--Subsection (a) shall take effect 1 year after the -# date of enactment of this Act or March 1, 2007, whichever is later. -# (c) Report to Congress.--Not later than 9 months after the effective -# date stated in subsection (b), the Secretary shall report to Congress -# on the impact of this section on energy consumption in the United -# States. -# (d) Right to Revert.--Congress retains the right to revert the -# Daylight Saving Time back to the 2005 time schedules once the -# Department study is complete. - -# US eastern time, represented by New York - -# Connecticut, Delaware, District of Columbia, most of Florida, -# Georgia, southeast Indiana (Dearborn and Ohio counties), eastern Kentucky -# (except America/Kentucky/Louisville below), Maine, Maryland, Massachusetts, -# New Hampshire, New Jersey, New York, North Carolina, Ohio, -# Pennsylvania, Rhode Island, South Carolina, eastern Tennessee, -# Vermont, Virginia, West Virginia - -# From Dave Cantor (2004-11-02): -# Early this summer I had the occasion to visit the Mount Washington -# Observatory weather station atop (of course!) Mount Washington [, NH].... -# One of the staff members said that the station was on Eastern Standard Time -# and didn't change their clocks for Daylight Saving ... so that their -# reports will always have times which are 5 hours behind UTC. - -# From Paul Eggert (2005-08-26): -# According to today's Huntsville Times -# http://www.al.com/news/huntsvilletimes/index.ssf?/base/news/1125047783228320.xml&coll=1 -# a few towns on Alabama's "eastern border with Georgia, such as Phenix City -# in Russell County, Lanett in Chambers County and some towns in Lee County, -# set their watches and clocks on Eastern time." It quotes H.H. "Bubba" -# Roberts, city administrator in Phenix City. as saying "We are in the Central -# time zone, but we do go by the Eastern time zone because so many people work -# in Columbus." -# -# From Paul Eggert (2017-02-22): -# Four cities are involved. The two not mentioned above are Smiths Station -# and Valley. Barbara Brooks, Valley's assistant treasurer, heard it started -# because West Point Pepperell textile mills were in Alabama while the -# corporate office was in Georgia, and residents voted to keep Eastern -# time even after the mills closed. See: Kazek K. Did you know which -# Alabama towns are in a different time zone? al.com 2017-02-06. -# http://www.al.com/living/index.ssf/2017/02/do_you_know_which_alabama_town.html - -# From Paul Eggert (2014-09-06): -# Monthly Notices of the Royal Astronomical Society 44, 4 (1884-02-08), 208 -# says that New York City Hall time was 3 minutes 58.4 seconds fast of -# Eastern time (i.e., -4:56:01.6) just before the 1883 switch. Round to the -# nearest second. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule NYC 1920 only - Mar lastSun 2:00 1:00 D -Rule NYC 1920 only - Oct lastSun 2:00 0 S -Rule NYC 1921 1966 - Apr lastSun 2:00 1:00 D -Rule NYC 1921 1954 - Sep lastSun 2:00 0 S -Rule NYC 1955 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:03:58 - -5:00 US E%sT 1920 - -5:00 NYC E%sT 1942 - -5:00 US E%sT 1946 - -5:00 NYC E%sT 1967 - -5:00 US E%sT - -# US central time, represented by Chicago - -# Alabama, Arkansas, Florida panhandle (Bay, Calhoun, Escambia, -# Gulf, Holmes, Jackson, Okaloosa, Santa Rosa, Walton, and -# Washington counties), Illinois, western Indiana -# (Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer, -# Vanderburgh, and Warrick counties), Iowa, most of Kansas, western -# Kentucky, Louisiana, Minnesota, Mississippi, Missouri, eastern -# Nebraska, eastern North Dakota, Oklahoma, eastern South Dakota, -# western Tennessee, most of Texas, Wisconsin - -# From Paul Eggert (2018-01-07): -# In 1869 the Chicago Astronomical Society contracted with the city to keep -# time. Though delayed by the Great Fire, by 1880 a wire ran from the -# Dearborn Observatory (on the University of Chicago campus) to City Hall, -# which then sent signals to police and fire stations. However, railroads got -# their time signals from the Allegheny Observatory, the Madison Observatory, -# the Ann Arbor Observatory, etc., so their clocks did not agree with each -# other or with the city's official time. The confusion took some years to -# clear up. See: -# Moser M. How Chicago gave America its time zones. Chicago. 2018-01-04. -# http://www.chicagomag.com/city-life/January-2018/How-Chicago-Gave-America-Its-Time-Zones/ - -# From Larry M. Smith (2006-04-26) re Wisconsin: -# https://docs.legis.wisconsin.gov/statutes/statutes/175.pdf -# is currently enforced at the 01:00 time of change. Because the local -# "bar time" in the state corresponds to 02:00, a number of citations -# are issued for the "sale of class 'B' alcohol after prohibited -# hours" within the deviated hour of this change every year.... -# -# From Douglas R. Bomberg (2007-03-12): -# Wisconsin has enacted (nearly eleventh-hour) legislation to get WI -# Statue 175 closer in synch with the US Congress' intent.... -# https://docs.legis.wisconsin.gov/2007/related/acts/3 - -# From an email administrator of the City of Fort Pierre, SD (2015-12-21): -# Fort Pierre is technically located in the Mountain time zone as is -# the rest of Stanley County. Most of Stanley County and Fort Pierre -# uses the Central time zone due to doing most of their business in -# Pierre so it simplifies schedules. I have lived in Stanley County -# all my life and it has been that way since I can remember. (43 years!) -# -# From Paul Eggert (2015-12-25): -# Assume this practice predates 1970, so Fort Pierre can use America/Chicago. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Chicago 1920 only - Jun 13 2:00 1:00 D -Rule Chicago 1920 1921 - Oct lastSun 2:00 0 S -Rule Chicago 1921 only - Mar lastSun 2:00 1:00 D -Rule Chicago 1922 1966 - Apr lastSun 2:00 1:00 D -Rule Chicago 1922 1954 - Sep lastSun 2:00 0 S -Rule Chicago 1955 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Chicago -5:50:36 - LMT 1883 Nov 18 12:09:24 - -6:00 US C%sT 1920 - -6:00 Chicago C%sT 1936 Mar 1 2:00 - -5:00 - EST 1936 Nov 15 2:00 - -6:00 Chicago C%sT 1942 - -6:00 US C%sT 1946 - -6:00 Chicago C%sT 1967 - -6:00 US C%sT -# Oliver County, ND switched from mountain to central time on 1992-10-25. -Zone America/North_Dakota/Center -6:45:12 - LMT 1883 Nov 18 12:14:48 - -7:00 US M%sT 1992 Oct 25 2:00 - -6:00 US C%sT -# Morton County, ND, switched from mountain to central time on -# 2003-10-26, except for the area around Mandan which was already central time. -# See <http://dmses.dot.gov/docimages/p63/135818.pdf>. -# Officially this switch also included part of Sioux County, and -# Jones, Mellette, and Todd Counties in South Dakota; -# but in practice these other counties were already observing central time. -# See <http://www.epa.gov/fedrgstr/EPA-IMPACT/2003/October/Day-28/i27056.htm>. -Zone America/North_Dakota/New_Salem -6:45:39 - LMT 1883 Nov 18 12:14:21 - -7:00 US M%sT 2003 Oct 26 2:00 - -6:00 US C%sT - -# From Josh Findley (2011-01-21): -# ...it appears that Mercer County, North Dakota, changed from the -# mountain time zone to the central time zone at the last transition from -# daylight-saving to standard time (on Nov. 7, 2010): -# https://www.gpo.gov/fdsys/pkg/FR-2010-09-29/html/2010-24376.htm -# http://www.bismarcktribune.com/news/local/article_1eb1b588-c758-11df-b472-001cc4c03286.html - -# From Andy Lipscomb (2011-01-24): -# ...according to the Census Bureau, the largest city is Beulah (although -# it's commonly referred to as Beulah-Hazen, with Hazen being the next -# largest city in Mercer County). Google Maps places Beulah's city hall -# at 47° 15' 51" N, 101° 46' 40" W, which yields an offset of 6h47'07". - -Zone America/North_Dakota/Beulah -6:47:07 - LMT 1883 Nov 18 12:12:53 - -7:00 US M%sT 2010 Nov 7 2:00 - -6:00 US C%sT - -# US mountain time, represented by Denver -# -# Colorado, far western Kansas, Montana, western -# Nebraska, Nevada border (Jackpot, Owyhee, and Mountain City), -# New Mexico, southwestern North Dakota, -# western South Dakota, far western Texas (El Paso County, Hudspeth County, -# and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming -# -# From Paul Eggert (2018-10-25): -# On 1921-03-04 federal law placed all of Texas into the central time zone. -# However, El Paso ignored the law for decades and continued to observe -# mountain time, on the grounds that that's what they had always done -# and they weren't about to let the federal government tell them what to do. -# Eventually the federal government gave in and changed the law on -# 1970-04-10 to match what El Paso was actually doing. Although -# that's slightly after our 1970 cutoff, there is no need to create a -# separate zone for El Paso since they were ignoring the law anyway. See: -# Long T. El Pasoans were time rebels, fought to stay in Mountain zone. -# El Paso Times. 2018-10-24 06:40 -06. -# https://www.elpasotimes.com/story/news/local/el-paso/2018/10/24/el-pasoans-were-time-rebels-fought-stay-mountain-zone/1744509002/ -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Denver 1920 1921 - Mar lastSun 2:00 1:00 D -Rule Denver 1920 only - Oct lastSun 2:00 0 S -Rule Denver 1921 only - May 22 2:00 0 S -Rule Denver 1965 1966 - Apr lastSun 2:00 1:00 D -Rule Denver 1965 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00:04 - -7:00 US M%sT 1920 - -7:00 Denver M%sT 1942 - -7:00 US M%sT 1946 - -7:00 Denver M%sT 1967 - -7:00 US M%sT - -# US Pacific time, represented by Los Angeles -# -# California, northern Idaho (Benewah, Bonner, Boundary, Clearwater, -# Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties, Idaho county -# north of the Salmon River, and the towns of Burgdorf and Warren), -# Nevada (except West Wendover), Oregon (except the northern ¾ of -# Malheur county), and Washington - -# From Paul Eggert (2016-08-20): -# In early February 1948, in response to California's electricity shortage, -# PG&E changed power frequency from 60 to 59.5 Hz during daylight hours, -# causing electric clocks to lose six minutes per day. (This did not change -# legal time, and is not part of the data here.) See: -# Ross SA. An energy crisis from the past: Northern California in 1948. -# Working Paper No. 8, Institute of Governmental Studies, UC Berkeley, -# 1973-11. https://escholarship.org/uc/item/8x22k30c -# -# In another measure to save electricity, DST was instituted from 1948-03-14 -# at 02:01 to 1949-01-16 at 02:00, with the governor having the option to move -# the fallback transition earlier. See pages 3-4 of: -# http://clerk.assembly.ca.gov/sites/clerk.assembly.ca.gov/files/archive/Statutes/1948/48Vol1_Chapters.pdf -# -# In response: -# -# Governor Warren received a torrent of objecting mail, and it is not too much -# to speculate that the objections to Daylight Saving Time were one important -# factor in the defeat of the Dewey-Warren Presidential ticket in California. -# -- Ross, p 25 -# -# On December 8 the governor exercised the option, setting the date to January 1 -# (LA Times 1948-12-09). The transition time was 02:00 (LA Times 1949-01-01). -# -# Despite the controversy, in 1949 California voters approved Proposition 12, -# which established DST from April's last Sunday at 01:00 until September's -# last Sunday at 02:00. This was amended by 1962's Proposition 6, which changed -# the fall-back date to October's last Sunday. See: -# https://repository.uchastings.edu/cgi/viewcontent.cgi?article=1501&context=ca_ballot_props -# https://repository.uchastings.edu/cgi/viewcontent.cgi?article=1636&context=ca_ballot_props -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule CA 1948 only - Mar 14 2:01 1:00 D -Rule CA 1949 only - Jan 1 2:00 0 S -Rule CA 1950 1966 - Apr lastSun 1:00 1:00 D -Rule CA 1950 1961 - Sep lastSun 2:00 0 S -Rule CA 1962 1966 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 - -8:00 US P%sT 1946 - -8:00 CA P%sT 1967 - -8:00 US P%sT - -# Alaska -# AK%sT is the modern abbreviation for -09 per USNO. -# -# From Paul Eggert (2017-06-15): -# Howse writes that Alaska switched from the Julian to the Gregorian calendar, -# and from east-of-GMT to west-of-GMT days, when the US bought it from Russia. -# On Friday, 1867-10-18 (Gregorian), at precisely 15:30 local time, the -# Russian forts and fleet at Sitka fired salutes to mark the ceremony of -# formal transfer. See the Sacramento Daily Union (1867-11-14), p 3, col 2. -# https://cdnc.ucr.edu/cgi-bin/cdnc?a=d&d=SDU18671114.2.12.1 -# Sitka workers did not change their calendars until Sunday, 1867-10-20, -# and so celebrated two Sundays that week. See: Ahllund T (tr Hallamaa P). -# From the memoirs of a Finnish workman. Alaska History. 2006 Fall;21(2):1-25. -# http://alaskahistoricalsociety.org/wp-content/uploads/2016/12/Ahllund-2006-Memoirs-of-a-Finnish-Workman.pdf -# Include only the time zone part of this transition, ignoring the switch -# from Julian to Gregorian, since we can't represent the Julian calendar. -# -# As far as we know, of the locations mentioned below only Sitka was -# permanently inhabited in 1867 by anyone using either calendar. -# (Yakutat was colonized by the Russians in 1799, but the settlement was -# destroyed in 1805 by a Yakutat-kon war party.) Many of Alaska's inhabitants -# were unaware of the US acquisition of Alaska, much less of any calendar or -# time change. However, the Russian-influenced part of Alaska did observe -# Russian time, and it is more accurate to model this than to ignore it. -# The database format requires an exact transition time; use the Russian -# salute as a somewhat-arbitrary time for the formal transfer of control for -# all of Alaska. Sitka's UTC offset is -9:01:13; adjust its 15:30 to the -# local times of other Alaskan locations so that they change simultaneously. - -# From Paul Eggert (2014-07-18): -# One opinion of the early-1980s turmoil in Alaska over time zones and -# daylight saving time appeared as graffiti on a Juneau airport wall: -# "Welcome to Juneau. Please turn your watch back to the 19th century." -# See: Turner W. Alaska's four time zones now two. NY Times 1983-11-01. -# http://www.nytimes.com/1983/11/01/us/alaska-s-four-time-zones-now-two.html -# -# Steve Ferguson (2011-01-31) referred to the following source: -# Norris F. Keeping time in Alaska: national directives, local response. -# Alaska History 2001;16(1-2). -# http://alaskahistoricalsociety.org/discover-alaska/glimpses-of-the-past/keeping-time-in-alaska/ - -# From Arthur David Olson (2011-02-01): -# Here's database-relevant material from the 2001 "Alaska History" article: -# -# On September 20 [1979]...DOT...officials decreed that on April 27, -# 1980, Juneau and other nearby communities would move to Yukon Time. -# Sitka, Petersburg, Wrangell, and Ketchikan, however, would remain on -# Pacific Time. -# -# ...on September 22, 1980, DOT Secretary Neil E. Goldschmidt rescinded the -# Department's September 1979 decision. Juneau and other communities in -# northern Southeast reverted to Pacific Time on October 26. -# -# On October 28 [1983]...the Metlakatla Indian Community Council voted -# unanimously to keep the reservation on Pacific Time. -# -# According to DOT official Joanne Petrie, Indian reservations are not -# bound to follow time zones imposed by neighboring jurisdictions. -# -# (The last is consistent with how the database now handles the Navajo -# Nation.) - -# From Arthur David Olson (2011-02-09): -# I just spoke by phone with a staff member at the Metlakatla Indian -# Community office (using contact information available at -# http://www.commerce.state.ak.us/dca/commdb/CIS.cfm?Comm_Boro_name=Metlakatla -# It's shortly after 1:00 here on the east coast of the United States; -# the staffer said it was shortly after 10:00 there. When I asked whether -# that meant they were on Pacific time, they said no - they were on their -# own time. I asked about daylight saving; they said it wasn't used. I -# did not inquire about practices in the past. - -# From Arthur David Olson (2011-08-17): -# For lack of better information, assume that Metlakatla's -# abandonment of use of daylight saving resulted from the 1983 vote. - -# From Steffen Thorsen (2015-11-09): -# It seems Metlakatla did go off PST on Sunday, November 1, changing -# their time to AKST and are going to follow Alaska's DST, switching -# between AKST and AKDT from now on.... -# https://www.krbd.org/2015/10/30/annette-island-times-they-are-a-changing/ - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Juneau 15:02:19 - LMT 1867 Oct 19 15:33:32 - -8:57:41 - LMT 1900 Aug 20 12:00 - -8:00 - PST 1942 - -8:00 US P%sT 1946 - -8:00 - PST 1969 - -8:00 US P%sT 1980 Apr 27 2:00 - -9:00 US Y%sT 1980 Oct 26 2:00 - -8:00 US P%sT 1983 Oct 30 2:00 - -9:00 US Y%sT 1983 Nov 30 - -9:00 US AK%sT -Zone America/Sitka 14:58:47 - LMT 1867 Oct 19 15:30 - -9:01:13 - LMT 1900 Aug 20 12:00 - -8:00 - PST 1942 - -8:00 US P%sT 1946 - -8:00 - PST 1969 - -8:00 US P%sT 1983 Oct 30 2:00 - -9:00 US Y%sT 1983 Nov 30 - -9:00 US AK%sT -Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 19 15:44:55 - -8:46:18 - LMT 1900 Aug 20 12:00 - -8:00 - PST 1942 - -8:00 US P%sT 1946 - -8:00 - PST 1969 - -8:00 US P%sT 1983 Oct 30 2:00 - -8:00 - PST 2015 Nov 1 2:00 - -9:00 US AK%sT -Zone America/Yakutat 14:41:05 - LMT 1867 Oct 19 15:12:18 - -9:18:55 - LMT 1900 Aug 20 12:00 - -9:00 - YST 1942 - -9:00 US Y%sT 1946 - -9:00 - YST 1969 - -9:00 US Y%sT 1983 Nov 30 - -9:00 US AK%sT -Zone America/Anchorage 14:00:24 - LMT 1867 Oct 19 14:31:37 - -9:59:36 - LMT 1900 Aug 20 12:00 - -10:00 - AST 1942 - -10:00 US A%sT 1967 Apr - -10:00 - AHST 1969 - -10:00 US AH%sT 1983 Oct 30 2:00 - -9:00 US Y%sT 1983 Nov 30 - -9:00 US AK%sT -Zone America/Nome 12:58:22 - LMT 1867 Oct 19 13:29:35 - -11:01:38 - LMT 1900 Aug 20 12:00 - -11:00 - NST 1942 - -11:00 US N%sT 1946 - -11:00 - NST 1967 Apr - -11:00 - BST 1969 - -11:00 US B%sT 1983 Oct 30 2:00 - -9:00 US Y%sT 1983 Nov 30 - -9:00 US AK%sT -Zone America/Adak 12:13:22 - LMT 1867 Oct 19 12:44:35 - -11:46:38 - LMT 1900 Aug 20 12:00 - -11:00 - NST 1942 - -11:00 US N%sT 1946 - -11:00 - NST 1967 Apr - -11:00 - BST 1969 - -11:00 US B%sT 1983 Oct 30 2:00 - -10:00 US AH%sT 1983 Nov 30 - -10:00 US H%sT -# The following switches don't quite make our 1970 cutoff. -# -# Shanks writes that part of southwest Alaska (e.g. Aniak) -# switched from -11:00 to -10:00 on 1968-09-22 at 02:00, -# and another part (e.g. Akiak) made the same switch five weeks later. -# -# From David Flater (2004-11-09): -# In e-mail, 2004-11-02, Ray Hudson, historian/liaison to the Unalaska -# Historic Preservation Commission, provided this information, which -# suggests that Unalaska deviated from statutory time from early 1967 -# possibly until 1983: -# -# Minutes of the Unalaska City Council Meeting, January 10, 1967: -# "Except for St. Paul and Akutan, Unalaska is the only important -# location not on Alaska Standard Time. The following resolution was -# made by William Robinson and seconded by Henry Swanson: Be it -# resolved that the City of Unalaska hereby goes to Alaska Standard -# Time as of midnight Friday, January 13, 1967 (1 A.M. Saturday, -# January 14, Alaska Standard Time.) This resolution was passed with -# three votes for and one against." - -# Hawaii - -# From Arthur David Olson (2010-12-09): -# "Hawaiian Time" by Robert C. Schmitt and Doak C. Cox appears on pages 207-225 -# of volume 26 of The Hawaiian Journal of History (1992). As of 2010-12-09, -# the article is available at -# https://evols.library.manoa.hawaii.edu/bitstream/10524/239/2/JL26215.pdf -# and indicates that standard time was adopted effective noon, January -# 13, 1896 (page 218), that in "1933, the Legislature decreed daylight -# saving for the period between the last Sunday of each April and the -# last Sunday of each September, but less than a month later repealed the -# act," (page 220), that year-round daylight saving time was in effect -# from 1942-02-09 to 1945-09-30 (page 221, with no time of day given for -# when clocks changed) and that clocks were changed by 30 minutes -# effective the second Sunday of June, 1947 (page 219, with no time of -# day given for when clocks changed). A footnote for the 1933 changes -# cites Session Laws of Hawaii 1933, "Act. 90 (approved 26 Apr. 1933) -# and Act 163 (approved 21 May 1933)." - -# From Arthur David Olson (2011-01-19): -# The following is from "Laws of the Territory of Hawaii Passed by the -# Seventeenth Legislature: Regular Session 1933," available (as of -# 2011-01-19) at American University's Pence Law Library. Page 85: "Act -# 90...At 2 o'clock ante meridian of the last Sunday in April of each -# year, the standard time of this Territory shall be advanced one -# hour...This Act shall take effect upon its approval. Approved this 26th -# day of April, A. D. 1933. LAWRENCE M JUDD, Governor of the Territory of -# Hawaii." Page 172: "Act 163...Act 90 of the Session Laws of 1933 is -# hereby repealed...This Act shall take effect upon its approval, upon -# which date the standard time of this Territory shall be restored to -# that existing immediately prior to the taking effect of said Act 90. -# Approved this 21st day of May, A. D. 1933. LAWRENCE M. JUDD, Governor -# of the Territory of Hawaii." -# -# Note that 1933-05-21 was a Sunday. -# We're left to guess the time of day when Act 163 was approved; guess noon. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Honolulu -10:31:26 - LMT 1896 Jan 13 12:00 - -10:30 - HST 1933 Apr 30 2:00 - -10:30 1:00 HDT 1933 May 21 12:00 - -10:30 US H%sT 1947 Jun 8 2:00 - -10:00 - HST - -# Now we turn to US areas that have diverged from the consensus since 1970. - -# Arizona mostly uses MST. - -# From Paul Eggert (2002-10-20): -# -# The information in the rest of this paragraph is derived from the -# Daylight Saving Time web page -# <http://www.dlapr.lib.az.us/links/daylight.htm> (2002-01-23) -# maintained by the Arizona State Library, Archives and Public Records. -# Between 1944-01-01 and 1944-04-01 the State of Arizona used standard -# time, but by federal law railroads, airlines, bus lines, military -# personnel, and some engaged in interstate commerce continued to -# observe war (i.e., daylight saving) time. The 1944-03-17 Phoenix -# Gazette says that was the date the law changed, and that 04-01 was -# the date the state's clocks would change. In 1945 the State of -# Arizona used standard time all year, again with exceptions only as -# mandated by federal law. Arizona observed DST in 1967, but Arizona -# Laws 1968, ch. 183 (effective 1968-03-21) repealed DST. -# -# Shanks says the 1944 experiment came to an end on 1944-03-17. -# Go with the Arizona State Library instead. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Phoenix -7:28:18 - LMT 1883 Nov 18 11:31:42 - -7:00 US M%sT 1944 Jan 1 0:01 - -7:00 - MST 1944 Apr 1 0:01 - -7:00 US M%sT 1944 Oct 1 0:01 - -7:00 - MST 1967 - -7:00 US M%sT 1968 Mar 21 - -7:00 - MST -# From Arthur David Olson (1988-02-13): -# A writer from the Inter Tribal Council of Arizona, Inc., -# notes in private correspondence dated 1987-12-28 that "Presently, only the -# Navajo Nation participates in the Daylight Saving Time policy, due to its -# large size and location in three states." (The "only" means that other -# tribal nations don't use DST.) -# -# From Paul Eggert (2013-08-26): -# See America/Denver for a zone appropriate for the Navajo Nation. - -# Southern Idaho (Ada, Adams, Bannock, Bear Lake, Bingham, Blaine, -# Boise, Bonneville, Butte, Camas, Canyon, Caribou, Cassia, Clark, -# Custer, Elmore, Franklin, Fremont, Gem, Gooding, Jefferson, Jerome, -# Lemhi, Lincoln, Madison, Minidoka, Oneida, Owyhee, Payette, Power, -# Teton, Twin Falls, Valley, Washington counties, and the southern -# quarter of Idaho county) and eastern Oregon (most of Malheur County) -# switched four weeks late in 1974. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:15:11 - -8:00 US P%sT 1923 May 13 2:00 - -7:00 US M%sT 1974 - -7:00 - MST 1974 Feb 3 2:00 - -7:00 US M%sT - -# Indiana -# -# For a map of Indiana's time zone regions, see: -# https://en.wikipedia.org/wiki/Time_in_Indiana -# -# From Paul Eggert (2007-08-17): -# Since 1970, most of Indiana has been like America/Indiana/Indianapolis, -# with the following exceptions: -# -# - Gibson, Jasper, Lake, LaPorte, Newton, Porter, Posey, Spencer, -# Vanderburgh, and Warrick counties have been like America/Chicago. -# -# - Dearborn and Ohio counties have been like America/New_York. -# -# - Clark, Floyd, and Harrison counties have been like -# America/Kentucky/Louisville. -# -# - Crawford, Daviess, Dubois, Knox, Martin, Perry, Pike, Pulaski, Starke, -# and Switzerland counties have their own time zone histories as noted below. -# -# Shanks partitioned Indiana into 345 regions, each with its own time history, -# and wrote "Even newspaper reports present contradictory information." -# Those Hoosiers! Such a flighty and changeable people! -# Fortunately, most of the complexity occurred before our cutoff date of 1970. -# -# Other than Indianapolis, the Indiana place names are so nondescript -# that they would be ambiguous if we left them at the 'America' level. -# So we reluctantly put them all in a subdirectory 'America/Indiana'. - -# From Paul Eggert (2014-06-26): -# https://www.federalregister.gov/articles/2006/01/20/06-563/standard-time-zone-boundary-in-the-state-of-indiana -# says "DOT is relocating the time zone boundary in Indiana to move Starke, -# Pulaski, Knox, Daviess, Martin, Pike, Dubois, and Perry Counties from the -# Eastern Time Zone to the Central Time Zone.... The effective date of -# this rule is 2 a.m. EST Sunday, April 2, 2006, which is the -# changeover date from standard time to Daylight Saving Time." -# Strictly speaking, this meant the affected counties changed their -# clocks twice that night, but this obviously was in error. The intent -# was that 01:59:59 EST be followed by 02:00:00 CDT. - -# From Gwillim Law (2007-02-10): -# The Associated Press has been reporting that Pulaski County, Indiana is -# going to switch from Central to Eastern Time on March 11, 2007.... -# http://www.indystar.com/apps/pbcs.dll/article?AID=/20070207/LOCAL190108/702070524/0/LOCAL - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Indianapolis 1941 only - Jun 22 2:00 1:00 D -Rule Indianapolis 1941 1954 - Sep lastSun 2:00 0 S -Rule Indianapolis 1946 1954 - Apr lastSun 2:00 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Indianapolis -5:44:38 - LMT 1883 Nov 18 12:15:22 - -6:00 US C%sT 1920 - -6:00 Indianapolis C%sT 1942 - -6:00 US C%sT 1946 - -6:00 Indianapolis C%sT 1955 Apr 24 2:00 - -5:00 - EST 1957 Sep 29 2:00 - -6:00 - CST 1958 Apr 27 2:00 - -5:00 - EST 1969 - -5:00 US E%sT 1971 - -5:00 - EST 2006 - -5:00 US E%sT -# -# Eastern Crawford County, Indiana, left its clocks alone in 1974, -# as well as from 1976 through 2005. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Marengo 1951 only - Apr lastSun 2:00 1:00 D -Rule Marengo 1951 only - Sep lastSun 2:00 0 S -Rule Marengo 1954 1960 - Apr lastSun 2:00 1:00 D -Rule Marengo 1954 1960 - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Marengo -5:45:23 - LMT 1883 Nov 18 12:14:37 - -6:00 US C%sT 1951 - -6:00 Marengo C%sT 1961 Apr 30 2:00 - -5:00 - EST 1969 - -5:00 US E%sT 1974 Jan 6 2:00 - -6:00 1:00 CDT 1974 Oct 27 2:00 - -5:00 US E%sT 1976 - -5:00 - EST 2006 - -5:00 US E%sT -# -# Daviess, Dubois, Knox, and Martin Counties, Indiana, -# switched from eastern to central time in April 2006, then switched back -# in November 2007. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Vincennes 1946 only - Apr lastSun 2:00 1:00 D -Rule Vincennes 1946 only - Sep lastSun 2:00 0 S -Rule Vincennes 1953 1954 - Apr lastSun 2:00 1:00 D -Rule Vincennes 1953 1959 - Sep lastSun 2:00 0 S -Rule Vincennes 1955 only - May 1 0:00 1:00 D -Rule Vincennes 1956 1963 - Apr lastSun 2:00 1:00 D -Rule Vincennes 1960 only - Oct lastSun 2:00 0 S -Rule Vincennes 1961 only - Sep lastSun 2:00 0 S -Rule Vincennes 1962 1963 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Vincennes -5:50:07 - LMT 1883 Nov 18 12:09:53 - -6:00 US C%sT 1946 - -6:00 Vincennes C%sT 1964 Apr 26 2:00 - -5:00 - EST 1969 - -5:00 US E%sT 1971 - -5:00 - EST 2006 Apr 2 2:00 - -6:00 US C%sT 2007 Nov 4 2:00 - -5:00 US E%sT -# -# Perry County, Indiana, switched from eastern to central time in April 2006. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Perry 1946 only - Apr lastSun 2:00 1:00 D -Rule Perry 1946 only - Sep lastSun 2:00 0 S -Rule Perry 1953 1954 - Apr lastSun 2:00 1:00 D -Rule Perry 1953 1959 - Sep lastSun 2:00 0 S -Rule Perry 1955 only - May 1 0:00 1:00 D -Rule Perry 1956 1963 - Apr lastSun 2:00 1:00 D -Rule Perry 1960 only - Oct lastSun 2:00 0 S -Rule Perry 1961 only - Sep lastSun 2:00 0 S -Rule Perry 1962 1963 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Tell_City -5:47:03 - LMT 1883 Nov 18 12:12:57 - -6:00 US C%sT 1946 - -6:00 Perry C%sT 1964 Apr 26 2:00 - -5:00 - EST 1969 - -5:00 US E%sT 1971 - -5:00 - EST 2006 Apr 2 2:00 - -6:00 US C%sT -# -# Pike County, Indiana moved from central to eastern time in 1977, -# then switched back in 2006, then switched back again in 2007. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Pike 1955 only - May 1 0:00 1:00 D -Rule Pike 1955 1960 - Sep lastSun 2:00 0 S -Rule Pike 1956 1964 - Apr lastSun 2:00 1:00 D -Rule Pike 1961 1964 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Petersburg -5:49:07 - LMT 1883 Nov 18 12:10:53 - -6:00 US C%sT 1955 - -6:00 Pike C%sT 1965 Apr 25 2:00 - -5:00 - EST 1966 Oct 30 2:00 - -6:00 US C%sT 1977 Oct 30 2:00 - -5:00 - EST 2006 Apr 2 2:00 - -6:00 US C%sT 2007 Nov 4 2:00 - -5:00 US E%sT -# -# Starke County, Indiana moved from central to eastern time in 1991, -# then switched back in 2006. -# From Arthur David Olson (1991-10-28): -# An article on page A3 of the Sunday, 1991-10-27 Washington Post -# notes that Starke County switched from Central time to Eastern time as of -# 1991-10-27. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Starke 1947 1961 - Apr lastSun 2:00 1:00 D -Rule Starke 1947 1954 - Sep lastSun 2:00 0 S -Rule Starke 1955 1956 - Oct lastSun 2:00 0 S -Rule Starke 1957 1958 - Sep lastSun 2:00 0 S -Rule Starke 1959 1961 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Knox -5:46:30 - LMT 1883 Nov 18 12:13:30 - -6:00 US C%sT 1947 - -6:00 Starke C%sT 1962 Apr 29 2:00 - -5:00 - EST 1963 Oct 27 2:00 - -6:00 US C%sT 1991 Oct 27 2:00 - -5:00 - EST 2006 Apr 2 2:00 - -6:00 US C%sT -# -# Pulaski County, Indiana, switched from eastern to central time in -# April 2006 and then switched back in March 2007. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Pulaski 1946 1960 - Apr lastSun 2:00 1:00 D -Rule Pulaski 1946 1954 - Sep lastSun 2:00 0 S -Rule Pulaski 1955 1956 - Oct lastSun 2:00 0 S -Rule Pulaski 1957 1960 - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Winamac -5:46:25 - LMT 1883 Nov 18 12:13:35 - -6:00 US C%sT 1946 - -6:00 Pulaski C%sT 1961 Apr 30 2:00 - -5:00 - EST 1969 - -5:00 US E%sT 1971 - -5:00 - EST 2006 Apr 2 2:00 - -6:00 US C%sT 2007 Mar 11 2:00 - -5:00 US E%sT -# -# Switzerland County, Indiana, did not observe DST from 1973 through 2005. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Indiana/Vevay -5:40:16 - LMT 1883 Nov 18 12:19:44 - -6:00 US C%sT 1954 Apr 25 2:00 - -5:00 - EST 1969 - -5:00 US E%sT 1973 - -5:00 - EST 2006 - -5:00 US E%sT - -# From Paul Eggert (2018-03-20): -# The Louisville & Nashville Railroad's 1883-11-18 change occurred at -# 10:00 old local time; train were supposed to come to a standstill -# for precisely 18 minutes. See Bartky Fig. 1 (page 50). It is not -# clear how this matched civil time in Louisville, so for now continue -# to assume Louisville switched at noon new local time, like New York. -# -# Part of Kentucky left its clocks alone in 1974. -# This also includes Clark, Floyd, and Harrison counties in Indiana. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Louisville 1921 only - May 1 2:00 1:00 D -Rule Louisville 1921 only - Sep 1 2:00 0 S -Rule Louisville 1941 1961 - Apr lastSun 2:00 1:00 D -Rule Louisville 1941 only - Sep lastSun 2:00 0 S -Rule Louisville 1946 only - Jun 2 2:00 0 S -Rule Louisville 1950 1955 - Sep lastSun 2:00 0 S -Rule Louisville 1956 1960 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Kentucky/Louisville -5:43:02 - LMT 1883 Nov 18 12:16:58 - -6:00 US C%sT 1921 - -6:00 Louisville C%sT 1942 - -6:00 US C%sT 1946 - -6:00 Louisville C%sT 1961 Jul 23 2:00 - -5:00 - EST 1968 - -5:00 US E%sT 1974 Jan 6 2:00 - -6:00 1:00 CDT 1974 Oct 27 2:00 - -5:00 US E%sT -# -# Wayne County, Kentucky -# -# From Lake Cumberland LIFE -# http://www.lake-cumberland.com/life/archive/news990129time.shtml -# (1999-01-29) via WKYM-101.7: -# Clinton County has joined Wayne County in asking the DoT to change from -# the Central to the Eastern time zone.... The Wayne County government made -# the same request in December. And while Russell County officials have not -# taken action, the majority of respondents to a poll conducted there in -# August indicated they would like to change to "fast time" also. -# The three Lake Cumberland counties are the farthest east of any U.S. -# location in the Central time zone. -# -# From Rich Wales (2000-08-29): -# After prolonged debate, and despite continuing deep differences of opinion, -# Wayne County (central Kentucky) is switching from Central (-0600) to Eastern -# (-0500) time. They won't "fall back" this year. See Sara Shipley, -# The difference an hour makes, Nando Times (2000-08-29 15:33 -0400). -# -# From Paul Eggert (2001-07-16): -# The final rule was published in the -# Federal Register 65, 160 (2000-08-17), pp 50154-50158. -# https://www.gpo.gov/fdsys/pkg/FR-2000-08-17/html/00-20854.htm -# -Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:20:36 - -6:00 US C%sT 1946 - -6:00 - CST 1968 - -6:00 US C%sT 2000 Oct 29 2:00 - -5:00 US E%sT - - -# From Rives McDow (2000-08-30): -# Here ... are all the changes in the US since 1985. -# Kearny County, KS (put all of county on central; -# previously split between MST and CST) ... 1990-10 -# Starke County, IN (from CST to EST) ... 1991-10 -# Oliver County, ND (from MST to CST) ... 1992-10 -# West Wendover, NV (from PST TO MST) ... 1999-10 -# Wayne County, KY (from CST to EST) ... 2000-10 -# -# From Paul Eggert (2001-07-17): -# We don't know where the line used to be within Kearny County, KS, -# so omit that change for now. -# See America/Indiana/Knox for the Starke County, IN change. -# See America/North_Dakota/Center for the Oliver County, ND change. -# West Wendover, NV officially switched from Pacific to mountain time on -# 1999-10-31. See the -# Federal Register 64, 203 (1999-10-21), pp 56705-56707. -# https://www.gpo.gov/fdsys/pkg/FR-1999-10-21/html/99-27240.htm -# However, the Federal Register says that West Wendover already operated -# on mountain time, and the rule merely made this official; -# hence a separate tz entry is not needed. - -# Michigan -# -# From Bob Devine (1988-01-28): -# Michigan didn't observe DST from 1968 to 1973. -# -# From Paul Eggert (1999-03-31): -# Shanks writes that Michigan started using standard time on 1885-09-18, -# but Howse writes (pp 124-125, referring to Popular Astronomy, 1901-01) -# that Detroit kept -# -# local time until 1900 when the City Council decreed that clocks should -# be put back twenty-eight minutes to Central Standard Time. Half the -# city obeyed, half refused. After considerable debate, the decision -# was rescinded and the city reverted to Sun time. A derisive offer to -# erect a sundial in front of the city hall was referred to the -# Committee on Sewers. Then, in 1905, Central time was adopted -# by city vote. -# -# This story is too entertaining to be false, so go with Howse over Shanks. -# -# From Paul Eggert (2001-03-06): -# Garland (1927) writes "Cleveland and Detroit advanced their clocks -# one hour in 1914." This change is not in Shanks. We have no more -# info, so omit this for now. -# -# From Paul Eggert (2017-07-26): -# Although Shanks says Detroit observed DST in 1967 from 06-14 00:01 -# until 10-29 00:01, I now see multiple reports that this is incorrect. -# For example, according to a 50-year anniversary report about the 1967 -# Detroit riots and a major-league doubleheader on 1967-07-23, "By the time -# the last fly ball of the doubleheader settled into the glove of leftfielder -# Lenny Green, it was after 7 p.m. Detroit did not observe daylight saving -# time, so light was already starting to fail. Twilight was made even deeper -# by billowing columns of smoke that ascended in an unbroken wall north of the -# ballpark." See: Dow B. Detroit '67: As violence unfolded, Tigers played two -# at home vs. Yankees. Detroit Free Press 2017-07-23. -# https://www.freep.com/story/sports/mlb/tigers/2017/07/23/detroit-tigers-1967-riot-new-york-yankees/499951001/ -# -# Most of Michigan observed DST from 1973 on, but was a bit late in 1975. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Detroit 1948 only - Apr lastSun 2:00 1:00 D -Rule Detroit 1948 only - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Detroit -5:32:11 - LMT 1905 - -6:00 - CST 1915 May 15 2:00 - -5:00 - EST 1942 - -5:00 US E%sT 1946 - -5:00 Detroit E%sT 1973 - -5:00 US E%sT 1975 - -5:00 - EST 1975 Apr 27 2:00 - -5:00 US E%sT -# -# Dickinson, Gogebic, Iron, and Menominee Counties, Michigan, -# switched from EST to CST/CDT in 1973. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER -Rule Menominee 1946 only - Apr lastSun 2:00 1:00 D -Rule Menominee 1946 only - Sep lastSun 2:00 0 S -Rule Menominee 1966 only - Apr lastSun 2:00 1:00 D -Rule Menominee 1966 only - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 - -6:00 US C%sT 1946 - -6:00 Menominee C%sT 1969 Apr 27 2:00 - -5:00 - EST 1973 Apr 29 2:00 - -6:00 US C%sT - -# Navassa -# administered by the US Fish and Wildlife Service -# claimed by US under the provisions of the 1856 Guano Islands Act -# also claimed by Haiti -# occupied 1857/1900 by the Navassa Phosphate Co -# US lighthouse 1917/1996-09 -# currently uninhabited -# see Mark Fineman, "An Isle Rich in Guano and Discord", -# _Los Angeles Times_ (1998-11-10), A1, A10; it cites -# Jimmy Skaggs, _The Great Guano Rush_ (1994). - -################################################################################ - - -# From Paul Eggert (2017-02-10): -# -# Unless otherwise specified, the source for data through 1990 is: -# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), -# San Diego: ACS Publications, Inc. (2003). -# Unfortunately this book contains many errors and cites no sources. -# -# Many years ago Gwillim Law wrote that a good source -# for time zone data was the International Air Transport -# Association's Standard Schedules Information Manual (IATA SSIM), -# published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. Except where otherwise noted, -# IATA SSIM is the source for entries after 1990. -# -# Other sources occasionally used include: -# -# Edward W. Whitman, World Time Differences, -# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), -# which I found in the UCLA library. -# -# William Willett, The Waste of Daylight, 19th edition -# <http://cs.ucla.edu/~eggert/The-Waste-of-Daylight-19th.pdf> -# [PDF] (1914-03) -# -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94 -# <https://www.jstor.org/stable/1774359>. -# -# See the 'europe' file for Greenland. - -# Canada - -# From Alain LaBonté (1994-11-14): -# I post here the time zone abbreviations standardized in Canada -# for both English and French in the CAN/CSA-Z234.4-89 standard.... -# -# UTC Standard time Daylight saving time -# offset French English French English -# -2:30 - - HAT NDT -# -3 - - HAA ADT -# -3:30 HNT NST - - -# -4 HNA AST HAE EDT -# -5 HNE EST HAC CDT -# -6 HNC CST HAR MDT -# -7 HNR MST HAP PDT -# -8 HNP PST HAY YDT -# -9 HNY YST - - -# -# HN: Heure Normale ST: Standard Time -# HA: Heure Avancée DT: Daylight saving Time -# -# A: de l'Atlantique Atlantic -# C: du Centre Central -# E: de l'Est Eastern -# M: Mountain -# N: Newfoundland -# P: du Pacifique Pacific -# R: des Rocheuses -# T: de Terre-Neuve -# Y: du Yukon Yukon -# -# From Paul Eggert (1994-11-22): -# Alas, this sort of thing must be handled by localization software. - -# Unless otherwise specified, the data entries for Canada are all from Shanks -# & Pottenger. - -# From Chris Walton (2006-04-01, 2006-04-25, 2006-06-26, 2007-01-31, -# 2007-03-01): -# The British Columbia government announced yesterday that it will -# adjust daylight savings next year to align with changes in the -# U.S. and the rest of Canada.... -# https://archive.news.gov.bc.ca/releases/news_releases_2005-2009/2006AG0014-000330.htm -# ... -# Nova Scotia -# Daylight saving time will be extended by four weeks starting in 2007.... -# https://www.novascotia.ca/just/regulations/rg2/2006/ma1206.pdf -# -# [For New Brunswick] the new legislation dictates that the time change is to -# be done at 02:00 instead of 00:01. -# https://www.gnb.ca/0062/acts/BBA-2006/Chap-19.pdf -# ... -# Manitoba has traditionally changed the clock every fall at 03:00. -# As of 2006, the transition is to take place one hour earlier at 02:00. -# https://web2.gov.mb.ca/laws/statutes/ccsm/o030e.php -# ... -# [Alberta, Ontario, Quebec] will follow US rules. -# http://www.qp.gov.ab.ca/documents/spring/CH03_06.CFM -# http://www.e-laws.gov.on.ca/DBLaws/Source/Regs/English/2006/R06111_e.htm -# http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=5&file=2006C39A.PDF -# ... -# P.E.I. will follow US rules.... -# http://www.assembly.pe.ca/bills/pdf_chapter/62/3/chapter-41.pdf -# ... -# Province of Newfoundland and Labrador.... -# http://www.hoa.gov.nl.ca/hoa/bills/Bill0634.htm -# ... -# Yukon -# https://www.gov.yk.ca/legislation/regs/oic2006_127.pdf -# ... -# N.W.T. will follow US rules. Whoever maintains the government web site -# does not seem to believe in bookmarks. To see the news release, click the -# following link and search for "Daylight Savings Time Change". Press the -# "Daylight Savings Time Change" link; it will fire off a popup using -# JavaScript. -# http://www.exec.gov.nt.ca/currentnews/currentPR.asp?mode=archive -# ... -# Nunavut -# An amendment to the Interpretation Act was registered on February 19/2007.... -# http://action.attavik.ca/home/justice-gn/attach/2007/gaz02part2.pdf - -# From Paul Eggert (2014-10-18): -# H. David Matthews and Mary Vincent's map -# "It's about TIME", _Canadian Geographic_ (September-October 1998) -# http://www.canadiangeographic.ca/Magazine/SO98/alacarte.asp -# contains detailed boundaries for regions observing nonstandard -# time and daylight saving time arrangements in Canada circa 1998. -# -# National Research Council Canada maintains info about time zones and DST. -# https://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html -# https://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5 -# Its unofficial information is often taken from Matthews and Vincent. - -# From Paul Eggert (2006-06-27): -# For now, assume all of DST-observing Canada will fall into line with the -# new US DST rules, - -# From Chris Walton (2011-12-01) -# In the first of Tammy Hardwick's articles -# http://www.ilovecreston.com/?p=articles&t=spec&ar=260 -# she quotes the Friday November 1/1918 edition of the Creston Review. -# The quote includes these two statements: -# 'Sunday the CPR went back to the old system of time...' -# '... The daylight saving scheme was dropped all over Canada at the same time,' -# These statements refer to a transition from daylight time to standard time -# that occurred nationally on Sunday October 27/1918. This transition was -# also documented in the Saturday October 26/1918 edition of the Toronto Star. - -# In light of that evidence, we alter the date from the earlier believed -# Oct 31, to Oct 27, 1918 (and Sunday is a more likely transition day -# than Thursday) in all Canadian rulesets. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Canada 1918 only - Apr 14 2:00 1:00 D -Rule Canada 1918 only - Oct 27 2:00 0 S -Rule Canada 1942 only - Feb 9 2:00 1:00 W # War -Rule Canada 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule Canada 1945 only - Sep 30 2:00 0 S -Rule Canada 1974 1986 - Apr lastSun 2:00 1:00 D -Rule Canada 1974 2006 - Oct lastSun 2:00 0 S -Rule Canada 1987 2006 - Apr Sun>=1 2:00 1:00 D -Rule Canada 2007 max - Mar Sun>=8 2:00 1:00 D -Rule Canada 2007 max - Nov Sun>=1 2:00 0 S - - -# Newfoundland and Labrador - -# From Paul Eggert (2017-10-14): -# Legally Labrador should observe Newfoundland time; see: -# McLeod J. Labrador time - legal or not? St. John's Telegram, 2017-10-07 -# http://www.thetelegram.com/news/local/labrador-time--legal-or-not-154860/ -# Matthews and Vincent (1998) write that the only part of Labrador -# that follows the rules is the southeast corner, including Port Hope -# Simpson and Mary's Harbour, but excluding, say, Black Tickle. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule StJohns 1917 only - Apr 8 2:00 1:00 D -Rule StJohns 1917 only - Sep 17 2:00 0 S -# Whitman gives 1919 Apr 5 and 1920 Apr 5; go with Shanks & Pottenger. -Rule StJohns 1919 only - May 5 23:00 1:00 D -Rule StJohns 1919 only - Aug 12 23:00 0 S -# For 1931-1935 Whitman gives Apr same date; go with Shanks & Pottenger. -Rule StJohns 1920 1935 - May Sun>=1 23:00 1:00 D -Rule StJohns 1920 1935 - Oct lastSun 23:00 0 S -# For 1936-1941 Whitman gives May Sun>=8 and Oct Sun>=1; go with Shanks & -# Pottenger. -Rule StJohns 1936 1941 - May Mon>=9 0:00 1:00 D -Rule StJohns 1936 1941 - Oct Mon>=2 0:00 0 S -# Whitman gives the following transitions: -# 1942 03-01/12-31, 1943 05-30/09-05, 1944 07-10/09-02, 1945 01-01/10-07 -# but go with Shanks & Pottenger and assume they used Canadian rules. -# For 1946-9 Whitman gives May 5,4,9,1 - Oct 1,5,3,2, and for 1950 he gives -# Apr 30 - Sep 24; go with Shanks & Pottenger. -Rule StJohns 1946 1950 - May Sun>=8 2:00 1:00 D -Rule StJohns 1946 1950 - Oct Sun>=2 2:00 0 S -Rule StJohns 1951 1986 - Apr lastSun 2:00 1:00 D -Rule StJohns 1951 1959 - Sep lastSun 2:00 0 S -Rule StJohns 1960 1986 - Oct lastSun 2:00 0 S -# From Paul Eggert (2000-10-02): -# INMS (2000-09-12) says that, since 1988 at least, Newfoundland switches -# at 00:01 local time. For now, assume it started in 1987. - -# From Michael Pelley (2011-09-12): -# We received today, Monday, September 12, 2011, notification that the -# changes to the Newfoundland Standard Time Act have been proclaimed. -# The change in the Act stipulates that the change from Daylight Savings -# Time to Standard Time and from Standard Time to Daylight Savings Time -# now occurs at 2:00AM. -# ... -# http://www.assembly.nl.ca/legislation/sr/annualstatutes/2011/1106.chp.htm -# ... -# MICHAEL PELLEY | Manager of Enterprise Architecture - Solution Delivery -# Office of the Chief Information Officer -# Executive Council -# Government of Newfoundland & Labrador - -Rule StJohns 1987 only - Apr Sun>=1 0:01 1:00 D -Rule StJohns 1987 2006 - Oct lastSun 0:01 0 S -Rule StJohns 1988 only - Apr Sun>=1 0:01 2:00 DD -Rule StJohns 1989 2006 - Apr Sun>=1 0:01 1:00 D -Rule StJohns 2007 2011 - Mar Sun>=8 0:01 1:00 D -Rule StJohns 2007 2010 - Nov Sun>=1 0:01 0 S -# -# St John's has an apostrophe, but Posix file names can't have apostrophes. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/St_Johns -3:30:52 - LMT 1884 - -3:30:52 StJohns N%sT 1918 - -3:30:52 Canada N%sT 1919 - -3:30:52 StJohns N%sT 1935 Mar 30 - -3:30 StJohns N%sT 1942 May 11 - -3:30 Canada N%sT 1946 - -3:30 StJohns N%sT 2011 Nov - -3:30 Canada N%sT - -# most of east Labrador - -# The name 'Happy Valley-Goose Bay' is too long; use 'Goose Bay'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Goose_Bay -4:01:40 - LMT 1884 # Happy Valley-Goose Bay - -3:30:52 - NST 1918 - -3:30:52 Canada N%sT 1919 - -3:30:52 - NST 1935 Mar 30 - -3:30 - NST 1936 - -3:30 StJohns N%sT 1942 May 11 - -3:30 Canada N%sT 1946 - -3:30 StJohns N%sT 1966 Mar 15 2:00 - -4:00 StJohns A%sT 2011 Nov - -4:00 Canada A%sT - - -# west Labrador, Nova Scotia, Prince Edward I - -# From Brian Inglis (2015-07-20): -# From the historical weather station records available at: -# https://weatherspark.com/history/28351/1971/Sydney-Nova-Scotia-Canada -# Sydney shares the same time history as Glace Bay, so was -# likely to be the same across the island.... -# Sydney, as the capital and most populous location, or Cape Breton, would -# have been better names for the zone had we known this in 1996. - -# From Paul Eggert (2015-07-20): -# Shanks & Pottenger write that since 1970 most of this region has been like -# Halifax. Many locales did not observe peacetime DST until 1972; -# the Cape Breton area, represented by Glace Bay, is the largest we know of -# (Glace Bay was perhaps not the best name choice but no point changing now). -# Shanks & Pottenger also write that Liverpool, NS was the only town -# in Canada to observe DST in 1971 but not 1970; for now we'll assume -# this is a typo. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Halifax 1916 only - Apr 1 0:00 1:00 D -Rule Halifax 1916 only - Oct 1 0:00 0 S -Rule Halifax 1920 only - May 9 0:00 1:00 D -Rule Halifax 1920 only - Aug 29 0:00 0 S -Rule Halifax 1921 only - May 6 0:00 1:00 D -Rule Halifax 1921 1922 - Sep 5 0:00 0 S -Rule Halifax 1922 only - Apr 30 0:00 1:00 D -Rule Halifax 1923 1925 - May Sun>=1 0:00 1:00 D -Rule Halifax 1923 only - Sep 4 0:00 0 S -Rule Halifax 1924 only - Sep 15 0:00 0 S -Rule Halifax 1925 only - Sep 28 0:00 0 S -Rule Halifax 1926 only - May 16 0:00 1:00 D -Rule Halifax 1926 only - Sep 13 0:00 0 S -Rule Halifax 1927 only - May 1 0:00 1:00 D -Rule Halifax 1927 only - Sep 26 0:00 0 S -Rule Halifax 1928 1931 - May Sun>=8 0:00 1:00 D -Rule Halifax 1928 only - Sep 9 0:00 0 S -Rule Halifax 1929 only - Sep 3 0:00 0 S -Rule Halifax 1930 only - Sep 15 0:00 0 S -Rule Halifax 1931 1932 - Sep Mon>=24 0:00 0 S -Rule Halifax 1932 only - May 1 0:00 1:00 D -Rule Halifax 1933 only - Apr 30 0:00 1:00 D -Rule Halifax 1933 only - Oct 2 0:00 0 S -Rule Halifax 1934 only - May 20 0:00 1:00 D -Rule Halifax 1934 only - Sep 16 0:00 0 S -Rule Halifax 1935 only - Jun 2 0:00 1:00 D -Rule Halifax 1935 only - Sep 30 0:00 0 S -Rule Halifax 1936 only - Jun 1 0:00 1:00 D -Rule Halifax 1936 only - Sep 14 0:00 0 S -Rule Halifax 1937 1938 - May Sun>=1 0:00 1:00 D -Rule Halifax 1937 1941 - Sep Mon>=24 0:00 0 S -Rule Halifax 1939 only - May 28 0:00 1:00 D -Rule Halifax 1940 1941 - May Sun>=1 0:00 1:00 D -Rule Halifax 1946 1949 - Apr lastSun 2:00 1:00 D -Rule Halifax 1946 1949 - Sep lastSun 2:00 0 S -Rule Halifax 1951 1954 - Apr lastSun 2:00 1:00 D -Rule Halifax 1951 1954 - Sep lastSun 2:00 0 S -Rule Halifax 1956 1959 - Apr lastSun 2:00 1:00 D -Rule Halifax 1956 1959 - Sep lastSun 2:00 0 S -Rule Halifax 1962 1973 - Apr lastSun 2:00 1:00 D -Rule Halifax 1962 1973 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Halifax -4:14:24 - LMT 1902 Jun 15 - -4:00 Halifax A%sT 1918 - -4:00 Canada A%sT 1919 - -4:00 Halifax A%sT 1942 Feb 9 2:00s - -4:00 Canada A%sT 1946 - -4:00 Halifax A%sT 1974 - -4:00 Canada A%sT -Zone America/Glace_Bay -3:59:48 - LMT 1902 Jun 15 - -4:00 Canada A%sT 1953 - -4:00 Halifax A%sT 1954 - -4:00 - AST 1972 - -4:00 Halifax A%sT 1974 - -4:00 Canada A%sT - -# New Brunswick - -# From Paul Eggert (2007-01-31): -# The Time Definition Act <http://www.gnb.ca/0062/PDF-acts/t-06.pdf> -# says they changed at 00:01 through 2006, and -# <http://www.canlii.org/nb/laws/sta/t-6/20030127/whole.html> makes it -# clear that this was the case since at least 1993. -# For now, assume it started in 1993. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Moncton 1933 1935 - Jun Sun>=8 1:00 1:00 D -Rule Moncton 1933 1935 - Sep Sun>=8 1:00 0 S -Rule Moncton 1936 1938 - Jun Sun>=1 1:00 1:00 D -Rule Moncton 1936 1938 - Sep Sun>=1 1:00 0 S -Rule Moncton 1939 only - May 27 1:00 1:00 D -Rule Moncton 1939 1941 - Sep Sat>=21 1:00 0 S -Rule Moncton 1940 only - May 19 1:00 1:00 D -Rule Moncton 1941 only - May 4 1:00 1:00 D -Rule Moncton 1946 1972 - Apr lastSun 2:00 1:00 D -Rule Moncton 1946 1956 - Sep lastSun 2:00 0 S -Rule Moncton 1957 1972 - Oct lastSun 2:00 0 S -Rule Moncton 1993 2006 - Apr Sun>=1 0:01 1:00 D -Rule Moncton 1993 2006 - Oct lastSun 0:01 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Moncton -4:19:08 - LMT 1883 Dec 9 - -5:00 - EST 1902 Jun 15 - -4:00 Canada A%sT 1933 - -4:00 Moncton A%sT 1942 - -4:00 Canada A%sT 1946 - -4:00 Moncton A%sT 1973 - -4:00 Canada A%sT 1993 - -4:00 Moncton A%sT 2007 - -4:00 Canada A%sT - -# Quebec - -# From Paul Eggert (2015-03-24): -# See America/Toronto for most of Quebec, including Montreal. -# -# Matthews and Vincent (1998) also write that Quebec east of the -63 -# meridian is supposed to observe AST, but residents as far east as -# Natashquan use EST/EDT, and residents east of Natashquan use AST. -# The Quebec department of justice writes in -# "The situation in Minganie and Basse-Côte-Nord" -# http://www.justice.gouv.qc.ca/english/publications/generale/temps-minganie-a.htm -# that the coastal strip from just east of Natashquan to Blanc-Sablon -# observes Atlantic standard time all year round. -# https://www.assnat.qc.ca/Media/Process.aspx?MediaId=ANQ.Vigie.Bll.DocumentGenerique_8845en -# says this common practice was codified into law as of 2007. -# For lack of better info, guess this practice began around 1970, contra to -# Shanks & Pottenger who have this region observing AST/ADT. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Blanc-Sablon -3:48:28 - LMT 1884 - -4:00 Canada A%sT 1970 - -4:00 - AST - -# Ontario - -# From Paul Eggert (2006-07-09): -# Shanks & Pottenger write that since 1970 most of Ontario has been like -# Toronto. -# Thunder Bay skipped DST in 1973. -# Many smaller locales did not observe peacetime DST until 1974; -# Nipigon (EST) and Rainy River (CST) are the largest that we know of. -# Far west Ontario is like Winnipeg; far east Quebec is like Halifax. - -# From Mark Brader (2003-07-26): -# [According to the Toronto Star] Orillia, Ontario, adopted DST -# effective Saturday, 1912-06-22, 22:00; the article mentions that -# Port Arthur (now part of Thunder Bay, Ontario) as well as Moose Jaw -# have already done so. In Orillia DST was to run until Saturday, -# 1912-08-31 (no time mentioned), but it was met with considerable -# hostility from certain segments of the public, and was revoked after -# only two weeks - I copied it as Saturday, 1912-07-07, 22:00, but -# presumably that should be -07-06. (1912-06-19, -07-12; also letters -# earlier in June). -# -# Kenora, Ontario, was to abandon DST on 1914-06-01 (-05-21). -# -# From Paul Eggert (2017-07-08): -# For more on Orillia, see: Daubs K. Bold attempt at daylight saving -# time became a comic failure in Orillia. Toronto Star 2017-07-08. -# https://www.thestar.com/news/insight/2017/07/08/bold-attempt-at-daylight-saving-time-became-a-comic-failure-in-orillia.html - -# From Paul Eggert (1997-10-17): -# Mark Brader writes that an article in the 1997-10-14 Toronto Star -# says that Atikokan, Ontario currently does not observe DST, -# but will vote on 11-10 whether to use EST/EDT. -# He also writes that the Ontario Time Act (1990, Chapter T.9) -# http://www.gov.on.ca/MBS/english/publications/statregs/conttext.html -# says that Ontario east of 90W uses EST/EDT, and west of 90W uses CST/CDT. -# Officially Atikokan is therefore on CST/CDT, and most likely this report -# concerns a non-official time observed as a matter of local practice. -# -# From Paul Eggert (2000-10-02): -# Matthews and Vincent (1998) write that Atikokan, Pickle Lake, and -# New Osnaburgh observe CST all year, that Big Trout Lake observes -# CST/CDT, and that Upsala and Shebandowan observe EST/EDT, all in -# violation of the official Ontario rules. -# -# From Paul Eggert (2006-07-09): -# Chris Walton (2006-07-06) mentioned an article by Stephanie MacLellan in the -# 2005-07-21 Chronicle-Journal, which said: -# -# The clocks in Atikokan stay set on standard time year-round. -# This means they spend about half the time on central time and -# the other half on eastern time. -# -# For the most part, the system works, Mayor Dennis Brown said. -# -# "The majority of businesses in Atikokan deal more with Eastern -# Canada, but there are some that deal with Western Canada," he -# said. "I don't see any changes happening here." -# -# Walton also writes "Supposedly Pickle Lake and Mishkeegogamang -# [New Osnaburgh] follow the same practice." - -# From Garry McKinnon (2006-07-14) via Chris Walton: -# I chatted with a member of my board who has an outstanding memory -# and a long history in Atikokan (and in the telecom industry) and he -# can say for certain that Atikokan has been practicing the current -# time keeping since 1952, at least. - -# From Paul Eggert (2006-07-17): -# Shanks & Pottenger say that Atikokan has agreed with Rainy River -# ever since standard time was introduced, but the information from -# McKinnon sounds more authoritative. For now, assume that Atikokan -# switched to EST immediately after WWII era daylight saving time -# ended. This matches the old (less-populous) America/Coral_Harbour -# entry since our cutoff date of 1970, so we can move -# America/Coral_Harbour to the 'backward' file. - -# From Mark Brader (2010-03-06): -# -# Currently the database has: -# -# # Ontario -# -# # From Paul Eggert (2006-07-09): -# # Shanks & Pottenger write that since 1970 most of Ontario has been like -# # Toronto. -# # Thunder Bay skipped DST in 1973. -# # Many smaller locales did not observe peacetime DST until 1974; -# # Nipigon (EST) and Rainy River (CST) are the largest that we know of. -# -# In the (Toronto) Globe and Mail for Saturday, 1955-09-24, in the bottom -# right corner of page 1, it says that Toronto will return to standard -# time at 2 am Sunday morning (which agrees with the database), and that: -# -# The one-hour setback will go into effect throughout most of Ontario, -# except in areas like Windsor which remains on standard time all year. -# -# Windsor is, of course, a lot larger than Nipigon. -# -# I only came across this incidentally. I don't know if Windsor began -# observing DST when Detroit did, or in 1974, or on some other date. -# -# By the way, the article continues by noting that: -# -# Some cities in the United States have pushed the deadline back -# three weeks and will change over from daylight saving in October. - -# From Arthur David Olson (2010-07-17): -# -# "Standard Time and Time Zones in Canada" appeared in -# The Journal of The Royal Astronomical Society of Canada, -# volume 26, number 2 (February 1932) and, as of 2010-07-17, -# was available at -# http://adsabs.harvard.edu/full/1932JRASC..26...49S -# -# It includes the text below (starting on page 57): -# -# A list of the places in Canada using daylight saving time would -# require yearly revision. From information kindly furnished by -# the provincial governments and by the postmasters in many cities -# and towns, it is found that the following places used daylight sav- -# ing in 1930. The information for the province of Quebec is definite, -# for the other provinces only approximate: -# -# Province Daylight saving time used -# Prince Edward Island Not used. -# Nova Scotia In Halifax only. -# New Brunswick In St. John only. -# Quebec In the following places: -# Montreal Lachine -# Quebec Mont-Royal -# Lévis Iberville -# St. Lambert Cap de la Madelèine -# Verdun Loretteville -# Westmount Richmond -# Outremont St. Jérôme -# Longueuil Greenfield Park -# Arvida Waterloo -# Chambly-Canton Beaulieu -# Melbourne La Tuque -# St. Théophile Buckingham -# Ontario Used generally in the cities and towns along -# the southerly part of the province. Not -# used in the northwesterly part. -# Manitoba Not used. -# Saskatchewan In Regina only. -# Alberta Not used. -# British Columbia Not used. -# -# With some exceptions, the use of daylight saving may be said to be limited -# to those cities and towns lying between Quebec city and Windsor, Ont. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Toronto 1919 only - Mar 30 23:30 1:00 D -Rule Toronto 1919 only - Oct 26 0:00 0 S -Rule Toronto 1920 only - May 2 2:00 1:00 D -Rule Toronto 1920 only - Sep 26 0:00 0 S -Rule Toronto 1921 only - May 15 2:00 1:00 D -Rule Toronto 1921 only - Sep 15 2:00 0 S -Rule Toronto 1922 1923 - May Sun>=8 2:00 1:00 D -# Shanks & Pottenger say 1923-09-19; assume it's a typo and that "-16" -# was meant. -Rule Toronto 1922 1926 - Sep Sun>=15 2:00 0 S -Rule Toronto 1924 1927 - May Sun>=1 2:00 1:00 D -# The 1927-to-1939 rules can be expressed more simply as -# Rule Toronto 1927 1937 - Sep Sun>=25 2:00 0 S -# Rule Toronto 1928 1937 - Apr Sun>=25 2:00 1:00 D -# Rule Toronto 1938 1940 - Apr lastSun 2:00 1:00 D -# Rule Toronto 1938 1939 - Sep lastSun 2:00 0 S -# The rules below avoid use of Sun>=25 -# (which pre-2004 versions of zic cannot handle). -Rule Toronto 1927 1932 - Sep lastSun 2:00 0 S -Rule Toronto 1928 1931 - Apr lastSun 2:00 1:00 D -Rule Toronto 1932 only - May 1 2:00 1:00 D -Rule Toronto 1933 1940 - Apr lastSun 2:00 1:00 D -Rule Toronto 1933 only - Oct 1 2:00 0 S -Rule Toronto 1934 1939 - Sep lastSun 2:00 0 S -Rule Toronto 1945 1946 - Sep lastSun 2:00 0 S -Rule Toronto 1946 only - Apr lastSun 2:00 1:00 D -Rule Toronto 1947 1949 - Apr lastSun 0:00 1:00 D -Rule Toronto 1947 1948 - Sep lastSun 0:00 0 S -Rule Toronto 1949 only - Nov lastSun 0:00 0 S -Rule Toronto 1950 1973 - Apr lastSun 2:00 1:00 D -Rule Toronto 1950 only - Nov lastSun 2:00 0 S -Rule Toronto 1951 1956 - Sep lastSun 2:00 0 S -# Shanks & Pottenger say Toronto ended DST a week early in 1971, -# namely on 1971-10-24, but Mark Brader wrote (2003-05-31) that this -# is wrong, and that he had confirmed it by checking the 1971-10-30 -# Toronto Star, which said that DST was ending 1971-10-31 as usual. -Rule Toronto 1957 1973 - Oct lastSun 2:00 0 S - -# From Paul Eggert (2003-07-27): -# Willett (1914-03) writes (p. 17) "In the Cities of Fort William, and -# Port Arthur, Ontario, the principle of the Bill has been in -# operation for the past three years, and in the City of Moose Jaw, -# Saskatchewan, for one year." - -# From David Bryan via Tory Tronrud, Director/Curator, -# Thunder Bay Museum (2003-11-12): -# There is some suggestion, however, that, by-law or not, daylight -# savings time was being practiced in Fort William and Port Arthur -# before 1909.... [I]n 1910, the line between the Eastern and Central -# Time Zones was permanently moved about two hundred miles west to -# include the Thunder Bay area.... When Canada adopted daylight -# savings time in 1916, Fort William and Port Arthur, having done so -# already, did not change their clocks.... During the Second World -# War,... [t]he cities agreed to implement DST during the summer -# months for the remainder of the war years. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Toronto -5:17:32 - LMT 1895 - -5:00 Canada E%sT 1919 - -5:00 Toronto E%sT 1942 Feb 9 2:00s - -5:00 Canada E%sT 1946 - -5:00 Toronto E%sT 1974 - -5:00 Canada E%sT -Zone America/Thunder_Bay -5:57:00 - LMT 1895 - -6:00 - CST 1910 - -5:00 - EST 1942 - -5:00 Canada E%sT 1970 - -5:00 Toronto E%sT 1973 - -5:00 - EST 1974 - -5:00 Canada E%sT -Zone America/Nipigon -5:53:04 - LMT 1895 - -5:00 Canada E%sT 1940 Sep 29 - -5:00 1:00 EDT 1942 Feb 9 2:00s - -5:00 Canada E%sT -Zone America/Rainy_River -6:18:16 - LMT 1895 - -6:00 Canada C%sT 1940 Sep 29 - -6:00 1:00 CDT 1942 Feb 9 2:00s - -6:00 Canada C%sT -Zone America/Atikokan -6:06:28 - LMT 1895 - -6:00 Canada C%sT 1940 Sep 29 - -6:00 1:00 CDT 1942 Feb 9 2:00s - -6:00 Canada C%sT 1945 Sep 30 2:00 - -5:00 - EST - - -# Manitoba - -# From Rob Douglas (2006-04-06): -# the old Manitoba Time Act - as amended by Bill 2, assented to -# March 27, 1987 ... said ... -# "between two o'clock Central Standard Time in the morning of -# the first Sunday of April of each year and two o'clock Central -# Standard Time in the morning of the last Sunday of October next -# following, one hour in advance of Central Standard Time."... -# I believe that the English legislation [of the old time act] had -# been assented to (March 22, 1967).... -# Also, as far as I can tell, there was no order-in-council varying -# the time of Daylight Saving Time for 2005 and so the provisions of -# the 1987 version would apply - the changeover was at 2:00 Central -# Standard Time (i.e. not until 3:00 Central Daylight Time). - -# From Paul Eggert (2006-04-10): -# Shanks & Pottenger say Manitoba switched at 02:00 (not 02:00s) -# starting 1966. Since 02:00s is clearly correct for 1967 on, assume -# it was also 02:00s in 1966. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Winn 1916 only - Apr 23 0:00 1:00 D -Rule Winn 1916 only - Sep 17 0:00 0 S -Rule Winn 1918 only - Apr 14 2:00 1:00 D -Rule Winn 1918 only - Oct 27 2:00 0 S -Rule Winn 1937 only - May 16 2:00 1:00 D -Rule Winn 1937 only - Sep 26 2:00 0 S -Rule Winn 1942 only - Feb 9 2:00 1:00 W # War -Rule Winn 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule Winn 1945 only - Sep lastSun 2:00 0 S -Rule Winn 1946 only - May 12 2:00 1:00 D -Rule Winn 1946 only - Oct 13 2:00 0 S -Rule Winn 1947 1949 - Apr lastSun 2:00 1:00 D -Rule Winn 1947 1949 - Sep lastSun 2:00 0 S -Rule Winn 1950 only - May 1 2:00 1:00 D -Rule Winn 1950 only - Sep 30 2:00 0 S -Rule Winn 1951 1960 - Apr lastSun 2:00 1:00 D -Rule Winn 1951 1958 - Sep lastSun 2:00 0 S -Rule Winn 1959 only - Oct lastSun 2:00 0 S -Rule Winn 1960 only - Sep lastSun 2:00 0 S -Rule Winn 1963 only - Apr lastSun 2:00 1:00 D -Rule Winn 1963 only - Sep 22 2:00 0 S -Rule Winn 1966 1986 - Apr lastSun 2:00s 1:00 D -Rule Winn 1966 2005 - Oct lastSun 2:00s 0 S -Rule Winn 1987 2005 - Apr Sun>=1 2:00s 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Winnipeg -6:28:36 - LMT 1887 Jul 16 - -6:00 Winn C%sT 2006 - -6:00 Canada C%sT - - -# Saskatchewan - -# From Mark Brader (2003-07-26): -# The first actual adoption of DST in Canada was at the municipal -# level. As the [Toronto] Star put it (1912-06-07), "While people -# elsewhere have long been talking of legislation to save daylight, -# the city of Moose Jaw [Saskatchewan] has acted on its own hook." -# DST in Moose Jaw began on Saturday, 1912-06-01 (no time mentioned: -# presumably late evening, as below), and would run until "the end of -# the summer". The discrepancy between municipal time and railroad -# time was noted. - -# From Paul Eggert (2003-07-27): -# Willett (1914-03) notes that DST "has been in operation ... in the -# City of Moose Jaw, Saskatchewan, for one year." - -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger say that since 1970 this region has mostly been as Regina. -# Some western towns (e.g. Swift Current) switched from MST/MDT to CST in 1972. -# Other western towns (e.g. Lloydminster) are like Edmonton. -# Matthews and Vincent (1998) write that Denare Beach and Creighton -# are like Winnipeg, in violation of Saskatchewan law. - -# From W. Jones (1992-11-06): -# The. . .below is based on information I got from our law library, the -# provincial archives, and the provincial Community Services department. -# A precise history would require digging through newspaper archives, and -# since you didn't say what you wanted, I didn't bother. -# -# Saskatchewan is split by a time zone meridian (105W) and over the years -# the boundary became pretty ragged as communities near it reevaluated -# their affiliations in one direction or the other. In 1965 a provincial -# referendum favoured legislating common time practices. -# -# On 15 April 1966 the Time Act (c. T-14, Revised Statutes of -# Saskatchewan 1978) was proclaimed, and established that the eastern -# part of Saskatchewan would use CST year round, that districts in -# northwest Saskatchewan would by default follow CST but could opt to -# follow Mountain Time rules (thus 1 hour difference in the winter and -# zero in the summer), and that districts in southwest Saskatchewan would -# by default follow MT but could opt to follow CST. -# -# It took a few years for the dust to settle (I know one story of a town -# on one time zone having its school in another, such that a mom had to -# serve her family lunch in two shifts), but presently it seems that only -# a few towns on the border with Alberta (e.g. Lloydminster) follow MT -# rules any more; all other districts appear to have used CST year round -# since sometime in the 1960s. - -# From Chris Walton (2006-06-26): -# The Saskatchewan time act which was last updated in 1996 is about 30 pages -# long and rather painful to read. -# http://www.qp.gov.sk.ca/documents/English/Statutes/Statutes/T14.pdf - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Regina 1918 only - Apr 14 2:00 1:00 D -Rule Regina 1918 only - Oct 27 2:00 0 S -Rule Regina 1930 1934 - May Sun>=1 0:00 1:00 D -Rule Regina 1930 1934 - Oct Sun>=1 0:00 0 S -Rule Regina 1937 1941 - Apr Sun>=8 0:00 1:00 D -Rule Regina 1937 only - Oct Sun>=8 0:00 0 S -Rule Regina 1938 only - Oct Sun>=1 0:00 0 S -Rule Regina 1939 1941 - Oct Sun>=8 0:00 0 S -Rule Regina 1942 only - Feb 9 2:00 1:00 W # War -Rule Regina 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule Regina 1945 only - Sep lastSun 2:00 0 S -Rule Regina 1946 only - Apr Sun>=8 2:00 1:00 D -Rule Regina 1946 only - Oct Sun>=8 2:00 0 S -Rule Regina 1947 1957 - Apr lastSun 2:00 1:00 D -Rule Regina 1947 1957 - Sep lastSun 2:00 0 S -Rule Regina 1959 only - Apr lastSun 2:00 1:00 D -Rule Regina 1959 only - Oct lastSun 2:00 0 S -# -Rule Swift 1957 only - Apr lastSun 2:00 1:00 D -Rule Swift 1957 only - Oct lastSun 2:00 0 S -Rule Swift 1959 1961 - Apr lastSun 2:00 1:00 D -Rule Swift 1959 only - Oct lastSun 2:00 0 S -Rule Swift 1960 1961 - Sep lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Regina -6:58:36 - LMT 1905 Sep - -7:00 Regina M%sT 1960 Apr lastSun 2:00 - -6:00 - CST -Zone America/Swift_Current -7:11:20 - LMT 1905 Sep - -7:00 Canada M%sT 1946 Apr lastSun 2:00 - -7:00 Regina M%sT 1950 - -7:00 Swift M%sT 1972 Apr lastSun 2:00 - -6:00 - CST - - -# Alberta - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Edm 1918 1919 - Apr Sun>=8 2:00 1:00 D -Rule Edm 1918 only - Oct 27 2:00 0 S -Rule Edm 1919 only - May 27 2:00 0 S -Rule Edm 1920 1923 - Apr lastSun 2:00 1:00 D -Rule Edm 1920 only - Oct lastSun 2:00 0 S -Rule Edm 1921 1923 - Sep lastSun 2:00 0 S -Rule Edm 1942 only - Feb 9 2:00 1:00 W # War -Rule Edm 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule Edm 1945 only - Sep lastSun 2:00 0 S -Rule Edm 1947 only - Apr lastSun 2:00 1:00 D -Rule Edm 1947 only - Sep lastSun 2:00 0 S -Rule Edm 1967 only - Apr lastSun 2:00 1:00 D -Rule Edm 1967 only - Oct lastSun 2:00 0 S -Rule Edm 1969 only - Apr lastSun 2:00 1:00 D -Rule Edm 1969 only - Oct lastSun 2:00 0 S -Rule Edm 1972 1986 - Apr lastSun 2:00 1:00 D -Rule Edm 1972 2006 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Edmonton -7:33:52 - LMT 1906 Sep - -7:00 Edm M%sT 1987 - -7:00 Canada M%sT - - -# British Columbia - -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger write that since 1970 most of this region has -# been like Vancouver. -# Dawson Creek uses MST. Much of east BC is like Edmonton. -# Matthews and Vincent (1998) write that Creston is like Dawson Creek. - -# It seems though that (re: Creston) is not entirely correct: - -# From Chris Walton (2011-12-01): -# There are two areas within the Canadian province of British Columbia -# that do not currently observe daylight saving: -# a) The Creston Valley (includes the town of Creston and surrounding area) -# b) The eastern half of the Peace River Regional District -# (includes the cities of Dawson Creek and Fort St. John) - -# Earlier this year I stumbled across a detailed article about the time -# keeping history of Creston; it was written by Tammy Hardwick who is the -# manager of the Creston & District Museum. The article was written in May 2009. -# http://www.ilovecreston.com/?p=articles&t=spec&ar=260 -# According to the article, Creston has not changed its clocks since June 1918. -# i.e. Creston has been stuck on UT-7 for 93 years. -# Dawson Creek, on the other hand, changed its clocks as recently as April 1972. - -# Unfortunately the exact date for the time change in June 1918 remains -# unknown and will be difficult to ascertain. I e-mailed Tammy a few months -# ago to ask if Sunday June 2 was a reasonable guess. She said it was just -# as plausible as any other date (in June). She also said that after writing -# the article she had discovered another time change in 1916; this is the -# subject of another article which she wrote in October 2010. -# http://www.creston.museum.bc.ca/index.php?module=comments&uop=view_comment&cm+id=56 - -# Here is a summary of the three clock change events in Creston's history: -# 1. 1884 or 1885: adoption of Mountain Standard Time (GMT-7) -# Exact date unknown -# 2. Oct 1916: switch to Pacific Standard Time (GMT-8) -# Exact date in October unknown; Sunday October 1 is a reasonable guess. -# 3. June 1918: switch to Pacific Daylight Time (GMT-7) -# Exact date in June unknown; Sunday June 2 is a reasonable guess. -# note 1: -# On Oct 27/1918 when daylight saving ended in the rest of Canada, -# Creston did not change its clocks. -# note 2: -# During WWII when the Federal Government legislated a mandatory clock change, -# Creston did not oblige. -# note 3: -# There is no guarantee that Creston will remain on Mountain Standard Time -# (UTC-7) forever. -# The subject was debated at least once this year by the town Council. -# http://www.bclocalnews.com/kootenay_rockies/crestonvalleyadvance/news/116760809.html - -# During a period WWII, summer time (Daylight saying) was mandatory in Canada. -# In Creston, that was handled by shifting the area to PST (-8:00) then applying -# summer time to cause the offset to be -7:00, the same as it had been before -# the change. It can be argued that the timezone abbreviation during this -# period should be PDT rather than MST, but that doesn't seem important enough -# (to anyone) to further complicate the rules. - -# The transition dates (and times) are guesses. - -# From Matt Johnson (2015-09-21): -# Fort Nelson, BC, Canada will cancel DST this year. So while previously they -# were aligned with America/Vancouver, they're now aligned with -# America/Dawson_Creek. -# http://www.northernrockies.ca/EN/meta/news/archives/2015/northern-rockies-time-change.html -# -# From Tim Parenti (2015-09-23): -# This requires a new zone for the Northern Rockies Regional Municipality, -# America/Fort_Nelson. The resolution of 2014-12-08 was reached following a -# 2014-11-15 poll with nearly 75% support. Effectively, the municipality has -# been on MST (-0700) like Dawson Creek since it advanced its clocks on -# 2015-03-08. -# -# From Paul Eggert (2015-09-23): -# Shanks says Fort Nelson did not observe DST in 1946, unlike Vancouver. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Vanc 1918 only - Apr 14 2:00 1:00 D -Rule Vanc 1918 only - Oct 27 2:00 0 S -Rule Vanc 1942 only - Feb 9 2:00 1:00 W # War -Rule Vanc 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule Vanc 1945 only - Sep 30 2:00 0 S -Rule Vanc 1946 1986 - Apr lastSun 2:00 1:00 D -Rule Vanc 1946 only - Oct 13 2:00 0 S -Rule Vanc 1947 1961 - Sep lastSun 2:00 0 S -Rule Vanc 1962 2006 - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Vancouver -8:12:28 - LMT 1884 - -8:00 Vanc P%sT 1987 - -8:00 Canada P%sT -Zone America/Dawson_Creek -8:00:56 - LMT 1884 - -8:00 Canada P%sT 1947 - -8:00 Vanc P%sT 1972 Aug 30 2:00 - -7:00 - MST -Zone America/Fort_Nelson -8:10:47 - LMT 1884 - -8:00 Vanc P%sT 1946 - -8:00 - PST 1947 - -8:00 Vanc P%sT 1987 - -8:00 Canada P%sT 2015 Mar 8 2:00 - -7:00 - MST -Zone America/Creston -7:46:04 - LMT 1884 - -7:00 - MST 1916 Oct 1 - -8:00 - PST 1918 Jun 2 - -7:00 - MST - -# Northwest Territories, Nunavut, Yukon - -# From Paul Eggert (2006-03-22): -# Dawson switched to PST in 1973. Inuvik switched to MST in 1979. -# Mathew Englander (1996-10-07) gives the following refs: -# * 1967. Paragraph 28(34)(g) of the Interpretation Act, S.C. 1967-68, -# c. 7 defines Yukon standard time as UTC-9.... -# see Interpretation Act, R.S.C. 1985, c. I-21, s. 35(1). -# [https://www.canlii.org/en/ca/laws/stat/rsc-1985-c-i-21/latest/rsc-1985-c-i-21.html] -# * C.O. 1973/214 switched Yukon to PST on 1973-10-28 00:00. -# * O.I.C. 1980/02 established DST. -# * O.I.C. 1987/056 changed DST to Apr firstSun 2:00 to Oct lastSun 2:00. - -# From Brian Inglis (2015-04-14): -# -# I tried to trace the history of Yukon time and found the following -# regulations, giving the reference title and URL if found, regulation name, -# and relevant quote if available. Each regulation specifically revokes its -# predecessor. The final reference is to the current Interpretation Act -# authorizing and resulting from these regulatory changes. -# -# Only recent regulations were retrievable via Yukon government site search or -# index, and only some via Canadian legal sources. Other sources used include -# articles titled "Standard Time and Time Zones in Canada" from JRASC via ADS -# Abstracts, cited by ADO for 1932 ..., and updated versions from 1958 and -# 1970 quoted below; each article includes current extracts from provincial -# and territorial ST and DST regulations at the end, summaries and details of -# standard times and daylight saving time at many locations across Canada, -# with time zone maps, tables and calculations for Canadian Sunrise, Sunset, -# and LMST; they also cover many countries and global locations, with a chart -# and table showing current Universal Time offsets, and may be useful as -# another source of information for 1970 and earlier. -# -# * Standard Time and Time Zones in Canada; Smith, C.C.; JRASC, Vol. 26, -# pp.49-77; February 1932; SAO/NASA Astrophysics Data System (ADS) -# http://adsabs.harvard.edu/abs/1932JRASC..26...49S from p.75: -# Yukon Interpretation Ordinance -# Yukon standard time is the local mean time at the one hundred and -# thirty-fifth meridian. -# -# * Standard Time and Time Zones in Canada; Smith, C.C.; Thomson, Malcolm M.; -# JRASC, Vol. 52, pp.193-223; October 1958; SAO/NASA Astrophysics Data System -# (ADS) http://adsabs.harvard.edu/abs/1958JRASC..52..193S from pp.220-1: -# Yukon Interpretation Ordinance, 1955, Chap. 16. -# -# (1) Subject to this section, standard time shall be reckoned as nine -# hours behind Greenwich Time and called Yukon Standard Time. -# -# (2) Notwithstanding subsection (1), the Commissioner may make regulations -# varying the manner of reckoning standard time. -# -# * Yukon Territory Commissioner's Order 1966-20 Interpretation Ordinance -# http://? - no online source found -# -# * Standard Time and Time Zones in Canada; Thomson, Malcolm M.; JRASC, -# Vol. 64, pp.129-162; June 1970; SAO/NASA Astrophysics Data System (ADS) -# http://adsabs.harvard.edu/abs/1970JRASC..64..129T from p.156: Yukon -# Territory Commissioner's Order 1967-59 Interpretation Ordinance ... -# -# 1. Commissioner's Order 1966-20 dated at Whitehorse in the Yukon -# Territory on 27th January, 1966, is hereby revoked. -# -# 2. Yukon (East) Standard Time as defined by section 36 of the -# Interpretation Ordinance from and after mid-night on the 28th day of May, -# 1967 shall be reckoned in the same manner as Pacific Standard Time, that -# is to say, eight hours behind Greenwich Time in the area of the Yukon -# Territory lying east of the 138th degree longitude west. -# -# 3. In the remainder of the Territory, lying west of the 138th degree -# longitude west, Yukon (West) Standard Time shall be reckoned as nine -# hours behind Greenwich Time. -# -# * Yukon Standard Time defined as Pacific Standard Time, YCO 1973/214 -# https://www.canlii.org/en/yk/laws/regu/yco-1973-214/latest/yco-1973-214.html -# C.O. 1973/214 INTERPRETATION ACT ... -# -# 1. Effective October 28, 1973 Commissioner's Order 1967/59 is hereby -# revoked. -# -# 2. Yukon Standard Time as defined by section 36 of the Interpretation -# Act from and after midnight on the twenty-eighth day of October, 1973 -# shall be reckoned in the same manner as Pacific Standard Time, that is -# to say eight hours behind Greenwich Time. -# -# * O.I.C. 1980/02 INTERPRETATION ACT -# http://? - no online source found -# -# * Yukon Daylight Saving Time, YOIC 1987/56 -# https://www.canlii.org/en/yk/laws/regu/yoic-1987-56/latest/yoic-1987-56.html -# O.I.C. 1987/056 INTERPRETATION ACT ... -# -# In every year between -# (a) two o'clock in the morning in the first Sunday in April, and -# (b) two o'clock in the morning in the last Sunday in October, -# Standard Time shall be reckoned as seven hours behind Greenwich Time and -# called Yukon Daylight Saving Time. -# ... -# Dated ... 9th day of March, A.D., 1987. -# -# * Yukon Daylight Saving Time 2006, YOIC 2006/127 -# https://www.canlii.org/en/yk/laws/regu/yoic-2006-127/latest/yoic-2006-127.html -# O.I.C. 2006/127 INTERPRETATION ACT ... -# -# 1. In Yukon each year the time for general purposes shall be 7 hours -# behind Greenwich mean time during the period commencing at two o'clock -# in the forenoon on the second Sunday of March and ending at two o'clock -# in the forenoon on the first Sunday of November and shall be called -# Yukon Daylight Saving Time. -# -# 2. Order-in-Council 1987/56 is revoked. -# -# 3. This order comes into force January 1, 2007. -# -# * Interpretation Act, RSY 2002, c 125 -# https://www.canlii.org/en/yk/laws/stat/rsy-2002-c-125/latest/rsy-2002-c-125.html - -# From Rives McDow (1999-09-04): -# Nunavut ... moved ... to incorporate the whole territory into one time zone. -# Nunavut moves to single time zone Oct. 31 -# http://www.nunatsiaq.com/nunavut/nvt90903_13.html -# -# From Antoine Leca (1999-09-06): -# We then need to create a new timezone for the Kitikmeot region of Nunavut -# to differentiate it from the Yellowknife region. - -# From Paul Eggert (1999-09-20): -# Basic Facts: The New Territory -# http://www.nunavut.com/basicfacts/english/basicfacts_1territory.html -# (1999) reports that Pangnirtung operates on eastern time, -# and that Coral Harbour does not observe DST. We don't know when -# Pangnirtung switched to eastern time; we'll guess 1995. - -# From Rives McDow (1999-11-08): -# On October 31, when the rest of Nunavut went to Central time, -# Pangnirtung wobbled. Here is the result of their wobble: -# -# The following businesses and organizations in Pangnirtung use Central Time: -# -# First Air, Power Corp, Nunavut Construction, Health Center, RCMP, -# Eastern Arctic National Parks, A & D Specialist -# -# The following businesses and organizations in Pangnirtung use Eastern Time: -# -# Hamlet office, All other businesses, Both schools, Airport operator -# -# This has made for an interesting situation there, which warranted the news. -# No one there that I spoke with seems concerned, or has plans to -# change the local methods of keeping time, as it evidently does not -# really interfere with any activities or make things difficult locally. -# They plan to celebrate New Year's turn-over twice, one hour apart, -# so it appears that the situation will last at least that long. -# The Nunavut Intergovernmental Affairs hopes that they will "come to -# their senses", but the locals evidently don't see any problem with -# the current state of affairs. - -# From Michaela Rodrigue, writing in the -# Nunatsiaq News (1999-11-19): -# http://www.nunatsiaqonline.ca/archives/nunavut991130/nvt91119_17.html -# Clyde River, Pangnirtung and Sanikiluaq now operate with two time zones, -# central - or Nunavut time - for government offices, and eastern time -# for municipal offices and schools.... Igloolik [was similar but then] -# made the switch to central time on Saturday, Nov. 6. - -# From Paul Eggert (2000-10-02): -# Matthews and Vincent (1998) say the following, but we lack histories -# for these potential new Zones. -# -# The Canadian Forces station at Alert uses Eastern Time while the -# handful of residents at the Eureka weather station [in the Central -# zone] skip daylight savings. Baffin Island, which is crossed by the -# Central, Eastern and Atlantic Time zones only uses Eastern Time. -# Gjoa Haven, Taloyoak and Pelly Bay all use Mountain instead of -# Central Time and Southampton Island [in the Central zone] is not -# required to use daylight savings. - -# From <http://www.nunatsiaqonline.ca/archives/nunavut001130/nvt21110_02.html> -# Nunavut now has two time zones (2000-11-10): -# The Nunavut government would allow its employees in Kugluktuk and -# Cambridge Bay to operate on central time year-round, putting them -# one hour behind the rest of Nunavut for six months during the winter. -# At the end of October the two communities had rebelled against -# Nunavut's unified time zone, refusing to shift to eastern time with -# the rest of the territory for the winter. Cambridge Bay remained on -# central time, while Kugluktuk, even farther west, reverted to -# mountain time, which they had used before the advent of Nunavut's -# unified time zone in 1999. -# -# From Rives McDow (2001-01-20), quoting the Nunavut government: -# The preceding decision came into effect at midnight, Saturday Nov 4, 2000. - -# From Paul Eggert (2000-12-04): -# Let's just keep track of the official times for now. - -# From Rives McDow (2001-03-07): -# The premier of Nunavut has issued a ministerial statement advising -# that effective 2001-04-01, the territory of Nunavut will revert -# back to three time zones (mountain, central, and eastern). Of the -# cities in Nunavut, Coral Harbor is the only one that I know of that -# has said it will not observe dst, staying on EST year round. I'm -# checking for more info, and will get back to you if I come up with -# more. -# [Also see <http://www.nunatsiaq.com/nunavut/nvt10309_06.html> (2001-03-09).] - -# From Gwillim Law (2005-05-21): -# According to ... -# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp -# (from a 1998 Canadian Geographic article), the de facto and de jure time -# for Southampton Island (at the north end of Hudson Bay) is UTC-5 all year -# round. Using Google, it's easy to find other websites that confirm this. -# I wasn't able to find how far back this time regimen goes, but since it -# predates the creation of Nunavut, it probably goes back many years.... -# The Inuktitut name of Coral Harbour is Sallit, but it's rarely used. -# -# From Paul Eggert (2014-10-17): -# For lack of better information, assume that Southampton Island observed -# daylight saving only during wartime. Gwillim Law's email also -# mentioned maps now maintained by National Research Council Canada; -# see above for an up-to-date link. - -# From Chris Walton (2007-03-01): -# ... the community of Resolute (located on Cornwallis Island in -# Nunavut) moved from Central Time to Eastern Time last November. -# Basically the community did not change its clocks at the end of -# daylight saving.... -# http://www.nnsl.com/frames/newspapers/2006-11/nov13_06none.html - -# From Chris Walton (2011-03-21): -# Back in 2007 I initiated the creation of a new "zone file" for Resolute -# Bay. Resolute Bay is a small community located about 900km north of -# the Arctic Circle. The zone file was required because Resolute Bay had -# decided to use UTC-5 instead of UTC-6 for the winter of 2006-2007. -# -# According to new information which I received last week, Resolute Bay -# went back to using UTC-6 in the winter of 2007-2008... -# -# On March 11/2007 most of Canada went onto daylight saving. On March -# 14/2007 I phoned the Resolute Bay hamlet office to do a "time check." I -# talked to somebody that was both knowledgeable and helpful. I was able -# to confirm that Resolute Bay was still operating on UTC-5. It was -# explained to me that Resolute Bay had been on the Eastern Time zone -# (EST) in the winter, and was now back on the Central Time zone (CDT). -# i.e. the time zone had changed twice in the last year but the clocks -# had not moved. The residents had to know which time zone they were in -# so they could follow the correct TV schedule... -# -# On Nov 02/2008 most of Canada went onto standard time. On Nov 03/2008 I -# phoned the Resolute Bay hamlet office...[D]ue to the challenging nature -# of the phone call, I decided to seek out an alternate source of -# information. I found an e-mail address for somebody by the name of -# Stephanie Adams whose job was listed as "Inns North Support Officer for -# Arctic Co-operatives." I was under the impression that Stephanie lived -# and worked in Resolute Bay... -# -# On March 14/2011 I phoned the hamlet office again. I was told that -# Resolute Bay had been using Central Standard Time over the winter of -# 2010-2011 and that the clocks had therefore been moved one hour ahead -# on March 13/2011. The person I talked to was aware that Resolute Bay -# had previously experimented with Eastern Standard Time but he could not -# tell me when the practice had stopped. -# -# On March 17/2011 I searched the Web to find an e-mail address of -# somebody that might be able to tell me exactly when Resolute Bay went -# off Eastern Standard Time. I stumbled on the name "Aziz Kheraj." Aziz -# used to be the mayor of Resolute Bay and he apparently owns half the -# businesses including "South Camp Inn." This website has some info on -# Aziz: -# http://www.uphere.ca/node/493 -# -# I sent Aziz an e-mail asking when Resolute Bay had stopped using -# Eastern Standard Time. -# -# Aziz responded quickly with this: "hi, The time was not changed for the -# 1 year only, the following year, the community went back to the old way -# of "spring ahead-fall behind" currently we are zulu plus 5 hrs and in -# the winter Zulu plus 6 hrs" -# -# This of course conflicted with everything I had ascertained in November 2008. -# -# I sent Aziz a copy of my 2008 e-mail exchange with Stephanie. Aziz -# responded with this: "Hi, Stephanie lives in Winnipeg. I live here, You -# may want to check with the weather office in Resolute Bay or do a -# search on the weather through Env. Canada. web site" -# -# If I had realized the Stephanie did not live in Resolute Bay I would -# never have contacted her. I now believe that all the information I -# obtained in November 2008 should be ignored... -# I apologize for reporting incorrect information in 2008. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NT_YK 1918 only - Apr 14 2:00 1:00 D -Rule NT_YK 1918 only - Oct 27 2:00 0 S -Rule NT_YK 1919 only - May 25 2:00 1:00 D -Rule NT_YK 1919 only - Nov 1 0:00 0 S -Rule NT_YK 1942 only - Feb 9 2:00 1:00 W # War -Rule NT_YK 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule NT_YK 1945 only - Sep 30 2:00 0 S -Rule NT_YK 1965 only - Apr lastSun 0:00 2:00 DD -Rule NT_YK 1965 only - Oct lastSun 2:00 0 S -Rule NT_YK 1980 1986 - Apr lastSun 2:00 1:00 D -Rule NT_YK 1980 2006 - Oct lastSun 2:00 0 S -Rule NT_YK 1987 2006 - Apr Sun>=1 2:00 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# aka Panniqtuuq -Zone America/Pangnirtung 0 - -00 1921 # trading post est. - -4:00 NT_YK A%sT 1995 Apr Sun>=1 2:00 - -5:00 Canada E%sT 1999 Oct 31 2:00 - -6:00 Canada C%sT 2000 Oct 29 2:00 - -5:00 Canada E%sT -# formerly Frobisher Bay -Zone America/Iqaluit 0 - -00 1942 Aug # Frobisher Bay est. - -5:00 NT_YK E%sT 1999 Oct 31 2:00 - -6:00 Canada C%sT 2000 Oct 29 2:00 - -5:00 Canada E%sT -# aka Qausuittuq -Zone America/Resolute 0 - -00 1947 Aug 31 # Resolute founded - -6:00 NT_YK C%sT 2000 Oct 29 2:00 - -5:00 - EST 2001 Apr 1 3:00 - -6:00 Canada C%sT 2006 Oct 29 2:00 - -5:00 - EST 2007 Mar 11 3:00 - -6:00 Canada C%sT -# aka Kangiqiniq -Zone America/Rankin_Inlet 0 - -00 1957 # Rankin Inlet founded - -6:00 NT_YK C%sT 2000 Oct 29 2:00 - -5:00 - EST 2001 Apr 1 3:00 - -6:00 Canada C%sT -# aka Iqaluktuuttiaq -Zone America/Cambridge_Bay 0 - -00 1920 # trading post est.? - -7:00 NT_YK M%sT 1999 Oct 31 2:00 - -6:00 Canada C%sT 2000 Oct 29 2:00 - -5:00 - EST 2000 Nov 5 0:00 - -6:00 - CST 2001 Apr 1 3:00 - -7:00 Canada M%sT -Zone America/Yellowknife 0 - -00 1935 # Yellowknife founded? - -7:00 NT_YK M%sT 1980 - -7:00 Canada M%sT -Zone America/Inuvik 0 - -00 1953 # Inuvik founded - -8:00 NT_YK P%sT 1979 Apr lastSun 2:00 - -7:00 NT_YK M%sT 1980 - -7:00 Canada M%sT -Zone America/Whitehorse -9:00:12 - LMT 1900 Aug 20 - -9:00 NT_YK Y%sT 1967 May 28 0:00 - -8:00 NT_YK P%sT 1980 - -8:00 Canada P%sT -Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 - -9:00 NT_YK Y%sT 1973 Oct 28 0:00 - -8:00 NT_YK P%sT 1980 - -8:00 Canada P%sT - - -############################################################################### - -# Mexico - -# From Paul Eggert (2014-12-07): -# The Investigation and Analysis Service of the -# Mexican Library of Congress (MLoC) has published a -# history of Mexican local time (in Spanish) -# http://www.diputados.gob.mx/bibliot/publica/inveyana/polisoc/horver/index.htm -# -# Here are the discrepancies between Shanks & Pottenger (S&P) and the MLoC. -# (In all cases we go with the MLoC.) -# S&P report that Baja was at -8:00 in 1922/1923. -# S&P say the 1930 transition in Baja was 1930-11-16. -# S&P report no DST during summer 1931. -# S&P report a transition at 1932-03-30 23:00, not 1932-04-01. - -# From Gwillim Law (2001-02-20): -# There are some other discrepancies between the Decrees page and the -# tz database. I think they can best be explained by supposing that -# the researchers who prepared the Decrees page failed to find some of -# the relevant documents. - -# From Alan Perry (1996-02-15): -# A guy from our Mexico subsidiary finally found the Presidential Decree -# outlining the timezone changes in Mexico. -# -# ------------- Begin Forwarded Message ------------- -# -# I finally got my hands on the Official Presidential Decree that sets up the -# rules for the DST changes. The rules are: -# -# 1. The country is divided in 3 timezones: -# - Baja California Norte (the Mexico/BajaNorte TZ) -# - Baja California Sur, Nayarit, Sinaloa and Sonora (the Mexico/BajaSur TZ) -# - The rest of the country (the Mexico/General TZ) -# -# 2. From the first Sunday in April at 2:00 AM to the last Sunday in October -# at 2:00 AM, the times in each zone are as follows: -# BajaNorte: GMT+7 -# BajaSur: GMT+6 -# General: GMT+5 -# -# 3. The rest of the year, the times are as follows: -# BajaNorte: GMT+8 -# BajaSur: GMT+7 -# General: GMT+6 -# -# The Decree was published in Mexico's Official Newspaper on January 4th. -# -# -------------- End Forwarded Message -------------- -# From Paul Eggert (1996-06-12): -# For an English translation of the decree, see -# "Diario Oficial: Time Zone Changeover" (1996-01-04). -# http://mexico-travel.com/extra/timezone_eng.html - -# From Rives McDow (1998-10-08): -# The State of Quintana Roo has reverted back to central STD and DST times -# (i.e. UTC -0600 and -0500 as of 1998-08-02). - -# From Rives McDow (2000-01-10): -# Effective April 4, 1999 at 2:00 AM local time, Sonora changed to the time -# zone 5 hours from the International Date Line, and will not observe daylight -# savings time so as to stay on the same time zone as the southern part of -# Arizona year round. - -# From Jesper Nørgaard, translating -# <http://www.reforma.com/nacional/articulo/064327/> (2001-01-17): -# In Oaxaca, the 55.000 teachers from the Section 22 of the National -# Syndicate of Education Workers, refuse to apply daylight saving each -# year, so that the more than 10,000 schools work at normal hour the -# whole year. - -# From Gwillim Law (2001-01-19): -# <http://www.reforma.com/negocios_y_dinero/articulo/064481/> ... says -# (translated):... -# January 17, 2000 - The Energy Secretary, Ernesto Martens, announced -# that Summer Time will be reduced from seven to five months, starting -# this year.... -# http://www.publico.com.mx/scripts/texto3.asp?action=pagina&pag=21&pos=p&secc=naci&date=01/17/2001 -# [translated], says "summer time will ... take effect on the first Sunday -# in May, and end on the last Sunday of September. - -# From Arthur David Olson (2001-01-25): -# The 2001-01-24 traditional Washington Post contained the page one -# story "Timely Issue Divides Mexicans."... -# http://www.washingtonpost.com/wp-dyn/articles/A37383-2001Jan23.html -# ... Mexico City Mayor López Obrador "...is threatening to keep -# Mexico City and its 20 million residents on a different time than -# the rest of the country..." In particular, López Obrador would abolish -# observation of Daylight Saving Time. - -# Official statute published by the Energy Department -# http://www.conae.gob.mx/ahorro/decretohorver2001.html#decre -# (2001-02-01) shows Baja and Chihauhua as still using US DST rules, -# and Sonora with no DST. This was reported by Jesper Nørgaard (2001-02-03). - -# From Paul Eggert (2001-03-03): -# -# http://www.latimes.com/news/nation/20010303/t000018766.html -# James F. Smith writes in today's LA Times -# * Sonora will continue to observe standard time. -# * Last week Mexico City's mayor Andrés Manuel López Obrador decreed that -# the Federal District will not adopt DST. -# * 4 of 16 district leaders announced they'll ignore the decree. -# * The decree does not affect federal-controlled facilities including -# the airport, banks, hospitals, and schools. -# -# For now we'll assume that the Federal District will bow to federal rules. - -# From Jesper Nørgaard (2001-04-01): -# I found some references to the Mexican application of daylight -# saving, which modifies what I had already sent you, stating earlier -# that a number of northern Mexican states would go on daylight -# saving. The modification reverts this to only cover Baja California -# (Norte), while all other states (except Sonora, who has no daylight -# saving all year) will follow the original decree of president -# Vicente Fox, starting daylight saving May 6, 2001 and ending -# September 30, 2001. -# References: "Diario de Monterrey" <http://www.diariodemonterrey.com/index.asp> -# Palabra <http://palabra.infosel.com/010331/primera/ppri3101.pdf> (2001-03-31) - -# From Reuters (2001-09-04): -# Mexico's Supreme Court on Tuesday declared that daylight savings was -# unconstitutional in Mexico City, creating the possibility the -# capital will be in a different time zone from the rest of the nation -# next year.... The Supreme Court's ruling takes effect at 2:00 -# a.m. (0800 GMT) on Sept. 30, when Mexico is scheduled to revert to -# standard time. "This is so residents of the Federal District are not -# subject to unexpected time changes," a statement from the court said. - -# From Jesper Nørgaard Welen (2002-03-12): -# ... consulting my local grocery store(!) and my coworkers, they all insisted -# that a new decision had been made to reinstate US style DST in Mexico.... -# http://www.conae.gob.mx/ahorro/horaver2001_m1_2002.html (2002-02-20) -# confirms this. Sonora as usual is the only state where DST is not applied. - -# From Steffen Thorsen (2009-12-28): -# -# Steffen Thorsen wrote: -# > Mexico's House of Representatives has approved a proposal for northern -# > Mexico's border cities to share the same daylight saving schedule as -# > the United States. -# Now this has passed both the Congress and the Senate, so starting from -# 2010, some border regions will be the same: -# http://www.signonsandiego.com/news/2009/dec/28/clocks-will-match-both-sides-border/ -# http://www.elmananarey.com/diario/noticia/nacional/noticias/empatan_horario_de_frontera_con_eu/621939 -# (Spanish) -# -# Could not find the new law text, but the proposed law text changes are here: -# http://gaceta.diputados.gob.mx/Gaceta/61/2009/dic/20091210-V.pdf -# (Gaceta Parlamentaria) -# -# There is also a list of the votes here: -# http://gaceta.diputados.gob.mx/Gaceta/61/2009/dic/V2-101209.html -# -# Our page: -# https://www.timeanddate.com/news/time/north-mexico-dst-change.html - -# From Arthur David Olson (2010-01-20): -# The page -# http://dof.gob.mx/nota_detalle.php?codigo=5127480&fecha=06/01/2010 -# includes this text: -# En los municipios fronterizos de Tijuana y Mexicali en Baja California; -# Juárez y Ojinaga en Chihuahua; Acuña y Piedras Negras en Coahuila; -# Anáhuac en Nuevo León; y Nuevo Laredo, Reynosa y Matamoros en -# Tamaulipas, la aplicación de este horario estacional surtirá efecto -# desde las dos horas del segundo domingo de marzo y concluirá a las dos -# horas del primer domingo de noviembre. -# En los municipios fronterizos que se encuentren ubicados en la franja -# fronteriza norte en el territorio comprendido entre la línea -# internacional y la línea paralela ubicada a una distancia de veinte -# kilómetros, así como la Ciudad de Ensenada, Baja California, hacia el -# interior del país, la aplicación de este horario estacional surtirá -# efecto desde las dos horas del segundo domingo de marzo y concluirá a -# las dos horas del primer domingo de noviembre. - -# From Steffen Thorsen (2014-12-08), translated by Gwillim Law: -# The Mexican state of Quintana Roo will likely change to EST in 2015. -# -# http://www.unioncancun.mx/articulo/2014/12/04/medio-ambiente/congreso-aprueba-una-hora-mas-de-sol-en-qroo -# "With this change, the time conflict that has existed between the municipios -# of Quintana Roo and the municipio of Felipe Carrillo Puerto may come to an -# end. The latter declared itself in rebellion 15 years ago when a time change -# was initiated in Mexico, and since then it has refused to change its time -# zone along with the rest of the country." -# -# From Steffen Thorsen (2015-01-14), translated by Gwillim Law: -# http://sipse.com/novedades/confirman-aplicacion-de-nueva-zona-horaria-para-quintana-roo-132331.html -# "...the new time zone will come into effect at two o'clock on the first Sunday -# of February, when we will have to advance the clock one hour from its current -# time..." -# Also, the new zone will not use DST. -# -# From Carlos Raúl Perasso (2015-02-02): -# The decree that modifies the Mexican Hour System Law has finally -# been published at the Diario Oficial de la Federación -# http://www.dof.gob.mx/nota_detalle.php?codigo=5380123&fecha=31/01/2015 -# It establishes 5 zones for Mexico: -# 1- Zona Centro (Central Zone): Corresponds to longitude 90 W, -# includes most of Mexico, excluding what's mentioned below. -# 2- Zona Pacífico (Pacific Zone): Longitude 105 W, includes the -# states of Baja California Sur; Chihuahua; Nayarit (excluding Bahía -# de Banderas which lies in Central Zone); Sinaloa and Sonora. -# 3- Zona Noroeste (Northwest Zone): Longitude 120 W, includes the -# state of Baja California. -# 4- Zona Sureste (Southeast Zone): Longitude 75 W, includes the state -# of Quintana Roo. -# 5- The islands, reefs and keys shall take their timezone from the -# longitude they are located at. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Mexico 1939 only - Feb 5 0:00 1:00 D -Rule Mexico 1939 only - Jun 25 0:00 0 S -Rule Mexico 1940 only - Dec 9 0:00 1:00 D -Rule Mexico 1941 only - Apr 1 0:00 0 S -Rule Mexico 1943 only - Dec 16 0:00 1:00 W # War -Rule Mexico 1944 only - May 1 0:00 0 S -Rule Mexico 1950 only - Feb 12 0:00 1:00 D -Rule Mexico 1950 only - Jul 30 0:00 0 S -Rule Mexico 1996 2000 - Apr Sun>=1 2:00 1:00 D -Rule Mexico 1996 2000 - Oct lastSun 2:00 0 S -Rule Mexico 2001 only - May Sun>=1 2:00 1:00 D -Rule Mexico 2001 only - Sep lastSun 2:00 0 S -Rule Mexico 2002 max - Apr Sun>=1 2:00 1:00 D -Rule Mexico 2002 max - Oct lastSun 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# Quintana Roo; represented by Cancún -Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56 - -6:00 - CST 1981 Dec 23 - -5:00 Mexico E%sT 1998 Aug 2 2:00 - -6:00 Mexico C%sT 2015 Feb 1 2:00 - -5:00 - EST -# Campeche, Yucatán; represented by Mérida -Zone America/Merida -5:58:28 - LMT 1922 Jan 1 0:01:32 - -6:00 - CST 1981 Dec 23 - -5:00 - EST 1982 Dec 2 - -6:00 Mexico C%sT -# Coahuila, Nuevo León, Tamaulipas (near US border) -# This includes the following municipalities: -# in Coahuila: Ocampo, Acuña, Zaragoza, Jiménez, Piedras Negras, Nava, -# Guerrero, Hidalgo. -# in Nuevo León: Anáhuac, Los Aldama. -# in Tamaulipas: Nuevo Laredo, Guerrero, Mier, Miguel Alemán, Camargo, -# Gustavo Díaz Ordaz, Reynosa, Río Bravo, Valle Hermoso, Matamoros. -# See: Inicia mañana Horario de Verano en zona fronteriza, El Universal, -# 2016-03-12 -# http://www.eluniversal.com.mx/articulo/estados/2016/03/12/inicia-manana-horario-de-verano-en-zona-fronteriza -Zone America/Matamoros -6:40:00 - LMT 1921 Dec 31 23:20:00 - -6:00 - CST 1988 - -6:00 US C%sT 1989 - -6:00 Mexico C%sT 2010 - -6:00 US C%sT -# Durango; Coahuila, Nuevo León, Tamaulipas (away from US border) -Zone America/Monterrey -6:41:16 - LMT 1921 Dec 31 23:18:44 - -6:00 - CST 1988 - -6:00 US C%sT 1989 - -6:00 Mexico C%sT -# Central Mexico -Zone America/Mexico_City -6:36:36 - LMT 1922 Jan 1 0:23:24 - -7:00 - MST 1927 Jun 10 23:00 - -6:00 - CST 1930 Nov 15 - -7:00 - MST 1931 May 1 23:00 - -6:00 - CST 1931 Oct - -7:00 - MST 1932 Apr 1 - -6:00 Mexico C%sT 2001 Sep 30 2:00 - -6:00 - CST 2002 Feb 20 - -6:00 Mexico C%sT -# Chihuahua (near US border) -# This includes the municipalities of Janos, Ascensión, Juárez, Guadalupe, -# Práxedis G Guerrero, Coyame del Sotol, Ojinaga, and Manuel Benavides. -# (See the 2016-03-12 El Universal source mentioned above.) -Zone America/Ojinaga -6:57:40 - LMT 1922 Jan 1 0:02:20 - -7:00 - MST 1927 Jun 10 23:00 - -6:00 - CST 1930 Nov 15 - -7:00 - MST 1931 May 1 23:00 - -6:00 - CST 1931 Oct - -7:00 - MST 1932 Apr 1 - -6:00 - CST 1996 - -6:00 Mexico C%sT 1998 - -6:00 - CST 1998 Apr Sun>=1 3:00 - -7:00 Mexico M%sT 2010 - -7:00 US M%sT -# Chihuahua (away from US border) -Zone America/Chihuahua -7:04:20 - LMT 1921 Dec 31 23:55:40 - -7:00 - MST 1927 Jun 10 23:00 - -6:00 - CST 1930 Nov 15 - -7:00 - MST 1931 May 1 23:00 - -6:00 - CST 1931 Oct - -7:00 - MST 1932 Apr 1 - -6:00 - CST 1996 - -6:00 Mexico C%sT 1998 - -6:00 - CST 1998 Apr Sun>=1 3:00 - -7:00 Mexico M%sT -# Sonora -Zone America/Hermosillo -7:23:52 - LMT 1921 Dec 31 23:36:08 - -7:00 - MST 1927 Jun 10 23:00 - -6:00 - CST 1930 Nov 15 - -7:00 - MST 1931 May 1 23:00 - -6:00 - CST 1931 Oct - -7:00 - MST 1932 Apr 1 - -6:00 - CST 1942 Apr 24 - -7:00 - MST 1949 Jan 14 - -8:00 - PST 1970 - -7:00 Mexico M%sT 1999 - -7:00 - MST - -# From Alexander Krivenyshev (2010-04-21): -# According to news, Bahía de Banderas (Mexican state of Nayarit) -# changed time zone UTC-7 to new time zone UTC-6 on April 4, 2010 (to -# share the same time zone as nearby city Puerto Vallarta, Jalisco). -# -# (Spanish) -# Bahía de Banderas homologa su horario al del centro del -# país, a partir de este domingo -# http://www.nayarit.gob.mx/notes.asp?id=20748 -# -# Bahía de Banderas homologa su horario con el del Centro del -# País -# http://www.bahiadebanderas.gob.mx/principal/index.php?option=com_content&view=article&id=261:bahia-de-banderas-homologa-su-horario-con-el-del-centro-del-pais&catid=42:comunicacion-social&Itemid=50 -# -# (English) -# Puerto Vallarta and Bahía de Banderas: One Time Zone -# http://virtualvallarta.com/puertovallarta/puertovallarta/localnews/2009-12-03-Puerto-Vallarta-and-Bahia-de-Banderas-One-Time-Zone.shtml -# http://www.worldtimezone.com/dst_news/dst_news_mexico08.html -# -# "Mexico's Senate approved the amendments to the Mexican Schedule System that -# will allow Bahía de Banderas and Puerto Vallarta to share the same time -# zone ..." -# Baja California Sur, Nayarit, Sinaloa - -# From Arthur David Olson (2010-05-01): -# Use "Bahia_Banderas" to keep the name to fourteen characters. - -# Mazatlán -Zone America/Mazatlan -7:05:40 - LMT 1921 Dec 31 23:54:20 - -7:00 - MST 1927 Jun 10 23:00 - -6:00 - CST 1930 Nov 15 - -7:00 - MST 1931 May 1 23:00 - -6:00 - CST 1931 Oct - -7:00 - MST 1932 Apr 1 - -6:00 - CST 1942 Apr 24 - -7:00 - MST 1949 Jan 14 - -8:00 - PST 1970 - -7:00 Mexico M%sT - -# Bahía de Banderas -Zone America/Bahia_Banderas -7:01:00 - LMT 1921 Dec 31 23:59:00 - -7:00 - MST 1927 Jun 10 23:00 - -6:00 - CST 1930 Nov 15 - -7:00 - MST 1931 May 1 23:00 - -6:00 - CST 1931 Oct - -7:00 - MST 1932 Apr 1 - -6:00 - CST 1942 Apr 24 - -7:00 - MST 1949 Jan 14 - -8:00 - PST 1970 - -7:00 Mexico M%sT 2010 Apr 4 2:00 - -6:00 Mexico C%sT - -# Baja California -Zone America/Tijuana -7:48:04 - LMT 1922 Jan 1 0:11:56 - -7:00 - MST 1924 - -8:00 - PST 1927 Jun 10 23:00 - -7:00 - MST 1930 Nov 15 - -8:00 - PST 1931 Apr 1 - -8:00 1:00 PDT 1931 Sep 30 - -8:00 - PST 1942 Apr 24 - -8:00 1:00 PWT 1945 Aug 14 23:00u - -8:00 1:00 PPT 1945 Nov 12 # Peace - -8:00 - PST 1948 Apr 5 - -8:00 1:00 PDT 1949 Jan 14 - -8:00 - PST 1954 - -8:00 CA P%sT 1961 - -8:00 - PST 1976 - -8:00 US P%sT 1996 - -8:00 Mexico P%sT 2001 - -8:00 US P%sT 2002 Feb 20 - -8:00 Mexico P%sT 2010 - -8:00 US P%sT -# From Paul Eggert (2006-03-22): -# Formerly there was an America/Ensenada zone, which differed from -# America/Tijuana only in that it did not observe DST from 1976 -# through 1995. This was as per Shanks (1999). But Shanks & Pottenger say -# Ensenada did not observe DST from 1948 through 1975. Guy Harris reports -# that the 1987 OAG says "Only Ensenada, Mexicali, San Felipe and -# Tijuana observe DST," which agrees with Shanks & Pottenger but implies that -# DST-observance was a town-by-town matter back then. This concerns -# data after 1970 so most likely there should be at least one Zone -# other than America/Tijuana for Baja, but it's not clear yet what its -# name or contents should be. -# -# From Paul Eggert (2015-10-08): -# Formerly there was an America/Santa_Isabel zone, but this appears to -# have come from a misreading of -# http://dof.gob.mx/nota_detalle.php?codigo=5127480&fecha=06/01/2010 -# It has been moved to the 'backward' file. -# -# -# Revillagigedo Is -# no information - -############################################################################### - -# Anguilla -# Antigua and Barbuda -# See America/Port_of_Spain. - -# Bahamas -# -# For 1899 Milne gives -5:09:29.5; round that. -# -# From Sue Williams (2006-12-07): -# The Bahamas announced about a month ago that they plan to change their DST -# rules to sync with the U.S. starting in 2007.... -# http://www.jonesbahamas.com/?c=45&a=10412 - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Bahamas 1964 1975 - Oct lastSun 2:00 0 S -Rule Bahamas 1964 1975 - Apr lastSun 2:00 1:00 D -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Nassau -5:09:30 - LMT 1912 Mar 2 - -5:00 Bahamas E%sT 1976 - -5:00 US E%sT - -# Barbados - -# For 1899 Milne gives -3:58:29.2; round that. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Barb 1977 only - Jun 12 2:00 1:00 D -Rule Barb 1977 1978 - Oct Sun>=1 2:00 0 S -Rule Barb 1978 1980 - Apr Sun>=15 2:00 1:00 D -Rule Barb 1979 only - Sep 30 2:00 0 S -Rule Barb 1980 only - Sep 25 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Barbados -3:58:29 - LMT 1924 # Bridgetown - -3:58:29 - BMT 1932 # Bridgetown Mean Time - -4:00 Barb A%sT - -# Belize -# Whitman entirely disagrees with Shanks; go with Shanks & Pottenger. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Belize 1918 1942 - Oct Sun>=2 0:00 0:30 -0530 -Rule Belize 1919 1943 - Feb Sun>=9 0:00 0 CST -Rule Belize 1973 only - Dec 5 0:00 1:00 CDT -Rule Belize 1974 only - Feb 9 0:00 0 CST -Rule Belize 1982 only - Dec 18 0:00 1:00 CDT -Rule Belize 1983 only - Feb 12 0:00 0 CST -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Belize -5:52:48 - LMT 1912 Apr - -6:00 Belize %s - -# Bermuda - -# For 1899 Milne gives -4:19:18.3 as the meridian of the clock tower, -# Bermuda dockyard, Ireland I; round that. - -# From Dan Jones, reporting in The Royal Gazette (2006-06-26): - -# Next year, however, clocks in the US will go forward on the second Sunday -# in March, until the first Sunday in November. And, after the Time Zone -# (Seasonal Variation) Bill 2006 was passed in the House of Assembly on -# Friday, the same thing will happen in Bermuda. -# http://www.theroyalgazette.com/apps/pbcs.dll/article?AID=/20060529/NEWS/105290135 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Bermuda -4:19:18 - LMT 1930 Jan 1 2:00 # Hamilton - -4:00 - AST 1974 Apr 28 2:00 - -4:00 Canada A%sT 1976 - -4:00 US A%sT - -# Cayman Is -# See America/Panama. - -# Costa Rica - -# Milne gives -5:36:13.3 as San José mean time; round to nearest. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule CR 1979 1980 - Feb lastSun 0:00 1:00 D -Rule CR 1979 1980 - Jun Sun>=1 0:00 0 S -Rule CR 1991 1992 - Jan Sat>=15 0:00 1:00 D -# IATA SSIM (1991-09) says the following was at 1:00; -# go with Shanks & Pottenger. -Rule CR 1991 only - Jul 1 0:00 0 S -Rule CR 1992 only - Mar 15 0:00 0 S -# There are too many San Josés elsewhere, so we'll use 'Costa Rica'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Costa_Rica -5:36:13 - LMT 1890 # San José - -5:36:13 - SJMT 1921 Jan 15 # San José Mean Time - -6:00 CR C%sT -# Coco -# no information; probably like America/Costa_Rica - -# Cuba - -# From Paul Eggert (2013-02-21): -# Milne gives -5:28:50.45 for the observatory at Havana, -5:29:23.57 -# for the port, and -5:30 for meteorological observations. -# For now, stick with Shanks & Pottenger. - -# From Arthur David Olson (1999-03-29): -# The 1999-03-28 exhibition baseball game held in Havana, Cuba, between -# the Cuban National Team and the Baltimore Orioles was carried live on -# the Orioles Radio Network, including affiliate WTOP in Washington, DC. -# During the game, play-by-play announcer Jim Hunter noted that -# "We'll be losing two hours of sleep...Cuba switched to Daylight Saving -# Time today." (The "two hour" remark referred to losing one hour of -# sleep on 1999-03-28 - when the announcers were in Cuba as it switched -# to DST - and one more hour on 1999-04-04 - when the announcers will have -# returned to Baltimore, which switches on that date.) - -# From Steffen Thorsen (2013-11-11): -# DST start in Cuba in 2004 ... does not follow the same rules as the -# years before. The correct date should be Sunday 2004-03-28 00:00 ... -# https://web.archive.org/web/20040402060750/http://www.granma.cu/espanol/2004/marzo/sab27/reloj.html - -# From Evert van der Veer via Steffen Thorsen (2004-10-28): -# Cuba is not going back to standard time this year. -# From Paul Eggert (2006-03-22): -# http://www.granma.cu/ingles/2004/septiembre/juev30/41medid-i.html -# says that it's due to a problem at the Antonio Guiteras -# thermoelectric plant, and says "This October there will be no return -# to normal hours (after daylight saving time)". -# For now, let's assume that it's a temporary measure. - -# From Carlos A. Carnero Delgado (2005-11-12): -# This year (just like in 2004-2005) there's no change in time zone -# adjustment in Cuba. We will stay in daylight saving time: -# http://www.granma.cu/espanol/2005/noviembre/mier9/horario.html - -# From Jesper Nørgaard Welen (2006-10-21): -# An article in GRANMA INTERNACIONAL claims that Cuba will end -# the 3 years of permanent DST next weekend, see -# http://www.granma.cu/ingles/2006/octubre/lun16/43horario.html -# "On Saturday night, October 28 going into Sunday, October 29, at 01:00, -# watches should be set back one hour - going back to 00:00 hours - returning -# to the normal schedule.... - -# From Paul Eggert (2007-03-02): -# <http://www.granma.cubaweb.cu/english/news/art89.html>, dated yesterday, -# says Cuban clocks will advance at midnight on March 10. -# For lack of better information, assume Cuba will use US rules, -# except that it switches at midnight standard time as usual. -# -# From Steffen Thorsen (2007-10-25): -# Carlos Alberto Fonseca Arauz informed me that Cuba will end DST one week -# earlier - on the last Sunday of October, just like in 2006. -# -# He supplied these references: -# -# http://www.prensalatina.com.mx/article.asp?ID=%7B4CC32C1B-A9F7-42FB-8A07-8631AFC923AF%7D&language=ES -# http://actualidad.terra.es/sociedad/articulo/cuba_llama_ahorrar_energia_cambio_1957044.htm -# -# From Alex Krivenyshev (2007-10-25): -# Here is also article from Granma (Cuba): -# -# Regirá el Horario Normal desde el próximo domingo 28 de octubre -# http://www.granma.cubaweb.cu/2007/10/24/nacional/artic07.html -# -# http://www.worldtimezone.com/dst_news/dst_news_cuba03.html - -# From Arthur David Olson (2008-03-09): -# I'm in Maryland which is now observing United States Eastern Daylight -# Time. At 9:44 local time I used RealPlayer to listen to -# http://media.enet.cu/radioreloj -# a Cuban information station, and heard -# the time announced as "ocho cuarenta y cuatro" ("eight forty-four"), -# indicating that Cuba is still on standard time. - -# From Steffen Thorsen (2008-03-12): -# It seems that Cuba will start DST on Sunday, 2007-03-16... -# It was announced yesterday, according to this source (in Spanish): -# http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm -# -# Some more background information is posted here: -# https://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html -# -# The article also says that Cuba has been observing DST since 1963, -# while Shanks (and tzdata) has 1965 as the first date (except in the -# 1940's). Many other web pages in Cuba also claim that it has been -# observed since 1963, but with the exception of 1970 - an exception -# which is not present in tzdata/Shanks. So there is a chance we need to -# change some historic records as well. -# -# One example: -# http://www.radiohc.cu/espanol/noticias/mar07/11mar/hor.htm - -# From Jesper Nørgaard Welen (2008-03-13): -# The Cuban time change has just been confirmed on the most authoritative -# web site, the Granma. Please check out -# http://www.granma.cubaweb.cu/2008/03/13/nacional/artic10.html -# -# Basically as expected after Steffen Thorsen's information, the change -# will take place midnight between Saturday and Sunday. - -# From Arthur David Olson (2008-03-12): -# Assume Sun>=15 (third Sunday) going forward. - -# From Alexander Krivenyshev (2009-03-04) -# According to the Radio Reloj - Cuba will start Daylight Saving Time on -# midnight between Saturday, March 07, 2009 and Sunday, March 08, 2009- -# not on midnight March 14 / March 15 as previously thought. -# -# http://www.worldtimezone.com/dst_news/dst_news_cuba05.html -# (in Spanish) - -# From Arthur David Olson (2009-03-09) -# I listened over the Internet to -# http://media.enet.cu/readioreloj -# this morning; when it was 10:05 a. m. here in Bethesda, Maryland the -# the time was announced as "diez cinco" - the same time as here, indicating -# that has indeed switched to DST. Assume second Sunday from 2009 forward. - -# From Steffen Thorsen (2011-03-08): -# Granma announced that Cuba is going to start DST on 2011-03-20 00:00:00 -# this year. Nothing about the end date known so far (if that has -# changed at all). -# -# Source: -# http://granma.co.cu/2011/03/08/nacional/artic01.html -# -# Our info: -# https://www.timeanddate.com/news/time/cuba-starts-dst-2011.html -# -# From Steffen Thorsen (2011-10-30) -# Cuba will end DST two weeks later this year. Instead of going back -# tonight, it has been delayed to 2011-11-13 at 01:00. -# -# One source (Spanish) -# http://www.radioangulo.cu/noticias/cuba/17105-cuba-restablecera-el-horario-del-meridiano-de-greenwich.html -# -# Our page: -# https://www.timeanddate.com/news/time/cuba-time-changes-2011.html -# -# From Steffen Thorsen (2012-03-01) -# According to Radio Reloj, Cuba will start DST on Midnight between March -# 31 and April 1. -# -# Radio Reloj has the following info (Spanish): -# http://www.radioreloj.cu/index.php/noticias-radio-reloj/71-miscelaneas/7529-cuba-aplicara-el-horario-de-verano-desde-el-1-de-abril -# -# Our info on it: -# https://www.timeanddate.com/news/time/cuba-starts-dst-2012.html - -# From Steffen Thorsen (2012-11-03): -# Radio Reloj and many other sources report that Cuba is changing back -# to standard time on 2012-11-04: -# http://www.radioreloj.cu/index.php/noticias-radio-reloj/36-nacionales/9961-regira-horario-normal-en-cuba-desde-el-domingo-cuatro-de-noviembre -# From Paul Eggert (2012-11-03): -# For now, assume the future rule is first Sunday in November. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Cuba 1928 only - Jun 10 0:00 1:00 D -Rule Cuba 1928 only - Oct 10 0:00 0 S -Rule Cuba 1940 1942 - Jun Sun>=1 0:00 1:00 D -Rule Cuba 1940 1942 - Sep Sun>=1 0:00 0 S -Rule Cuba 1945 1946 - Jun Sun>=1 0:00 1:00 D -Rule Cuba 1945 1946 - Sep Sun>=1 0:00 0 S -Rule Cuba 1965 only - Jun 1 0:00 1:00 D -Rule Cuba 1965 only - Sep 30 0:00 0 S -Rule Cuba 1966 only - May 29 0:00 1:00 D -Rule Cuba 1966 only - Oct 2 0:00 0 S -Rule Cuba 1967 only - Apr 8 0:00 1:00 D -Rule Cuba 1967 1968 - Sep Sun>=8 0:00 0 S -Rule Cuba 1968 only - Apr 14 0:00 1:00 D -Rule Cuba 1969 1977 - Apr lastSun 0:00 1:00 D -Rule Cuba 1969 1971 - Oct lastSun 0:00 0 S -Rule Cuba 1972 1974 - Oct 8 0:00 0 S -Rule Cuba 1975 1977 - Oct lastSun 0:00 0 S -Rule Cuba 1978 only - May 7 0:00 1:00 D -Rule Cuba 1978 1990 - Oct Sun>=8 0:00 0 S -Rule Cuba 1979 1980 - Mar Sun>=15 0:00 1:00 D -Rule Cuba 1981 1985 - May Sun>=5 0:00 1:00 D -Rule Cuba 1986 1989 - Mar Sun>=14 0:00 1:00 D -Rule Cuba 1990 1997 - Apr Sun>=1 0:00 1:00 D -Rule Cuba 1991 1995 - Oct Sun>=8 0:00s 0 S -Rule Cuba 1996 only - Oct 6 0:00s 0 S -Rule Cuba 1997 only - Oct 12 0:00s 0 S -Rule Cuba 1998 1999 - Mar lastSun 0:00s 1:00 D -Rule Cuba 1998 2003 - Oct lastSun 0:00s 0 S -Rule Cuba 2000 2003 - Apr Sun>=1 0:00s 1:00 D -Rule Cuba 2004 only - Mar lastSun 0:00s 1:00 D -Rule Cuba 2006 2010 - Oct lastSun 0:00s 0 S -Rule Cuba 2007 only - Mar Sun>=8 0:00s 1:00 D -Rule Cuba 2008 only - Mar Sun>=15 0:00s 1:00 D -Rule Cuba 2009 2010 - Mar Sun>=8 0:00s 1:00 D -Rule Cuba 2011 only - Mar Sun>=15 0:00s 1:00 D -Rule Cuba 2011 only - Nov 13 0:00s 0 S -Rule Cuba 2012 only - Apr 1 0:00s 1:00 D -Rule Cuba 2012 max - Nov Sun>=1 0:00s 0 S -Rule Cuba 2013 max - Mar Sun>=8 0:00s 1:00 D - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Havana -5:29:28 - LMT 1890 - -5:29:36 - HMT 1925 Jul 19 12:00 # Havana MT - -5:00 Cuba C%sT - -# Dominica -# See America/Port_of_Spain. - -# Dominican Republic - -# From Steffen Thorsen (2000-10-30): -# Enrique Morales reported to me that the Dominican Republic has changed the -# time zone to Eastern Standard Time as of Sunday 29 at 2 am.... -# http://www.listin.com.do/antes/261000/republica/princi.html - -# From Paul Eggert (2000-12-04): -# That URL (2000-10-26, in Spanish) says they planned to use US-style DST. - -# From Rives McDow (2000-12-01): -# Dominican Republic changed its mind and presidential decree on Tuesday, -# November 28, 2000, with a new decree. On Sunday, December 3 at 1:00 AM the -# Dominican Republic will be reverting to 8 hours from the International Date -# Line, and will not be using DST in the foreseeable future. The reason they -# decided to use DST was to be in synch with Puerto Rico, who was also going -# to implement DST. When Puerto Rico didn't implement DST, the president -# decided to revert. - - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule DR 1966 only - Oct 30 0:00 1:00 EDT -Rule DR 1967 only - Feb 28 0:00 0 EST -Rule DR 1969 1973 - Oct lastSun 0:00 0:30 -0430 -Rule DR 1970 only - Feb 21 0:00 0 EST -Rule DR 1971 only - Jan 20 0:00 0 EST -Rule DR 1972 1974 - Jan 21 0:00 0 EST -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Santo_Domingo -4:39:36 - LMT 1890 - -4:40 - SDMT 1933 Apr 1 12:00 # S. Dom. MT - -5:00 DR %s 1974 Oct 27 - -4:00 - AST 2000 Oct 29 2:00 - -5:00 US E%sT 2000 Dec 3 1:00 - -4:00 - AST - -# El Salvador - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Salv 1987 1988 - May Sun>=1 0:00 1:00 D -Rule Salv 1987 1988 - Sep lastSun 0:00 0 S -# There are too many San Salvadors elsewhere, so use America/El_Salvador -# instead of America/San_Salvador. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/El_Salvador -5:56:48 - LMT 1921 # San Salvador - -6:00 Salv C%sT - -# Grenada -# Guadeloupe -# St Barthélemy -# St Martin (French part) -# See America/Port_of_Spain. - -# Guatemala -# -# From Gwillim Law (2006-04-22), after a heads-up from Oscar van Vlijmen: -# Diario Co Latino, at -# <http://www.diariocolatino.com/internacionales/detalles.asp?NewsID=8079>, -# says in an article dated 2006-04-19 that the Guatemalan government had -# decided on that date to advance official time by 60 minutes, to lessen the -# impact of the elevated cost of oil.... Daylight saving time will last from -# 2006-04-29 24:00 (Guatemalan standard time) to 2006-09-30 (time unspecified). -# From Paul Eggert (2006-06-22): -# The Ministry of Energy and Mines, press release CP-15/2006 -# (2006-04-19), says DST ends at 24:00. See -# http://www.sieca.org.gt/Sitio_publico/Energeticos/Doc/Medidas/Cambio_Horario_Nac_190406.pdf - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Guat 1973 only - Nov 25 0:00 1:00 D -Rule Guat 1974 only - Feb 24 0:00 0 S -Rule Guat 1983 only - May 21 0:00 1:00 D -Rule Guat 1983 only - Sep 22 0:00 0 S -Rule Guat 1991 only - Mar 23 0:00 1:00 D -Rule Guat 1991 only - Sep 7 0:00 0 S -Rule Guat 2006 only - Apr 30 0:00 1:00 D -Rule Guat 2006 only - Oct 1 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Guatemala -6:02:04 - LMT 1918 Oct 5 - -6:00 Guat C%sT - -# Haiti -# From Gwillim Law (2005-04-15): -# Risto O. Nykänen wrote me that Haiti is now on DST. -# I searched for confirmation, and I found a press release -# on the Web page of the Haitian Consulate in Chicago (2005-03-31), -# <http://www.haitianconsulate.org/time.doc>. Translated from French, it says: -# -# "The Prime Minister's Communication Office notifies the public in general -# and the press in particular that, following a decision of the Interior -# Ministry and the Territorial Collectivities [I suppose that means the -# provinces], Haiti will move to Eastern Daylight Time in the night from next -# Saturday the 2nd to Sunday the 3rd. -# -# "Consequently, the Prime Minister's Communication Office wishes to inform -# the population that the country's clocks will be set forward one hour -# starting at midnight. This provision will hold until the last Saturday in -# October 2005. -# -# "Port-au-Prince, March 31, 2005" -# -# From Steffen Thorsen (2006-04-04): -# I have been informed by users that Haiti observes DST this year like -# last year, so the current "only" rule for 2005 might be changed to a -# "max" rule or to last until 2006. (Who knows if they will observe DST -# next year or if they will extend their DST like US/Canada next year). -# -# I have found this article about it (in French): -# http://www.haitipressnetwork.com/news.cfm?articleID=7612 -# -# The reason seems to be an energy crisis. - -# From Stephen Colebourne (2007-02-22): -# Some IATA info: Haiti won't be having DST in 2007. - -# From Steffen Thorsen (2012-03-11): -# According to several news sources, Haiti will observe DST this year, -# apparently using the same start and end date as USA/Canada. -# So this means they have already changed their time. -# -# http://www.alterpresse.org/spip.php?article12510 -# http://radiovision2000haiti.net/home/?p=13253 -# -# From Arthur David Olson (2012-03-11): -# The alterpresse.org source seems to show a US-style leap from 2:00 a.m. to -# 3:00 a.m. rather than the traditional Haitian jump at midnight. -# Assume a US-style fall back as well. - -# From Steffen Thorsen (2013-03-10): -# It appears that Haiti is observing DST this year as well, same rules -# as US/Canada. They did it last year as well, and it looks like they -# are going to observe DST every year now... -# -# http://radiovision2000haiti.net/public/haiti-avis-changement-dheure-dimanche/ -# http://www.canalplushaiti.net/?p=6714 - -# From Steffen Thorsen (2016-03-12): -# Jean Antoine, editor of www.haiti-reference.com informed us that Haiti -# are not going on DST this year. Several other resources confirm this: ... -# https://www.radiotelevisioncaraibes.com/presse/heure_d_t_pas_de_changement_d_heure_pr_vu_pour_cet_ann_e.html -# https://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/ -# http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/ - -# From Steffen Thorsen (2017-03-12): -# We have received 4 mails from different people telling that Haiti -# has started DST again today, and this source seems to confirm that, -# I have not been able to find a more authoritative source: -# https://www.haitilibre.com/en/news-20319-haiti-notices-time-change-in-haiti.html - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Haiti 1983 only - May 8 0:00 1:00 D -Rule Haiti 1984 1987 - Apr lastSun 0:00 1:00 D -Rule Haiti 1983 1987 - Oct lastSun 0:00 0 S -# Shanks & Pottenger say AT is 2:00, but IATA SSIM (1991/1997) says 1:00s. -# Go with IATA. -Rule Haiti 1988 1997 - Apr Sun>=1 1:00s 1:00 D -Rule Haiti 1988 1997 - Oct lastSun 1:00s 0 S -Rule Haiti 2005 2006 - Apr Sun>=1 0:00 1:00 D -Rule Haiti 2005 2006 - Oct lastSun 0:00 0 S -Rule Haiti 2012 2015 - Mar Sun>=8 2:00 1:00 D -Rule Haiti 2012 2015 - Nov Sun>=1 2:00 0 S -Rule Haiti 2017 max - Mar Sun>=8 2:00 1:00 D -Rule Haiti 2017 max - Nov Sun>=1 2:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Port-au-Prince -4:49:20 - LMT 1890 - -4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT - -5:00 Haiti E%sT - -# Honduras -# Shanks & Pottenger say 1921 Jan 1; go with Whitman's more precise Apr 1. - -# From Paul Eggert (2006-05-05): -# worldtimezone.com reports a 2006-05-02 Spanish-language AP article -# saying Honduras will start using DST midnight Saturday, effective 4 -# months until September. La Tribuna reported today -# <http://www.latribuna.hn/99299.html> that Manuel Zelaya, the president -# of Honduras, refused to back down on this. - -# From Jesper Nørgaard Welen (2006-08-08): -# It seems that Honduras has returned from DST to standard time this Monday at -# 00:00 hours (prolonging Sunday to 25 hours duration). -# http://www.worldtimezone.com/dst_news/dst_news_honduras04.html - -# From Paul Eggert (2006-08-08): -# Also see Diario El Heraldo, The country returns to standard time (2006-08-08). -# http://www.elheraldo.hn/nota.php?nid=54941&sec=12 -# It mentions executive decree 18-2006. - -# From Steffen Thorsen (2006-08-17): -# Honduras will observe DST from 2007 to 2009, exact dates are not -# published, I have located this authoritative source: -# http://www.presidencia.gob.hn/noticia.aspx?nId=47 - -# From Steffen Thorsen (2007-03-30): -# http://www.laprensahn.com/pais_nota.php?id04962=7386 -# So it seems that Honduras will not enter DST this year.... - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Hond 1987 1988 - May Sun>=1 0:00 1:00 D -Rule Hond 1987 1988 - Sep lastSun 0:00 0 S -Rule Hond 2006 only - May Sun>=1 0:00 1:00 D -Rule Hond 2006 only - Aug Mon>=1 0:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Tegucigalpa -5:48:52 - LMT 1921 Apr - -6:00 Hond C%sT -# -# Great Swan I ceded by US to Honduras in 1972 - -# Jamaica -# Shanks & Pottenger give -5:07:12, but Milne records -5:07:10.41 from an -# unspecified official document, and says "This time is used throughout the -# island". Go with Milne. Round to the nearest second as required by zic. -# -# Shanks & Pottenger give April 28 for the 1974 spring-forward transition, but -# Lance Neita writes that Prime Minister Michael Manley decreed it January 5. -# Assume Neita meant Jan 6 02:00, the same as the US. Neita also writes that -# Manley's supporters associated this act with Manley's nickname "Joshua" -# (recall that in the Bible the sun stood still at Joshua's request), -# and with the Rod of Correction which Manley said he had received from -# Haile Selassie, Emperor of Ethiopia. See: -# Neita L. The politician in all of us. Jamaica Observer 2014-09-20 -# http://www.jamaicaobserver.com/columns/The-politician-in-all-of-us_17573647 -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Jamaica -5:07:10 - LMT 1890 # Kingston - -5:07:10 - KMT 1912 Feb # Kingston Mean Time - -5:00 - EST 1974 - -5:00 US E%sT 1984 - -5:00 - EST - -# Martinique -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Martinique -4:04:20 - LMT 1890 # Fort-de-France - -4:04:20 - FFMT 1911 May # Fort-de-France MT - -4:00 - AST 1980 Apr 6 - -4:00 1:00 ADT 1980 Sep 28 - -4:00 - AST - -# Montserrat -# See America/Port_of_Spain. - -# Nicaragua -# -# This uses Shanks & Pottenger for times before 2005. -# -# From Steffen Thorsen (2005-04-12): -# I've got reports from 8 different people that Nicaragua just started -# DST on Sunday 2005-04-10, in order to save energy because of -# expensive petroleum. The exact end date for DST is not yet -# announced, only "September" but some sites also say "mid-September". -# Some background information is available on the President's official site: -# http://www.presidencia.gob.ni/Presidencia/Files_index/Secretaria/Notas%20de%20Prensa/Presidente/2005/ABRIL/Gobierno-de-nicaragua-adelanta-hora-oficial-06abril.htm -# The Decree, no 23-2005 is available here: -# http://www.presidencia.gob.ni/buscador_gaceta/BD/DECRETOS/2005/Decreto%2023-2005%20Se%20adelanta%20en%20una%20hora%20en%20todo%20el%20territorio%20nacional%20apartir%20de%20las%2024horas%20del%2009%20de%20Abril.pdf -# -# From Paul Eggert (2005-05-01): -# The decree doesn't say anything about daylight saving, but for now let's -# assume that it is daylight saving.... -# -# From Gwillim Law (2005-04-21): -# The Associated Press story on the time change, which can be found at -# http://www.lapalmainteractivo.com/guias/content/gen/ap/America_Latina/AMC_GEN_NICARAGUA_HORA.html -# and elsewhere, says (fifth paragraph, translated from Spanish): "The last -# time that a change of clocks was applied to save energy was in the year 2000 -# during the Arnoldo Alemán administration."... -# The northamerica file says that Nicaragua has been on UTC-6 continuously -# since December 1998. I wasn't able to find any details of Nicaraguan time -# changes in 2000. Perhaps a note could be added to the northamerica file, to -# the effect that we have indirect evidence that DST was observed in 2000. -# -# From Jesper Nørgaard Welen (2005-11-02): -# Nicaragua left DST the 2005-10-02 at 00:00 (local time). -# http://www.presidencia.gob.ni/presidencia/files_index/secretaria/comunicados/2005/septiembre/26septiembre-cambio-hora.htm -# (2005-09-26) -# -# From Jesper Nørgaard Welen (2006-05-05): -# http://www.elnuevodiario.com.ni/2006/05/01/nacionales/18410 -# (my informal translation) -# By order of the president of the republic, Enrique Bolaños, Nicaragua -# advanced by sixty minutes their official time, yesterday at 2 in the -# morning, and will stay that way until 30th of September. -# -# From Jesper Nørgaard Welen (2006-09-30): -# http://www.presidencia.gob.ni/buscador_gaceta/BD/DECRETOS/2006/D-063-2006P-PRN-Cambio-Hora.pdf -# My informal translation runs: -# The natural sun time is restored in all the national territory, in that the -# time is returned one hour at 01:00 am of October 1 of 2006. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Nic 1979 1980 - Mar Sun>=16 0:00 1:00 D -Rule Nic 1979 1980 - Jun Mon>=23 0:00 0 S -Rule Nic 2005 only - Apr 10 0:00 1:00 D -Rule Nic 2005 only - Oct Sun>=1 0:00 0 S -Rule Nic 2006 only - Apr 30 2:00 1:00 D -Rule Nic 2006 only - Oct Sun>=1 1:00 0 S -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Managua -5:45:08 - LMT 1890 - -5:45:12 - MMT 1934 Jun 23 # Managua Mean Time? - -6:00 - CST 1973 May - -5:00 - EST 1975 Feb 16 - -6:00 Nic C%sT 1992 Jan 1 4:00 - -5:00 - EST 1992 Sep 24 - -6:00 - CST 1993 - -5:00 - EST 1997 - -6:00 Nic C%sT - -# Panama -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Panama -5:18:08 - LMT 1890 - -5:19:36 - CMT 1908 Apr 22 # Colón Mean Time - -5:00 - EST -Link America/Panama America/Cayman - -# Puerto Rico -# There are too many San Juans elsewhere, so we'll use 'Puerto_Rico'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Puerto_Rico -4:24:25 - LMT 1899 Mar 28 12:00 # San Juan - -4:00 - AST 1942 May 3 - -4:00 US A%sT 1946 - -4:00 - AST - -# St Kitts-Nevis -# St Lucia -# See America/Port_of_Spain. - -# St Pierre and Miquelon -# There are too many St Pierres elsewhere, so we'll use 'Miquelon'. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre - -4:00 - AST 1980 May - -3:00 - -03 1987 - -3:00 Canada -03/-02 - -# St Vincent and the Grenadines -# See America/Port_of_Spain. - -# Turks and Caicos -# -# From Chris Dunn in -# https://bugs.debian.org/415007 -# (2007-03-15): In the Turks & Caicos Islands (America/Grand_Turk) the -# daylight saving dates for time changes have been adjusted to match -# the recent U.S. change of dates. -# -# From Brian Inglis (2007-04-28): -# http://www.turksandcaicos.tc/calendar/index.htm [2007-04-26] -# there is an entry for Nov 4 "Daylight Savings Time Ends 2007" and three -# rows before that there is an out of date entry for Oct: -# "Eastern Standard Times Begins 2007 -# Clocks are set back one hour at 2:00 a.m. local Daylight Saving Time" -# indicating that the normal ET rules are followed. -# -# From Paul Eggert (2014-08-19): -# The 2014-08-13 Cabinet meeting decided to stay on UT -04 year-round. See: -# http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm -# Model this as a switch from EST/EDT to AST ... -# From Chris Walton (2014-11-04): -# ... the TCI government appears to have delayed the switch to -# "permanent daylight saving time" by one year.... -# http://tcweeklynews.com/time-change-to-go-ahead-this-november-p5437-127.htm -# -# From the Turks & Caicos Cabinet (2017-07-20), heads-up from Steffen Thorsen: -# ... agreed to the reintroduction in TCI of Daylight Saving Time (DST) -# during the summer months and Standard Time, also known as Local -# Time, during the winter months with effect from April 2018 ... -# https://www.gov.uk/government/news/turks-and-caicos-post-cabinet-meeting-statement--3 -# -# From Paul Eggert (2017-08-26): -# The date of effect of the spring 2018 change appears to be March 11, -# which makes more sense. See: Hamilton D. Time change back -# by March 2018 for TCI. Magnetic Media. 2017-08-25. -# http://magneticmediatv.com/2017/08/time-change-back-by-march-2018-for-tci/ -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Grand_Turk -4:44:32 - LMT 1890 - -5:07:10 - KMT 1912 Feb # Kingston Mean Time - -5:00 - EST 1979 - -5:00 US E%sT 2015 Nov Sun>=1 2:00 - -4:00 - AST 2018 Mar 11 3:00 - -5:00 US E%sT - -# British Virgin Is -# Virgin Is -# See America/Port_of_Spain. - - -# Local Variables: -# coding: utf-8 -# End: diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/pacificnew b/src/test/jdk/sun/util/calendar/zi/tzdata/pacificnew deleted file mode 100644 index 020b599bf00..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/pacificnew +++ /dev/null @@ -1,52 +0,0 @@ -# -# 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. -# -# tzdb data for proposed US election time (this file is obsolete) - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# From Arthur David Olson (1989-04-05): -# On 1989-04-05, the U. S. House of Representatives passed (238-154) a bill -# establishing "Pacific Presidential Election Time"; it was not acted on -# by the Senate or signed into law by the President. -# You might want to change the "PE" (Presidential Election) below to -# "Q" (Quadrennial) to maintain three-character zone abbreviations. -# If you're really conservative, you might want to change it to "D". -# Avoid "L" (Leap Year), which won't be true in 2100. - -# If Presidential Election Time is ever established, replace "XXXX" below -# with the year the law takes effect and uncomment the "##" lines. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -## Rule Twilite XXXX max - Apr Sun>=1 2:00 1:00 D -## Rule Twilite XXXX max uspres Oct lastSun 2:00 1:00 PE -## Rule Twilite XXXX max uspres Nov Sun>=7 2:00 0 S -## Rule Twilite XXXX max nonpres Oct lastSun 2:00 0 S - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -## Zone America/Los_Angeles-PET -8:00 US P%sT XXXX -## -8:00 Twilite P%sT - -# For now... -Link America/Los_Angeles US/Pacific-New ## diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/solar87 b/src/test/jdk/sun/util/calendar/zi/tzdata/solar87 deleted file mode 100644 index 0512ca410c1..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/solar87 +++ /dev/null @@ -1,413 +0,0 @@ -# -# 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. -# -# <pre> -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# So much for footnotes about Saudi Arabia. -# Apparent noon times below are for Riyadh; your mileage will vary. -# Times were computed using formulas in the U.S. Naval Observatory's -# Almanac for Computers 1987; the formulas "will give EqT to an accuracy of -# [plus or minus two] seconds during the current year." -# -# Rounding to the nearest five seconds results in fewer than -# 256 different "time types"--a limit that's faced because time types are -# stored on disk as unsigned chars. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule sol87 1987 only - Jan 1 12:03:20s -0:03:20 - -Rule sol87 1987 only - Jan 2 12:03:50s -0:03:50 - -Rule sol87 1987 only - Jan 3 12:04:15s -0:04:15 - -Rule sol87 1987 only - Jan 4 12:04:45s -0:04:45 - -Rule sol87 1987 only - Jan 5 12:05:10s -0:05:10 - -Rule sol87 1987 only - Jan 6 12:05:40s -0:05:40 - -Rule sol87 1987 only - Jan 7 12:06:05s -0:06:05 - -Rule sol87 1987 only - Jan 8 12:06:30s -0:06:30 - -Rule sol87 1987 only - Jan 9 12:06:55s -0:06:55 - -Rule sol87 1987 only - Jan 10 12:07:20s -0:07:20 - -Rule sol87 1987 only - Jan 11 12:07:45s -0:07:45 - -Rule sol87 1987 only - Jan 12 12:08:10s -0:08:10 - -Rule sol87 1987 only - Jan 13 12:08:30s -0:08:30 - -Rule sol87 1987 only - Jan 14 12:08:55s -0:08:55 - -Rule sol87 1987 only - Jan 15 12:09:15s -0:09:15 - -Rule sol87 1987 only - Jan 16 12:09:35s -0:09:35 - -Rule sol87 1987 only - Jan 17 12:09:55s -0:09:55 - -Rule sol87 1987 only - Jan 18 12:10:15s -0:10:15 - -Rule sol87 1987 only - Jan 19 12:10:35s -0:10:35 - -Rule sol87 1987 only - Jan 20 12:10:55s -0:10:55 - -Rule sol87 1987 only - Jan 21 12:11:10s -0:11:10 - -Rule sol87 1987 only - Jan 22 12:11:30s -0:11:30 - -Rule sol87 1987 only - Jan 23 12:11:45s -0:11:45 - -Rule sol87 1987 only - Jan 24 12:12:00s -0:12:00 - -Rule sol87 1987 only - Jan 25 12:12:15s -0:12:15 - -Rule sol87 1987 only - Jan 26 12:12:30s -0:12:30 - -Rule sol87 1987 only - Jan 27 12:12:40s -0:12:40 - -Rule sol87 1987 only - Jan 28 12:12:55s -0:12:55 - -Rule sol87 1987 only - Jan 29 12:13:05s -0:13:05 - -Rule sol87 1987 only - Jan 30 12:13:15s -0:13:15 - -Rule sol87 1987 only - Jan 31 12:13:25s -0:13:25 - -Rule sol87 1987 only - Feb 1 12:13:35s -0:13:35 - -Rule sol87 1987 only - Feb 2 12:13:40s -0:13:40 - -Rule sol87 1987 only - Feb 3 12:13:50s -0:13:50 - -Rule sol87 1987 only - Feb 4 12:13:55s -0:13:55 - -Rule sol87 1987 only - Feb 5 12:14:00s -0:14:00 - -Rule sol87 1987 only - Feb 6 12:14:05s -0:14:05 - -Rule sol87 1987 only - Feb 7 12:14:10s -0:14:10 - -Rule sol87 1987 only - Feb 8 12:14:10s -0:14:10 - -Rule sol87 1987 only - Feb 9 12:14:15s -0:14:15 - -Rule sol87 1987 only - Feb 10 12:14:15s -0:14:15 - -Rule sol87 1987 only - Feb 11 12:14:15s -0:14:15 - -Rule sol87 1987 only - Feb 12 12:14:15s -0:14:15 - -Rule sol87 1987 only - Feb 13 12:14:15s -0:14:15 - -Rule sol87 1987 only - Feb 14 12:14:15s -0:14:15 - -Rule sol87 1987 only - Feb 15 12:14:10s -0:14:10 - -Rule sol87 1987 only - Feb 16 12:14:10s -0:14:10 - -Rule sol87 1987 only - Feb 17 12:14:05s -0:14:05 - -Rule sol87 1987 only - Feb 18 12:14:00s -0:14:00 - -Rule sol87 1987 only - Feb 19 12:13:55s -0:13:55 - -Rule sol87 1987 only - Feb 20 12:13:50s -0:13:50 - -Rule sol87 1987 only - Feb 21 12:13:45s -0:13:45 - -Rule sol87 1987 only - Feb 22 12:13:35s -0:13:35 - -Rule sol87 1987 only - Feb 23 12:13:30s -0:13:30 - -Rule sol87 1987 only - Feb 24 12:13:20s -0:13:20 - -Rule sol87 1987 only - Feb 25 12:13:10s -0:13:10 - -Rule sol87 1987 only - Feb 26 12:13:00s -0:13:00 - -Rule sol87 1987 only - Feb 27 12:12:50s -0:12:50 - -Rule sol87 1987 only - Feb 28 12:12:40s -0:12:40 - -Rule sol87 1987 only - Mar 1 12:12:30s -0:12:30 - -Rule sol87 1987 only - Mar 2 12:12:20s -0:12:20 - -Rule sol87 1987 only - Mar 3 12:12:05s -0:12:05 - -Rule sol87 1987 only - Mar 4 12:11:55s -0:11:55 - -Rule sol87 1987 only - Mar 5 12:11:40s -0:11:40 - -Rule sol87 1987 only - Mar 6 12:11:25s -0:11:25 - -Rule sol87 1987 only - Mar 7 12:11:15s -0:11:15 - -Rule sol87 1987 only - Mar 8 12:11:00s -0:11:00 - -Rule sol87 1987 only - Mar 9 12:10:45s -0:10:45 - -Rule sol87 1987 only - Mar 10 12:10:30s -0:10:30 - -Rule sol87 1987 only - Mar 11 12:10:15s -0:10:15 - -Rule sol87 1987 only - Mar 12 12:09:55s -0:09:55 - -Rule sol87 1987 only - Mar 13 12:09:40s -0:09:40 - -Rule sol87 1987 only - Mar 14 12:09:25s -0:09:25 - -Rule sol87 1987 only - Mar 15 12:09:10s -0:09:10 - -Rule sol87 1987 only - Mar 16 12:08:50s -0:08:50 - -Rule sol87 1987 only - Mar 17 12:08:35s -0:08:35 - -Rule sol87 1987 only - Mar 18 12:08:15s -0:08:15 - -Rule sol87 1987 only - Mar 19 12:08:00s -0:08:00 - -Rule sol87 1987 only - Mar 20 12:07:40s -0:07:40 - -Rule sol87 1987 only - Mar 21 12:07:25s -0:07:25 - -Rule sol87 1987 only - Mar 22 12:07:05s -0:07:05 - -Rule sol87 1987 only - Mar 23 12:06:50s -0:06:50 - -Rule sol87 1987 only - Mar 24 12:06:30s -0:06:30 - -Rule sol87 1987 only - Mar 25 12:06:10s -0:06:10 - -Rule sol87 1987 only - Mar 26 12:05:55s -0:05:55 - -Rule sol87 1987 only - Mar 27 12:05:35s -0:05:35 - -Rule sol87 1987 only - Mar 28 12:05:15s -0:05:15 - -Rule sol87 1987 only - Mar 29 12:05:00s -0:05:00 - -Rule sol87 1987 only - Mar 30 12:04:40s -0:04:40 - -Rule sol87 1987 only - Mar 31 12:04:25s -0:04:25 - -Rule sol87 1987 only - Apr 1 12:04:05s -0:04:05 - -Rule sol87 1987 only - Apr 2 12:03:45s -0:03:45 - -Rule sol87 1987 only - Apr 3 12:03:30s -0:03:30 - -Rule sol87 1987 only - Apr 4 12:03:10s -0:03:10 - -Rule sol87 1987 only - Apr 5 12:02:55s -0:02:55 - -Rule sol87 1987 only - Apr 6 12:02:35s -0:02:35 - -Rule sol87 1987 only - Apr 7 12:02:20s -0:02:20 - -Rule sol87 1987 only - Apr 8 12:02:05s -0:02:05 - -Rule sol87 1987 only - Apr 9 12:01:45s -0:01:45 - -Rule sol87 1987 only - Apr 10 12:01:30s -0:01:30 - -Rule sol87 1987 only - Apr 11 12:01:15s -0:01:15 - -Rule sol87 1987 only - Apr 12 12:00:55s -0:00:55 - -Rule sol87 1987 only - Apr 13 12:00:40s -0:00:40 - -Rule sol87 1987 only - Apr 14 12:00:25s -0:00:25 - -Rule sol87 1987 only - Apr 15 12:00:10s -0:00:10 - -Rule sol87 1987 only - Apr 16 11:59:55s 0:00:05 - -Rule sol87 1987 only - Apr 17 11:59:45s 0:00:15 - -Rule sol87 1987 only - Apr 18 11:59:30s 0:00:30 - -Rule sol87 1987 only - Apr 19 11:59:15s 0:00:45 - -Rule sol87 1987 only - Apr 20 11:59:05s 0:00:55 - -Rule sol87 1987 only - Apr 21 11:58:50s 0:01:10 - -Rule sol87 1987 only - Apr 22 11:58:40s 0:01:20 - -Rule sol87 1987 only - Apr 23 11:58:25s 0:01:35 - -Rule sol87 1987 only - Apr 24 11:58:15s 0:01:45 - -Rule sol87 1987 only - Apr 25 11:58:05s 0:01:55 - -Rule sol87 1987 only - Apr 26 11:57:55s 0:02:05 - -Rule sol87 1987 only - Apr 27 11:57:45s 0:02:15 - -Rule sol87 1987 only - Apr 28 11:57:35s 0:02:25 - -Rule sol87 1987 only - Apr 29 11:57:25s 0:02:35 - -Rule sol87 1987 only - Apr 30 11:57:15s 0:02:45 - -Rule sol87 1987 only - May 1 11:57:10s 0:02:50 - -Rule sol87 1987 only - May 2 11:57:00s 0:03:00 - -Rule sol87 1987 only - May 3 11:56:55s 0:03:05 - -Rule sol87 1987 only - May 4 11:56:50s 0:03:10 - -Rule sol87 1987 only - May 5 11:56:45s 0:03:15 - -Rule sol87 1987 only - May 6 11:56:40s 0:03:20 - -Rule sol87 1987 only - May 7 11:56:35s 0:03:25 - -Rule sol87 1987 only - May 8 11:56:30s 0:03:30 - -Rule sol87 1987 only - May 9 11:56:25s 0:03:35 - -Rule sol87 1987 only - May 10 11:56:25s 0:03:35 - -Rule sol87 1987 only - May 11 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 12 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 13 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 14 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 15 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 16 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 17 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 18 11:56:20s 0:03:40 - -Rule sol87 1987 only - May 19 11:56:25s 0:03:35 - -Rule sol87 1987 only - May 20 11:56:25s 0:03:35 - -Rule sol87 1987 only - May 21 11:56:30s 0:03:30 - -Rule sol87 1987 only - May 22 11:56:35s 0:03:25 - -Rule sol87 1987 only - May 23 11:56:40s 0:03:20 - -Rule sol87 1987 only - May 24 11:56:45s 0:03:15 - -Rule sol87 1987 only - May 25 11:56:50s 0:03:10 - -Rule sol87 1987 only - May 26 11:56:55s 0:03:05 - -Rule sol87 1987 only - May 27 11:57:00s 0:03:00 - -Rule sol87 1987 only - May 28 11:57:10s 0:02:50 - -Rule sol87 1987 only - May 29 11:57:15s 0:02:45 - -Rule sol87 1987 only - May 30 11:57:25s 0:02:35 - -Rule sol87 1987 only - May 31 11:57:30s 0:02:30 - -Rule sol87 1987 only - Jun 1 11:57:40s 0:02:20 - -Rule sol87 1987 only - Jun 2 11:57:50s 0:02:10 - -Rule sol87 1987 only - Jun 3 11:58:00s 0:02:00 - -Rule sol87 1987 only - Jun 4 11:58:10s 0:01:50 - -Rule sol87 1987 only - Jun 5 11:58:20s 0:01:40 - -Rule sol87 1987 only - Jun 6 11:58:30s 0:01:30 - -Rule sol87 1987 only - Jun 7 11:58:40s 0:01:20 - -Rule sol87 1987 only - Jun 8 11:58:50s 0:01:10 - -Rule sol87 1987 only - Jun 9 11:59:05s 0:00:55 - -Rule sol87 1987 only - Jun 10 11:59:15s 0:00:45 - -Rule sol87 1987 only - Jun 11 11:59:30s 0:00:30 - -Rule sol87 1987 only - Jun 12 11:59:40s 0:00:20 - -Rule sol87 1987 only - Jun 13 11:59:50s 0:00:10 - -Rule sol87 1987 only - Jun 14 12:00:05s -0:00:05 - -Rule sol87 1987 only - Jun 15 12:00:15s -0:00:15 - -Rule sol87 1987 only - Jun 16 12:00:30s -0:00:30 - -Rule sol87 1987 only - Jun 17 12:00:45s -0:00:45 - -Rule sol87 1987 only - Jun 18 12:00:55s -0:00:55 - -Rule sol87 1987 only - Jun 19 12:01:10s -0:01:10 - -Rule sol87 1987 only - Jun 20 12:01:20s -0:01:20 - -Rule sol87 1987 only - Jun 21 12:01:35s -0:01:35 - -Rule sol87 1987 only - Jun 22 12:01:50s -0:01:50 - -Rule sol87 1987 only - Jun 23 12:02:00s -0:02:00 - -Rule sol87 1987 only - Jun 24 12:02:15s -0:02:15 - -Rule sol87 1987 only - Jun 25 12:02:25s -0:02:25 - -Rule sol87 1987 only - Jun 26 12:02:40s -0:02:40 - -Rule sol87 1987 only - Jun 27 12:02:50s -0:02:50 - -Rule sol87 1987 only - Jun 28 12:03:05s -0:03:05 - -Rule sol87 1987 only - Jun 29 12:03:15s -0:03:15 - -Rule sol87 1987 only - Jun 30 12:03:30s -0:03:30 - -Rule sol87 1987 only - Jul 1 12:03:40s -0:03:40 - -Rule sol87 1987 only - Jul 2 12:03:50s -0:03:50 - -Rule sol87 1987 only - Jul 3 12:04:05s -0:04:05 - -Rule sol87 1987 only - Jul 4 12:04:15s -0:04:15 - -Rule sol87 1987 only - Jul 5 12:04:25s -0:04:25 - -Rule sol87 1987 only - Jul 6 12:04:35s -0:04:35 - -Rule sol87 1987 only - Jul 7 12:04:45s -0:04:45 - -Rule sol87 1987 only - Jul 8 12:04:55s -0:04:55 - -Rule sol87 1987 only - Jul 9 12:05:05s -0:05:05 - -Rule sol87 1987 only - Jul 10 12:05:15s -0:05:15 - -Rule sol87 1987 only - Jul 11 12:05:20s -0:05:20 - -Rule sol87 1987 only - Jul 12 12:05:30s -0:05:30 - -Rule sol87 1987 only - Jul 13 12:05:40s -0:05:40 - -Rule sol87 1987 only - Jul 14 12:05:45s -0:05:45 - -Rule sol87 1987 only - Jul 15 12:05:50s -0:05:50 - -Rule sol87 1987 only - Jul 16 12:06:00s -0:06:00 - -Rule sol87 1987 only - Jul 17 12:06:05s -0:06:05 - -Rule sol87 1987 only - Jul 18 12:06:10s -0:06:10 - -Rule sol87 1987 only - Jul 19 12:06:15s -0:06:15 - -Rule sol87 1987 only - Jul 20 12:06:15s -0:06:15 - -Rule sol87 1987 only - Jul 21 12:06:20s -0:06:20 - -Rule sol87 1987 only - Jul 22 12:06:25s -0:06:25 - -Rule sol87 1987 only - Jul 23 12:06:25s -0:06:25 - -Rule sol87 1987 only - Jul 24 12:06:25s -0:06:25 - -Rule sol87 1987 only - Jul 25 12:06:30s -0:06:30 - -Rule sol87 1987 only - Jul 26 12:06:30s -0:06:30 - -Rule sol87 1987 only - Jul 27 12:06:30s -0:06:30 - -Rule sol87 1987 only - Jul 28 12:06:30s -0:06:30 - -Rule sol87 1987 only - Jul 29 12:06:25s -0:06:25 - -Rule sol87 1987 only - Jul 30 12:06:25s -0:06:25 - -Rule sol87 1987 only - Jul 31 12:06:25s -0:06:25 - -Rule sol87 1987 only - Aug 1 12:06:20s -0:06:20 - -Rule sol87 1987 only - Aug 2 12:06:15s -0:06:15 - -Rule sol87 1987 only - Aug 3 12:06:10s -0:06:10 - -Rule sol87 1987 only - Aug 4 12:06:05s -0:06:05 - -Rule sol87 1987 only - Aug 5 12:06:00s -0:06:00 - -Rule sol87 1987 only - Aug 6 12:05:55s -0:05:55 - -Rule sol87 1987 only - Aug 7 12:05:50s -0:05:50 - -Rule sol87 1987 only - Aug 8 12:05:40s -0:05:40 - -Rule sol87 1987 only - Aug 9 12:05:35s -0:05:35 - -Rule sol87 1987 only - Aug 10 12:05:25s -0:05:25 - -Rule sol87 1987 only - Aug 11 12:05:15s -0:05:15 - -Rule sol87 1987 only - Aug 12 12:05:05s -0:05:05 - -Rule sol87 1987 only - Aug 13 12:04:55s -0:04:55 - -Rule sol87 1987 only - Aug 14 12:04:45s -0:04:45 - -Rule sol87 1987 only - Aug 15 12:04:35s -0:04:35 - -Rule sol87 1987 only - Aug 16 12:04:25s -0:04:25 - -Rule sol87 1987 only - Aug 17 12:04:10s -0:04:10 - -Rule sol87 1987 only - Aug 18 12:04:00s -0:04:00 - -Rule sol87 1987 only - Aug 19 12:03:45s -0:03:45 - -Rule sol87 1987 only - Aug 20 12:03:30s -0:03:30 - -Rule sol87 1987 only - Aug 21 12:03:15s -0:03:15 - -Rule sol87 1987 only - Aug 22 12:03:00s -0:03:00 - -Rule sol87 1987 only - Aug 23 12:02:45s -0:02:45 - -Rule sol87 1987 only - Aug 24 12:02:30s -0:02:30 - -Rule sol87 1987 only - Aug 25 12:02:15s -0:02:15 - -Rule sol87 1987 only - Aug 26 12:02:00s -0:02:00 - -Rule sol87 1987 only - Aug 27 12:01:40s -0:01:40 - -Rule sol87 1987 only - Aug 28 12:01:25s -0:01:25 - -Rule sol87 1987 only - Aug 29 12:01:05s -0:01:05 - -Rule sol87 1987 only - Aug 30 12:00:50s -0:00:50 - -Rule sol87 1987 only - Aug 31 12:00:30s -0:00:30 - -Rule sol87 1987 only - Sep 1 12:00:10s -0:00:10 - -Rule sol87 1987 only - Sep 2 11:59:50s 0:00:10 - -Rule sol87 1987 only - Sep 3 11:59:35s 0:00:25 - -Rule sol87 1987 only - Sep 4 11:59:15s 0:00:45 - -Rule sol87 1987 only - Sep 5 11:58:55s 0:01:05 - -Rule sol87 1987 only - Sep 6 11:58:35s 0:01:25 - -Rule sol87 1987 only - Sep 7 11:58:15s 0:01:45 - -Rule sol87 1987 only - Sep 8 11:57:55s 0:02:05 - -Rule sol87 1987 only - Sep 9 11:57:30s 0:02:30 - -Rule sol87 1987 only - Sep 10 11:57:10s 0:02:50 - -Rule sol87 1987 only - Sep 11 11:56:50s 0:03:10 - -Rule sol87 1987 only - Sep 12 11:56:30s 0:03:30 - -Rule sol87 1987 only - Sep 13 11:56:10s 0:03:50 - -Rule sol87 1987 only - Sep 14 11:55:45s 0:04:15 - -Rule sol87 1987 only - Sep 15 11:55:25s 0:04:35 - -Rule sol87 1987 only - Sep 16 11:55:05s 0:04:55 - -Rule sol87 1987 only - Sep 17 11:54:45s 0:05:15 - -Rule sol87 1987 only - Sep 18 11:54:20s 0:05:40 - -Rule sol87 1987 only - Sep 19 11:54:00s 0:06:00 - -Rule sol87 1987 only - Sep 20 11:53:40s 0:06:20 - -Rule sol87 1987 only - Sep 21 11:53:15s 0:06:45 - -Rule sol87 1987 only - Sep 22 11:52:55s 0:07:05 - -Rule sol87 1987 only - Sep 23 11:52:35s 0:07:25 - -Rule sol87 1987 only - Sep 24 11:52:15s 0:07:45 - -Rule sol87 1987 only - Sep 25 11:51:55s 0:08:05 - -Rule sol87 1987 only - Sep 26 11:51:35s 0:08:25 - -Rule sol87 1987 only - Sep 27 11:51:10s 0:08:50 - -Rule sol87 1987 only - Sep 28 11:50:50s 0:09:10 - -Rule sol87 1987 only - Sep 29 11:50:30s 0:09:30 - -Rule sol87 1987 only - Sep 30 11:50:10s 0:09:50 - -Rule sol87 1987 only - Oct 1 11:49:50s 0:10:10 - -Rule sol87 1987 only - Oct 2 11:49:35s 0:10:25 - -Rule sol87 1987 only - Oct 3 11:49:15s 0:10:45 - -Rule sol87 1987 only - Oct 4 11:48:55s 0:11:05 - -Rule sol87 1987 only - Oct 5 11:48:35s 0:11:25 - -Rule sol87 1987 only - Oct 6 11:48:20s 0:11:40 - -Rule sol87 1987 only - Oct 7 11:48:00s 0:12:00 - -Rule sol87 1987 only - Oct 8 11:47:45s 0:12:15 - -Rule sol87 1987 only - Oct 9 11:47:25s 0:12:35 - -Rule sol87 1987 only - Oct 10 11:47:10s 0:12:50 - -Rule sol87 1987 only - Oct 11 11:46:55s 0:13:05 - -Rule sol87 1987 only - Oct 12 11:46:40s 0:13:20 - -Rule sol87 1987 only - Oct 13 11:46:25s 0:13:35 - -Rule sol87 1987 only - Oct 14 11:46:10s 0:13:50 - -Rule sol87 1987 only - Oct 15 11:45:55s 0:14:05 - -Rule sol87 1987 only - Oct 16 11:45:45s 0:14:15 - -Rule sol87 1987 only - Oct 17 11:45:30s 0:14:30 - -Rule sol87 1987 only - Oct 18 11:45:20s 0:14:40 - -Rule sol87 1987 only - Oct 19 11:45:05s 0:14:55 - -Rule sol87 1987 only - Oct 20 11:44:55s 0:15:05 - -Rule sol87 1987 only - Oct 21 11:44:45s 0:15:15 - -Rule sol87 1987 only - Oct 22 11:44:35s 0:15:25 - -Rule sol87 1987 only - Oct 23 11:44:25s 0:15:35 - -Rule sol87 1987 only - Oct 24 11:44:20s 0:15:40 - -Rule sol87 1987 only - Oct 25 11:44:10s 0:15:50 - -Rule sol87 1987 only - Oct 26 11:44:05s 0:15:55 - -Rule sol87 1987 only - Oct 27 11:43:55s 0:16:05 - -Rule sol87 1987 only - Oct 28 11:43:50s 0:16:10 - -Rule sol87 1987 only - Oct 29 11:43:45s 0:16:15 - -Rule sol87 1987 only - Oct 30 11:43:45s 0:16:15 - -Rule sol87 1987 only - Oct 31 11:43:40s 0:16:20 - -Rule sol87 1987 only - Nov 1 11:43:40s 0:16:20 - -Rule sol87 1987 only - Nov 2 11:43:35s 0:16:25 - -Rule sol87 1987 only - Nov 3 11:43:35s 0:16:25 - -Rule sol87 1987 only - Nov 4 11:43:35s 0:16:25 - -Rule sol87 1987 only - Nov 5 11:43:35s 0:16:25 - -Rule sol87 1987 only - Nov 6 11:43:40s 0:16:20 - -Rule sol87 1987 only - Nov 7 11:43:40s 0:16:20 - -Rule sol87 1987 only - Nov 8 11:43:45s 0:16:15 - -Rule sol87 1987 only - Nov 9 11:43:50s 0:16:10 - -Rule sol87 1987 only - Nov 10 11:43:55s 0:16:05 - -Rule sol87 1987 only - Nov 11 11:44:00s 0:16:00 - -Rule sol87 1987 only - Nov 12 11:44:05s 0:15:55 - -Rule sol87 1987 only - Nov 13 11:44:15s 0:15:45 - -Rule sol87 1987 only - Nov 14 11:44:20s 0:15:40 - -Rule sol87 1987 only - Nov 15 11:44:30s 0:15:30 - -Rule sol87 1987 only - Nov 16 11:44:40s 0:15:20 - -Rule sol87 1987 only - Nov 17 11:44:50s 0:15:10 - -Rule sol87 1987 only - Nov 18 11:45:05s 0:14:55 - -Rule sol87 1987 only - Nov 19 11:45:15s 0:14:45 - -Rule sol87 1987 only - Nov 20 11:45:30s 0:14:30 - -Rule sol87 1987 only - Nov 21 11:45:45s 0:14:15 - -Rule sol87 1987 only - Nov 22 11:46:00s 0:14:00 - -Rule sol87 1987 only - Nov 23 11:46:15s 0:13:45 - -Rule sol87 1987 only - Nov 24 11:46:30s 0:13:30 - -Rule sol87 1987 only - Nov 25 11:46:50s 0:13:10 - -Rule sol87 1987 only - Nov 26 11:47:10s 0:12:50 - -Rule sol87 1987 only - Nov 27 11:47:25s 0:12:35 - -Rule sol87 1987 only - Nov 28 11:47:45s 0:12:15 - -Rule sol87 1987 only - Nov 29 11:48:05s 0:11:55 - -Rule sol87 1987 only - Nov 30 11:48:30s 0:11:30 - -Rule sol87 1987 only - Dec 1 11:48:50s 0:11:10 - -Rule sol87 1987 only - Dec 2 11:49:10s 0:10:50 - -Rule sol87 1987 only - Dec 3 11:49:35s 0:10:25 - -Rule sol87 1987 only - Dec 4 11:50:00s 0:10:00 - -Rule sol87 1987 only - Dec 5 11:50:25s 0:09:35 - -Rule sol87 1987 only - Dec 6 11:50:50s 0:09:10 - -Rule sol87 1987 only - Dec 7 11:51:15s 0:08:45 - -Rule sol87 1987 only - Dec 8 11:51:40s 0:08:20 - -Rule sol87 1987 only - Dec 9 11:52:05s 0:07:55 - -Rule sol87 1987 only - Dec 10 11:52:30s 0:07:30 - -Rule sol87 1987 only - Dec 11 11:53:00s 0:07:00 - -Rule sol87 1987 only - Dec 12 11:53:25s 0:06:35 - -Rule sol87 1987 only - Dec 13 11:53:55s 0:06:05 - -Rule sol87 1987 only - Dec 14 11:54:25s 0:05:35 - -Rule sol87 1987 only - Dec 15 11:54:50s 0:05:10 - -Rule sol87 1987 only - Dec 16 11:55:20s 0:04:40 - -Rule sol87 1987 only - Dec 17 11:55:50s 0:04:10 - -Rule sol87 1987 only - Dec 18 11:56:20s 0:03:40 - -Rule sol87 1987 only - Dec 19 11:56:50s 0:03:10 - -Rule sol87 1987 only - Dec 20 11:57:20s 0:02:40 - -Rule sol87 1987 only - Dec 21 11:57:50s 0:02:10 - -Rule sol87 1987 only - Dec 22 11:58:20s 0:01:40 - -Rule sol87 1987 only - Dec 23 11:58:50s 0:01:10 - -Rule sol87 1987 only - Dec 24 11:59:20s 0:00:40 - -Rule sol87 1987 only - Dec 25 11:59:50s 0:00:10 - -Rule sol87 1987 only - Dec 26 12:00:20s -0:00:20 - -Rule sol87 1987 only - Dec 27 12:00:45s -0:00:45 - -Rule sol87 1987 only - Dec 28 12:01:15s -0:01:15 - -Rule sol87 1987 only - Dec 29 12:01:45s -0:01:45 - -Rule sol87 1987 only - Dec 30 12:02:15s -0:02:15 - -Rule sol87 1987 only - Dec 31 12:02:45s -0:02:45 - - -# Riyadh is at about 46 degrees 46 minutes East: 3 hrs, 7 mins, 4 secs -# Before and after 1987, we'll operate on local mean solar time. - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -Zone Asia/Riyadh87 3:07:04 - zzz 1987 - 3:07:04 sol87 zzz 1988 - 3:07:04 - zzz -# For backward compatibility... -Link Asia/Riyadh87 Mideast/Riyadh87 diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/solar88 b/src/test/jdk/sun/util/calendar/zi/tzdata/solar88 deleted file mode 100644 index 3314cb1d640..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/solar88 +++ /dev/null @@ -1,413 +0,0 @@ -# -# 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. -# -# <pre> -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# Apparent noon times below are for Riyadh; they're a bit off for other places. -# Times were computed using formulas in the U.S. Naval Observatory's -# Almanac for Computers 1988; the formulas "will give EqT to an accuracy of -# [plus or minus two] seconds during the current year." -# -# Rounding to the nearest five seconds results in fewer than -# 256 different "time types"--a limit that's faced because time types are -# stored on disk as unsigned chars. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule sol88 1988 only - Jan 1 12:03:15s -0:03:15 - -Rule sol88 1988 only - Jan 2 12:03:40s -0:03:40 - -Rule sol88 1988 only - Jan 3 12:04:10s -0:04:10 - -Rule sol88 1988 only - Jan 4 12:04:40s -0:04:40 - -Rule sol88 1988 only - Jan 5 12:05:05s -0:05:05 - -Rule sol88 1988 only - Jan 6 12:05:30s -0:05:30 - -Rule sol88 1988 only - Jan 7 12:06:00s -0:06:00 - -Rule sol88 1988 only - Jan 8 12:06:25s -0:06:25 - -Rule sol88 1988 only - Jan 9 12:06:50s -0:06:50 - -Rule sol88 1988 only - Jan 10 12:07:15s -0:07:15 - -Rule sol88 1988 only - Jan 11 12:07:40s -0:07:40 - -Rule sol88 1988 only - Jan 12 12:08:05s -0:08:05 - -Rule sol88 1988 only - Jan 13 12:08:25s -0:08:25 - -Rule sol88 1988 only - Jan 14 12:08:50s -0:08:50 - -Rule sol88 1988 only - Jan 15 12:09:10s -0:09:10 - -Rule sol88 1988 only - Jan 16 12:09:30s -0:09:30 - -Rule sol88 1988 only - Jan 17 12:09:50s -0:09:50 - -Rule sol88 1988 only - Jan 18 12:10:10s -0:10:10 - -Rule sol88 1988 only - Jan 19 12:10:30s -0:10:30 - -Rule sol88 1988 only - Jan 20 12:10:50s -0:10:50 - -Rule sol88 1988 only - Jan 21 12:11:05s -0:11:05 - -Rule sol88 1988 only - Jan 22 12:11:25s -0:11:25 - -Rule sol88 1988 only - Jan 23 12:11:40s -0:11:40 - -Rule sol88 1988 only - Jan 24 12:11:55s -0:11:55 - -Rule sol88 1988 only - Jan 25 12:12:10s -0:12:10 - -Rule sol88 1988 only - Jan 26 12:12:25s -0:12:25 - -Rule sol88 1988 only - Jan 27 12:12:40s -0:12:40 - -Rule sol88 1988 only - Jan 28 12:12:50s -0:12:50 - -Rule sol88 1988 only - Jan 29 12:13:00s -0:13:00 - -Rule sol88 1988 only - Jan 30 12:13:10s -0:13:10 - -Rule sol88 1988 only - Jan 31 12:13:20s -0:13:20 - -Rule sol88 1988 only - Feb 1 12:13:30s -0:13:30 - -Rule sol88 1988 only - Feb 2 12:13:40s -0:13:40 - -Rule sol88 1988 only - Feb 3 12:13:45s -0:13:45 - -Rule sol88 1988 only - Feb 4 12:13:55s -0:13:55 - -Rule sol88 1988 only - Feb 5 12:14:00s -0:14:00 - -Rule sol88 1988 only - Feb 6 12:14:05s -0:14:05 - -Rule sol88 1988 only - Feb 7 12:14:10s -0:14:10 - -Rule sol88 1988 only - Feb 8 12:14:10s -0:14:10 - -Rule sol88 1988 only - Feb 9 12:14:15s -0:14:15 - -Rule sol88 1988 only - Feb 10 12:14:15s -0:14:15 - -Rule sol88 1988 only - Feb 11 12:14:15s -0:14:15 - -Rule sol88 1988 only - Feb 12 12:14:15s -0:14:15 - -Rule sol88 1988 only - Feb 13 12:14:15s -0:14:15 - -Rule sol88 1988 only - Feb 14 12:14:15s -0:14:15 - -Rule sol88 1988 only - Feb 15 12:14:10s -0:14:10 - -Rule sol88 1988 only - Feb 16 12:14:10s -0:14:10 - -Rule sol88 1988 only - Feb 17 12:14:05s -0:14:05 - -Rule sol88 1988 only - Feb 18 12:14:00s -0:14:00 - -Rule sol88 1988 only - Feb 19 12:13:55s -0:13:55 - -Rule sol88 1988 only - Feb 20 12:13:50s -0:13:50 - -Rule sol88 1988 only - Feb 21 12:13:45s -0:13:45 - -Rule sol88 1988 only - Feb 22 12:13:40s -0:13:40 - -Rule sol88 1988 only - Feb 23 12:13:30s -0:13:30 - -Rule sol88 1988 only - Feb 24 12:13:20s -0:13:20 - -Rule sol88 1988 only - Feb 25 12:13:15s -0:13:15 - -Rule sol88 1988 only - Feb 26 12:13:05s -0:13:05 - -Rule sol88 1988 only - Feb 27 12:12:55s -0:12:55 - -Rule sol88 1988 only - Feb 28 12:12:45s -0:12:45 - -Rule sol88 1988 only - Feb 29 12:12:30s -0:12:30 - -Rule sol88 1988 only - Mar 1 12:12:20s -0:12:20 - -Rule sol88 1988 only - Mar 2 12:12:10s -0:12:10 - -Rule sol88 1988 only - Mar 3 12:11:55s -0:11:55 - -Rule sol88 1988 only - Mar 4 12:11:45s -0:11:45 - -Rule sol88 1988 only - Mar 5 12:11:30s -0:11:30 - -Rule sol88 1988 only - Mar 6 12:11:15s -0:11:15 - -Rule sol88 1988 only - Mar 7 12:11:00s -0:11:00 - -Rule sol88 1988 only - Mar 8 12:10:45s -0:10:45 - -Rule sol88 1988 only - Mar 9 12:10:30s -0:10:30 - -Rule sol88 1988 only - Mar 10 12:10:15s -0:10:15 - -Rule sol88 1988 only - Mar 11 12:10:00s -0:10:00 - -Rule sol88 1988 only - Mar 12 12:09:45s -0:09:45 - -Rule sol88 1988 only - Mar 13 12:09:30s -0:09:30 - -Rule sol88 1988 only - Mar 14 12:09:10s -0:09:10 - -Rule sol88 1988 only - Mar 15 12:08:55s -0:08:55 - -Rule sol88 1988 only - Mar 16 12:08:40s -0:08:40 - -Rule sol88 1988 only - Mar 17 12:08:20s -0:08:20 - -Rule sol88 1988 only - Mar 18 12:08:05s -0:08:05 - -Rule sol88 1988 only - Mar 19 12:07:45s -0:07:45 - -Rule sol88 1988 only - Mar 20 12:07:30s -0:07:30 - -Rule sol88 1988 only - Mar 21 12:07:10s -0:07:10 - -Rule sol88 1988 only - Mar 22 12:06:50s -0:06:50 - -Rule sol88 1988 only - Mar 23 12:06:35s -0:06:35 - -Rule sol88 1988 only - Mar 24 12:06:15s -0:06:15 - -Rule sol88 1988 only - Mar 25 12:06:00s -0:06:00 - -Rule sol88 1988 only - Mar 26 12:05:40s -0:05:40 - -Rule sol88 1988 only - Mar 27 12:05:20s -0:05:20 - -Rule sol88 1988 only - Mar 28 12:05:05s -0:05:05 - -Rule sol88 1988 only - Mar 29 12:04:45s -0:04:45 - -Rule sol88 1988 only - Mar 30 12:04:25s -0:04:25 - -Rule sol88 1988 only - Mar 31 12:04:10s -0:04:10 - -Rule sol88 1988 only - Apr 1 12:03:50s -0:03:50 - -Rule sol88 1988 only - Apr 2 12:03:35s -0:03:35 - -Rule sol88 1988 only - Apr 3 12:03:15s -0:03:15 - -Rule sol88 1988 only - Apr 4 12:03:00s -0:03:00 - -Rule sol88 1988 only - Apr 5 12:02:40s -0:02:40 - -Rule sol88 1988 only - Apr 6 12:02:25s -0:02:25 - -Rule sol88 1988 only - Apr 7 12:02:05s -0:02:05 - -Rule sol88 1988 only - Apr 8 12:01:50s -0:01:50 - -Rule sol88 1988 only - Apr 9 12:01:35s -0:01:35 - -Rule sol88 1988 only - Apr 10 12:01:15s -0:01:15 - -Rule sol88 1988 only - Apr 11 12:01:00s -0:01:00 - -Rule sol88 1988 only - Apr 12 12:00:45s -0:00:45 - -Rule sol88 1988 only - Apr 13 12:00:30s -0:00:30 - -Rule sol88 1988 only - Apr 14 12:00:15s -0:00:15 - -Rule sol88 1988 only - Apr 15 12:00:00s 0:00:00 - -Rule sol88 1988 only - Apr 16 11:59:45s 0:00:15 - -Rule sol88 1988 only - Apr 17 11:59:30s 0:00:30 - -Rule sol88 1988 only - Apr 18 11:59:20s 0:00:40 - -Rule sol88 1988 only - Apr 19 11:59:05s 0:00:55 - -Rule sol88 1988 only - Apr 20 11:58:55s 0:01:05 - -Rule sol88 1988 only - Apr 21 11:58:40s 0:01:20 - -Rule sol88 1988 only - Apr 22 11:58:30s 0:01:30 - -Rule sol88 1988 only - Apr 23 11:58:15s 0:01:45 - -Rule sol88 1988 only - Apr 24 11:58:05s 0:01:55 - -Rule sol88 1988 only - Apr 25 11:57:55s 0:02:05 - -Rule sol88 1988 only - Apr 26 11:57:45s 0:02:15 - -Rule sol88 1988 only - Apr 27 11:57:35s 0:02:25 - -Rule sol88 1988 only - Apr 28 11:57:30s 0:02:30 - -Rule sol88 1988 only - Apr 29 11:57:20s 0:02:40 - -Rule sol88 1988 only - Apr 30 11:57:10s 0:02:50 - -Rule sol88 1988 only - May 1 11:57:05s 0:02:55 - -Rule sol88 1988 only - May 2 11:56:55s 0:03:05 - -Rule sol88 1988 only - May 3 11:56:50s 0:03:10 - -Rule sol88 1988 only - May 4 11:56:45s 0:03:15 - -Rule sol88 1988 only - May 5 11:56:40s 0:03:20 - -Rule sol88 1988 only - May 6 11:56:35s 0:03:25 - -Rule sol88 1988 only - May 7 11:56:30s 0:03:30 - -Rule sol88 1988 only - May 8 11:56:25s 0:03:35 - -Rule sol88 1988 only - May 9 11:56:25s 0:03:35 - -Rule sol88 1988 only - May 10 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 11 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 12 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 13 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 14 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 15 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 16 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 17 11:56:20s 0:03:40 - -Rule sol88 1988 only - May 18 11:56:25s 0:03:35 - -Rule sol88 1988 only - May 19 11:56:25s 0:03:35 - -Rule sol88 1988 only - May 20 11:56:30s 0:03:30 - -Rule sol88 1988 only - May 21 11:56:35s 0:03:25 - -Rule sol88 1988 only - May 22 11:56:40s 0:03:20 - -Rule sol88 1988 only - May 23 11:56:45s 0:03:15 - -Rule sol88 1988 only - May 24 11:56:50s 0:03:10 - -Rule sol88 1988 only - May 25 11:56:55s 0:03:05 - -Rule sol88 1988 only - May 26 11:57:00s 0:03:00 - -Rule sol88 1988 only - May 27 11:57:05s 0:02:55 - -Rule sol88 1988 only - May 28 11:57:15s 0:02:45 - -Rule sol88 1988 only - May 29 11:57:20s 0:02:40 - -Rule sol88 1988 only - May 30 11:57:30s 0:02:30 - -Rule sol88 1988 only - May 31 11:57:40s 0:02:20 - -Rule sol88 1988 only - Jun 1 11:57:50s 0:02:10 - -Rule sol88 1988 only - Jun 2 11:57:55s 0:02:05 - -Rule sol88 1988 only - Jun 3 11:58:05s 0:01:55 - -Rule sol88 1988 only - Jun 4 11:58:15s 0:01:45 - -Rule sol88 1988 only - Jun 5 11:58:30s 0:01:30 - -Rule sol88 1988 only - Jun 6 11:58:40s 0:01:20 - -Rule sol88 1988 only - Jun 7 11:58:50s 0:01:10 - -Rule sol88 1988 only - Jun 8 11:59:00s 0:01:00 - -Rule sol88 1988 only - Jun 9 11:59:15s 0:00:45 - -Rule sol88 1988 only - Jun 10 11:59:25s 0:00:35 - -Rule sol88 1988 only - Jun 11 11:59:35s 0:00:25 - -Rule sol88 1988 only - Jun 12 11:59:50s 0:00:10 - -Rule sol88 1988 only - Jun 13 12:00:00s 0:00:00 - -Rule sol88 1988 only - Jun 14 12:00:15s -0:00:15 - -Rule sol88 1988 only - Jun 15 12:00:25s -0:00:25 - -Rule sol88 1988 only - Jun 16 12:00:40s -0:00:40 - -Rule sol88 1988 only - Jun 17 12:00:55s -0:00:55 - -Rule sol88 1988 only - Jun 18 12:01:05s -0:01:05 - -Rule sol88 1988 only - Jun 19 12:01:20s -0:01:20 - -Rule sol88 1988 only - Jun 20 12:01:30s -0:01:30 - -Rule sol88 1988 only - Jun 21 12:01:45s -0:01:45 - -Rule sol88 1988 only - Jun 22 12:02:00s -0:02:00 - -Rule sol88 1988 only - Jun 23 12:02:10s -0:02:10 - -Rule sol88 1988 only - Jun 24 12:02:25s -0:02:25 - -Rule sol88 1988 only - Jun 25 12:02:35s -0:02:35 - -Rule sol88 1988 only - Jun 26 12:02:50s -0:02:50 - -Rule sol88 1988 only - Jun 27 12:03:00s -0:03:00 - -Rule sol88 1988 only - Jun 28 12:03:15s -0:03:15 - -Rule sol88 1988 only - Jun 29 12:03:25s -0:03:25 - -Rule sol88 1988 only - Jun 30 12:03:40s -0:03:40 - -Rule sol88 1988 only - Jul 1 12:03:50s -0:03:50 - -Rule sol88 1988 only - Jul 2 12:04:00s -0:04:00 - -Rule sol88 1988 only - Jul 3 12:04:10s -0:04:10 - -Rule sol88 1988 only - Jul 4 12:04:25s -0:04:25 - -Rule sol88 1988 only - Jul 5 12:04:35s -0:04:35 - -Rule sol88 1988 only - Jul 6 12:04:45s -0:04:45 - -Rule sol88 1988 only - Jul 7 12:04:55s -0:04:55 - -Rule sol88 1988 only - Jul 8 12:05:05s -0:05:05 - -Rule sol88 1988 only - Jul 9 12:05:10s -0:05:10 - -Rule sol88 1988 only - Jul 10 12:05:20s -0:05:20 - -Rule sol88 1988 only - Jul 11 12:05:30s -0:05:30 - -Rule sol88 1988 only - Jul 12 12:05:35s -0:05:35 - -Rule sol88 1988 only - Jul 13 12:05:45s -0:05:45 - -Rule sol88 1988 only - Jul 14 12:05:50s -0:05:50 - -Rule sol88 1988 only - Jul 15 12:05:55s -0:05:55 - -Rule sol88 1988 only - Jul 16 12:06:00s -0:06:00 - -Rule sol88 1988 only - Jul 17 12:06:05s -0:06:05 - -Rule sol88 1988 only - Jul 18 12:06:10s -0:06:10 - -Rule sol88 1988 only - Jul 19 12:06:15s -0:06:15 - -Rule sol88 1988 only - Jul 20 12:06:20s -0:06:20 - -Rule sol88 1988 only - Jul 21 12:06:25s -0:06:25 - -Rule sol88 1988 only - Jul 22 12:06:25s -0:06:25 - -Rule sol88 1988 only - Jul 23 12:06:25s -0:06:25 - -Rule sol88 1988 only - Jul 24 12:06:30s -0:06:30 - -Rule sol88 1988 only - Jul 25 12:06:30s -0:06:30 - -Rule sol88 1988 only - Jul 26 12:06:30s -0:06:30 - -Rule sol88 1988 only - Jul 27 12:06:30s -0:06:30 - -Rule sol88 1988 only - Jul 28 12:06:30s -0:06:30 - -Rule sol88 1988 only - Jul 29 12:06:25s -0:06:25 - -Rule sol88 1988 only - Jul 30 12:06:25s -0:06:25 - -Rule sol88 1988 only - Jul 31 12:06:20s -0:06:20 - -Rule sol88 1988 only - Aug 1 12:06:15s -0:06:15 - -Rule sol88 1988 only - Aug 2 12:06:15s -0:06:15 - -Rule sol88 1988 only - Aug 3 12:06:10s -0:06:10 - -Rule sol88 1988 only - Aug 4 12:06:05s -0:06:05 - -Rule sol88 1988 only - Aug 5 12:05:55s -0:05:55 - -Rule sol88 1988 only - Aug 6 12:05:50s -0:05:50 - -Rule sol88 1988 only - Aug 7 12:05:45s -0:05:45 - -Rule sol88 1988 only - Aug 8 12:05:35s -0:05:35 - -Rule sol88 1988 only - Aug 9 12:05:25s -0:05:25 - -Rule sol88 1988 only - Aug 10 12:05:20s -0:05:20 - -Rule sol88 1988 only - Aug 11 12:05:10s -0:05:10 - -Rule sol88 1988 only - Aug 12 12:05:00s -0:05:00 - -Rule sol88 1988 only - Aug 13 12:04:50s -0:04:50 - -Rule sol88 1988 only - Aug 14 12:04:35s -0:04:35 - -Rule sol88 1988 only - Aug 15 12:04:25s -0:04:25 - -Rule sol88 1988 only - Aug 16 12:04:15s -0:04:15 - -Rule sol88 1988 only - Aug 17 12:04:00s -0:04:00 - -Rule sol88 1988 only - Aug 18 12:03:50s -0:03:50 - -Rule sol88 1988 only - Aug 19 12:03:35s -0:03:35 - -Rule sol88 1988 only - Aug 20 12:03:20s -0:03:20 - -Rule sol88 1988 only - Aug 21 12:03:05s -0:03:05 - -Rule sol88 1988 only - Aug 22 12:02:50s -0:02:50 - -Rule sol88 1988 only - Aug 23 12:02:35s -0:02:35 - -Rule sol88 1988 only - Aug 24 12:02:20s -0:02:20 - -Rule sol88 1988 only - Aug 25 12:02:00s -0:02:00 - -Rule sol88 1988 only - Aug 26 12:01:45s -0:01:45 - -Rule sol88 1988 only - Aug 27 12:01:30s -0:01:30 - -Rule sol88 1988 only - Aug 28 12:01:10s -0:01:10 - -Rule sol88 1988 only - Aug 29 12:00:50s -0:00:50 - -Rule sol88 1988 only - Aug 30 12:00:35s -0:00:35 - -Rule sol88 1988 only - Aug 31 12:00:15s -0:00:15 - -Rule sol88 1988 only - Sep 1 11:59:55s 0:00:05 - -Rule sol88 1988 only - Sep 2 11:59:35s 0:00:25 - -Rule sol88 1988 only - Sep 3 11:59:20s 0:00:40 - -Rule sol88 1988 only - Sep 4 11:59:00s 0:01:00 - -Rule sol88 1988 only - Sep 5 11:58:40s 0:01:20 - -Rule sol88 1988 only - Sep 6 11:58:20s 0:01:40 - -Rule sol88 1988 only - Sep 7 11:58:00s 0:02:00 - -Rule sol88 1988 only - Sep 8 11:57:35s 0:02:25 - -Rule sol88 1988 only - Sep 9 11:57:15s 0:02:45 - -Rule sol88 1988 only - Sep 10 11:56:55s 0:03:05 - -Rule sol88 1988 only - Sep 11 11:56:35s 0:03:25 - -Rule sol88 1988 only - Sep 12 11:56:15s 0:03:45 - -Rule sol88 1988 only - Sep 13 11:55:50s 0:04:10 - -Rule sol88 1988 only - Sep 14 11:55:30s 0:04:30 - -Rule sol88 1988 only - Sep 15 11:55:10s 0:04:50 - -Rule sol88 1988 only - Sep 16 11:54:50s 0:05:10 - -Rule sol88 1988 only - Sep 17 11:54:25s 0:05:35 - -Rule sol88 1988 only - Sep 18 11:54:05s 0:05:55 - -Rule sol88 1988 only - Sep 19 11:53:45s 0:06:15 - -Rule sol88 1988 only - Sep 20 11:53:25s 0:06:35 - -Rule sol88 1988 only - Sep 21 11:53:00s 0:07:00 - -Rule sol88 1988 only - Sep 22 11:52:40s 0:07:20 - -Rule sol88 1988 only - Sep 23 11:52:20s 0:07:40 - -Rule sol88 1988 only - Sep 24 11:52:00s 0:08:00 - -Rule sol88 1988 only - Sep 25 11:51:40s 0:08:20 - -Rule sol88 1988 only - Sep 26 11:51:15s 0:08:45 - -Rule sol88 1988 only - Sep 27 11:50:55s 0:09:05 - -Rule sol88 1988 only - Sep 28 11:50:35s 0:09:25 - -Rule sol88 1988 only - Sep 29 11:50:15s 0:09:45 - -Rule sol88 1988 only - Sep 30 11:49:55s 0:10:05 - -Rule sol88 1988 only - Oct 1 11:49:35s 0:10:25 - -Rule sol88 1988 only - Oct 2 11:49:20s 0:10:40 - -Rule sol88 1988 only - Oct 3 11:49:00s 0:11:00 - -Rule sol88 1988 only - Oct 4 11:48:40s 0:11:20 - -Rule sol88 1988 only - Oct 5 11:48:25s 0:11:35 - -Rule sol88 1988 only - Oct 6 11:48:05s 0:11:55 - -Rule sol88 1988 only - Oct 7 11:47:50s 0:12:10 - -Rule sol88 1988 only - Oct 8 11:47:30s 0:12:30 - -Rule sol88 1988 only - Oct 9 11:47:15s 0:12:45 - -Rule sol88 1988 only - Oct 10 11:47:00s 0:13:00 - -Rule sol88 1988 only - Oct 11 11:46:45s 0:13:15 - -Rule sol88 1988 only - Oct 12 11:46:30s 0:13:30 - -Rule sol88 1988 only - Oct 13 11:46:15s 0:13:45 - -Rule sol88 1988 only - Oct 14 11:46:00s 0:14:00 - -Rule sol88 1988 only - Oct 15 11:45:45s 0:14:15 - -Rule sol88 1988 only - Oct 16 11:45:35s 0:14:25 - -Rule sol88 1988 only - Oct 17 11:45:20s 0:14:40 - -Rule sol88 1988 only - Oct 18 11:45:10s 0:14:50 - -Rule sol88 1988 only - Oct 19 11:45:00s 0:15:00 - -Rule sol88 1988 only - Oct 20 11:44:45s 0:15:15 - -Rule sol88 1988 only - Oct 21 11:44:40s 0:15:20 - -Rule sol88 1988 only - Oct 22 11:44:30s 0:15:30 - -Rule sol88 1988 only - Oct 23 11:44:20s 0:15:40 - -Rule sol88 1988 only - Oct 24 11:44:10s 0:15:50 - -Rule sol88 1988 only - Oct 25 11:44:05s 0:15:55 - -Rule sol88 1988 only - Oct 26 11:44:00s 0:16:00 - -Rule sol88 1988 only - Oct 27 11:43:55s 0:16:05 - -Rule sol88 1988 only - Oct 28 11:43:50s 0:16:10 - -Rule sol88 1988 only - Oct 29 11:43:45s 0:16:15 - -Rule sol88 1988 only - Oct 30 11:43:40s 0:16:20 - -Rule sol88 1988 only - Oct 31 11:43:40s 0:16:20 - -Rule sol88 1988 only - Nov 1 11:43:35s 0:16:25 - -Rule sol88 1988 only - Nov 2 11:43:35s 0:16:25 - -Rule sol88 1988 only - Nov 3 11:43:35s 0:16:25 - -Rule sol88 1988 only - Nov 4 11:43:35s 0:16:25 - -Rule sol88 1988 only - Nov 5 11:43:40s 0:16:20 - -Rule sol88 1988 only - Nov 6 11:43:40s 0:16:20 - -Rule sol88 1988 only - Nov 7 11:43:45s 0:16:15 - -Rule sol88 1988 only - Nov 8 11:43:45s 0:16:15 - -Rule sol88 1988 only - Nov 9 11:43:50s 0:16:10 - -Rule sol88 1988 only - Nov 10 11:44:00s 0:16:00 - -Rule sol88 1988 only - Nov 11 11:44:05s 0:15:55 - -Rule sol88 1988 only - Nov 12 11:44:10s 0:15:50 - -Rule sol88 1988 only - Nov 13 11:44:20s 0:15:40 - -Rule sol88 1988 only - Nov 14 11:44:30s 0:15:30 - -Rule sol88 1988 only - Nov 15 11:44:40s 0:15:20 - -Rule sol88 1988 only - Nov 16 11:44:50s 0:15:10 - -Rule sol88 1988 only - Nov 17 11:45:00s 0:15:00 - -Rule sol88 1988 only - Nov 18 11:45:15s 0:14:45 - -Rule sol88 1988 only - Nov 19 11:45:25s 0:14:35 - -Rule sol88 1988 only - Nov 20 11:45:40s 0:14:20 - -Rule sol88 1988 only - Nov 21 11:45:55s 0:14:05 - -Rule sol88 1988 only - Nov 22 11:46:10s 0:13:50 - -Rule sol88 1988 only - Nov 23 11:46:30s 0:13:30 - -Rule sol88 1988 only - Nov 24 11:46:45s 0:13:15 - -Rule sol88 1988 only - Nov 25 11:47:05s 0:12:55 - -Rule sol88 1988 only - Nov 26 11:47:20s 0:12:40 - -Rule sol88 1988 only - Nov 27 11:47:40s 0:12:20 - -Rule sol88 1988 only - Nov 28 11:48:00s 0:12:00 - -Rule sol88 1988 only - Nov 29 11:48:25s 0:11:35 - -Rule sol88 1988 only - Nov 30 11:48:45s 0:11:15 - -Rule sol88 1988 only - Dec 1 11:49:05s 0:10:55 - -Rule sol88 1988 only - Dec 2 11:49:30s 0:10:30 - -Rule sol88 1988 only - Dec 3 11:49:55s 0:10:05 - -Rule sol88 1988 only - Dec 4 11:50:15s 0:09:45 - -Rule sol88 1988 only - Dec 5 11:50:40s 0:09:20 - -Rule sol88 1988 only - Dec 6 11:51:05s 0:08:55 - -Rule sol88 1988 only - Dec 7 11:51:35s 0:08:25 - -Rule sol88 1988 only - Dec 8 11:52:00s 0:08:00 - -Rule sol88 1988 only - Dec 9 11:52:25s 0:07:35 - -Rule sol88 1988 only - Dec 10 11:52:55s 0:07:05 - -Rule sol88 1988 only - Dec 11 11:53:20s 0:06:40 - -Rule sol88 1988 only - Dec 12 11:53:50s 0:06:10 - -Rule sol88 1988 only - Dec 13 11:54:15s 0:05:45 - -Rule sol88 1988 only - Dec 14 11:54:45s 0:05:15 - -Rule sol88 1988 only - Dec 15 11:55:15s 0:04:45 - -Rule sol88 1988 only - Dec 16 11:55:45s 0:04:15 - -Rule sol88 1988 only - Dec 17 11:56:15s 0:03:45 - -Rule sol88 1988 only - Dec 18 11:56:40s 0:03:20 - -Rule sol88 1988 only - Dec 19 11:57:10s 0:02:50 - -Rule sol88 1988 only - Dec 20 11:57:40s 0:02:20 - -Rule sol88 1988 only - Dec 21 11:58:10s 0:01:50 - -Rule sol88 1988 only - Dec 22 11:58:40s 0:01:20 - -Rule sol88 1988 only - Dec 23 11:59:10s 0:00:50 - -Rule sol88 1988 only - Dec 24 11:59:40s 0:00:20 - -Rule sol88 1988 only - Dec 25 12:00:10s -0:00:10 - -Rule sol88 1988 only - Dec 26 12:00:40s -0:00:40 - -Rule sol88 1988 only - Dec 27 12:01:10s -0:01:10 - -Rule sol88 1988 only - Dec 28 12:01:40s -0:01:40 - -Rule sol88 1988 only - Dec 29 12:02:10s -0:02:10 - -Rule sol88 1988 only - Dec 30 12:02:35s -0:02:35 - -Rule sol88 1988 only - Dec 31 12:03:05s -0:03:05 - - -# Riyadh is at about 46 degrees 46 minutes East: 3 hrs, 7 mins, 4 secs -# Before and after 1988, we'll operate on local mean solar time. - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -Zone Asia/Riyadh88 3:07:04 - zzz 1988 - 3:07:04 sol88 zzz 1989 - 3:07:04 - zzz -# For backward compatibility... -Link Asia/Riyadh88 Mideast/Riyadh88 diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/solar89 b/src/test/jdk/sun/util/calendar/zi/tzdata/solar89 deleted file mode 100644 index 3aa88cf0893..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/solar89 +++ /dev/null @@ -1,418 +0,0 @@ -# -# 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. -# -# <pre> -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# Apparent noon times below are for Riyadh; they're a bit off for other places. -# Times were computed using a formula provided by the U. S. Naval Observatory: -# eqt = -105.8 * sin(l) + 596.2 * sin(2 * l) + 4.4 * sin(3 * l) -# -12.7 * sin(4 * l) - 429.0 * cos(l) - 2.1 * cos (2 * l) -# + 19.3 * cos(3 * l); -# where l is the "mean longitude of the Sun" given by -# l = 279.642 degrees + 0.985647 * d -# and d is the interval in days from January 0, 0 hours Universal Time -# (equaling the day of the year plus the fraction of a day from zero hours). -# The accuracy of the formula is plus or minus three seconds. -# -# Rounding to the nearest five seconds results in fewer than -# 256 different "time types"--a limit that's faced because time types are -# stored on disk as unsigned chars. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule sol89 1989 only - Jan 1 12:03:35s -0:03:35 - -Rule sol89 1989 only - Jan 2 12:04:05s -0:04:05 - -Rule sol89 1989 only - Jan 3 12:04:30s -0:04:30 - -Rule sol89 1989 only - Jan 4 12:05:00s -0:05:00 - -Rule sol89 1989 only - Jan 5 12:05:25s -0:05:25 - -Rule sol89 1989 only - Jan 6 12:05:50s -0:05:50 - -Rule sol89 1989 only - Jan 7 12:06:15s -0:06:15 - -Rule sol89 1989 only - Jan 8 12:06:45s -0:06:45 - -Rule sol89 1989 only - Jan 9 12:07:10s -0:07:10 - -Rule sol89 1989 only - Jan 10 12:07:35s -0:07:35 - -Rule sol89 1989 only - Jan 11 12:07:55s -0:07:55 - -Rule sol89 1989 only - Jan 12 12:08:20s -0:08:20 - -Rule sol89 1989 only - Jan 13 12:08:45s -0:08:45 - -Rule sol89 1989 only - Jan 14 12:09:05s -0:09:05 - -Rule sol89 1989 only - Jan 15 12:09:25s -0:09:25 - -Rule sol89 1989 only - Jan 16 12:09:45s -0:09:45 - -Rule sol89 1989 only - Jan 17 12:10:05s -0:10:05 - -Rule sol89 1989 only - Jan 18 12:10:25s -0:10:25 - -Rule sol89 1989 only - Jan 19 12:10:45s -0:10:45 - -Rule sol89 1989 only - Jan 20 12:11:05s -0:11:05 - -Rule sol89 1989 only - Jan 21 12:11:20s -0:11:20 - -Rule sol89 1989 only - Jan 22 12:11:35s -0:11:35 - -Rule sol89 1989 only - Jan 23 12:11:55s -0:11:55 - -Rule sol89 1989 only - Jan 24 12:12:10s -0:12:10 - -Rule sol89 1989 only - Jan 25 12:12:20s -0:12:20 - -Rule sol89 1989 only - Jan 26 12:12:35s -0:12:35 - -Rule sol89 1989 only - Jan 27 12:12:50s -0:12:50 - -Rule sol89 1989 only - Jan 28 12:13:00s -0:13:00 - -Rule sol89 1989 only - Jan 29 12:13:10s -0:13:10 - -Rule sol89 1989 only - Jan 30 12:13:20s -0:13:20 - -Rule sol89 1989 only - Jan 31 12:13:30s -0:13:30 - -Rule sol89 1989 only - Feb 1 12:13:40s -0:13:40 - -Rule sol89 1989 only - Feb 2 12:13:45s -0:13:45 - -Rule sol89 1989 only - Feb 3 12:13:55s -0:13:55 - -Rule sol89 1989 only - Feb 4 12:14:00s -0:14:00 - -Rule sol89 1989 only - Feb 5 12:14:05s -0:14:05 - -Rule sol89 1989 only - Feb 6 12:14:10s -0:14:10 - -Rule sol89 1989 only - Feb 7 12:14:10s -0:14:10 - -Rule sol89 1989 only - Feb 8 12:14:15s -0:14:15 - -Rule sol89 1989 only - Feb 9 12:14:15s -0:14:15 - -Rule sol89 1989 only - Feb 10 12:14:20s -0:14:20 - -Rule sol89 1989 only - Feb 11 12:14:20s -0:14:20 - -Rule sol89 1989 only - Feb 12 12:14:20s -0:14:20 - -Rule sol89 1989 only - Feb 13 12:14:15s -0:14:15 - -Rule sol89 1989 only - Feb 14 12:14:15s -0:14:15 - -Rule sol89 1989 only - Feb 15 12:14:10s -0:14:10 - -Rule sol89 1989 only - Feb 16 12:14:10s -0:14:10 - -Rule sol89 1989 only - Feb 17 12:14:05s -0:14:05 - -Rule sol89 1989 only - Feb 18 12:14:00s -0:14:00 - -Rule sol89 1989 only - Feb 19 12:13:55s -0:13:55 - -Rule sol89 1989 only - Feb 20 12:13:50s -0:13:50 - -Rule sol89 1989 only - Feb 21 12:13:40s -0:13:40 - -Rule sol89 1989 only - Feb 22 12:13:35s -0:13:35 - -Rule sol89 1989 only - Feb 23 12:13:25s -0:13:25 - -Rule sol89 1989 only - Feb 24 12:13:15s -0:13:15 - -Rule sol89 1989 only - Feb 25 12:13:05s -0:13:05 - -Rule sol89 1989 only - Feb 26 12:12:55s -0:12:55 - -Rule sol89 1989 only - Feb 27 12:12:45s -0:12:45 - -Rule sol89 1989 only - Feb 28 12:12:35s -0:12:35 - -Rule sol89 1989 only - Mar 1 12:12:25s -0:12:25 - -Rule sol89 1989 only - Mar 2 12:12:10s -0:12:10 - -Rule sol89 1989 only - Mar 3 12:12:00s -0:12:00 - -Rule sol89 1989 only - Mar 4 12:11:45s -0:11:45 - -Rule sol89 1989 only - Mar 5 12:11:35s -0:11:35 - -Rule sol89 1989 only - Mar 6 12:11:20s -0:11:20 - -Rule sol89 1989 only - Mar 7 12:11:05s -0:11:05 - -Rule sol89 1989 only - Mar 8 12:10:50s -0:10:50 - -Rule sol89 1989 only - Mar 9 12:10:35s -0:10:35 - -Rule sol89 1989 only - Mar 10 12:10:20s -0:10:20 - -Rule sol89 1989 only - Mar 11 12:10:05s -0:10:05 - -Rule sol89 1989 only - Mar 12 12:09:50s -0:09:50 - -Rule sol89 1989 only - Mar 13 12:09:30s -0:09:30 - -Rule sol89 1989 only - Mar 14 12:09:15s -0:09:15 - -Rule sol89 1989 only - Mar 15 12:09:00s -0:09:00 - -Rule sol89 1989 only - Mar 16 12:08:40s -0:08:40 - -Rule sol89 1989 only - Mar 17 12:08:25s -0:08:25 - -Rule sol89 1989 only - Mar 18 12:08:05s -0:08:05 - -Rule sol89 1989 only - Mar 19 12:07:50s -0:07:50 - -Rule sol89 1989 only - Mar 20 12:07:30s -0:07:30 - -Rule sol89 1989 only - Mar 21 12:07:15s -0:07:15 - -Rule sol89 1989 only - Mar 22 12:06:55s -0:06:55 - -Rule sol89 1989 only - Mar 23 12:06:35s -0:06:35 - -Rule sol89 1989 only - Mar 24 12:06:20s -0:06:20 - -Rule sol89 1989 only - Mar 25 12:06:00s -0:06:00 - -Rule sol89 1989 only - Mar 26 12:05:40s -0:05:40 - -Rule sol89 1989 only - Mar 27 12:05:25s -0:05:25 - -Rule sol89 1989 only - Mar 28 12:05:05s -0:05:05 - -Rule sol89 1989 only - Mar 29 12:04:50s -0:04:50 - -Rule sol89 1989 only - Mar 30 12:04:30s -0:04:30 - -Rule sol89 1989 only - Mar 31 12:04:10s -0:04:10 - -Rule sol89 1989 only - Apr 1 12:03:55s -0:03:55 - -Rule sol89 1989 only - Apr 2 12:03:35s -0:03:35 - -Rule sol89 1989 only - Apr 3 12:03:20s -0:03:20 - -Rule sol89 1989 only - Apr 4 12:03:00s -0:03:00 - -Rule sol89 1989 only - Apr 5 12:02:45s -0:02:45 - -Rule sol89 1989 only - Apr 6 12:02:25s -0:02:25 - -Rule sol89 1989 only - Apr 7 12:02:10s -0:02:10 - -Rule sol89 1989 only - Apr 8 12:01:50s -0:01:50 - -Rule sol89 1989 only - Apr 9 12:01:35s -0:01:35 - -Rule sol89 1989 only - Apr 10 12:01:20s -0:01:20 - -Rule sol89 1989 only - Apr 11 12:01:05s -0:01:05 - -Rule sol89 1989 only - Apr 12 12:00:50s -0:00:50 - -Rule sol89 1989 only - Apr 13 12:00:35s -0:00:35 - -Rule sol89 1989 only - Apr 14 12:00:20s -0:00:20 - -Rule sol89 1989 only - Apr 15 12:00:05s -0:00:05 - -Rule sol89 1989 only - Apr 16 11:59:50s 0:00:10 - -Rule sol89 1989 only - Apr 17 11:59:35s 0:00:25 - -Rule sol89 1989 only - Apr 18 11:59:20s 0:00:40 - -Rule sol89 1989 only - Apr 19 11:59:10s 0:00:50 - -Rule sol89 1989 only - Apr 20 11:58:55s 0:01:05 - -Rule sol89 1989 only - Apr 21 11:58:45s 0:01:15 - -Rule sol89 1989 only - Apr 22 11:58:30s 0:01:30 - -Rule sol89 1989 only - Apr 23 11:58:20s 0:01:40 - -Rule sol89 1989 only - Apr 24 11:58:10s 0:01:50 - -Rule sol89 1989 only - Apr 25 11:58:00s 0:02:00 - -Rule sol89 1989 only - Apr 26 11:57:50s 0:02:10 - -Rule sol89 1989 only - Apr 27 11:57:40s 0:02:20 - -Rule sol89 1989 only - Apr 28 11:57:30s 0:02:30 - -Rule sol89 1989 only - Apr 29 11:57:20s 0:02:40 - -Rule sol89 1989 only - Apr 30 11:57:15s 0:02:45 - -Rule sol89 1989 only - May 1 11:57:05s 0:02:55 - -Rule sol89 1989 only - May 2 11:57:00s 0:03:00 - -Rule sol89 1989 only - May 3 11:56:50s 0:03:10 - -Rule sol89 1989 only - May 4 11:56:45s 0:03:15 - -Rule sol89 1989 only - May 5 11:56:40s 0:03:20 - -Rule sol89 1989 only - May 6 11:56:35s 0:03:25 - -Rule sol89 1989 only - May 7 11:56:30s 0:03:30 - -Rule sol89 1989 only - May 8 11:56:30s 0:03:30 - -Rule sol89 1989 only - May 9 11:56:25s 0:03:35 - -Rule sol89 1989 only - May 10 11:56:25s 0:03:35 - -Rule sol89 1989 only - May 11 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 12 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 13 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 14 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 15 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 16 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 17 11:56:20s 0:03:40 - -Rule sol89 1989 only - May 18 11:56:25s 0:03:35 - -Rule sol89 1989 only - May 19 11:56:25s 0:03:35 - -Rule sol89 1989 only - May 20 11:56:30s 0:03:30 - -Rule sol89 1989 only - May 21 11:56:35s 0:03:25 - -Rule sol89 1989 only - May 22 11:56:35s 0:03:25 - -Rule sol89 1989 only - May 23 11:56:40s 0:03:20 - -Rule sol89 1989 only - May 24 11:56:45s 0:03:15 - -Rule sol89 1989 only - May 25 11:56:55s 0:03:05 - -Rule sol89 1989 only - May 26 11:57:00s 0:03:00 - -Rule sol89 1989 only - May 27 11:57:05s 0:02:55 - -Rule sol89 1989 only - May 28 11:57:15s 0:02:45 - -Rule sol89 1989 only - May 29 11:57:20s 0:02:40 - -Rule sol89 1989 only - May 30 11:57:30s 0:02:30 - -Rule sol89 1989 only - May 31 11:57:35s 0:02:25 - -Rule sol89 1989 only - Jun 1 11:57:45s 0:02:15 - -Rule sol89 1989 only - Jun 2 11:57:55s 0:02:05 - -Rule sol89 1989 only - Jun 3 11:58:05s 0:01:55 - -Rule sol89 1989 only - Jun 4 11:58:15s 0:01:45 - -Rule sol89 1989 only - Jun 5 11:58:25s 0:01:35 - -Rule sol89 1989 only - Jun 6 11:58:35s 0:01:25 - -Rule sol89 1989 only - Jun 7 11:58:45s 0:01:15 - -Rule sol89 1989 only - Jun 8 11:59:00s 0:01:00 - -Rule sol89 1989 only - Jun 9 11:59:10s 0:00:50 - -Rule sol89 1989 only - Jun 10 11:59:20s 0:00:40 - -Rule sol89 1989 only - Jun 11 11:59:35s 0:00:25 - -Rule sol89 1989 only - Jun 12 11:59:45s 0:00:15 - -Rule sol89 1989 only - Jun 13 12:00:00s 0:00:00 - -Rule sol89 1989 only - Jun 14 12:00:10s -0:00:10 - -Rule sol89 1989 only - Jun 15 12:00:25s -0:00:25 - -Rule sol89 1989 only - Jun 16 12:00:35s -0:00:35 - -Rule sol89 1989 only - Jun 17 12:00:50s -0:00:50 - -Rule sol89 1989 only - Jun 18 12:01:05s -0:01:05 - -Rule sol89 1989 only - Jun 19 12:01:15s -0:01:15 - -Rule sol89 1989 only - Jun 20 12:01:30s -0:01:30 - -Rule sol89 1989 only - Jun 21 12:01:40s -0:01:40 - -Rule sol89 1989 only - Jun 22 12:01:55s -0:01:55 - -Rule sol89 1989 only - Jun 23 12:02:10s -0:02:10 - -Rule sol89 1989 only - Jun 24 12:02:20s -0:02:20 - -Rule sol89 1989 only - Jun 25 12:02:35s -0:02:35 - -Rule sol89 1989 only - Jun 26 12:02:45s -0:02:45 - -Rule sol89 1989 only - Jun 27 12:03:00s -0:03:00 - -Rule sol89 1989 only - Jun 28 12:03:10s -0:03:10 - -Rule sol89 1989 only - Jun 29 12:03:25s -0:03:25 - -Rule sol89 1989 only - Jun 30 12:03:35s -0:03:35 - -Rule sol89 1989 only - Jul 1 12:03:45s -0:03:45 - -Rule sol89 1989 only - Jul 2 12:04:00s -0:04:00 - -Rule sol89 1989 only - Jul 3 12:04:10s -0:04:10 - -Rule sol89 1989 only - Jul 4 12:04:20s -0:04:20 - -Rule sol89 1989 only - Jul 5 12:04:30s -0:04:30 - -Rule sol89 1989 only - Jul 6 12:04:40s -0:04:40 - -Rule sol89 1989 only - Jul 7 12:04:50s -0:04:50 - -Rule sol89 1989 only - Jul 8 12:05:00s -0:05:00 - -Rule sol89 1989 only - Jul 9 12:05:10s -0:05:10 - -Rule sol89 1989 only - Jul 10 12:05:20s -0:05:20 - -Rule sol89 1989 only - Jul 11 12:05:25s -0:05:25 - -Rule sol89 1989 only - Jul 12 12:05:35s -0:05:35 - -Rule sol89 1989 only - Jul 13 12:05:40s -0:05:40 - -Rule sol89 1989 only - Jul 14 12:05:50s -0:05:50 - -Rule sol89 1989 only - Jul 15 12:05:55s -0:05:55 - -Rule sol89 1989 only - Jul 16 12:06:00s -0:06:00 - -Rule sol89 1989 only - Jul 17 12:06:05s -0:06:05 - -Rule sol89 1989 only - Jul 18 12:06:10s -0:06:10 - -Rule sol89 1989 only - Jul 19 12:06:15s -0:06:15 - -Rule sol89 1989 only - Jul 20 12:06:20s -0:06:20 - -Rule sol89 1989 only - Jul 21 12:06:20s -0:06:20 - -Rule sol89 1989 only - Jul 22 12:06:25s -0:06:25 - -Rule sol89 1989 only - Jul 23 12:06:25s -0:06:25 - -Rule sol89 1989 only - Jul 24 12:06:30s -0:06:30 - -Rule sol89 1989 only - Jul 25 12:06:30s -0:06:30 - -Rule sol89 1989 only - Jul 26 12:06:30s -0:06:30 - -Rule sol89 1989 only - Jul 27 12:06:30s -0:06:30 - -Rule sol89 1989 only - Jul 28 12:06:30s -0:06:30 - -Rule sol89 1989 only - Jul 29 12:06:25s -0:06:25 - -Rule sol89 1989 only - Jul 30 12:06:25s -0:06:25 - -Rule sol89 1989 only - Jul 31 12:06:20s -0:06:20 - -Rule sol89 1989 only - Aug 1 12:06:20s -0:06:20 - -Rule sol89 1989 only - Aug 2 12:06:15s -0:06:15 - -Rule sol89 1989 only - Aug 3 12:06:10s -0:06:10 - -Rule sol89 1989 only - Aug 4 12:06:05s -0:06:05 - -Rule sol89 1989 only - Aug 5 12:06:00s -0:06:00 - -Rule sol89 1989 only - Aug 6 12:05:50s -0:05:50 - -Rule sol89 1989 only - Aug 7 12:05:45s -0:05:45 - -Rule sol89 1989 only - Aug 8 12:05:35s -0:05:35 - -Rule sol89 1989 only - Aug 9 12:05:30s -0:05:30 - -Rule sol89 1989 only - Aug 10 12:05:20s -0:05:20 - -Rule sol89 1989 only - Aug 11 12:05:10s -0:05:10 - -Rule sol89 1989 only - Aug 12 12:05:00s -0:05:00 - -Rule sol89 1989 only - Aug 13 12:04:50s -0:04:50 - -Rule sol89 1989 only - Aug 14 12:04:40s -0:04:40 - -Rule sol89 1989 only - Aug 15 12:04:30s -0:04:30 - -Rule sol89 1989 only - Aug 16 12:04:15s -0:04:15 - -Rule sol89 1989 only - Aug 17 12:04:05s -0:04:05 - -Rule sol89 1989 only - Aug 18 12:03:50s -0:03:50 - -Rule sol89 1989 only - Aug 19 12:03:35s -0:03:35 - -Rule sol89 1989 only - Aug 20 12:03:25s -0:03:25 - -Rule sol89 1989 only - Aug 21 12:03:10s -0:03:10 - -Rule sol89 1989 only - Aug 22 12:02:55s -0:02:55 - -Rule sol89 1989 only - Aug 23 12:02:40s -0:02:40 - -Rule sol89 1989 only - Aug 24 12:02:20s -0:02:20 - -Rule sol89 1989 only - Aug 25 12:02:05s -0:02:05 - -Rule sol89 1989 only - Aug 26 12:01:50s -0:01:50 - -Rule sol89 1989 only - Aug 27 12:01:30s -0:01:30 - -Rule sol89 1989 only - Aug 28 12:01:15s -0:01:15 - -Rule sol89 1989 only - Aug 29 12:00:55s -0:00:55 - -Rule sol89 1989 only - Aug 30 12:00:40s -0:00:40 - -Rule sol89 1989 only - Aug 31 12:00:20s -0:00:20 - -Rule sol89 1989 only - Sep 1 12:00:00s 0:00:00 - -Rule sol89 1989 only - Sep 2 11:59:45s 0:00:15 - -Rule sol89 1989 only - Sep 3 11:59:25s 0:00:35 - -Rule sol89 1989 only - Sep 4 11:59:05s 0:00:55 - -Rule sol89 1989 only - Sep 5 11:58:45s 0:01:15 - -Rule sol89 1989 only - Sep 6 11:58:25s 0:01:35 - -Rule sol89 1989 only - Sep 7 11:58:05s 0:01:55 - -Rule sol89 1989 only - Sep 8 11:57:45s 0:02:15 - -Rule sol89 1989 only - Sep 9 11:57:20s 0:02:40 - -Rule sol89 1989 only - Sep 10 11:57:00s 0:03:00 - -Rule sol89 1989 only - Sep 11 11:56:40s 0:03:20 - -Rule sol89 1989 only - Sep 12 11:56:20s 0:03:40 - -Rule sol89 1989 only - Sep 13 11:56:00s 0:04:00 - -Rule sol89 1989 only - Sep 14 11:55:35s 0:04:25 - -Rule sol89 1989 only - Sep 15 11:55:15s 0:04:45 - -Rule sol89 1989 only - Sep 16 11:54:55s 0:05:05 - -Rule sol89 1989 only - Sep 17 11:54:35s 0:05:25 - -Rule sol89 1989 only - Sep 18 11:54:10s 0:05:50 - -Rule sol89 1989 only - Sep 19 11:53:50s 0:06:10 - -Rule sol89 1989 only - Sep 20 11:53:30s 0:06:30 - -Rule sol89 1989 only - Sep 21 11:53:10s 0:06:50 - -Rule sol89 1989 only - Sep 22 11:52:45s 0:07:15 - -Rule sol89 1989 only - Sep 23 11:52:25s 0:07:35 - -Rule sol89 1989 only - Sep 24 11:52:05s 0:07:55 - -Rule sol89 1989 only - Sep 25 11:51:45s 0:08:15 - -Rule sol89 1989 only - Sep 26 11:51:25s 0:08:35 - -Rule sol89 1989 only - Sep 27 11:51:05s 0:08:55 - -Rule sol89 1989 only - Sep 28 11:50:40s 0:09:20 - -Rule sol89 1989 only - Sep 29 11:50:20s 0:09:40 - -Rule sol89 1989 only - Sep 30 11:50:00s 0:10:00 - -Rule sol89 1989 only - Oct 1 11:49:45s 0:10:15 - -Rule sol89 1989 only - Oct 2 11:49:25s 0:10:35 - -Rule sol89 1989 only - Oct 3 11:49:05s 0:10:55 - -Rule sol89 1989 only - Oct 4 11:48:45s 0:11:15 - -Rule sol89 1989 only - Oct 5 11:48:30s 0:11:30 - -Rule sol89 1989 only - Oct 6 11:48:10s 0:11:50 - -Rule sol89 1989 only - Oct 7 11:47:50s 0:12:10 - -Rule sol89 1989 only - Oct 8 11:47:35s 0:12:25 - -Rule sol89 1989 only - Oct 9 11:47:20s 0:12:40 - -Rule sol89 1989 only - Oct 10 11:47:00s 0:13:00 - -Rule sol89 1989 only - Oct 11 11:46:45s 0:13:15 - -Rule sol89 1989 only - Oct 12 11:46:30s 0:13:30 - -Rule sol89 1989 only - Oct 13 11:46:15s 0:13:45 - -Rule sol89 1989 only - Oct 14 11:46:00s 0:14:00 - -Rule sol89 1989 only - Oct 15 11:45:50s 0:14:10 - -Rule sol89 1989 only - Oct 16 11:45:35s 0:14:25 - -Rule sol89 1989 only - Oct 17 11:45:20s 0:14:40 - -Rule sol89 1989 only - Oct 18 11:45:10s 0:14:50 - -Rule sol89 1989 only - Oct 19 11:45:00s 0:15:00 - -Rule sol89 1989 only - Oct 20 11:44:50s 0:15:10 - -Rule sol89 1989 only - Oct 21 11:44:40s 0:15:20 - -Rule sol89 1989 only - Oct 22 11:44:30s 0:15:30 - -Rule sol89 1989 only - Oct 23 11:44:20s 0:15:40 - -Rule sol89 1989 only - Oct 24 11:44:10s 0:15:50 - -Rule sol89 1989 only - Oct 25 11:44:05s 0:15:55 - -Rule sol89 1989 only - Oct 26 11:44:00s 0:16:00 - -Rule sol89 1989 only - Oct 27 11:43:50s 0:16:10 - -Rule sol89 1989 only - Oct 28 11:43:45s 0:16:15 - -Rule sol89 1989 only - Oct 29 11:43:40s 0:16:20 - -Rule sol89 1989 only - Oct 30 11:43:40s 0:16:20 - -Rule sol89 1989 only - Oct 31 11:43:35s 0:16:25 - -Rule sol89 1989 only - Nov 1 11:43:35s 0:16:25 - -Rule sol89 1989 only - Nov 2 11:43:35s 0:16:25 - -Rule sol89 1989 only - Nov 3 11:43:30s 0:16:30 - -Rule sol89 1989 only - Nov 4 11:43:35s 0:16:25 - -Rule sol89 1989 only - Nov 5 11:43:35s 0:16:25 - -Rule sol89 1989 only - Nov 6 11:43:35s 0:16:25 - -Rule sol89 1989 only - Nov 7 11:43:40s 0:16:20 - -Rule sol89 1989 only - Nov 8 11:43:45s 0:16:15 - -Rule sol89 1989 only - Nov 9 11:43:50s 0:16:10 - -Rule sol89 1989 only - Nov 10 11:43:55s 0:16:05 - -Rule sol89 1989 only - Nov 11 11:44:00s 0:16:00 - -Rule sol89 1989 only - Nov 12 11:44:05s 0:15:55 - -Rule sol89 1989 only - Nov 13 11:44:15s 0:15:45 - -Rule sol89 1989 only - Nov 14 11:44:25s 0:15:35 - -Rule sol89 1989 only - Nov 15 11:44:35s 0:15:25 - -Rule sol89 1989 only - Nov 16 11:44:45s 0:15:15 - -Rule sol89 1989 only - Nov 17 11:44:55s 0:15:05 - -Rule sol89 1989 only - Nov 18 11:45:10s 0:14:50 - -Rule sol89 1989 only - Nov 19 11:45:20s 0:14:40 - -Rule sol89 1989 only - Nov 20 11:45:35s 0:14:25 - -Rule sol89 1989 only - Nov 21 11:45:50s 0:14:10 - -Rule sol89 1989 only - Nov 22 11:46:05s 0:13:55 - -Rule sol89 1989 only - Nov 23 11:46:25s 0:13:35 - -Rule sol89 1989 only - Nov 24 11:46:40s 0:13:20 - -Rule sol89 1989 only - Nov 25 11:47:00s 0:13:00 - -Rule sol89 1989 only - Nov 26 11:47:20s 0:12:40 - -Rule sol89 1989 only - Nov 27 11:47:35s 0:12:25 - -Rule sol89 1989 only - Nov 28 11:47:55s 0:12:05 - -Rule sol89 1989 only - Nov 29 11:48:20s 0:11:40 - -Rule sol89 1989 only - Nov 30 11:48:40s 0:11:20 - -Rule sol89 1989 only - Dec 1 11:49:00s 0:11:00 - -Rule sol89 1989 only - Dec 2 11:49:25s 0:10:35 - -Rule sol89 1989 only - Dec 3 11:49:50s 0:10:10 - -Rule sol89 1989 only - Dec 4 11:50:15s 0:09:45 - -Rule sol89 1989 only - Dec 5 11:50:35s 0:09:25 - -Rule sol89 1989 only - Dec 6 11:51:00s 0:09:00 - -Rule sol89 1989 only - Dec 7 11:51:30s 0:08:30 - -Rule sol89 1989 only - Dec 8 11:51:55s 0:08:05 - -Rule sol89 1989 only - Dec 9 11:52:20s 0:07:40 - -Rule sol89 1989 only - Dec 10 11:52:50s 0:07:10 - -Rule sol89 1989 only - Dec 11 11:53:15s 0:06:45 - -Rule sol89 1989 only - Dec 12 11:53:45s 0:06:15 - -Rule sol89 1989 only - Dec 13 11:54:10s 0:05:50 - -Rule sol89 1989 only - Dec 14 11:54:40s 0:05:20 - -Rule sol89 1989 only - Dec 15 11:55:10s 0:04:50 - -Rule sol89 1989 only - Dec 16 11:55:40s 0:04:20 - -Rule sol89 1989 only - Dec 17 11:56:05s 0:03:55 - -Rule sol89 1989 only - Dec 18 11:56:35s 0:03:25 - -Rule sol89 1989 only - Dec 19 11:57:05s 0:02:55 - -Rule sol89 1989 only - Dec 20 11:57:35s 0:02:25 - -Rule sol89 1989 only - Dec 21 11:58:05s 0:01:55 - -Rule sol89 1989 only - Dec 22 11:58:35s 0:01:25 - -Rule sol89 1989 only - Dec 23 11:59:05s 0:00:55 - -Rule sol89 1989 only - Dec 24 11:59:35s 0:00:25 - -Rule sol89 1989 only - Dec 25 12:00:05s -0:00:05 - -Rule sol89 1989 only - Dec 26 12:00:35s -0:00:35 - -Rule sol89 1989 only - Dec 27 12:01:05s -0:01:05 - -Rule sol89 1989 only - Dec 28 12:01:35s -0:01:35 - -Rule sol89 1989 only - Dec 29 12:02:00s -0:02:00 - -Rule sol89 1989 only - Dec 30 12:02:30s -0:02:30 - -Rule sol89 1989 only - Dec 31 12:03:00s -0:03:00 - - -# Riyadh is at about 46 degrees 46 minutes East: 3 hrs, 7 mins, 4 secs -# Before and after 1989, we'll operate on local mean solar time. - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -Zone Asia/Riyadh89 3:07:04 - zzz 1989 - 3:07:04 sol89 zzz 1990 - 3:07:04 - zzz -# For backward compatibility... -Link Asia/Riyadh89 Mideast/Riyadh89 diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/southamerica b/src/test/jdk/sun/util/calendar/zi/tzdata/southamerica deleted file mode 100644 index 3f016479a75..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/southamerica +++ /dev/null @@ -1,1989 +0,0 @@ -# -# 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. -# -# tzdb data for South America and environs - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# This file is by no means authoritative; if you think you know better, -# go ahead and edit the file (and please send any changes to -# tz@iana.org for general use in the future). For more, please see -# the file CONTRIBUTING in the tz distribution. - -# From Paul Eggert (2016-12-05): -# -# Unless otherwise specified, the source for data through 1990 is: -# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), -# San Diego: ACS Publications, Inc. (2003). -# Unfortunately this book contains many errors and cites no sources. -# -# Many years ago Gwillim Law wrote that a good source -# for time zone data was the International Air Transport -# Association's Standard Schedules Information Manual (IATA SSIM), -# published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. Except where otherwise noted, -# IATA SSIM is the source for entries after 1990. -# -# For data circa 1899, a common source is: -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# https://www.jstor.org/stable/1774359 -# -# These tables use numeric abbreviations like -03 and -0330 for -# integer hour and minute UT offsets. Although earlier editions used -# alphabetic time zone abbreviations, these abbreviations were -# invented and did not reflect common practice. - -############################################################################### - -############################################################################### - -# Argentina - -# From Bob Devine (1988-01-28): -# Argentina: first Sunday in October to first Sunday in April since 1976. -# Double Summer time from 1969 to 1974. Switches at midnight. - -# From U. S. Naval Observatory (1988-01-19): -# ARGENTINA 3 H BEHIND UTC - -# From Hernan G. Otero (1995-06-26): -# I am sending modifications to the Argentine time zone table... -# AR was chosen because they are the ISO letters that represent Argentina. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Arg 1930 only - Dec 1 0:00 1:00 - -Rule Arg 1931 only - Apr 1 0:00 0 - -Rule Arg 1931 only - Oct 15 0:00 1:00 - -Rule Arg 1932 1940 - Mar 1 0:00 0 - -Rule Arg 1932 1939 - Nov 1 0:00 1:00 - -Rule Arg 1940 only - Jul 1 0:00 1:00 - -Rule Arg 1941 only - Jun 15 0:00 0 - -Rule Arg 1941 only - Oct 15 0:00 1:00 - -Rule Arg 1943 only - Aug 1 0:00 0 - -Rule Arg 1943 only - Oct 15 0:00 1:00 - -Rule Arg 1946 only - Mar 1 0:00 0 - -Rule Arg 1946 only - Oct 1 0:00 1:00 - -Rule Arg 1963 only - Oct 1 0:00 0 - -Rule Arg 1963 only - Dec 15 0:00 1:00 - -Rule Arg 1964 1966 - Mar 1 0:00 0 - -Rule Arg 1964 1966 - Oct 15 0:00 1:00 - -Rule Arg 1967 only - Apr 2 0:00 0 - -Rule Arg 1967 1968 - Oct Sun>=1 0:00 1:00 - -Rule Arg 1968 1969 - Apr Sun>=1 0:00 0 - -Rule Arg 1974 only - Jan 23 0:00 1:00 - -Rule Arg 1974 only - May 1 0:00 0 - -Rule Arg 1988 only - Dec 1 0:00 1:00 - -# -# From Hernan G. Otero (1995-06-26): -# These corrections were contributed by InterSoft Argentina S.A., -# obtaining the data from the: -# Talleres de Hidrografía Naval Argentina -# (Argentine Naval Hydrography Institute) -Rule Arg 1989 1993 - Mar Sun>=1 0:00 0 - -Rule Arg 1989 1992 - Oct Sun>=15 0:00 1:00 - -# -# From Hernan G. Otero (1995-06-26): -# From this moment on, the law that mandated the daylight saving -# time corrections was derogated and no more modifications -# to the time zones (for daylight saving) are now made. -# -# From Rives McDow (2000-01-10): -# On October 3, 1999, 0:00 local, Argentina implemented daylight savings time, -# which did not result in the switch of a time zone, as they stayed 9 hours -# from the International Date Line. -Rule Arg 1999 only - Oct Sun>=1 0:00 1:00 - -# From Paul Eggert (2007-12-28): -# DST was set to expire on March 5, not March 3, but since it was converted -# to standard time on March 3 it's more convenient for us to pretend that -# it ended on March 3. -Rule Arg 2000 only - Mar 3 0:00 0 - -# -# From Peter Gradelski via Steffen Thorsen (2000-03-01): -# We just checked with our São Paulo office and they say the government of -# Argentina decided not to become one of the countries that go on or off DST. -# So Buenos Aires should be -3 hours from GMT at all times. -# -# From Fabián L. Arce Jofré (2000-04-04): -# The law that claimed DST for Argentina was derogated by President Fernando -# de la Rúa on March 2, 2000, because it would make people spend more energy -# in the winter time, rather than less. The change took effect on March 3. -# -# From Mariano Absatz (2001-06-06): -# one of the major newspapers here in Argentina said that the 1999 -# Timezone Law (which never was effectively applied) will (would?) be -# in effect.... The article is at -# http://ar.clarin.com/diario/2001-06-06/e-01701.htm -# ... The Law itself is "Ley No. 25155", sanctioned on 1999-08-25, enacted -# 1999-09-17, and published 1999-09-21. The official publication is at: -# http://www.boletin.jus.gov.ar/BON/Primera/1999/09-Septiembre/21/PDF/BO21-09-99LEG.PDF -# Regretfully, you have to subscribe (and pay) for the on-line version.... -# -# (2001-06-12): -# the timezone for Argentina will not change next Sunday. -# Apparently it will do so on Sunday 24th.... -# http://ar.clarin.com/diario/2001-06-12/s-03501.htm -# -# (2001-06-25): -# Last Friday (yes, the last working day before the date of the change), the -# Senate annulled the 1999 law that introduced the changes later postponed. -# http://www.clarin.com.ar/diario/2001-06-22/s-03601.htm -# It remains the vote of the Deputies..., but it will be the same.... -# This kind of things had always been done this way in Argentina. -# We are still -03:00 all year round in all of the country. -# -# From Steffen Thorsen (2007-12-21): -# A user (Leonardo Chaim) reported that Argentina will adopt DST.... -# all of the country (all Zone-entries) are affected. News reports like -# http://www.lanacion.com.ar/opinion/nota.asp?nota_id=973037 indicate -# that Argentina will use DST next year as well, from October to -# March, although exact rules are not given. -# -# From Jesper Nørgaard Welen (2007-12-26) -# The last hurdle of Argentina DST is over, the proposal was approved in -# the lower chamber too (Diputados) with a vote 192 for and 2 against. -# By the way thanks to Mariano Absatz and Daniel Mario Vega for the link to -# the original scanned proposal, where the dates and the zero hours are -# clear and unambiguous...This is the article about final approval: -# http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996 -# -# From Paul Eggert (2007-12-22): -# For dates after mid-2008, the following rules are my guesses and -# are quite possibly wrong, but are more likely than no DST at all. - -# From Alexander Krivenyshev (2008-09-05): -# As per message from Carlos Alberto Fonseca Arauz (Nicaragua), -# Argentina will start DST on Sunday October 19, 2008. -# -# http://www.worldtimezone.com/dst_news/dst_news_argentina03.html -# http://www.impulsobaires.com.ar/nota.php?id=57832 (in spanish) - -# From Juan Manuel Docile in https://bugs.gentoo.org/240339 (2008-10-07) -# via Rodrigo Severo: -# Argentinian law No. 25.155 is no longer valid. -# http://www.infoleg.gov.ar/infolegInternet/anexos/60000-64999/60036/norma.htm -# The new one is law No. 26.350 -# http://www.infoleg.gov.ar/infolegInternet/anexos/135000-139999/136191/norma.htm -# So there is no summer time in Argentina for now. - -# From Mariano Absatz (2008-10-20): -# Decree 1693/2008 applies Law 26.350 for the summer 2008/2009 establishing DST -# in Argentina from 2008-10-19 until 2009-03-15. -# http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=16102008&pi=3&pf=4&s=0&sec=01 -# - -# Decree 1705/2008 excepting 12 Provinces from applying DST in the summer -# 2008/2009: Catamarca, La Rioja, Mendoza, Salta, San Juan, San Luis, La -# Pampa, Neuquén, Rio Negro, Chubut, Santa Cruz and Tierra del Fuego -# http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=17102008&pi=1&pf=1&s=0&sec=01 -# -# Press release 235 dated Saturday October 18th, from the Government of the -# Province of Jujuy saying it will not apply DST either (even when it was not -# included in Decree 1705/2008). -# http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc - -# From fullinet (2009-10-18): -# As announced in -# http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356 -# (an official .gob.ar) under title: "Sin Cambio de Hora" -# (English: "No hour change"). -# -# "Por el momento, el Gobierno Nacional resolvió no modificar la hora -# oficial, decisión que estaba en estudio para su implementación el -# domingo 18 de octubre. Desde el Ministerio de Planificación se anunció -# que la Argentina hoy, en estas condiciones meteorológicas, no necesita -# la modificación del huso horario, ya que 2009 nos encuentra con -# crecimiento en la producción y distribución energética." - -Rule Arg 2007 only - Dec 30 0:00 1:00 - -Rule Arg 2008 2009 - Mar Sun>=15 0:00 0 - -Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 - - -# From Mariano Absatz (2004-05-21): -# Today it was officially published that the Province of Mendoza is changing -# its timezone this winter... starting tomorrow night.... -# http://www.gobernac.mendoza.gov.ar/boletin/pdf/20040521-27158-normas.pdf -# From Paul Eggert (2004-05-24): -# It's Law No. 7,210. This change is due to a public power emergency, so for -# now we'll assume it's for this year only. -# -# From Paul Eggert (2018-01-31): -# Hora de verano para la República Argentina -# http://buenasiembra.com.ar/esoterismo/astrologia/hora-de-verano-de-la-republica-argentina-27.html -# says that standard time in Argentina from 1894-10-31 -# to 1920-05-01 was -4:16:48.25. Go with this more-precise value -# over Shanks & Pottenger. It is upward compatible with Milne, who -# says Córdoba time was -4:16:48.2. - -# -# From Mariano Absatz (2004-06-05): -# These media articles from a major newspaper mostly cover the current state: -# http://www.lanacion.com.ar/04/05/27/de_604825.asp -# http://www.lanacion.com.ar/04/05/28/de_605203.asp -# -# The following eight (8) provinces pulled clocks back to UTC-04:00 at -# midnight Monday May 31st. (that is, the night between 05/31 and 06/01). -# Apparently, all nine provinces would go back to UTC-03:00 at the same -# time in October 17th. -# -# Catamarca, Chubut, La Rioja, San Juan, San Luis, Santa Cruz, -# Tierra del Fuego, Tucumán. -# -# From Mariano Absatz (2004-06-14): -# ... this weekend, the Province of Tucumán decided it'd go back to UTC-03:00 -# yesterday midnight (that is, at 24:00 Saturday 12th), since the people's -# annoyance with the change is much higher than the power savings obtained.... -# -# From Gwillim Law (2004-06-14): -# http://www.lanacion.com.ar/04/06/10/de_609078.asp ... -# "The time change in Tierra del Fuego was a conflicted decision from -# the start. The government had decreed that the measure would take -# effect on June 1, but a normative error forced the new time to begin -# three days earlier, from a Saturday to a Sunday.... -# Our understanding was that the change was originally scheduled to take place -# on June 1 at 00:00 in Chubut, Santa Cruz, Tierra del Fuego (and some other -# provinces). Sunday was May 30, only two days earlier. So the article -# contains a contradiction. I would give more credence to the Saturday/Sunday -# date than the "three days earlier" phrase, and conclude that Tierra del -# Fuego set its clocks back at 2004-05-30 00:00. -# -# From Steffen Thorsen (2004-10-05): -# The previous law 7210 which changed the province of Mendoza's time zone -# back in May have been modified slightly in a new law 7277, which set the -# new end date to 2004-09-26 (original date was 2004-10-17). -# http://www.gobernac.mendoza.gov.ar/boletin/pdf/20040924-27244-normas.pdf -# -# From Mariano Absatz (2004-10-05): -# San Juan changed from UTC-03:00 to UTC-04:00 at midnight between -# Sunday, May 30th and Monday, May 31st. It changed back to UTC-03:00 -# at midnight between Saturday, July 24th and Sunday, July 25th.... -# http://www.sanjuan.gov.ar/prensa/archivo/000329.html -# http://www.sanjuan.gov.ar/prensa/archivo/000426.html -# http://www.sanjuan.gov.ar/prensa/archivo/000441.html - -# From Alex Krivenyshev (2008-01-17): -# Here are articles that Argentina Province San Luis is planning to end DST -# as earlier as upcoming Monday January 21, 2008 or February 2008: -# -# Provincia argentina retrasa reloj y marca diferencia con resto del país -# (Argentine Province delayed clock and mark difference with the rest of the -# country) -# http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel -# -# Es inminente que en San Luis atrasen una hora los relojes -# (It is imminent in San Luis clocks one hour delay) -# https://www.lagaceta.com.ar/nota/253414/Economia/Es-inminente-que-en-San-Luis-atrasen-una-hora-los-relojes.html -# http://www.worldtimezone.com/dst_news/dst_news_argentina02.html - -# From Jesper Nørgaard Welen (2008-01-18): -# The page of the San Luis provincial government -# http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812 -# confirms what Alex Krivenyshev has earlier sent to the tz -# emailing list about that San Luis plans to return to standard -# time much earlier than the rest of the country. It also -# confirms that upon request the provinces San Juan and Mendoza -# refused to follow San Luis in this change. -# -# The change is supposed to take place Monday the 21st at 0:00 -# hours. As far as I understand it if this goes ahead, we need -# a new timezone for San Luis (although there are also documented -# independent changes in the southamerica file of San Luis in -# 1990 and 1991 which has not been confirmed). - -# From Jesper Nørgaard Welen (2008-01-25): -# Unfortunately the below page has become defunct, about the San Luis -# time change. Perhaps because it now is part of a group of pages "Most -# important pages of 2008." -# -# You can use -# http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834 -# instead it seems. Or use "Buscador" from the main page of the San Luis -# government, and fill in "huso" and click OK, and you will get 3 pages -# from which the first one is identical to the above. - -# From Mariano Absatz (2008-01-28): -# I can confirm that the Province of San Luis (and so far only that -# province) decided to go back to UTC-3 effective midnight Jan 20th 2008 -# (that is, Monday 21st at 0:00 is the time the clocks were delayed back -# 1 hour), and they intend to keep UTC-3 as their timezone all year round -# (that is, unless they change their mind any minute now). -# -# So we'll have to add yet another city to 'southamerica' (I think San -# Luis city is the mos populated city in the Province, so it'd be -# America/Argentina/San_Luis... of course I can't remember if San Luis's -# history of particular changes goes along with Mendoza or San Juan :-( -# (I only remember not being able to collect hard facts about San Luis -# back in 2004, when these provinces changed to UTC-4 for a few days, I -# mailed them personally and never got an answer). - -# From Paul Eggert (2014-08-12): -# Unless otherwise specified, data entries are from Shanks & Pottenger through -# 1992, from the IATA otherwise. As noted below, Shanks & Pottenger say that -# America/Cordoba split into 6 subregions during 1991/1992, one of which -# was America/San_Luis, but we haven't verified this yet so for now we'll -# keep America/Cordoba a single region rather than splitting it into the -# other 5 subregions. - -# From Mariano Absatz (2009-03-13): -# Yesterday (with our usual 2-day notice) the Province of San Luis -# decided that next Sunday instead of "staying" @utc-03:00 they will go -# to utc-04:00 until the second Saturday in October... -# -# The press release is at -# http://www.sanluis.gov.ar/SL/Paginas/NoticiaDetalle.asp?TemaId=1&InfoPrensaId=3102 -# (I couldn't find the decree, but www.sanluis.gov.ar -# is the official page for the Province Government.) -# -# There's also a note in only one of the major national papers ... -# http://www.lanacion.com.ar/nota.asp?nota_id=1107912 -# -# The press release says [quick and dirty translation]: -# ... announced that next Sunday, at 00:00, Puntanos (the San Luis -# inhabitants) will have to turn back one hour their clocks -# -# Since then, San Luis will establish its own Province timezone. Thus, -# during 2009, this timezone change will run from 00:00 the third Sunday -# in March until 24:00 of the second Saturday in October. - -# From Mariano Absatz (2009-10-16): -# ...the Province of San Luis is a case in itself. -# -# The Law at -# http://www.diputadossanluis.gov.ar/diputadosasp/paginas/verNorma.asp?NormaID=276 -# is ambiguous because establishes a calendar from the 2nd Sunday in -# October at 0:00 thru the 2nd Saturday in March at 24:00 and the -# complement of that starting on the 2nd Sunday of March at 0:00 and -# ending on the 2nd Saturday of March at 24:00. -# -# This clearly breaks every time the 1st of March or October is a Sunday. -# -# IMHO, the "spirit of the Law" is to make the changes at 0:00 on the 2nd -# Sunday of October and March. -# -# The problem is that the changes in the rest of the Provinces that did -# change in 2007/2008, were made according to the Federal Law and Decrees -# that did so on the 3rd Sunday of October and March. -# -# In fact, San Luis actually switched from UTC-4 to UTC-3 last Sunday -# (October 11th) at 0:00. -# -# So I guess a new set of rules, besides "Arg", must be made and the last -# America/Argentina/San_Luis entries should change to use these... -# ... - -# From Alexander Krivenyshev (2010-04-09): -# According to news reports from El Diario de la República Province San -# Luis, Argentina (standard time UTC-04) will keep Daylight Saving Time -# after April 11, 2010 - will continue to have same time as rest of -# Argentina (UTC-3) (no DST). -# -# Confirmaron la prórroga del huso horario de verano (Spanish) -# http://www.eldiariodelarepublica.com/index.php?option=com_content&task=view&id=29383&Itemid=9 -# or (some English translation): -# http://www.worldtimezone.com/dst_news/dst_news_argentina08.html - -# From Mariano Absatz (2010-04-12): -# yes...I can confirm this...and given that San Luis keeps calling -# UTC-03:00 "summer time", we should't just let San Luis go back to "Arg" -# rules...San Luis is still using "Western ARgentina Time" and it got -# stuck on Summer daylight savings time even though the summer is over. - -# From Paul Eggert (2018-01-23): -# Perhaps San Luis operates on the legal fiction that it is at -04 -# with perpetual daylight saving time, but ordinary usage typically seems to -# just say it's at -03; see, for example, -# https://es.wikipedia.org/wiki/Hora_oficial_argentina -# We've documented similar situations as being plain changes to -# standard time, so let's do that here too. This does not change UTC -# offsets, only tm_isdst and the time zone abbreviations. One minor -# plus is that this silences a zic complaint that there's no POSIX TZ -# setting for timestamps past 2038. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# -# Buenos Aires (BA), Capital Federal (CF), -Zone America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May # Córdoba Mean Time - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 Arg -03/-02 -# -# Córdoba (CB), Santa Fe (SF), Entre Ríos (ER), Corrientes (CN), Misiones (MN), -# Chaco (CC), Formosa (FM), Santiago del Estero (SE) -# -# Shanks & Pottenger also make the following claims, which we haven't verified: -# - Formosa switched to -3:00 on 1991-01-07. -# - Misiones switched to -3:00 on 1990-12-29. -# - Chaco switched to -3:00 on 1991-01-04. -# - Santiago del Estero switched to -4:00 on 1991-04-01, -# then to -3:00 on 1991-04-26. -# -Zone America/Argentina/Cordoba -4:16:48 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1991 Mar 3 - -4:00 - -04 1991 Oct 20 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 Arg -03/-02 -# -# Salta (SA), La Pampa (LP), Neuquén (NQ), Rio Negro (RN) -Zone America/Argentina/Salta -4:21:40 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1991 Mar 3 - -4:00 - -04 1991 Oct 20 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# Tucumán (TM) -Zone America/Argentina/Tucuman -4:20:52 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1991 Mar 3 - -4:00 - -04 1991 Oct 20 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 Jun 1 - -4:00 - -04 2004 Jun 13 - -3:00 Arg -03/-02 -# -# La Rioja (LR) -Zone America/Argentina/La_Rioja -4:27:24 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1991 Mar 1 - -4:00 - -04 1991 May 7 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 Jun 1 - -4:00 - -04 2004 Jun 20 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# San Juan (SJ) -Zone America/Argentina/San_Juan -4:34:04 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1991 Mar 1 - -4:00 - -04 1991 May 7 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 May 31 - -4:00 - -04 2004 Jul 25 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# Jujuy (JY) -Zone America/Argentina/Jujuy -4:21:12 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1990 Mar 4 - -4:00 - -04 1990 Oct 28 - -4:00 1:00 -03 1991 Mar 17 - -4:00 - -04 1991 Oct 6 - -3:00 1:00 -02 1992 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# Catamarca (CT), Chubut (CH) -Zone America/Argentina/Catamarca -4:23:08 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1991 Mar 3 - -4:00 - -04 1991 Oct 20 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 Jun 1 - -4:00 - -04 2004 Jun 20 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# Mendoza (MZ) -Zone America/Argentina/Mendoza -4:35:16 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1990 Mar 4 - -4:00 - -04 1990 Oct 15 - -4:00 1:00 -03 1991 Mar 1 - -4:00 - -04 1991 Oct 15 - -4:00 1:00 -03 1992 Mar 1 - -4:00 - -04 1992 Oct 18 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 May 23 - -4:00 - -04 2004 Sep 26 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# San Luis (SL) - -Rule SanLuis 2008 2009 - Mar Sun>=8 0:00 0 - -Rule SanLuis 2007 2008 - Oct Sun>=8 0:00 1:00 - - -Zone America/Argentina/San_Luis -4:25:24 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1990 - -3:00 1:00 -02 1990 Mar 14 - -4:00 - -04 1990 Oct 15 - -4:00 1:00 -03 1991 Mar 1 - -4:00 - -04 1991 Jun 1 - -3:00 - -03 1999 Oct 3 - -4:00 1:00 -03 2000 Mar 3 - -3:00 - -03 2004 May 31 - -4:00 - -04 2004 Jul 25 - -3:00 Arg -03/-02 2008 Jan 21 - -4:00 SanLuis -04/-03 2009 Oct 11 - -3:00 - -03 -# -# Santa Cruz (SC) -Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 Jun 1 - -4:00 - -04 2004 Jun 20 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 -# -# Tierra del Fuego, Antártida e Islas del Atlántico Sur (TF) -Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31 - -4:16:48 - CMT 1920 May - -4:00 - -04 1930 Dec - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1999 Oct 3 - -4:00 Arg -04/-03 2000 Mar 3 - -3:00 - -03 2004 May 30 - -4:00 - -04 2004 Jun 20 - -3:00 Arg -03/-02 2008 Oct 18 - -3:00 - -03 - -# Aruba -Link America/Curacao America/Aruba - -# Bolivia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/La_Paz -4:32:36 - LMT 1890 - -4:32:36 - CMT 1931 Oct 15 # Calamarca MT - -4:32:36 1:00 BST 1932 Mar 21 # Bolivia ST - -4:00 - -04 - -# Brazil - -# From Paul Eggert (1993-11-18): -# The mayor of Rio recently attempted to change the time zone rules -# just in his city, in order to leave more summer time for the tourist trade. -# The rule change lasted only part of the day; -# the federal government refused to follow the city's rules, and business -# was in a chaos, so the mayor backed down that afternoon. - -# From IATA SSIM (1996-02): -# _Only_ the following states in BR1 observe DST: Rio Grande do Sul (RS), -# Santa Catarina (SC), Paraná (PR), São Paulo (SP), Rio de Janeiro (RJ), -# Espírito Santo (ES), Minas Gerais (MG), Bahia (BA), Goiás (GO), -# Distrito Federal (DF), Tocantins (TO), Sergipe [SE] and Alagoas [AL]. -# [The last three states are new to this issue of the IATA SSIM.] - -# From Gwillim Law (1996-10-07): -# Geography, history (Tocantins was part of Goiás until 1989), and other -# sources of time zone information lead me to believe that AL, SE, and TO were -# always in BR1, and so the only change was whether or not they observed DST.... -# The earliest issue of the SSIM I have is 2/91. Each issue from then until -# 9/95 says that DST is observed only in the ten states I quoted from 9/95, -# along with Mato Grosso (MT) and Mato Grosso do Sul (MS), which are in BR2 -# (UTC-4).... The other two time zones given for Brazil are BR3, which is -# UTC-5, no DST, and applies only in the state of Acre (AC); and BR4, which is -# UTC-2, and applies to Fernando de Noronha (formerly FN, but I believe it's -# become part of the state of Pernambuco). The boundary between BR1 and BR2 -# has never been clearly stated. They've simply been called East and West. -# However, some conclusions can be drawn from another IATA manual: the Airline -# Coding Directory, which lists close to 400 airports in Brazil. For each -# airport it gives a time zone which is coded to the SSIM. From that -# information, I'm led to conclude that the states of Amapá (AP), Ceará (CE), -# Maranhão (MA), Paraíba (PR), Pernambuco (PE), Piauí (PI), and Rio Grande do -# Norte (RN), and the eastern part of Pará (PA) are all in BR1 without DST. - -# From Marcos Tadeu (1998-09-27): -# Brazilian official page <http://pcdsh01.on.br/verao1.html> - -# From Jesper Nørgaard (2000-11-03): -# [For an official list of which regions in Brazil use which time zones, see:] -# http://pcdsh01.on.br/Fusbr.htm -# http://pcdsh01.on.br/Fusbrhv.htm - -# From Celso Doria via David Madeo (2002-10-09): -# The reason for the delay this year has to do with elections in Brazil. -# -# Unlike in the United States, elections in Brazil are 100% computerized and -# the results are known almost immediately. Yesterday, it was the first -# round of the elections when 115 million Brazilians voted for President, -# Governor, Senators, Federal Deputies, and State Deputies. Nobody is -# counting (or re-counting) votes anymore and we know there will be a second -# round for the Presidency and also for some Governors. The 2nd round will -# take place on October 27th. -# -# The reason why the DST will only begin November 3rd is that the thousands -# of electoral machines used cannot have their time changed, and since the -# Constitution says the elections must begin at 8:00 AM and end at 5:00 PM, -# the Government decided to postpone DST, instead of changing the Constitution -# (maybe, for the next elections, it will be possible to change the clock)... - -# From Rodrigo Severo (2004-10-04): -# It's just the biannual change made necessary by the much hyped, supposedly -# modern Brazilian eletronic voting machines which, apparently, can't deal -# with a time change between the first and the second rounds of the elections. - -# From Steffen Thorsen (2007-09-20): -# Brazil will start DST on 2007-10-14 00:00 and end on 2008-02-17 00:00: -# http://www.mme.gov.br/site/news/detail.do;jsessionid=BBA06811AFCAAC28F0285210913513DA?newsId=13975 - -# From Paul Schulze (2008-06-24): -# ...by law number 11.662 of April 24, 2008 (published in the "Diario -# Oficial da União"...) in Brazil there are changes in the timezones, -# effective today (00:00am at June 24, 2008) as follows: -# -# a) The timezone UTC+5 is extinguished, with all the Acre state and the -# part of the Amazonas state that had this timezone now being put to the -# timezone UTC+4 -# b) The whole Pará state now is put at timezone UTC+3, instead of just -# part of it, as was before. -# -# This change follows a proposal of senator Tiao Viana of Acre state, that -# proposed it due to concerns about open television channels displaying -# programs inappropriate to youths in the states that had the timezone -# UTC+5 too early in the night. In the occasion, some more corrections -# were proposed, trying to unify the timezones of any given state. This -# change modifies timezone rules defined in decree 2.784 of 18 June, -# 1913. - -# From Rodrigo Severo (2008-06-24): -# Just correcting the URL: -# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=do&secao=1&pagina=1&data=25/04/2008 -# -# As a result of the above Decree I believe the America/Rio_Branco -# timezone shall be modified from UTC-5 to UTC-4 and a new timezone shall -# be created to represent the...west side of the Pará State. I -# suggest this new timezone be called Santarem as the most -# important/populated city in the affected area. -# -# This new timezone would be the same as the Rio_Branco timezone up to -# the 2008/06/24 change which would be to UTC-3 instead of UTC-4. - -# From Alex Krivenyshev (2008-06-24): -# This is a quick reference page for New and Old Brazil Time Zones map. -# http://www.worldtimezone.com/brazil-time-new-old.php -# -# - 4 time zones replaced by 3 time zones - eliminating time zone UTC-05 -# (state Acre and the part of the Amazonas will be UTC/GMT-04) - western -# part of Par state is moving to one timezone UTC-03 (from UTC-04). - -# From Paul Eggert (2002-10-10): -# The official decrees referenced below are mostly taken from -# Decretos sobre o Horário de Verão no Brasil. -# http://pcdsh01.on.br/DecHV.html - -# From Steffen Thorsen (2008-08-29): -# As announced by the government and many newspapers in Brazil late -# yesterday, Brazil will start DST on 2008-10-19 (need to change rule) and -# it will end on 2009-02-15 (current rule for Brazil is fine). Based on -# past years experience with the elections, there was a good chance that -# the start was postponed to November, but it did not happen this year. -# -# It has not yet been posted to http://pcdsh01.on.br/DecHV.html -# -# An official page about it: -# http://www.mme.gov.br/site/news/detail.do?newsId=16722 -# Note that this link does not always work directly, but must be accessed -# by going to -# http://www.mme.gov.br/first -# -# One example link that works directly: -# http://jornale.com.br/index.php?option=com_content&task=view&id=13530&Itemid=54 -# (Portuguese) -# -# We have a written a short article about it as well: -# https://www.timeanddate.com/news/time/brazil-dst-2008-2009.html -# -# From Alexander Krivenyshev (2011-10-04): -# State Bahia will return to Daylight savings time this year after 8 years off. -# The announcement was made by Governor Jaques Wagner in an interview to a -# television station in Salvador. - -# In Portuguese: -# http://g1.globo.com/bahia/noticia/2011/10/governador-jaques-wagner-confirma-horario-de-verao-na-bahia.html -# https://noticias.terra.com.br/brasil/noticias/0,,OI5390887-EI8139,00-Bahia+volta+a+ter+horario+de+verao+apos+oito+anos.html - -# From Guilherme Bernardes Rodrigues (2011-10-07): -# There is news in the media, however there is still no decree about it. -# I just send a e-mail to Zulmira Brandao at http://pcdsh01.on.br/ the -# official agency about time in Brazil, and she confirmed that the old rule is -# still in force. - -# From Guilherme Bernardes Rodrigues (2011-10-14) -# It's official, the President signed a decree that includes Bahia in summer -# time. -# [ and in a second message (same day): ] -# I found the decree. -# -# DECRETO No. 7.584, DE 13 DE OUTUBRO DE 2011 -# Link : -# http://www.in.gov.br/visualiza/index.jsp?data=13/10/2011&jornal=1000&pagina=6&totalArquivos=6 - -# From Kelley Cook (2012-10-16): -# The governor of state of Bahia in Brazil announced on Thursday that -# due to public pressure, he is reversing the DST policy they implemented -# last year and will not be going to Summer Time on October 21st.... -# http://www.correio24horas.com.br/r/artigo/apos-pressoes-wagner-suspende-horario-de-verao-na-bahia - -# From Rodrigo Severo (2012-10-16): -# Tocantins state will have DST. -# https://noticias.terra.com.br/brasil/noticias/0,,OI6232536-EI306.html - -# From Steffen Thorsen (2013-09-20): -# Tocantins in Brazil is very likely not to observe DST from October.... -# http://conexaoto.com.br/2013/09/18/ministerio-confirma-que-tocantins-esta-fora-do-horario-de-verao-em-2013-mas-falta-publicacao-de-decreto -# We will keep this article updated when this is confirmed: -# https://www.timeanddate.com/news/time/brazil-starts-dst-2013.html - -# From Steffen Thorsen (2013-10-17): -# https://www.timeanddate.com/news/time/acre-amazonas-change-time-zone.html -# Senator Jorge Viana announced that Acre will change time zone on November 10. -# He did not specify the time of the change, nor if western parts of Amazonas -# will change as well. -# -# From Paul Eggert (2013-10-17): -# For now, assume western Amazonas will change as well. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# Decree 20,466 <http://pcdsh01.on.br/HV20466.htm> (1931-10-01) -# Decree 21,896 <http://pcdsh01.on.br/HV21896.htm> (1932-01-10) -Rule Brazil 1931 only - Oct 3 11:00 1:00 - -Rule Brazil 1932 1933 - Apr 1 0:00 0 - -Rule Brazil 1932 only - Oct 3 0:00 1:00 - -# Decree 23,195 <http://pcdsh01.on.br/HV23195.htm> (1933-10-10) -# revoked DST. -# Decree 27,496 <http://pcdsh01.on.br/HV27496.htm> (1949-11-24) -# Decree 27,998 <http://pcdsh01.on.br/HV27998.htm> (1950-04-13) -Rule Brazil 1949 1952 - Dec 1 0:00 1:00 - -Rule Brazil 1950 only - Apr 16 1:00 0 - -Rule Brazil 1951 1952 - Apr 1 0:00 0 - -# Decree 32,308 <http://pcdsh01.on.br/HV32308.htm> (1953-02-24) -Rule Brazil 1953 only - Mar 1 0:00 0 - -# Decree 34,724 <http://pcdsh01.on.br/HV34724.htm> (1953-11-30) -# revoked DST. -# Decree 52,700 <http://pcdsh01.on.br/HV52700.htm> (1963-10-18) -# established DST from 1963-10-23 00:00 to 1964-02-29 00:00 -# in SP, RJ, GB, MG, ES, due to the prolongation of the drought. -# Decree 53,071 <http://pcdsh01.on.br/HV53071.htm> (1963-12-03) -# extended the above decree to all of the national territory on 12-09. -Rule Brazil 1963 only - Dec 9 0:00 1:00 - -# Decree 53,604 <http://pcdsh01.on.br/HV53604.htm> (1964-02-25) -# extended summer time by one day to 1964-03-01 00:00 (start of school). -Rule Brazil 1964 only - Mar 1 0:00 0 - -# Decree 55,639 <http://pcdsh01.on.br/HV55639.htm> (1965-01-27) -Rule Brazil 1965 only - Jan 31 0:00 1:00 - -Rule Brazil 1965 only - Mar 31 0:00 0 - -# Decree 57,303 <http://pcdsh01.on.br/HV57303.htm> (1965-11-22) -Rule Brazil 1965 only - Dec 1 0:00 1:00 - -# Decree 57,843 <http://pcdsh01.on.br/HV57843.htm> (1966-02-18) -Rule Brazil 1966 1968 - Mar 1 0:00 0 - -Rule Brazil 1966 1967 - Nov 1 0:00 1:00 - -# Decree 63,429 <http://pcdsh01.on.br/HV63429.htm> (1968-10-15) -# revoked DST. -# Decree 91,698 <http://pcdsh01.on.br/HV91698.htm> (1985-09-27) -Rule Brazil 1985 only - Nov 2 0:00 1:00 - -# Decree 92,310 (1986-01-21) -# Decree 92,463 (1986-03-13) -Rule Brazil 1986 only - Mar 15 0:00 0 - -# Decree 93,316 (1986-10-01) -Rule Brazil 1986 only - Oct 25 0:00 1:00 - -Rule Brazil 1987 only - Feb 14 0:00 0 - -# Decree 94,922 <http://pcdsh01.on.br/HV94922.htm> (1987-09-22) -Rule Brazil 1987 only - Oct 25 0:00 1:00 - -Rule Brazil 1988 only - Feb 7 0:00 0 - -# Decree 96,676 <http://pcdsh01.on.br/HV96676.htm> (1988-09-12) -# except for the states of AC, AM, PA, RR, RO, and AP (then a territory) -Rule Brazil 1988 only - Oct 16 0:00 1:00 - -Rule Brazil 1989 only - Jan 29 0:00 0 - -# Decree 98,077 <http://pcdsh01.on.br/HV98077.htm> (1989-08-21) -# with the same exceptions -Rule Brazil 1989 only - Oct 15 0:00 1:00 - -Rule Brazil 1990 only - Feb 11 0:00 0 - -# Decree 99,530 <http://pcdsh01.on.br/HV99530.htm> (1990-09-17) -# adopted by RS, SC, PR, SP, RJ, ES, MG, GO, MS, DF. -# Decree 99,629 (1990-10-19) adds BA, MT. -Rule Brazil 1990 only - Oct 21 0:00 1:00 - -Rule Brazil 1991 only - Feb 17 0:00 0 - -# Unnumbered decree <http://pcdsh01.on.br/HV1991.htm> (1991-09-25) -# adopted by RS, SC, PR, SP, RJ, ES, MG, BA, GO, MT, MS, DF. -Rule Brazil 1991 only - Oct 20 0:00 1:00 - -Rule Brazil 1992 only - Feb 9 0:00 0 - -# Unnumbered decree <http://pcdsh01.on.br/HV1992.htm> (1992-10-16) -# adopted by same states. -Rule Brazil 1992 only - Oct 25 0:00 1:00 - -Rule Brazil 1993 only - Jan 31 0:00 0 - -# Decree 942 <http://pcdsh01.on.br/HV942.htm> (1993-09-28) -# adopted by same states, plus AM. -# Decree 1,252 <http://pcdsh01.on.br/HV1252.htm> (1994-09-22; -# web page corrected 2004-01-07) adopted by same states, minus AM. -# Decree 1,636 <http://pcdsh01.on.br/HV1636.htm> (1995-09-14) -# adopted by same states, plus MT and TO. -# Decree 1,674 <http://pcdsh01.on.br/HV1674.htm> (1995-10-13) -# adds AL, SE. -Rule Brazil 1993 1995 - Oct Sun>=11 0:00 1:00 - -Rule Brazil 1994 1995 - Feb Sun>=15 0:00 0 - -Rule Brazil 1996 only - Feb 11 0:00 0 - -# Decree 2,000 <http://pcdsh01.on.br/HV2000.htm> (1996-09-04) -# adopted by same states, minus AL, SE. -Rule Brazil 1996 only - Oct 6 0:00 1:00 - -Rule Brazil 1997 only - Feb 16 0:00 0 - -# From Daniel C. Sobral (1998-02-12): -# In 1997, the DS began on October 6. The stated reason was that -# because international television networks ignored Brazil's policy on DS, -# they bought the wrong times on satellite for coverage of Pope's visit. -# This year, the ending date of DS was postponed to March 1 -# to help dealing with the shortages of electric power. -# -# Decree 2,317 (1997-09-04), adopted by same states. -Rule Brazil 1997 only - Oct 6 0:00 1:00 - -# Decree 2,495 <http://pcdsh01.on.br/figuras/HV2495.JPG> -# (1998-02-10) -Rule Brazil 1998 only - Mar 1 0:00 0 - -# Decree 2,780 <http://pcdsh01.on.br/figuras/Hv98.jpg> (1998-09-11) -# adopted by the same states as before. -Rule Brazil 1998 only - Oct 11 0:00 1:00 - -Rule Brazil 1999 only - Feb 21 0:00 0 - -# Decree 3,150 <http://pcdsh01.on.br/figuras/HV3150.gif> -# (1999-08-23) adopted by same states. -# Decree 3,188 <http://pcdsh01.on.br/DecHV99.gif> (1999-09-30) -# adds SE, AL, PB, PE, RN, CE, PI, MA and RR. -Rule Brazil 1999 only - Oct 3 0:00 1:00 - -Rule Brazil 2000 only - Feb 27 0:00 0 - -# Decree 3,592 <http://pcdsh01.on.br/DEC3592.htm> (2000-09-06) -# adopted by the same states as before. -# Decree 3,630 <http://pcdsh01.on.br/Dec3630.jpg> (2000-10-13) -# repeals DST in PE and RR, effective 2000-10-15 00:00. -# Decree 3,632 <http://pcdsh01.on.br/Dec3632.jpg> (2000-10-17) -# repeals DST in SE, AL, PB, RN, CE, PI and MA, effective 2000-10-22 00:00. -# Decree 3,916 <http://pcdsh01.on.br/figuras/HV3916.gif> -# (2001-09-13) reestablishes DST in AL, CE, MA, PB, PE, PI, RN, SE. -Rule Brazil 2000 2001 - Oct Sun>=8 0:00 1:00 - -Rule Brazil 2001 2006 - Feb Sun>=15 0:00 0 - -# Decree 4,399 (2002-10-01) repeals DST in AL, CE, MA, PB, PE, PI, RN, SE. -# 4,399 <http://www.presidencia.gov.br/CCIVIL/decreto/2002/D4399.htm> -Rule Brazil 2002 only - Nov 3 0:00 1:00 - -# Decree 4,844 (2003-09-24; corrected 2003-09-26) repeals DST in BA, MT, TO. -# 4,844 <http://www.presidencia.gov.br/CCIVIL/decreto/2003/D4844.htm> -Rule Brazil 2003 only - Oct 19 0:00 1:00 - -# Decree 5,223 (2004-10-01) reestablishes DST in MT. -# 5,223 <http://www.planalto.gov.br/ccivil_03/_Ato2004-2006/2004/Decreto/D5223.htm> -Rule Brazil 2004 only - Nov 2 0:00 1:00 - -# Decree 5,539 <http://pcdsh01.on.br/DecHV5539.gif> (2005-09-19), -# adopted by the same states as before. -Rule Brazil 2005 only - Oct 16 0:00 1:00 - -# Decree 5,920 <http://pcdsh01.on.br/DecHV5920.gif> (2006-10-03), -# adopted by the same states as before. -Rule Brazil 2006 only - Nov 5 0:00 1:00 - -Rule Brazil 2007 only - Feb 25 0:00 0 - -# Decree 6,212 <http://pcdsh01.on.br/DecHV6212.gif> (2007-09-26), -# adopted by the same states as before. -Rule Brazil 2007 only - Oct Sun>=8 0:00 1:00 - -# From Frederico A. C. Neves (2008-09-10): -# According to this decree -# http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm -# [t]he DST period in Brazil now on will be from the 3rd Oct Sunday to the -# 3rd Feb Sunday. There is an exception on the return date when this is -# the Carnival Sunday then the return date will be the next Sunday... -Rule Brazil 2008 2017 - Oct Sun>=15 0:00 1:00 - -Rule Brazil 2008 2011 - Feb Sun>=15 0:00 0 - -# Decree 7,584 <http://pcdsh01.on.br/HVdecreto7584_20111013.jpg> (2011-10-13) -# added Bahia. -Rule Brazil 2012 only - Feb Sun>=22 0:00 0 - -# Decree 7,826 <http://pcdsh01.on.br/HVdecreto7826_20121015.jpg> (2012-10-15) -# removed Bahia and added Tocantins. -# Decree 8,112 <http://pcdsh01.on.br/HVdecreto8112_20130930.JPG> (2013-09-30) -# removed Tocantins. -Rule Brazil 2013 2014 - Feb Sun>=15 0:00 0 - -Rule Brazil 2015 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2016 2022 - Feb Sun>=15 0:00 0 - -# From Steffen Thorsen (2017-12-18): -# According to many media sources, next year's DST start in Brazil will move to -# the first Sunday of November, and it will stay like that for the years after. -# ... https://www.timeanddate.com/news/time/brazil-delays-dst-2018.html -# From Steffen Thorsen (2017-12-20): -# http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2017/decreto/D9242.htm -# -# From Fábio Gomes (2018-10-04): -# The Brazilian president just announced a new change on this year DST. -# It was scheduled to start on November 4th and it was changed to November 18th. -# From Rodrigo Brüning Wessler (2018-10-15): -# The Brazilian government just announced that the change in DST was -# canceled.... Maybe the president Michel Temer also woke up one hour -# earlier today. :) -Rule Brazil 2018 max - Nov Sun>=1 0:00 1:00 - -Rule Brazil 2023 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2024 2025 - Feb Sun>=15 0:00 0 - -Rule Brazil 2026 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2027 2033 - Feb Sun>=15 0:00 0 - -Rule Brazil 2034 only - Feb Sun>=22 0:00 0 - -Rule Brazil 2035 2036 - Feb Sun>=15 0:00 0 - -Rule Brazil 2037 only - Feb Sun>=22 0:00 0 - -# From Arthur David Olson (2008-09-29): -# The next is wrong in some years but is better than nothing. -Rule Brazil 2038 max - Feb Sun>=15 0:00 0 - - -# The latest ruleset listed above says that the following states observe DST: -# DF, ES, GO, MG, MS, MT, PR, RJ, RS, SC, SP. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -# -# Fernando de Noronha (administratively part of PE) -Zone America/Noronha -2:09:40 - LMT 1914 - -2:00 Brazil -02/-01 1990 Sep 17 - -2:00 - -02 1999 Sep 30 - -2:00 Brazil -02/-01 2000 Oct 15 - -2:00 - -02 2001 Sep 13 - -2:00 Brazil -02/-01 2002 Oct 1 - -2:00 - -02 -# Other Atlantic islands have no permanent settlement. -# These include Trindade and Martim Vaz (administratively part of ES), -# Rocas Atoll (RN), and the St Peter and St Paul Archipelago (PE). -# Fernando de Noronha was a separate territory from 1942-09-02 to 1989-01-01; -# it also included the Penedos. -# -# Amapá (AP), east Pará (PA) -# East Pará includes Belém, Marabá, Serra Norte, and São Félix do Xingu. -# The division between east and west Pará is the river Xingu. -# In the north a very small part from the river Javary (now Jari I guess, -# the border with Amapá) to the Amazon, then to the Xingu. -Zone America/Belem -3:13:56 - LMT 1914 - -3:00 Brazil -03/-02 1988 Sep 12 - -3:00 - -03 -# -# west Pará (PA) -# West Pará includes Altamira, Óbidos, Prainha, Oriximiná, and Santarém. -Zone America/Santarem -3:38:48 - LMT 1914 - -4:00 Brazil -04/-03 1988 Sep 12 - -4:00 - -04 2008 Jun 24 0:00 - -3:00 - -03 -# -# Maranhão (MA), Piauí (PI), Ceará (CE), Rio Grande do Norte (RN), -# Paraíba (PB) -Zone America/Fortaleza -2:34:00 - LMT 1914 - -3:00 Brazil -03/-02 1990 Sep 17 - -3:00 - -03 1999 Sep 30 - -3:00 Brazil -03/-02 2000 Oct 22 - -3:00 - -03 2001 Sep 13 - -3:00 Brazil -03/-02 2002 Oct 1 - -3:00 - -03 -# -# Pernambuco (PE) (except Atlantic islands) -Zone America/Recife -2:19:36 - LMT 1914 - -3:00 Brazil -03/-02 1990 Sep 17 - -3:00 - -03 1999 Sep 30 - -3:00 Brazil -03/-02 2000 Oct 15 - -3:00 - -03 2001 Sep 13 - -3:00 Brazil -03/-02 2002 Oct 1 - -3:00 - -03 -# -# Tocantins (TO) -Zone America/Araguaina -3:12:48 - LMT 1914 - -3:00 Brazil -03/-02 1990 Sep 17 - -3:00 - -03 1995 Sep 14 - -3:00 Brazil -03/-02 2003 Sep 24 - -3:00 - -03 2012 Oct 21 - -3:00 Brazil -03/-02 2013 Sep - -3:00 - -03 -# -# Alagoas (AL), Sergipe (SE) -Zone America/Maceio -2:22:52 - LMT 1914 - -3:00 Brazil -03/-02 1990 Sep 17 - -3:00 - -03 1995 Oct 13 - -3:00 Brazil -03/-02 1996 Sep 4 - -3:00 - -03 1999 Sep 30 - -3:00 Brazil -03/-02 2000 Oct 22 - -3:00 - -03 2001 Sep 13 - -3:00 Brazil -03/-02 2002 Oct 1 - -3:00 - -03 -# -# Bahia (BA) -# There are too many Salvadors elsewhere, so use America/Bahia instead -# of America/Salvador. -Zone America/Bahia -2:34:04 - LMT 1914 - -3:00 Brazil -03/-02 2003 Sep 24 - -3:00 - -03 2011 Oct 16 - -3:00 Brazil -03/-02 2012 Oct 21 - -3:00 - -03 -# -# Goiás (GO), Distrito Federal (DF), Minas Gerais (MG), -# Espírito Santo (ES), Rio de Janeiro (RJ), São Paulo (SP), Paraná (PR), -# Santa Catarina (SC), Rio Grande do Sul (RS) -Zone America/Sao_Paulo -3:06:28 - LMT 1914 - -3:00 Brazil -03/-02 1963 Oct 23 0:00 - -3:00 1:00 -02 1964 - -3:00 Brazil -03/-02 -# -# Mato Grosso do Sul (MS) -Zone America/Campo_Grande -3:38:28 - LMT 1914 - -4:00 Brazil -04/-03 -# -# Mato Grosso (MT) -Zone America/Cuiaba -3:44:20 - LMT 1914 - -4:00 Brazil -04/-03 2003 Sep 24 - -4:00 - -04 2004 Oct 1 - -4:00 Brazil -04/-03 -# -# Rondônia (RO) -Zone America/Porto_Velho -4:15:36 - LMT 1914 - -4:00 Brazil -04/-03 1988 Sep 12 - -4:00 - -04 -# -# Roraima (RR) -Zone America/Boa_Vista -4:02:40 - LMT 1914 - -4:00 Brazil -04/-03 1988 Sep 12 - -4:00 - -04 1999 Sep 30 - -4:00 Brazil -04/-03 2000 Oct 15 - -4:00 - -04 -# -# east Amazonas (AM): Boca do Acre, Jutaí, Manaus, Floriano Peixoto -# The great circle line from Tabatinga to Porto Acre divides -# east from west Amazonas. -Zone America/Manaus -4:00:04 - LMT 1914 - -4:00 Brazil -04/-03 1988 Sep 12 - -4:00 - -04 1993 Sep 28 - -4:00 Brazil -04/-03 1994 Sep 22 - -4:00 - -04 -# -# west Amazonas (AM): Atalaia do Norte, Boca do Maoco, Benjamin Constant, -# Eirunepé, Envira, Ipixuna -Zone America/Eirunepe -4:39:28 - LMT 1914 - -5:00 Brazil -05/-04 1988 Sep 12 - -5:00 - -05 1993 Sep 28 - -5:00 Brazil -05/-04 1994 Sep 22 - -5:00 - -05 2008 Jun 24 0:00 - -4:00 - -04 2013 Nov 10 - -5:00 - -05 -# -# Acre (AC) -Zone America/Rio_Branco -4:31:12 - LMT 1914 - -5:00 Brazil -05/-04 1988 Sep 12 - -5:00 - -05 2008 Jun 24 0:00 - -4:00 - -04 2013 Nov 10 - -5:00 - -05 - -# Chile - -# From Paul Eggert (2015-04-03): -# Shanks & Pottenger says America/Santiago introduced standard time in -# 1890 and rounds its UT offset to 70W40; guess that in practice this -# was the same offset as in 1916-1919. It also says Pacific/Easter -# standardized on 109W22 in 1890; assume this didn't change the clocks. -# -# Dates for America/Santiago from 1910 to 2004 are primarily from -# the following source, cited by Oscar van Vlijmen (2006-10-08): -# [1] Chile Law -# http://www.webexhibits.org/daylightsaving/chile.html -# This contains a copy of this official table: -# Cambios en la hora oficial de Chile desde 1900 (retrieved 2008-03-30) -# https://web.archive.org/web/20080330200901/http://www.horaoficial.cl/cambio.htm -# [1] needs several corrections, though. -# -# The first set of corrections is from: -# [2] History of the Official Time of Chile -# http://www.horaoficial.cl/ing/horaof_ing.html (retrieved 2012-03-06). See: -# https://web.archive.org/web/20120306042032/http://www.horaoficial.cl/ing/horaof_ing.html -# This is an English translation of: -# Historia de la hora oficial de Chile (retrieved 2012-10-24). See: -# https://web.archive.org/web/20121024234627/http://www.horaoficial.cl/horaof.htm -# A fancier Spanish version (requiring mouse-clicking) is at: -# http://www.horaoficial.cl/historia_hora.html -# Conflicts between [1] and [2] were resolved as follows: -# -# - [1] says the 1910 transition was Jan 1, [2] says Jan 10 and cites -# Boletín No. 1, Aviso No. 1 (1910). Go with [2]. -# -# - [1] says SMT was -4:42:45, [2] says Chile's official time from -# 1916 to 1919 was -4:42:46.3, the meridian of Chile's National -# Astronomical Observatory (OAN), then located in what is now -# Quinta Normal in Santiago. Go with [2], rounding it to -4:42:46. -# -# - [1] says the 1918 transition was Sep 1, [2] says Sep 10 and cites -# Boletín No. 22, Aviso No. 129/1918 (1918-08-23). Go with [2]. -# -# - [1] does not give times for transitions; assume they occur -# at midnight mainland time, the current common practice. However, -# go with [2]'s specification of 23:00 for the 1947-05-21 transition. -# -# Another correction to [1] is from Jesper Nørgaard Welen, who -# wrote (2006-10-08), "I think that there are some obvious mistakes in -# the suggested link from Oscar van Vlijmen,... for instance entry 66 -# says that GMT-4 ended 1990-09-12 while entry 67 only begins GMT-3 at -# 1990-09-15 (they should have been 1990-09-15 and 1990-09-16 -# respectively), but anyhow it clears up some doubts too." -# -# Data for Pacific/Easter from 1910 through 1967 come from Shanks & -# Pottenger. After that, for lack of better info assume -# Pacific/Easter is always two hours behind America/Santiago; -# this is known to work for DST transitions starting in 2008 and -# may well be true for earlier transitions. - -# From Eduardo Krell (1995-10-19): -# The law says to switch to DST at midnight [24:00] on the second SATURDAY -# of October.... The law is the same for March and October. -# (1998-09-29): -# Because of the drought this year, the government decided to go into -# DST earlier (saturday 9/26 at 24:00). This is a one-time change only ... -# (unless there's another dry season next year, I guess). - -# From Julio I. Pacheco Troncoso (1999-03-18): -# Because of the same drought, the government decided to end DST later, -# on April 3, (one-time change). - -# From Germán Poo-Caamaño (2008-03-03): -# Due to drought, Chile extends Daylight Time in three weeks. This -# is one-time change (Saturday 3/29 at 24:00 for America/Santiago -# and Saturday 3/29 at 22:00 for Pacific/Easter) -# The Supreme Decree is located at -# http://www.shoa.cl/servicios/supremo316.pdf -# -# From José Miguel Garrido (2008-03-05): -# http://www.shoa.cl/noticias/2008/04hora/hora.htm - -# From Angel Chiang (2010-03-04): -# Subject: DST in Chile exceptionally extended to 3 April due to earthquake -# http://www.gobiernodechile.cl/viewNoticia.aspx?idArticulo=30098 -# -# From Arthur David Olson (2010-03-06): -# Angel Chiang's message confirmed by Julio Pacheco; Julio provided a patch. - -# From Glenn Eychaner (2011-03-28): -# http://diario.elmercurio.com/2011/03/28/_portada/_portada/noticias/7565897A-CA86-49E6-9E03-660B21A4883E.htm?id=3D{7565897A-CA86-49E6-9E03-660B21A4883E} -# In English: -# Chile's clocks will go back an hour this year on the 7th of May instead -# of this Saturday. They will go forward again the 3rd Saturday in -# August, not in October as they have since 1968. - -# From Mauricio Parada (2012-02-22), translated by Glenn Eychaner (2012-02-23): -# As stated in the website of the Chilean Energy Ministry -# http://www.minenergia.cl/ministerio/noticias/generales/gobierno-anuncia-fechas-de-cambio-de.html -# The Chilean Government has decided to postpone the entrance into winter time -# (to leave DST) from March 11 2012 to April 28th 2012.... -# Quote from the website communication: -# -# 6. For the year 2012, the dates of entry into winter time will be as follows: -# a. Saturday April 28, 2012, clocks should go back 60 minutes; that is, at -# 23:59:59, instead of passing to 0:00, the time should be adjusted to be 23:00 -# of the same day. -# b. Saturday, September 1, 2012, clocks should go forward 60 minutes; that is, -# at 23:59:59, instead of passing to 0:00, the time should be adjusted to be -# 01:00 on September 2. - -# From Steffen Thorsen (2013-02-15): -# According to several news sources, Chile has extended DST this year, -# they will end DST later and start DST earlier than planned. They -# hope to save energy. The new end date is 2013-04-28 00:00 and new -# start date is 2013-09-08 00:00.... -# http://www.gob.cl/informa/2013/02/15/gobierno-anuncia-fechas-de-cambio-de-hora-para-el-ano-2013.htm - -# From José Miguel Garrido (2014-02-19): -# Today appeared in the Diario Oficial a decree amending the time change -# dates to 2014. -# DST End: last Saturday of April 2014 (Sun 27 Apr 2014 03:00 UTC) -# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC) -# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf - -# From Eduardo Romero Urra (2015-03-03): -# Today has been published officially that Chile will use the DST time -# permanently until March 25 of 2017 -# http://www.diariooficial.interior.gob.cl/media/2015/03/03/1-large.jpg -# -# From Paul Eggert (2015-03-03): -# For now, assume that the extension will persist indefinitely. - -# From Juan Correa (2016-03-18): -# The decree regarding DST has been published in today's Official Gazette: -# http://www.diariooficial.interior.gob.cl/versiones-anteriores/do/20160318/ -# http://www.leychile.cl/Navegar?idNorma=1088502 -# It does consider the second Saturday of May and August as the dates -# for the transition; and it lists DST dates until 2019, but I think -# this scheme will stick. -# -# From Paul Eggert (2016-03-18): -# For now, assume the pattern holds for the indefinite future. -# The decree says transitions occur at 24:00; in practice this appears -# to mean 24:00 mainland time, not 24:00 local time, so that Easter -# Island is always two hours behind the mainland. - -# From Juan Correa (2016-12-04): -# Magallanes region ... will keep DST (UTC -3) all year round.... -# http://www.soychile.cl/Santiago/Sociedad/2016/12/04/433428/Bachelet-firmo-el-decreto-para-establecer-un-horario-unico-para-la-Region-de-Magallanes.aspx -# -# From Deborah Goldsmith (2017-01-19): -# http://www.diariooficial.interior.gob.cl/publicaciones/2017/01/17/41660/01/1169626.pdf -# From Paul Eggert (2017-01-19): -# The above says the Magallanes change expires 2019-05-11 at 24:00, -# so in theory, they will revert to -04/-03 after that, which means -# they will switch from -03 to -04 one hour after Santiago does that day. -# For now, assume that they will not revert. - -# From Juan Correa (2018-08-13): -# As of moments ago, the Ministry of Energy in Chile has announced the new -# schema for DST. ... Announcement in video (in Spanish): -# https://twitter.com/MinEnergia/status/1029000399129374720 -# From Yonathan Dossow (2018-08-13): -# The video says "first Saturday of September", we all know it means Sunday at -# midnight. -# From Tim Parenti (2018-08-13): -# Translating the captions on the video at 0:44-0:55, "We want to announce as -# Government that from 2019, Winter Time will be increased to 5 months, between -# the first Saturday of April and the first Saturday of September." -# At 2:08-2:20, "The Magallanes region will maintain its current time, as -# decided by the citizens during 2017, but our Government will promote a -# regional dialogue table to gather their opinion on this matter." -# https://twitter.com/MinEnergia/status/1029009354001973248 -# "We will keep the new time policy unchanged for at least the next 4 years." -# So we extend the new rules on Saturdays at 24:00 mainland time indefinitely. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Chile 1927 1931 - Sep 1 0:00 1:00 - -Rule Chile 1928 1932 - Apr 1 0:00 0 - -Rule Chile 1968 only - Nov 3 4:00u 1:00 - -Rule Chile 1969 only - Mar 30 3:00u 0 - -Rule Chile 1969 only - Nov 23 4:00u 1:00 - -Rule Chile 1970 only - Mar 29 3:00u 0 - -Rule Chile 1971 only - Mar 14 3:00u 0 - -Rule Chile 1970 1972 - Oct Sun>=9 4:00u 1:00 - -Rule Chile 1972 1986 - Mar Sun>=9 3:00u 0 - -Rule Chile 1973 only - Sep 30 4:00u 1:00 - -Rule Chile 1974 1987 - Oct Sun>=9 4:00u 1:00 - -Rule Chile 1987 only - Apr 12 3:00u 0 - -Rule Chile 1988 1990 - Mar Sun>=9 3:00u 0 - -Rule Chile 1988 1989 - Oct Sun>=9 4:00u 1:00 - -Rule Chile 1990 only - Sep 16 4:00u 1:00 - -Rule Chile 1991 1996 - Mar Sun>=9 3:00u 0 - -Rule Chile 1991 1997 - Oct Sun>=9 4:00u 1:00 - -Rule Chile 1997 only - Mar 30 3:00u 0 - -Rule Chile 1998 only - Mar Sun>=9 3:00u 0 - -Rule Chile 1998 only - Sep 27 4:00u 1:00 - -Rule Chile 1999 only - Apr 4 3:00u 0 - -Rule Chile 1999 2010 - Oct Sun>=9 4:00u 1:00 - -Rule Chile 2000 2007 - Mar Sun>=9 3:00u 0 - -# N.B.: the end of March 29 in Chile is March 30 in Universal time, -# which is used below in specifying the transition. -Rule Chile 2008 only - Mar 30 3:00u 0 - -Rule Chile 2009 only - Mar Sun>=9 3:00u 0 - -Rule Chile 2010 only - Apr Sun>=1 3:00u 0 - -Rule Chile 2011 only - May Sun>=2 3:00u 0 - -Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 - -Rule Chile 2012 2014 - Apr Sun>=23 3:00u 0 - -Rule Chile 2012 2014 - Sep Sun>=2 4:00u 1:00 - -Rule Chile 2016 2018 - May Sun>=9 3:00u 0 - -Rule Chile 2016 2018 - Aug Sun>=9 4:00u 1:00 - -Rule Chile 2019 max - Apr Sun>=2 3:00u 0 - -Rule Chile 2019 max - Sep Sun>=2 4:00u 1:00 - -# IATA SSIM anomalies: (1992-02) says 1992-03-14; -# (1996-09) says 1998-03-08. Ignore these. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Santiago -4:42:46 - LMT 1890 - -4:42:46 - SMT 1910 Jan 10 # Santiago Mean Time - -5:00 - -05 1916 Jul 1 - -4:42:46 - SMT 1918 Sep 10 - -4:00 - -04 1919 Jul 1 - -4:42:46 - SMT 1927 Sep 1 - -5:00 Chile -05/-04 1932 Sep 1 - -4:00 - -04 1942 Jun 1 - -5:00 - -05 1942 Aug 1 - -4:00 - -04 1946 Jul 15 - -4:00 1:00 -03 1946 Sep 1 # central Chile - -4:00 - -04 1947 Apr 1 - -5:00 - -05 1947 May 21 23:00 - -4:00 Chile -04/-03 -Zone America/Punta_Arenas -4:43:40 - LMT 1890 - -4:42:46 - SMT 1910 Jan 10 - -5:00 - -05 1916 Jul 1 - -4:42:46 - SMT 1918 Sep 10 - -4:00 - -04 1919 Jul 1 - -4:42:46 - SMT 1927 Sep 1 - -5:00 Chile -05/-04 1932 Sep 1 - -4:00 - -04 1942 Jun 1 - -5:00 - -05 1942 Aug 1 - -4:00 - -04 1947 Apr 1 - -5:00 - -05 1947 May 21 23:00 - -4:00 Chile -04/-03 2016 Dec 4 - -3:00 - -03 -Zone Pacific/Easter -7:17:28 - LMT 1890 - -7:17:28 - EMT 1932 Sep # Easter Mean Time - -7:00 Chile -07/-06 1982 Mar 14 3:00u # Easter Time - -6:00 Chile -06/-05 -# -# Salas y Gómez Island is uninhabited. -# Other Chilean locations, including Juan Fernández Is, Desventuradas Is, -# and Antarctic bases, are like America/Santiago. - -# Antarctic base using South American rules -# (See the file 'antarctica' for more.) -# -# Palmer, Anvers Island, since 1965 (moved 2 miles in 1968) -# -# From Ethan Dicks (1996-10-06): -# It keeps the same time as Punta Arenas, Chile, because, just like us -# and the South Pole, that's the other end of their supply line.... -# I verified with someone who was there that since 1980, -# Palmer has followed Chile. Prior to that, before the Falklands War, -# Palmer used to be supplied from Argentina. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Palmer 0 - -00 1965 - -4:00 Arg -04/-03 1969 Oct 5 - -3:00 Arg -03/-02 1982 May - -4:00 Chile -04/-03 2016 Dec 4 - -3:00 - -03 - -# Colombia - -# Milne gives 4:56:16.4 for Bogotá time in 1899; round to nearest. He writes, -# "A variation of fifteen minutes in the public clocks of Bogota is not rare." - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule CO 1992 only - May 3 0:00 1:00 - -Rule CO 1993 only - Apr 4 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Bogota -4:56:16 - LMT 1884 Mar 13 - -4:56:16 - BMT 1914 Nov 23 # Bogotá Mean Time - -5:00 CO -05/-04 -# Malpelo, Providencia, San Andres -# no information; probably like America/Bogota - -# Curaçao - -# Milne gives 4:35:46.9 for Curaçao mean time; round to nearest. -# -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger say that The Bottom and Philipsburg have been at -# -4:00 since standard time was introduced on 1912-03-02; and that -# Kralendijk and Rincon used Kralendijk Mean Time (-4:33:08) from -# 1912-02-02 to 1965-01-01. The former is dubious, since S&P also say -# Saba Island has been like Curaçao. -# This all predates our 1970 cutoff, though. -# -# By July 2007 Curaçao and St Maarten are planned to become -# associated states within the Netherlands, much like Aruba; -# Bonaire, Saba and St Eustatius would become directly part of the -# Netherlands as Kingdom Islands. This won't affect their time zones -# though, as far as we know. -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Curacao -4:35:47 - LMT 1912 Feb 12 # Willemstad - -4:30 - -0430 1965 - -4:00 - AST - -# From Arthur David Olson (2011-06-15): -# use links for places with new iso3166 codes. -# The name "Lower Prince's Quarter" is both longer than fourteen characters -# and contains an apostrophe; use "Lower_Princes" below. - -Link America/Curacao America/Lower_Princes # Sint Maarten -Link America/Curacao America/Kralendijk # Caribbean Netherlands - -# Ecuador -# -# Milne says the Central and South American Telegraph Company used -5:24:15. -# -# From Alois Treindl (2016-12-15): -# https://www.elcomercio.com/actualidad/hora-sixto-1993.html -# ... Whether the law applied also to Galápagos, I do not know. -# From Paul Eggert (2016-12-15): -# https://www.elcomercio.com/afull/modificacion-husohorario-ecuador-presidentes-decreto.html -# This says President Sixto Durán Ballén signed decree No. 285, which -# established DST from 1992-11-28 to 1993-02-05; it does not give transition -# times. The people called it "hora de Sixto" ("Sixto hour"). The change did -# not go over well; a popular song "Qué hora es" by Jaime Guevara had lyrics -# that included "Amanecía en mitad de la noche, los guaguas iban a clase sin -# sol" ("It was dawning in the middle of the night, the buses went to class -# without sun"). Although Ballén's campaign slogan was "Ni un paso atrás" -# (Not one step back), the clocks went back in 1993 and the experiment was not -# repeated. For now, assume transitions were at 00:00 local time country-wide. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Ecuador 1992 only - Nov 28 0:00 1:00 - -Rule Ecuador 1993 only - Feb 5 0:00 0 - -# -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Guayaquil -5:19:20 - LMT 1890 - -5:14:00 - QMT 1931 # Quito Mean Time - -5:00 Ecuador -05/-04 -Zone Pacific/Galapagos -5:58:24 - LMT 1931 # Puerto Baquerizo Moreno - -5:00 - -05 1986 - -6:00 Ecuador -06/-05 - -# Falklands - -# From Paul Eggert (2006-03-22): -# Between 1990 and 2000 inclusive, Shanks & Pottenger and the IATA agree except -# the IATA gives 1996-09-08. Go with Shanks & Pottenger. - -# From Falkland Islands Government Office, London (2001-01-22) -# via Jesper Nørgaard: -# ... the clocks revert back to Local Mean Time at 2 am on Sunday 15 -# April 2001 and advance one hour to summer time at 2 am on Sunday 2 -# September. It is anticipated that the clocks will revert back at 2 -# am on Sunday 21 April 2002 and advance to summer time at 2 am on -# Sunday 1 September. - -# From Rives McDow (2001-02-13): -# -# I have communicated several times with people there, and the last -# time I had communications that was helpful was in 1998. Here is -# what was said then: -# -# "The general rule was that Stanley used daylight saving and the Camp -# did not. However for various reasons many people in the Camp have -# started to use daylight saving (known locally as 'Stanley Time') -# There is no rule as to who uses daylight saving - it is a matter of -# personal choice and so it is impossible to draw a map showing who -# uses it and who does not. Any list would be out of date as soon as -# it was produced. This year daylight saving ended on April 18/19th -# and started again on September 12/13th. I do not know what the rule -# is, but can find out if you like. We do not change at the same time -# as UK or Chile." -# -# I did have in my notes that the rule was "Second Saturday in Sep at -# 0:00 until third Saturday in Apr at 0:00". I think that this does -# not agree in some cases with Shanks; is this true? -# -# Also, there is no mention in the list that some areas in the -# Falklands do not use DST. I have found in my communications there -# that these areas are on the western half of East Falkland and all of -# West Falkland. Stanley is the only place that consistently observes -# DST. Again, as in other places in the world, the farmers don't like -# it. West Falkland is almost entirely sheep farmers. -# -# I know one lady there that keeps a list of which farm keeps DST and -# which doesn't each year. She runs a shop in Stanley, and says that -# the list changes each year. She uses it to communicate to her -# customers, catching them when they are home for lunch or dinner. - -# From Paul Eggert (2001-03-05): -# For now, we'll just record the time in Stanley, since we have no -# better info. - -# From Steffen Thorsen (2011-04-01): -# The Falkland Islands will not turn back clocks this winter, but stay on -# daylight saving time. -# -# One source: -# http://www.falklandnews.com/public/story.cfm?get=5914&source=3 -# -# We have gotten this confirmed by a clerk of the legislative assembly: -# Normally the clocks revert to Local Mean Time (UTC/GMT -4 hours) on the -# third Sunday of April at 0200hrs and advance to Summer Time (UTC/GMT -3 -# hours) on the first Sunday of September at 0200hrs. -# -# IMPORTANT NOTE: During 2011, on a trial basis, the Falkland Islands -# will not revert to local mean time, but clocks will remain on Summer -# time (UTC/GMT - 3 hours) throughout the whole of 2011. Any long term -# change to local time following the trial period will be notified. -# -# From Andrew Newman (2012-02-24) -# A letter from Justin McPhee, Chief Executive, -# Cable & Wireless Falkland Islands (dated 2012-02-22) -# states... -# The current Atlantic/Stanley entry under South America expects the -# clocks to go back to standard Falklands Time (FKT) on the 15th April. -# The database entry states that in 2011 Stanley was staying on fixed -# summer time on a trial basis only. FIG need to contact IANA and/or -# the maintainers of the database to inform them we're adopting -# the same policy this year and suggest recommendations for future years. -# -# For now we will assume permanent -03 for the Falklands -# until advised differently (to apply for 2012 and beyond, after the 2011 -# experiment was apparently successful.) -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Falk 1937 1938 - Sep lastSun 0:00 1:00 - -Rule Falk 1938 1942 - Mar Sun>=19 0:00 0 - -Rule Falk 1939 only - Oct 1 0:00 1:00 - -Rule Falk 1940 1942 - Sep lastSun 0:00 1:00 - -Rule Falk 1943 only - Jan 1 0:00 0 - -Rule Falk 1983 only - Sep lastSun 0:00 1:00 - -Rule Falk 1984 1985 - Apr lastSun 0:00 0 - -Rule Falk 1984 only - Sep 16 0:00 1:00 - -Rule Falk 1985 2000 - Sep Sun>=9 0:00 1:00 - -Rule Falk 1986 2000 - Apr Sun>=16 0:00 0 - -Rule Falk 2001 2010 - Apr Sun>=15 2:00 0 - -Rule Falk 2001 2010 - Sep Sun>=1 2:00 1:00 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Stanley -3:51:24 - LMT 1890 - -3:51:24 - SMT 1912 Mar 12 # Stanley Mean Time - -4:00 Falk -04/-03 1983 May - -3:00 Falk -03/-02 1985 Sep 15 - -4:00 Falk -04/-03 2010 Sep 5 2:00 - -3:00 - -03 - -# French Guiana -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Cayenne -3:29:20 - LMT 1911 Jul - -4:00 - -04 1967 Oct - -3:00 - -03 - -# Guyana -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Guyana -3:52:40 - LMT 1915 Mar # Georgetown - -3:45 - -0345 1975 Jul 31 - -3:00 - -03 1991 -# IATA SSIM (1996-06) says -4:00. Assume a 1991 switch. - -4:00 - -04 - -# Paraguay -# -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger say that spring transitions are 01:00 -> 02:00, -# and autumn transitions are 00:00 -> 23:00. Go with pre-1999 -# editions of Shanks, and with the IATA, who say transitions occur at 00:00. -# -# From Waldemar Villamayor-Venialbo (2013-09-20): -# No time of the day is established for the adjustment, so people normally -# adjust their clocks at 0 hour of the given dates. -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Para 1975 1988 - Oct 1 0:00 1:00 - -Rule Para 1975 1978 - Mar 1 0:00 0 - -Rule Para 1979 1991 - Apr 1 0:00 0 - -Rule Para 1989 only - Oct 22 0:00 1:00 - -Rule Para 1990 only - Oct 1 0:00 1:00 - -Rule Para 1991 only - Oct 6 0:00 1:00 - -Rule Para 1992 only - Mar 1 0:00 0 - -Rule Para 1992 only - Oct 5 0:00 1:00 - -Rule Para 1993 only - Mar 31 0:00 0 - -Rule Para 1993 1995 - Oct 1 0:00 1:00 - -Rule Para 1994 1995 - Feb lastSun 0:00 0 - -Rule Para 1996 only - Mar 1 0:00 0 - -# IATA SSIM (2000-02) says 1999-10-10; ignore this for now. -# From Steffen Thorsen (2000-10-02): -# I have three independent reports that Paraguay changed to DST this Sunday -# (10-01). -# -# Translated by Gwillim Law (2001-02-27) from -# Noticias, a daily paper in Asunción, Paraguay (2000-10-01): -# http://www.diarionoticias.com.py/011000/nacional/naciona1.htm -# Starting at 0:00 today, the clock will be set forward 60 minutes, in -# fulfillment of Decree No. 7,273 of the Executive Power.... The time change -# system has been operating for several years. Formerly there was a separate -# decree each year; the new law has the same effect, but permanently. Every -# year, the time will change on the first Sunday of October; likewise, the -# clock will be set back on the first Sunday of March. -# -Rule Para 1996 2001 - Oct Sun>=1 0:00 1:00 - -# IATA SSIM (1997-09) says Mar 1; go with Shanks & Pottenger. -Rule Para 1997 only - Feb lastSun 0:00 0 - -# Shanks & Pottenger say 1999-02-28; IATA SSIM (1999-02) says 1999-02-27, but -# (1999-09) reports no date; go with above sources and Gerd Knops (2001-02-27). -Rule Para 1998 2001 - Mar Sun>=1 0:00 0 - -# From Rives McDow (2002-02-28): -# A decree was issued in Paraguay (No. 16350) on 2002-02-26 that changed the -# dst method to be from the first Sunday in September to the first Sunday in -# April. -Rule Para 2002 2004 - Apr Sun>=1 0:00 0 - -Rule Para 2002 2003 - Sep Sun>=1 0:00 1:00 - -# -# From Jesper Nørgaard Welen (2005-01-02): -# There are several sources that claim that Paraguay made -# a timezone rule change in autumn 2004. -# From Steffen Thorsen (2005-01-05): -# Decree 1,867 (2004-03-05) -# From Carlos Raúl Perasso via Jesper Nørgaard Welen (2006-10-13) -# http://www.presidencia.gov.py/decretos/D1867.pdf -Rule Para 2004 2009 - Oct Sun>=15 0:00 1:00 - -Rule Para 2005 2009 - Mar Sun>=8 0:00 0 - -# From Carlos Raúl Perasso (2010-02-18): -# By decree number 3958 issued yesterday -# http://www.presidencia.gov.py/v1/wp-content/uploads/2010/02/decreto3958.pdf -# Paraguay changes its DST schedule, postponing the March rule to April and -# modifying the October date. The decree reads: -# ... -# Art. 1. It is hereby established that from the second Sunday of the month of -# April of this year (2010), the official time is to be set back 60 minutes, -# and that on the first Sunday of the month of October, it is to be set -# forward 60 minutes, in all the territory of the Paraguayan Republic. -# ... -Rule Para 2010 max - Oct Sun>=1 0:00 1:00 - -Rule Para 2010 2012 - Apr Sun>=8 0:00 0 - -# -# From Steffen Thorsen (2013-03-07): -# Paraguay will end DST on 2013-03-24 00:00.... -# http://www.ande.gov.py/interna.php?id=1075 -# -# From Carlos Raúl Perasso (2013-03-15): -# The change in Paraguay is now final. Decree number 10780 -# http://www.presidencia.gov.py/uploads/pdf/presidencia-3b86ff4b691c79d4f5927ca964922ec74772ce857c02ca054a52a37b49afc7fb.pdf -# From Carlos Raúl Perasso (2014-02-28): -# Decree 1264 can be found at: -# http://www.presidencia.gov.py/archivos/documentos/DECRETO1264_ey9r8zai.pdf -Rule Para 2013 max - Mar Sun>=22 0:00 0 - - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Asuncion -3:50:40 - LMT 1890 - -3:50:40 - AMT 1931 Oct 10 # Asunción Mean Time - -4:00 - -04 1972 Oct - -3:00 - -03 1974 Apr - -4:00 Para -04/-03 - -# Peru -# -# From Evelyn C. Leeper via Mark Brader (2003-10-26) -# <news:xrGmb.39935$gA1.13896113@news4.srv.hcvlny.cv.net>: -# When we were in Peru in 1985-1986, they apparently switched over -# sometime between December 29 and January 3 while we were on the Amazon. -# -# From Paul Eggert (2006-03-22): -# Shanks & Pottenger don't have this transition. Assume 1986 was like 1987. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Peru 1938 only - Jan 1 0:00 1:00 - -Rule Peru 1938 only - Apr 1 0:00 0 - -Rule Peru 1938 1939 - Sep lastSun 0:00 1:00 - -Rule Peru 1939 1940 - Mar Sun>=24 0:00 0 - -Rule Peru 1986 1987 - Jan 1 0:00 1:00 - -Rule Peru 1986 1987 - Apr 1 0:00 0 - -Rule Peru 1990 only - Jan 1 0:00 1:00 - -Rule Peru 1990 only - Apr 1 0:00 0 - -# IATA is ambiguous for 1993/1995; go with Shanks & Pottenger. -Rule Peru 1994 only - Jan 1 0:00 1:00 - -Rule Peru 1994 only - Apr 1 0:00 0 - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Lima -5:08:12 - LMT 1890 - -5:08:36 - LMT 1908 Jul 28 # Lima Mean Time? - -5:00 Peru -05/-04 - -# South Georgia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/South_Georgia -2:26:08 - LMT 1890 # Grytviken - -2:00 - -02 - -# South Sandwich Is -# uninhabited; scientific personnel have wintered - -# Suriname -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Paramaribo -3:40:40 - LMT 1911 - -3:40:52 - PMT 1935 # Paramaribo Mean Time - -3:40:36 - PMT 1945 Oct # The capital moved? - -3:30 - -0330 1984 Oct - -3:00 - -03 - -# Trinidad and Tobago -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Port_of_Spain -4:06:04 - LMT 1912 Mar 2 - -4:00 - AST - -# These all agree with Trinidad and Tobago since 1970. -Link America/Port_of_Spain America/Anguilla -Link America/Port_of_Spain America/Antigua -Link America/Port_of_Spain America/Dominica -Link America/Port_of_Spain America/Grenada -Link America/Port_of_Spain America/Guadeloupe -Link America/Port_of_Spain America/Marigot # St Martin (French part) -Link America/Port_of_Spain America/Montserrat -Link America/Port_of_Spain America/St_Barthelemy # St Barthélemy -Link America/Port_of_Spain America/St_Kitts # St Kitts & Nevis -Link America/Port_of_Spain America/St_Lucia -Link America/Port_of_Spain America/St_Thomas # Virgin Islands (US) -Link America/Port_of_Spain America/St_Vincent -Link America/Port_of_Spain America/Tortola # Virgin Islands (UK) - -# Uruguay -# From Paul Eggert (1993-11-18): -# Uruguay wins the prize for the strangest peacetime manipulation of the rules. -# -# From Tim Parenti (2018-02-20), per Jeremie Bonjour (2018-01-31) and Michael -# Deckers (2018-02-20): -# ... At least they kept good records... -# -# http://www.armada.mil.uy/ContenidosPDFs/sohma/web/almanaque/almanaque_2018.pdf#page=36 -# Page 36 of Almanaque 2018, published by the Oceanography, Hydrography, and -# Meteorology Service of the Uruguayan Navy, seems to give many transitions -# with greater clarity than we've had before. It directly references many laws -# and decrees which are, in turn, referenced below. They can be viewed in the -# public archives of the Diario Oficial (in Spanish) at -# http://www.impo.com.uy/diariooficial/ -# -# Ley No. 3920 of 1908-06-10 placed the determination of legal time under the -# auspices of the National Institute for the Prediction of Time. It is unclear -# exactly what offset was used during this period, though Ley No. 7200 of -# 1920-04-23 used the Observatory of the National Meteorological Institute in -# Montevideo (34° 54' 33" S, 56° 12' 45" W) as its reference meridian, -# retarding legal time by 15 minutes 9 seconds from 1920-04-30 24:00, -# resulting in UT-04. Assume the corresponding LMT of UT-03:44:51 (given on -# page 725 of the Proceedings of the Second Pan-American Scientific Congress, -# 1915-1916) was in use, and merely became official from 1908-06-10. -# https://www.impo.com.uy/diariooficial/1908/06/18/12 -# https://www.impo.com.uy/diariooficial/1920/04/27/9 -# -# Ley No. 7594 of 1923-06-28 specified legal time as Observatory time advanced -# by 44 minutes 51 seconds (UT-03) "from 30 September to 31 March", and by 14 -# minutes 51 seconds (UT-03:30) "the rest of the year"; a message from the -# National Council of Administration the same day, published directly below the -# law in the Diario Oficial, specified the first transition to be 1923-09-30 -# 24:00. This effectively established standard time at UT-03:30 with 30 -# minutes DST. Assume transitions at 24:00 on the specified days until Ley No. -# 7919 of 1926-03-05 ended this arrangement, repealing all "laws and other -# provisions which oppose" it, resulting in year-round UT-03:30; a Resolución -# of 1926-03-11 puts the final transition at 1926-03-31 24:00, the same as it -# would have been under the previous law. -# https://www.impo.com.uy/diariooficial/1923/07/02/2 -# https://www.impo.com.uy/diariooficial/1926/03/10/2 -# https://www.impo.com.uy/diariooficial/1926/03/18/2 -# -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Uruguay 1923 1925 - Oct 1 0:00 0:30 - -Rule Uruguay 1924 1926 - Apr 1 0:00 0 - -# From Tim Parenti (2018-02-15): -# http://www.impo.com.uy/diariooficial/1933/10/27/6 -# -# It appears Ley No. 9122 of 1933 was never published as such in the Diario -# Oficial, but instead appeared as Document 26 in the Diario on Friday -# 1933-10-27 as a decree made Monday 1933-10-23 and filed under the Ministry of -# National Defense. It reinstituted a DST of 30 minutes (to UT-03) "from the -# last Sunday of October...until the last Saturday of March." In accordance -# with this provision, the first transition was explicitly specified in Article -# 2 of the decree as Saturday 1933-10-28 at 24:00; that is, Sunday 1933-10-29 -# at 00:00. Assume transitions at 00:00 Sunday throughout. -# -# Departing from the matter-of-fact nature of previous timekeeping laws, the -# 1933 decree "consider[s] the advantages of...the advance of legal time": -# -# "Whereas: The measure adopted by almost all nations at the time of the last -# World War still persists in North America and Europe, precisely because of -# the economic, hygienic, and social advantages derived from such an -# emergency measure... -# -# Whereas: The advance of the legal time during the summer seasons, by -# displacing social activity near sunrise, favors the citizen populations -# and especially the society that creates and works..." -# -# It further specified that "necessary measures" be taken to ensure that -# "public spectacles finish, in general, before [01:00]." -Rule Uruguay 1933 1938 - Oct lastSun 0:00 0:30 - -Rule Uruguay 1934 1941 - Mar lastSat 24:00 0 - -# From Tim Parenti (2018-02-15): -# Most of the Rules below, and their contemporaneous Zone lines, have been -# updated simply to match the Almanaque 2018. Although the document does not -# list exact transition times, midnight transitions were already present in our -# data here for all transitions through 2004-09, and this is both consistent -# with prior transitions and verified in several decrees marked below between -# 1939-09 and 2004-09, wherein the relevant text was typically of the form: -# -# "From 0 hours on [date], the legal time of the entire Republic will be... -# -# In accordance with [the preceding], on [previous date] at 24 hours, all -# clocks throughout the Republic will be [advanced/retarded] by..." -# -# It is possible that there is greater specificity to be found for the Rules -# below, but it is buried in no fewer than 40 different decrees individually -# referenced by the Almanaque for the period from 1939-09 to 2014-09. -# Four-fifths of these were promulgated less than two weeks before taking -# effect; more than half within a week and none more than 5 weeks. Only the -# handful with comments below have been checked with any thoroughness. -Rule Uruguay 1939 only - Oct 1 0:00 0:30 - -Rule Uruguay 1940 only - Oct 27 0:00 0:30 - -# From Tim Parenti (2018-02-15): -# Decreto 1145 of the Ministry of National Defense, dated 1941-07-26, specified -# UT-03 from Friday 1941-08-01 00:00, citing an "urgent...need to save fuel". -# http://www.impo.com.uy/diariooficial/1941/08/04/1 -Rule Uruguay 1941 only - Aug 1 0:00 0:30 - -# From Tim Parenti (2018-02-15): -# Decreto 1866 of the Ministry of National Defense, dated 1942-12-09, specified -# further advancement (to UT-02:30) from Sunday 1942-12-13 24:00. Since clocks -# never went back to UT-03:30 thereafter, this is modeled as advancing standard -# time by 30 minutes to UT-03, while retaining 30 minutes of DST. -# http://www.impo.com.uy/diariooficial/1942/12/16/3 -Rule Uruguay 1942 only - Dec 14 0:00 0:30 - -Rule Uruguay 1943 only - Mar 14 0:00 0 - -Rule Uruguay 1959 only - May 24 0:00 0:30 - -Rule Uruguay 1959 only - Nov 15 0:00 0 - -Rule Uruguay 1960 only - Jan 17 0:00 1:00 - -Rule Uruguay 1960 only - Mar 6 0:00 0 - -Rule Uruguay 1965 only - Apr 4 0:00 1:00 - -Rule Uruguay 1965 only - Sep 26 0:00 0 - -# From Tim Parenti (2018-02-15): -# Decreto 321/968 of 1968-05-25, citing emergency drought measures decreed the -# day before, brought clocks forward 30 minutes from Monday 1968-05-27 00:00. -# http://www.impo.com.uy/diariooficial/1968/05/30/5 -Rule Uruguay 1968 only - May 27 0:00 0:30 - -Rule Uruguay 1968 only - Dec 1 0:00 0 - -# From Tim Parenti (2018-02-15): -# Decreto 188/970 of 1970-04-23 instituted restrictions on electricity -# consumption "as a consequence of the current rainfall regime in the country". -# Articles 13 and 14 advanced clocks by an hour from Saturday 1970-04-25 00:00. -# http://www.impo.com.uy/diariooficial/1970/04/29/4 -Rule Uruguay 1970 only - Apr 25 0:00 1:00 - -Rule Uruguay 1970 only - Jun 14 0:00 0 - -Rule Uruguay 1972 only - Apr 23 0:00 1:00 - -Rule Uruguay 1972 only - Jul 16 0:00 0 - -# From Tim Parenti (2018-02-15): -# Decreto 29/974 of 1974-01-11, citing "the international rise in the price of -# oil", advanced clocks by 90 minutes (to UT-01:30). Decreto 163/974 of -# 1974-03-04 returned 60 of those minutes (to UT-02:30), and the remaining 30 -# minutes followed in Decreto 679/974 of 1974-08-29. -# http://www.impo.com.uy/diariooficial/1974/01/22/11 -# http://www.impo.com.uy/diariooficial/1974/03/14/3 -# http://www.impo.com.uy/diariooficial/1974/09/04/6 -Rule Uruguay 1974 only - Jan 13 0:00 1:30 - -Rule Uruguay 1974 only - Mar 10 0:00 0:30 - -Rule Uruguay 1974 only - Sep 1 0:00 0 - -Rule Uruguay 1974 only - Dec 22 0:00 1:00 - -Rule Uruguay 1975 only - Mar 30 0:00 0 - -Rule Uruguay 1976 only - Dec 19 0:00 1:00 - -Rule Uruguay 1977 only - Mar 6 0:00 0 - -Rule Uruguay 1977 only - Dec 4 0:00 1:00 - -Rule Uruguay 1978 1979 - Mar Sun>=1 0:00 0 - -Rule Uruguay 1978 only - Dec 17 0:00 1:00 - -Rule Uruguay 1979 only - Apr 29 0:00 1:00 - -Rule Uruguay 1980 only - Mar 16 0:00 0 - -# From Tim Parenti (2018-02-15): -# Decreto 725/987 of 1987-12-04 cited "better use of national tourist -# attractions" to advance clocks one hour from Monday 1987-12-14 00:00. -# http://www.impo.com.uy/diariooficial/1988/01/25/1 -Rule Uruguay 1987 only - Dec 14 0:00 1:00 - -Rule Uruguay 1988 only - Feb 28 0:00 0 - -Rule Uruguay 1988 only - Dec 11 0:00 1:00 - -Rule Uruguay 1989 only - Mar 5 0:00 0 - -Rule Uruguay 1989 only - Oct 29 0:00 1:00 - -Rule Uruguay 1990 only - Feb 25 0:00 0 - -# From Tim Parenti (2018-02-15), per Paul Eggert (1999-11-04): -# IATA agrees as below for 1990-10 through 1993-02. Per Almanaque 2018, the -# 1992/1993 season appears to be the first in over half a century where DST -# both began and ended pursuant to the same decree. -Rule Uruguay 1990 1991 - Oct Sun>=21 0:00 1:00 - -Rule Uruguay 1991 1992 - Mar Sun>=1 0:00 0 - -Rule Uruguay 1992 only - Oct 18 0:00 1:00 - -Rule Uruguay 1993 only - Feb 28 0:00 0 - -# From Eduardo Cota (2004-09-20): -# The Uruguayan government has decreed a change in the local time.... -# From Tim Parenti (2018-02-15): -# Decreto 328/004 of 2004-09-15. -# http://www.impo.com.uy/diariooficial/2004/09/23/documentos.pdf#page=1 -Rule Uruguay 2004 only - Sep 19 0:00 1:00 - -# From Steffen Thorsen (2005-03-11): -# Uruguay's DST was scheduled to end on Sunday, 2005-03-13, but in order to -# save energy ... it was postponed two weeks.... -# From Tim Parenti (2018-02-15): -# This 2005 postponement is not in Almanaque 2018. Go with the contemporaneous -# reporting, which is confirmed by Decreto 107/005 of 2005-03-10 amending -# Decreto 328/004: -# http://www.impo.com.uy/diariooficial/2005/03/15/documentos.pdf#page=1 -# The original decree specified a transition of 2005-03-12 24:00, but the new -# one specified 2005-03-27 02:00. -Rule Uruguay 2005 only - Mar 27 2:00 0 - -# From Eduardo Cota (2005-09-27): -# ...from 2005-10-09 at 02:00 local time, until 2006-03-12 at 02:00 local time, -# official time in Uruguay will be at GMT -2. -# From Tim Parenti (2018-02-15): -# Decreto 318/005 of 2005-09-19. -# http://www.impo.com.uy/diariooficial/2005/09/23/documentos.pdf#page=1 -Rule Uruguay 2005 only - Oct 9 2:00 1:00 - -Rule Uruguay 2006 2015 - Mar Sun>=8 2:00 0 - -# From Tim Parenti (2018-02-15), per Jesper Nørgaard Welen (2006-09-06): -# Decreto 311/006 of 2006-09-04 established regular DST from the first Sunday -# of October at 02:00 through the second Sunday of March at 02:00. Almanaque -# 2018 appears to have a few typoed dates through this period; ignore them. -# http://www.impo.com.uy/diariooficial/2006/09/08/documentos.pdf#page=1 -Rule Uruguay 2006 2014 - Oct Sun>=1 2:00 1:00 - -# From Steffen Thorsen (2015-06-30): -# ... it looks like they will not be using DST the coming summer: -# http://www.elobservador.com.uy/gobierno-resolvio-que-no-habra-cambio-horario-verano-n656787 -# http://www.republica.com.uy/este-ano-no-se-modificara-el-huso-horario-en-uruguay/523760/ -# From Paul Eggert (2015-06-30): -# Apparently restaurateurs complained that DST caused people to go to the beach -# instead of out to dinner. -# From Pablo Camargo (2015-07-13): -# http://archivo.presidencia.gub.uy/sci/decretos/2015/06/cons_min_201.pdf -# From Tim Parenti (2018-02-15): -# Decreto 178/015 of 2015-06-29; repeals Decreto 311/006. - -# This Zone can be simplified once we assume zic %z. -Zone America/Montevideo -3:44:51 - LMT 1908 Jun 10 - -3:44:51 - MMT 1920 May 1 # Montevideo MT - -4:00 - -04 1923 Oct 1 - -3:30 Uruguay -0330/-03 1942 Dec 14 - -3:00 Uruguay -03/-0230 1960 - -3:00 Uruguay -03/-02 1968 - -3:00 Uruguay -03/-0230 1970 - -3:00 Uruguay -03/-02 1974 - -3:00 Uruguay -03/-0130 1974 Mar 10 - -3:00 Uruguay -03/-0230 1974 Dec 22 - -3:00 Uruguay -03/-02 - -# Venezuela -# -# From Paul Eggert (2015-07-28): -# For the 1965 transition see Gaceta Oficial No. 27.619 (1964-12-15), p 205.533 -# http://www.pgr.gob.ve/dmdocuments/1964/27619.pdf -# -# From John Stainforth (2007-11-28): -# ... the change for Venezuela originally expected for 2007-12-31 has -# been brought forward to 2007-12-09. The official announcement was -# published today in the "Gaceta Oficial de la República Bolivariana -# de Venezuela, número 38.819" (official document for all laws or -# resolution publication) -# http://www.globovision.com/news.php?nid=72208 - -# From Alexander Krivenyshev (2016-04-15): -# https://actualidad.rt.com/actualidad/204758-venezuela-modificar-huso-horario-sequia-elnino -# -# From Paul Eggert (2016-04-15): -# Clocks advance 30 minutes on 2016-05-01 at 02:30.... -# "'Venezuela's new time-zone: hours without light, hours without water, -# hours of presidential broadcasts, hours of lines,' quipped comedian -# Jean Mary Curró ...". See: Cawthorne A, Kai D. Venezuela scraps -# half-hour time difference set by Chavez. Reuters 2016-04-15 14:50 -0400 -# https://www.reuters.com/article/us-venezuela-timezone-idUSKCN0XC2BE -# -# From Matt Johnson (2016-04-20): -# ... published in the official Gazette [2016-04-18], here: -# http://historico.tsj.gob.ve/gaceta_ext/abril/1842016/E-1842016-4551.pdf - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Caracas -4:27:44 - LMT 1890 - -4:27:40 - CMT 1912 Feb 12 # Caracas Mean Time? - -4:30 - -0430 1965 Jan 1 0:00 - -4:00 - -04 2007 Dec 9 3:00 - -4:30 - -0430 2016 May 1 2:30 - -4:00 - -04 diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/systemv b/src/test/jdk/sun/util/calendar/zi/tzdata/systemv deleted file mode 100644 index 63a48e8c3e0..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/systemv +++ /dev/null @@ -1,62 +0,0 @@ -# -# 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. -# -# tzdb data for System V rules (this file is obsolete) - -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. - -# Old rules, should the need arise. -# No attempt is made to handle Newfoundland, since it cannot be expressed -# using the System V "TZ" scheme (half-hour offset), or anything outside -# North America (no support for non-standard DST start/end dates), nor -# the changes in the DST rules in the US after 1976 (which occurred after -# the old rules were written). -# -# If you need the old rules, uncomment ## lines. -# Compile this *without* leap second correction for true conformance. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule SystemV min 1973 - Apr lastSun 2:00 1:00 D -Rule SystemV min 1973 - Oct lastSun 2:00 0 S -Rule SystemV 1974 only - Jan 6 2:00 1:00 D -Rule SystemV 1974 only - Nov lastSun 2:00 0 S -Rule SystemV 1975 only - Feb 23 2:00 1:00 D -Rule SystemV 1975 only - Oct lastSun 2:00 0 S -Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D -Rule SystemV 1976 max - Oct lastSun 2:00 0 S - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -## Zone SystemV/AST4ADT -4:00 SystemV A%sT -## Zone SystemV/EST5EDT -5:00 SystemV E%sT -## Zone SystemV/CST6CDT -6:00 SystemV C%sT -## Zone SystemV/MST7MDT -7:00 SystemV M%sT -## Zone SystemV/PST8PDT -8:00 SystemV P%sT -## Zone SystemV/YST9YDT -9:00 SystemV Y%sT -## Zone SystemV/AST4 -4:00 - AST -## Zone SystemV/EST5 -5:00 - EST -## Zone SystemV/CST6 -6:00 - CST -## Zone SystemV/MST7 -7:00 - MST -## Zone SystemV/PST8 -8:00 - PST -## Zone SystemV/YST9 -9:00 - YST -## Zone SystemV/HST10 -10:00 - HST diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata/zone.tab b/src/test/jdk/sun/util/calendar/zi/tzdata/zone.tab deleted file mode 100644 index 2a985868d28..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata/zone.tab +++ /dev/null @@ -1,471 +0,0 @@ -# -# 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. -# -# tzdb timezone descriptions (deprecated version) -# -# This file is in the public domain, so clarified as of -# 2009-05-17 by Arthur David Olson. -# -# From Paul Eggert (2018-06-27): -# This file is intended as a backward-compatibility aid for older programs. -# New programs should use zone1970.tab. This file is like zone1970.tab (see -# zone1970.tab's comments), but with the following additional restrictions: -# -# 1. This file contains only ASCII characters. -# 2. The first data column contains exactly one country code. -# -# Because of (2), each row stands for an area that is the intersection -# of a region identified by a country code and of a timezone where civil -# clocks have agreed since 1970; this is a narrower definition than -# that of zone1970.tab. -# -# This table is intended as an aid for users, to help them select timezones -# appropriate for their practical needs. It is not intended to take or -# endorse any position on legal or territorial claims. -# -#country- -#code coordinates TZ comments -AD +4230+00131 Europe/Andorra -AE +2518+05518 Asia/Dubai -AF +3431+06912 Asia/Kabul -AG +1703-06148 America/Antigua -AI +1812-06304 America/Anguilla -AL +4120+01950 Europe/Tirane -AM +4011+04430 Asia/Yerevan -AO -0848+01314 Africa/Luanda -AQ -7750+16636 Antarctica/McMurdo New Zealand time - McMurdo, South Pole -AQ -6617+11031 Antarctica/Casey Casey -AQ -6835+07758 Antarctica/Davis Davis -AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville -AQ -6736+06253 Antarctica/Mawson Mawson -AQ -6448-06406 Antarctica/Palmer Palmer -AQ -6734-06808 Antarctica/Rothera Rothera -AQ -690022+0393524 Antarctica/Syowa Syowa -AQ -720041+0023206 Antarctica/Troll Troll -AQ -7824+10654 Antarctica/Vostok Vostok -AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) -AR -3124-06411 America/Argentina/Cordoba Argentina (most areas: CB, CC, CN, ER, FM, MN, SE, SF) -AR -2447-06525 America/Argentina/Salta Salta (SA, LP, NQ, RN) -AR -2411-06518 America/Argentina/Jujuy Jujuy (JY) -AR -2649-06513 America/Argentina/Tucuman Tucuman (TM) -AR -2828-06547 America/Argentina/Catamarca Catamarca (CT); Chubut (CH) -AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR) -AR -3132-06831 America/Argentina/San_Juan San Juan (SJ) -AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ) -AR -3319-06621 America/Argentina/San_Luis San Luis (SL) -AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC) -AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF) -AS -1416-17042 Pacific/Pago_Pago -AT +4813+01620 Europe/Vienna -AU -3133+15905 Australia/Lord_Howe Lord Howe Island -AU -5430+15857 Antarctica/Macquarie Macquarie Island -AU -4253+14719 Australia/Hobart Tasmania (most areas) -AU -3956+14352 Australia/Currie Tasmania (King Island) -AU -3749+14458 Australia/Melbourne Victoria -AU -3352+15113 Australia/Sydney New South Wales (most areas) -AU -3157+14127 Australia/Broken_Hill New South Wales (Yancowinna) -AU -2728+15302 Australia/Brisbane Queensland (most areas) -AU -2016+14900 Australia/Lindeman Queensland (Whitsunday Islands) -AU -3455+13835 Australia/Adelaide South Australia -AU -1228+13050 Australia/Darwin Northern Territory -AU -3157+11551 Australia/Perth Western Australia (most areas) -AU -3143+12852 Australia/Eucla Western Australia (Eucla) -AW +1230-06958 America/Aruba -AX +6006+01957 Europe/Mariehamn -AZ +4023+04951 Asia/Baku -BA +4352+01825 Europe/Sarajevo -BB +1306-05937 America/Barbados -BD +2343+09025 Asia/Dhaka -BE +5050+00420 Europe/Brussels -BF +1222-00131 Africa/Ouagadougou -BG +4241+02319 Europe/Sofia -BH +2623+05035 Asia/Bahrain -BI -0323+02922 Africa/Bujumbura -BJ +0629+00237 Africa/Porto-Novo -BL +1753-06251 America/St_Barthelemy -BM +3217-06446 Atlantic/Bermuda -BN +0456+11455 Asia/Brunei -BO -1630-06809 America/La_Paz -BQ +120903-0681636 America/Kralendijk -BR -0351-03225 America/Noronha Atlantic islands -BR -0127-04829 America/Belem Para (east); Amapa -BR -0343-03830 America/Fortaleza Brazil (northeast: MA, PI, CE, RN, PB) -BR -0803-03454 America/Recife Pernambuco -BR -0712-04812 America/Araguaina Tocantins -BR -0940-03543 America/Maceio Alagoas, Sergipe -BR -1259-03831 America/Bahia Bahia -BR -2332-04637 America/Sao_Paulo Brazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS) -BR -2027-05437 America/Campo_Grande Mato Grosso do Sul -BR -1535-05605 America/Cuiaba Mato Grosso -BR -0226-05452 America/Santarem Para (west) -BR -0846-06354 America/Porto_Velho Rondonia -BR +0249-06040 America/Boa_Vista Roraima -BR -0308-06001 America/Manaus Amazonas (east) -BR -0640-06952 America/Eirunepe Amazonas (west) -BR -0958-06748 America/Rio_Branco Acre -BS +2505-07721 America/Nassau -BT +2728+08939 Asia/Thimphu -BW -2439+02555 Africa/Gaborone -BY +5354+02734 Europe/Minsk -BZ +1730-08812 America/Belize -CA +4734-05243 America/St_Johns Newfoundland; Labrador (southeast) -CA +4439-06336 America/Halifax Atlantic - NS (most areas); PE -CA +4612-05957 America/Glace_Bay Atlantic - NS (Cape Breton) -CA +4606-06447 America/Moncton Atlantic - New Brunswick -CA +5320-06025 America/Goose_Bay Atlantic - Labrador (most areas) -CA +5125-05707 America/Blanc-Sablon AST - QC (Lower North Shore) -CA +4339-07923 America/Toronto Eastern - ON, QC (most areas) -CA +4901-08816 America/Nipigon Eastern - ON, QC (no DST 1967-73) -CA +4823-08915 America/Thunder_Bay Eastern - ON (Thunder Bay) -CA +6344-06828 America/Iqaluit Eastern - NU (most east areas) -CA +6608-06544 America/Pangnirtung Eastern - NU (Pangnirtung) -CA +484531-0913718 America/Atikokan EST - ON (Atikokan); NU (Coral H) -CA +4953-09709 America/Winnipeg Central - ON (west); Manitoba -CA +4843-09434 America/Rainy_River Central - ON (Rainy R, Ft Frances) -CA +744144-0944945 America/Resolute Central - NU (Resolute) -CA +624900-0920459 America/Rankin_Inlet Central - NU (central) -CA +5024-10439 America/Regina CST - SK (most areas) -CA +5017-10750 America/Swift_Current CST - SK (midwest) -CA +5333-11328 America/Edmonton Mountain - AB; BC (E); SK (W) -CA +690650-1050310 America/Cambridge_Bay Mountain - NU (west) -CA +6227-11421 America/Yellowknife Mountain - NT (central) -CA +682059-1334300 America/Inuvik Mountain - NT (west) -CA +4906-11631 America/Creston MST - BC (Creston) -CA +5946-12014 America/Dawson_Creek MST - BC (Dawson Cr, Ft St John) -CA +5848-12242 America/Fort_Nelson MST - BC (Ft Nelson) -CA +4916-12307 America/Vancouver Pacific - BC (most areas) -CA +6043-13503 America/Whitehorse Pacific - Yukon (south) -CA +6404-13925 America/Dawson Pacific - Yukon (north) -CC -1210+09655 Indian/Cocos -CD -0418+01518 Africa/Kinshasa Dem. Rep. of Congo (west) -CD -1140+02728 Africa/Lubumbashi Dem. Rep. of Congo (east) -CF +0422+01835 Africa/Bangui -CG -0416+01517 Africa/Brazzaville -CH +4723+00832 Europe/Zurich -CI +0519-00402 Africa/Abidjan -CK -2114-15946 Pacific/Rarotonga -CL -3327-07040 America/Santiago Chile (most areas) -CL -5309-07055 America/Punta_Arenas Region of Magallanes -CL -2709-10926 Pacific/Easter Easter Island -CM +0403+00942 Africa/Douala -CN +3114+12128 Asia/Shanghai Beijing Time -CN +4348+08735 Asia/Urumqi Xinjiang Time -CO +0436-07405 America/Bogota -CR +0956-08405 America/Costa_Rica -CU +2308-08222 America/Havana -CV +1455-02331 Atlantic/Cape_Verde -CW +1211-06900 America/Curacao -CX -1025+10543 Indian/Christmas -CY +3510+03322 Asia/Nicosia Cyprus (most areas) -CY +3507+03357 Asia/Famagusta Northern Cyprus -CZ +5005+01426 Europe/Prague -DE +5230+01322 Europe/Berlin Germany (most areas) -DE +4742+00841 Europe/Busingen Busingen -DJ +1136+04309 Africa/Djibouti -DK +5540+01235 Europe/Copenhagen -DM +1518-06124 America/Dominica -DO +1828-06954 America/Santo_Domingo -DZ +3647+00303 Africa/Algiers -EC -0210-07950 America/Guayaquil Ecuador (mainland) -EC -0054-08936 Pacific/Galapagos Galapagos Islands -EE +5925+02445 Europe/Tallinn -EG +3003+03115 Africa/Cairo -EH +2709-01312 Africa/El_Aaiun -ER +1520+03853 Africa/Asmara -ES +4024-00341 Europe/Madrid Spain (mainland) -ES +3553-00519 Africa/Ceuta Ceuta, Melilla -ES +2806-01524 Atlantic/Canary Canary Islands -ET +0902+03842 Africa/Addis_Ababa -FI +6010+02458 Europe/Helsinki -FJ -1808+17825 Pacific/Fiji -FK -5142-05751 Atlantic/Stanley -FM +0725+15147 Pacific/Chuuk Chuuk/Truk, Yap -FM +0658+15813 Pacific/Pohnpei Pohnpei/Ponape -FM +0519+16259 Pacific/Kosrae Kosrae -FO +6201-00646 Atlantic/Faroe -FR +4852+00220 Europe/Paris -GA +0023+00927 Africa/Libreville -GB +513030-0000731 Europe/London -GD +1203-06145 America/Grenada -GE +4143+04449 Asia/Tbilisi -GF +0456-05220 America/Cayenne -GG +492717-0023210 Europe/Guernsey -GH +0533-00013 Africa/Accra -GI +3608-00521 Europe/Gibraltar -GL +6411-05144 America/Godthab Greenland (most areas) -GL +7646-01840 America/Danmarkshavn National Park (east coast) -GL +7029-02158 America/Scoresbysund Scoresbysund/Ittoqqortoormiit -GL +7634-06847 America/Thule Thule/Pituffik -GM +1328-01639 Africa/Banjul -GN +0931-01343 Africa/Conakry -GP +1614-06132 America/Guadeloupe -GQ +0345+00847 Africa/Malabo -GR +3758+02343 Europe/Athens -GS -5416-03632 Atlantic/South_Georgia -GT +1438-09031 America/Guatemala -GU +1328+14445 Pacific/Guam -GW +1151-01535 Africa/Bissau -GY +0648-05810 America/Guyana -HK +2217+11409 Asia/Hong_Kong -HN +1406-08713 America/Tegucigalpa -HR +4548+01558 Europe/Zagreb -HT +1832-07220 America/Port-au-Prince -HU +4730+01905 Europe/Budapest -ID -0610+10648 Asia/Jakarta Java, Sumatra -ID -0002+10920 Asia/Pontianak Borneo (west, central) -ID -0507+11924 Asia/Makassar Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west) -ID -0232+14042 Asia/Jayapura New Guinea (West Papua / Irian Jaya); Malukus/Moluccas -IE +5320-00615 Europe/Dublin -IL +314650+0351326 Asia/Jerusalem -IM +5409-00428 Europe/Isle_of_Man -IN +2232+08822 Asia/Kolkata -IO -0720+07225 Indian/Chagos -IQ +3321+04425 Asia/Baghdad -IR +3540+05126 Asia/Tehran -IS +6409-02151 Atlantic/Reykjavik -IT +4154+01229 Europe/Rome -JE +491101-0020624 Europe/Jersey -JM +175805-0764736 America/Jamaica -JO +3157+03556 Asia/Amman -JP +353916+1394441 Asia/Tokyo -KE -0117+03649 Africa/Nairobi -KG +4254+07436 Asia/Bishkek -KH +1133+10455 Asia/Phnom_Penh -KI +0125+17300 Pacific/Tarawa Gilbert Islands -KI -0308-17105 Pacific/Enderbury Phoenix Islands -KI +0152-15720 Pacific/Kiritimati Line Islands -KM -1141+04316 Indian/Comoro -KN +1718-06243 America/St_Kitts -KP +3901+12545 Asia/Pyongyang -KR +3733+12658 Asia/Seoul -KW +2920+04759 Asia/Kuwait -KY +1918-08123 America/Cayman -KZ +4315+07657 Asia/Almaty Kazakhstan (most areas) -KZ +4448+06528 Asia/Qyzylorda Qyzylorda/Kyzylorda/Kzyl-Orda -KZ +5017+05710 Asia/Aqtobe Aqtobe/Aktobe -KZ +4431+05016 Asia/Aqtau Mangghystau/Mankistau -KZ +4707+05156 Asia/Atyrau Atyrau/Atirau/Gur'yev -KZ +5113+05121 Asia/Oral West Kazakhstan -LA +1758+10236 Asia/Vientiane -LB +3353+03530 Asia/Beirut -LC +1401-06100 America/St_Lucia -LI +4709+00931 Europe/Vaduz -LK +0656+07951 Asia/Colombo -LR +0618-01047 Africa/Monrovia -LS -2928+02730 Africa/Maseru -LT +5441+02519 Europe/Vilnius -LU +4936+00609 Europe/Luxembourg -LV +5657+02406 Europe/Riga -LY +3254+01311 Africa/Tripoli -MA +3339-00735 Africa/Casablanca -MC +4342+00723 Europe/Monaco -MD +4700+02850 Europe/Chisinau -ME +4226+01916 Europe/Podgorica -MF +1804-06305 America/Marigot -MG -1855+04731 Indian/Antananarivo -MH +0709+17112 Pacific/Majuro Marshall Islands (most areas) -MH +0905+16720 Pacific/Kwajalein Kwajalein -MK +4159+02126 Europe/Skopje -ML +1239-00800 Africa/Bamako -MM +1647+09610 Asia/Yangon -MN +4755+10653 Asia/Ulaanbaatar Mongolia (most areas) -MN +4801+09139 Asia/Hovd Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan -MN +4804+11430 Asia/Choibalsan Dornod, Sukhbaatar -MO +221150+1133230 Asia/Macau -MP +1512+14545 Pacific/Saipan -MQ +1436-06105 America/Martinique -MR +1806-01557 Africa/Nouakchott -MS +1643-06213 America/Montserrat -MT +3554+01431 Europe/Malta -MU -2010+05730 Indian/Mauritius -MV +0410+07330 Indian/Maldives -MW -1547+03500 Africa/Blantyre -MX +1924-09909 America/Mexico_City Central Time -MX +2105-08646 America/Cancun Eastern Standard Time - Quintana Roo -MX +2058-08937 America/Merida Central Time - Campeche, Yucatan -MX +2540-10019 America/Monterrey Central Time - Durango; Coahuila, Nuevo Leon, Tamaulipas (most areas) -MX +2550-09730 America/Matamoros Central Time US - Coahuila, Nuevo Leon, Tamaulipas (US border) -MX +2313-10625 America/Mazatlan Mountain Time - Baja California Sur, Nayarit, Sinaloa -MX +2838-10605 America/Chihuahua Mountain Time - Chihuahua (most areas) -MX +2934-10425 America/Ojinaga Mountain Time US - Chihuahua (US border) -MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora -MX +3232-11701 America/Tijuana Pacific Time US - Baja California -MX +2048-10515 America/Bahia_Banderas Central Time - Bahia de Banderas -MY +0310+10142 Asia/Kuala_Lumpur Malaysia (peninsula) -MY +0133+11020 Asia/Kuching Sabah, Sarawak -MZ -2558+03235 Africa/Maputo -NA -2234+01706 Africa/Windhoek -NC -2216+16627 Pacific/Noumea -NE +1331+00207 Africa/Niamey -NF -2903+16758 Pacific/Norfolk -NG +0627+00324 Africa/Lagos -NI +1209-08617 America/Managua -NL +5222+00454 Europe/Amsterdam -NO +5955+01045 Europe/Oslo -NP +2743+08519 Asia/Kathmandu -NR -0031+16655 Pacific/Nauru -NU -1901-16955 Pacific/Niue -NZ -3652+17446 Pacific/Auckland New Zealand (most areas) -NZ -4357-17633 Pacific/Chatham Chatham Islands -OM +2336+05835 Asia/Muscat -PA +0858-07932 America/Panama -PE -1203-07703 America/Lima -PF -1732-14934 Pacific/Tahiti Society Islands -PF -0900-13930 Pacific/Marquesas Marquesas Islands -PF -2308-13457 Pacific/Gambier Gambier Islands -PG -0930+14710 Pacific/Port_Moresby Papua New Guinea (most areas) -PG -0613+15534 Pacific/Bougainville Bougainville -PH +1435+12100 Asia/Manila -PK +2452+06703 Asia/Karachi -PL +5215+02100 Europe/Warsaw -PM +4703-05620 America/Miquelon -PN -2504-13005 Pacific/Pitcairn -PR +182806-0660622 America/Puerto_Rico -PS +3130+03428 Asia/Gaza Gaza Strip -PS +313200+0350542 Asia/Hebron West Bank -PT +3843-00908 Europe/Lisbon Portugal (mainland) -PT +3238-01654 Atlantic/Madeira Madeira Islands -PT +3744-02540 Atlantic/Azores Azores -PW +0720+13429 Pacific/Palau -PY -2516-05740 America/Asuncion -QA +2517+05132 Asia/Qatar -RE -2052+05528 Indian/Reunion -RO +4426+02606 Europe/Bucharest -RS +4450+02030 Europe/Belgrade -RU +5443+02030 Europe/Kaliningrad MSK-01 - Kaliningrad -RU +554521+0373704 Europe/Moscow MSK+00 - Moscow area -RU +4457+03406 Europe/Simferopol MSK+00 - Crimea -RU +4844+04425 Europe/Volgograd MSK+00 - Volgograd -RU +5836+04939 Europe/Kirov MSK+00 - Kirov -RU +4621+04803 Europe/Astrakhan MSK+01 - Astrakhan -RU +5134+04602 Europe/Saratov MSK+01 - Saratov -RU +5420+04824 Europe/Ulyanovsk MSK+01 - Ulyanovsk -RU +5312+05009 Europe/Samara MSK+01 - Samara, Udmurtia -RU +5651+06036 Asia/Yekaterinburg MSK+02 - Urals -RU +5500+07324 Asia/Omsk MSK+03 - Omsk -RU +5502+08255 Asia/Novosibirsk MSK+04 - Novosibirsk -RU +5322+08345 Asia/Barnaul MSK+04 - Altai -RU +5630+08458 Asia/Tomsk MSK+04 - Tomsk -RU +5345+08707 Asia/Novokuznetsk MSK+04 - Kemerovo -RU +5601+09250 Asia/Krasnoyarsk MSK+04 - Krasnoyarsk area -RU +5216+10420 Asia/Irkutsk MSK+05 - Irkutsk, Buryatia -RU +5203+11328 Asia/Chita MSK+06 - Zabaykalsky -RU +6200+12940 Asia/Yakutsk MSK+06 - Lena River -RU +623923+1353314 Asia/Khandyga MSK+06 - Tomponsky, Ust-Maysky -RU +4310+13156 Asia/Vladivostok MSK+07 - Amur River -RU +643337+1431336 Asia/Ust-Nera MSK+07 - Oymyakonsky -RU +5934+15048 Asia/Magadan MSK+08 - Magadan -RU +4658+14242 Asia/Sakhalin MSK+08 - Sakhalin Island -RU +6728+15343 Asia/Srednekolymsk MSK+08 - Sakha (E); North Kuril Is -RU +5301+15839 Asia/Kamchatka MSK+09 - Kamchatka -RU +6445+17729 Asia/Anadyr MSK+09 - Bering Sea -RW -0157+03004 Africa/Kigali -SA +2438+04643 Asia/Riyadh -SB -0932+16012 Pacific/Guadalcanal -SC -0440+05528 Indian/Mahe -SD +1536+03232 Africa/Khartoum -SE +5920+01803 Europe/Stockholm -SG +0117+10351 Asia/Singapore -SH -1555-00542 Atlantic/St_Helena -SI +4603+01431 Europe/Ljubljana -SJ +7800+01600 Arctic/Longyearbyen -SK +4809+01707 Europe/Bratislava -SL +0830-01315 Africa/Freetown -SM +4355+01228 Europe/San_Marino -SN +1440-01726 Africa/Dakar -SO +0204+04522 Africa/Mogadishu -SR +0550-05510 America/Paramaribo -SS +0451+03137 Africa/Juba -ST +0020+00644 Africa/Sao_Tome -SV +1342-08912 America/El_Salvador -SX +180305-0630250 America/Lower_Princes -SY +3330+03618 Asia/Damascus -SZ -2618+03106 Africa/Mbabane -TC +2128-07108 America/Grand_Turk -TD +1207+01503 Africa/Ndjamena -TF -492110+0701303 Indian/Kerguelen -TG +0608+00113 Africa/Lome -TH +1345+10031 Asia/Bangkok -TJ +3835+06848 Asia/Dushanbe -TK -0922-17114 Pacific/Fakaofo -TL -0833+12535 Asia/Dili -TM +3757+05823 Asia/Ashgabat -TN +3648+01011 Africa/Tunis -TO -2110-17510 Pacific/Tongatapu -TR +4101+02858 Europe/Istanbul -TT +1039-06131 America/Port_of_Spain -TV -0831+17913 Pacific/Funafuti -TW +2503+12130 Asia/Taipei -TZ -0648+03917 Africa/Dar_es_Salaam -UA +5026+03031 Europe/Kiev Ukraine (most areas) -UA +4837+02218 Europe/Uzhgorod Ruthenia -UA +4750+03510 Europe/Zaporozhye Zaporozh'ye/Zaporizhia; Lugansk/Luhansk (east) -UG +0019+03225 Africa/Kampala -UM +2813-17722 Pacific/Midway Midway Islands -UM +1917+16637 Pacific/Wake Wake Island -US +404251-0740023 America/New_York Eastern (most areas) -US +421953-0830245 America/Detroit Eastern - MI (most areas) -US +381515-0854534 America/Kentucky/Louisville Eastern - KY (Louisville area) -US +364947-0845057 America/Kentucky/Monticello Eastern - KY (Wayne) -US +394606-0860929 America/Indiana/Indianapolis Eastern - IN (most areas) -US +384038-0873143 America/Indiana/Vincennes Eastern - IN (Da, Du, K, Mn) -US +410305-0863611 America/Indiana/Winamac Eastern - IN (Pulaski) -US +382232-0862041 America/Indiana/Marengo Eastern - IN (Crawford) -US +382931-0871643 America/Indiana/Petersburg Eastern - IN (Pike) -US +384452-0850402 America/Indiana/Vevay Eastern - IN (Switzerland) -US +415100-0873900 America/Chicago Central (most areas) -US +375711-0864541 America/Indiana/Tell_City Central - IN (Perry) -US +411745-0863730 America/Indiana/Knox Central - IN (Starke) -US +450628-0873651 America/Menominee Central - MI (Wisconsin border) -US +470659-1011757 America/North_Dakota/Center Central - ND (Oliver) -US +465042-1012439 America/North_Dakota/New_Salem Central - ND (Morton rural) -US +471551-1014640 America/North_Dakota/Beulah Central - ND (Mercer) -US +394421-1045903 America/Denver Mountain (most areas) -US +433649-1161209 America/Boise Mountain - ID (south); OR (east) -US +332654-1120424 America/Phoenix MST - Arizona (except Navajo) -US +340308-1181434 America/Los_Angeles Pacific -US +611305-1495401 America/Anchorage Alaska (most areas) -US +581807-1342511 America/Juneau Alaska - Juneau area -US +571035-1351807 America/Sitka Alaska - Sitka area -US +550737-1313435 America/Metlakatla Alaska - Annette Island -US +593249-1394338 America/Yakutat Alaska - Yakutat -US +643004-1652423 America/Nome Alaska (west) -US +515248-1763929 America/Adak Aleutian Islands -US +211825-1575130 Pacific/Honolulu Hawaii -UY -345433-0561245 America/Montevideo -UZ +3940+06648 Asia/Samarkand Uzbekistan (west) -UZ +4120+06918 Asia/Tashkent Uzbekistan (east) -VA +415408+0122711 Europe/Vatican -VC +1309-06114 America/St_Vincent -VE +1030-06656 America/Caracas -VG +1827-06437 America/Tortola -VI +1821-06456 America/St_Thomas -VN +1045+10640 Asia/Ho_Chi_Minh -VU -1740+16825 Pacific/Efate -WF -1318-17610 Pacific/Wallis -WS -1350-17144 Pacific/Apia -YE +1245+04512 Asia/Aden -YT -1247+04514 Indian/Mayotte -ZA -2615+02800 Africa/Johannesburg -ZM -1525+02817 Africa/Lusaka -ZW -1750+03103 Africa/Harare diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata_jdk/gmt b/src/test/jdk/sun/util/calendar/zi/tzdata_jdk/gmt deleted file mode 100644 index 7685fda0390..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata_jdk/gmt +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2000, 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. -# - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone GMT 0:00 - GMT diff --git a/src/test/jdk/sun/util/calendar/zi/tzdata_jdk/jdk11_full_backward b/src/test/jdk/sun/util/calendar/zi/tzdata_jdk/jdk11_full_backward deleted file mode 100644 index bba0aa95503..00000000000 --- a/src/test/jdk/sun/util/calendar/zi/tzdata_jdk/jdk11_full_backward +++ /dev/null @@ -1,93 +0,0 @@ -# -# Copyright (c) 2001, 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. -# -# JDK 1.1.x compatible time zone IDs -# - -Link Australia/Darwin ACT -Link Australia/Sydney AET -Link America/Argentina/Buenos_Aires AGT -Link Africa/Cairo ART -Link America/Anchorage AST -Link America/Sao_Paulo BET -Link Asia/Dhaka BST -Link Africa/Harare CAT -Link America/St_Johns CNT -Link America/Chicago CST -Link Asia/Shanghai CTT -Link Africa/Addis_Ababa EAT -Link Europe/Paris ECT -Link America/New_York EST -Link Pacific/Honolulu HST -Link America/Indiana/Indianapolis IET -Link Asia/Calcutta IST -Link Asia/Tokyo JST -Link Pacific/Apia MIT -Link America/Denver MST -Link Asia/Yerevan NET -Link Pacific/Auckland NST -Link Asia/Karachi PLT -Link America/Phoenix PNT -Link America/Puerto_Rico PRT -Link America/Los_Angeles PST -Link Pacific/Guadalcanal SST -Link Asia/Saigon VST - -# The follwong link is required to generate JDK 1.2.x and 1.3.x -# compatible zones. In the Olson public source, MET is defined as -# GMT+1:00 with the C-Eur rules. In JDK, MET is defined as an alias -# of Asia/Tehran. This line must be removed if a full set of Olson -# zones is generated. Otherwise, MET appears twice in the -# ZoneInfoMappings.IDs table. -Link Asia/Tehran MET - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule SystemV min 1973 - Apr lastSun 2:00 1:00 D -Rule SystemV min 1973 - Oct lastSun 2:00 0 S -Rule SystemV 1974 only - Jan 6 2:00 1:00 D -Rule SystemV 1974 only - Nov lastSun 2:00 0 S -Rule SystemV 1975 only - Feb 23 2:00 1:00 D -Rule SystemV 1975 only - Oct lastSun 2:00 0 S -Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D -Rule SystemV 1976 max - Oct lastSun 2:00 0 S - -# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] -Zone SystemV/AST4ADT -4:00 SystemV A%sT -Zone SystemV/EST5EDT -5:00 SystemV E%sT -Zone SystemV/CST6CDT -6:00 SystemV C%sT -Zone SystemV/MST7MDT -7:00 SystemV M%sT -Zone SystemV/PST8PDT -8:00 SystemV P%sT -Zone SystemV/YST9YDT -9:00 SystemV Y%sT -Zone SystemV/AST4 -4:00 - AST -Zone SystemV/EST5 -5:00 - EST -Zone SystemV/CST6 -6:00 - CST -Zone SystemV/MST7 -7:00 - MST -Zone SystemV/PST8 -8:00 - PST -Zone SystemV/YST9 -9:00 - YST -Zone SystemV/HST10 -10:00 - HST - -# -# For the UTC change in Mustang -# -Link GMT UTC diff --git a/src/test/jdk/tools/launcher/Settings.java b/src/test/jdk/tools/launcher/Settings.java index 0a7398f9b5c..57a1b1b96e0 100644 --- a/src/test/jdk/tools/launcher/Settings.java +++ b/src/test/jdk/tools/launcher/Settings.java @@ -68,6 +68,7 @@ static void checkNotContains(TestResult tr, String str) { private static final String PROP_SETTINGS = "Property settings:"; private static final String LOCALE_SETTINGS = "Locale settings:"; private static final String SYSTEM_SETTINGS = "Operating System Metrics:"; + private static final String STACKSIZE_SETTINGS = "Stack Size:"; static void containsAllOptions(TestResult tr) { checkContains(tr, VM_SETTINGS); @@ -82,10 +83,22 @@ static void runTestOptionDefault() throws IOException { int stackSize = 256; // in kb if (getArch().equals("ppc64") || getArch().equals("ppc64le")) { stackSize = 800; + } else if (getArch().equals("aarch64")) { + /* + * The max value of minimum stack size allowed for aarch64 can be estimated as + * such: suppose the vm page size is 64KB and the test runs with a debug build, + * the initial _java_thread_min_stack_allowed defined in os_linux_aarch64.cpp is + * 72K, stack guard zones could take 192KB, and the shadow zone needs 128KB, + * after aligning up all parts to the page size, the final size would be 448KB. + * See details in JDK-8163363 + */ + stackSize = 448; } TestResult tr; tr = doExec(javaCmd, "-Xms64m", "-Xmx512m", "-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath()); + // Check the stack size logs printed by -XshowSettings to verify -Xss meaningfully. + checkContains(tr, STACKSIZE_SETTINGS); containsAllOptions(tr); if (!tr.isOK()) { System.out.println(tr); @@ -93,6 +106,7 @@ static void runTestOptionDefault() throws IOException { } tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m", "-Xss" + (stackSize * 1024), "-XshowSettings", "-jar", testJar.getAbsolutePath()); + checkContains(tr, STACKSIZE_SETTINGS); containsAllOptions(tr); if (!tr.isOK()) { System.out.println(tr); diff --git a/src/test/langtools/jdk/javadoc/tool/MultiReleaseJar/TestMultiRelease.java b/src/test/langtools/jdk/javadoc/tool/MultiReleaseJar/TestMultiRelease.java new file mode 100644 index 00000000000..cf58eaa4931 --- /dev/null +++ b/src/test/langtools/jdk/javadoc/tool/MultiReleaseJar/TestMultiRelease.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8208269 + * @summary Verify module-infos are read from the correct place in multi-release jars + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.javadoc/jdk.javadoc.internal.api + * jdk.javadoc/jdk.javadoc.internal.tool + * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox + * @run main TestMultiRelease + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; + +import toolbox.JarTask; +import toolbox.JavacTask; +import toolbox.JavadocTask; +import toolbox.Task.Expect; +import toolbox.TestRunner; +import toolbox.ToolBox; + +public class TestMultiRelease extends TestRunner { + + public static void main(String... args) throws Exception { + TestMultiRelease t = new TestMultiRelease(); + t.runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + private final ToolBox tb = new ToolBox(); + + TestMultiRelease() throws IOException { + super(System.err); + } + + @Test + public void testMultiReleaseModule(Path base) throws Exception { + Files.createDirectory(base); + + Path module = base.resolve("module"); + Path moduleSrc = module.resolve("src"); + Path moduleCls = module.resolve("classes"); + + tb.writeJavaFiles(moduleSrc, "module test.module { }"); + + Files.createDirectories(moduleCls); + + new JavacTask(tb) + .outdir(moduleCls) + .files(tb.findJavaFiles(moduleSrc)) + .run() + .writeAll(); + + Path moduleJarDir = module.resolve("jar-dir"); + Path versions = moduleJarDir.resolve("META-INF/versions/10"); + + Files.createDirectories(versions); + + Files.copy(moduleCls.resolve("module-info.class"), + versions.resolve("module-info.class")); + + Path moduleJar = module.resolve("module.jar"); + + new JarTask(tb, moduleJar) + .baseDir(moduleJarDir) + .files(Arrays.stream(tb.findFiles("class", moduleJarDir)) + .map(p -> moduleJarDir.relativize(p).toString()) + .toArray(s -> new String[s])) + .manifest("Multi-Release: true\n\n") + .run(); + + Path src = base.resolve("src"); + + tb.writeJavaFiles(src, + "module m { requires test.module; exports api; }", + "package api; public class Api { }"); + Path out = base.resolve("out"); + Files.createDirectory(out); + + JavadocTask task = new JavadocTask(tb); + task.outdir(out) + .options("--module-path", moduleJar.toString(), + "-source", "10") + .files(tb.findJavaFiles(src)) + .run(Expect.SUCCESS); + + task.outdir(out) + .options("--module-path", moduleJar.toString(), + "-source", "9") + .files(tb.findJavaFiles(src)) + .run(Expect.FAIL); + } +} diff --git a/src/test/langtools/jdk/javadoc/tool/TestScriptInComment.java b/src/test/langtools/jdk/javadoc/tool/TestScriptInComment.java index 2b404fc8a2b..5167ba3ae06 100644 --- a/src/test/langtools/jdk/javadoc/tool/TestScriptInComment.java +++ b/src/test/langtools/jdk/javadoc/tool/TestScriptInComment.java @@ -25,7 +25,7 @@ /** * @test - * @bug 8138725 + * @bug 8138725 8226765 * @summary test --allow-script-in-comments * @modules jdk.javadoc/jdk.javadoc.internal.tool */ @@ -65,6 +65,10 @@ enum Comment { WS("< script >#ALERT</script>", false, "-Xdoclint:none"), // script tag with invalid white space SP("<script src=\"file\"> #ALERT </script>", true), // script tag with an attribute ON("<a onclick='#ALERT'>x</a>", true), // event handler attribute + OME("<img alt='1' onmouseenter='#ALERT'>", true), // onmouseenter event handler attribute + OML("<img alt='1' onmouseleave='#ALERT'>", true), // onmouseleave event handler attribute + OFI("<a href='#' onfocusin='#ALERT'>x</a>", true), // onfocusin event handler attribute + OBE("<a onbogusevent='#ALERT'>x</a>", true), // bogus/future event handler attribute URI("<a href='javascript:#ALERT'>x</a>", true); // javascript URI /** diff --git a/src/test/langtools/tools/javap/default_methods/JavapNotPrintingDefaultModifierTest.java b/src/test/langtools/tools/javap/default_methods/JavapNotPrintingDefaultModifierTest.java new file mode 100644 index 00000000000..4cf5e28d778 --- /dev/null +++ b/src/test/langtools/tools/javap/default_methods/JavapNotPrintingDefaultModifierTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test 8216261 + * @summary Javap ignores default modifier on interfaces + * @library /tools/lib + * @modules jdk.jdeps/com.sun.tools.javap + * @build toolbox.ToolBox toolbox.JavapTask + * @run main JavapNotPrintingDefaultModifierTest + */ + +import java.nio.file.*; +import java.util.*; + +import toolbox.JavapTask; +import toolbox.TestRunner; +import toolbox.ToolBox; +import toolbox.Task; + +public class JavapNotPrintingDefaultModifierTest extends TestRunner { + ToolBox tb = new ToolBox(); + + interface SimpleInterface { + default void defaultMethod() {} + void foo(); + } + + private static final List<String> expectedOutput = List.of( + "Compiled from \"JavapNotPrintingDefaultModifierTest.java\"", + "interface JavapNotPrintingDefaultModifierTest$SimpleInterface {", + " public default void defaultMethod();", + " public abstract void foo();", + "}"); + + JavapNotPrintingDefaultModifierTest() throws Exception { + super(System.err); + } + + public static void main(String... args) throws Exception { + JavapNotPrintingDefaultModifierTest tester = new JavapNotPrintingDefaultModifierTest(); + tester.runTests(); + } + + protected void runTests() throws Exception { + runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + @Test + public void testMain(Path base) throws Exception { + Path testClassesPath = Paths.get(System.getProperty("test.classes")); + List<String> output = new JavapTask(tb) + .options("-p", testClassesPath.resolve(this.getClass().getSimpleName() + "$SimpleInterface.class").toString()) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + System.out.println(output); + if (!output.equals(expectedOutput)) { + throw new AssertionError(String.format("unexpected output:\n %s", output)); + } + } +} diff --git a/src/test/langtools/tools/sjavac/IdleShutdown.java b/src/test/langtools/tools/sjavac/IdleShutdown.java index 44ece83a1fe..e6bb900f90c 100644 --- a/src/test/langtools/tools/sjavac/IdleShutdown.java +++ b/src/test/langtools/tools/sjavac/IdleShutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, 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 @@ -88,9 +88,13 @@ public void shutdown(String msg) { long error = Math.abs(expectedTimeout - timeoutTimestamp.get()); log("Timeout error: " + error + " ms"); - if (error > TIMEOUT_MS * .1) - throw new AssertionError("Error too big"); - + String timeoutFactorText = System.getProperty("test.timeout.factor", "1.0"); + double timeoutFactor = Double.parseDouble(timeoutFactorText); + double allowedError = TIMEOUT_MS * 0.1 * timeoutFactor; + if (error > allowedError) { + throw new AssertionError("Timeout error too large, error is " + error + + " milliseconds, we allowed " + allowedError + " milliseconds"); + } log("Shutting down"); service.shutdown(); } diff --git a/src/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java b/src/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java index d366e3dda6f..cbd3e83a0af 100644 --- a/src/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java +++ b/src/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.math.BigInteger; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -85,7 +86,7 @@ private static void setPath(String[] line) { String mountPoint = paths[1]; if (root != null && cgroupPath != null) { if (root.equals("/")) { - if (cgroupPath.equals("/")) { + if (!cgroupPath.equals("/")) { finalPath = mountPoint + cgroupPath; } else { finalPath = mountPoint; @@ -94,7 +95,7 @@ private static void setPath(String[] line) { if (root.equals(cgroupPath)) { finalPath = mountPoint; } else { - if (root.indexOf(cgroupPath) == 0) { + if (cgroupPath.startsWith(root)) { if (cgroupPath.length() > root.length()) { String cgroupSubstr = cgroupPath.substring(root.length()); finalPath = mountPoint + cgroupSubstr; @@ -103,7 +104,7 @@ private static void setPath(String[] line) { } } } - subSystemPaths.put(subSystem, new String[]{finalPath}); + subSystemPaths.put(subSystem, new String[]{finalPath, mountPoint}); } } } @@ -157,7 +158,24 @@ private static String getFileContents(SubSystem subSystem, String fileName) { private static long getLongValueFromFile(SubSystem subSystem, String fileName) { String data = getFileContents(subSystem, fileName); - return data.isEmpty() ? 0L : Long.parseLong(data); + return data.isEmpty() ? 0L : convertStringToLong(data); + } + + private static long convertStringToLong(String strval) { + long retval = 0; + if (strval == null) return 0L; + + try { + retval = Long.parseLong(strval); + } catch (NumberFormatException e) { + // For some properties (e.g. memory.limit_in_bytes) we may overflow the range of signed long. + // In this case, return Long.MAX_VALUE + BigInteger b = new BigInteger(strval); + if (b.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { + return Long.MAX_VALUE; + } + } + return retval; } private static long getLongValueFromFile(SubSystem subSystem, String metric, String subMetric) { @@ -165,7 +183,8 @@ private static long getLongValueFromFile(SubSystem subSystem, String metric, Str String[] tokens = stats.split("[\\r\\n]+"); for (int i = 0; i < tokens.length; i++) { if (tokens[i].startsWith(subMetric)) { - return Long.parseLong(tokens[i].split("\\s+")[1]); + String strval = tokens[i].split("\\s+")[1]; + return convertStringToLong(strval); } } return 0L; diff --git a/src/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java b/src/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java index f9f6e9e0e1d..ff3674fe6b2 100644 --- a/src/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java +++ b/src/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -24,6 +24,7 @@ package jdk.test.lib.containers.docker; import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.FileVisitResult; @@ -32,13 +33,14 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; import java.nio.file.attribute.BasicFileAttributes; +import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import jdk.test.lib.Platform; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; public class DockerTestUtils { @@ -46,8 +48,29 @@ public class DockerTestUtils { private static boolean isDockerEngineAvailable = false; private static boolean wasDockerEngineChecked = false; - // Diagnostics: set to true to enable more diagnostic info - private static final boolean DEBUG = false; + // Specifies how many lines to copy from child STDOUT to main test output. + // Having too many lines in the main test output will result + // in JT harness trimming the output, and can lead to loss of useful + // diagnostic information. + private static final int MAX_LINES_TO_COPY_FOR_CHILD_STDOUT = 100; + + // Use this property to specify docker location on your system. + // E.g.: "/usr/local/bin/docker". + private static final String DOCKER_COMMAND = + System.getProperty("jdk.test.docker.command", "docker"); + + // Set this property to true to retain image after test. By default + // images are removed after test execution completes. + // Retaining the image can be useful for diagnostics and image inspection. + // E.g.: start image interactively: docker run -it <IMAGE_NAME>. + public static final boolean RETAIN_IMAGE_AFTER_TEST = + Boolean.getBoolean("jdk.test.docker.retain.image"); + + // Path to a JDK under test. + // This may be useful when developing tests on non-Linux platforms. + public static final String JDK_UNDER_TEST = + System.getProperty("jdk.test.docker.jdk", Utils.TEST_JDK); + /** * Optimized check of whether the docker engine is available in a given @@ -77,9 +100,7 @@ public static boolean canTestDocker() throws Exception { if (isDockerEngineAvailable()) { return true; } else { - System.out.println("Docker engine is not available on this system"); - System.out.println("This test is SKIPPED"); - return false; + throw new SkippedException("Docker engine is not available on this system"); } } @@ -95,7 +116,7 @@ public static boolean canTestDocker() throws Exception { */ private static boolean isDockerEngineAvailableCheck() throws Exception { try { - execute("docker", "ps") + execute(DOCKER_COMMAND, "ps") .shouldHaveExitValue(0) .shouldContain("CONTAINER") .shouldContain("IMAGE"); @@ -126,13 +147,8 @@ private static boolean isDockerEngineAvailableCheck() throws Exception { if (Files.exists(buildDir)) { throw new RuntimeException("The docker build directory already exists: " + buildDir); } - // check for the existance of a platform specific docker file as well - String platformSpecificDockerfile = dockerfile + "-" + Platform.getOsArch(); - if (Files.exists(Paths.get(Utils.TEST_SRC, platformSpecificDockerfile))) { - dockerfile = platformSpecificDockerfile; - } - Path jdkSrcDir = Paths.get(Utils.TEST_JDK); + Path jdkSrcDir = Paths.get(JDK_UNDER_TEST); Path jdkDstDir = buildDir.resolve("jdk"); Files.createDirectories(jdkDstDir); @@ -158,13 +174,20 @@ private static boolean isDockerEngineAvailableCheck() throws Exception { public static void buildDockerImage(String imageName, Path dockerfile, Path buildDir) throws Exception { - // Copy docker file to the build dir - Files.copy(dockerfile, buildDir.resolve("Dockerfile")); - - // Build the docker - execute("docker", "build", "--no-cache", "--tag", imageName, buildDir.toString()) - .shouldHaveExitValue(0) - .shouldContain("Successfully built"); + generateDockerFile(buildDir.resolve("Dockerfile"), + DockerfileConfig.getBaseImageName(), + DockerfileConfig.getBaseImageVersion()); + try { + // Build the docker + execute(DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) + .shouldHaveExitValue(0) + .shouldContain("Successfully built"); + } catch (Exception e) { + // If docker image building fails there is a good chance it happens due to environment and/or + // configuration other than product failure. Throw jtreg skipped exception in such case + // instead of failing the test. + throw new SkippedException("Building docker image failed. Details: \n" + e.getMessage()); + } } @@ -179,7 +202,7 @@ private static boolean isDockerEngineAvailableCheck() throws Exception { public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception { ArrayList<String> cmd = new ArrayList<>(); - cmd.add("docker"); + cmd.add(DOCKER_COMMAND); cmd.add("run"); if (opts.tty) cmd.add("--tty=true"); @@ -206,11 +229,10 @@ public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Excepti * Remove docker image * * @param DockerRunOptions optins for running docker - * @return output of the command * @throws Exception */ - public static OutputAnalyzer removeDockerImage(String imageNameAndTag) throws Exception { - return execute("docker", "rmi", "--force", imageNameAndTag); + public static void removeDockerImage(String imageNameAndTag) throws Exception { + execute(DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); } @@ -240,16 +262,53 @@ public static OutputAnalyzer execute(String... command) throws Exception { System.out.println("[COMMAND]\n" + Utils.getCommandLine(pb)); long started = System.currentTimeMillis(); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); + Process p = pb.start(); + long pid = p.pid(); + OutputAnalyzer output = new OutputAnalyzer(p); + String stdoutLogFile = String.format("docker-stdout-%d.log", pid); System.out.println("[ELAPSED: " + (System.currentTimeMillis() - started) + " ms]"); System.out.println("[STDERR]\n" + output.getStderr()); - System.out.println("[STDOUT]\n" + output.getStdout()); + System.out.println("[STDOUT]\n" + + trimLines(output.getStdout(),MAX_LINES_TO_COPY_FOR_CHILD_STDOUT)); + System.out.printf("Child process STDOUT is trimmed to %d lines \n", + MAX_LINES_TO_COPY_FOR_CHILD_STDOUT); + writeOutputToFile(output.getStdout(), stdoutLogFile); + System.out.println("Full child process STDOUT was saved to " + stdoutLogFile); return output; } + private static void writeOutputToFile(String output, String fileName) throws Exception { + try (FileWriter fw = new FileWriter(fileName)) { + fw.write(output, 0, output.length()); + } + } + + + private static String trimLines(String buffer, int nrOfLines) { + List<String> l = Arrays.asList(buffer.split("\\R")); + if (l.size() < nrOfLines) { + return buffer; + } + + return String.join("\n", l.subList(0, nrOfLines)); + } + + + private static void generateDockerFile(Path dockerfile, String baseImage, + String baseImageVersion) throws Exception { + String template = + "FROM %s:%s\n" + + "COPY /jdk /jdk\n" + + "ENV JAVA_HOME=/jdk\n" + + "CMD [\"/bin/bash\"]\n"; + String dockerFileStr = String.format(template, baseImage, baseImageVersion); + Files.writeString(dockerfile, dockerFileStr); + } + + private static class CopyFileVisitor extends SimpleFileVisitor<Path> { private final Path src; private final Path dst; diff --git a/src/test/lib/jdk/test/lib/containers/docker/DockerfileConfig.java b/src/test/lib/jdk/test/lib/containers/docker/DockerfileConfig.java new file mode 100644 index 00000000000..61612d3c82c --- /dev/null +++ b/src/test/lib/jdk/test/lib/containers/docker/DockerfileConfig.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.containers.docker; + +import jdk.test.lib.Platform; + +// Use the following properties to specify docker base image at test execution time: +// Image name: jdk.test.docker.image.name +// Image version: jdk.test.docker.image.version +// Usage: +// jtreg -Djdk.test.docker.image.name=<BASE_IMAGE_NAME> -Djdk.test.docker.image.version=<BASE_IMAGE_VERSION> test/hotspot/jtreg/runtime/containers/docker/ +// E.g.: +// jtreg -Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest test/hotspot/jtreg/runtime/containers/docker/ +// Using make: +// make test TEST="test/hotspot/jtreg/runtime/containers/docker" JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest" +// Note: base image version should not be an empty string. Use "latest" to get the latest version. + +public class DockerfileConfig { + static String getBaseImageName() { + String name = System.getProperty("jdk.test.docker.image.name"); + if (name != null) { + System.out.println("DockerfileConfig: using custom image name: " + name); + return name; + } + + switch (Platform.getOsArch()) { + case "aarch64": + return "arm64v8/ubuntu"; + case "ppc64le": + return "ppc64le/ubuntu"; + case "s390x": + return "s390x/ubuntu"; + default: + return "oraclelinux"; + } + } + + static String getBaseImageVersion() { + String version = System.getProperty("jdk.test.docker.image.version"); + if (version != null) { + System.out.println("DockerfileConfig: using custom image version: " + version); + return version; + } + + switch (Platform.getOsArch()) { + case "aarch64": + case "ppc64le": + case "s390x": + return "latest"; + default: + return "7.6"; + } + } +} diff --git a/src/test/lib/jdk/test/lib/jfr/EventNames.java b/src/test/lib/jdk/test/lib/jfr/EventNames.java index ad11c3c2db1..74c185d2514 100644 --- a/src/test/lib/jdk/test/lib/jfr/EventNames.java +++ b/src/test/lib/jdk/test/lib/jfr/EventNames.java @@ -168,6 +168,10 @@ public class EventNames { public final static String JavaErrorThrow = PREFIX + "JavaErrorThrow"; public final static String ModuleRequire = PREFIX + "ModuleRequire"; public final static String ModuleExport = PREFIX + "ModuleExport"; + public final static String TLSHandshake = PREFIX + "TLSHandshake"; + public final static String X509Certificate = PREFIX + "X509Certificate"; + public final static String X509Validation = PREFIX + "X509Validation"; + public final static String SecurityProperty = PREFIX + "SecurityPropertyModification"; // Flight Recorder public final static String DumpReason = PREFIX + "DumpReason"; diff --git a/src/test/lib/jdk/test/lib/net/URIBuilder.java b/src/test/lib/jdk/test/lib/net/URIBuilder.java new file mode 100644 index 00000000000..179553fede8 --- /dev/null +++ b/src/test/lib/jdk/test/lib/net/URIBuilder.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, Google and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.net; + +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + +public class URIBuilder { + + public static URIBuilder newBuilder() { + return new URIBuilder(); + } + + private String scheme; + private String userInfo; + private String host; + private int port; + private String path; + private String query; + private String fragment; + + private URIBuilder() {} + + public URIBuilder scheme(String scheme) { + this.scheme = scheme; + return this; + } + + public URIBuilder userInfo(String userInfo) { + this.userInfo = userInfo; + return this; + } + + public URIBuilder host(String host) { + this.host = host; + return this; + } + + public URIBuilder loopback() { + return host(InetAddress.getLoopbackAddress().getHostAddress()); + } + + public URIBuilder port(int port) { + this.port = port; + return this; + } + + public URIBuilder path(String path) { + this.path = path; + return this; + } + + public URIBuilder query(String query) { + this.query = query; + return this; + } + + public URIBuilder fragment(String fragment) { + this.fragment = fragment; + return this; + } + + public URI build() throws URISyntaxException { + return new URI(scheme, userInfo, host, port, path, query, fragment); + } + + public URI buildUnchecked() { + try { + return build(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + + public URL toURL() throws URISyntaxException, MalformedURLException { + return build().toURL(); + } + + public URL toURLUnchecked() { + try { + return toURL(); + } catch (URISyntaxException | MalformedURLException e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/src/test/lib/jdk/test/lib/security/DerUtils.java b/src/test/lib/jdk/test/lib/security/DerUtils.java new file mode 100644 index 00000000000..c2efaf91503 --- /dev/null +++ b/src/test/lib/jdk/test/lib/security/DerUtils.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.test.lib.security; + +import jdk.test.lib.Asserts; +import sun.security.util.DerInputStream; +import sun.security.util.DerValue; +import sun.security.util.ObjectIdentifier; + +import java.io.IOException; + +public class DerUtils { + /** + * Returns a DerValue (deep) inside another DerValue. + * <p> + * The location of the inner DerValue is expressed as a string, in which + * each character is a step from the outer DerValue into the inner one. + * If it's a number n, the n'th element (starting from 0) of a sequence + * is the next step. If it's 'c', the content of an OctetString parsed + * as a DerValue is the next step. Note that n cannot be bigger than 9. + * <p> + * Attention: do not reuse the return value. DerValue is mutable and + * reading it advances a pointer inside. + * <p> + * For example, here is a PKCS #12 file: + * <pre> + * 0000:0845 [] SEQUENCE + * 0004:0003 [0] INTEGER 3 + * 0007:07FE [1] SEQUENCE + * 000B:000B [10] OID 1.2.840.113549.1.7.1 (data) + * 0016:07EF [11] cont [0] + * 001A:07EB [110] OCTET STRING + * ... + * </pre> + * and the content of OCTET string at offset 001A can be parsed as another + * DerValue which is: + * <pre> + * 0000:07E7 [] SEQUENCE + * 0004:0303 [0] SEQUENCE + * 0008:000B [00] OID 1.2.840.113549.1.7.1 (data) + * .... + * </pre> + * Then the OID is {@code innerDerValue(data, "110c00").getOID()}. + * + * @param data the outer DerValue. We choose byte[] instead of DerValue + * because DerValue is mutable and cannot be reused. + * @param location the location of the inner DerValue + * @return the inner DerValue, or null if no DerValue is at the location + * @throws IOException if an I/O error happens + */ + public static DerValue innerDerValue(byte[] data, String location) + throws IOException { + + DerValue v = new DerValue(data); + for (char step : location.toCharArray()) { + if (step == 'c') { + v = new DerValue(v.getOctetString()); + } else { + DerInputStream ins = v.getData(); + // skip n DerValue in the sequence + for (int i = 0; i < step - '0'; i++) { + ins.getDerValue(); + } + if (ins.available() > 0) { + v = ins.getDerValue(); + } else { + return null; + } + } + } + return v; + } + + /** + * Ensures that the inner DerValue is the expected ObjectIdentifier. + */ + public static void checkAlg(byte[] der, String location, + ObjectIdentifier expected) throws Exception { + Asserts.assertEQ(innerDerValue(der, location).getOID(), expected); + } + + /** + * Ensures that the inner DerValue is the expected integer. + */ + public static void checkInt(byte[] der, String location, int expected) + throws Exception { + Asserts.assertEQ(innerDerValue(der, location).getInteger(), expected); + } + + /** + * Ensures that there is no inner DerValue at the specified location. + */ + public static void shouldNotExist(byte[] der, String location) + throws Exception { + Asserts.assertTrue(innerDerValue(der, location) == null); + } +} diff --git a/src/test/lib/jdk/test/lib/security/JDKSecurityProperties.java b/src/test/lib/jdk/test/lib/security/JDKSecurityProperties.java new file mode 100644 index 00000000000..fee966d31cb --- /dev/null +++ b/src/test/lib/jdk/test/lib/security/JDKSecurityProperties.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.security; + +import java.util.List; +import java.security.Security; + +public final class JDKSecurityProperties { + + public static final List<String> jdkProps = List.of( + "com.sun.CORBA.ORBIorTypeCheckRegistryFilter", + "crypto.policy", + "jceks.key.serialFilter", + "jdk.certpath.disabledAlgorithms", + "keystore.type", + "krb5.kdc.bad.policy", + "login.config", + "networkaddress.cache.ttl", + "ocsp.responderURL", + "package.access", + "policy.allowSystemProperty", + "securerandom.drbg.config", + "security.provider.1", + "ssl.KeyManagerFactory.algorithm", + "sun.rmi.registry.registryFilter" + ); + + public static List getKeys() { + return jdkProps; + } +} diff --git a/src/test/lib/jdk/test/lib/security/SSLSocketTest.java b/src/test/lib/jdk/test/lib/security/SSLSocketTest.java new file mode 100644 index 00000000000..3375803925f --- /dev/null +++ b/src/test/lib/jdk/test/lib/security/SSLSocketTest.java @@ -0,0 +1,891 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.security; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.OutputStream; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManagerFactory; +import java.net.InetSocketAddress; +import java.net.SocketTimeoutException; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.KeyFactory; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.Base64; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/** + * Template to help speed up your client/server tests. + * + * Two examples that use this template: + * test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java + * test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java + */ +public abstract class SSLSocketTest { + + /* + * Run the test case. + */ + public void run() throws Exception { + bootup(); + } + + /* + * Define the server side application of the test for the specified socket. + */ + protected abstract void runServerApplication(SSLSocket socket) throws Exception; + + /* + * Define the client side application of the test for the specified socket. + * This method is used if the returned value of + * isCustomizedClientConnection() is false. + * + * @param socket may be null is no client socket is generated. + * + * @see #isCustomizedClientConnection() + */ + protected abstract void runClientApplication(SSLSocket socket) throws Exception; + + /* + * Define the client side application of the test for the specified + * server port. This method is used if the returned value of + * isCustomizedClientConnection() is true. + * + * Note that the client need to connect to the server port by itself + * for the actual message exchange. + * + * @see #isCustomizedClientConnection() + */ + protected void runClientApplication(int serverPort) throws Exception { + // blank + } + + /* + * Create an instance of SSLContext for client use. + */ + protected SSLContext createClientSSLContext() throws Exception { + return createSSLContext(trustedCertStrs, + endEntityCertStrs, endEntityPrivateKeys, + endEntityPrivateKeyAlgs, + endEntityPrivateKeyNames, + getClientContextParameters()); + } + + /* + * Create an instance of SSLContext for server use. + */ + protected SSLContext createServerSSLContext() throws Exception { + return createSSLContext(trustedCertStrs, + endEntityCertStrs, endEntityPrivateKeys, + endEntityPrivateKeyAlgs, + endEntityPrivateKeyNames, + getServerContextParameters()); + } + + /* + * The parameters used to configure SSLContext. + */ + protected static final class ContextParameters { + final String contextProtocol; + final String tmAlgorithm; + final String kmAlgorithm; + + ContextParameters(String contextProtocol, + String tmAlgorithm, String kmAlgorithm) { + + this.contextProtocol = contextProtocol; + this.tmAlgorithm = tmAlgorithm; + this.kmAlgorithm = kmAlgorithm; + } + } + + /* + * Get the client side parameters of SSLContext. + */ + protected ContextParameters getClientContextParameters() { + return new ContextParameters("TLS", "PKIX", "NewSunX509"); + } + + /* + * Get the server side parameters of SSLContext. + */ + protected ContextParameters getServerContextParameters() { + return new ContextParameters("TLS", "PKIX", "NewSunX509"); + } + + /* + * Does the client side use customized connection other than + * explicit Socket.connect(), for example, URL.openConnection()? + */ + protected boolean isCustomizedClientConnection() { + return false; + } + + /* + * Configure the server side socket. + */ + protected void configureServerSocket(SSLServerSocket socket) { + + } + + /* + * ============================================= + * Define the client and server side operations. + * + * If the client or server is doing some kind of object creation + * that the other side depends on, and that thread prematurely + * exits, you may experience a hang. The test harness will + * terminate all hung threads after its timeout has expired, + * currently 3 minutes by default, but you might try to be + * smart about it.... + */ + + /* + * Is the server ready to serve? + */ + private final CountDownLatch serverCondition = new CountDownLatch(1); + + /* + * Is the client ready to handshake? + */ + private final CountDownLatch clientCondition = new CountDownLatch(1); + + /* + * What's the server port? Use any free port by default + */ + private volatile int serverPort = 0; + + /* + * Define the server side of the test. + */ + private void doServerSide() throws Exception { + // kick start the server side service + SSLContext context = createServerSSLContext(); + SSLServerSocketFactory sslssf = context.getServerSocketFactory(); + SSLServerSocket sslServerSocket = + (SSLServerSocket)sslssf.createServerSocket(serverPort); + configureServerSocket(sslServerSocket); + serverPort = sslServerSocket.getLocalPort(); + + // Signal the client, the server is ready to accept connection. + serverCondition.countDown(); + + // Try to accept a connection in 30 seconds. + SSLSocket sslSocket; + try { + sslServerSocket.setSoTimeout(30000); + sslSocket = (SSLSocket)sslServerSocket.accept(); + } catch (SocketTimeoutException ste) { + // Ignore the test case if no connection within 30 seconds. + System.out.println( + "No incoming client connection in 30 seconds. " + + "Ignore in server side."); + return; + } finally { + sslServerSocket.close(); + } + + // handle the connection + try { + // Is it the expected client connection? + // + // Naughty test cases or third party routines may try to + // connection to this server port unintentionally. In + // order to mitigate the impact of unexpected client + // connections and avoid intermittent failure, it should + // be checked that the accepted connection is really linked + // to the expected client. + boolean clientIsReady = + clientCondition.await(30L, TimeUnit.SECONDS); + + if (clientIsReady) { + // Run the application in server side. + runServerApplication(sslSocket); + } else { // Otherwise, ignore + // We don't actually care about plain socket connections + // for TLS communication testing generally. Just ignore + // the test if the accepted connection is not linked to + // the expected client or the client connection timeout + // in 30 seconds. + System.out.println( + "The client is not the expected one or timeout. " + + "Ignore in server side."); + } + } finally { + sslSocket.close(); + } + } + + /* + * Define the client side of the test. + */ + private void doClientSide() throws Exception { + + // Wait for server to get started. + // + // The server side takes care of the issue if the server cannot + // get started in 90 seconds. The client side would just ignore + // the test case if the serer is not ready. + boolean serverIsReady = + serverCondition.await(90L, TimeUnit.SECONDS); + if (!serverIsReady) { + System.out.println( + "The server is not ready yet in 90 seconds. " + + "Ignore in client side."); + return; + } + + if (isCustomizedClientConnection()) { + // Signal the server, the client is ready to communicate. + clientCondition.countDown(); + + // Run the application in client side. + runClientApplication(serverPort); + + return; + } + + SSLContext context = createClientSSLContext(); + SSLSocketFactory sslsf = context.getSocketFactory(); + + try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) { + try { + sslSocket.connect( + new InetSocketAddress("localhost", serverPort), 15000); + } catch (IOException ioe) { + // The server side may be impacted by naughty test cases or + // third party routines, and cannot accept connections. + // + // Just ignore the test if the connection cannot be + // established. + System.out.println( + "Cannot make a connection in 15 seconds. " + + "Ignore in client side."); + return; + } + + // OK, here the client and server get connected. + + // Signal the server, the client is ready to communicate. + clientCondition.countDown(); + + // There is still a chance in theory that the server thread may + // wait client-ready timeout and then quit. The chance should + // be really rare so we don't consider it until it becomes a + // real problem. + + // Run the application in client side. + runClientApplication(sslSocket); + } + } + + /* + * ============================================= + * Stuffs to customize the SSLContext instances. + */ + + /* + * ======================================= + * Certificates and keys used in the test. + */ + // Trusted certificates. + private final static String[] trustedCertStrs = { + // SHA256withECDSA, curve prime256v1 + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Subject Key Identifier: + // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 + "-----BEGIN CERTIFICATE-----\n" + + "MIIBvjCCAWOgAwIBAgIJAIvFG6GbTroCMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYTAlVT\n" + + "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" + + "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABBz1WeVb6gM2mh85z3QlvaB/l11b5h0v\n" + + "LIzmkC3DKlVukZT+ltH2Eq1oEkpXuf7QmbM0ibrUgtjsWH3mULfmcWmjUDBOMB0G\n" + + "A1UdDgQWBBRgz71z//oaMNKk7NNJcUbvGjWghjAfBgNVHSMEGDAWgBRgz71z//oa\n" + + "MNKk7NNJcUbvGjWghjAMBgNVHRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCG\n" + + "6wluh1r2/T6L31mZXRKf9JxeSf9pIzoLj+8xQeUChQIhAJ09wAi1kV8yePLh2FD9\n" + + "2YEHlSQUAbwwqCDEVB5KxaqP\n" + + "-----END CERTIFICATE-----", + // -----BEGIN PRIVATE KEY----- + // MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/HcHdoLJCdq3haVd + // XZTSKP00YzM3xX97l98vGL/RI1KhRANCAAQc9VnlW+oDNpofOc90Jb2gf5ddW+Yd + // LyyM5pAtwypVbpGU/pbR9hKtaBJKV7n+0JmzNIm61ILY7Fh95lC35nFp + // -----END PRIVATE KEY----- + + // SHA256withRSA, 2048 bits + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Subject Key Identifier: + // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C + "-----BEGIN CERTIFICATE-----\n" + + "MIIDSTCCAjGgAwIBAgIJAI4ZF3iy8zG+MA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALpMcY7aWieXDEM1/YJf\n" + + "JW27b4nRIFZyEYhEloyGsKTuQiiQjc8cqRZFNXe2vwziDB4IyTEl0Hjl5QF6ZaQE\n" + + "huPzzwvQm1pv64KrRXrmj3FisQK8B5OWLty9xp6xDqsaMRoyObLK+oIb20T5fSlE\n" + + "evmo1vYjnh8CX0Yzx5Gr5ye6YSEHQvYOWEws8ad17OlyToR2KMeC8w4qo6rs59pW\n" + + "g7Mxn9vo22ImDzrtAbTbXbCias3xlE0Bp0h5luyf+5U4UgksoL9B9r2oP4GrLNEV\n" + + "oJk57t8lwaR0upiv3CnS8LcJELpegZub5ggqLY8ZPYFQPjlK6IzLOm6rXPgZiZ3m\n" + + "RL0CAwEAAaNQME4wHQYDVR0OBBYEFA3dk8n+S701t+iZeJD721o92xVMMB8GA1Ud\n" + + "IwQYMBaAFA3dk8n+S701t+iZeJD721o92xVMMAwGA1UdEwQFMAMBAf8wDQYJKoZI\n" + + "hvcNAQELBQADggEBAJTRC3rKUUhVH07/1+stUungSYgpM08dY4utJq0BDk36BbmO\n" + + "0AnLDMbkwFdHEoqF6hQIfpm7SQTmXk0Fss6Eejm8ynYr6+EXiRAsaXOGOBCzF918\n" + + "/RuKOzqABfgSU4UBKECLM5bMfQTL60qx+HdbdVIpnikHZOFfmjCDVxoHsGyXc1LW\n" + + "Jhkht8IGOgc4PMGvyzTtRFjz01kvrVQZ75aN2E0GQv6dCxaEY0i3ypSzjUWAKqDh\n" + + "3e2OLwUSvumcdaxyCdZAOUsN6pDBQ+8VRG7KxnlRlY1SMEk46QgQYLbPDe/+W/yH\n" + + "ca4PejicPeh+9xRAwoTpiE2gulfT7Lm+fVM7Ruc=\n" + + "-----END CERTIFICATE-----", + // -----BEGIN PRIVATE KEY----- + // MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6THGO2lonlwxD + // Nf2CXyVtu2+J0SBWchGIRJaMhrCk7kIokI3PHKkWRTV3tr8M4gweCMkxJdB45eUB + // emWkBIbj888L0Jtab+uCq0V65o9xYrECvAeTli7cvcaesQ6rGjEaMjmyyvqCG9tE + // +X0pRHr5qNb2I54fAl9GM8eRq+cnumEhB0L2DlhMLPGndezpck6EdijHgvMOKqOq + // 7OfaVoOzMZ/b6NtiJg867QG0212womrN8ZRNAadIeZbsn/uVOFIJLKC/Qfa9qD+B + // qyzRFaCZOe7fJcGkdLqYr9wp0vC3CRC6XoGbm+YIKi2PGT2BUD45SuiMyzpuq1z4 + // GYmd5kS9AgMBAAECggEAFHSoU2MuWwJ+2jJnb5U66t2V1bAcuOE1g5zkWvG/G5z9 + // rq6Qo5kmB8f5ovdx6tw3MGUOklLwnRXBG3RxDJ1iokz3AvkY1clMNsDPlDsUrQKF + // JSO4QUBQTPSZhnsyfR8XHSU+qJ8Y+ohMfzpVv95BEoCzebtXdVgxVegBlcEmVHo2 + // kMmkRN+bYNsr8eb2r+b0EpyumS39ZgKYh09+cFb78y3T6IFMGcVJTP6nlGBFkmA/ + // 25pYeCF2tSki08qtMJZQAvKfw0Kviibk7ZxRbJqmc7B1yfnOEHP6ftjuvKl2+RP/ + // +5P5f8CfIP6gtA0LwSzAqQX/hfIKrGV5j0pCqrD0kQKBgQDeNR6Xi4sXVq79lihO + // a1bSeV7r8yoQrS8x951uO+ox+UIZ1MsAULadl7zB/P0er92p198I9M/0Jth3KBuS + // zj45mucvpiiGvmQlMKMEfNq4nN7WHOu55kufPswQB2mR4J3xmwI+4fM/nl1zc82h + // De8JSazRldJXNhfx0RGFPmgzbwKBgQDWoVXrXLbCAn41oVnWB8vwY9wjt92ztDqJ + // HMFA/SUohjePep9UDq6ooHyAf/Lz6oE5NgeVpPfTDkgvrCFVKnaWdwALbYoKXT2W + // 9FlyJox6eQzrtHAacj3HJooXWuXlphKSizntfxj3LtMR9BmrmRJOfK+SxNOVJzW2 + // +MowT20EkwKBgHmpB8jdZBgxI7o//m2BI5Y1UZ1KE5vx1kc7VXzHXSBjYqeV9FeF + // 2ZZLP9POWh/1Fh4pzTmwIDODGT2UPhSQy0zq3O0fwkyT7WzXRknsuiwd53u/dejg + // iEL2NPAJvulZ2+AuiHo5Z99LK8tMeidV46xoJDDUIMgTG+UQHNGhK5gNAoGAZn/S + // Cn7SgMC0CWSvBHnguULXZO9wH1wZAFYNLL44OqwuaIUFBh2k578M9kkke7woTmwx + // HxQTjmWpr6qimIuY6q6WBN8hJ2Xz/d1fwhYKzIp20zHuv5KDUlJjbFfqpsuy3u1C + // kts5zwI7pr1ObRbDGVyOdKcu7HI3QtR5qqyjwaUCgYABo7Wq6oHva/9V34+G3Goh + // 63bYGUnRw2l5BD11yhQv8XzGGZFqZVincD8gltNThB0Dc/BI+qu3ky4YdgdZJZ7K + // z51GQGtaHEbrHS5caV79yQ8QGY5mUVH3E+VXSxuIqb6pZq2DH4sTAEFHyncddmOH + // zoXBInYwRG9KE/Bw5elhUw== + // -----END PRIVATE KEY----- + + // SHA256withDSA, 2048 bits + // Validity + // Not Before: May 22 07:18:18 2018 GMT + // Not After : May 17 07:18:18 2038 GMT + // Subject Key Identifier: + // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 + "-----BEGIN CERTIFICATE-----\n" + + "MIIErjCCBFSgAwIBAgIJAOktYLNCbr02MAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + + "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + + "Y2UwHhcNMTgwNTIyMDcxODE4WhcNMzgwNTE3MDcxODE4WjA7MQswCQYDVQQGEwJV\n" + + "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Uw\n" + + "ggNHMIICOQYHKoZIzjgEATCCAiwCggEBAO5GyPhSm0ze3LSu+gicdULLj05iOfTL\n" + + "UvZQ29sYz41zmqrLBQbdKiHqgJu2Re9sgTb5suLNjF047TOLPnU3jhPtWm2X8Xzi\n" + + "VGIcHym/Q/MeZxStt/88seqroI3WOKzIML2GcrishT+lcGrtH36Tf1+ue2Snn3PS\n" + + "WyxygNqPjllP5uUjYmFLvAf4QLMldkd/D2VxcwsHjB8y5iUZsXezc/LEhRZS/02m\n" + + "ivqlRw3AMkq/OVe/ZtxFWsP0nsfxEGdZuaUFpppGfixxFvymrB3+J51cTt+pZBDq\n" + + "D2y0DYfc+88iCs4jwHTfcDIpLb538HBjBj2rEgtQESQmB0ooD/+wsPsCIQC1bYch\n" + + "gElNtDYL3FgpLgNSUYp7gIWv9ehaC7LO2z7biQKCAQBitvFOnDkUja8NAF7lDpOV\n" + + "b5ipQ8SicBLW3kQamxhyuyxgZyy/PojZ/oPorkqW/T/A0rhnG6MssEpAtdiwVB+c\n" + + "rBYGo3bcwmExJhdOJ6dYuKFppPWhCwKMHs9npK+lqBMl8l5j58xlcFeC7ZfGf8GY\n" + + "GkhFW0c44vEQhMMbac6ZTTP4mw+1t7xJfmDMlLEyIpTXaAAk8uoVLWzQWnR40sHi\n" + + "ybvS0u3JxQkb7/y8tOOZu8qlz/YOS7lQ6UxUGX27Ce1E0+agfPphetoRAlS1cezq\n" + + "Wa7r64Ga0nkj1kwkcRqjgTiJx0NwnUXr78VAXFhVF95+O3lfqhvdtEGtkhDGPg7N\n" + + "A4IBBgACggEBAMmSHQK0w2i+iqUjOPzn0yNEZrzepLlLeQ1tqtn0xnlv5vBAeefD\n" + + "Pm9dd3tZOjufVWP7hhEz8xPobb1CS4e3vuQiv5UBfhdPL3f3l9T7JMAKPH6C9Vve\n" + + "OQXE5eGqbjsySbcmseHoYUt1WCSnSda1opX8zchX04e7DhGfE2/L9flpYEoSt8lI\n" + + "vMNjgOwvKdW3yvPt1/eBBHYNFG5gWPv/Q5KoyCtHS03uqGm4rNc/wZTIEEfd66C+\n" + + "QRaUltjOaHmtwOdDHaNqwhYZSVOip+Mo+TfyzHFREcdHLapo7ZXqbdYkRGxRR3d+\n" + + "3DfHaraJO0OKoYlPkr3JMvM/MSGR9AnZOcejUDBOMB0GA1UdDgQWBBR2Zp73O91F\n" + + "5TvZcjw/8FQ5hjEmUzAfBgNVHSMEGDAWgBR2Zp73O91F5TvZcjw/8FQ5hjEmUzAM\n" + + "BgNVHRMEBTADAQH/MAsGCWCGSAFlAwQDAgNHADBEAiBzriYE41M2y9Hy5ppkL0Qn\n" + + "dIlNc8JhXT/PHW7GDtViagIgMko8Qoj9gDGPK3+O9E8DC3wGiiF9CObM4LN387ok\n" + + "J+g=\n" + + "-----END CERTIFICATE-----" + // -----BEGIN PRIVATE KEY----- + // MIICZQIBADCCAjkGByqGSM44BAEwggIsAoIBAQDuRsj4UptM3ty0rvoInHVCy49O + // Yjn0y1L2UNvbGM+Nc5qqywUG3Soh6oCbtkXvbIE2+bLizYxdOO0ziz51N44T7Vpt + // l/F84lRiHB8pv0PzHmcUrbf/PLHqq6CN1jisyDC9hnK4rIU/pXBq7R9+k39frntk + // p59z0lsscoDaj45ZT+blI2JhS7wH+ECzJXZHfw9lcXMLB4wfMuYlGbF3s3PyxIUW + // Uv9Npor6pUcNwDJKvzlXv2bcRVrD9J7H8RBnWbmlBaaaRn4scRb8pqwd/iedXE7f + // qWQQ6g9stA2H3PvPIgrOI8B033AyKS2+d/BwYwY9qxILUBEkJgdKKA//sLD7AiEA + // tW2HIYBJTbQ2C9xYKS4DUlGKe4CFr/XoWguyzts+24kCggEAYrbxTpw5FI2vDQBe + // 5Q6TlW+YqUPEonAS1t5EGpsYcrssYGcsvz6I2f6D6K5Klv0/wNK4ZxujLLBKQLXY + // sFQfnKwWBqN23MJhMSYXTienWLihaaT1oQsCjB7PZ6SvpagTJfJeY+fMZXBXgu2X + // xn/BmBpIRVtHOOLxEITDG2nOmU0z+JsPtbe8SX5gzJSxMiKU12gAJPLqFS1s0Fp0 + // eNLB4sm70tLtycUJG+/8vLTjmbvKpc/2Dku5UOlMVBl9uwntRNPmoHz6YXraEQJU + // tXHs6lmu6+uBmtJ5I9ZMJHEao4E4icdDcJ1F6+/FQFxYVRfefjt5X6ob3bRBrZIQ + // xj4OzQQjAiEAsceWOM8do4etxp2zgnoNXV8PUUyqWhz1+0srcKV7FR4= + // -----END PRIVATE KEY----- + }; + + // End entity certificate. + private final static String[] endEntityCertStrs = { + // SHA256withECDSA, curve prime256v1 + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Authority Key Identifier: + // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 + "-----BEGIN CERTIFICATE-----\n" + + "MIIBqjCCAVCgAwIBAgIJAPLY8qZjgNRAMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYTAlVT\n" + + "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" + + "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + + "QgAEb+9n05qfXnfHUb0xtQJNS4JeSi6IjOfW5NqchvKnfJey9VkJzR7QHLuOESdf\n" + + "xlR7q8YIWgih3iWLGfB+wxHiOqMjMCEwHwYDVR0jBBgwFoAUYM+9c//6GjDSpOzT\n" + + "SXFG7xo1oIYwCgYIKoZIzj0EAwIDSAAwRQIgWpRegWXMheiD3qFdd8kMdrkLxRbq\n" + + "1zj8nQMEwFTUjjQCIQDRIrAjZX+YXHN9b0SoWWLPUq0HmiFIi8RwMnO//wJIGQ==\n" + + "-----END CERTIFICATE-----", + + // SHA256withRSA, 2048 bits + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Authority Key Identifier: + // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C + "-----BEGIN CERTIFICATE-----\n" + + "MIIDNjCCAh6gAwIBAgIJAO2+yPcFryUTMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOC\n" + + "AQ8AMIIBCgKCAQEAszfBobWfZIp8AgC6PiWDDavP65mSvgCXUGxACbxVNAfkLhNR\n" + + "QOsHriRB3X1Q3nvO9PetC6wKlvE9jlnDDj7D+1j1r1CHO7ms1fq8rfcQYdkanDtu\n" + + "4AlHo8v+SSWX16MIXFRYDj2VVHmyPtgbltcg4zGAuwT746FdLI94uXjJjq1IOr/v\n" + + "0VIlwE5ORWH5Xc+5Tj+oFWK0E4a4GHDgtKKhn2m72hN56/GkPKGkguP5NRS1qYYV\n" + + "/EFkdyQMOV8J1M7HaicSft4OL6eKjTrgo93+kHk+tv0Dc6cpVBnalX3TorG8QI6B\n" + + "cHj1XQd78oAlAC+/jF4pc0mwi0un49kdK9gRfQIDAQABoyMwITAfBgNVHSMEGDAW\n" + + "gBQN3ZPJ/ku9NbfomXiQ+9taPdsVTDANBgkqhkiG9w0BAQsFAAOCAQEApXS0nKwm\n" + + "Kp8gpmO2yG1rpd1+2wBABiMU4JZaTqmma24DQ3RzyS+V2TeRb29dl5oTUEm98uc0\n" + + "GPZvhK8z5RFr4YE17dc04nI/VaNDCw4y1NALXGs+AHkjoPjLyGbWpi1S+gfq2sNB\n" + + "Ekkjp6COb/cb9yiFXOGVls7UOIjnVZVd0r7KaPFjZhYh82/f4PA/A1SnIKd1+nfH\n" + + "2yk7mSJNC7Z3qIVDL8MM/jBVwiC3uNe5GPB2uwhd7k5LGAVN3j4HQQGB0Sz+VC1h\n" + + "92oi6xDa+YBva2fvHuCd8P50DDjxmp9CemC7rnZ5j8egj88w14X44Xjb/Fd/ApG9\n" + + "e57NnbT7KM+Grw==\n" + + "-----END CERTIFICATE-----", + + // SHA256withRSA, curv prime256v1 + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 21 07:18:16 2028 GMT + // Authority Key Identifier: + // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C + "-----BEGIN CERTIFICATE-----\n" + + "MIICazCCAVOgAwIBAgIJAO2+yPcFryUUMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0yODA1MjEwNzE4MTZaMFUxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0D\n" + + "AQcDQgAE59MERNTlVZ1eeps8Z3Oue5ZkgQdPtD+WIE6tj3PbIKpxGPDxvfNP959A\n" + + "yQjEK/ehWQVrCMmNoEkIzY+IIBgB06MjMCEwHwYDVR0jBBgwFoAUDd2Tyf5LvTW3\n" + + "6Jl4kPvbWj3bFUwwDQYJKoZIhvcNAQELBQADggEBAFOTVEqs70ykhZiIdrEsF1Ra\n" + + "I3B2rLvwXZk52uSltk2/bzVvewA577ZCoxQ1pL7ynkisPfBN1uVYtHjM1VA3RC+4\n" + + "+TAK78dnI7otYjWoHp5rvs4l6c/IbOspS290IlNuDUxMErEm5wxIwj+Aukx/1y68\n" + + "hOyCvHBLMY2c1LskH1MMBbDuS1aI+lnGpToi+MoYObxGcV458vxuT8+wwV8Fkpvd\n" + + "ll8IIFmeNPRv+1E+lXbES6CSNCVaZ/lFhPgdgYKleN7sfspiz50DG4dqafuEAaX5\n" + + "xaK1NWXJxTRz0ROH/IUziyuDW6jphrlgit4+3NCzp6vP9hAJQ8Vhcj0n15BKHIQ=\n" + + "-----END CERTIFICATE-----", + + // SHA256withDSA, 2048 bits + // Validity + // Not Before: May 22 07:18:20 2018 GMT + // Not After : May 17 07:18:20 2038 GMT + // Authority Key Identifier: + // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 + "-----BEGIN CERTIFICATE-----\n" + + "MIIEnDCCBEGgAwIBAgIJAP/jh1qVhNVjMAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + + "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + + "Y2UwHhcNMTgwNTIyMDcxODIwWhcNMzgwNTE3MDcxODIwWjBVMQswCQYDVQQGEwJV\n" + + "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Ux\n" + + "GDAWBgNVBAMMD1JlZ3Jlc3Npb24gVGVzdDCCA0cwggI6BgcqhkjOOAQBMIICLQKC\n" + + "AQEAmlavgoJrMcjqWRVcDE2dmWAPREgnzQvneEDef68cprDzjSwvOs5QeFyx75ib\n" + + "ado1e6jO/rW1prCGWHDD1oA/Tn4Pk3vu0nUxzvl1qATc+aJbpUU5Op0bvp6LbCsQ\n" + + "QslV9FeRh7Eb7bP6gpc/kHCBzEgC1VCK7prccXWy+t6SMOHbND3h+UbckfSaUuaV\n" + + "sVJNTD1D6GElfRj4Nmz1BGPfSYvKorwNZEU3gXwFgtDoAcGx7tcyClLpDHfqRfw/\n" + + "7yiqLyeiP7D4hl5lMNouJWDlAdMFp0FMgS3s9VDFinIcr6VtBWMTG7+4+czHAB+3\n" + + "fvrwlqNzhBn3uFHrekN/w8fNxwIhAJo7Sae1za7IMW0Q6hE5B4b+s2B/FaKPoA4E\n" + + "jtZu13B9AoIBAQCOZqLMKfvqZWUgT0PQ3QjR7dAFdd06I9Y3+TOQzZk1+j+vw/6E\n" + + "X4vFItX4gihb/u5Q9CdmpwhVGi7bvo+7+/IKeTgoQ6f5+PSug7SrWWUQ5sPwaZui\n" + + "zXZJ5nTeZDucFc2yFx0wgnjbPwiUxZklOT7xGiOMtzOTa2koCz5KuIBL+/wPKKxm\n" + + "ypo9VoY9xfbdU6LMXZv/lpD5XTM9rYHr/vUTNkukvV6Hpm0YMEWhVZKUJiqCqTqG\n" + + "XHaleOxSw6uQWB/+TznifcC7gB48UOQjCqOKf5VuwQneJLhlhU/jhRV3xtr+hLZa\n" + + "hW1wYhVi8cjLDrZFKlgEQqhB4crnJU0mJY+tA4IBBQACggEAID0ezl00/X8mv7eb\n" + + "bzovum1+DEEP7FM57k6HZEG2N3ve4CW+0m9Cd+cWPz8wkZ+M0j/Eqa6F0IdbkXEc\n" + + "Q7CuzvUyJ57xQ3L/WCgXsiS+Bh8O4Mz7GwW22CGmHqafbVv+hKBfr8MkskO6GJUt\n" + + "SUF/CVLzB4gMIvZMH26tBP2xK+i7FeEK9kT+nGdzQSZBAhFYpEVCBplHZO24/OYq\n" + + "1DNoU327nUuXIhmsfA8N0PjiWbIZIjTPwBGr9H0LpATI7DIDNcvRRvtROP+pBU9y\n" + + "fuykPkptg9C0rCM9t06bukpOSaEz/2VIQdLE8fHYFA6pHZ6CIc2+5cfvMgTPhcjz\n" + + "W2jCt6MjMCEwHwYDVR0jBBgwFoAUdmae9zvdReU72XI8P/BUOYYxJlMwCwYJYIZI\n" + + "AWUDBAMCA0gAMEUCIQCeI5fN08b9BpOaHdc3zQNGjp24FOL/RxlBLeBAorswJgIg\n" + + "JEZ8DhYxQy1O7mmZ2UIT7op6epWMB4dENjs0qWPmcKo=\n" + + "-----END CERTIFICATE-----" + }; + + // Private key in the format of PKCS#8. + private final static String[] endEntityPrivateKeys = { + // + // EC private key related to cert endEntityCertStrs[0]. + // + "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgn5K03bpTLjEtFQRa\n" + + "JUtx22gtmGEvvSUSQdimhGthdtihRANCAARv72fTmp9ed8dRvTG1Ak1Lgl5KLoiM\n" + + "59bk2pyG8qd8l7L1WQnNHtAcu44RJ1/GVHurxghaCKHeJYsZ8H7DEeI6", + + // + // RSA private key related to cert endEntityCertStrs[1]. + // + "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzN8GhtZ9kinwC\n" + + "ALo+JYMNq8/rmZK+AJdQbEAJvFU0B+QuE1FA6weuJEHdfVDee870960LrAqW8T2O\n" + + "WcMOPsP7WPWvUIc7uazV+ryt9xBh2RqcO27gCUejy/5JJZfXowhcVFgOPZVUebI+\n" + + "2BuW1yDjMYC7BPvjoV0sj3i5eMmOrUg6v+/RUiXATk5FYfldz7lOP6gVYrQThrgY\n" + + "cOC0oqGfabvaE3nr8aQ8oaSC4/k1FLWphhX8QWR3JAw5XwnUzsdqJxJ+3g4vp4qN\n" + + "OuCj3f6QeT62/QNzpylUGdqVfdOisbxAjoFwePVdB3vygCUAL7+MXilzSbCLS6fj\n" + + "2R0r2BF9AgMBAAECggEASIkPkMCuw4WdTT44IwERus3IOIYOs2IP3BgEDyyvm4B6\n" + + "JP/iihDWKfA4zEl1Gqcni1RXMHswSglXra682J4kui02Ov+vzEeJIY37Ibn2YnP5\n" + + "ZjRT2s9GtI/S2o4hl8A/mQb2IMViFC+xKehTukhV4j5d6NPKk0XzLR7gcMjnYxwn\n" + + "l21fS6D2oM1xRG/di7sL+uLF8EXLRzfiWDNi12uQv4nwtxPKvuKhH6yzHt7YqMH0\n" + + "46pmDKDaxV4w1JdycjCb6NrCJOYZygoQobuZqOQ30UZoZsPJrtovkncFr1e+lNcO\n" + + "+aWDfOLCtTH046dEQh5oCShyXMybNlry/QHsOtHOwQKBgQDh2iIjs+FPpQy7Z3EX\n" + + "DGEvHYqPjrYO9an2KSRr1m9gzRlWYxKY46WmPKwjMerYtra0GP+TBHrgxsfO8tD2\n" + + "wUAII6sd1qup0a/Sutgf2JxVilLykd0+Ge4/Cs51tCdJ8EqDV2B6WhTewOY2EGvg\n" + + "JiKYkeNwgRX/9M9CFSAMAk0hUQKBgQDLJAartL3DoGUPjYtpJnfgGM23yAGl6G5r\n" + + "NSXDn80BiYIC1p0bG3N0xm3yAjqOtJAUj9jZbvDNbCe3GJfLARMr23legX4tRrgZ\n" + + "nEdKnAFKAKL01oM+A5/lHdkwaZI9yyv+hgSVdYzUjB8rDmzeVQzo1BT7vXypt2yV\n" + + "6O1OnUpCbQKBgA/0rzDChopv6KRcvHqaX0tK1P0rYeVQqb9ATNhpf9jg5Idb3HZ8\n" + + "rrk91BNwdVz2G5ZBpdynFl9G69rNAMJOCM4KZw5mmh4XOEq09Ivba8AHU7DbaTv3\n" + + "7QL7KnbaUWRB26HHzIMYVh0el6T+KADf8NXCiMTr+bfpfbL3dxoiF3zhAoGAbCJD\n" + + "Qse1dBs/cKYCHfkSOsI5T6kx52Tw0jS6Y4X/FOBjyqr/elyEexbdk8PH9Ar931Qr\n" + + "NKMvn8oA4iA/PRrXX7M2yi3YQrWwbkGYWYjtzrzEAdzmg+5eARKAeJrZ8/bg9l3U\n" + + "ttKaItJsDPlizn8rngy3FsJpR9aSAMK6/+wOiYkCgYEA1tZkI1rD1W9NYZtbI9BE\n" + + "qlJVFi2PBOJMKNuWdouPX3HLQ72GJSQff2BFzLTELjweVVJ0SvY4IipzpQOHQOBy\n" + + "5qh/p6izXJZh3IHtvwVBjHoEVplg1b2+I5e3jDCfqnwcQw82dW5SxOJMg1h/BD0I\n" + + "qAL3go42DYeYhu/WnECMeis=", + + // + // EC private key related to cert endEntityCertStrs[2]. + // + "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGVc7hICpmp91jbYe\n" + + "nrr8nYHD37RZP3VENY+szuA7WjuhRANCAATn0wRE1OVVnV56mzxnc657lmSBB0+0\n" + + "P5YgTq2Pc9sgqnEY8PG980/3n0DJCMQr96FZBWsIyY2gSQjNj4ggGAHT", + + // + // DSA private key related to cert endEntityCertStrs[3]. + // + "MIICZQIBADCCAjoGByqGSM44BAEwggItAoIBAQCaVq+CgmsxyOpZFVwMTZ2ZYA9E\n" + + "SCfNC+d4QN5/rxymsPONLC86zlB4XLHvmJtp2jV7qM7+tbWmsIZYcMPWgD9Ofg+T\n" + + "e+7SdTHO+XWoBNz5olulRTk6nRu+notsKxBCyVX0V5GHsRvts/qClz+QcIHMSALV\n" + + "UIrumtxxdbL63pIw4ds0PeH5RtyR9JpS5pWxUk1MPUPoYSV9GPg2bPUEY99Ji8qi\n" + + "vA1kRTeBfAWC0OgBwbHu1zIKUukMd+pF/D/vKKovJ6I/sPiGXmUw2i4lYOUB0wWn\n" + + "QUyBLez1UMWKchyvpW0FYxMbv7j5zMcAH7d++vCWo3OEGfe4Uet6Q3/Dx83HAiEA\n" + + "mjtJp7XNrsgxbRDqETkHhv6zYH8Voo+gDgSO1m7XcH0CggEBAI5moswp++plZSBP\n" + + "Q9DdCNHt0AV13Toj1jf5M5DNmTX6P6/D/oRfi8Ui1fiCKFv+7lD0J2anCFUaLtu+\n" + + "j7v78gp5OChDp/n49K6DtKtZZRDmw/Bpm6LNdknmdN5kO5wVzbIXHTCCeNs/CJTF\n" + + "mSU5PvEaI4y3M5NraSgLPkq4gEv7/A8orGbKmj1Whj3F9t1Tosxdm/+WkPldMz2t\n" + + "gev+9RM2S6S9XoembRgwRaFVkpQmKoKpOoZcdqV47FLDq5BYH/5POeJ9wLuAHjxQ\n" + + "5CMKo4p/lW7BCd4kuGWFT+OFFXfG2v6EtlqFbXBiFWLxyMsOtkUqWARCqEHhyucl\n" + + "TSYlj60EIgIgLfA75+8KcKxdN8mr6gzGjQe7jPFGG42Ejhd7Q2F4wuw=" + }; + + // Private key algorithm of endEntityPrivateKeys. + private final static String[] endEntityPrivateKeyAlgs = { + "EC", + "RSA", + "EC", + "DSA", + }; + + // Private key names of endEntityPrivateKeys. + private final static String[] endEntityPrivateKeyNames = { + "ecdsa", + "rsa", + "ec-rsa", + "dsa", + }; + + /* + * Create an instance of SSLContext with the specified trust/key materials. + */ + private SSLContext createSSLContext( + String[] trustedMaterials, + String[] keyMaterialCerts, + String[] keyMaterialKeys, + String[] keyMaterialKeyAlgs, + String[] keyMaterialKeyNames, + ContextParameters params) throws Exception { + + KeyStore ts = null; // trust store + KeyStore ks = null; // key store + char passphrase[] = "passphrase".toCharArray(); + + // Generate certificate from cert string. + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + + // Import the trused certs. + ByteArrayInputStream is; + if (trustedMaterials != null && trustedMaterials.length != 0) { + ts = KeyStore.getInstance("JKS"); + ts.load(null, null); + + Certificate[] trustedCert = + new Certificate[trustedMaterials.length]; + for (int i = 0; i < trustedMaterials.length; i++) { + String trustedCertStr = trustedMaterials[i]; + + is = new ByteArrayInputStream(trustedCertStr.getBytes()); + try { + trustedCert[i] = cf.generateCertificate(is); + } finally { + is.close(); + } + + ts.setCertificateEntry("trusted-cert-" + i, trustedCert[i]); + } + } + + // Import the key materials. + // + // Note that certification pathes bigger than one are not supported yet. + boolean hasKeyMaterials = + (keyMaterialCerts != null) && (keyMaterialCerts.length != 0) && + (keyMaterialKeys != null) && (keyMaterialKeys.length != 0) && + (keyMaterialKeyAlgs != null) && (keyMaterialKeyAlgs.length != 0) && + (keyMaterialCerts.length == keyMaterialKeys.length) && + (keyMaterialCerts.length == keyMaterialKeyAlgs.length); + if (hasKeyMaterials) { + ks = KeyStore.getInstance("JKS"); + ks.load(null, null); + + for (int i = 0; i < keyMaterialCerts.length; i++) { + String keyCertStr = keyMaterialCerts[i]; + + // generate the private key. + PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( + Base64.getMimeDecoder().decode(keyMaterialKeys[i])); + KeyFactory kf = + KeyFactory.getInstance(keyMaterialKeyAlgs[i]); + PrivateKey priKey = kf.generatePrivate(priKeySpec); + + // generate certificate chain + is = new ByteArrayInputStream(keyCertStr.getBytes()); + Certificate keyCert = null; + try { + keyCert = cf.generateCertificate(is); + } finally { + is.close(); + } + + Certificate[] chain = new Certificate[] { keyCert }; + + // import the key entry. + ks.setKeyEntry("cert-" + keyMaterialKeyNames[i], + priKey, passphrase, chain); + } + } + + // Create an SSLContext object. + TrustManagerFactory tmf = + TrustManagerFactory.getInstance(params.tmAlgorithm); + tmf.init(ts); + + SSLContext context = SSLContext.getInstance(params.contextProtocol); + if (hasKeyMaterials && ks != null) { + KeyManagerFactory kmf = + KeyManagerFactory.getInstance(params.kmAlgorithm); + kmf.init(ks, passphrase); + + context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + } else { + context.init(null, tmf.getTrustManagers(), null); + } + + return context; + } + + /* + * ================================================= + * Stuffs to boot up the client-server mode testing. + */ + private Thread clientThread = null; + private Thread serverThread = null; + private volatile Exception serverException = null; + private volatile Exception clientException = null; + + /* + * Should we run the client or server in a separate thread? + * Both sides can throw exceptions, but do you have a preference + * as to which side should be the main thread. + */ + private static final boolean separateServerThread = false; + + /* + * Boot up the testing, used to drive remainder of the test. + */ + private void bootup() throws Exception { + Exception startException = null; + try { + if (separateServerThread) { + startServer(true); + startClient(false); + } else { + startClient(true); + startServer(false); + } + } catch (Exception e) { + startException = e; + } + + /* + * Wait for other side to close down. + */ + if (separateServerThread) { + if (serverThread != null) { + serverThread.join(); + } + } else { + if (clientThread != null) { + clientThread.join(); + } + } + + /* + * When we get here, the test is pretty much over. + * Which side threw the error? + */ + Exception local; + Exception remote; + + if (separateServerThread) { + remote = serverException; + local = clientException; + } else { + remote = clientException; + local = serverException; + } + + Exception exception = null; + + /* + * Check various exception conditions. + */ + if ((local != null) && (remote != null)) { + // If both failed, return the curthread's exception. + local.initCause(remote); + exception = local; + } else if (local != null) { + exception = local; + } else if (remote != null) { + exception = remote; + } else if (startException != null) { + exception = startException; + } + + /* + * If there was an exception *AND* a startException, + * output it. + */ + if (exception != null) { + if (exception != startException && startException != null) { + exception.addSuppressed(startException); + } + throw exception; + } + + // Fall-through: no exception to throw! + } + + private void startServer(boolean newThread) throws Exception { + if (newThread) { + serverThread = new Thread() { + @Override + public void run() { + try { + doServerSide(); + } catch (Exception e) { + /* + * Our server thread just died. + * + * Release the client, if not active already... + */ + logException("Server died", e); + serverException = e; + } + } + }; + serverThread.start(); + } else { + try { + doServerSide(); + } catch (Exception e) { + logException("Server failed", e); + serverException = e; + } + } + } + + private void startClient(boolean newThread) throws Exception { + if (newThread) { + clientThread = new Thread() { + @Override + public void run() { + try { + doClientSide(); + } catch (Exception e) { + /* + * Our client thread just died. + */ + logException("Client died", e); + clientException = e; + } + } + }; + clientThread.start(); + } else { + try { + doClientSide(); + } catch (Exception e) { + logException("Client failed", e); + clientException = e; + } + } + } + + private synchronized void logException(String prefix, Throwable cause) { + System.out.println(prefix + ": " + cause); + cause.printStackTrace(System.out); + } +} diff --git a/src/test/lib/jdk/test/lib/security/TestCertificate.java b/src/test/lib/jdk/test/lib/security/TestCertificate.java new file mode 100644 index 00000000000..098cd2f1197 --- /dev/null +++ b/src/test/lib/jdk/test/lib/security/TestCertificate.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.security; + +import java.io.ByteArrayInputStream; +import java.security.cert.CertPath; +import java.security.cert.CertPathValidator; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.PKIXParameters; +import java.security.cert.TrustAnchor; +import java.security.cert.X509Certificate; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +// Certificates taken from old ValWithAnchorByName testcase *** +public enum TestCertificate { + // Subject: CN=SSLCertificate, O=SomeCompany + // Issuer: CN=Intermediate CA Cert, O=SomeCompany + // Validity: Tue Aug 30 14:37:19 PDT 2016 to Wed Aug 30 14:37:19 PDT 2017 + ONE("1000", + "CN=SSLCertificate, O=SomeCompany", + "CN=Intermediate CA Cert, O=SomeCompany", + -1063259762, + "-----BEGIN CERTIFICATE-----\n" + + "MIIDnTCCAoWgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTEUMBIGA1UEChMLU29t\n" + + "ZUNvbXBhbnkxHTAbBgNVBAMTFEludGVybWVkaWF0ZSBDQSBDZXJ0MB4XDTE2MDgz\n" + + "MDIxMzcxOVoXDTE3MDgzMDIxMzcxOVowLzEUMBIGA1UEChMLU29tZUNvbXBhbnkx\n" + + "FzAVBgNVBAMTDlNTTENlcnRpZmljYXRlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + + "MIIBCgKCAQEAjgv8KKE4CO0rbCjRLA1hXjRiSq30jeusCJ8frbRG+QOBgQ3j6jgc\n" + + "vk5wG1aTu7R4AFn0/HRDMzP9ZbRlZVIbJUTd8YiaNyZeyWapPnxHWrPCd5e1xopk\n" + + "ElieDdEH5FiLGtIrWy56CGA1hfQb1vUVYegyeY+TTtMFVHt0PrmMk4ZRgj/GtVNp\n" + + "BQQYIzaYAcrcWMeCn30ZrhaGAL1hsdgmEVV1wsTD4JeNMSwLwMYem7fg8ondGZIR\n" + + "kZuGtuSdOHu4Xz+mgDNXTeX/Bp/dQFucxCG+FOOM9Hoz72RY2W8YqgL38RlnwYWp\n" + + "nUNxhXWFH6vyINRQVEu3IgahR6HXjxM7LwIDAQABo4G8MIG5MBQGA1UdEQQNMAuC\n" + + "CWxvY2FsaG9zdDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9s\n" + + "b2NhbGhvc3Q6NDIzMzMwHwYDVR0jBBgwFoAUYT525lwHCI4CmuWs8a7poaeKRJ4w\n" + + "HQYDVR0OBBYEFCaQnOX4L1ovqyfeKuoay+kI+lXgMA4GA1UdDwEB/wQEAwIFoDAd\n" + + "BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDQYJKoZIhvcNAQELBQADggEB\n" + + "AD8dqQIqFasJcL8lm4mPTsBl0JgNiN8tQcXM7VCvcH+yDvEyh9vudDjuhpSORqPq\n" + + "f1o/EvJ+gfs269mBnYQujYRvmSd6EAcBntv5zn6amOh03o6PqTY9KaUC/mL9hB84\n" + + "Y5/LYioP16sME7egKnlrGUgKh0ZvGzm7c3SYx3Z5YoeFBOkZajc7Jm+cBw/uBQkF\n" + + "a9mLEczIvOgkq1wto8vr2ptH1gEuvFRcorN3muvq34bk40G08+AHlP3fCLFpI3FA\n" + + "IStJLJZRcO+Ib4sOcKuaBGnuMo/QVOCEMDUs6RgiWtSd93OZKFIUOASVp6YIkcSs\n" + + "5/rmc06sICqBjLfPEB68Jjw=\n" + + "-----END CERTIFICATE-----"), + // Subject: CN=Intermediate CA Cert, O=SomeCompany + // Issuer: CN=Root CA Cert, O=SomeCompany + // Validity: Sun Aug 07 14:37:19 PDT 2016 to Tue Aug 07 14:37:19 PDT 2018 + TWO("64", + "CN=Intermediate CA Cert, O=SomeCompany", + "CN=Root CA Cert, O=SomeCompany", + -927189373, + "-----BEGIN CERTIFICATE-----\n" + + "MIIDdjCCAl6gAwIBAgIBZDANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + + "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDgwNzIxMzcxOVoX\n" + + "DTE4MDgwNzIxMzcxOVowNTEUMBIGA1UEChMLU29tZUNvbXBhbnkxHTAbBgNVBAMT\n" + + "FEludGVybWVkaWF0ZSBDQSBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" + + "CgKCAQEAnJR5CnE7GKlQjigExSJ6hHu302mc0PcA6TDgsIitPYD/r8RBbBuE51OQ\n" + + "7IP7AXmfPUV3/+pO/uxx6mgY5O6XeUl7KadhVPtPcL0BVVevCSOdTMVa3iV4zRpa\n" + + "C6Uy2ouUFnafKnDtlbieggyETUoNgVNJYA9L0XNhtSnENoLHC4Pq0v8OsNtsOWFR\n" + + "NiMTOA49NNDBw85WgPyFAxjqO4z0J0zxdWq3W4rSMB8xrkulv2Rvj3GcfYJK/ab8\n" + + "V1IJ6PMWCpujASY3BzvYPnN7BKuBjbWJPgZdPYfX1cxeG80u0tOuMfWWiNONSMSA\n" + + "7m9y304QA0gKqlrFFn9U4hU89kv1IwIDAQABo4GYMIGVMA8GA1UdEwEB/wQFMAMB\n" + + "Af8wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzABhhZodHRwOi8vbG9jYWxob3N0\n" + + "OjM5MTM0MB8GA1UdIwQYMBaAFJNMsejEyJUB9tiWycVczvpiMVQZMB0GA1UdDgQW\n" + + "BBRhPnbmXAcIjgKa5azxrumhp4pEnjAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcN\n" + + "AQELBQADggEBAE4nOFdW9OirPnRvxihQXYL9CXLuGQz5tr0XgN8wSY6Un9b6CRiK\n" + + "7obgIGimVdhvUC1qdRcwJqgOfJ2/jR5/5Qo0TVp+ww4dHNdUoj73tagJ7jTu0ZMz\n" + + "5Zdp0uwd4RD/syvTeVcbPc3m4awtgEvRgzpDMcSeKPZWInlo7fbnowKSAUAfO8de\n" + + "0cDkxEBkzPIzGNu256cdLZOqOK9wLJ9mQ0zKgi/2NsldNc2pl/6jkGpA6uL5lJsm\n" + + "fo9sDusWNHV1YggqjDQ19hrf40VuuC9GFl/qAW3marMuEzY/NiKVUxty1q1s48SO\n" + + "g5LoEPDDkbygOt7ICL3HYG1VufhC1Q2YY9c=\n" + + "-----END CERTIFICATE-----"), + // Subject: CN=Root CA Cert, O=SomeCompany + // Issuer: CN=Root CA Cert, O=SomeCompany + // Validity: Fri Jul 08 14:37:18 PDT 2016 to Fri Jun 28 14:37:18 PDT 2019 + ROOT_CA("1", + "CN=Root CA Cert, O=SomeCompany", + "CN=Root CA Cert, O=SomeCompany", + -1299818863, + "-----BEGIN CERTIFICATE-----\n" + + "MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMRQwEgYDVQQKEwtTb21l\n" + + "Q29tcGFueTEVMBMGA1UEAxMMUm9vdCBDQSBDZXJ0MB4XDTE2MDcwODIxMzcxOFoX\n" + + "DTE5MDYyODIxMzcxOFowLTEUMBIGA1UEChMLU29tZUNvbXBhbnkxFTATBgNVBAMT\n" + + "DFJvb3QgQ0EgQ2VydDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIlN\n" + + "M3WYEqkU2elXEZrV9QSDbDKwyaLEHafLFciH8Edoag3q/7jEzFJxI7JZ831tdbWQ\n" + + "Bm6Hgo+8pvetOFW1BckL8eIjyOONP2CKfFaeMaozsWi1cgxa+rjpU/Rekc+zBqvv\n" + + "y4Sr97TwT6nQiLlgjC1nCfR1SVpO51qoDChS7n785rsKEZxw/p+kkVWSZffU7zN9\n" + + "c645cPg//L/kjiyeKMkaquGQOYS68gQgy8YZXQv1E3l/8e8Ci1s1DYA5wpCbaBqg\n" + + "Tw84Rr4zlUEQBgXzQlRt+mPzeaDpdG1EeGkXrcdkZ+0EMELoOVXOEn6VNsz6vT3I\n" + + "KrnvQBSnN06xq/iWwC0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME\n" + + "GDAWgBSTTLHoxMiVAfbYlsnFXM76YjFUGTAdBgNVHQ4EFgQUk0yx6MTIlQH22JbJ\n" + + "xVzO+mIxVBkwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAAi+Nl\n" + + "sxP9t2IhiZIHRJGSBZuQlXIjwYIwbq3ZWc/ApZ+0oxtl7DYQi5uRNt8/opcGNCHc\n" + + "IY0fG93SbkDubXbxPYBW6D/RUjbz59ZryaP5ym55p1MjHTOqy+AM8g41xNTJikc3\n" + + "UUFXXnckeFbawijCsb7vf71owzKuxgBXi9n1rmXXtncKoA/LrUVXoUlKefdgDnsU\n" + + "sl3Q29eibE3HSqziMMoAOLm0jjekFGWIgLeTtyRYR1d0dNaUwsHTrQpPjxxUTn1x\n" + + "sAPpXKfzPnsYAZeeiaaE75GwbWlHzrNinvxdZQd0zctpfBJfVqD/+lWANlw+rOaK\n" + + "J2GyCaJINsyaI/I2\n" + + "-----END CERTIFICATE-----"); + + public String serialNumber; + public String algorithm; + public String subject; + public String issuer; + public String keyType; + public long certId; + public int keyLength; + public String encoded; + + TestCertificate(String serialNumber, String subject, String issuer, + long certId, String encoded) { + this.serialNumber = serialNumber; + this.subject = subject; + this.issuer = issuer; + this.algorithm = "SHA256withRSA"; + this.encoded = encoded; + this.certId = certId; + this.keyType = "RSA"; + this.keyLength = 2048; + } + + public X509Certificate generate(CertificateFactory cf) throws CertificateException { + ByteArrayInputStream is = new ByteArrayInputStream(encoded.getBytes()); + return (X509Certificate) cf.generateCertificate(is); + } + + public static void generateChain(boolean selfSignedTest) throws Exception { + // Do path validation as if it is always Tue, 06 Sep 2016 22:12:21 GMT + // This value is within the lifetimes of all certificates. + Date testDate = new Date(1473199941000L); + + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + X509Certificate c1 = TestCertificate.ONE.generate(cf); + X509Certificate c2 = TestCertificate.TWO.generate(cf); + X509Certificate ca = TestCertificate.ROOT_CA.generate(cf); + + TrustAnchor ta = new TrustAnchor(ca, null); + CertPathValidator validator = CertPathValidator.getInstance("PKIX"); + + PKIXParameters params = new PKIXParameters(Collections.singleton(ta)); + params.setRevocationEnabled(false); + params.setDate(testDate); + if (!selfSignedTest) { + CertPath path = cf.generateCertPath(List.of(c1, c2)); + validator.validate(path, params); + } else { + CertPath path = cf.generateCertPath(List.of(ca)); + validator.validate(path, params); + } + } +} \ No newline at end of file diff --git a/src/test/lib/jdk/test/lib/security/TestTLSHandshake.java b/src/test/lib/jdk/test/lib/security/TestTLSHandshake.java new file mode 100644 index 00000000000..309a3f8ef2c --- /dev/null +++ b/src/test/lib/jdk/test/lib/security/TestTLSHandshake.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.security; + +import java.io.*; + +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocket; + + +public final class TestTLSHandshake extends SSLSocketTest { + + public static final String CIPHER_SUITE = + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"; + public static final long HASHCODE = -1057291798L; + public static final long ANCHOR_HASHCODE = 1688661792L; + public static final String CERT_SERIAL = "edbec8f705af2514"; + public static final String ANCHOR_CERT_SERIAL = "8e191778b2f331be"; + + public String protocolVersion; + public String peerHost; + public int peerPort; + + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslIS.read(); + sslOS.write(85); + sslOS.flush(); + } + + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + socket.setEnabledCipherSuites(new String[] { CIPHER_SUITE }); + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + + sslOS.write(280); + sslOS.flush(); + sslIS.read(); + + SSLSession sslSession = socket.getSession(); + protocolVersion = sslSession.getProtocol(); + peerHost = sslSession.getPeerHost(); + peerPort = sslSession.getPeerPort(); + } +} diff --git a/src/test/lib/jdk/test/lib/util/JarUtils.java b/src/test/lib/jdk/test/lib/util/JarUtils.java index f7dd5599809..8f8d0d9ffb0 100644 --- a/src/test/lib/jdk/test/lib/util/JarUtils.java +++ b/src/test/lib/jdk/test/lib/util/JarUtils.java @@ -24,26 +24,98 @@ package jdk.test.lib.util; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import java.util.stream.Stream; /** * Common library for various test jar file utility functions. */ public final class JarUtils { + private JarUtils() { } + + /** + * Creates a JAR file. + * + * Equivalent to {@code jar cfm <jarfile> <manifest> -C <dir> file...} + * + * The input files are resolved against the given directory. Any input + * files that are directories are processed recursively. + */ + public static void createJarFile(Path jarfile, Manifest man, Path dir, Path... files) + throws IOException + { + // create the target directory + Path parent = jarfile.getParent(); + if (parent != null) { + Files.createDirectories(parent); + } + + List<Path> entries = findAllRegularFiles(dir, files); + + try (OutputStream out = Files.newOutputStream(jarfile); + JarOutputStream jos = new JarOutputStream(out)) { + if (man != null) { + JarEntry je = new JarEntry(JarFile.MANIFEST_NAME); + jos.putNextEntry(je); + man.write(jos); + jos.closeEntry(); + } + + for (Path entry : entries) { + String name = toJarEntryName(entry); + jos.putNextEntry(new JarEntry(name)); + Files.copy(dir.resolve(entry), jos); + jos.closeEntry(); + } + } + } + + /** + * Creates a JAR file. + * + * Equivalent to {@code jar cf <jarfile> -C <dir> file...} + * + * The input files are resolved against the given directory. Any input + * files that are directories are processed recursively. + */ + public static void createJarFile(Path jarfile, Path dir, Path... files) + throws IOException + { + createJarFile(jarfile, null, dir, files); + } + + /** + * Creates a JAR file. + * + * Equivalent to {@code jar cf <jarfile> -C <dir> file...} + * + * The input files are resolved against the given directory. Any input + * files that are directories are processed recursively. + */ + public static void createJarFile(Path jarfile, Path dir, String... input) + throws IOException + { + Path[] paths = Stream.of(input).map(Paths::get).toArray(Path[]::new); + createJarFile(jarfile, dir, paths); + } /** * Create jar file with specified files. If a specified file does not exist, @@ -194,4 +266,26 @@ private static void updateEntry(JarOutputStream jos, String name, Object content } } } + + /** + * Maps a file path to the equivalent name in a JAR file + */ + private static String toJarEntryName(Path file) { + Path normalized = file.normalize(); + return normalized.subpath(0, normalized.getNameCount()) // drop root + .toString() + .replace(File.separatorChar, '/'); + } + + private static List<Path> findAllRegularFiles(Path dir, Path[] files) throws IOException { + List<Path> entries = new ArrayList<>(); + for (Path file : files) { + try (Stream<Path> stream = Files.find(dir.resolve(file), Integer.MAX_VALUE, + (p, attrs) -> attrs.isRegularFile())) { + stream.map(dir::relativize) + .forEach(entries::add); + } + } + return entries; + } } diff --git a/src/test/lib/jtreg/SkippedException.java b/src/test/lib/jtreg/SkippedException.java new file mode 100644 index 00000000000..ac1afa5d0aa --- /dev/null +++ b/src/test/lib/jtreg/SkippedException.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jtreg; + +/** + * {@code SkippedException} is an exception treaded by jtreg as an indication + * of skipped status. + */ +public final class SkippedException extends RuntimeException { + public SkippedException(String s, Throwable t) { + super(s, t); + } + + public SkippedException(String s) { + super(s); + } +} diff --git a/src/test/lib/sun/hotspot/WhiteBox.java b/src/test/lib/sun/hotspot/WhiteBox.java index 4f78905aa96..003c987bd40 100644 --- a/src/test/lib/sun/hotspot/WhiteBox.java +++ b/src/test/lib/sun/hotspot/WhiteBox.java @@ -325,6 +325,7 @@ public boolean enqueueInitializerForCompilation(Class<?> aClass, int compLevel) return enqueueInitializerForCompilation0(aClass, compLevel); } private native void clearMethodState0(Executable method); + public native void markMethodProfiled(Executable method); public void clearMethodState(Executable method) { Objects.requireNonNull(method); clearMethodState0(method);